Skip to content

Commit

Permalink
feat(export): added headers in separators (#967)
Browse files Browse the repository at this point in the history
* feat(export): added headers in separators

* fix(import-export): fix wfs and arrows
  • Loading branch information
LAMM26 committed Feb 16, 2022
1 parent 5212624 commit 2f87eed
Showing 1 changed file with 57 additions and 9 deletions.
Expand Up @@ -573,6 +573,7 @@ export class ImportExportComponent implements OnDestroy, OnInit {
previousFeature.get('_featureStore').layer.options.title) {
const titleEmptyRows = this.createTitleEmptyRows(previousFeature, currentFeature);
featuresCSV.push(titleEmptyRows[2]);
featuresCSV.push(titleEmptyRows[0]);
featuresCSV.push(titleEmptyRows[1]);
}
} else {
Expand Down Expand Up @@ -632,23 +633,70 @@ export class ImportExportComponent implements OnDestroy, OnInit {
}

private createTitleEmptyRows(previousFeature, currentFeature) {
const titleRow = previousFeature.clone();
const titleRowWithArrow = previousFeature.clone();
const emptyRow = previousFeature.clone();
const titleRow = currentFeature.clone();
const headerRow = currentFeature.clone();
const emptyRow = currentFeature.clone();
const previousFeatureKeys: Array<string> = previousFeature.getKeys();
const firstKey: string = previousFeatureKeys[1];
previousFeatureKeys.forEach(key => {
if (key === firstKey) {
let firstKeyPrevious: string = '';
for (const key in previousFeatureKeys) {
if (previousFeatureKeys[key] !== 'geometry') {
firstKeyPrevious = previousFeatureKeys[key];
break;
}
}

const currentFeatureKeys: Array<string> = currentFeature.getKeys();
let firstKeyCurrent: string = '';
for (const key in currentFeatureKeys) {
if (currentFeatureKeys[key] !== 'geometry') {
firstKeyCurrent = currentFeatureKeys[key];
break;
}
}
const allKeys: Array<string> = currentFeature.getKeys();
previousFeatureKeys.forEach(previousKey => {
if (allKeys.includes(previousKey) && previousKey !== firstKeyPrevious) {
allKeys.push(previousKey);
}
});
allKeys.unshift(firstKeyPrevious);

let firstKeyAll: string = '';
for (const key in allKeys) {
if (allKeys[key] !== 'geometry') {
firstKeyAll = allKeys[key];
break;
}
}
allKeys.forEach(key => {
const sameKeys: boolean = previousFeatureKeys.length === currentFeatureKeys.length &&
previousFeatureKeys.every((value, index) => value === currentFeatureKeys[index]);
if (key === firstKeyAll && !sameKeys) {
titleRow.set(key, currentFeature.get('_featureStore').layer.options.title + " ===============>", true);
headerRow.set(key, key, true);
emptyRow.unset(key, true);
} else if (key === firstKeyAll && sameKeys) {
titleRow.set(key, currentFeature.get('_featureStore').layer.options.title, true);
headerRow.set(key, key, true);
emptyRow.unset(key, true);
} else if (key === firstKeyCurrent) {
titleRow.set(key, currentFeature.get('_featureStore').layer.options.title, true);
titleRowWithArrow.set(key, currentFeature.get('_featureStore').layer.options.title + " ===================>", true);
headerRow.set(key, key, true);
emptyRow.unset(key, true);
} else if (key !== 'geometry') {
titleRow.unset(key, true);
headerRow.set(key, key, true);
emptyRow.unset(key, true);
} else {
titleRow.unset(key, true);
titleRowWithArrow.unset(key, true);
emptyRow.unset(key, true);
}

if (!(currentFeatureKeys.includes(key))) {
headerRow.unset(key, true);
}
});
const titleEmptyRows = [titleRow, titleRowWithArrow, emptyRow];
const titleEmptyRows = [titleRow, headerRow, emptyRow];
return titleEmptyRows;
}

Expand Down

0 comments on commit 2f87eed

Please sign in to comment.