Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(catalog): add catalog composite #559

Merged
merged 11 commits into from
Feb 11, 2020
69 changes: 69 additions & 0 deletions demo/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,75 @@ export const environment: Environment = {
title: 'Controling tooltip format',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/igo_gouvouvert.fcgi',
tooltipType: 'abstract' // or title
},
{
id: 'fusion_catalog',
title: '(composite catalog) fusion catalog',
composite: [
{
id: 'tq_swtq',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/swtq'
},
{
id: 'rn_wmts',
url: 'https://servicesmatriciels.mern.gouv.qc.ca/erdas-iws/ogc/wmts/Cartes_Images',
type: 'wmts',
crossOrigin: true,
matrixSet: 'EPSG_3857',
version: '1.0.0'
}
]
},
{
id: 'group_impose',
title: '(composite catalog) group imposed and unique layer title for same source',
composite: [
{
id: 'tq_swtq',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/swtq',
regFilters: ['zpegt'],
groupImpose: {id: 'zpegt', title: 'zpegt'}
},
{
id: 'Gououvert',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/igo_gouvouvert.fcgi',
regFilters: ['zpegt'],
groupImpose: {id: 'zpegt', title: 'zpegt'}
},
{
id: 'Gououvert',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/igo_gouvouvert.fcgi',
regFilters: ['zpegt'],
groupImpose: {id: 'zpegt', title: 'zpegt'}
},
{
id: 'rn_wmts',
url: 'https://servicesmatriciels.mern.gouv.qc.ca/erdas-iws/ogc/wmts/Cartes_Images',
type: 'wmts',
crossOrigin: true,
matrixSet: 'EPSG_3857',
version: '1.0.0',
groupImpose: {id: 'cartetopo', title: 'Carte topo échelle 1/20 000'}
}
]
},
{
id: 'tag_layernametitle',
title: '(composite catalog) tag source on same layer title',
composite: [
{
id: 'tq_swtq',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/swtq',
regFilters: ['limtn_charg'],
groupImpose: {id: 'mix_swtq_gouv', title: 'mix same name layer'}
},
{
id: 'Gououvert',
url: 'https://geoegl.msp.gouv.qc.ca/apis/ws/igo_gouvouvert.fcgi',
regFilters: ['limtn_charg'],
groupImpose: {id: 'mix_swtq_gouv', title: 'mix same name layer'}
}
]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ <h4 class="igo-catalog-group-title" id="catalog-group-title" mat-line matTooltip

<div #items>
<ng-template ngFor let-item [ngForOf]="store.view.all$() | async">
<ng-container *ngIf="isGroup(item)"></ng-container>
<ng-container *ngIf="isGroup(item)">
<!-- todo: add display ans manage CatalogItemGroup -->
</ng-container>
<ng-container *ngIf="isLayer(item)">
<igo-catalog-browser-layer
igoListItem
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<mat-list-item>
<mat-icon mat-list-avatar svgIcon="blank"></mat-icon>
<mat-icon *ngIf="haveGroup()" mat-list-avatar svgIcon="blank"></mat-icon>
<h4 mat-line matTooltipShowDelay="500" [ngClass]="(catalogAllowLegend)?'igo-cataloglayer-title':''" (click)="askForLegend($event)" [matTooltip]="title">{{title}}</h4>

<igo-metadata-button [layer]="layer"></igo-metadata-button>

<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ export class CatalogBrowserLayerComponent implements OnInit {
}
}

haveGroup(): boolean {
return !(!this.layer.address || this.layer.address.split('.').length === 1);
}

isInResolutionsRange(): boolean {
const minResolution = this.layer.options.minResolution;
const maxResolution = this.layer.options.maxResolution;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Component, Input, ChangeDetectionStrategy } from '@angular/core';

import { getEntityTitle } from '@igo2/common';
import { IgoMap } from '../../map';

import { Catalog } from '../shared/catalog.interface';
import { Catalog } from '../shared/catalog.abstract';

