Last active
April 30, 2021 08:16
-
-
Save xx7y7xx/07e29258184e79e527b725813068df11 to your computer and use it in GitHub Desktop.
Convert OSM Bbox to GeoJSON
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
// OSM context | |
// const boundingBox = window.context.map().extent().bbox(); | |
// const west = boundingBox.minX; | |
// const east = boundingBox.maxX; | |
// const north = boundingBox.maxY; | |
// const south = boundingBox.minY; | |
east=103.95809871524841 | |
north=1.3401293903131355 | |
south=1.3292472996510163 | |
west=103.92966431487436 | |
const convert = () => { | |
const feature = { | |
"type": "Feature", | |
"properties": {}, | |
"geometry": { | |
"type": "Polygon", | |
"coordinates": [ | |
[[west,south], | |
[east,south], | |
[east,north], | |
[west,north], | |
[west,south]] | |
] | |
} | |
} | |
featureCollection = { | |
"type": "FeatureCollection", | |
"features": [feature] | |
} | |
return featureCollection | |
} | |
console.log(JSON.stringify(convert().features[0])) | |
copy(convert().features[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment