[postgis-users] Getting inconsistent results with function in select vs in a join

Stephen Woodbridge woodbri at swoodbridge.com
Mon Oct 24 11:27:20 PDT 2011

Hi all,

I have a query that gives me one result when I just call the stored 
procedure directly and a different result when it gets call with a join. 
I can not for the life of me figure out what is going on.

So here is the basic query:
select * from imt_rgeo_countyzip(-79.2723,41.2393);

Here is the row that I will join the above with:
select * from testdata where gid=552;

Here is the joined results:
select *, imt_rgeo_countyzip(a.x,a.y) from testdata a where gid=552;

Notice the 5242.59489074449 as the 2nd to last result to the 
imt_rgeo_countyzip() call here but in the reference query above it is 0. 
I have also verified the I'm selecting the same polygon in both of these 
cases. Is this a bug in PostGIS? Specifically in:
    ST_Distance_Spheroid(pnt, the_geom,
      'SPHEROID["WGS 84",6378137,298.257223563]')

My stored procedure definition is here: http://codepad.org/jt9WVoi7

"PostgreSQL 8.3.14 on x86_64-pc-linux-gnu, compiled by GCC gcc-4.3.real 
(Debian 4.3.2-1.1) 4.3.2"

"POSTGIS="1.5.1" GEOS="3.2.0-CAPI-1.6.0" PROJ="Rel. 4.6.1, 21 August 
2008" LIBXML="2.6.32" USE_STATS"

Confused again,

More information about the postgis-users mailing list