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

strk at refractions.net strk at refractions.net
Thu Jul 28 06:52:25 PDT 2005


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
> ('0105000000010000000102000000020000001BA43BA50E5A5541A12F8367C80956418284C50C685A5541F12B9D84250A5641',
> '0105000000010000000102000000050000002246BA2BF05A55418B479267A20956414C8D31C4965A5541C6DC774A450956411BA43BA50E5A5541A02F8367C80956418484C50C685A5541F52B9D84250A56412246BA2BF05A55418B479267A2095641');
> 
> 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



More information about the postgis-users mailing list