Bug report #8572

PostGIS Geography Type, ERROR: Invalid geography

Added by Denver Pierce almost 7 years ago. Updated almost 5 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Data Provider/PostGIS
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:17317

Description

Loading geography types in Master by adding a PostGIS Layer, nothing is displayed and the following log is given:

Query: DECLARE qgisf0_0 BINARY CURSOR FOR SELECT
st_asbinary(st_force_2d("pos"::geometry),'NDR'),"id" FROM
"public"."locations" WHERE "pos" && st_makeenvelope(-180,-90,180,90,4326)
returned 7 [ERROR: Invalid geography. Antipodal (180 degrees long) edge
(180 -90,180 90) detected, add a point between to make two edges that span
less than 180 degrees.]

Relevant stack exchange post:
http://gis.stackexchange.com/questions/70556/error-invalid-geography-antipodal-edge-with-postgis?noredirect=1#comment96122_70556

And post on the list:
http://osgeo-org.1560.x6.nabble.com/geometry-with-geography-type-column-not-displayed-td4690688.html#a4690860

It seems the BBOX query is being cast to geography, then that is being sent back as invalid as it contains a banned antipodal query on a geography.

CREATE TABLE global_points (
id SERIAL PRIMARY KEY,
name VARCHAR(64),
location GEOGRAPHY(POINT,4326)
);
INSERT INTO global_points (name, location) VALUES ('freiburg', ST_GeographyFromText('POINT(7.86 48.0)'));
CREATE INDEX global_points_gix ON global_points USING GIST ( location );

Associated revisions

Revision 90b3efb9
Added by Jürgen Fischer almost 5 years ago

postgres provider: also cast geography to geometry when using && (fixes #8572)

Revision 3792afdb
Added by Jürgen Fischer almost 5 years ago

postgres provider: also cast geography to geometry when using && (fixes #8572)

(cherry picked from commit 90b3efb93dd0b6460ce496a8acd7fcbf34b22f63)

History

#1 Updated by Sandro Santilli over 6 years ago

Casting the geography to a geometry would fix this:
WHERE "location"::geometry && ...

Jef: was this that you had in mind when you asked about casting to geometry ?

#2 Updated by Sandro Santilli over 6 years ago

I've filed an upstream bug as the workaround suggested by the error message (adding in-between point) doesn't help:
http://trac.osgeo.org/postgis/ticket/2495

#3 Updated by Jonathan Moules almost 5 years ago

This still happens with 2.6.1. I'm surprised the priority is so low given it makes QGIS useless with many PostGIS datasets.

#4 Updated by Jürgen Fischer almost 5 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF