Skip to content

Instantly share code, notes, and snippets.

@spikeheap
Last active August 29, 2015 14:03
Show Gist options
  • Save spikeheap/697f25a7a442b8bb1c33 to your computer and use it in GitHub Desktop.
Save spikeheap/697f25a7a442b8bb1c33 to your computer and use it in GitHub Desktop.
Converts WildSwim.com data to GeoJSON format (part of the SusHack2 event)
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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