From a3b2d8d3a1ea2886e1ae27744f1249f3d384723b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 11 Sep 2018 15:17:00 -0400 Subject: [PATCH 01/42] refactor(map) a more customizable way to add overlay --- projects/geo/src/lib/map/shared/map.ts | 56 +++++++++++++++++--------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/projects/geo/src/lib/map/shared/map.ts b/projects/geo/src/lib/map/shared/map.ts index f6233454e8..1cc6617df6 100644 --- a/projects/geo/src/lib/map/shared/map.ts +++ b/projects/geo/src/lib/map/shared/map.ts @@ -115,25 +115,7 @@ export class IgoMap { this.overlayMarkerStyle = this.setOverlayMarkerStyle(); this.overlayDataSource = new FeatureDataSource(); - - const stroke = new olstyle.Stroke({ - color: [0, 161, 222, 1], - width: 2 - }); - - const fill = new olstyle.Fill({ - color: [0, 161, 222, 0.15] - }); - - this.overlayStyle = new olstyle.Style({ - stroke: stroke, - fill: fill, - image: new olstyle.Circle({ - radius: 5, - stroke: stroke, - fill: fill - }) - }); + this.overlayStyle = this.setOverlayDataSourceStyle(); const layer = new VectorLayer({ title: 'Overlay', @@ -352,6 +334,12 @@ export class IgoMap { this.overlayDataSource.ol.addFeature(feature); } + getOverlayByID(id): olFeature { + if (this.overlayDataSource.ol.getFeatureById(id)) { + return this.overlayDataSource.ol.getFeatureById(id); + } + return; + } removeOverlayByID(id) { if (this.overlayDataSource.ol.getFeatureById(id)) { @@ -455,7 +443,35 @@ export class IgoMap { return listLegend; } - setOverlayMarkerStyle(color = 'blue', text = undefined): olstyle.Style { + setOverlayDataSourceStyle( + strokeRGBA: [number, number, number, number] = [0, 161, 222, 1], + strokeWidth: number = 2, + fillRGBA: [number, number, number, number] = [0, 161, 222, 0.15], + text?): olstyle.Style { + + + const stroke = new olstyle.Stroke({ + color: strokeRGBA, + width: strokeWidth + }); + + const fill = new olstyle.Fill({ + color: fillRGBA + }); + + return new olstyle.Style({ + stroke: stroke, + fill: fill, + image: new olstyle.Circle({ + radius: 5, + stroke: stroke, + fill: fill + }) + }); + +} + + setOverlayMarkerStyle(color = 'blue', text?): olstyle.Style { let iconColor; switch (color) { case 'blue': From b1e580c2f86e0f2fa98297de8b0f457ce7241383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 11 Sep 2018 15:18:35 -0400 Subject: [PATCH 02/42] feat(wkt service) refactor and adding ways to return wkt objects --- .../geo/src/lib/wkt/shared/wkt.service.ts | 66 +++++++++++++++---- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/projects/geo/src/lib/wkt/shared/wkt.service.ts b/projects/geo/src/lib/wkt/shared/wkt.service.ts index b04423f78b..bf0cda7af2 100644 --- a/projects/geo/src/lib/wkt/shared/wkt.service.ts +++ b/projects/geo/src/lib/wkt/shared/wkt.service.ts @@ -2,25 +2,44 @@ import { Injectable } from '@angular/core'; import * as olproj from 'ol/proj'; import olWKT from 'ol/format/WKT'; -import olPolygon from 'ol/geom/Polygon'; - -import { MapService } from '../../map/shared/map.service'; @Injectable({ providedIn: 'root' }) export class WktService { - constructor(private mapService: MapService) {} + constructor() {} - public mapExtentToWKT(epsgTO = this.mapService.getMap().projection) { - let extent = olproj.transformExtent( - this.mapService.getMap().getExtent(), - this.mapService.getMap().projection, + public wktToFeature(wkt, wktProj, featureProj= 'EPSG:3857') { + return new olWKT().readFeature(wkt, { + dataProjection: wktProj, + featureProjection: featureProj + }); + } + public extentToWkt(epsgTO, extent, extentProj) { + let currentExtent = olproj.transformExtent( + extent, + extentProj, epsgTO ); - extent = this.roundCoordinateArray(extent, epsgTO, 0); - const wkt = new olWKT().writeGeometry(olPolygon.fromExtent(extent)); - return wkt; + currentExtent = this.roundCoordinateArray(currentExtent, epsgTO, 0); + const wktPoly = `POLYGON(( + ${extent[0]} ${extent[1]}, + ${extent[0]} ${extent[3]}, + ${extent[2]} ${extent[3]}, + ${extent[2]} ${extent[1]}, + ${extent[0]} ${extent[1]}))`; + const wktLine = `LINESTRING( + ${extent[0]} ${extent[1]}, + ${extent[0]} ${extent[3]}, + ${extent[2]} ${extent[3]}, + ${extent[2]} ${extent[1]}, + ${extent[0]} ${extent[1]})`; + const wktMultiPoints = `MULTIPOINT( + ${extent[0]} ${extent[1]}, + ${extent[0]} ${extent[3]}, + ${extent[2]} ${extent[3]}, + ${extent[2]} ${extent[1]})`; + return {wktPoly : wktPoly, wktLine : wktLine, wktMultiPoints: wktMultiPoints }; } private roundCoordinateArray(coordinateArray, projection, decimal = 0) { @@ -28,7 +47,7 @@ export class WktService { const units = lproj.getUnits(); const olUnits = ['ft', 'm', 'us-ft']; if (olUnits.indexOf(units) !== -1) { - coordinateArray = this.roundArray(coordinateArray); + coordinateArray = this.roundArray(coordinateArray, decimal); } return coordinateArray; } @@ -42,7 +61,7 @@ export class WktService { return array; } - public snrcWKT(snrc, epsgTO = 'EPSG:3857') { + public snrcToWkt(snrc, epsgTO = 'EPSG:3857') { snrc = snrc.toLowerCase(); let wktPoly; const ew = { @@ -214,8 +233,27 @@ export class WktService { coord.ul.join(' ') ].join(',') + '))'; + const wktLine = + 'LINESTRING(' + + [ + coord.ul.join(' '), + coord['ur'].join(' '), + coord['lr'].join(' '), + coord['ll'].join(' '), + coord.ul.join(' ') + ].join(',') + + ')'; - return wktPoly; + const wktMultiPoints = + 'MULTIPOINT(' + + [ + coord.ul.join(' '), + coord['ur'].join(' '), + coord['lr'].join(' '), + coord['ll'].join(' ') + ].join(',') + + ')'; + return {wktPoly : wktPoly, wktLine : wktLine, wktMultiPoints: wktMultiPoints }; } } } From bce39c2e880489a87f979b5e9619eb7fc20ff349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 11 Sep 2018 15:19:56 -0400 Subject: [PATCH 03/42] fix(ogc-fillter interface and class) refactor interfaces and operators --- .../lib/filter/shared/ogc-filter.interface.ts | 5 ++-- .../geo/src/lib/filter/shared/ogc-filter.ts | 27 ++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/projects/geo/src/lib/filter/shared/ogc-filter.interface.ts b/projects/geo/src/lib/filter/shared/ogc-filter.interface.ts index e77b45e0d5..4b3042355b 100644 --- a/projects/geo/src/lib/filter/shared/ogc-filter.interface.ts +++ b/projects/geo/src/lib/filter/shared/ogc-filter.interface.ts @@ -40,7 +40,7 @@ export type IgoOgcFilterObject = export interface OgcFiltersOptions { filtersAreEditable: boolean; - filters: IgoLogicalArrayOptions[] | AnyBaseOgcFilterOptions; + filters: IgoLogicalArrayOptions | AnyBaseOgcFilterOptions; interfaceOgcFilters?: any[]; } @@ -54,7 +54,7 @@ export interface OgcFilterableDataSource extends DataSource { export interface IgoLogicalArrayOptions { logical: string; - filters: IgoLogicalArrayOptions[] | AnyBaseOgcFilterOptions; + filters: IgoLogicalArrayOptions | AnyBaseOgcFilterOptions[]; } export interface OgcFilterCondionsArrayOptions { @@ -120,6 +120,7 @@ export interface OgcInterfaceFilterOptions { matchCase?: boolean; geometryName?: string; geometry?: olGeometry; + wkt_geometry?: string; extent?: [number, number, number, number]; srsName?: string; parentLogical?: string; diff --git a/projects/geo/src/lib/filter/shared/ogc-filter.ts b/projects/geo/src/lib/filter/shared/ogc-filter.ts index 77cfd05b7a..c2ba5e1c82 100644 --- a/projects/geo/src/lib/filter/shared/ogc-filter.ts +++ b/projects/geo/src/lib/filter/shared/ogc-filter.ts @@ -16,19 +16,19 @@ import { export class OgcFilterWriter { private filterSequence: OgcInterfaceFilterOptions[] = []; public operators = { - PropertyIsEqualTo: { fieldRestrict: [] }, - PropertyIsNotEqualTo: { fieldRestrict: [] }, - PropertyIsLike: { fieldRestrict: ['string'] }, - PropertyIsGreaterThan: { fieldRestrict: ['number'] }, - PropertyIsGreaterThanOrEqualTo: { fieldRestrict: ['number'] }, - PropertyIsLessThan: { fieldRestrict: ['number'] }, - PropertyIsLessThanOrEqualTo: { fieldRestrict: ['number'] }, - PropertyIsBetween: { fieldRestrict: ['number'] }, - During: { fieldRestrict: [] }, - PropertyIsNull: { fieldRestrict: [] }, - Intersects: { fieldRestrict: [] }, - Within: { fieldRestrict: [] }, - Contains: { fieldRestrict: [] } + PropertyIsEqualTo: { spatial: false, fieldRestrict: [] }, + PropertyIsNotEqualTo: { spatial: false, fieldRestrict: [] }, + PropertyIsLike: { spatial: false, fieldRestrict: ['string'] }, + PropertyIsGreaterThan: { spatial: false, fieldRestrict: ['number'] }, + PropertyIsGreaterThanOrEqualTo: { spatial: false, fieldRestrict: ['number'] }, + PropertyIsLessThan: { spatial: false, fieldRestrict: ['number'] }, + PropertyIsLessThanOrEqualTo: { spatial: false, fieldRestrict: ['number'] }, + PropertyIsBetween: { spatial: false, fieldRestrict: ['number'] }, + During: { spatial: false, fieldRestrict: [] }, + PropertyIsNull: { spatial: false, fieldRestrict: [] }, + Intersects: { spatial: true, fieldRestrict: [] }, + Within: { spatial: true, fieldRestrict: [] }, + Contains: { spatial: true, fieldRestrict: [] } }; public buildFilter( @@ -268,6 +268,7 @@ export class OgcFilterWriter { igoSpatialSelector: '', geometryName: '', geometry: '', + wkt_geometry: '', extent: '', srsName: '', parentLogical: '', From 9dee1e7190a98d44298715d7828b1e9326258b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 11 Sep 2018 15:27:46 -0400 Subject: [PATCH 04/42] refactor(ogc-filter) bing map to ogcfilter. --- .../app/geo/ogc-filter/ogc-filter.component.html | 2 +- .../ogc-filterable-item.component.ts | 13 ++++++++++++- .../ogc-filterable-list.component.html | 2 +- .../ogc-filterable-list.component.ts | 10 ++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/demo/src/app/geo/ogc-filter/ogc-filter.component.html b/demo/src/app/geo/ogc-filter/ogc-filter.component.html index 041ec3e49e..0fca5c743c 100644 --- a/demo/src/app/geo/ogc-filter/ogc-filter.component.html +++ b/demo/src/app/geo/ogc-filter/ogc-filter.component.html @@ -14,7 +14,7 @@ - + diff --git a/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.ts b/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.ts index bd4e54892b..c413d3b450 100644 --- a/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.ts +++ b/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.ts @@ -10,6 +10,7 @@ import { OgcFiltersOptions } from '../shared/ogc-filter.interface'; import { OGCFilterService } from '../shared/ogc-filter.service'; +import { IgoMap } from '../../map'; @Component({ selector: 'igo-ogc-filterable-item', @@ -28,6 +29,16 @@ export class OgcFilterableItemComponent implements OnInit { set layer(value: Layer) { this._layer = value; } + + @Input() + get map(): IgoMap { + return this._map; + } + set map(value: IgoMap) { + this._map = value; + } + + private _map: IgoMap; private _layer: Layer; get datasource(): OgcFilterableDataSource { @@ -63,7 +74,7 @@ export class OgcFilterableItemComponent implements OnInit { } this.datasource.options['disableRefreshFilter'] = true; - } + } addFilterToSequence() { const arr = this.datasource.options.ogcFilters.interfaceOgcFilters; diff --git a/projects/geo/src/lib/filter/ogc-filterable-list/ogc-filterable-list.component.html b/projects/geo/src/lib/filter/ogc-filterable-list/ogc-filterable-list.component.html index 76dad13c6e..a02c367821 100644 --- a/projects/geo/src/lib/filter/ogc-filterable-list/ogc-filterable-list.component.html +++ b/projects/geo/src/lib/filter/ogc-filterable-list/ogc-filterable-list.component.html @@ -1,5 +1,5 @@ - + diff --git a/projects/geo/src/lib/filter/ogc-filterable-list/ogc-filterable-list.component.ts b/projects/geo/src/lib/filter/ogc-filterable-list/ogc-filterable-list.component.ts index 679ab44c81..9eb2c742f5 100644 --- a/projects/geo/src/lib/filter/ogc-filterable-list/ogc-filterable-list.component.ts +++ b/projects/geo/src/lib/filter/ogc-filterable-list/ogc-filterable-list.component.ts @@ -6,6 +6,7 @@ import { } from '@angular/core'; import { Layer } from '../../layer/shared/layers/layer'; +import { IgoMap } from '../../map'; @Component({ selector: 'igo-ogc-filterable-list', @@ -21,6 +22,15 @@ export class OgcFilterableListComponent { this._layers = value; this.cdRef.detectChanges(); } + @Input() + get map(): IgoMap { + return this._map; + } + set map(value: IgoMap) { + this._map = value; + } + + private _map: IgoMap; private _layers: Layer[] = []; constructor(private cdRef: ChangeDetectorRef) {} From 9796a1e705e85df785194f95c36ce5b751e4200f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 11 Sep 2018 15:29:53 -0400 Subject: [PATCH 05/42] (feat) feature color used as a extent (0000 vs gray) and autorefresh --- .../ogc-filterable-item.component.ts | 46 +++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.ts b/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.ts index c413d3b450..c5ded2c4cf 100644 --- a/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.ts +++ b/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.ts @@ -38,6 +38,18 @@ export class OgcFilterableItemComponent implements OnInit { this._map = value; } + get refreshFunc() { + return this.refreshFilters.bind(this); + } + @Input() + get showFeatureOnMap(): boolean { + return this._showFeatureOnMap; + } + set showFeatureOnMap(value: boolean) { + this._showFeatureOnMap = value; + } + + public _showFeatureOnMap = false; private _map: IgoMap; private _layer: Layer; @@ -73,8 +85,34 @@ export class OgcFilterableItemComponent implements OnInit { ); } - this.datasource.options['disableRefreshFilter'] = true; - } + // this.datasource.options['diskableRefreshFilter'] = true; + } + + toggleShowFeatureOnMap() { + this.showFeatureOnMap = !this.showFeatureOnMap; + this.datasource.options.ogcFilters.interfaceOgcFilters.forEach(filter => { + let drawnFeature; + let drawnStrokeColor = [125, 136, 140, 0] as [number, number, number, number]; + let drawStrokeWidth = 2; + let drawnFillColor = [125, 136, 140, 0]as [number, number, number, number]; + + if (this.showFeatureOnMap === false) { + drawnFeature = this.map.getOverlayByID('ogcFilterOverlay_' + filter.filterid); + } else { + drawnFeature = this.map.getOverlayByID('ogcFilterOverlay_' + filter.filterid); + drawnStrokeColor = [125, 136, 140, 0.5]; + drawStrokeWidth = 2; + drawnFillColor = [125, 136, 140, 0]; + } + if (drawnFeature) { + drawnFeature.setStyle(this.map.setOverlayDataSourceStyle(drawnStrokeColor, drawStrokeWidth, drawnFillColor)); + } + }); + + + + + } addFilterToSequence() { const arr = this.datasource.options.ogcFilters.interfaceOgcFilters; @@ -163,10 +201,10 @@ export class OgcFilterableItemComponent implements OnInit { } this.lastRunOgcFilter = JSON.parse(JSON.stringify(activeFilters)); - this.datasource.options['disableRefreshFilter'] = true; + // this.datasource.options['dislableRefreshFilter'] = true; } else { // identical filter. Nothing triggered - this.datasource.options['disableRefreshFilter'] = true; + // this.datasource.options['disableRefrkeshFilter'] = true; } } From 31b53dd3864b22efe750be6e157867b329b80248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 11 Sep 2018 15:30:47 -0400 Subject: [PATCH 06/42] fix(download-service) with right properties --- projects/geo/src/lib/download/shared/download.service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/geo/src/lib/download/shared/download.service.ts b/projects/geo/src/lib/download/shared/download.service.ts index 010e65265c..34de026ff2 100644 --- a/projects/geo/src/lib/download/shared/download.service.ts +++ b/projects/geo/src/lib/download/shared/download.service.ts @@ -43,13 +43,13 @@ export class DownloadService { ) { wfsOptions = layer.dataSource.options['wfsSource']; } else { - wfsOptions = layer.dataSource.options; + wfsOptions = layer.dataSource.options['params']; } const outputFormatDownload = - wfsOptions['outputFormatDownload'] === undefined - ? 'outputformat=' + wfsOptions['outputFormat'] - : 'outputformat=' + wfsOptions['outputFormatDownload']; + wfsOptions.outputFormatDownload === undefined + ? 'outputformat=' + wfsOptions.outputFormat + : 'outputformat=' + wfsOptions.outputFormatDownload; const baseurl = DSOptions.download['dynamicUrl'] .replace(/&?outputformat=[^&]*/gi, '') From 570e5ceb937a52ed0a34c5c8a84c691c9391745e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?= Date: Tue, 11 Sep 2018 15:32:56 -0400 Subject: [PATCH 07/42] feat(ogc-filter) Autorefresh toggle feature extent and bind map --- .../ogc-filterable-form.component.html | 2 +- .../ogc-filterable-form.component.ts | 26 +++++++++++++++++++ .../ogc-filterable-item.component.html | 24 +++++++++++++++-- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/projects/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.html b/projects/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.html index e3dc138177..1bd3e15590 100644 --- a/projects/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.html +++ b/projects/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.html @@ -1,6 +1,6 @@ - + diff --git a/projects/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts b/projects/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts index 56c0a01df0..e8d7f43cfc 100644 --- a/projects/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts +++ b/projects/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts @@ -1,5 +1,6 @@ import { Component, Input } from '@angular/core'; import { OgcFilterableDataSource } from '../shared/ogc-filter.interface'; +import { IgoMap } from '../../map'; @Component({ selector: 'igo-ogc-filterable-form', @@ -13,6 +14,31 @@ export class OgcFilterableFormComponent { set datasource(value: OgcFilterableDataSource) { this._dataSource = value; } + + @Input() + get map(): IgoMap { + return this._map; + } + set map(value: IgoMap) { + this._map = value; + } + + @Input() refreshFilters: Function; + + get refreshFunc() { + return this.refreshFilters; + } + @Input() + get showFeatureOnMap(): Boolean { + return this._showFeatureOnMap; + } + set showFeatureOnMap(value: Boolean) { + this._showFeatureOnMap = value; + } + + + private _showFeatureOnMap: Boolean; + private _map: IgoMap; private _dataSource: OgcFilterableDataSource; public color = 'primary'; diff --git a/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.html b/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.html index 69cd6ba148..9a08722503 100644 --- a/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.html +++ b/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.html @@ -5,8 +5,28 @@

{{layer.title}}

+ + + + - @@ -130,7 +130,7 @@ - @@ -143,7 +143,7 @@ - @@ -164,13 +164,13 @@
- - {{operator.value.alias}} + + {{('igo.geo.operators.'+ operator.key) | translate}}
- - {{igoSpatialSelector.alias}} + + {{('igo.geo.spatialSelector.'+ igoSpatialSelector.type) | translate}}
@@ -185,7 +185,7 @@ -
- - + --> --> - + - -
-
- - - +
+
From 41796fe6f74a5e23f67e1500fa44d22043e1c285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Mon, 15 Oct 2018 16:54:53 -0400 Subject: [PATCH 37/42] Update layer.component.ts --- demo/src/app/geo/layer/layer.component.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/demo/src/app/geo/layer/layer.component.ts b/demo/src/app/geo/layer/layer.component.ts index b30acfe82c..8739f4a966 100644 --- a/demo/src/app/geo/layer/layer.component.ts +++ b/demo/src/app/geo/layer/layer.component.ts @@ -6,7 +6,6 @@ import { DataSourceService, LayerService, WMSDataSourceOptions, - MetadataDataSourceOptions, LayerOptions, WFSDataSourceOptions, @@ -65,16 +64,16 @@ export class AppLayerComponent { version: '2.0.0', outputFormat: 'geojson_utf8', outputFormatDownload: 'shp' - }, - ogcFilters: { - enabled: true, - editable: true, - filters: { - operator: 'PropertyIsEqualTo', - propertyName: 'code_municipalite', - expression: '10043' - } + }, + ogcFilters: { + enabled: true, + editable: true, + filters: { + operator: 'PropertyIsEqualTo', + propertyName: 'code_municipalite', + expression: '10043' } + } }; From 74bb16cabc0a7f2f687653a9219bdaad6e0102b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Mon, 15 Oct 2018 17:01:35 -0400 Subject: [PATCH 38/42] Update ogc-filter.component.ts --- .../geo/ogc-filter/ogc-filter.component.ts | 51 ++++++++----------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/demo/src/app/geo/ogc-filter/ogc-filter.component.ts b/demo/src/app/geo/ogc-filter/ogc-filter.component.ts index 91fe5165a8..e263de3ba5 100644 --- a/demo/src/app/geo/ogc-filter/ogc-filter.component.ts +++ b/demo/src/app/geo/ogc-filter/ogc-filter.component.ts @@ -68,40 +68,33 @@ export class AppOgcFilterComponent { {name: 'code_municipalite', 'alias': '# de la municipalitée'}, {name: 'date_observation'}, {name: 'urgence', values: ['immédiate', 'inconnue']} - ], + ], ogcFilters: { enabled: true, editable: true, filters: { logical: 'Or', filters: [{ - operator: 'PropertyIsEqualTo', - propertyName: 'code_municipalite', - expression: '10043' - }, - { - operator: 'Intersects', - geometryName: 'the_geom', - wkt_geometry: ` - MULTIPOLYGON((( - -8379441.158019895 5844447.897707146,-8379441.158019895 5936172.331649357, - -8134842.66750733 5936172.331649357,-8134842.66750733 5844447.897707146, - -8379441.158019895 5844447.897707146), - (-8015003 5942074,-8015003 5780349,-7792364 5780349,-7792364 5942074,-8015003 5942074))) - `} - // OR - // POLYGON(( - // -8015003 5942074,-8015003 5780349, - // -7792364 5780349,-7792364 5942074,-8015003 5942074 - // )) - // OR - // MULTIPOLYGON((( - // -8379441.158019895 5844447.897707146,-8379441.158019895 5936172.331649357, - // -8134842.66750733 5936172.331649357,-8134842.66750733 5844447.897707146, - // -8379441.158019895 5844447.897707146), - // (-8015003 5942074,-8015003 5780349,-7792364 5780349,-7792364 5942074,-8015003 5942074))) - - ] as AnyBaseOgcFilterOptions[] + operator: 'PropertyIsEqualTo', + propertyName: 'code_municipalite', + expression: '10043' + }, { + operator: 'Intersects', + geometryName: 'the_geom', + wkt_geometry: `MULTIPOLYGON((( + -8379441.158019895 5844447.897707146, + -8379441.158019895 5936172.331649357, + -8134842.66750733 5936172.331649357, + -8134842.66750733 5844447.897707146, + -8379441.158019895 5844447.897707146 + ), ( + -8015003 5942074, + -8015003 5780349, + -7792364 5780349, + -7792364 5942074, + -8015003 5942074 + )))` + }] as AnyBaseOgcFilterOptions[] } } }; @@ -117,7 +110,7 @@ export class AppOgcFilterComponent { ); }); - interface WMSoptions + interface WMSoptions extends WMSDataSourceOptions, OgcFilterableDataSourceOptions {} const datasourceWms: WMSoptions = { From f93e1016958c4dfd39e40edf48ad31ddb47b04d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Tue, 16 Oct 2018 11:04:30 -0400 Subject: [PATCH 39/42] lint code --- .../geo/ogc-filter/ogc-filter.component.ts | 43 ++++++------ .../core/src/lib/request/error.interceptor.ts | 1 + .../datasource/shared/datasource.service.ts | 16 +++-- .../shared/datasources/datasource.ts | 3 +- .../shared/datasources/wfs-datasource.ts | 35 ++++++---- .../shared/datasources/wfs.service.ts | 36 ++++------ .../datasources/wms-datasource.interface.ts | 4 +- .../shared/datasources/wms-datasource.ts | 42 ++++++++---- .../ogc-filter-form.component.ts | 49 +++++++++---- .../ogc-filterable-form.component.ts | 1 - .../ogc-filterable-item.component.html | 14 +--- .../ogc-filterable-item.component.ts | 68 ++++++++++++------- .../lib/filter/shared/ogc-filter.service.ts | 5 -- .../geo/src/lib/filter/shared/ogc-filter.ts | 5 +- projects/geo/src/lib/map/shared/map.ts | 8 +-- .../geo/src/lib/wkt/shared/wkt.service.ts | 24 ++++--- 16 files changed, 211 insertions(+), 143 deletions(-) diff --git a/demo/src/app/geo/ogc-filter/ogc-filter.component.ts b/demo/src/app/geo/ogc-filter/ogc-filter.component.ts index e263de3ba5..3f721ffd6e 100644 --- a/demo/src/app/geo/ogc-filter/ogc-filter.component.ts +++ b/demo/src/app/geo/ogc-filter/ogc-filter.component.ts @@ -65,23 +65,25 @@ export class AppOgcFilterComponent { outputFormatDownload: 'SHP' // based on service capabilities }, sourceFields: [ - {name: 'code_municipalite', 'alias': '# de la municipalitée'}, - {name: 'date_observation'}, - {name: 'urgence', values: ['immédiate', 'inconnue']} + { name: 'code_municipalite', alias: '# de la municipalitée' }, + { name: 'date_observation' }, + { name: 'urgence', values: ['immédiate', 'inconnue'] } ], ogcFilters: { enabled: true, editable: true, filters: { logical: 'Or', - filters: [{ - operator: 'PropertyIsEqualTo', - propertyName: 'code_municipalite', - expression: '10043' - }, { - operator: 'Intersects', - geometryName: 'the_geom', - wkt_geometry: `MULTIPOLYGON((( + filters: [ + { + operator: 'PropertyIsEqualTo', + propertyName: 'code_municipalite', + expression: '10043' + }, + { + operator: 'Intersects', + geometryName: 'the_geom', + wkt_geometry: `MULTIPOLYGON((( -8379441.158019895 5844447.897707146, -8379441.158019895 5936172.331649357, -8134842.66750733 5936172.331649357, @@ -94,7 +96,8 @@ export class AppOgcFilterComponent { -7792364 5942074, -8015003 5942074 )))` - }] as AnyBaseOgcFilterOptions[] + } + ] as AnyBaseOgcFilterOptions[] } } }; @@ -111,7 +114,8 @@ export class AppOgcFilterComponent { }); interface WMSoptions - extends WMSDataSourceOptions, OgcFilterableDataSourceOptions {} + extends WMSDataSourceOptions, + OgcFilterableDataSourceOptions {} const datasourceWms: WMSoptions = { type: 'wms', @@ -127,13 +131,14 @@ export class AppOgcFilterComponent { filters: { operator: 'PropertyIsEqualTo', propertyName: 'waterway', - expression: 'riverbank'} + expression: 'riverbank' + } }, sourceFields: [ - {name: 'waterway', 'alias': 'Chemin d eau'}, - {name: 'osm_id'}, - {name: 'landuse', values: ['yes', 'no']} - ], + { name: 'waterway', alias: 'Chemin d eau' }, + { name: 'osm_id' }, + { name: 'landuse', values: ['yes', 'no'] } + ], paramsWFS: { featureTypes: 'water_areas', fieldNameGeometry: 'the_geom', @@ -141,7 +146,7 @@ export class AppOgcFilterComponent { version: '1.1.0', outputFormat: 'application/json', outputFormatDownload: 'application/vnd.google-earth.kml+xml' - } as WFSDataSourceOptionsParams, + } as WFSDataSourceOptionsParams }; this.dataSourceService diff --git a/projects/core/src/lib/request/error.interceptor.ts b/projects/core/src/lib/request/error.interceptor.ts index 5273de4fd5..1d2f8052b4 100644 --- a/projects/core/src/lib/request/error.interceptor.ts +++ b/projects/core/src/lib/request/error.interceptor.ts @@ -71,6 +71,7 @@ export class ErrorInterceptor implements HttpInterceptor { const translate = this.injector.get(LanguageService).translate; const message = translate.instant('igo.core.errors.uncaught.message'); const title = translate.instant('igo.core.errors.uncaught.title'); + this.httpError.error.caught = true; this.messageService.error(message, title); } } diff --git a/projects/geo/src/lib/datasource/shared/datasource.service.ts b/projects/geo/src/lib/datasource/shared/datasource.service.ts index 46536d3da3..06dfbbc5ec 100644 --- a/projects/geo/src/lib/datasource/shared/datasource.service.ts +++ b/projects/geo/src/lib/datasource/shared/datasource.service.ts @@ -36,7 +36,8 @@ export class DataSourceService { constructor( private capabilitiesService: CapabilitiesService, - private wfsDataSourceService: WFSService) {} + private wfsDataSourceService: WFSService + ) {} createAsyncDataSource(context: AnyDataSourceOptions): Observable { if (!context.type) { @@ -107,7 +108,9 @@ export class DataSourceService { private createWFSDataSource( context: WFSDataSourceOptions ): Observable { - return new Observable(d => d.next(new WFSDataSource(context, this.wfsDataSourceService))); + return new Observable(d => + d.next(new WFSDataSource(context, this.wfsDataSourceService)) + ); } private createWMSDataSource( @@ -117,11 +120,16 @@ export class DataSourceService { return this.capabilitiesService .getWMSOptions(context) .pipe( - map((options: WMSDataSourceOptions) => new WMSDataSource(options, this.wfsDataSourceService)) + map( + (options: WMSDataSourceOptions) => + new WMSDataSource(options, this.wfsDataSourceService) + ) ); } - return new Observable(d => d.next(new WMSDataSource(context, this.wfsDataSourceService))); + return new Observable(d => + d.next(new WMSDataSource(context, this.wfsDataSourceService)) + ); } private createWMTSDataSource( diff --git a/projects/geo/src/lib/datasource/shared/datasources/datasource.ts b/projects/geo/src/lib/datasource/shared/datasources/datasource.ts index 282c2caa3a..7d5fe75ad8 100644 --- a/projects/geo/src/lib/datasource/shared/datasources/datasource.ts +++ b/projects/geo/src/lib/datasource/shared/datasources/datasource.ts @@ -12,7 +12,8 @@ export abstract class DataSource { public ol: olSource; constructor( - public options: DataSourceOptions = {}, protected dataService?: DataService + public options: DataSourceOptions = {}, + protected dataService?: DataService ) { this.options = options; this.id = this.generateId(); diff --git a/projects/geo/src/lib/datasource/shared/datasources/wfs-datasource.ts b/projects/geo/src/lib/datasource/shared/datasources/wfs-datasource.ts index 6887790bba..78ba9bc18a 100644 --- a/projects/geo/src/lib/datasource/shared/datasources/wfs-datasource.ts +++ b/projects/geo/src/lib/datasource/shared/datasources/wfs-datasource.ts @@ -17,7 +17,8 @@ export class WFSDataSource extends DataSource { constructor( public options: WFSDataSourceOptions, - protected wfsService: WFSService) { + protected wfsService: WFSService + ) { super(options); this.options = this.wfsService.checkWfsOptions(options); this.ogcFilterWriter = new OgcFilterWriter(); @@ -33,17 +34,24 @@ export class WFSDataSource extends DataSource { this.options.paramsWFS = this.options.params; this.options.urlWfs = this.options.url; // default wfs version - this.options.paramsWFS.version = this.options.paramsWFS.version ? this.options.paramsWFS.version : '2.0.0'; + this.options.paramsWFS.version = this.options.paramsWFS.version + ? this.options.paramsWFS.version + : '2.0.0'; const ogcFiltersDefaultValue = true; // default values for wfs. (this.options as OgcFilterableDataSourceOptions).ogcFilters = - (this.options as OgcFilterableDataSourceOptions).ogcFilters === undefined ? - {} : (this.options as OgcFilterableDataSourceOptions).ogcFilters; + (this.options as OgcFilterableDataSourceOptions).ogcFilters === undefined + ? {} + : (this.options as OgcFilterableDataSourceOptions).ogcFilters; (this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled = - (this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled === undefined ? - ogcFiltersDefaultValue : (this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled; + (this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled === + undefined + ? ogcFiltersDefaultValue + : (this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled; (this.options as OgcFilterableDataSourceOptions).ogcFilters.editable = - (this.options as OgcFilterableDataSourceOptions).ogcFilters.editable === undefined ? - ogcFiltersDefaultValue : (this.options as OgcFilterableDataSourceOptions).ogcFilters.editable; + (this.options as OgcFilterableDataSourceOptions).ogcFilters.editable === + undefined + ? ogcFiltersDefaultValue + : (this.options as OgcFilterableDataSourceOptions).ogcFilters.editable; return new olSourceVector({ format: this.getFormatFromOptions(), @@ -82,10 +90,13 @@ export class WFSDataSource extends DataSource { if ( (this.options as OgcFilterableDataSourceOptions).ogcFilters && - (this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled) { - this.options.paramsWFS.xmlFilter = this.ogcFilterWriter.buildFilter( - (this.options as OgcFilterableDataSourceOptions).ogcFilters.filters, - extent, proj, this.options.paramsWFS.fieldNameGeometry + (this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled + ) { + this.options.paramsWFS.xmlFilter = this.ogcFilterWriter.buildFilter( + (this.options as OgcFilterableDataSourceOptions).ogcFilters.filters, + extent, + proj, + this.options.paramsWFS.fieldNameGeometry ); } diff --git a/projects/geo/src/lib/datasource/shared/datasources/wfs.service.ts b/projects/geo/src/lib/datasource/shared/datasources/wfs.service.ts index 0defa7b39c..02dbbfed7a 100644 --- a/projects/geo/src/lib/datasource/shared/datasources/wfs.service.ts +++ b/projects/geo/src/lib/datasource/shared/datasources/wfs.service.ts @@ -27,24 +27,19 @@ export class WFSService extends DataService { Object.keys(datasource.sourceFields).length === 0 ) { datasource.sourceFields = []; - this.wfsGetCapabilities(datasource) - .subscribe(wfsCapabilities => { - datasource.paramsWFS.wfsCapabilities = { - xmlBody: wfsCapabilities.body, - GetPropertyValue: /GetPropertyValue/gi.test(wfsCapabilities.body) - ? true - : false - }; + this.wfsGetCapabilities(datasource).subscribe(wfsCapabilities => { + datasource.paramsWFS.wfsCapabilities = { + xmlBody: wfsCapabilities.body, + GetPropertyValue: /GetPropertyValue/gi.test(wfsCapabilities.body) + ? true + : false + }; - this.defineFieldAndValuefromWFS( - datasource - ) - .subscribe(sourceFields => { - datasource.sourceFields = sourceFields; - }); + this.defineFieldAndValuefromWFS(datasource).subscribe(sourceFields => { + datasource.sourceFields = sourceFields; }); + }); } else { - datasource.sourceFields.forEach(sourcefield => { if (sourcefield.alias === undefined) { sourcefield.alias = sourcefield.name; // to allow only a list of sourcefield with names @@ -58,12 +53,11 @@ export class WFSService extends DataService { .forEach(f => { this.getValueFromWfsGetPropertyValues( datasource, - f.name, - 200, - 0, - 0 - ) - .subscribe(rep => (f.values = rep)); + f.name, + 200, + 0, + 0 + ).subscribe(rep => (f.values = rep)); }); } } diff --git a/projects/geo/src/lib/datasource/shared/datasources/wms-datasource.interface.ts b/projects/geo/src/lib/datasource/shared/datasources/wms-datasource.interface.ts index e65feb4a14..7f6678045d 100644 --- a/projects/geo/src/lib/datasource/shared/datasources/wms-datasource.interface.ts +++ b/projects/geo/src/lib/datasource/shared/datasources/wms-datasource.interface.ts @@ -6,8 +6,8 @@ import { WFSDataSourceOptionsParams } from './wfs-datasource.interface'; export interface WMSDataSourceOptions extends DataSourceOptions { // type?: 'wms'; optionsFromCapabilities?: boolean; - paramsWFS?: WFSDataSourceOptionsParams; // for wms linked with wfs - urlWfs?: string; // if url for linked wfs differ from the url for wms. + paramsWFS?: WFSDataSourceOptionsParams; // for wms linked with wfs + urlWfs?: string; // if url for linked wfs differ from the url for wms. url: string; params: WMSDataSourceOptionsParams; projection?: string; diff --git a/projects/geo/src/lib/datasource/shared/datasources/wms-datasource.ts b/projects/geo/src/lib/datasource/shared/datasources/wms-datasource.ts index 9b4d9d0c91..3f01380759 100644 --- a/projects/geo/src/lib/datasource/shared/datasources/wms-datasource.ts +++ b/projects/geo/src/lib/datasource/shared/datasources/wms-datasource.ts @@ -32,8 +32,10 @@ export class WMSDataSource extends DataSource { : 'newtab'; } - constructor(public options: WMSDataSourceOptions, - protected wfsService: WFSService) { + constructor( + public options: WMSDataSourceOptions, + protected wfsService: WFSService + ) { super(options); // Important: To use wms versions smaller than 1.3.0, SRS // needs to be supplied in the source "params" @@ -47,7 +49,7 @@ export class WMSDataSource extends DataSource { if (options.refreshIntervalSec && options.refreshIntervalSec > 0) { setInterval(() => { - this.ol.updateParams({'igoRefresh': Math.random()}); + this.ol.updateParams({ igoRefresh: Math.random() }); }, options.refreshIntervalSec * 1000); // Convert seconds to MS } @@ -57,7 +59,6 @@ export class WMSDataSource extends DataSource { options.paramsWFS.version = wfsCheckup.paramsWFS.version; options.paramsWFS.wfsCapabilities = wfsCheckup.params.wfsCapabilities; - this.wfsService.getSourceFieldsFromWFS(options); this.options.download = Object.assign({}, this.options.download, { @@ -65,7 +66,7 @@ export class WMSDataSource extends DataSource { }); } // #### END if paramsWFS this.ogcFilterWriter = new OgcFilterWriter(); - if (!options.sourceFields || options.sourceFields.length === 0 ) { + if (!options.sourceFields || options.sourceFields.length === 0) { options.sourceFields = []; } } @@ -77,7 +78,10 @@ export class WMSDataSource extends DataSource { : ''; let paramMaxFeatures = 'maxFeatures'; - if (asWFSDataSourceOptions.paramsWFS.version === '2.0.0' || !asWFSDataSourceOptions.paramsWFS.version) { + if ( + asWFSDataSourceOptions.paramsWFS.version === '2.0.0' || + !asWFSDataSourceOptions.paramsWFS.version + ) { paramMaxFeatures = 'count'; } const maxFeatures = asWFSDataSourceOptions.paramsWFS.maxFeatures @@ -91,24 +95,32 @@ export class WMSDataSource extends DataSource { 'GetFeature' ); return `${baseWfsQuery}&${outputFormat}&${srsname}&${maxFeatures}`; - } protected createOlSource(): olSourceImageWMS { if (this.options.paramsWFS) { - this.options.urlWfs = this.options.urlWfs ? this.options.urlWfs : this.options.url; - this.options.paramsWFS.version = this.options.paramsWFS.version ? this.options.paramsWFS.version : '2.0.0'; + this.options.urlWfs = this.options.urlWfs + ? this.options.urlWfs + : this.options.url; + this.options.paramsWFS.version = this.options.paramsWFS.version + ? this.options.paramsWFS.version + : '2.0.0'; } const ogcFiltersDefaultValue = false; // default values for wms. (this.options as OgcFilterableDataSourceOptions).ogcFilters = - (this.options as OgcFilterableDataSourceOptions).ogcFilters === undefined ? - {} : (this.options as OgcFilterableDataSourceOptions).ogcFilters; + (this.options as OgcFilterableDataSourceOptions).ogcFilters === undefined + ? {} + : (this.options as OgcFilterableDataSourceOptions).ogcFilters; (this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled = - (this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled === undefined ? - ogcFiltersDefaultValue : (this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled; + (this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled === + undefined + ? ogcFiltersDefaultValue + : (this.options as OgcFilterableDataSourceOptions).ogcFilters.enabled; (this.options as OgcFilterableDataSourceOptions).ogcFilters.editable = - (this.options as OgcFilterableDataSourceOptions).ogcFilters.editable === undefined ? - ogcFiltersDefaultValue : (this.options as OgcFilterableDataSourceOptions).ogcFilters.editable; + (this.options as OgcFilterableDataSourceOptions).ogcFilters.editable === + undefined + ? ogcFiltersDefaultValue + : (this.options as OgcFilterableDataSourceOptions).ogcFilters.editable; return new olSourceImageWMS(this.options); } diff --git a/projects/geo/src/lib/filter/ogc-filter-form/ogc-filter-form.component.ts b/projects/geo/src/lib/filter/ogc-filter-form/ogc-filter-form.component.ts index 24c9d81c34..b4f7a68aa9 100644 --- a/projects/geo/src/lib/filter/ogc-filter-form/ogc-filter-form.component.ts +++ b/projects/geo/src/lib/filter/ogc-filter-form/ogc-filter-form.component.ts @@ -1,5 +1,9 @@ -import { Component, Input, ChangeDetectorRef, AfterContentChecked } from '@angular/core'; - +import { + Component, + Input, + ChangeDetectorRef, + AfterContentChecked +} from '@angular/core'; import { OgcInterfaceFilterOptions, @@ -98,10 +102,16 @@ export class OgcFilterFormComponent implements AfterContentChecked { ngAfterContentChecked() { if (this.map) { this.activeFilters - .filter(af => ['Contains', 'Intersects', 'Within'].indexOf(af.operator) !== -1).forEach(activeFilterSpatial => { + .filter( + af => ['Contains', 'Intersects', 'Within'].indexOf(af.operator) !== -1 + ) + .forEach(activeFilterSpatial => { if (activeFilterSpatial.wkt_geometry) { - this.addWktAsOverlay(activeFilterSpatial.wkt_geometry, activeFilterSpatial.filterid, this.map.projection); - + this.addWktAsOverlay( + activeFilterSpatial.wkt_geometry, + activeFilterSpatial.filterid, + this.map.projection + ); } }); } @@ -134,7 +144,14 @@ export class OgcFilterFormComponent implements AfterContentChecked { if (this.showFeatureOnMap) { opacity = 0.5; } - wktAsFeature.setStyle(this.map.setOverlayDataSourceStyle([125, 136, 140, opacity], 2, [125, 136, 140, 0])); + wktAsFeature.setStyle( + this.map.setOverlayDataSourceStyle([125, 136, 140, opacity], 2, [ + 125, + 136, + 140, + 0 + ]) + ); this.map.addOverlay(wktAsFeature); } @@ -143,7 +160,11 @@ export class OgcFilterFormComponent implements AfterContentChecked { const mapProjection = this.map.projection; if (event.checked) { if (filter.wkt_geometry !== '') { - this.addWktAsOverlay(filter.wkt_geometry, filter.filterid, mapProjection); + this.addWktAsOverlay( + filter.wkt_geometry, + filter.filterid, + mapProjection + ); } this.datasource.options.ogcFilters.interfaceOgcFilters .filter(f => f.filterid === filter.filterid) @@ -197,7 +218,6 @@ export class OgcFilterFormComponent implements AfterContentChecked { } changeGeometry(filter, value?) { - const checkSNRC50k = /\d{2,3}[a-l][0,1][0-9]/gi; const checkSNRC250k = /\d{2,3}[a-p]/gi; const checkSNRC1m = /\d{2,3}/gi; @@ -213,16 +233,19 @@ export class OgcFilterFormComponent implements AfterContentChecked { element.wkt_geometry = wktPoly; } else if ( value !== '' && - (checkSNRC1m.test(value) || checkSNRC250k.test(value) || checkSNRC50k.test(value) )) { + (checkSNRC1m.test(value) || + checkSNRC250k.test(value) || + checkSNRC50k.test(value)) + ) { wktPoly = this.wktService.snrcToWkt(value).wktPoly; element.wkt_geometry = wktPoly; } - } else if (filter.igoSpatialSelector === 'fixedExtent') { wktPoly = this.wktService.extentToWkt( - mapProjection, - this.map.getExtent(), - mapProjection).wktPoly; + mapProjection, + this.map.getExtent(), + mapProjection + ).wktPoly; element.wkt_geometry = wktPoly; } if (wktPoly) { diff --git a/projects/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts b/projects/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts index e8d7f43cfc..9c5dc9960a 100644 --- a/projects/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts +++ b/projects/geo/src/lib/filter/ogc-filterable-form/ogc-filterable-form.component.ts @@ -36,7 +36,6 @@ export class OgcFilterableFormComponent { this._showFeatureOnMap = value; } - private _showFeatureOnMap: Boolean; private _map: IgoMap; private _dataSource: OgcFilterableDataSource; diff --git a/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.html b/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.html index 88030dcf1b..1b501c80fd 100644 --- a/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.html +++ b/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.html @@ -6,7 +6,7 @@

{{layer.title}}

- - - -
- \ No newline at end of file + diff --git a/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.ts b/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.ts index 5706fcb6f5..93e3e1f60b 100644 --- a/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.ts +++ b/projects/geo/src/lib/filter/ogc-filterable-item/ogc-filterable-item.component.ts @@ -13,7 +13,6 @@ import { import { OGCFilterService } from '../shared/ogc-filter.service'; import { IgoMap } from '../../map'; - @Component({ selector: 'igo-ogc-filterable-item', templateUrl: './ogc-filterable-item.component.html', @@ -88,50 +87,65 @@ export class OgcFilterableItemComponent implements OnInit { } if (this.datasource.options.ogcFilters) { - if ( - this.datasource.options.ogcFilters.interfaceOgcFilters - ) { + if (this.datasource.options.ogcFilters.interfaceOgcFilters) { this.lastRunOgcFilter = JSON.parse( JSON.stringify(this.datasource.options.ogcFilters.interfaceOgcFilters) ); - if (this.datasource.options.ogcFilters.interfaceOgcFilters.filter(f => f.wkt_geometry).length >= 1) { + if ( + this.datasource.options.ogcFilters.interfaceOgcFilters.filter( + f => f.wkt_geometry + ).length >= 1 + ) { this.hasActiveSpatialFilter = true; } } - this.filtersAreEditable = this.datasource.options.ogcFilters.editable ? - this.datasource.options.ogcFilters.editable : false; - + this.filtersAreEditable = this.datasource.options.ogcFilters.editable + ? this.datasource.options.ogcFilters.editable + : false; } - - - // this.datasource.options['diskableRefreshFilter'] = true; } toggleShowFeatureOnMap() { this.showFeatureOnMap = !this.showFeatureOnMap; this.datasource.options.ogcFilters.interfaceOgcFilters.forEach(filter => { let drawnFeature; - let drawnStrokeColor = [125, 136, 140, 0] as [number, number, number, number]; + let drawnStrokeColor = [125, 136, 140, 0] as [ + number, + number, + number, + number + ]; let drawStrokeWidth = 2; - let drawnFillColor = [125, 136, 140, 0]as [number, number, number, number]; + let drawnFillColor = [125, 136, 140, 0] as [ + number, + number, + number, + number + ]; if (this.showFeatureOnMap === false) { - drawnFeature = this.map.getOverlayByID('ogcFilterOverlay_' + filter.filterid); + drawnFeature = this.map.getOverlayByID( + 'ogcFilterOverlay_' + filter.filterid + ); } else { - drawnFeature = this.map.getOverlayByID('ogcFilterOverlay_' + filter.filterid); + drawnFeature = this.map.getOverlayByID( + 'ogcFilterOverlay_' + filter.filterid + ); drawnStrokeColor = [125, 136, 140, 0.5]; drawStrokeWidth = 2; drawnFillColor = [125, 136, 140, 0]; } if (drawnFeature) { - drawnFeature.setStyle(this.map.setOverlayDataSourceStyle(drawnStrokeColor, drawStrokeWidth, drawnFillColor)); + drawnFeature.setStyle( + this.map.setOverlayDataSourceStyle( + drawnStrokeColor, + drawStrokeWidth, + drawnFillColor + ) + ); } }); - - - - } addFilterToSequence() { @@ -145,7 +159,8 @@ export class OgcFilterableItemComponent implements OnInit { : this.datasource.options.sourceFields[0].name; } let fieldNameGeometry; - const datasourceOptions = this.datasource.options as WFSDataSourceOptionsParams; + const datasourceOptions = this.datasource + .options as WFSDataSourceOptionsParams; if (datasourceOptions.fieldNameGeometry) { fieldNameGeometry = datasourceOptions.fieldNameGeometry; } else if ( @@ -183,7 +198,11 @@ export class OgcFilterableItemComponent implements OnInit { if (activeFilters.length > 1) { activeFilters[0].parentLogical = activeFilters[1].parentLogical; } - if (activeFilters.filter(af => ['Contains', 'Intersects', 'Within'].indexOf(af.operator) !== -1).length === 0) { + if ( + activeFilters.filter( + af => ['Contains', 'Intersects', 'Within'].indexOf(af.operator) !== -1 + ).length === 0 + ) { this.hasActiveSpatialFilter = false; } else { this.hasActiveSpatialFilter = true; @@ -220,7 +239,10 @@ export class OgcFilterableItemComponent implements OnInit { this.layer.dataSource.options['fieldNameGeometry'] ); } - this.ogcFilterService.filterByOgc(this.datasource as WMSDataSource , rebuildFilter); + this.ogcFilterService.filterByOgc( + this.datasource as WMSDataSource, + rebuildFilter + ); this.datasource.options.ogcFilters.filtered = activeFilters.length === 0 ? false : true; } diff --git a/projects/geo/src/lib/filter/shared/ogc-filter.service.ts b/projects/geo/src/lib/filter/shared/ogc-filter.service.ts index 3dd9c2aa48..bc1f5b3c31 100644 --- a/projects/geo/src/lib/filter/shared/ogc-filter.service.ts +++ b/projects/geo/src/lib/filter/shared/ogc-filter.service.ts @@ -3,7 +3,6 @@ import { BehaviorSubject } from 'rxjs'; import { WMSDataSource } from '../../datasource/shared/datasources/wms-datasource'; import { WFSDataSourceOptions } from '../../datasource/shared/datasources/wfs-datasource.interface'; -// import { WFSService } from '../../datasource/shared/wfs.service'; import { OgcFilterWriter } from './ogc-filter'; import { OgcFilterableDataSource } from './ogc-filter.interface'; @@ -19,7 +18,6 @@ export class OGCFilterService { wmsDatasource.ol.updateParams({ filter: wmsFilterValue }); } - public setOgcWFSFiltersOptions(wfsDatasource: OgcFilterableDataSource) { const options: any = wfsDatasource.options; const ogcFilterWriter = new OgcFilterWriter(); @@ -43,8 +41,6 @@ export class OGCFilterService { const options: any = wmsDatasource.options; const ogcFilterWriter = new OgcFilterWriter(); - - if (options.ogcFilters.enabled && options.ogcFilters.filters) { options.ogcFilters.filters = ogcFilterWriter.checkIgoFiltersProperties( options.ogcFilters.filters, @@ -66,6 +62,5 @@ export class OGCFilterService { options.ogcFilters.interfaceOgcFilters = []; options.filtered = false; } - } } diff --git a/projects/geo/src/lib/filter/shared/ogc-filter.ts b/projects/geo/src/lib/filter/shared/ogc-filter.ts index e82d2cc54c..deb5b11546 100644 --- a/projects/geo/src/lib/filter/shared/ogc-filter.ts +++ b/projects/geo/src/lib/filter/shared/ogc-filter.ts @@ -20,7 +20,10 @@ export class OgcFilterWriter { PropertyIsNotEqualTo: { spatial: false, fieldRestrict: [] }, PropertyIsLike: { spatial: false, fieldRestrict: ['string'] }, PropertyIsGreaterThan: { spatial: false, fieldRestrict: ['number'] }, - PropertyIsGreaterThanOrEqualTo: { spatial: false, fieldRestrict: ['number'] }, + PropertyIsGreaterThanOrEqualTo: { + spatial: false, + fieldRestrict: ['number'] + }, PropertyIsLessThan: { spatial: false, fieldRestrict: ['number'] }, PropertyIsLessThanOrEqualTo: { spatial: false, fieldRestrict: ['number'] }, PropertyIsBetween: { spatial: false, fieldRestrict: ['number'] }, diff --git a/projects/geo/src/lib/map/shared/map.ts b/projects/geo/src/lib/map/shared/map.ts index b40298130a..80010a044c 100644 --- a/projects/geo/src/lib/map/shared/map.ts +++ b/projects/geo/src/lib/map/shared/map.ts @@ -447,9 +447,8 @@ export class IgoMap { strokeRGBA: [number, number, number, number] = [0, 161, 222, 1], strokeWidth: number = 2, fillRGBA: [number, number, number, number] = [0, 161, 222, 0.15], - text?): olstyle.Style { - - + text? + ): olstyle.Style { const stroke = new olstyle.Stroke({ color: strokeRGBA, width: strokeWidth @@ -468,8 +467,7 @@ export class IgoMap { fill: fill }) }); - -} + } setOverlayMarkerStyle(color = 'blue', text?): olstyle.Style { let iconColor; diff --git a/projects/geo/src/lib/wkt/shared/wkt.service.ts b/projects/geo/src/lib/wkt/shared/wkt.service.ts index ee9b523912..2d1985a61a 100644 --- a/projects/geo/src/lib/wkt/shared/wkt.service.ts +++ b/projects/geo/src/lib/wkt/shared/wkt.service.ts @@ -9,18 +9,14 @@ import olWKT from 'ol/format/WKT'; export class WktService { constructor() {} - public wktToFeature(wkt, wktProj, featureProj= 'EPSG:3857') { + public wktToFeature(wkt, wktProj, featureProj = 'EPSG:3857') { return new olWKT().readFeature(wkt, { dataProjection: wktProj, featureProjection: featureProj }); } public extentToWkt(epsgTO, extent, extentProj) { - let currentExtent = olproj.transformExtent( - extent, - extentProj, - epsgTO - ); + let currentExtent = olproj.transformExtent(extent, extentProj, epsgTO); currentExtent = this.roundCoordinateArray(currentExtent, epsgTO, 0); const wktPoly = `POLYGON(( ${extent[0]} ${extent[1]}, @@ -39,7 +35,11 @@ export class WktService { ${extent[0]} ${extent[3]}, ${extent[2]} ${extent[3]}, ${extent[2]} ${extent[1]})`; - return {wktPoly : wktPoly, wktLine : wktLine, wktMultiPoints: wktMultiPoints }; + return { + wktPoly: wktPoly, + wktLine: wktLine, + wktMultiPoints: wktMultiPoints + }; } private roundCoordinateArray(coordinateArray, projection, decimal = 0) { @@ -233,7 +233,7 @@ export class WktService { coord.ul.join(' ') ].join(',') + '))'; - const wktLine = + const wktLine = 'LINESTRING(' + [ coord.ul.join(' '), @@ -244,7 +244,7 @@ export class WktService { ].join(',') + ')'; - const wktMultiPoints = + const wktMultiPoints = 'MULTIPOINT(' + [ coord.ul.join(' '), @@ -253,7 +253,11 @@ export class WktService { coord['ll'].join(' ') ].join(',') + ')'; - return {wktPoly : wktPoly, wktLine : wktLine, wktMultiPoints: wktMultiPoints }; + return { + wktPoly: wktPoly, + wktLine: wktLine, + wktMultiPoints: wktMultiPoints + }; } } } From 1343bbe69edb615f4abfd6a5adb4ef6462b281b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Tue, 16 Oct 2018 11:18:26 -0400 Subject: [PATCH 40/42] Update map.ts --- projects/geo/src/lib/map/shared/map.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/geo/src/lib/map/shared/map.ts b/projects/geo/src/lib/map/shared/map.ts index 80010a044c..3b0ac12727 100644 --- a/projects/geo/src/lib/map/shared/map.ts +++ b/projects/geo/src/lib/map/shared/map.ts @@ -465,6 +465,12 @@ export class IgoMap { radius: 5, stroke: stroke, fill: fill + }), + text: new olstyle.Text({ + font: '12px Calibri,sans-serif', + text: text, + fill: new olstyle.Fill({ color: '#000' }), + stroke: new olstyle.Stroke({ color: '#fff', width: 3 }) }) }); } From 8e10a3f70e5bee7b5b96c6fb6cce925a184e90a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Tue, 16 Oct 2018 11:28:42 -0400 Subject: [PATCH 41/42] remove inused import --- demo/src/app/geo/layer/layer.component.ts | 71 +++++++++++------------ 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/demo/src/app/geo/layer/layer.component.ts b/demo/src/app/geo/layer/layer.component.ts index 8739f4a966..64e6880bf8 100644 --- a/demo/src/app/geo/layer/layer.component.ts +++ b/demo/src/app/geo/layer/layer.component.ts @@ -6,12 +6,10 @@ import { DataSourceService, LayerService, WMSDataSourceOptions, - MetadataDataSourceOptions, LayerOptions, WFSDataSourceOptions, OgcFilterableDataSourceOptions, MetadataLayerOptions - } from '@igo2/geo'; @Component({ @@ -51,43 +49,42 @@ export class AppLayerComponent { ); }); - interface WFSoptions - extends WFSDataSourceOptions, OgcFilterableDataSourceOptions { } + interface WFSoptions + extends WFSDataSourceOptions, + OgcFilterableDataSourceOptions {} - const wfsDatasource: WFSoptions = { - type: 'wfs', - url: 'https://geoegl.msp.gouv.qc.ca/igo2/api/ws/igo_gouvouvert.fcgi', - params: { - featureTypes: 'vg_observation_v_autre_wmst', - fieldNameGeometry: 'geometry', - maxFeatures: 10000, - version: '2.0.0', - outputFormat: 'geojson_utf8', - outputFormatDownload: 'shp' - }, - ogcFilters: { - enabled: true, - editable: true, - filters: { - operator: 'PropertyIsEqualTo', - propertyName: 'code_municipalite', - expression: '10043' - } - } - }; - - - this.dataSourceService - .createAsyncDataSource(wfsDatasource) - .subscribe(dataSource => { - const layer: LayerOptions = { - title: 'WFS ', - visible: true, - source: dataSource - }; - this.map.addLayer(this.layerService.createLayer(layer)); - }); + const wfsDatasource: WFSoptions = { + type: 'wfs', + url: 'https://geoegl.msp.gouv.qc.ca/igo2/api/ws/igo_gouvouvert.fcgi', + params: { + featureTypes: 'vg_observation_v_autre_wmst', + fieldNameGeometry: 'geometry', + maxFeatures: 10000, + version: '2.0.0', + outputFormat: 'geojson_utf8', + outputFormatDownload: 'shp' + }, + ogcFilters: { + enabled: true, + editable: true, + filters: { + operator: 'PropertyIsEqualTo', + propertyName: 'code_municipalite', + expression: '10043' + } + } + }; + this.dataSourceService + .createAsyncDataSource(wfsDatasource) + .subscribe(dataSource => { + const layer: LayerOptions = { + title: 'WFS ', + visible: true, + source: dataSource + }; + this.map.addLayer(this.layerService.createLayer(layer)); + }); this.layerService .createAsyncLayer({ From 3cb852bfc8f8c977d0fa71accad45c2d415a39bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Tue, 16 Oct 2018 13:39:20 -0400 Subject: [PATCH 42/42] fix position buttons layer --- .../ogc-filter-button/ogc-filter-button.component.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/geo/src/lib/filter/ogc-filter-button/ogc-filter-button.component.html b/projects/geo/src/lib/filter/ogc-filter-button/ogc-filter-button.component.html index 0a29b459ee..ae91a7b4cb 100644 --- a/projects/geo/src/lib/filter/ogc-filter-button/ogc-filter-button.component.html +++ b/projects/geo/src/lib/filter/ogc-filter-button/ogc-filter-button.component.html @@ -12,7 +12,10 @@ filter_list -
+ +