-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(export): added possibility of exporting merged CSV files #949
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e946efc
feat(export): export unique CSVs
LAMM26 5f3962d
added toggle to combine layers
LAMM26 97f8672
Merge remote-tracking branch 'origin/next' into export_csv_unique
LAMM26 262db67
added empty row toggle
LAMM26 c2c458e
refactor(export): change label of toggle and add column when exportin…
LAMM26 ea1796d
Merge remote-tracking branch 'origin/next' into export_csv_unique
LAMM26 c8e8790
refactor(remove zone when exporting results from spatial filter tool)
LAMM26 39bd4d4
fix(demo): fix import-export lib demo
PhilippeLafreniere18 e9da836
Merge remote-tracking branch 'origin/next' into export_csv_unique
PhilippeLafreniere18 1f9b774
lint
PhilippeLafreniere18 b3bced3
Merge remote-tracking branch 'origin/next' into export_csv_unique
LAMM26 70cfc66
refactor(export): translated filename and csv adjustments
LAMM26 bd4cc63
Merge branch 'export_csv_unique' of https://github.com/infra-geo-ouve…
LAMM26 fa304a2
Merge remote-tracking branch 'origin/next' into export_csv_unique
LAMM26 29b04b0
Merge remote-tracking branch 'origin/next' into export_csv_unique
LAMM26 440d694
Merge remote-tracking branch 'origin/next' into export_csv_unique
LAMM26 ac7ae0c
Merge remote-tracking branch 'origin/next' into export_csv_unique
LAMM26 1cd1144
fix(export): fix hang
LAMM26 2166573
fix(export): add arrow in divider
LAMM26 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -459,11 +459,20 @@ 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) | ||
|| !data.combineLayers || data.layers.length === 1) { | ||
filename = lay.title; | ||
if (data.name) { | ||
filename = data.name; | ||
} | ||
} else { | ||
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)) { | ||
|
@@ -531,7 +540,6 @@ export class ImportExportComponent implements OnDestroy, OnInit { | |
geomTypes.forEach(geomType => { | ||
geomType.features.forEach(feature => { | ||
const radius: number = feature.get('rad'); | ||
|
||
if (radius) { | ||
const center4326: Array<number> = [feature.get('longitude'), feature.get('latitude')]; | ||
const circle = circular(center4326, radius, 500); | ||
|
@@ -550,6 +558,33 @@ export class ImportExportComponent implements OnDestroy, OnInit { | |
const message = translate.instant('igo.geo.export.gpx.error.poly.text'); | ||
this.messageService.error(message, title, { timeOut: 20000 }); | ||
} | ||
} else if ((data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma) && data.combineLayers) { | ||
geomTypes.forEach(geomType => geomTypesCSV.push(geomType)); | ||
|
||
if (layerIndex !== data.layers.length - 1) { | ||
continue; | ||
} else { | ||
let previousFeature = undefined; | ||
geomTypesCSV.forEach(geomType => { | ||
geomType.features.forEach(currentFeature => { | ||
if (data.separator) { | ||
if (previousFeature) { | ||
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]); | ||
} | ||
} else { | ||
const titleEmptyRows = this.createTitleEmptyRows(currentFeature, currentFeature); | ||
featuresCSV.push(titleEmptyRows[0]); | ||
} | ||
} | ||
featuresCSV.push(currentFeature); | ||
previousFeature = currentFeature; | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
if (geomTypes.length === 0) { | ||
|
@@ -559,29 +594,72 @@ 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) || !data.combineLayers) { | ||
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 => { | ||
this.circleToPoint(feature); | ||
}); | ||
|
||
this.loading$.next(false); | ||
} | ||
)); | ||
)); | ||
} | ||
} | ||
}; | ||
if ((data.format === ExportFormat.CSVsemicolon || data.format === ExportFormat.CSVcomma) && data.combineLayers) { | ||
this.exportService.export(featuresCSV, data.format, filename, data.encoding, this.map.projection) | ||
.subscribe( | ||
() => {}, | ||
(error: Error) => this.onFileExportError(error), | ||
() => { | ||
this.onFileExportSuccess(); | ||
|
||
featuresCSV.forEach(feature => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create method instead ? Could be also use for geomType at line 609 |
||
this.circleToPoint(feature); | ||
}); | ||
|
||
this.loading$.next(false); | ||
} | ||
); | ||
} | ||
} | ||
|
||
private createTitleEmptyRows(previousFeature, currentFeature) { | ||
const titleRow = previousFeature.clone(); | ||
const titleRowWithArrow = previousFeature.clone(); | ||
const emptyRow = previousFeature.clone(); | ||
const previousFeatureKeys: Array<string> = 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, titleRowWithArrow, 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() { | ||
|
@@ -595,6 +673,8 @@ export class ImportExportComponent implements OnDestroy, OnInit { | |
layers: [[], [Validators.required]], | ||
layersWithSelection: [[]], | ||
encoding: [EncodingFormat.UTF8, [Validators.required]], | ||
combineLayers: [true, [Validators.required]], | ||
separator: [false, [Validators.required]], | ||
featureInMapExtent: [false, [Validators.required]], | ||
name: ['', [Validators.required]] | ||
}); | ||
|
@@ -604,6 +684,8 @@ export class ImportExportComponent implements OnDestroy, OnInit { | |
layers: [[], [Validators.required]], | ||
layersWithSelection: [[]], | ||
encoding: [EncodingFormat.UTF8, [Validators.required]], | ||
combineLayers: [true, [Validators.required]], | ||
separator: [false, [Validators.required]], | ||
featureInMapExtent: [false, [Validators.required]], | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be put into else condition (line 561) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done