Hi,
Assume I have a Point p and a LineString ls.
By the statement
double dist = ls.distance(p)
I easily can figure out the distance between them.
But now I want to now the Point p_cut on the LineString that was used to
calculate the distance, more accurate I want to know the length of the
LineString from the beginning to the Point p_cut.
Any suggestions?
My first idea was to create a circle around Point p with a radius of
distance, and the intersection between this circle and the LineString is
point p_cut.
To get the length of LineString from the beginning to this point the
following algorithm could do it:
Create new empty line String lsCopy
Add first coordinate of the original LineString to lsCopy
DO
Add next coordinate of the original LineString to lsCopy
IF NOT lsCopy intersects p_cut THEN
Continue;
ELSE
Remove last coordinate from ls_copy
Add coordinates of p_cut to ls_copy
WHILE original LineString has next coordinate
I have not yet tried it, I guess it would work but this looks very ugly
and I wonder if there is a more beautiful solution?
Thanks for help
Stefan
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users