[geos-devel] Re: WKB parser

Martin Davis mbdavis at VividSolutions.com
Fri May 13 15:51:45 EDT 2005


JTS is basically a 2D system.  For that reason the equality methods just
check the 2D values.  I agree this is an issue for checking 3D data.  I
guess we could have an equalsExact3D to take care of this.  But to my
mind this is starting to get a bit crufty.  

With the proving-out of user-defined CoordinateSequences, the new "zen"
of JTS which I am following is that JTS is basically 2D, but users can
provide CoordinateSequences which contain extra information at each
point.  Given this, what JTS methods need to do is let the user define
the behaviour of CoordinateSequences.  In the case of equality testing,
this means they have to define CoordinateSequence equality.  This is the
approach I have taken in the unit test code for WKB I/O.  I have defined
a Geometry#compareTo(Object, CoordinateSequenceComparator) method, which
lets the user say how CoordinateSequences should compare.  And I've
provided an implementation of CoordinateSequenceComparator which allows
specifying how many dimensions should be compared.  This lets me use
existing Coordinate objects and compare them across 2 or 3 dimensions.

Comments?  Does this design solve the problem?

Martin Davis, Senior Technical Architect
Vivid Solutions Inc.      www.vividsolutions.com
Suite #1A-2328 Government Street Victoria, B.C. V8T 5G5
Phone: (250) 385 6040 - Local 308 Fax: (250) 385 6046


> -----Original Message-----
> From: strk at refractions.net [mailto:strk at refractions.net] 
> Sent: May 13, 2005 9:13 AM
> To: geos-devel at geos.refractions.net
> Cc: Martin Davis
> Subject: Re: [geos-devel] Re: WKB parser
> 
> 
> Martin, I checked out the equalsExact method as suggested
> by Dave. It internally calls equals() on Coordinates, which
> is again 2D only. Isn't this a conceptual bug since the
> metohd is named equalsEXACT ?
> 
> Yes, current JTS does the same, it's
> Geometry#equal(Coordinate, Coordinate, double)
> 
> --strk;
> 
> On Fri, May 13, 2005 at 05:30:05PM +0200, strk at refractions.net wrote:
> > On Fri, May 13, 2005 at 09:14:23AM -0400, 
> dblasby at openplans.org wrote:
> > > strk,
> > > 
> > > JTS has an "equalsExact(Geometry,Geometry)" method and a 
> > > "equalsExact(Geometry,Geometry, tolerance)".
> > > 
> > > I'm pretty sure that GEOS has at least the former.
> > > 
> > > I'm not 100% sure if its 2d or 3d (I assume its 3d, but I 
> could be 
> > > wrong).
> > 
> > I'm making some tests, the tolerance argument is mandatory 
> with GEOS, 
> > but code seems broken (a simple comparison of a point in 
> and out WKB 
> > returns false...).
> > 
> > Anyway, thanks for the point, I'll at least fix that, and 
> possibly use 
> > it for testing WKB.
> > 
> > --strk;
> > _______________________________________________
> > geos-devel mailing list
> > geos-devel at geos.refractions.net 
> > http://geos.refractions.net/mailman/listinfo/geos-devel
> 



More information about the geos-devel mailing list