[GIS] Bounding Box Coordinates are given in different Projection – how to find out which

geoserveropenlayers-2

All the layers in my application are EPSG:31466. However, if I retrieve the capabilites:

        var wms = new OpenLayers.Format.WMSCapabilities();

        OpenLayers.Request.GET({
            url: myUrl,
            success: function(e){

                var response = wms.read(e.responseText);
                var layerObj = response.capability.layers[0];  
                console.log(layerObj.llbbox);

            }
        }

The BoundingBox' Coordinates are given in a totally different format.

In EPSG:31466 I would expect them to be similar to new OpenLayers.Bounds(363060,5770362,363496,5771118), but in fact they are like this: [-23.015284514192917, 48.276782941782315, -22.953739137948624, 48.29765968309495].

Looks like a different format, but why and how do I change this?


    console.log(layerObj.llbbox);
    var my_extent=new OpenLayers.Bounds(layerObj.llbbox).transform(new OpenLayers.Projection("EPSG:4326"),map.displayProjection);
    console.log(my_extent);

Console Output:

 [-23.015284514192917, 48.276782941782315, -22.953739137948624, 48.29765968309495]

Object { left=-23.015284514193, bottom=48.276782941782, right=-22.953739137949, more...}

Best Answer

It's EPSG 4326. llbox means latlon-boundingbox. Every layer has to be published in 4326 but can often be requested in different crs's, so you get the llbbox always in 4326. just reproject them with

.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:31466"));

for example

var my_extent=new OpenLayers.Bounds(-23.015284514192917, 48.276782941782315, -22.953739137948624, 48.29765968309495).transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:31466"));

If transforming fails one reason can also be that you have not included proj4.js for this projection.

    var neu=new OpenLayers.Bounds.fromArray([35.76180874190184, 7.0599674899119, 
36.38799280563133, 7.559116178088183]);

    console.log(neu.transform(new OpenLayers.Projection("EPSG:4326"),
new OpenLayers.Projection("EPSG:31466")));

Reprojecting should work if proj4.js is included. see console.log in this example: enter image description here

http://dev.openlayers.org/examples/using-proj4js.html

You can get the BBOX of your Layer also with

console.log(layerObj.bbox["EPSG:31466"]);

instead of

console.log(layerObj.llbbox);