[Jts-topo-suite-user] find nearest vertex of linestring From: Imran Rajjad - 2013-05-02 19:29 Attachments: Message as HTML ```Dear list, I have been searching javadocs of JTS .. but am unable to find a way to find the nearest vertex of a linestring. Further is it possible to split a linestring at a given point or clip a linestring using two points which are on that linestring? Currently I have to iterate through the whole set of vertices which doesnt look very comfortable regards, -- I.R ```
 Re: [Jts-topo-suite-user] find nearest vertex of linestring From: Martin Davis - 2013-05-02 19:47 Attachments: Message as HTML ```"Nearest vertex of a linestring" - nearest to what? If to an arbitrary point, then there is no builtin method to do this - you will have to iterate over the vertices of the linestring and compute the distance to the query point. If on the other hand you mean "find the nearest *point location* on a linestring to a given point", then you can use the linear referencing API to do this. Have a look at: http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/linearref/LengthIndexedLine.html#extractPoint(double) and http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/linearref/LengthIndexedLine.html#project(com.vividsolutions.jts.geom.Coordinate) To extract a section of a linestring between two points, compute the length indices of the points using LengthIndexedLine.project, and then use http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/linearref/LengthIndexedLine.html#extractLine(double, double) You can also use the LengthIndexedLine.project method to get the index of t On Thu, May 2, 2013 at 12:28 PM, Imran Rajjad wrote: > Dear list, > > I have been searching javadocs of JTS .. but am unable to find a way to > find the nearest vertex of a linestring. > > Further is it possible to split a linestring at a given point or clip a > linestring using two points which are on that linestring? Currently I have > to iterate through the whole set of vertices which doesnt look very > comfortable > > > ```
 Re: [Jts-topo-suite-user] find nearest vertex of linestring From: Imran Rajjad - 2013-05-04 11:27 Attachments: Message as HTML ```Hi, thanks for your reply.. is it possible to hatch the linestring geometry before doing this using Densifier , that way I will have points at equal intervals instead of segments with random length. regards, Imran On Fri, May 3, 2013 at 12:47 AM, Martin Davis wrote: > "Nearest vertex of a linestring" - nearest to what? If to an arbitrary > point, then there is no builtin method to do this - you will have to > iterate over the vertices of the linestring and compute the distance to the > query point. > > If on the other hand you mean "find the nearest *point location* on a > linestring to a given point", then you can use the linear referencing API > to do this. Have a look at: > > > http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/linearref/LengthIndexedLine.html#extractPoint(double) > and > > http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/linearref/LengthIndexedLine.html#project(com.vividsolutions.jts.geom.Coordinate) > > To extract a section of a linestring between two points, compute the > length indices of the points using LengthIndexedLine.project, and then use > > > http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/linearref/LengthIndexedLine.html#extractLine(double, > double) > > You can also use the LengthIndexedLine.project method to get the index of t > > > On Thu, May 2, 2013 at 12:28 PM, Imran Rajjad wrote: > >> Dear list, >> >> I have been searching javadocs of JTS .. but am unable to find a way to >> find the nearest vertex of a linestring. >> >> Further is it possible to split a linestring at a given point or clip a >> linestring using two points which are on that linestring? Currently I have >> to iterate through the whole set of vertices which doesnt look very >> comfortable >> >> >> > > ------------------------------------------------------------------------------ > Get 100% visibility into Java/.NET code with AppDynamics Lite > It's a free troubleshooting tool designed for production > Get down to code-level detail for bottlenecks, with <2% overhead. > Download for free and get started troubleshooting in minutes. > http://p.sf.net/sfu/appdyn_d2d_ap2 > _______________________________________________ > Jts-topo-suite-user mailing list > Jts-topo-suite-user@... > https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user > > -- I.R ```
 Re: [Jts-topo-suite-user] find nearest vertex of linestring From: Martin Davis - 2013-05-04 15:21 Attachments: Message as HTML ```On Sat, May 4, 2013 at 4:27 AM, Imran Rajjad wrote: > Hi, > > thanks for your reply.. is it possible to hatch the linestring geometry > before doing this using Densifier , that way I will have points at equal > intervals instead of segments with random length. > > Yes ```