For the basic line subsetting you can use LocationIndexedLine.extractLine:
http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/linearref/LocationIndexedLine.html#extractLine(com.vividsolutions.jts.linearref.LinearLocation,
com.vividsolutions.jts.linearref.LinearLocation)
The linear referencing algorithms do not provide special handling for
closed linesttrings. So in that case custom code is needed to determine
whether to extract the portion between the points, or the "ends" of the
line. If the ends are extracted they can be concatenated to form a
contiguous linestring.
You don't say exactly how you want to discriminate between these cases. I
don't think the orientation of the input ring matters. If you definitely
know the start point and end point then what matters is if the start point
is *after* the end point along the line. If they are in forward order,
then compute the subline between them. If they are reversed then compute
the "ends" and concatenate them.
(An alternative requirement would be wanting the shortest extracted line.
This would require computing both possibilities and picking the desired
one).
When you get this working it would be nice to have the code posted for
others to use.
On Mon, Feb 23, 2015 at 1:41 PM, Jan Tosovsky <[email protected]> wrote:
> Dear All,
>
> I need to create a subpath from the original path in between two
> intersections. I am just curious if something like this is covered by some
> theory and can be solved even with JTS library or I have to write my code
> to
> handle this.
>
> In my case the original path can be closed and its starting point may lay
> between two intersections. In these cases I would expect joining both ends
> together.
>
> http://drifted.in/other/jts/subpath.png
>
> Original paths are red, intersections are represented by small red spots,
> the beginning of closed path is green. The processing direction could be
> optional, by default clock-wise.
>
> Do you have any idea?
>
> Thanks, Jan
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Jts-topo-suite-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
>
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Jts-topo-suite-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user