Skip to content

Instantly share code, notes, and snippets.

@pfirpfel
Last active June 23, 2017 13:01
Show Gist options
  • Save pfirpfel/39b1868b8f885be0d854cbd3d4f81966 to your computer and use it in GitHub Desktop.
Save pfirpfel/39b1868b8f885be0d854cbd3d4f81966 to your computer and use it in GitHub Desktop.
mergeLineStrings
/**
* @param arr Array of LineStrings, see: https://tools.ietf.org/html/rfc7946#appendix-A.2
* @returns LineString
*/
function mergeLineStrings(arr){
return {
type: 'LineString',
coordinates: arr.map(ls => ls.coordinates).reduce((acc, cur) => acc.concat(cur.slice(1)))
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment