Last active
April 24, 2020 13:14
-
-
Save LouisaKB/fbbc647998630c6944626378ea838d11 to your computer and use it in GitHub Desktop.
This file contains 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
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