Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a very tricky problem: I have a Postgis 2.0 database, used as datastore for Geoserver 2.1.3

I have a table with a geometry column (named shape), with SRID 4326

I have created a view like this:

CREATE VIEW pippo AS SELECT st_geometryn(shape,1) as geom FROM events

And then I published the view using geoserver. Everything works, except for GetFeatureInfo requests, that fails with the error 'Operation on mixed SRID geometries A simple

select * from geometry_columns

returns that the SRID of pippo.geom is 0 (but should be 4326)

I tried also with this definition for the view

CREATE VIEW pippo AS SELECT st_setsrid(st_geometryn(shape,1), 4326) as geom FROM events

but I still have SRID=0 in the geometry_columns....any help?

Here is how the layer is defined in Geoserver: enter image description here

Workaround

I found a workaround to fix not the problem itself, but to let Geoserver to perform spatial search on GetFeatureInfo requests:

instead of creating a view and publish it, I published an SQL-layer defined directly in geoserver. In the layer-definition form it allowed me to select the right gemoetry type and SRID and everything is working now!

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

You can use a typmod to specify the srid in the geometry_columns view, something like

CREATE VIEW pippo AS
SELECT st_geometryn(shape,1)::geometry(Geometry, 4326) as geom
FROM events

The manual has more info.

share|improve this answer
add comment

When in Layers you can see the CRS (Coordinate Reference System)

enter image description here

You can Force the CRS in Geoserver

http://docs.geoserver.org/2.1.3/user/webadmin/data/layers.html#webadmin-layers

enter image description here

share|improve this answer
    
Geoserver looks in geometry_columns for the native CRS of the layer, which in my case is 0. I edited the answer attaching the layer definition in Geoserver –  Tommaso Sep 7 '12 at 14:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.