MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / middleInside

Function middleInside

libs/mapv/mapv.js:2112–2123  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

2110
2111// check if the middle point of a polygon diagonal is inside the polygon
2112function middleInside(a, b) {
2113 var p = a,
2114 inside = false,
2115 px = (a.x + b.x) / 2,
2116 py = (a.y + b.y) / 2;
2117 do {
2118 if (p.y > py !== p.next.y > py && px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x) inside = !inside;
2119 p = p.next;
2120 } while (p !== a);
2121
2122 return inside;
2123}
2124
2125// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
2126// if one belongs to the outer ring and another to a hole, it merges it into a single ring

Callers 1

isValidDiagonalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected