Skip to content

Commit

Permalink
Updated submissions download to show gps coordinates in non-decimal f…
Browse files Browse the repository at this point in the history
…ormat (Resolves #64)
  • Loading branch information
zachsa committed Oct 10, 2022
1 parent b6ccd67 commit cef8b8f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"csv": "^6.2.0",
"dataloader": "^2.1.0",
"date-fns": "^2.29.3",
"dms-conversion": "^3.1.1",
"dotenv": "^16.0.3",
"graphql": "^16.6.0",
"graphql-type-json": "^0.3.2",
Expand Down
10 changes: 10 additions & 0 deletions src/api/src/http/download-submissions/parse-row/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {
import { HOSTNAME } from '../../../config/index.js'
import parseProgressData from './parse-progress-data/index.js'
import { stringify as stringifySync } from 'csv/sync'
import { parse as parseWkt } from 'wkt'
import dms from 'dms-conversion'
const { default: DmsCoordinates } = dms

const generalVocabularyFields = ['submissionStatus']

Expand Down Expand Up @@ -49,6 +52,13 @@ const parseValue = (id, { key, obj, vocabFields, inputFields }) => {
return id
}

if (key === 'xy') {
return parseWkt(value)
.geometries.filter(({ type }) => type?.toLowerCase() === 'point')
.map(({ coordinates: [x, y] }) => new DmsCoordinates(y, x).toString().replace(',', ''))
.join(', ')
}

if (key === 'carbonCredit') {
return `${value}`
}
Expand Down

0 comments on commit cef8b8f

Please sign in to comment.