Skip to content

Instantly share code, notes, and snippets.

@cnrdh
Last active November 1, 2018 12:32
Show Gist options
  • Save cnrdh/662fa1b73cf78fbe7fb3e0dad9030380 to your computer and use it in GitHub Desktop.
Save cnrdh/662fa1b73cf78fbe7fb3e0dad9030380 to your computer and use it in GitHub Desktop.
Sampling events from HI toktlogger
import wellknown from 'wellknown'; //https://www.npmjs.com/package/wellknown
// @param Object a: activity from IMR toktlogger
// @return Map
export function dwcSamplingEventMapFromImrActivity(a) {
const startCoordinates = a.startPosition.coordinates;
const endCoordinates = a.endPosition.coordinates;
const multiPoint = { type: 'MultiPoint', coordinates: [startCoordinates, endCoordinates]};
return new Map([
['eventDate', `${new Date(a.startTime).toISOString()}/${new Date(a.endTime).toISOString()}`],
['samplingProtocol', a.name],
['localstationNumber', a.localstationNumber],
['superstationNumber', a.superstationNumber],
['decimalLongitude', startCoordinates[0]],
['decimalLatitude', startCoordinates[1]],
['fieldNotes', a.comment],
['footprintWKT', wellknown.stringify(multiPoint)],
['eventID', a._id],
// ['stationName','locationID'], // FIXME toktlogger data has no named stations
// ['parentEventID', ''], // FIXME toktlogger data has no parent event
]);
}
// Other useful fields
// ['samplingProtocol','samplingProtocol'], // FIXME need shared vocab
// ['samplingEffort','samplingEffort'],
// ['sampleSizeValue','sampleSizeValue'], // 1
// ['sampleSizeUnit','sampleSizeUnit'], // m3
// Personell: caretaker / responsible for the sample
// Bottom depth
// ['countryCode','countryCode'] //?
//
// Only provide datum/refsystem if not WGS84?
// ['geodeticDatum', 'WGS84'],
// ['footprintSRS','WGS84 GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137,298.257223563]],PRIMEM['Greenwich',0],UNIT['Degree',0.0174532925199433]]'],
eventDate samplingProtocol localstationNumber superstationNumber fieldNotes footprintWKT eventID locationID parentEventID
2018-06-04T16:09:31.877Z/2018-06-04T16:30:16.733Z Akustisk transekt 2 11 MULTIPOINT (5.14754 62.028975, 5.151541666666667 61.96099) 5ee4wKQZD2rMYfTxY
2018-06-04T07:57:23.434Z/2018-06-04T08:20:48.713Z CTD 4 8 MULTIPOINT (7.390098333333333 63.069426666666665, 5.314988333333333 60.397758333333336) 6BMEwgcfhGCtcbeFH
2018-06-02T18:18:38.725Z/2018-06-02T18:46:52.725Z Pelagisk trål 2 1 MULTIPOINT (16.56165 68.61344, 13.487921666666667 66.92780166666667) CG72qfEjbHqJyuCvb
2018-06-05T11:35:23.950Z/2018-06-05T11:35:46.150Z Pelagisk trål 14 14 MULTIPOINT (5.314993333333334 60.397753333333334, 5.314993333333334 60.39776166666667) DQn6y4WCkgoo3MtJg
2018-06-03T01:13:09.444Z/2018-06-03T01:59:59.444Z Pelagisk trål 3 1 MULTIPOINT (14.272616666666666 67.719635, 13.375166666666667 66.88073666666666) EB3rnH8pJxNN9rxHo
2018-06-04T11:45:43.736Z/2018-06-04T12:23:16.482Z Bomtrål 1 10 MULTIPOINT (6.212461666666667 62.57385166666667, 5.314993333333334 60.39776166666667) LC87dxEYMxfPs2mnY
2018-06-05T04:34:42.532Z/2018-06-05T04:54:30.300Z CTD 5 14 MULTIPOINT (5.299501666666667 60.40262833333333, 5.31499 60.397758333333336) LooekCTMszKeeGkDS
2018-06-03T06:42:57.856Z/2018-06-03T06:48:14.177Z CTD 2 1 MULTIPOINT (13.34659 66.86489833333333, 5.314993333333334 60.39776166666667) QCJ2BHNGBtzgb6jkD
2018-06-05T10:58:39.927Z/2018-06-05T11:38:16.684Z Bunntrål 13 14 MULTIPOINT (5.314996666666667 60.39776166666667, 5.314993333333334 60.39776166666667) TpuEYb9NiDpmRPg5v
@cnrdh
Copy link
Author

cnrdh commented Nov 1, 2018

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment