point_in_ranked_polygon - ObjectVision/GeoDMS GitHub Wiki
Geometric functions point_in_ranked_polygon

- point_in_ranked_polygon(point_data_item, polygon_data_item, rank_data_item)
point_in_ranked_polygon(point_data_item, polygon_data_item, rank_data_item) results for each point of the point_data_item in a relation towards the domain unit of the polygon_data_item in which the point is located.
The resulting values unit is the domain unit of the polygon_data_item.
If a point is not located in any polygon, the function results in a null value. If a point is located in multiple polygons (the red point in the image), the function results in the polygon with the lowest rank_data_item value.
The rank_data_item argument is used to make an explicit choice for a polygon, if a point is located in multiple polygons. Therefore the rank values need to distinguish the different polygons. If a constant is used as rank value, the point_in_ranked_polygon results in the same values as the point_in_polygon function.
- a data item point_data_item with Point value type
- a data item polygon_data_item with composition type type polygon and Point value type
- a data item rank_data_item with a uint8, (u)int32, float32 or float64 value type
8.036
O(n log p + n * k) where n = number of points, p = number of polygons, and k = average polygon complexity. Similar to point_in_polygon, but additionally considers ranking when multiple polygons contain a point.
attribute<city> city_rel (ADomain) := point_in_ranked_polygon(Adomain/point, city/geometry, city/rank);
| point | city_rel |
|---|---|
| xy(115135; 401331) | 3 |
| xy(111803; 399476) | 2 |
| xy(114903; 399289) | 1 |
| xy(111353; 401729) | 5 |
| xy(111741; 398696) | null |
ADomain, nr of rows = 5
| City/geometry | City/rank |
|---|---|
| {21:xy(113810; 403025),{4 | 2 |
| {17:xy(113269; 400990),{4 | 1 |
| {19:xy(115099; 403128),{4 | 7 |
| {23:xy(113703; 402174),{4 | 4 |
| {30:xy(114646; 401531),{4 | 6 |
| {13:xy(114546; 402757),{4 | 5 |
| {54:xy(113562; 405282),{4 | 3 |
domain City, nr of rows = 7