Last active
May 26, 2020 19:24
-
-
Save mrummuka/731a91bd02e6e638f7d390ff62106464 to your computer and use it in GitHub Desktop.
Generate all points (gps resolution) into hand-drawn region inside browser, using geojson.io as data source
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
// featureCollection and all features on map | |
let fc; | |
// autogenerated features (points within hand-drawn region) | |
let uniqueWps; | |
// gps coordinates of autogenerated features | |
let wps; | |
// script that does the magic | |
let gscript = "https://gist.githubusercontent.com/mrummuka/b70b9a9fb0825b4bace91a4b6d6b1257/raw/602987bba124e03a7641e96d56800375abd96409/regionWpGenerator"; | |
fc = window.api.data.get('map'); | |
fetch('https://npmcdn.com/@turf/turf@5.1.6/turf.js') | |
.then(t => t.text()) | |
.then(eval) | |
.then( t => fetch(gscript)) | |
.then( t => t.text()) | |
.then(eval) | |
.then( t => { | |
uniqueWps = generateUniqueWps( fc ); | |
wps = []; | |
uniqueWps.features.forEach( f => { wps.push( f.properties.gps ) }) | |
console.log("Generated " + wps.length + " waypoints" ) | |
} | |
) | |
// next one does not scale well but can be used for visualizing generated points.. | |
.then( t => window.api.data.mergeFeatures( uniqueWps.features ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment