Skip to content

Instantly share code, notes, and snippets.

@LouisaKB
Last active April 24, 2020 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LouisaKB/fbbc647998630c6944626378ea838d11 to your computer and use it in GitHub Desktop.
Save LouisaKB/fbbc647998630c6944626378ea838d11 to your computer and use it in GitHub Desktop.
function toGeojson(timeMapResponse) {
// Parses the response json. This is needed if the parameter is a raw string. You don't need this if the response has already been parsed.
var responseData = JSON.parse(timeMapResponse);
// Converts each result in the response into a MultiPolygon object.
var multiPolygons = responseData['results'].map(r => shapesToMultiPolygon(r['shapes']));
// Returns a feature collection object. This can be written to a file or sent for further processing.
return {
'type': 'FeatureCollection',
'features': multiPolygons
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment