Both these results look like they are as per spec to me.

Don't try using DistanceToPoint - it's just a utility class for Hausdorff
distance.  It really shouldn't be public.

I'm not really clear on what you're looking for, but it sounds like you may
have to build it yourself out of primitive operations.

On Tue, Mar 3, 2015 at 3:20 PM, Jan Tosovsky <[email protected]> wrote:

> On 2015-02-26 Jan Tosovsky wrote:
> > On 2015-02-26 Martin Davis wrote:
> > > On 2015-02-24 Jan Tosovsky wrote:
> > > >
> > > > http://drifted.in/other/jts/snapping.png (exaggerated)
> > > >
> > > > Can I somehow snap line fragment endpoints (blue) to the
> > > > specific path (red) if the distance is in a specified
> > > > tolerance?
> > >
> > > Have you looked at: DistanceOp.nearestPoints ?
> > > ...
> > >
> > > Or if you are working only with lines, look at LengthIndexedLine
> > > project() and extractPoint()
> >
> > Wow, thanks, it looks promising, I'll give it a try.
>
> Hmm, see http://drifted.in/other/jts/jts_snap.png
>
> // RED
> Coordinate[] coords = new Coordinate[4];
> coords[0] = new Coordinate(0, 0);
> coords[1] = new Coordinate(1, 0);
> coords[2] = new Coordinate(1, 1);
> coords[3] = new Coordinate(0, 1);
> Geometry reference = factory.createLineString(coords);
>
> // BLUE
> coords = new Coordinate[2];
> coords[0] = new Coordinate(0.1, 0.5);
> coords[1] = new Coordinate(0.5, 0.1);
> Geometry geometry = factory.createLineString(coords);
>
> Coordinate[] nearestPoints = DistanceOp.nearestPoints(reference, geometry);
> for (Coordinate coordinate : nearestPoints) {
>    System.out.println(coordinate.toString());
> }
>
> // (0.5, 0.0, NaN)
> // (0.5, 0.1, NaN)
>
> So this method can be used for determining nearest points on two
> geometries,
> but it cannot be used for analyzing the oposite line endpoint.
>
> =================
>
> The same data, but different handling:
>
> Coordinate[] coordsF = geometry.getCoordinates();
> PointPairDistance distance = new PointPairDistance();
>
> DistanceToPoint.computeDistance(reference, coordsF[0], distance);
> System.out.println(distance.toString());
> // LINESTRING ( 0.1 0.0, 0.1 0.5 )
>
> Here I'd expect rather LINESTRING ( 0.0 0.5, 0.1 0.5 ). Currently only Y
> axis difference seems to be taken into an account. Is it a bug or feature?
> Is there any way to get the minimum distance regardless X/Y direction?
>
>
> DistanceToPoint.computeDistance(reference, coordsF[coordsF.length - 1],
> distance);
> System.out.println(distance.toString());
> // LINESTRING ( 0.5 0.0, 0.5 0.1 )   // This is correct.
>
>
------------------------------------------------------------------------------
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

Reply via email to