Skip to content

Commit

Permalink
feat(wfs): creating an indepedant source for from wfs-datasource (#120)
Browse files Browse the repository at this point in the history
Creating an indepedant source for from wfs-datasource. Previously dependent of feature-datasource. Adding possibilities for creating an initial filter (into context.json) for wfs datasets based on a new IGO object, called IgoOgcFilterObject.

This structure for logical filters:
{"logical" : "Or", "filters": [ {"operator" : "During","propertyName" : "date", "begin" : "2014" ,"end" : "2016"}, {"operator" : "PropertyIsEqualTo","propertyName" : "name", "pattern" : "Québec"}, {"operator" : "PropertyIsLike","propertyName" : "number", "pattern" : "3*"} ] },
This structure for simple OGC filters:
{"operator" : "PropertyIsLike","propertyName" : "number", "pattern" : "3*"}
In this pull request, I renamed some properties to clearly separate TimeFilter from OgcFilter. Next pull request will use these properties to populate a component.

Documentation for additionnal mandatory and optional parameters for wfs datasources will soon follow.

Tested on WFS with :

Mapserver 7.0.7 and 7.0.3 (https://ws.mapserver.transports.gouv.qc.ca/swtq?service=wfs&request=getcapabilities) == > GML 3.1.1 and geojson

ArcGIS (https://infogeo.education.gouv.qc.ca/arcgis/services/DonneesOuvertes/SW_MEES/MapServer/WFSServer?request=GetCapabilities&service=WFS) == > GML 3.1.1

Geomedia == > GML 3.1.1
  • Loading branch information
pelord authored and mbarbeau committed Mar 1, 2018
1 parent 79b1f75 commit 96f66e1
Show file tree
Hide file tree
Showing 31 changed files with 732 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/demo-app/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
</mat-card>

<mat-card>
<mat-card-subtitle>Filter module</mat-card-subtitle>
<mat-card-subtitle>Time Filter module</mat-card-subtitle>
<mat-card-title>time-filter.component</mat-card-title>
<mat-card-content>
<igo-time-filter-list igoTimeFilterListBinding></igo-time-filter-list>
Expand Down
8 changes: 8 additions & 0 deletions src/demo-app/contexts/_contexts.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
{
"uri": "_default",
"title": "Default Context"
},
{
"uri": "wfs_test",
"title": "wfs_test"
},
{
"uri": "wfs_test",
"title": "WFS examples"
},
{
"uri": "embacle",
Expand Down
12 changes: 6 additions & 6 deletions src/demo-app/contexts/_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"type": "wms",
"optionsFromCapabilities": true,
"source": {
"url": "/ws/igo_gouvouvert.fcgi",
"url": "https://geoegl.msp.gouv.qc.ca/ws/igo_gouvouvert.fcgi",
"params": {
"layers": "vg_observation_v_inondation_embacle_wmst",
"version": "1.3.0"
Expand All @@ -36,19 +36,19 @@
"range": true,
"type": "date",
"style": "slider",
"timeinterval": 3153600,
"step": 3153600
"timeinterval": 3153600,
"step": 3153600
}
},
{
{
"type": "wms",
"opacity": 0.6,
"optionsFromCapabilities": true,
"metadata": {
"extern": true
},
"source": {
"url": "/ws/adnInternetV2.fcgi",
"url": "https://geoegl.msp.gouv.qc.ca/ws/adnInternetV2.fcgi",
"params": {
"layers": "adn_reg_admin_public_v",
"version": "1.3.0"
Expand All @@ -63,7 +63,7 @@
"extern": true
},
"source": {
"url": "/ws/igo_gouvouvert.fcgi",
"url": "https://geoegl.msp.gouv.qc.ca/ws/igo_gouvouvert.fcgi",
"params": {
"layers": "MELS_CS_ANGLO_S",
"version": "1.3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/demo-app/contexts/embacle.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"title": "Bassin (WFS)",
"type" : "wfs",
"source":{
"url" : "/ws/adnInternetV2.fcgi?service=WFS&version=1.1.0&request=GetFeature&typename=adn_bassin_n1_simplify_500&srsname=EPSG:3857"
"url" : "https://geoegl.msp.gouv.qc.ca/ws/adnInternetV2.fcgi?service=WFS&version=1.1.0&request=GetFeature&typename=adn_bassin_n1_simplify_500&srsname=EPSG:3857"
},
"style" : {
"stroke" : {
Expand Down
177 changes: 177 additions & 0 deletions src/demo-app/contexts/wfs_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
{
"uri": "test_wfs",
"title": "test_wfs",
"map": {
"view": {
"projection": "EPSG:3857",
"center": [-72, 50],
"zoom": 7,
"geolocate": true
}
},

"layers": [{
"title": "OSM",
"type": "osm"
},
{
"name": "cs sans filtre gml",
"visible": false,
"id": "cs sans filtre gml",
"title": "cs sans filtre gml",
"type": "wfs",
"source": {
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq",
"featureTypes": "bgr_v_centr_servc_geomt_act",
"fieldNameGeometry": "geometry",
"maxFeatures": 10000,
"version": "2.0.0",
"outputFormat": "text/xml; subtype=gml/3.1.1",
"outputFormatDownload": "shp"
}
},
{
"name": "cs avec filtre gml",
"visible": false,
"id": "cs avec filtre gml",
"title": "cs avec filtre gml",
"type": "wfs",
"source": {
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq",
"featureTypes": "bgr_v_centr_servc_geomt_act",
"fieldNameGeometry": "geometry",
"maxFeatures": 10000,
"version": "2.0.0",
"outputFormat": "text/xml; subtype=gml/3.1.1",
"outputFormatDownload": "shp"
},
"filters": {
"logical": "Or",
"filters": [
{"operator": "During", "propertyName": "dat_debut_", "begin": "2014", "end": "2016"},
{"operator": "PropertyIsEqualTo", "propertyName": "nom_unite_", "pattern": "CS de Lévis"},
{"operator": "PropertyIsLike", "propertyName": "ide_unite_", "pattern": "3*"}
]
}
},
{
"name": "cs avec filtre geojson",
"visible": false,
"id": "cs avec filtre",
"title": "cs avec filtre",
"type": "wfs",
"source": {
"url": "https://ws.mapserver.transports.gouv.qc.ca/swtq",
"featureTypes": "bgr_v_centr_servc_geomt_act",
"fieldNameGeometry": "geometry",
"maxFeatures": 10000,
"version": "2.0.0",
"outputFormat": "geojson",
"outputFormatDownload": "shp"
},
"filters": {
"logical": "Or",
"filters": [
{"operator": "During", "propertyName": "dat_debut_", "begin": "2014", "end": "2016"},
{"operator": "PropertyIsEqualTo", "propertyName": "nom_unite_", "pattern": "CS de Lévis"},
{"operator": "PropertyIsLike", "propertyName": "ide_unite_", "pattern": "3*"}
]
}
},
{
"name": "vg avec filtre",
"visible": false,
"id": "vg",
"title": "vg avec filtre",
"type": "wfs",
"source": {
"url": "https://geoegl.msp.gouv.qc.ca/ws/igo_gouvouvert.fcgi",
"featureTypes": "vg_observation_v_inondation_embacle_wmst",
"fieldNameGeometry": "geometry",
"maxFeatures": 10000,
"version": "2.0.0",
"outputFormat": "geojson",
"outputFormatDownload": "shp"
},
"filters": {"operator": "PropertyIsEqualTo", "propertyName": "cap_severite", "pattern": "Mineure"}
},
{
"name": "vg sans filtre",
"visible": false,
"id": "vg sans filtre",
"title": "vg sans filtre",
"type": "wfs",
"source": {
"url": "https://geoegl.msp.gouv.qc.ca/ws/igo_gouvouvert.fcgi",
"featureTypes": "vg_observation_v_inondation_embacle_wmst",
"fieldNameGeometry": "geometry",
"maxFeatures": 10000,
"version": "2.0.0",
"outputFormat": "geojson",
"outputFormatDownload": "shp"
}
},
{
"name": "edu sans filtre",
"visible": false,
"id": "edu sans filtre",
"title": "edu sans filtre",
"type": "wfs",
"minScaleDenom": 200000,
"maxScaleDenom": 5000000,
"source": {
"url": "https://infogeo.education.gouv.qc.ca/arcgis/services/DonneesOuvertes/SW_MEES/MapServer/WFSServer",
"featureTypes": "Établissement_privé",
"fieldNameGeometry": "SHAPE",
"maxFeatures": 10000,
"version": "2.0.0",
"outputFormat": "text/xml; subType=gml/3.1.1"
}
},
{
"name": "edu avec filtre",
"visible": false,
"id": "edu avec filtre",
"title": "edu avec filtre",
"type": "wfs",
"minScaleDenom": 200000,
"maxScaleDenom": 5000000,
"source": {
"url": "https://infogeo.education.gouv.qc.ca/arcgis/services/DonneesOuvertes/SW_MEES/MapServer/WFSServer",
"featureTypes": "Établissement_privé",
"fieldNameGeometry": "SHAPE",
"maxFeatures": 10000,
"version": "2.0.0",
"outputFormat": "text/xml; subType=gml/3.1.1"

},
"filters": {"operator": "PropertyIsLike", "propertyName": "Code_d_organisme", "pattern": "01*"}
}

],
"toolbar": [
"searchResults",
"mapDetails",
"timeAnalysis",
"contextManager",
"print"
],

"tools": [
{
"name": "searchResults"
},
{
"name": "mapDetails"
},
{
"name": "timeAnalysis"
},
{
"name": "contextManager"
},
{
"name": "print"
}
]
}
18 changes: 18 additions & 0 deletions src/lib/context/shared/layer-context.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ export class LayerContextDirective implements OnInit, OnDestroy {
}

private addLayerToMap(contextLayer: ContextLayer) {
if (contextLayer.maxScaleDenom) {
contextLayer.maxResolution = this.getResolutionFromScale(contextLayer.maxScaleDenom)
}
if (contextLayer.minScaleDenom) {
contextLayer.minResolution = this.getResolutionFromScale(contextLayer.minScaleDenom)
}
const sourceContext = contextLayer.source;
const layerContext: any = Object.assign({}, contextLayer);
delete layerContext.source;
Expand All @@ -82,6 +88,18 @@ export class LayerContextDirective implements OnInit, OnDestroy {
);
}

public getResolutionFromScale(scale: number): number {
const dpi = 25.4 / 0.28;
return scale / (39.37 * dpi);
}


public getResolutionFromScale(scale: number): number {
const dpi = 25.4 / 0.28;
return scale / (39.37 * dpi);
}


private getLayerParamVisibilityUrl(id, layer) {
const params = this.queryParams;
const current_context = this.contextService.context$.value['uri'];
Expand Down
25 changes: 19 additions & 6 deletions src/lib/datasource/shared/datasources/datasource.interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TimeFilterOptions } from '../../../filter';
import { TimeFilterOptions, IgoOgcFilterObject } from '../../../filter';
import { QueryFormat, QueryOptions } from '../../../query';
import { MetadataOptions } from '../../../metadata';

import { DownloadOptions } from '../../../download';
import { DataSource } from './datasource';


Expand All @@ -10,6 +10,7 @@ export interface DataSourceOptions {
alias?: string;
legend?: DataSourceLegendOptions;
metadata?: MetadataOptions;
download?: DownloadOptions;
view?: olx.layer.ImageOptions;
}

Expand Down Expand Up @@ -40,14 +41,26 @@ export interface QueryableDataSource extends DataSource {
getQueryUrl(options: QueryOptions): string;
}

export interface FilterableDataSourceOptions extends DataSourceOptions,
export interface TimeFilterableDataSourceOptions extends DataSourceOptions,
olx.source.ImageWMSOptions {

filterable?: boolean;
timeFilterable?: boolean;
timeFilter?: TimeFilterOptions;
}

export interface FilterableDataSource extends DataSource {
options: FilterableDataSourceOptions;
export interface TimeFilterableDataSource extends DataSource {
options: TimeFilterableDataSourceOptions;
filterByDate(date: Date | [Date, Date]);
}

export interface OgcFilterableDataSourceOptions extends DataSourceOptions,
olx.source.VectorOptions {

ogcFilterable?: boolean;
filters?: IgoOgcFilterObject;
}

export interface OgcFilterableDataSource extends DataSource {
options: OgcFilterableDataSourceOptions;
filterByOgc(IgoOgcFilterObject);
}
20 changes: 14 additions & 6 deletions src/lib/datasource/shared/datasources/datasource.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DataSourceOptions, DataSourceLegendOptions, FilterableDataSource,
QueryableDataSource } from './datasource.interface';
import { DataSourceOptions, DataSourceLegendOptions, TimeFilterableDataSource,
QueryableDataSource, OgcFilterableDataSource } from './datasource.interface';

export abstract class DataSource {

Expand Down Expand Up @@ -29,11 +29,11 @@ export abstract class DataSource {
return this.options.legend ? [this.options.legend] : [];
}

isFilterable(): this is FilterableDataSource {
const dataSource = this as any as FilterableDataSource;
isTimeFilterable(): this is TimeFilterableDataSource {
const dataSource = this as any as TimeFilterableDataSource;
if (typeof dataSource.filterByDate === 'function') {
return dataSource.options.filterable !== undefined ?
dataSource.options.filterable : true;
return dataSource.options.timeFilterable !== undefined ?
dataSource.options.timeFilterable : true;
}

return false;
Expand All @@ -49,4 +49,12 @@ export abstract class DataSource {
return false;
}

isOgcFilterable(): this is OgcFilterableDataSource {
const dataSource = this as any as OgcFilterableDataSource;
if (typeof dataSource.filterByOgc === 'function') {
return true;
}

return false;
}
}
19 changes: 16 additions & 3 deletions src/lib/datasource/shared/datasources/wfs-datasource.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import { FeatureDataSourceOptions, FeatureDataSourceContext } from './feature-datasource.interface';

export interface WFSDataSourceOptions extends FeatureDataSourceOptions {}
import { IgoOgcFilterObject } from '../../../filter';
import { DataSourceOptions, DataSourceContext } from './datasource.interface';

export interface WFSDataSourceContext extends FeatureDataSourceContext {}

export interface WFSDataSourceOptions extends DataSourceOptions, olx.source.VectorOptions {
version?: string;
url: string;
featureTypes: string;
fieldNameGeometry: string;
maxFeatures?: Number;
outputFormat?: string;
outputFormatDownload?: string;
srsname?: string;
filters?: IgoOgcFilterObject;
}

export interface WFSDataSourceContext extends DataSourceContext, WFSDataSourceOptions {}
Loading

0 comments on commit 96f66e1

Please sign in to comment.