/**
* Catalog library item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {

import { EntityStore } from '@igo2/common';
import { IgoMap } from '../../map';
import { Catalog } from '../shared/catalog.interface';
import { Catalog } from '../shared/catalog.abstract';

/**
* Component to browse a list of available catalogs
Expand Down
114 changes: 114 additions & 0 deletions packages/geo/src/lib/catalog/shared/catalog.abstract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import { Observable } from 'rxjs';

import { TooltipType } from '../../layer';
import { TimeFilterOptions } from '../../filter';
import { QueryFormat, QueryHtmlTarget } from '../../query';

import { ICatalog, ICompositeCatalog , CatalogItem, CatalogItemGroup } from './catalog.interface';
import { CatalogService } from './catalog.service';
import { TypeCatalog, TypeCatalogStrings } from './catalog.enum';

export abstract class Catalog implements ICatalog {

// ICatalog -----------------------------
id: string;
title: string;
url: string;
items?: CatalogItem[];
type?: TypeCatalogStrings;
version?: string;
matrixSet?: string;
requestEncoding?: string;
regFilters?: string[];
groupImpose?: CatalogItemGroup;
timeFilter?: TimeFilterOptions;
queryFormat?: QueryFormat;
queryHtmlTarget?: QueryHtmlTarget;
queryParams?: { [key: string]: string; };
sourceOptions?: { [key: string]: any; };
count?: number;
tooltipType?: TooltipType.ABSTRACT | TooltipType.TITLE;
sortDirection?: 'asc' | 'desc';
setCrossOriginAnonymous?: boolean;
showLegend?: boolean;
// ICatalog -----------------------------

protected catalogService: CatalogService;

constructor(options: Catalog, service: CatalogService) {
Object.assign(this, options);
this.catalogService = service;
}

public abstract collectCatalogItems(): Observable<CatalogItem[]>;
}

class WMSCatalog extends Catalog {
constructor(options: Catalog, service: CatalogService) {
super(options, service);
const sType: string = TypeCatalog[TypeCatalog.wms];
this.type = TypeCatalog[sType];
}

public collectCatalogItems(): Observable<CatalogItem[]> {
return this.catalogService.loadCatalogWMSLayerItems(this);
}
}

class WMTSCatalog extends Catalog {
constructor(options: Catalog, service: CatalogService) {
super(options, service);
const sType: string = TypeCatalog[TypeCatalog.wmts];
this.type = TypeCatalog[sType];
}

public collectCatalogItems(): Observable<CatalogItem[]> {
return this.catalogService.loadCatalogWMTSLayerItems(this);
}
}

class BaselayersCatalog extends Catalog {
constructor(options: Catalog, service: CatalogService) {
super(options, service);
const sType: string = TypeCatalog[TypeCatalog.baselayers];
this.type = TypeCatalog[sType];
}

public collectCatalogItems(): Observable<CatalogItemGroup[]> {
return this.catalogService.loadCatalogBaseLayerItems(this);
}
}

export class CompositeCatalog extends Catalog implements ICompositeCatalog {
composite: ICatalog[];

constructor(options: Catalog, service: CatalogService) {
super(options, service);
const sType: string = TypeCatalog[TypeCatalog.composite];
this.type = TypeCatalog[sType];
this.url = null;
}

public collectCatalogItems(): Observable<CatalogItem[]> {
return this.catalogService.loadCatalogCompositeLayerItems(this);
}
}

export class CatalogFactory {

public static createInstanceCatalog(options: Catalog, service: CatalogService): Catalog {

let catalog: Catalog;
if (options.hasOwnProperty('composite')) {
catalog = new CompositeCatalog(options, service);
} else if (options.type === TypeCatalog[TypeCatalog.baselayers]) {
catalog = new BaselayersCatalog(options, service);
} else if (options.type === TypeCatalog[TypeCatalog.wmts]) {
catalog = new WMTSCatalog(options, service);
} else {
catalog = new WMSCatalog(options, service);
}

return catalog;
}
}
6 changes: 6 additions & 0 deletions packages/geo/src/lib/catalog/shared/catalog.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ export enum CatalogItemType {
Layer = 'layer',
Group = 'group'
}

export enum TypeCatalog {
wms, wmts, baselayers, composite
}

export type TypeCatalogStrings = keyof typeof TypeCatalog;
14 changes: 10 additions & 4 deletions packages/geo/src/lib/catalog/shared/catalog.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ import { TooltipType } from '../../layer';
import { TimeFilterOptions } from '../../filter';
import { QueryFormat, QueryHtmlTarget } from '../../query';

import { CatalogItemType } from './catalog.enum';
import { CatalogItemType, TypeCatalogStrings } from './catalog.enum';

export interface Catalog {
export interface ICatalog {
id: string;
title: string;
url: string;
items?: CatalogItem[];
type?: string;
type?: TypeCatalogStrings;
version?: string;
matrixSet?: string;
requestEncoding?: string;
regFilters?: string[];
groupImpose?: CatalogItemGroup; // only use by ICompositeCatalog object (id and title)
timeFilter?: TimeFilterOptions;
queryFormat?: QueryFormat;
queryHtmlTarget?: QueryHtmlTarget;
Expand All @@ -29,10 +30,15 @@ export interface Catalog {
showLegend?: boolean;
}

export interface ICompositeCatalog extends ICatalog {
composite: ICatalog[];
}

export interface CatalogItem {
id: string;
title: string;
type: CatalogItemType;
address?: string;
}

export interface CatalogItemLayer<L = MetadataLayerOptions>
Expand All @@ -50,6 +56,6 @@ export interface CatalogItemState extends EntityState {

export interface CatalogServiceOptions {
baseLayers?: boolean;
sources?: Catalog[];
sources?: (ICatalog|ICompositeCatalog)[];
sourcesUrl?: string;
}
Loading