Created
July 28, 2013 20:35
-
-
Save rclark/6100129 to your computer and use it in GitHub Desktop.
Example of jsts.operation.polygonize not working on arbitrary "spaghetti" lines
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
var jsts = require("jsts"), | |
spaghetti = [ | |
"LINESTRING(-108.6328125 32.54681317351517,-117.7734375 44.33956524809713,-91.0546875 50.51342652633956,-92.46093749999999 30.751277776257812)", | |
"LINESTRING(-120.58593749999999 25.48295117535531,-106.5234375 42.032974332441405,-78.046875 40.713955826286046)" | |
], | |
reader = new jsts.io.WKTReader(), | |
polygonizer = new jsts.operation.polygonize.Polygonizer(), | |
polygons, dangles, cutEdges, invalidRingLines; | |
spaghetti.forEach(function (line) { | |
var geom = reader.read(line); | |
polygonizer.add(geom); | |
}); | |
polygons = polygonizer.getPolygons(); | |
process.stdout.write("Polygons: " + JSON.stringify(polygons.array) + "\n\n"); | |
dangles = polygonizer.getDangles(); | |
process.stdout.write("Dangles: " + JSON.stringify(dangles.array) + "\n\n"); | |
cutEdges = polygonizer.getCutEdges(); | |
process.stdout.write("Cut Edges: " + JSON.stringify(cutEdges.array) + "\n\n"); | |
invalidRingLines = polygonizer.getInvalidRingLines(); | |
process.stdout.write("Invalid Ring Lines: " + JSON.stringify(invalidRingLines.array) + "\n\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment