[postgis-users] New within problem
Miguel de la Fuente
mjdelafuente at gmail.com
Thu Jul 28 11:19:58 PDT 2005
Yes, I was trying something like that when I read your reply.
You're right the first geometry came from a function that I made to
convert a MULTIPOLYGON to a MULTILINESTRING and I made it by taking
the points from an astext() of a multipolygon, and building the
multilinestrig with them.
Now I note that I can do the same using BOUNDARY(multipolygon) with no
accuracy loss.
I was comparing the of apply my function and boundary, and noted that
the astext() of both results were the same, but the binary form were
different. So using astext there is an information loss.
And your second suggestion of using Snaptogrid() is good, but I will
try not to use it as I can, because of its cost.
Thank you very much for your answers.
On 7/28/05, strk at refractions.net <strk at refractions.net> wrote:
> On Thu, Jul 28, 2005 at 12:01:24PM -0300, Miguel de la Fuente wrote:
> > I think I didn't explain it very well.
> >
> > what I don't understand is why Within(g1,g2) returns me False while g1
> > is in fact a segment of g2, so g1 is "within" g2.
> >
> > WITHIN(g1,g2) returns FALSE
> >
> > And only because of it is that I added the within functions between
> > their box2d(), and their geometryfromtext(astext()), and they return
> > me TRUE as I expected.
> >
> > WITHIN(BOX2D(g1),BOX2D(g2)) returns TRUE
> > WITHIN(GEOMETRYFROMTEXT(ASTEXT(g1)),GEOMETRYFROMTEXT(ASTEXT(g2))) returns TRUE
>
> Ok, sorry, I answered too fast.
> Also it seems I was wrong about within definition ...
>
> I've reduced your problem to a single point, starting
> from the WKB you provided.
>
> g1: 01010000001BA43BA50E5A5541A12F8367C8095641
> g2: 01010000001BA43BA50E5A5541A02F8367C8095641
> ^
> The two points are *different*, so within() output
> is correct.
>
> within(g1, g2) == false
> intersects(g1, g2) == false
>
> Passing the first geometry (g1) trough WKT and back
> makes it the same of g2:
>
> geometryfromtext(astext(g1)) === g2 :
> 01010000001BA43BA50E5A5541A02F8367C8095641
>
> Did one of your geometries come from a GeomFromText input
> func while the other directly from a shapefile ?
>
> In general, you should not be using GeometryFromText
> to extract elements from your goemetries if you want to
> retain precision.
>
> Or, as an alternative, pass ALL your geoms trough the SnapToGrid
> function to enforce a grid/precision system.
> Using GeometryFromText is like calling SnapToGrid using the
> smallest representable float number as grid size.
>
> --strk;
>
>
> _______________________________________________
> 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