The GeometryEngine in runtime 100.1 onwards has a cut method that cuts a geometry using a polyline.
However, what would be the best and safest way to split an actual polyline by a single point?
Currently, I would need to create a polyline as the cutter. Since all I have is a single point, then technically, without knowing ahead of time the geometry of the polyline I want to cut, I would have to add another random point to my known point to create a polyline, then use that as the cutter to cut my initial polyline. No matter where I add that second random point, I could never be sure that it wouldn't intersect the initial polyline twice.
The only safe way is the way I previously did it, where I create a brand new polyline and add all the points up to that cut/split point and use that new polyline.
Is there a better way I'm missing? Or is this perhaps a suggestion for a variation of the cut method specifically for this task?
Solved! Go to Solution.
Sounds like you want something like the split workflow from Desktop? Methods for splitting line features—Help | ArcGIS for Desktop We don't really have anything like that at the moment
Hi Paul!
What is the sense behind cutting a polyline by a single point?
Is the single point an element of that polyline?
If so you can access all points of a polyline using
polyline.parts().part(0).pointCount() // pointCount of first part
Maybe the operator== is not sufficiant, give qFuzzyCompare a try....
Hope it helps 🙂
Hi Norbert
Thanks for the reply.
You ask what is the sense of cutting a polyline by a single point - perhaps 'cut' is the wrong term, but the concept is valid. Perhaps a use case would help understand:
e.g. I have a polyline that represents a waterway. I have a user standing beside that waterway. Given their gps location, I then find the nearest coordinate on the waterway polyline. I now have a 'point' on that polyline. I want to then obtain a section of that line, say, from the beginning of the line up to that point.
As I mention above, my current approach is to create a new line and copy all the points across from the original line up to the point in question. This works fine. My question is whether there is or should be a runtime method that can achieve this more efficiently.
cheers.
-Paul
By definition a point is dimension-less. I can't see how one can 'cut' an areal object with one that has no dimension...
Hi Joe.
See my reply to Norbert above. Perhaps 'cut' is not the correct term.
I also have a similar use case. It's also pretty clear what @Anonymous User was asking and there's really no need to get too technical about the definition of a point. I've done this in the past using several of the GeometryEngine functions in the ArcGIS for JavaScript API. You should find similar functions in the ArcGIS Runtime.
Sounds like you want something like the split workflow from Desktop? Methods for splitting line features—Help | ArcGIS for Desktop We don't really have anything like that at the moment
Yeah I think you're on to it. Not terribly important, but could be useful in the future.
cheers,
-Paul