From e946efcd94a9e150ac9f125e74d322d30441425d Mon Sep 17 00:00:00 2001 From: "MAXIME LAMER (LAMM26)" Date: Mon, 18 Oct 2021 10:51:06 -0400 Subject: [PATCH 01/10] feat(export): export unique CSVs --- .../import-export/import-export.component.ts | 96 ++++++++++++++----- 1 file changed, 71 insertions(+), 25 deletions(-) diff --git a/packages/geo/src/lib/import-export/import-export/import-export.component.ts b/packages/geo/src/lib/import-export/import-export/import-export.component.ts index 1407147b08..3b20d56b82 100644 --- a/packages/geo/src/lib/import-export/import-export/import-export.component.ts +++ b/packages/geo/src/lib/import-export/import-export/import-export.component.ts @@ -459,11 +459,17 @@ export class ImportExportComponent implements OnDestroy, OnInit { this.handlePopup(); } - data.layers.forEach((layer) => { + let geomTypesCSV: { geometryType: string, features: any[] }[] = []; + let featuresCSV: any[] = []; + let filename: string = ""; + + for (const [layerIndex, layer] of data.layers.entries()) { const lay = this.map.getLayerById(layer); - let filename = lay.title; - if (data.name !== undefined) { - filename = data.name; + if (!(data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma)) { + filename = lay.title; + if (data.name) { + filename = data.name; + } } const dSOptions: DataSourceOptions = lay.dataSource.options; if (data.format === ExportFormat.URL && dSOptions.download && (dSOptions.download.url || dSOptions.download.dynamicUrl)) { @@ -552,6 +558,22 @@ export class ImportExportComponent implements OnDestroy, OnInit { } } + if (data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma) { + geomTypes.forEach(geomType => geomTypesCSV.push(geomType)); + + if (layerIndex !== data.layers.length - 1) { + filename = filename + lay.title + "_"; + continue; + } else { + filename += lay.title; + geomTypesCSV.forEach(geomType => { + geomType.features.forEach(feature => { + featuresCSV.push(feature); + }); + }); + } + } + if (geomTypes.length === 0) { this.loading$.next(false); const title = translate.instant('igo.geo.export.nothing.title'); @@ -559,29 +581,53 @@ export class ImportExportComponent implements OnDestroy, OnInit { this.messageService.error(message, title, { timeOut: 20000 }); } else { - geomTypes.map(geomType => - this.exportService.export(geomType.features, data.format, filename + geomType.geometryType, data.encoding, this.map.projection) - .subscribe( - () => {}, - (error: Error) => this.onFileExportError(error), - () => { - this.onFileExportSuccess(); - - geomType.features.forEach(feature => { - const radius: number = feature.get('rad'); - - if (radius) { - const point = new olPoint([feature.get('longitude'), feature.get('latitude')]); - point.transform('EPSG:4326', feature.get('_projection')); - feature.setGeometry(point); - } - }); - - this.loading$.next(false); + if (!(data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma)) { + geomTypes.map(geomType => + this.exportService.export(geomType.features, data.format, filename + geomType.geometryType, data.encoding, this.map.projection) + .subscribe( + () => {}, + (error: Error) => this.onFileExportError(error), + () => { + this.onFileExportSuccess(); + + geomType.features.forEach(feature => { + const radius: number = feature.get('rad'); + + if (radius) { + const point = new olPoint([feature.get('longitude'), feature.get('latitude')]); + point.transform('EPSG:4326', feature.get('_projection')); + feature.setGeometry(point); + } + }); + + this.loading$.next(false); } - )); + )); + } } - }); + }; + if (data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma) { + this.exportService.export(featuresCSV, data.format, filename, data.encoding, this.map.projection) + .subscribe( + () => {}, + (error: Error) => this.onFileExportError(error), + () => { + this.onFileExportSuccess(); + + featuresCSV.forEach(feature => { + const radius: number = feature.get('rad'); + + if (radius) { + const point = new olPoint([feature.get('longitude'), feature.get('latitude')]); + point.transform('EPSG:4326', feature.get('_projection')); + feature.setGeometry(point); + } + }); + + this.loading$.next(false); + } + ); + } } private buildForm() { From 5f3962d019f7e6de33977c94ce1aef4295ef4654 Mon Sep 17 00:00:00 2001 From: MAXIME LAMER Date: Tue, 26 Oct 2021 15:40:07 -0400 Subject: [PATCH 02/10] added toggle to combine layers --- .../import-export/import-export.component.html | 8 ++++++++ .../import-export/import-export.component.scss | 2 +- .../import-export/import-export.component.ts | 14 ++++++++------ .../lib/import-export/shared/export.interface.ts | 2 +- packages/geo/src/locale/en.geo.json | 6 +++--- packages/geo/src/locale/fr.geo.json | 6 +++--- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/packages/geo/src/lib/import-export/import-export/import-export.component.html b/packages/geo/src/lib/import-export/import-export/import-export.component.html index 2d5fa5c857..a8e524f982 100644 --- a/packages/geo/src/lib/import-export/import-export/import-export.component.html +++ b/packages/geo/src/lib/import-export/import-export/import-export.component.html @@ -132,6 +132,14 @@

{{'igo.geo.importExportForm.exportNoLayersExportable' | translate}}

+
+ + {{'igo.geo.importExportForm.exportCombineResults' | translate}} + +
+
geomTypesCSV.push(geomType)); if (layerIndex !== data.layers.length - 1) { - filename = filename + lay.title + "_"; continue; } else { - filename += lay.title; geomTypesCSV.forEach(geomType => { geomType.features.forEach(feature => { featuresCSV.push(feature); @@ -581,7 +581,7 @@ export class ImportExportComponent implements OnDestroy, OnInit { this.messageService.error(message, title, { timeOut: 20000 }); } else { - if (!(data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma)) { + if (!(data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma) || !data.combineLayers) { geomTypes.map(geomType => this.exportService.export(geomType.features, data.format, filename + geomType.geometryType, data.encoding, this.map.projection) .subscribe( @@ -606,7 +606,7 @@ export class ImportExportComponent implements OnDestroy, OnInit { } } }; - if (data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma) { + if ((data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma) && data.combineLayers) { this.exportService.export(featuresCSV, data.format, filename, data.encoding, this.map.projection) .subscribe( () => {}, @@ -641,6 +641,7 @@ export class ImportExportComponent implements OnDestroy, OnInit { layers: [[], [Validators.required]], layersWithSelection: [[]], encoding: [EncodingFormat.UTF8, [Validators.required]], + combineLayers: [true, [Validators.required]], featureInMapExtent: [false, [Validators.required]], name: ['', [Validators.required]] }); @@ -650,6 +651,7 @@ export class ImportExportComponent implements OnDestroy, OnInit { layers: [[], [Validators.required]], layersWithSelection: [[]], encoding: [EncodingFormat.UTF8, [Validators.required]], + combineLayers: [true, [Validators.required]], featureInMapExtent: [false, [Validators.required]], }); } diff --git a/packages/geo/src/lib/import-export/shared/export.interface.ts b/packages/geo/src/lib/import-export/shared/export.interface.ts index 584324f492..a2eaa22af2 100644 --- a/packages/geo/src/lib/import-export/shared/export.interface.ts +++ b/packages/geo/src/lib/import-export/shared/export.interface.ts @@ -6,6 +6,6 @@ export interface ExportOptions { layers: string[]; layersWithSelection?: string[]; name?: string; + combineLayers?: boolean; featureInMapExtent?: boolean; - circlesToPolygons?: boolean; } diff --git a/packages/geo/src/locale/en.geo.json b/packages/geo/src/locale/en.geo.json index d897749a2b..267d1bf14a 100644 --- a/packages/geo/src/locale/en.geo.json +++ b/packages/geo/src/locale/en.geo.json @@ -119,7 +119,7 @@ "exportButton": "Export", "exportButtonLink": "Open the link", "exportButtonLinks": "Open the links", - "exportCircleToPolygon": "Transform Circle entities in polygons", + "exportCombineResults": "Combine layers into one file", "exportFormatPlaceholder": "Format", "exportLayerPlaceholder": "Layer", "exportFileNamePlaceholder": "Filename", @@ -382,8 +382,8 @@ "notification": "notification ...", "uturnText": "Make u-turn and head {{translatedDirection}} on {{route}}", "unknown": "???", - - "cntSuffix": { + + "cntSuffix": { "first": "st", "secondAndMore": "rd" }, diff --git a/packages/geo/src/locale/fr.geo.json b/packages/geo/src/locale/fr.geo.json index 38d70eecf5..f0c91df517 100644 --- a/packages/geo/src/locale/fr.geo.json +++ b/packages/geo/src/locale/fr.geo.json @@ -119,7 +119,7 @@ "exportButton": "Exporter", "exportButtonLink": "Ouvrir le lien", "exportButtonLinks": "Ouvrir les liens", - "exportCircleToPolygon": "Transformer les entités de type Cercle en polygones", + "exportCombineResults": "Combiner les couches dans un seul fichier", "exportFormatPlaceholder": "Format", "exportLayerPlaceholder": "Couche(s)", "exportFileNamePlaceholder": "Nom du fichier", @@ -381,8 +381,8 @@ "notification": "notification ...", "uturnText": "Faire demi-tour et continuer en direction {{translatedDirection}} sur {{route}}", "unknown": "???", - - "cntSuffix": { + + "cntSuffix": { "first": "ère", "secondAndMore": "e" }, From 262db67e434b7af96592643711162094c2a1e917 Mon Sep 17 00:00:00 2001 From: MAXIME LAMER Date: Thu, 28 Oct 2021 15:30:36 -0400 Subject: [PATCH 03/10] added empty row toggle --- .../import-export.component.html | 8 ++++++++ .../import-export.component.scss | 2 +- .../import-export/import-export.component.ts | 20 +++++++++++++++++-- .../import-export/shared/export.interface.ts | 1 + packages/geo/src/locale/en.geo.json | 1 + packages/geo/src/locale/fr.geo.json | 1 + 6 files changed, 30 insertions(+), 3 deletions(-) diff --git a/packages/geo/src/lib/import-export/import-export/import-export.component.html b/packages/geo/src/lib/import-export/import-export/import-export.component.html index a8e524f982..a84b8882a9 100644 --- a/packages/geo/src/lib/import-export/import-export/import-export.component.html +++ b/packages/geo/src/lib/import-export/import-export/import-export.component.html @@ -140,6 +140,14 @@

{{'igo.geo.importExportForm.exportNoLayersExportable' | translate}}

+
+ + {{'igo.geo.importExportForm.exportSeparator' | translate}} + +
+
{ - geomType.features.forEach(feature => { - featuresCSV.push(feature); + geomType.features.forEach(currentFeature => { + if (data.separator) { + if (previousFeature) { + if (currentFeature.get('type') !== previousFeature.get('type')) { + const emptyRowFeature = previousFeature.clone(); + const previousFeatureKeys: Array = previousFeature.getKeys(); + previousFeatureKeys.forEach(key => { + emptyRowFeature.unset(key, true); + }); + featuresCSV.push(emptyRowFeature); + } + } + } + featuresCSV.push(currentFeature); + previousFeature = currentFeature; }); }); } @@ -642,6 +656,7 @@ export class ImportExportComponent implements OnDestroy, OnInit { layersWithSelection: [[]], encoding: [EncodingFormat.UTF8, [Validators.required]], combineLayers: [true, [Validators.required]], + separator: [false, [Validators.required]], featureInMapExtent: [false, [Validators.required]], name: ['', [Validators.required]] }); @@ -652,6 +667,7 @@ export class ImportExportComponent implements OnDestroy, OnInit { layersWithSelection: [[]], encoding: [EncodingFormat.UTF8, [Validators.required]], combineLayers: [true, [Validators.required]], + separator: [false, [Validators.required]], featureInMapExtent: [false, [Validators.required]], }); } diff --git a/packages/geo/src/lib/import-export/shared/export.interface.ts b/packages/geo/src/lib/import-export/shared/export.interface.ts index a2eaa22af2..139e541df3 100644 --- a/packages/geo/src/lib/import-export/shared/export.interface.ts +++ b/packages/geo/src/lib/import-export/shared/export.interface.ts @@ -7,5 +7,6 @@ export interface ExportOptions { layersWithSelection?: string[]; name?: string; combineLayers?: boolean; + separator?: boolean; featureInMapExtent?: boolean; } diff --git a/packages/geo/src/locale/en.geo.json b/packages/geo/src/locale/en.geo.json index 267d1bf14a..af39f4b612 100644 --- a/packages/geo/src/locale/en.geo.json +++ b/packages/geo/src/locale/en.geo.json @@ -123,6 +123,7 @@ "exportFormatPlaceholder": "Format", "exportLayerPlaceholder": "Layer", "exportFileNamePlaceholder": "Filename", + "exportSeparator": "Insert empty row between layers", "encodingPlaceholder": "Encoding", "exportTabTitle": "Export", "exportFeatureInExtent": "Export only features in map extent", diff --git a/packages/geo/src/locale/fr.geo.json b/packages/geo/src/locale/fr.geo.json index f0c91df517..b48c868c3f 100644 --- a/packages/geo/src/locale/fr.geo.json +++ b/packages/geo/src/locale/fr.geo.json @@ -123,6 +123,7 @@ "exportFormatPlaceholder": "Format", "exportLayerPlaceholder": "Couche(s)", "exportFileNamePlaceholder": "Nom du fichier", + "exportSeparator": "Insérer un enregistrement vide entre les couches", "encodingPlaceholder": "Encodage", "exportTabTitle": "Exporter", "exportFeatureInExtent": "Seulement les entités contenues dans la carte", From c2c458ebefa513ed64c5956f69b553a76e6b101b Mon Sep 17 00:00:00 2001 From: MAXIME LAMER Date: Fri, 19 Nov 2021 12:33:26 -0500 Subject: [PATCH 04/10] refactor(export): change label of toggle and add column when exporting csv --- .../import-export/import-export/import-export.component.ts | 2 ++ packages/geo/src/locale/en.geo.json | 2 +- packages/geo/src/locale/fr.geo.json | 2 +- .../spatial-filter-tool/spatial-filter-tool.component.ts | 5 ++++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/geo/src/lib/import-export/import-export/import-export.component.ts b/packages/geo/src/lib/import-export/import-export/import-export.component.ts index 3e0fab0554..b4af623e0c 100644 --- a/packages/geo/src/lib/import-export/import-export/import-export.component.ts +++ b/packages/geo/src/lib/import-export/import-export/import-export.component.ts @@ -538,6 +538,8 @@ export class ImportExportComponent implements OnDestroy, OnInit { geomTypes.forEach(geomType => { geomType.features.forEach(feature => { + const re = new RegExp('^\\D+'); + feature.set('couche', lay.title.match(re)[0].trim()); const radius: number = feature.get('rad'); if (radius) { diff --git a/packages/geo/src/locale/en.geo.json b/packages/geo/src/locale/en.geo.json index af39f4b612..95501e711c 100644 --- a/packages/geo/src/locale/en.geo.json +++ b/packages/geo/src/locale/en.geo.json @@ -123,7 +123,7 @@ "exportFormatPlaceholder": "Format", "exportLayerPlaceholder": "Layer", "exportFileNamePlaceholder": "Filename", - "exportSeparator": "Insert empty row between layers", + "exportSeparator": "Insert separator (empty row) between layers", "encodingPlaceholder": "Encoding", "exportTabTitle": "Export", "exportFeatureInExtent": "Export only features in map extent", diff --git a/packages/geo/src/locale/fr.geo.json b/packages/geo/src/locale/fr.geo.json index b48c868c3f..71274082e1 100644 --- a/packages/geo/src/locale/fr.geo.json +++ b/packages/geo/src/locale/fr.geo.json @@ -123,7 +123,7 @@ "exportFormatPlaceholder": "Format", "exportLayerPlaceholder": "Couche(s)", "exportFileNamePlaceholder": "Nom du fichier", - "exportSeparator": "Insérer un enregistrement vide entre les couches", + "exportSeparator": "Insérer un séparateur (ligne vide) entre les couches", "encodingPlaceholder": "Encodage", "exportTabTitle": "Exporter", "exportFeatureInExtent": "Seulement les entités contenues dans la carte", 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 3f7880cfdb..b414672659 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 @@ -132,8 +132,11 @@ export class SpatialFilterToolComponent implements OnInit, OnDestroy { activateExportTool() { const ids = []; + const re = new RegExp('^Zone \\d+'); for (const layer of this.layers) { - ids.push(layer.id); + if(layer.title.match(re)[0]) { + ids.push(layer.id); + } } this.importExportState.setMode(ImportExportMode.export); this.importExportState.setsExportOptions({ layers: ids } as ExportOptions); From c8e8790e3681fdce0217c0a433e2208cc307c1e2 Mon Sep 17 00:00:00 2001 From: MAXIME LAMER Date: Wed, 24 Nov 2021 10:13:54 -0500 Subject: [PATCH 05/10] refactor(remove zone when exporting results from spatial filter tool) --- .../filter/spatial-filter-tool/spatial-filter-tool.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b414672659..17a29ed1c8 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 @@ -134,7 +134,7 @@ export class SpatialFilterToolComponent implements OnInit, OnDestroy { const ids = []; const re = new RegExp('^Zone \\d+'); for (const layer of this.layers) { - if(layer.title.match(re)[0]) { + if (!layer.title.match(re)) { ids.push(layer.id); } } From 39bd4d44435a6db8246aaea0835af93fcf4c8ea8 Mon Sep 17 00:00:00 2001 From: Philippe Lafreniere Date: Fri, 3 Dec 2021 12:29:00 -0500 Subject: [PATCH 06/10] fix(demo): fix import-export lib demo --- demo/src/app/geo/import-export/import-export.component.html | 2 +- demo/src/app/geo/import-export/import-export.component.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/demo/src/app/geo/import-export/import-export.component.html b/demo/src/app/geo/import-export/import-export.component.html index 849620ce06..83a64d90b6 100644 --- a/demo/src/app/geo/import-export/import-export.component.html +++ b/demo/src/app/geo/import-export/import-export.component.html @@ -13,7 +13,7 @@ - + diff --git a/demo/src/app/geo/import-export/import-export.component.ts b/demo/src/app/geo/import-export/import-export.component.ts index d0cc61f2bb..cd33ac17f5 100644 --- a/demo/src/app/geo/import-export/import-export.component.ts +++ b/demo/src/app/geo/import-export/import-export.component.ts @@ -2,6 +2,7 @@ import { Component } from '@angular/core'; import { LanguageService } from '@igo2/core'; import { IgoMap, LayerService } from '@igo2/geo'; +import { WorkspaceStore } from '@igo2/common' @Component({ selector: 'app-import-export', @@ -22,6 +23,8 @@ export class AppImportExportComponent { zoom: 9 }; + public store = new WorkspaceStore([]); + constructor( private languageService: LanguageService, private layerService: LayerService From 1f9b774e9591702d61e749f5ae07f8c39517620b Mon Sep 17 00:00:00 2001 From: Philippe Lafreniere Date: Fri, 3 Dec 2021 12:48:51 -0500 Subject: [PATCH 07/10] lint --- demo/src/app/geo/import-export/import-export.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/src/app/geo/import-export/import-export.component.ts b/demo/src/app/geo/import-export/import-export.component.ts index cd33ac17f5..362eb2ddfa 100644 --- a/demo/src/app/geo/import-export/import-export.component.ts +++ b/demo/src/app/geo/import-export/import-export.component.ts @@ -2,7 +2,7 @@ import { Component } from '@angular/core'; import { LanguageService } from '@igo2/core'; import { IgoMap, LayerService } from '@igo2/geo'; -import { WorkspaceStore } from '@igo2/common' +import { WorkspaceStore } from '@igo2/common'; @Component({ selector: 'app-import-export', From 70cfc66786287d52742df8b3920c90b0e2cb0d82 Mon Sep 17 00:00:00 2001 From: MAXIME LAMER Date: Mon, 6 Dec 2021 13:21:20 -0500 Subject: [PATCH 08/10] refactor(export): translated filename and csv adjustments --- .../import-export/import-export.component.ts | 66 ++++++++++++------- packages/geo/src/locale/en.geo.json | 3 +- packages/geo/src/locale/fr.geo.json | 3 +- 3 files changed, 45 insertions(+), 27 deletions(-) diff --git a/packages/geo/src/lib/import-export/import-export/import-export.component.ts b/packages/geo/src/lib/import-export/import-export/import-export.component.ts index b4af623e0c..bbe560164b 100644 --- a/packages/geo/src/lib/import-export/import-export/import-export.component.ts +++ b/packages/geo/src/lib/import-export/import-export/import-export.component.ts @@ -471,7 +471,7 @@ export class ImportExportComponent implements OnDestroy, OnInit { filename = data.name; } } else { - filename = "combinedLayers"; + filename = this.languageService.translate.instant('igo.geo.export.combinedLayers'); } const dSOptions: DataSourceOptions = lay.dataSource.options; if (data.format === ExportFormat.URL && dSOptions.download && (dSOptions.download.url || dSOptions.download.dynamicUrl)) { @@ -560,9 +560,7 @@ export class ImportExportComponent implements OnDestroy, OnInit { const message = translate.instant('igo.geo.export.gpx.error.poly.text'); this.messageService.error(message, title, { timeOut: 20000 }); } - } - - if ((data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma) && data.combineLayers) { + } else if ((data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma) && data.combineLayers) { geomTypes.forEach(geomType => geomTypesCSV.push(geomType)); if (layerIndex !== data.layers.length - 1) { @@ -573,14 +571,14 @@ export class ImportExportComponent implements OnDestroy, OnInit { geomType.features.forEach(currentFeature => { if (data.separator) { if (previousFeature) { - if (currentFeature.get('type') !== previousFeature.get('type')) { - const emptyRowFeature = previousFeature.clone(); - const previousFeatureKeys: Array = previousFeature.getKeys(); - previousFeatureKeys.forEach(key => { - emptyRowFeature.unset(key, true); - }); - featuresCSV.push(emptyRowFeature); + if (currentFeature.get('couche') !== previousFeature.get('couche')) { + const titleEmptyRows = this.createTitleEmptyRows(previousFeature, currentFeature); + featuresCSV.push(titleEmptyRows[1]); + featuresCSV.push(titleEmptyRows[0]); } + } else { + const titleEmptyRows = this.createTitleEmptyRows(currentFeature, currentFeature); + featuresCSV.push(titleEmptyRows[0]); } } featuresCSV.push(currentFeature); @@ -588,6 +586,9 @@ export class ImportExportComponent implements OnDestroy, OnInit { }); }); } + featuresCSV.forEach(feature => { + feature.unset('couche', true); + }); } if (geomTypes.length === 0) { @@ -607,13 +608,7 @@ export class ImportExportComponent implements OnDestroy, OnInit { this.onFileExportSuccess(); geomType.features.forEach(feature => { - const radius: number = feature.get('rad'); - - if (radius) { - const point = new olPoint([feature.get('longitude'), feature.get('latitude')]); - point.transform('EPSG:4326', feature.get('_projection')); - feature.setGeometry(point); - } + this.circleToPoint(feature); }); this.loading$.next(false); @@ -631,13 +626,7 @@ export class ImportExportComponent implements OnDestroy, OnInit { this.onFileExportSuccess(); featuresCSV.forEach(feature => { - const radius: number = feature.get('rad'); - - if (radius) { - const point = new olPoint([feature.get('longitude'), feature.get('latitude')]); - point.transform('EPSG:4326', feature.get('_projection')); - feature.setGeometry(point); - } + this.circleToPoint(feature); }); this.loading$.next(false); @@ -646,6 +635,33 @@ export class ImportExportComponent implements OnDestroy, OnInit { } } + private createTitleEmptyRows(previousFeature, currentFeature) { + const titleRow = previousFeature.clone(); + const emptyRow = previousFeature.clone(); + const previousFeatureKeys: Array = previousFeature.getKeys(); + previousFeatureKeys.forEach(key => { + if (key === 'code') { + titleRow.set(key, currentFeature.get('couche'), true); + emptyRow.unset(key, true); + } else { + titleRow.unset(key, true); + emptyRow.unset(key, true); + } + }); + const titleEmptyRows = [titleRow, emptyRow]; + return titleEmptyRows; + } + + private circleToPoint(feature) { + const radius: number = feature.get('rad'); + + if (radius) { + const point = new olPoint([feature.get('longitude'), feature.get('latitude')]); + point.transform('EPSG:4326', feature.get('_projection')); + feature.setGeometry(point); + } + } + private buildForm() { this.importForm = this.formBuilder.group({ inputProj: ['', [Validators.required]] diff --git a/packages/geo/src/locale/en.geo.json b/packages/geo/src/locale/en.geo.json index 95501e711c..c4a6edad22 100644 --- a/packages/geo/src/locale/en.geo.json +++ b/packages/geo/src/locale/en.geo.json @@ -113,7 +113,8 @@ "encoding": { "LATIN1": "LATIN-1", "UTF8": "UTF-8" - } + }, + "combinedLayers": "combinedLayers" }, "importExportForm": { "exportButton": "Export", diff --git a/packages/geo/src/locale/fr.geo.json b/packages/geo/src/locale/fr.geo.json index c5de324e89..5997d88933 100644 --- a/packages/geo/src/locale/fr.geo.json +++ b/packages/geo/src/locale/fr.geo.json @@ -113,7 +113,8 @@ "encoding": { "LATIN1": "LATIN-1", "UTF8": "UTF-8" - } + }, + "combinedLayers": "couchesCombinees" }, "importExportForm": { "exportButton": "Exporter", From 1cd1144342e85af13134ce7d0c3da1dcc3b3b517 Mon Sep 17 00:00:00 2001 From: MAXIME LAMER Date: Fri, 10 Dec 2021 13:01:03 -0500 Subject: [PATCH 09/10] fix(export): fix hang --- .../import-export/import-export.component.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/geo/src/lib/import-export/import-export/import-export.component.ts b/packages/geo/src/lib/import-export/import-export/import-export.component.ts index bbe560164b..f4c304719b 100644 --- a/packages/geo/src/lib/import-export/import-export/import-export.component.ts +++ b/packages/geo/src/lib/import-export/import-export/import-export.component.ts @@ -465,7 +465,8 @@ export class ImportExportComponent implements OnDestroy, OnInit { for (const [layerIndex, layer] of data.layers.entries()) { const lay = this.map.getLayerById(layer); - if (!(data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma) || ! data.combineLayers) { + if (!(data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma) + || !data.combineLayers || data.layers.length === 1) { filename = lay.title; if (data.name) { filename = data.name; @@ -538,10 +539,7 @@ export class ImportExportComponent implements OnDestroy, OnInit { geomTypes.forEach(geomType => { geomType.features.forEach(feature => { - const re = new RegExp('^\\D+'); - feature.set('couche', lay.title.match(re)[0].trim()); const radius: number = feature.get('rad'); - if (radius) { const center4326: Array = [feature.get('longitude'), feature.get('latitude')]; const circle = circular(center4326, radius, 500); @@ -571,7 +569,8 @@ export class ImportExportComponent implements OnDestroy, OnInit { geomType.features.forEach(currentFeature => { if (data.separator) { if (previousFeature) { - if (currentFeature.get('couche') !== previousFeature.get('couche')) { + if (currentFeature.get('_featureStore').layer.options.title !== + previousFeature.get('_featureStore').layer.options.title) { const titleEmptyRows = this.createTitleEmptyRows(previousFeature, currentFeature); featuresCSV.push(titleEmptyRows[1]); featuresCSV.push(titleEmptyRows[0]); @@ -586,9 +585,6 @@ export class ImportExportComponent implements OnDestroy, OnInit { }); }); } - featuresCSV.forEach(feature => { - feature.unset('couche', true); - }); } if (geomTypes.length === 0) { @@ -639,9 +635,10 @@ export class ImportExportComponent implements OnDestroy, OnInit { const titleRow = previousFeature.clone(); const emptyRow = previousFeature.clone(); const previousFeatureKeys: Array = previousFeature.getKeys(); + const firstKey: string = previousFeatureKeys[1]; previousFeatureKeys.forEach(key => { - if (key === 'code') { - titleRow.set(key, currentFeature.get('couche'), true); + if (key === firstKey) { + titleRow.set(key, currentFeature.get('_featureStore').layer.options.title, true); emptyRow.unset(key, true); } else { titleRow.unset(key, true); From 2166573980f25d70d2ae08448d33283fc9c85ccd Mon Sep 17 00:00:00 2001 From: MAXIME LAMER Date: Fri, 10 Dec 2021 15:09:02 -0500 Subject: [PATCH 10/10] fix(export): add arrow in divider --- .../import-export/import-export/import-export.component.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/geo/src/lib/import-export/import-export/import-export.component.ts b/packages/geo/src/lib/import-export/import-export/import-export.component.ts index f4c304719b..20b4c62dc0 100644 --- a/packages/geo/src/lib/import-export/import-export/import-export.component.ts +++ b/packages/geo/src/lib/import-export/import-export/import-export.component.ts @@ -572,8 +572,8 @@ export class ImportExportComponent implements OnDestroy, OnInit { if (currentFeature.get('_featureStore').layer.options.title !== previousFeature.get('_featureStore').layer.options.title) { const titleEmptyRows = this.createTitleEmptyRows(previousFeature, currentFeature); + featuresCSV.push(titleEmptyRows[2]); featuresCSV.push(titleEmptyRows[1]); - featuresCSV.push(titleEmptyRows[0]); } } else { const titleEmptyRows = this.createTitleEmptyRows(currentFeature, currentFeature); @@ -633,19 +633,22 @@ export class ImportExportComponent implements OnDestroy, OnInit { private createTitleEmptyRows(previousFeature, currentFeature) { const titleRow = previousFeature.clone(); + const titleRowWithArrow = previousFeature.clone(); const emptyRow = previousFeature.clone(); const previousFeatureKeys: Array = previousFeature.getKeys(); const firstKey: string = previousFeatureKeys[1]; previousFeatureKeys.forEach(key => { if (key === firstKey) { titleRow.set(key, currentFeature.get('_featureStore').layer.options.title, true); + titleRowWithArrow.set(key, currentFeature.get('_featureStore').layer.options.title + " ===================>", true); emptyRow.unset(key, true); } else { titleRow.unset(key, true); + titleRowWithArrow.unset(key, true); emptyRow.unset(key, true); } }); - const titleEmptyRows = [titleRow, emptyRow]; + const titleEmptyRows = [titleRow, titleRowWithArrow, emptyRow]; return titleEmptyRows; }