[postgis-devel] RE: ST_Distance, ST_Dwithin possible breaking change in 1.4
Paragon Corporation
lr at pcorp.us
Fri Apr 3 23:26:07 PDT 2009
This was a bit of a false alarm. On further inspection ST_Distance and
ST_Dwithin do work with geometry collections. What I was testing was this
from my torture script:
SELECT ST_Distance(foo1.the_geom, foo2.the_geom), ST_AsEWKT(foo1.the_geom),
ST_AsEWKT(foo2.the_geom)
FROM ((SELECT ST_SetSRID(ST_Point(i,j),4326) As
the_geom
FROM generate_series(-10,50,15) As i
CROSS JOIN generate_series(40,70, 15) j)) As foo1
CROSS JOIN ((SELECT
ST_Collect(ST_Collect(ST_SetSRID(ST_MakePoint(i,j,m),4326),ST_SetSRID(ST_Mak
ePolygon(ST_AddPoint(ST_AddPoint(ST_MakeLine(ST_MakePoint(i+m,j,m),ST_MakePo
int(j+m,i-m,m)),ST_MakePoint(i,j,m)),ST_MakePointM(i+m,j,m))),4326))) As
the_geom
FROM generate_series(-10,50,20) As i
CROSS JOIN generate_series(50,70, 20) As j
CROSS JOIN generate_series(1,2) As m
GROUP BY m)) As foo2
LIMIT 3;
In 1.3.5 -- this just returns 0
In 1.4 -- it returns a "ERROR: Unsupported geometry type:
GeometryCollection"
I had run a simpler test to isolate - but can't find where that is. At
first I thought it was an issue with 3d collections, but both these give 2d
answers in 1.3.5 and 1.4
SELECT ST_Distance(g1,g2), ST_Dwithin(g1,g2,0.01), ST_AsEWKT(g2)
FROM (SELECT ST_geomFromText('LINESTRING(1 2 3, 2 4 3)') As g1,
ST_Collect(ST_Buffer(ST_GeomFromText('POINT(0 0 1)'),1),
ST_GeomFromText('LINESTRING(0 0 1, -1 -1 -1)')) As g2)
As foo
So I'm not quite sure what the problem is or if it is even a bug.
I thought it was because of the nested collections in the first, but I think
my simpler example which I have to dig up -- proved there were cases where a
simple collection would trigger this.
Thanks,
Regina
-----Original Message-----
From: Paragon Corporation [mailto:lr at pcorp.us]
Sent: Friday, April 03, 2009 11:39 PM
To: 'PostGIS Development Discussion'
Subject: ST_Distance, ST_Dwithin possible breaking change in 1.4
I noticed we made a somewhat fundamental correct change that when
ST_Distance comes across a Geometry collection it throws an error "geometry
collection not supported"
Before it would just incorrectly return 0 I think. I wouldn't be so
bothered about this code except I have some applications that do an
intersection and then a distance against some other geometry. Sometimes
that intersection results in a geometry collection. I fear if I put 1.4
into production, it will break my somewhat flawed code and there are a lot
of places I need to check this logic.
We should probably at least note this in the release notes that it's a
possibly breaking change or
1) Alternatively we can just return NULL. Though NULL has its problems as
well and is not that satisfying either, but would at least allow queries to
run to completion so bit less breaking.
2) if its not much trouble we could just fix it to work with geometry
collections.
3) Just have it return 0 when it hits a geometry collection as it did
before. If no one notices it was broken before, no one will notice when we
don't fix it, but they may notice when we have it throw a correct error.
Thanks,
Regina
More information about the postgis-devel
mailing list