Newbie question: Newbie Question: how to clip a curved line between 2 given points

31 views
Skip to first unread message

Arvinder Chopra

unread,
Mar 9, 2022, 6:21:18 PM3/9/22
to NetTopologySuite
I have a line (LineString) that passes through the red triangle and the black X, and looks like this:
S1.png

I want to clip the line to only the segment between the red triangle and black X.

I used this code:

LengthLocationMap llm = new LengthLocationMap(ls); //where ls is my LineString LengthIndexedLine lil = new LengthIndexedLine(ls); //where ls is my LineString ExtractLineByLocation ell = new ExtractLineByLocation(ls); //where ls is my LineString LinearLocation ll1 = llm.GetLocation(lil.Project(redTriangle.Coordinate)); var ls1 = ell.Extract(new LinearLocation(0, 0d), ll1); LinearLocation ll2 = llm.GetLocation(lil.Project(blackX.Coordinate), true); var ls2 = ell.Extract(ll1, ll2); //This is the clipped line (final result)

The above code produced the result shown below which is not what I had in mind. Could you please suggest a fix in the code above, such that I can keep just the line segment between the red triangle and black X? Thanks


S2.png


Reply all
Reply to author
Forward
0 new messages