[postgis-users] New within problem (was:(URGENT BUGFIX (was: twodifferent geometries with the same Astext))

Martin Davis mbdavis at VividSolutions.com
Thu Jul 28 08:43:17 PDT 2005


Strk, running the given test case in JTS returns g1.within(g1) = true.
I'm pretty sure this is the correct answer.    Converting the geometries
to LineStrings gives the same result.

So there does seem to be a discrepancy between PostGIS and JTS here...

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: postgis-users-bounces at postgis.refractions.net 
> [mailto:postgis-users-bounces at postgis.refractions.net] On 
> Behalf Of strk at refractions.net
> Sent: July 28, 2005 6:52 AM
> To: postgis-users at postgis.refractions.net
> Subject: Re: [postgis-users] New within problem (was:(URGENT 
> BUGFIX (was: twodifferent geometries with the same Astext))
> 
> 
> By definition within requires NO boundary overlap.
> 
> Within(box2d,box2d) implicitily casts the box2d 
> into polygons, and since the polygons boundaries overlap
> I think within() is correctly returning false.
> 
> For MULTILINESTRINGS the boundaries are the endpoints.
> 
> Try:
> 
>   SELECT within(exteriorring(box2d(g1)), exteriorring(box2d(g2)))
> 
> This would return the polygon boundaries as LINESTRINGS
> 
> --strk;
> 
> On Thu, Jul 28, 2005 at 10:38:45AM -0300, Miguel de la Fuente wrote:
> > Thanks Strk, your fix work well with the example I wrote first.
> > 
> > But, now I`m still having problems with within().
> > 
> > I fix the bug as you see:
> > 
> > select postgis_full_version()
> > 
> > "POSTGIS="1.0.2" GEOS="2.1.3" PROJ="Rel. 4.4.9, 29 Oct 
> 2004" USE_STATS 
> > DBPROC="0.3.0" RELPROC="0.3.0""
> > 
> > After that, I found the following error
> > 
> > CREATE TABLE mu (
> >    g1 geometry,
> >    g2 geometry
> > );
> > 
> > ALTER TABLE public.mu OWNER TO postgres;
> > 
> > INSERT INTO mu (g1, g2) VALUES 
> > 
> ('0105000000010000000102000000020000001BA43BA50E5A5541A12F8367C8095641
> > 8284C50C685A5541F12B9D84250A5641',
> > 
> '0105000000010000000102000000050000002246BA2BF05A55418B479267A
> 20956414C8D31C4965A5541C6DC774A450956411BA43BA50E5A5541A02F836
> 7C80956418484C50C685A5541F52B9D84250A56412246BA2BF05A55418B479
> 267A2095641');
> > 
> > SELECT
> >             ASTEXT(g1),
> >             ASTEXT(g2),
> >             BOX2D(g1),
> >             BOX2D(g2),
> >             WITHIN(g1,g2),
> >             WITHIN(BOX2D(g1),BOX2D(g2)),
> >             
> > WITHIN(GEOMETRYFROMTEXT(ASTEXT(g1)),GEOMETRYFROMTEXT(ASTEXT(g2)))
> > FROM
> > mu
> > 
> > "MULTILINESTRING((5597242.5817652 5777185.61738196,5597600.19955552 
> > 5777558.072093))";"MULTILINESTRING((5598144.68324426
> > 5777033.61830319,5597787.06552441 5776661.16356582,5597242.5817652 
> > 5777185.61738196,5597600.19955552 5777558.072093,5598144.68324426 
> > 5777033.61830319))";"BOX(5597242.5 5777185.5,5597600.5 
> > 5777558.5)";"BOX(5597242.5 5776661,5598145 5777558.5)";f;t;t
> > 
> > within(g1,g2) return FALSE
> > within(box2d(g1),box2d(g2)) return TRUE
> > within(geometryfromtext(astext(g1)),geometryfromtext(astext(g2))) 
> > return TRUE
> > 
> > ?????
> > 
> > As you see both box2d are well created, and the within() works well 
> > with the box2d, but it fails with the multilinestrings. Do you know 
> > why? _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 



More information about the postgis-users mailing list