-
-
Save untoldwind/e95b7eff8ad61527a5dc4bdd889169b0 to your computer and use it in GitHub Desktop.
Test geojson with javascript algorithm
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
npm install | |
node main.js |
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
const martinez = require('martinez-polygon-clipping'); | |
const geojson2svg = require('geojson-to-svg'); | |
const gj1 = { | |
"type": "Feature", | |
"properties": {}, | |
"geometry": { "type": "Polygon", "coordinates": [[[ -530, -530], [-530, 530], [530, 530], [530, -530], [ -530, -530]]] } | |
} | |
const gj2 = { | |
"type": "Feature", | |
"properties": {}, | |
"geometry": { "type": "Polygon", "coordinates": [[[1.2500125250252, -531],[-98, -531],[-98, 531],[1.250012525025, 531],[1.2500125250252, -531]]] } | |
} | |
const intersection = { | |
"type": "Feature", | |
"geometry": { | |
"type": "Polygon", | |
"coordinates": martinez.intersection(gj1.geometry.coordinates, gj2.geometry.coordinates) | |
} | |
}; | |
console.log(JSON.stringify(intersection, null, " ")); | |
console.log(geojson2svg() | |
.data(gj1) | |
.render()); | |
console.log(geojson2svg() | |
.data(gj2) | |
.render()); |
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
{ | |
"dependencies": { | |
"geojson-to-svg": "^1.0.3", | |
"martinez-polygon-clipping": "^0.5.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment