From 8e0bccb6aa97ea7828177666511e1d463b89fa8a Mon Sep 17 00:00:00 2001 From: Jan Marsch Date: Wed, 20 Apr 2016 15:00:36 +0200 Subject: [PATCH] missing isClockwise() added --- dist/Triangulate.js | 6 ++++++ package.json | 2 +- src/Triangulate.js | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dist/Triangulate.js b/dist/Triangulate.js index df3f636..ee225ec 100644 --- a/dist/Triangulate.js +++ b/dist/Triangulate.js @@ -1245,6 +1245,12 @@ var Triangulate = {}; } }; + function isClockWise(ring) { + return 0 < ring.reduce(function(a, b, c, d) { + return a + ((c < d.length - 1) ? (d[c+1][0] - b[0]) * (d[c+1][1] + b[1]) : 0); + }, 0); + } + function process(res, id, properties, geom, position, color) { var geometry = transform(geom, position), bbox = getBBox(geometry[0]), diff --git a/package.json b/package.json index 5a8cae0..d6b3484 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Triangulate", - "version": "0.1.2", + "version": "0.1.3", "homepage": "http://osmbuildings.org", "description": "GeoJSON triangulation scripts collection. Mainly used for OSM Buildings backend + frontend.", "main": "dist/Triangulate.js", diff --git a/src/Triangulate.js b/src/Triangulate.js index 086986d..33cc605 100644 --- a/src/Triangulate.js +++ b/src/Triangulate.js @@ -96,6 +96,12 @@ var Triangulate = {}; } }; + function isClockWise(ring) { + return 0 < ring.reduce(function(a, b, c, d) { + return a + ((c < d.length - 1) ? (d[c+1][0] - b[0]) * (d[c+1][1] + b[1]) : 0); + }, 0); + } + function process(res, id, properties, geom, position, color) { var geometry = transform(geom, position), bbox = getBBox(geometry[0]),