Skip to content

Commit 9d240d2

Browse files
authored
Revise documentation
revisions to increase the accuracy of ST_LabelPoint docs
1 parent 131a45a commit 9d240d2

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

docs/api/flink/Function.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,26 +166,24 @@ Output: `POLYGON Z((2 3 1, 4 5 1, 7 8 2, 2 3 1))`
166166

167167
## ST_LabelPoint
168168

169-
Introduction: `ST_LabelPoint` computes and returns a label point for a given polygon or geometry collection. The label point is chosen to:
169+
Introduction: `ST_LabelPoint` computes and returns a label point for a given polygon or geometry collection. The label point is chosen to be sufficiently far from boundaries of the geometry. For a regular Polygon this will be the
170+
centroid.
170171

171-
- Be near the center of the polygon.
172-
- Stay far from boundaries for optimal placement.
172+
The algorithm is derived from Tippecanoe’s `polygon_to_anchor`, an approximate solution for label point generation, designed to be faster than optimal algorithms like `polylabel`. It searches for a “good enough” label point within a limited number of iterations. For geometry collections, only the largest Polygon by area is considered. While `ST_Centroid` is a fast algorithm to calculate the center of mass of a (Multi)Polygon, it may place the point outside of the Polygon or near a boundary for concave shapes, polygons with holes, or MultiPolygons.
173173

174-
The algorithm is inspired by Tippecanoe’s `polygon_to_anchor`, an approximate solution for label point generation, designed to be faster than iterative algorithms like `polylabel`. It may not produce the globally optimal result, but it ensures a “good enough” label point within a limited number of iterations. For geometry collections, only the largest polygon by area is considered. While `ST_Centroid` is a fast algorithm to calculate the center of mass of a polygon, assuming uniform density, it may place the point outside the polygon or near a boundary, especially for irregular shapes or polygons with holes.
174+
`ST_LabelPoint` takes up to 3 arguments,
175175

176-
`ST_LabelPoint` takes upto 3 arguments,
177-
178-
- `geometry`: input geometry (e.g., a polygon or GeometryCollection) for which the anchor point is to be calculated.
179-
- `gridResolution` (Optional, default is 16): Controls the resolution of the search grid for refining the label point. A higher resolution increases the grid density, providing more accurate results but at the cost of additional computation. For example, a gridResolution of 16 divides the bounding box of the polygon into a 16x16 grid.
176+
- `geometry`: input geometry (e.g., a Polygon or GeometryCollection) for which the anchor point is to be calculated.
177+
- `gridResolution` (Optional, default is 16): Controls the resolution of the search grid for refining the label point. A higher resolution increases the grid density, providing a higher chance of finding a good enough result at the cost of runtime. For example, a gridResolution of 16 divides the bounding box of the polygon into a 16x16 grid.
180178
- `goodnessThreshold` (Optional, default is 0.2): Determines the minimum acceptable “goodness” value for the anchor point. Higher thresholds prioritize points farther from boundaries but may require more computation.
181179

182180
!!!note
183181
- `ST_LabelPoint` throws an `IllegalArgumentException` if the input geometry has an area of zero or less.
184-
- Holes within polygons are respected, and the anchor is always placed inside the outer boundary, not inside a hole.
185-
- For GeometryCollection, only the largest polygon by area is considered.
182+
- Holes within polygons are respected. Points within a hole are given a goodness of 0.
183+
- For GeometryCollections, only the largest polygon by area is considered.
186184

187185
!!!tip
188-
- Use `ST_LabelPoint` for tasks such as label placement, identifying representative points for polygons, or other spatial analyses requiring an internal reference point.
186+
- Use `ST_LabelPoint` for tasks such as label placement, identifying representative points for polygons, or other spatial analyses where an internal reference point is preferred but not required. If intersection of the point and the original geometry is required, use of an algorithm like `polylabel` should be considered.
189187
- `ST_LabelPoint` offers a faster, approximate solution for label point generation, making it ideal for large datasets or real-time applications.
190188

191189
Format:

0 commit comments

Comments
 (0)