Last active
August 29, 2015 14:03
-
-
Save spikeheap/697f25a7a442b8bb1c33 to your computer and use it in GitHub Desktop.
Converts WildSwim.com data to GeoJSON format (part of the SusHack2 event)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var inputJSON = process.argv[2] | |
fs.readFile(inputJSON, 'utf8', function (err, data) { | |
if (err) { | |
console.log('Error: ' + err); | |
return; | |
} | |
var inputObj = JSON.parse(data); | |
var outputObj = { | |
type: "FeatureCollection", | |
features: [] | |
}; | |
inputObj.Spots.forEach(function (element, index, array) { | |
for (var i = 0; i < element.Points.length; i++) { | |
outputObj.features.push({ | |
"type": "Feature", | |
"geometry": { | |
type: "Point", | |
coordinates: [element.Points[i].Longitude, element.Points[i].Latitude] | |
}, | |
properties: { | |
type: element.Type.Text, | |
description: element.Description, | |
details: element.DetailsUrl, | |
warnings: { | |
present: element.HasWarnings, | |
text: element.HasWarningText | |
} | |
} | |
}); | |
} | |
}); | |
console.log(JSON.stringify(outputObj)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment