Skip to content

Instantly share code, notes, and snippets.

@grabcode
Created November 3, 2019 05:21
Show Gist options
  • Save grabcode/dd78b48e3d9068f8e9b25d4397af3e77 to your computer and use it in GitHub Desktop.
Save grabcode/dd78b48e3d9068f8e9b25d4397af3e77 to your computer and use it in GitHub Desktop.
// Geojson
// Produced by
// 1. Google My Map / Export to KMZ
// 2. Convert KMZ to GeoJSON (using https://mygeodata.cloud/converter/kmz-to-geojson)
// 3. Utilise any helpers below to produce the `output` and, through the console, run copy(JSON.stringify(output))
// Util: polygonToAllowedArea
// Convert a polygon in a Network.settings.AllowedArea ([]{latitude: number, longitude: number})
// Entry: Array[Longitude: number, Latitude: number]
// Note: currently support only first polygon
const polygonToAllowedArea = ({ coordinates }) => coordinates[0].map((lngLat)=>{
return {latitude: lngLat[1], longitude: lngLat[0]};
});
// Util: pointsToMeetingPoints
// Convert a list of GeoJSON features of type "Point" in a Network.settings.meetingPointsData.meetingPoints
// Entry: Array[{geometry: {coordinates: [Longitude: number, Latitude: number]}}]
const pointsToMeetingPoints = features => features.map(({geometry}) => {
return {lat: geometry.coordinates[1], lng: geometry.coordinates[0]};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment