[postgis-users] Querying geometries with different srid

Ture Pålsson ture.palsson at gmail.com
Thu Jan 13 21:38:15 PST 2011


2011/1/14 Farrukh Najmi <farrukh at wellfleetsoftware.com>:

>> --Gives Error: Operation on mixed geometries
>> SELECT * FROM GeometryValueType gvt WHERE ( ST_SRID(gvt.geometry) = 4326
>> AND
>>  within(gvt.geometry, ST_GeomFromText('POLYGON((-100 0, 0 0, 0 100, -100
>> 100, -100 0))', 4326)) = true )

Does SQL guarantee left-to-right evaluation and short-circuiting of
AND checks the way that C does? I must confess I have no clue.
However, if it doesn't, that might be what's causing your headaches.
I'd try moving the SRID filter into a WITH construct or a sub-select
just to see what happens:

WITH filteredgeom AS (
  SELECT * FROM gvt WHERE ST_SRID(geometry) = 4326)
SELECT * FROM filteredgeom WHERE within(geometry, ...) ;

Probably lots of syntax errors (haven't had breakfast yet) but you get
the idea...

  -- Ture



More information about the postgis-users mailing list