[postgis-users] Strange intersection behavior

Paul Ramsey pramsey at cleverelephant.ca
Mon Dec 29 10:26:44 PST 2008


Indeed. If I test the distance of your derived point from the original
line, it is:

 5.82594422389951e-15

We only have 64 bits of precision to work with (less, really, since
the exponent and sign take up space) in a double, so the derived point
will not be "on" the original line, in a mathematical sense.

P.

On Mon, Dec 29, 2008 at 10:19 AM, Obe, Regina <robe.dnd at cityofboston.gov> wrote:
> Andreas,
>
> I think you have unearthed one of the cruel lessons of floating point math.
>
> Best described in Isaac Kunen's blog.
>
> http://blogs.msdn.com/isaac/archive/2008/08/07/the-imprecise-nature-of-geometry.aspx
>
> So we see it is not unique to PostGIS.
>
> Hope that helps,
> Regina
>
>
>
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net on behalf of Andreas
> Albarello
> Sent: Mon 12/29/2008 1:06 PM
> To: postgis-users at postgis.refractions.net
> Subject: [postgis-users] Strange intersection behavior
>
> Hi list,
>
> I'm at a loss as to what is happening here. I'm using PostgreSQL 8.3.5
> along with PostGIS 1.3.5 on Windows.
>
> So this query works fine:
>
> select astext(intersection(geomfromtext('LINESTRING(8.30234187721807
> 46.6802395904018,6.3382169942078 46.3031276124166)'),
> geomfromtext('LINESTRING(7.32028160673789
> 46.4916949088309,7.32028323240689 46.491581924505)')));
>
> Now I'd expect this query to work too:
>
> select
> astext(intersection(intersection(geomfromtext('LINESTRING(8.30234187721807
> 46.6802395904018,6.3382169942078 46.3031276124166)'),
> geomfromtext('LINESTRING(7.32028160673789
> 46.4916949088309,7.32028323240689 46.491581924505)')),
> geomfromtext('LINESTRING(7.32028160673789
> 46.4916949088309,7.32028323240689 46.491581924505)')));
>
> i.e., intersecting the intersection with the original line. Weirdly
> enough, I'm getting GEOMETRYCOLLECTION EMPTY. This has nothing to do
> with using geomfromtext, tried the same thing inside plpgsql and got the
> same result. Besides, geomfromtext ought to be deterministic anyways.
>
> Same thing goes for this:
>
> select
> intersects(line_interpolate_point(geomfromtext('LINESTRING(7.32028160673789
> 46.4916949088309,7.32028323240689 46.491581924505)'), 0.1),
> geomfromtext('LINESTRING(7.32028160673789
> 46.4916949088309,7.32028323240689 46.491581924505)'));
>
> returns false.
>
> Can anyone shed some light on this?
>
> TIA
>
> --
> --------------------------------------------------------------------
> Andreas Albarello
> Analysis & SW Development
>
> Territorium Online srl/GmbH
> Via Buozzi Str. 12
> I 39100 Bolzano/Bozen
>
> Phone:  +39 0471 068611
> Fax:    +39 0471 068619
>
> email: andreas.albarello at territoriumonline.com
> web:   http://www.territoriumonline.com
> --------------------------------------------------------------------
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
>
>
> ________________________________
>
> The substance of this message, including any attachments, may be
> confidential, legally privileged and/or exempt from disclosure pursuant to
> Massachusetts law. It is intended solely for the addressee. If you received
> this in error, please contact the sender and delete the material from any
> computer.
>
> ________________________________
>
> Help make the earth a greener place. If at all possible resist printing this
> email and join us in saving paper.
>
> _______________________________________________
> 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