citygml-validate-shell
Advanced tools
Comparing version 0.1.20 to 0.1.21
30
index.js
@@ -370,2 +370,5 @@ // Note: QIE paper states that only LOD1–3 geometries are to be tested, | ||
// | ||
// Note: This overlooks issues with collinear points (which should fail before | ||
// anyway) | ||
// | ||
// IMPL: Find a polygon we know is facing up/down based on horizontal plane (eg. | ||
@@ -459,5 +462,30 @@ // top-most must have normal angled above horizontal, bottom-most below). Seems | ||
_.each(topPolygons, function(oPolygon, oPolygonIndex) { | ||
var p0, p1, p2; | ||
var normal; | ||
var collinearThreshold = 0.01; | ||
// Find first sequence of points that aren't collinear | ||
_.each(oPolygon[0], function(point, pIndex) { | ||
// Exit if no more points are available | ||
if (pIndex === oPolygon[0].length - 2) { | ||
return false; | ||
} | ||
p0 = $V(point); | ||
p1 = $V(oPolygon[0][pIndex+1]); | ||
p2 = $V(oPolygon[0][pIndex+2]); | ||
// Colinear or near-colinear? | ||
var cross = p0.subtract(p1).cross(p0.subtract(p2)); | ||
// Exit if non-collinear points are found | ||
if (Math.abs(cross.e(1)) > collinearThreshold || Math.abs(cross.e(2)) > collinearThreshold || Math.abs(cross.e(3)) > collinearThreshold) { | ||
normal = normalUnit(p0, p1, p2); | ||
return false; | ||
} | ||
}); | ||
// Skip first point to avoid normal inconsistancies with polygons that | ||
// have identical start and end points. | ||
var normal = normalUnit(oPolygon[0][0], oPolygon[0][1], oPolygon[0][2]); | ||
// var normal = normalUnit(oPolygon[0][0], oPolygon[0][1], oPolygon[0][2]); | ||
var absNormalZ = Math.abs(normal.e(3)); | ||
@@ -464,0 +492,0 @@ |
{ | ||
"name": "citygml-validate-shell", | ||
"version": "0.1.20", | ||
"version": "0.1.21", | ||
"description": "Validate a CityGML shell against the QIE suite", | ||
@@ -34,3 +34,3 @@ "main": "index.js", | ||
"lodash": "^3.9.3", | ||
"points-3d-to-2d": "^0.1.1", | ||
"points-3d-to-2d": "^0.1.2", | ||
"polygon": "^1.0.1", | ||
@@ -37,0 +37,0 @@ "sylvester": "0.0.21" |
29496
672
Updatedpoints-3d-to-2d@^0.1.2