Skip to content

Instantly share code, notes, and snippets.

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/9734316f1b4f85538bfc5561703fe2eb to your computer and use it in GitHub Desktop.
Save LouisaKB/9734316f1b4f85538bfc5561703fe2eb to your computer and use it in GitHub Desktop.
function shapesToMultiPolygon(shapes) {
var allRings = shapes.map(function (shape) {
// The shell of the polygon is in a separate property 'shell'.
var shell = remapLinearRing(shape['shell']);
// The 'holes' property is an array of linear rings for holes.
var holes = shape['holes'].map(h => remapLinearRing(h));
// Combine the shell and holes so that the shell is the first element in the resulting array.
return [shell] + holes;
});
// returns an object adhering to GeoJson Multipolygon specification.
return {
'type': 'MultiPolygon',
'coordinates': allRings
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment