last_point - ObjectVision/GeoDMS GitHub Wiki
Geometric functions last_point
The last_point function extracts the last point from each sequence (arc, polygon, or linestring).
last_point(sequences: E->Sequence<Point>) -> E->Point
Returns the last point of each sequence geometry. For:
- Arcs/linestrings: The endpoint of the line
- Polygons: The last vertex (which equals the first vertex for closed rings)
- Empty sequences: Returns undefined (null)
This is the counterpart to first_point.
| argument | description | type |
|---|---|---|
| sequences | Attribute containing sequence geometries | E->Sequence |
Time complexity: O(n) where n is the number of sequences (constant time per sequence).
Memory efficient as it only accesses the last element of each sequence without loading entire geometries.
- Input must be a sequence type (arc, polygon, linestring)
- Result is undefined for empty sequences
unit<uint32> Roads: nrofrows = 100;
attribute<FPoint> geometry (poly, Roads); // road linestrings
// Get start and end points of each road
attribute<FPoint> start_point (Roads) := first_point(geometry);
attribute<FPoint> end_point (Roads) := last_point(geometry);
// Road length from first to last point (simplified)
attribute<Float64> straight_distance (Roads) := dist(start_point, end_point);
- first_point - extracts first point
- sequence2points - extracts all points from sequences
- centroid - center of mass of geometry
- Geometric functions
5.0