Skip to content

Commit

Permalink
Fix CSV export lat/long, add created date, accuracy
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Cassidy <[email protected]>
  • Loading branch information
stevecassidy committed Sep 24, 2024
1 parent abad1c8 commit c0a2cf6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/couchdb/notebooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,12 +623,14 @@ const csvFormatValue = (
if (fieldType === 'faims-pos::Location') {
if (value instanceof Object && 'geometry' in value) {
result[fieldName] = value;
result[fieldName + '_latitude'] = value.geometry.coordinates[0];
result[fieldName + '_longitude'] = value.geometry.coordinates[1];
result[fieldName + '_latitude'] = value.geometry.coordinates[1];
result[fieldName + '_longitude'] = value.geometry.coordinates[0];
result[fieldName + '_accuracy'] = value.properties.accuracy || '';
} else {
result[fieldName] = value;
result[fieldName + '_latitude'] = '';
result[fieldName + '_longitude'] = '';
result[fieldName + '_accuracy'] = '';
}
return result;
}
Expand Down Expand Up @@ -740,6 +742,8 @@ export const streamNotebookRecordsAsCSV = async (
record.record_id,
record.revision_id,
record.type,
record.created_by,
record.created.toISOString(),
record.updated_by,
record.updated.toISOString(),
];
Expand All @@ -759,6 +763,8 @@ export const streamNotebookRecordsAsCSV = async (
'record_id',
'revision_id',
'type',
'created_by',
'created',
'updated_by',
'updated',
];
Expand Down

0 comments on commit c0a2cf6

Please sign in to comment.