[Geoserver-devel] [jira] (GEOS-4937) Error "Operation on two geometries with different SRIDs" appears for views with null geometries in first row

Nathan Wiese created GEOS-4937:
----------------------------------

             Summary: Error "Operation on two geometries with different SRIDs" appears for views with null geometries in first row
                 Key: GEOS-4937
                 URL: https://jira.codehaus.org/browse/GEOS-4937
             Project: GeoServer
          Issue Type: Bug
          Components: PostGIS
    Affects Versions: 2.1.3
         Environment: Windows 7 (64 bit), PostgreSQL 9.0.4, PostGIS 1.5.3
            Reporter: Nathan Wiese
            Assignee: Andrea Aime

Hallo GeoServer Team,

I created the following data set in PostgreSQL/PostGIS:

-- feature data
CREATE TABLE city (id int, name varchar, population int, PRIMARY KEY(id));
INSERT INTO city VALUES (1, 'Aachen', 258664);
INSERT INTO city VALUES (2, 'Berlin', 3490445);

-- geometries for features in low resolution
CREATE TABLE city_geometry_low_res (id int, PRIMARY KEY(id));
SELECT AddGeometryColumn('city_geometry_low_res', 'the_geom', 4326, 'POINT', 2);
INSERT INTO city_geometry_low_res VALUES (2, GeomFromText('POINT(52 13)', 4326));

-- geometries for features in high resolution
CREATE TABLE city_geometry_high_res (id int, PRIMARY KEY(id));
SELECT AddGeometryColumn('city_geometry_high_res', 'the_geom', 4326, 'POINT', 2);
INSERT INTO city_geometry_high_res VALUES (1, GeomFromText('POINT(50.772341 6.102912)', 4326));
INSERT INTO city_geometry_high_res VALUES (2, GeomFromText('POINT(52.540558 13.406748)', 4326));

CREATE VIEW city_view AS SELECT * FROM city NATURAL LEFT OUTER JOIN city_geometry_low_res city_geometry_low_res(id, the_geom) NATURAL LEFT OUTER JOIN city_geometry_high_res city_geometry_high_res(id, the_geom2);

This gives me the following view:
id; name; population; the_geom, the_geom2
-----------------------------------------
1; "Aachen"; 258664; ""; "0101000020E6100000122EE411DC624940BC7669C361691840"
2; "Berlin"; 3490445; "0101000020E61000000000000000004A400000000000002A40"; "0101000020E6100000ABCB290131454A40446D1B4641D02A40"

After having published the view as layer in GeoServer, I get the following error message in the layer preview:
"Internal error occurred java.io.IOException null FEHLER: Operation on two geometries with different SRIDs"

In the log file, this error appears:

2012-01-26 16:49:32,202 DEBUG [org.geotools.jdbc] - SELECT encode(ST_AsBinary(ST_Force_2D("the_geom")),'base64') as "the_geom" FROM "public"."city_view" WHERE "the_geom" && ST_GeomFromText('POLYGON ((51.999796875 12.999797265625, 51.999796875 13.000202734375, 52.000203125 13.000202734375, 52.000203125 12.999797265625, 51.999796875 12.999797265625))', 0)
2012-01-26 16:49:32,203 DEBUG [org.geotools.jdbc] - CLOSE CONNECTION 2012-01-26 16:49:32,203 ERROR [org.geotools.rendering] - java.io.IOException java.lang.RuntimeException: java.io.IOException at org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:212)
...

The query "SELECT DISTINCT srid(the_geom) FROM city_view" results in two rows:
NULL and 4326.

I suspect it could have something to do with this:
"if no SRID can be found in the geometry columns just look into the first geometry"
source: http://jira.codehaus.org/browse/GEOT-2664

Because when I switch rows, everything is fine.

Best wishes,
Nathan

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira