Could Esri consider adding a Arcade function for getting the endpoint of a polyline? (including multipart lines)
Similar to ST_Geometry’s St_Endpoint() function.
Related: Arcade: Get endpoint coordinates of multi-part polyline
In case you don't know: You can use negative numbers to index arrays from the end. While array[0] returns the first element, array[-1] returns the last element, array[-2] returns the second to last element and so on.
So you can get the last point of a polyline by jumping to the last point of the last line segment:
Geometry($feature).paths[-1][-1]
Whilst @JohannesLindner has offered up a perfectly acceptable solution, it's a bit of a geeky way of doing things (please don't take offence!). ArcObjects would offer up a ToPoint on IPolyline, so getting hold of a start/end point of a line becomes a simple property of the geometry. Navigating arrays by index position just feel like too much work and open to error.
@Bud has recently been suggesting all sorts of ideas that would make geometry manipulation in Arcade a cleaner approach rather than cycling through dictionaries and lists, which seem to me as a desktop nerd a very web-based approach.
Hi everybody,
I am currently also working on a problem related to this topic and wanted to jump in here as well. Basically I am trying to iterate over a featureset of polylines and check if the currently made feature intersects with any of the endpoints of the feature lines in the feature set. For this to work I created this code:
for(var line in lines){
var endPoint = Geometry(line).paths[-1][-1]
return count(intersects(endPoint, Geometry($feature))) > 0
}
This should return "False" if the created feature is not intersecting on of the line endpoints im trying to iterate over. However all I get is a "unexpected null" error at "var endPoint". Any Ideas how i could solve the problem and get the end points of all the line features im iterating over?
Thanks.
Stefan
Stefan,
This is an IDEAS post not a place to ask questions, you need to be asking this under the appropriate question group, I'm guessing ArcGIS Online? Please migrate your question to there and delete your "idea" here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.