Skip to content

Instantly share code, notes, and snippets.

@xx7y7xx
Last active April 30, 2021 08:16
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 xx7y7xx/07e29258184e79e527b725813068df11 to your computer and use it in GitHub Desktop.
Save xx7y7xx/07e29258184e79e527b725813068df11 to your computer and use it in GitHub Desktop.
Convert OSM Bbox to GeoJSON
// 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