[postgis-users] ST_Intersects differing results

Paul Ramsey pramsey at cleverelephant.ca
Tue May 24 10:28:33 PDT 2016


The question is not why ST_Intersects() is returning boundary touching
results, it's why your old version did not (at least, as far as you
observed). Because, ST_Intersects(A,B) is *supposed* to return true
for any object B that is not disjoint from A. So, either you were not
observing what you thought you were from that original GeoServer
setup, or GeoServer was post-filtering the data from the database to
remove the touching cases. I was pretty sure GeoServer used exactly
the same intersects semantics as PostGIS, so I lean towards the first
option.

ATB,
P

On Tue, May 24, 2016 at 6:45 AM, Timothy Asquith <tim at redronin.io> wrote:
> I have a table of land parcels in my PostGIS database, and I'm doing a basic
> spatial join against zoning polygons.
>
> I'm having issues where a previously-correct query is now returning
> different results.
>
> Up until now, I've been using a Geoserver WFS, and making these queries
> using CQL's INTERSECT operation. This operation generates a PostGIS query
> like so:
>
> SELECT * FROM "public"."planning_zones" WHERE "geom" && ST_GeomFromWKB($1,
> 4326) AND ST_Intersects("geom", ST_GeomFromWKB($2, 4326)) LIMIT 1000000
>
> As my land parcel dataset is snapped to my zoning polygons, this query
> causes Geoserver to return a single record.
>
> Now, I'm refactoring that query into a JSON API I'm building, and I'm
> recreating that PostGIS query, and making the query directly to Postgres
> (not Geoserver).
>
> The problem is that the query is now returning multiple zoning polygons. The
> difference is that I'm directly joining the zoning polys to the parcels:
>
> SELECT * FROM zones AS z, parcels AS p ON ST_Intersects(z.geom, p.geom)
> WHERE p.id = 99 AND z.geom && p.geom
>
> This new query is returning multiple results, including polygons that share
> a boundary. This didn't happen before.
>
> Can anyone shed any light on why this might be happening? My suspicions are
> that the tolerance of the Geoserver query differs to the raw PostGIS query,
> but I'm uncertain how to best affect this.
>
> ▬▬▬ι═══════════ﺤ
> Timothy Asquith // Red Ronin
> tim at redronin.io
> www.redronin.io
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/postgis-users


More information about the postgis-users mailing list