From fa0773ca0bcba1ac8a933e277c97bb346298e698 Mon Sep 17 00:00:00 2001 From: Wille Marcel Date: Mon, 20 May 2024 16:49:12 -0300 Subject: [PATCH] Add NAMMA campaign data and adapt code to process it --- campaigns/NAMMA/deployments.yaml | 19 +++++++++++++++++++ task/src/process.js | 13 ++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 campaigns/NAMMA/deployments.yaml diff --git a/campaigns/NAMMA/deployments.yaml b/campaigns/NAMMA/deployments.yaml new file mode 100644 index 0000000..7eafe9e --- /dev/null +++ b/campaigns/NAMMA/deployments.yaml @@ -0,0 +1,19 @@ +--- +deployments: +- name: NAMMA-D1_2006 + platforms: + - name: DC-8 + files: + - https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060912_larc.csv + - https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060909_larc.csv + - https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060908_larc.csv + - https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060905_larc.csv + - https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060904_larc.csv + - https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060903_larc.csv + - https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060901_larc.csv + - https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060830_larc.csv + - https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060826_larc.csv + - https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060825_larc.csv + - https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060823_larc.csv + - https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060820_larc.csv + - https://data.ghrc.earthdata.nasa.gov/ghrcw-protected/namlargen__1/namma_large_nav_20060819_larc.csv \ No newline at end of file diff --git a/task/src/process.js b/task/src/process.js index 173d684..72a0e64 100644 --- a/task/src/process.js +++ b/task/src/process.js @@ -157,6 +157,8 @@ const makeStaticLocationsGeoJSON = (filePath) => { * @param {Object} extraProperties - predefined properties * @param {Array} columnsStats - an array containing the columns that will have the stats computed. Stats include the average, minimum and maximum values. +* @param {Number} coordsDivisor - an optional integer number. Case informed, +all coordinates values will be divided by it. * @param {Boolean} fixCoords - if true, coordinates that seems to be wrong will be removed. See cleanCoords function. * @return {Object} resulting GeoJSON object @@ -170,15 +172,24 @@ const makeGeoJSON = ( ) => { const file = fs.readFileSync(filePath); const content = file.toString(); + // configure latitude and longitude fields + let latField = 'latitude'; + let lonField = 'longitude'; + if (content.includes('Latitude,') && content.includes('Longitude,')) { + latField = 'Latitude'; + lonField = 'Longitude'; + } + let geojson; csv2geojson.csv2geojson( content, - { latfield: 'latitude', lonfield: 'longitude', delimiter: ',' }, + { latfield: latField, lonfield: lonField, delimiter: ',' }, (err, data) => geojson = data ); if (coordsDivisor) { geojson.features = divideCoordinates(geojson.features, coordsDivisor); } + // remove invalid coordinates geojson.features = geojson.features.filter((i) => ( i.geometry.coordinates[0] >= -180 && i.geometry.coordinates[1] >= -90 && i.geometry.coordinates[0] <= 180 && i.geometry.coordinates[1] <= 90