Re: [Jts-topo-suite-user] find nearest vertex of linestring
Brought to you by:
dr_jts
From: Martin D. <mtn...@gm...> - 2013-05-02 19:47:52
|
"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 <ra...@gm...> 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 > > > |