How to cut a polyline by a single point?

681
6
Jump to solution
10-12-2018 01:48 AM
PaulHaakma
Regular Contributor

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?

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

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

View solution in original post

0 Kudos
6 Replies
NorbertThoden
Occasional Contributor III

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

  • ImmutablepartCollection Polyline::parts()
  • Immutablepart ImmutablepartCollection::part(index)
  • Point Immutablepart::point(pointIndex)

polyline.parts().part(0).pointCount() // pointCount of first part

Maybe the operator== is not sufficiant, give qFuzzyCompare a try....

Hope it helps 🙂

0 Kudos
PaulHaakma
Regular Contributor

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

0 Kudos
JoeBorgione
MVP Esteemed Contributor

By definition a point is dimension-less.  I can't see how one can 'cut' an areal object with one that has no dimension...

can't wait to retire....
0 Kudos
PaulHaakma
Regular Contributor

Hi Joe.

See my reply to Norbert above. Perhaps 'cut' is not the correct term.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

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

View solution in original post

0 Kudos
PaulHaakma
Regular Contributor

Yeah I think you're on to it. Not terribly important, but could be useful in the future.

cheers,

-Paul

0 Kudos