feat: close rect geometry in csv export to match behavior of orion suite
Pyxis/fieldnotes/pipeline/head This commit is unstable Details

This commit is contained in:
wpetit 2023-03-07 11:27:59 +01:00
parent 86898bb820
commit 4d192c4299
1 changed files with 13 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import { XYZtoLLA, LLAtoXYZ, WGS84Ellipsoid, project, Projections, EPSG_WGS84 }
import { ErrSelectionCanceled } from './errors';
import { ControlSession } from '../store/reducers/control-sessions';
import { ControlledPoint } from '../store';
import { slice } from 'lodash';
const ExportDirectoryPath = `${RNFS.ExternalDirectoryPath}/fieldnotes/export`;
const CellSeparator = ';';
@ -80,15 +81,24 @@ export function entitiesToCSV(entities: any, projection: any) {
};
let index = 0;
return entities.reduce((rows: any[], e: any) => {
return entities.reduce((rows: any[], e: any) => {
rows.push(...e.positions.map((p: any) => {
return [
index++,
...transformCoordinates(p),
...metadataToArray(e.metadata)
].join(CellSeparator);
];
}));
return rows;
// If the entity is of type "rect", push first row
// to close geometry
if (e.metadata.type == "rect") {
const copy = rows[0].slice(0);
copy[0] = index++;
rows.push(copy);
}
return rows.map(row => row.join(CellSeparator));
}, []).join(LineSeparator);
}