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 am using Geoserver to get featureinfo, but sometimes I want to re-project the native SRS in the output gml. The request is a (WMS) "GetFeatureInfo" with INFO_FORMAT: application/vnd.ogc.gml.

I am aware of the option to set the "declared SRS" when publishing a layer in Geoserver, see below:
geoserver settings

But is there a way to re-project the coordinates on-the-fly?

EDIT: Below is two diffrent WMS GetFeatureInfo requests that shows the problem. The first request has Srs=EPSG:4326 and bbox in the same srs and the second request has in Srs=EPSG:900913 and the bbox in in the same srs.

  1. http://demo.opengeo.org/geoserver/wms?REQUEST=GetFeatureInfo&EXCEPTIONS=application/vnd.ogc.se_xml &BBOX=-139.848137,18.549615,51.852863,55.778385&X=351&Y=193 &INFO_FORMAT=application/vnd.ogc.gml&QUERY_LAYERS=topp:states &FEATURE_COUNT=50&Layers=topp:states&Styles=&Srs=EPSG:4326 &WIDTH=780&HEIGHT=330&format=image/png

  2. http://demo.opengeo.org/geoserver/wms?REQUEST=GetFeatureInfo&EXCEPTIONS=application/vnd.ogc.se_xml &BBOX=-15567823.399227962,2101981.4669995294,5772234.305333375,7514424.280422591 &X=352&Y=220&INFO_FORMAT=application/vnd.ogc.gml&QUERY_LAYERS=topp:states &FEATURE_COUNT=50&Layers=topp:states&Styles=&Srs=EPSG:900913 &WIDTH=780&HEIGHT=330&format=image/png

Both requests return the same gml with coordinates in EPSG:4326. I would expect the second request to have coordinates in EPSG:900913. As mentioned I can set the "declared SRS" in Geoserver, but what if I want to get the gml in another srs then the one declared. By on-the-fly I meant: Ask in one srs get the coordinates in the same srs without setting the declared srs. I hope that the question in more clear now.

share|improve this question
add comment

5 Answers

up vote 2 down vote accepted

I am aware of the option to set the "declared SRS" when publishing a layer in Geoserver, [...] But is there a way to re-project the coordinates on-the-fly?

That's exactly how you enable on-the-fly reprojection.

Reprojection that's not "on-the-fly" would mean that you have to upload the layer in the correct/final CRS.

Update:

GetFeatureInfo() was not designed to retrieve the vector geometry of objects. It will only return the original data (geometry and attributes). If you need reprojected vector geometries, you'll have to use a WFS.

share|improve this answer
add comment

You can't do that! In the layer publishing page you have to set the data projection to match the projection your data is in (in this case epsg:4326) - to do on the fly reprojection you just need to change the SRS in your request.

I'm not sure however if demo.openplans.org supports 90913 as the capabilities file only lists 4326 for the States layer.

I'm also not sure that GetFeatureInfo supports reprojection. You might want to try using WFS 1.1 for this task if you really need the GML coordinates which is not really what getFeatureInfo was designed for.

share|improve this answer
add comment

I couldnt get GetFeatureInfo to reproject, so i'm not sure it is possible with that request. But you can do it with WFS and GetFeature request.

On our Geoserver we have one layer that is with following settings alt text

Example:

http://xxx.xxx.hr:8080/geoserver/wfs?REQUEST=GetFeature&MAXFEATURES=50&typename=osm:planet_osm_point&SRSname=EPSG:4326

returns

<gml:pos>13.390277999999968 45.31972200000002</gml:pos>

and

http://xxx.xxx.hr:8080/geoserver/wfs?REQUEST=GetFeature&MAXFEATURES=50&typename=osm:planet_osm_point&SRSname=EPSG:900913

returns

<gml:pos>1490598.92854037 5671996.39529428</gml:pos>

For filtering you can look at this reference. I hope this will help you.

share|improve this answer
add comment

Just dug into this, and I don't believe there is any way in GeoServer to do exactly what you want. Looking at the WMS specification it offers no guidance as to what a WMS should do when GML is requested in an alternate SRS, though I agree that the proper behavior probably should be to reproject it. Putting that requirement in though would have made that spec a lot more difficult to implement. I'm pretty sure being able to get GML from a WMS was a bit of an afterthought for the spec authors.

What OGC did to handle real GML requests was make the Web Feature Service specification. And they didn't even get to handling reprojection well until version 1.1 of the spec. So a less than ideal answer to your question is to use WFS, as it will certainly handle what you want. The downside is you have to manually transform your x,y screen coordinates to the proper bounding box, though most existing client software can do that.

You can go ahead and report the issue, as I think most geoserver devs would agree that even though the spec doesn't say anything about it what you want should be the right behavior. And should be relatively easy to implement, as all the mechanisms for reprojection are there. But it may not get fixed, since most everyone who wants GML uses WFS, as it's superior in every way except for not having the shortcut of x,y screen coordinates.

share|improve this answer
add comment

Unless I'm misunderstanding your question, reprojecting on the fly should be a simple matter of just specifying your desired output SRS in your WMS request string.

share|improve this answer
    
I have updated the question –  taudorf Aug 9 '10 at 14:50
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.