diff --git a/packages/geo/src/lib/filter/shared/spatial-filter.service.ts b/packages/geo/src/lib/filter/shared/spatial-filter.service.ts index c46dbeac6c..7a642a21c8 100644 --- a/packages/geo/src/lib/filter/shared/spatial-filter.service.ts +++ b/packages/geo/src/lib/filter/shared/spatial-filter.service.ts @@ -7,7 +7,8 @@ import { Observable } from 'rxjs'; import { Feature } from '../../feature/shared'; import { SpatialFilterQueryType, - SpatialFilterItemType + SpatialFilterItemType, + SpatialFilterType } from './spatial-filter.enum'; import { SpatialFilterThematic } from './spatial-filter.interface'; @@ -157,7 +158,8 @@ export class SpatialFilterService { params: { geometry: 'true', icon: 'true', - buffer: buffer.toString() + bufferInput: buffer.toString(), + simplified: '100' } } ) @@ -185,7 +187,8 @@ export class SpatialFilterService { params: { geometry: 'true', icon: 'true', - buffer: buffer.toString() + buffer: buffer.toString(), + simplified: '100' } } ) @@ -211,7 +214,6 @@ export class SpatialFilterService { .post<{ features: Feature[] }>(url + urlItem, { geometry: 'true', icon: 'true', - buffer, loc: JSON.stringify(feature) }) .pipe( @@ -235,7 +237,6 @@ export class SpatialFilterService { .post<{ features: Feature[] }>(url + urlItem, { geometry: 'true', icon: 'true', - buffer, loc: JSON.stringify(feature) }) .pipe( @@ -282,4 +283,51 @@ export class SpatialFilterService { ); } } + + /* + * Get buffer geometry + */ + loadBufferGeometry( + feature: Feature, + filterType: SpatialFilterType, + buffer?: number, + type?: SpatialFilterQueryType, + ): Observable { + if (filterType === SpatialFilterType.Predefined) { + const featureType = this.urlFilterList[type]; + const featureCode = '/' + feature.properties.code; + if (featureType && featureCode) { + return this.http + .get(this.baseUrl + featureType + featureCode, + { + params: { + geometry: '100', + bufferOutput: buffer.toString() + } + } + ) + .pipe( + map(f => { + f.meta = { + id: f.properties.code, + alias: f.properties.nom, + title: f.properties.nom + }; + return f; + }) + ); + } + } else { + return this.http + .post(this.baseUrl + 'geospatial/buffer?', { + buffer, + loc: JSON.stringify(feature) + }) + .pipe( + map(f => { + return f; + }) + ); + } + } } diff --git a/packages/geo/src/lib/filter/spatial-filter/spatial-filter-item/spatial-filter-item.component.html b/packages/geo/src/lib/filter/spatial-filter/spatial-filter-item/spatial-filter-item.component.html index 82d52eb296..8abf223b4d 100644 --- a/packages/geo/src/lib/filter/spatial-filter/spatial-filter-item/spatial-filter-item.component.html +++ b/packages/geo/src/lib/filter/spatial-filter/spatial-filter-item/spatial-filter-item.component.html @@ -26,7 +26,7 @@ - +
@@ -147,7 +147,7 @@ {{'igo.geo.spatialFilter.goSearch' | translate}} - diff --git a/packages/geo/src/lib/filter/spatial-filter/spatial-filter-item/spatial-filter-item.component.scss b/packages/geo/src/lib/filter/spatial-filter/spatial-filter-item/spatial-filter-item.component.scss index 24b10b8ecb..cf2b2d42b4 100644 --- a/packages/geo/src/lib/filter/spatial-filter/spatial-filter-item/spatial-filter-item.component.scss +++ b/packages/geo/src/lib/filter/spatial-filter/spatial-filter-item/spatial-filter-item.component.scss @@ -1,3 +1,5 @@ +@import '../../../../../../core/src/style/partial/media'; + .header { margin-top: 5px; width: 100%; @@ -44,27 +46,72 @@ } .search-button { - left: 25px; - width: 150px; + left: 15px; + width: 165px; + + @include mobile { + left: 10px; + width: 45%; + min-height: 35px; + white-space: normal; + line-height: normal; + } +} + +.export-button { + left: 15px; + width: 165px; + + @include mobile { + left: 10px; + margin-top: 10px; + width: 45%; + min-height: 35px; + white-space: normal; + line-height: normal; + } } .remove-button { - margin: 12px; - width: 150px; + margin-top: 12px; + left: 5px; + width: 165px; + + @include mobile { + margin: 0px; + width: 45%; + min-height: 35px; + white-space: normal; + line-height: normal; + } } .clear-form-button { left: 10px; - width: 150px; + width: 165px; + + @include mobile { + width: 45%; + min-height: 35px; + white-space: normal; + line-height: normal; + } } .clear-search-button { - left: 10px; - width: 150px; + left: 5px; + width: 165px; + + @include mobile { + width: 45%; + min-height: 35px; + white-space: normal; + line-height: normal; + } } .thematics { - max-height: 30%; + max-height: 35%; overflow: auto; margin-top: 5px; width: 98%; diff --git a/packages/geo/src/lib/filter/spatial-filter/spatial-filter-item/spatial-filter-item.component.ts b/packages/geo/src/lib/filter/spatial-filter/spatial-filter-item/spatial-filter-item.component.ts index e5409455b1..1c2a73e1c3 100644 --- a/packages/geo/src/lib/filter/spatial-filter/spatial-filter-item/spatial-filter-item.component.ts +++ b/packages/geo/src/lib/filter/spatial-filter/spatial-filter-item/spatial-filter-item.component.ts @@ -29,9 +29,7 @@ import { Layer } from '../../../layer/shared'; import { NestedTreeControl } from '@angular/cdk/tree'; import { SpatialFilterThematic } from './../../shared/spatial-filter.interface'; import { MessageService, LanguageService } from '@igo2/core'; -import buffer from '@turf/buffer'; -import * as turf from '@turf/helpers'; -import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; +import { debounceTime } from 'rxjs/operators'; /** * Spatial-Filter-Item (search parameters) @@ -135,6 +133,8 @@ export class SpatialFilterItemComponent implements OnDestroy, OnInit { @Input() layers: Layer[] = []; + @Input() allLayers: Layer[] = []; + @Input() get thematicLength(): number { return this._thematicLength; @@ -230,6 +230,12 @@ export class SpatialFilterItemComponent implements OnDestroy, OnInit { return a.name.localeCompare(b.name); }); } + this.groups.push(this.languageService.translate.instant('igo.geo.terrapi.limites')); + const limits: SpatialFilterThematic = { + name: this.groups[0], + children: [] + }; + this.thematics.push(limits); this.childrens.forEach(child => { if (child.group && (this.groups.indexOf(child.group) === -1)) { this.groups.push(child.group); @@ -239,13 +245,28 @@ export class SpatialFilterItemComponent implements OnDestroy, OnInit { }; this.thematics.push(thematic); } + if (!child.group) { - const thematic: SpatialFilterThematic = { - name: child.name, - children: [], - source: child.source - }; - this.thematics.push(thematic); + if ( + child.name === this.languageService.translate.instant('igo.geo.terrapi.AdmRegion') || + child.name === this.languageService.translate.instant('igo.geo.terrapi.Mun') || + child.name === this.languageService.translate.instant('igo.geo.terrapi.Arrond') || + child.name === this.languageService.translate.instant('igo.geo.terrapi.CircFed') || + child.name === this.languageService.translate.instant('igo.geo.terrapi.CircProv') || + child.name === this.languageService.translate.instant('igo.geo.terrapi.DirReg') || + child.name === this.languageService.translate.instant('igo.geo.terrapi.MRC') || + child.name === this.languageService.translate.instant('igo.geo.terrapi.RegTour')) { + child.group = limits.name; + } else if (child.name === this.languageService.translate.instant('igo.geo.terrapi.routes')) { + child.group = this.languageService.translate.instant('igo.geo.spatialFilter.group.transport'); + } else { + const thematic: SpatialFilterThematic = { + name: child.name, + children: [], + source: child.source + }; + this.thematics.push(thematic); + } } this.thematics.sort((a, b) => { return a.name.localeCompare(b.name); @@ -296,13 +317,25 @@ export class SpatialFilterItemComponent implements OnDestroy, OnInit { if (this.measureUnit === MeasureLengthUnit.Meters && value > 0 && value <= 100000) { this.buffer = value; this.bufferEvent.emit(value); - this.zoneWithBuffer = buffer(turf.polygon(this.drawZone.coordinates), this.bufferFormControl.value / 1000, {units: 'kilometers'}); - this.zoneWithBufferChange.emit(this.zoneWithBuffer); + this.spatialFilterService.loadBufferGeometry( + this.drawZone, + SpatialFilterType.Polygon, + value + ).subscribe((featureGeom: Feature) => { + this.zoneWithBuffer = featureGeom; + this.zoneWithBufferChange.emit(this.zoneWithBuffer); + }); } else if (this.measureUnit === MeasureLengthUnit.Kilometers && value > 0 && value <= 100) { this.buffer = value; this.bufferEvent.emit(value); - this.zoneWithBuffer = buffer(turf.polygon(this.drawZone.coordinates), this.bufferFormControl.value, {units: 'kilometers'}); - this.zoneWithBufferChange.emit(this.zoneWithBuffer); + this.spatialFilterService.loadBufferGeometry( + this.drawZone, + SpatialFilterType.Polygon, + value * 1000 + ).subscribe((featureGeom: Feature) => { + this.zoneWithBuffer = featureGeom; + this.zoneWithBufferChange.emit(this.zoneWithBuffer); + }); } else if (value === 0) { this.buffer = value; this.bufferEvent.emit(value); @@ -535,15 +568,27 @@ export class SpatialFilterItemComponent implements OnDestroy, OnInit { */ toggleSearchButton() { if (!this.isPredefined()) { - this.drawZone.meta = { - id: undefined, - title: 'Zone' - }; - this.drawZone.properties = { - nom: 'Zone', - type: this.type as string - }; - this.drawZoneEvent.emit(this.drawZone); + if (this.buffer > 0) { + this.zoneWithBuffer.meta = { + id: undefined, + title: 'Zone' + }; + this.zoneWithBuffer.properties = { + nom: 'Zone', + type: this.type as string + }; + this.drawZoneEvent.emit(this.zoneWithBuffer); + } else { + this.drawZone.meta = { + id: undefined, + title: 'Zone' + }; + this.drawZone.properties = { + nom: 'Zone', + type: this.type as string + }; + this.drawZoneEvent.emit(this.drawZone); + } } if (this.isPoint()) { this.radiusEvent.emit(this.radius); diff --git a/packages/geo/src/lib/filter/spatial-filter/spatial-filter-list/spatial-filter-list.component.html b/packages/geo/src/lib/filter/spatial-filter/spatial-filter-list/spatial-filter-list.component.html index 27080f45b7..fcd6e76b6c 100644 --- a/packages/geo/src/lib/filter/spatial-filter/spatial-filter-list/spatial-filter-list.component.html +++ b/packages/geo/src/lib/filter/spatial-filter/spatial-filter-list/spatial-filter-list.component.html @@ -11,7 +11,7 @@ - +
diff --git a/packages/geo/src/lib/filter/spatial-filter/spatial-filter-list/spatial-filter-list.component.ts b/packages/geo/src/lib/filter/spatial-filter/spatial-filter-list/spatial-filter-list.component.ts index 721f82584b..f6f66438e8 100644 --- a/packages/geo/src/lib/filter/spatial-filter/spatial-filter-list/spatial-filter-list.component.ts +++ b/packages/geo/src/lib/filter/spatial-filter/spatial-filter-list/spatial-filter-list.component.ts @@ -1,7 +1,7 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; import { EntityStore } from '@igo2/common'; import { SpatialFilterService } from './../../shared/spatial-filter.service'; -import { SpatialFilterQueryType } from './../../shared/spatial-filter.enum'; +import { SpatialFilterQueryType, SpatialFilterType } from './../../shared/spatial-filter.enum'; import { Component, Input, @@ -16,23 +16,7 @@ import { FormControl } from '@angular/forms'; import { Feature } from '../../../feature'; import { MeasureLengthUnit } from '../../../measure/shared'; import { LanguageService, MessageService } from '@igo2/core'; -// import buffer from '@turf/buffer'; -// import * as TurfProj from '@turf/projection'; import { Layer } from '../../../layer'; -import { - LineString, - MultiLineString, - MultiPoint, - MultiPolygon, - Point, - Polygon, -} from 'ol/geom'; -import LinearRing from 'ol/geom/LinearRing'; -import GeoJSON from 'ol/format/GeoJSON'; -// import GeoJSONReader from 'jsts/org/locationtech/jts/io/GeoJSONReader'; -// import GeoJSONWriter from 'jsts/org/locationtech/jts/io/GeoJSONWriter'; -// import { BufferOp } from 'jsts/org/locationtech/jts/operation/buffer'; -// import Parser from 'jsts/org/locationtech/jts/io/OL3Parser'; @Component({ selector: 'igo-spatial-filter-list', @@ -85,9 +69,6 @@ export class SpatialFilterListComponent implements OnInit, OnDestroy { public bufferFormControl = new FormControl(); - // private reader = new GeoJSONReader(); - // private writer = new GeoJSONWriter(); - /** * Available measure units for the measure type given * @internal @@ -127,51 +108,27 @@ export class SpatialFilterListComponent implements OnInit, OnDestroy { ) .subscribe((value) => { if (this.measureUnit === MeasureLengthUnit.Meters && value > 0 && value <= 100000) { - // this.bufferChange.emit(value); - // // const bufferFeature = {...this.selectedZone}; - // const format = new GeoJSON(); - // const bufferFeature = format.readFeature(this.selectedZone, { - // featureProjection: 'EPSG:4326', - // }); - // const parser = new Parser(); - // parser.inject( - // Point, - // LineString, - // LinearRing, - // Polygon, - // MultiPoint, - // MultiLineString, - // MultiPolygon - // ); - // - // // let bufferFeature = TurfProj.toMercator(this.selectedZone); - // // console.log(bufferFeature); - // // let jstsGeom = this.reader.read(bufferFeature.geometry); - // // console.log(jstsGeom); - // // console.log(bufferFeature); - // // for (let coordinate of bufferFeature.geometry.coordinates[0][0]) { - // // coordinate = olproj.transform(coordinate, 'EPSG:4326', 'EPSG:3857'); - // // } - // // bufferFeature.geometry = OlPolygon.transform('EPSG:4326', 'EPSG:3857'); - // // bufferFeature = jstsGeom.buffer(this.bufferFormControl.value / 1000); - // // for (let coordinate of this.zoneWithBuffer.geometry.coordinates[0][0]) { - // // coordinate = olproj.transform(coordinate, 'EPSG:3857', 'EPSG:4326'); - // // } - // - // // convert the OpenLayers geometry to a JSTS geometry - // const jstsGeom = parser.read(bufferFeature.geometry); - // // create a buffer of 40 meters around each line - // const buffered = jstsGeom.buffer(this.bufferFormControl.value); - // - // this.zoneWithBuffer = {...this.selectedZone}; - // this.zoneWithBuffer.geometry = parser.write(buffered); - // // this.zoneWithBuffer.geometry = this.writer.write(bufferFeature); - // // this.zoneWithBuffer = TurfProj.toWgs84(this.zoneWithBuffer); - // this.zoneWithBufferChange.emit(this.zoneWithBuffer); - // } else if (this.measureUnit === MeasureLengthUnit.Kilometers && value > 0 && value <= 100) { - // this.bufferChange.emit(value); - // this.zoneWithBuffer = buffer(this.selectedZone, this.bufferFormControl.value, {units: 'kilometers'}); - this.zoneWithBufferChange.emit(this.zoneWithBuffer); + this.bufferChange.emit(value); + this.spatialFilterService.loadBufferGeometry( + this.selectedZone, + SpatialFilterType.Predefined, + value, + this.queryType + ).subscribe((featureGeom: Feature) => { + this.zoneWithBuffer = featureGeom; + this.zoneWithBufferChange.emit(this.zoneWithBuffer); + }); + } else if (this.measureUnit === MeasureLengthUnit.Kilometers && value > 0 && value <= 100) { + this.bufferChange.emit(value); + this.spatialFilterService.loadBufferGeometry( + this.selectedZone, + SpatialFilterType.Predefined, + value * 1000, + this.queryType + ).subscribe((featureGeom: Feature) => { + this.zoneWithBuffer = featureGeom; + this.zoneWithBufferChange.emit(this.zoneWithBuffer); + }); } else if (value === 0 && this.layers.length > 0) { this.bufferChange.emit(value); this.zoneWithBufferChange.emit(this.selectedZone); @@ -195,7 +152,6 @@ export class SpatialFilterListComponent implements OnInit, OnDestroy { } onZoneChange(feature) { - this.bufferFormControl.setValue(0); if (feature && this.queryType) { this.spatialFilterService.loadItemById(feature, this.queryType) .subscribe((featureGeom: Feature) => { diff --git a/packages/geo/src/locale/en.geo.json b/packages/geo/src/locale/en.geo.json index 88c0293747..8827d0f10b 100644 --- a/packages/geo/src/locale/en.geo.json +++ b/packages/geo/src/locale/en.geo.json @@ -424,6 +424,7 @@ "minute": "Minute" }, "spatialFilter": { + "spatialFilter": "Spatial filter", "predefined": "Predefined Zone", "draw": "Draw", "polygon": "Polygon", @@ -440,7 +441,7 @@ "removeLayer": "Remove results", "exportLayer": "Export results", "clearForm": "Remove draw", - "clearSearch": "Reset", + "clearSearch": "Reset field", "Address": "Addresses", "Thematics": "Thematics", "searchResults": "Search Results", @@ -471,6 +472,7 @@ "DirReg": "Regionals directorates", "MRC": "RCM", "RegTour": "Touristics regions", + "limites": "Administrative boundaries", "bornes": "Landmarks", "hydro": "Hydrography", "routes": "Roads", diff --git a/packages/geo/src/locale/fr.geo.json b/packages/geo/src/locale/fr.geo.json index 739a2007ef..33e64f74d4 100644 --- a/packages/geo/src/locale/fr.geo.json +++ b/packages/geo/src/locale/fr.geo.json @@ -423,6 +423,7 @@ "minute": "Minute" }, "spatialFilter": { + "spatialFilter": "Filtre spatial", "predefined": "Zone Prédéfinie", "draw": "Dessin", "polygon": "Polygone", @@ -440,7 +441,7 @@ "removeLayer": "Retirer les résultats", "exportLayer": "Exporter les résultats", "clearForm": "Retirer le dessin", - "clearSearch": "Réinitialiser", + "clearSearch": "Réinitialiser les champs", "Address": "Adresses", "Thematics": "Thématiques", "searchResults": "Résultats de la recherche", @@ -471,6 +472,7 @@ "DirReg": "Directions régionales", "MRC": "MRC", "RegTour": "Régions touristiques", + "limites": "Limites administratives", "bornes": "Bornes sumi", "hydro": "Hydrographie", "routes": "Routes", diff --git a/packages/integration/src/lib/filter/spatial-filter-tool/spatial-filter-tool.component.html b/packages/integration/src/lib/filter/spatial-filter-tool/spatial-filter-tool.component.html index 2fc23822e3..b26908ed1e 100644 --- a/packages/integration/src/lib/filter/spatial-filter-tool/spatial-filter-tool.component.html +++ b/packages/integration/src/lib/filter/spatial-filter-tool/spatial-filter-tool.component.html @@ -20,6 +20,7 @@ [loading]="loading" [store]="store" [layers]="activeLayers" + [allLayers]="layers" [thematicLength]="thematicLength" (radiusEvent)="buffer = $event" (bufferEvent)="buffer = $event" diff --git a/packages/integration/src/lib/filter/spatial-filter-tool/spatial-filter-tool.component.ts b/packages/integration/src/lib/filter/spatial-filter-tool/spatial-filter-tool.component.ts index e504b6adda..554c730ce4 100644 --- a/packages/integration/src/lib/filter/spatial-filter-tool/spatial-filter-tool.component.ts +++ b/packages/integration/src/lib/filter/spatial-filter-tool/spatial-filter-tool.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, ChangeDetectionStrategy, ChangeDetectorRef, OnDestroy } from '@angular/core'; +import { Component, Input, ChangeDetectionStrategy, ChangeDetectorRef, OnDestroy, OnInit } from '@angular/core'; import { MatIconRegistry } from '@angular/material/icon'; import { Observable, forkJoin, Subject } from 'rxjs'; import { tap, take, takeUntil } from 'rxjs/operators'; @@ -51,7 +51,7 @@ import { WorkspaceState } from '../../workspace/workspace.state'; styleUrls: ['./spatial-filter-tool.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush }) -export class SpatialFilterToolComponent implements OnDestroy { +export class SpatialFilterToolComponent implements OnInit, OnDestroy { get map(): IgoMap { return this.mapState.map; } @@ -102,6 +102,14 @@ export class SpatialFilterToolComponent implements OnDestroy { private cdRef: ChangeDetectorRef ) {} + ngOnInit() { + for (const layer of this.map.layers) { + if (layer.title && layer.title.includes(this.languageService.translate.instant('igo.geo.spatialFilter.spatialFilter'))) { + this.layers.push(layer); + } + } + } + ngOnDestroy() { this.unsubscribe$.next(); this.unsubscribe$.complete(); @@ -191,7 +199,7 @@ export class SpatialFilterToolComponent implements OnDestroy { this.activeLayers = []; this.thematicLength = 0; this.iterator = 1; - if (this.type !== SpatialFilterType.Predefined) { + if (this.type === SpatialFilterType.Predefined) { this.zone = undefined; this.queryType = undefined; } @@ -201,7 +209,9 @@ export class SpatialFilterToolComponent implements OnDestroy { this.loading = true; let zeroResults = true; let thematics; - this.tryAddFeaturesToMap([this.zone]); + if (this.buffer === 0) { + this.tryAddFeaturesToMap([this.zone]); + } if (this.itemType !== SpatialFilterItemType.Thematics) { const theme: SpatialFilterThematic = { name: '' @@ -234,6 +244,8 @@ export class SpatialFilterToolComponent implements OnDestroy { let idLinePoly; features.forEach(feature => { if (feature.geometry.type === 'Point') { + feature.properties.longitude = feature.geometry.coordinates[0]; + feature.properties.latitude = feature.geometry.coordinates[1]; featuresPoint.push(feature); idPoint = feature.meta.id; } else { @@ -300,7 +312,7 @@ export class SpatialFilterToolComponent implements OnDestroy { let i = 1; for (const feature of features) { if (this.type === SpatialFilterType.Predefined) { - for (const layer of this.map.layers) { + for (const layer of this.layers) { if ( layer.options._internal && layer.options._internal.code === feature.properties.code && @@ -344,7 +356,9 @@ export class SpatialFilterToolComponent implements OnDestroy { .pipe(take(1)) .subscribe((dataSource: DataSource) => { const olLayer = this.layerService.createLayer({ - title: ('Zone ' + i) as string, + title: ('Zone ' + i + ' - ' + this.languageService.translate.instant( + 'igo.geo.spatialFilter.spatialFilter' + )) as string, workspace: { enabled: true }, _internal: { code: @@ -399,7 +413,7 @@ export class SpatialFilterToolComponent implements OnDestroy { } /** - * Try to point features to the map + * Try to add point features to the map * Necessary to create clusters */ private tryAddPointToMap(features: Feature[], id) { @@ -434,7 +448,9 @@ export class SpatialFilterToolComponent implements OnDestroy { } const olLayer = this.layerService.createLayer({ - title: (features[0].meta.title + ' ' + i) as string, + title: (features[0].meta.title + ' ' + i + ' - ' + this.languageService.translate.instant( + 'igo.geo.spatialFilter.spatialFilter' + )) as string, source: dataSource, visible: true, style @@ -444,12 +460,14 @@ export class SpatialFilterToolComponent implements OnDestroy { return featureToOl(feature, this.map.projection); }); dataSource.ol.source.addFeatures(featuresOl); - if (this.map.layers.find(layer => layer.id === olLayer.id)) { + if (this.layers.find(layer => layer.id === olLayer.id)) { this.map.removeLayer( - this.map.layers.find(layer => layer.id === olLayer.id) + this.layers.find(layer => layer.id === olLayer.id) ); i = i - 1; - olLayer.title = (features[0].meta.title + ' ' + i) as string; + olLayer.title = (features[0].meta.title + ' ' + i + ' - ' + this.languageService.translate.instant( + 'igo.geo.spatialFilter.spatialFilter' + )) as string; olLayer.options.title = olLayer.title; } this.iterator = i; @@ -487,7 +505,7 @@ export class SpatialFilterToolComponent implements OnDestroy { if (this.map === undefined) { return; } - for (const layer of this.map.layers) { + for (const layer of this.layers) { if (layer.title?.startsWith(features[0].meta.title)) { i++; } @@ -501,7 +519,9 @@ export class SpatialFilterToolComponent implements OnDestroy { .pipe(take(1)) .subscribe((dataSource: DataSource) => { const olLayer = this.layerService.createLayer({ - title: (features[0].meta.title + ' ' + i) as string, + title: (features[0].meta.title + ' ' + i + ' - ' + this.languageService.translate.instant( + 'igo.geo.spatialFilter.spatialFilter' + )) as string, source: dataSource, visible: true }); @@ -509,12 +529,14 @@ export class SpatialFilterToolComponent implements OnDestroy { return featureToOl(feature, this.map.projection); }); dataSource.ol.addFeatures(featuresOl); - if (this.map.layers.find(layer => layer.id === olLayer.id)) { + if (this.layers.find(layer => layer.id === olLayer.id)) { this.map.removeLayer( - this.map.layers.find(layer => layer.id === olLayer.id) + this.layers.find(layer => layer.id === olLayer.id) ); i = i - 1; - olLayer.title = (features[0].meta.title + ' ' + i) as string; + olLayer.title = (features[0].meta.title + ' ' + i + ' - ' + this.languageService.translate.instant( + 'igo.geo.spatialFilter.spatialFilter' + )) as string; olLayer.options.title = olLayer.title; } this.map.addLayer(olLayer);