概述
函数pointInPolygon()
判断一个二维坐标点是否位于一个多边形区域内。
参数:pointInPolygon(<point>, <polygon>)
<point>
:坐标对象(point或list类型)<polygon>
:多边形区域(list类型)
返回值:
- 判断结果,1(是)或0(否)
- 点落在区域边界上的视为否
一般用法

本例使用异源别名计算:
uncollect [[1.5,0.5],[2,2]] as point
uncollect [[[1,0],[3,0],[3,1],[1,1]],[[1,0],[2,1],[1,2],[0,1]]] as polygon
return table(toString(point), toString(polygon), pointInPolygon(point, polygon))
| toString(point) | toString(polygon) | pointInPolygon(point, polygon) |
|-----------------|---------------------------|--------------------------------|
| [1.5,0.5] | [[1,0],[3,0],[3,1],[1,1]] | 1 |
| [2,2] | [[1,0],[2,1],[1,2],[0,1]] | 0 |
本例将异源别名做笛卡尔积组合后计算:
uncollect [[1.5,0.5],[2,2]] as point
uncollect [[[1,0],[3,0],[3,1],[1,1]],[[1,0],[2,1],[1,2],[0,1]]] as polygon
with pointInPolygon(point, polygon) as result
return table(toString(point), toString(polygon), result)
| toString(point) | toString(polygon) | result |
|-----------------|---------------------------|--------|
| [1.5,0.5] | [[1,0],[3,0],[3,1],[1,1]] | 1 |
| [1.5,0.5] | [[1,0],[2,1],[1,2],[0,1]] | 0 |
| [2,2] | [[1,0],[3,0],[3,1],[1,1]] | 0 |
| [2,2] | [[1,0],[2,1],[1,2],[0,1]] | 0 |