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

Method isInsidePolygon

src/common/overlay/levelRenderer/Area.js:640–653  ·  view source on GitHub ↗

* @function LevelRenderer.Tool.Areal.prototype.isInsidePolygon * @description 图形 Polygon 是否包含鼠标位置, true表示坐标处在图形内。与 canvas 一样采用 non-zero winding rule * @returns {boolean} 图形是否包含鼠标位置, true表示坐标处在图形内。

(points, x, y)

Source from the content-addressed store, hash-verified

638 * @returns {boolean} 图形是否包含鼠标位置, true表示坐标处在图形内。
639 */
640 isInsidePolygon(points, x, y) {
641 var N = points.length;
642 var w = 0;
643
644 for (var i = 0, j = N - 1; i < N; i++) {
645 var x0 = points[j][0];
646 var y0 = points[j][1];
647 var x1 = points[i][0];
648 var y1 = points[i][1];
649 w += this.windingLine(x0, y0, x1, y1, x, y);
650 j = i;
651 }
652 return w !== 0;
653 }
654
655
656 /**

Callers 1

_mathMethodMethod · 0.95

Calls 1

windingLineMethod · 0.95

Tested by

no test coverage detected