3

I have a Geoserver with a layer in a EPSG:32632 projection. I want to display this layer over Open Street Map tiles.

When I use the following html code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script src="http://www.openlayers.org/api/2.11/OpenLayers.js"></script>
    <script>

        var map, layer;

        function init(){
            var epsg900913 = new OpenLayers.Projection("EPSG:900913");
            var epsg4326 = new OpenLayers.Projection("EPSG:4326");
            var cent=new OpenLayers.LonLat(6.59,46.39).transform(epsg4326,epsg900913);

            var osm = new OpenLayers.Layer.OSM("Open Street Map");

            bwms = new OpenLayers.Layer.WMS("Trajectory", "http://server.domain.com:8080/geoserver/test/wms",
                {
                    version: "1.3.0",
                    layers: "test:v_trajectory",
                    transparent: true,
                    tiled: true
                },
                {
                    visibility: true,
                    sphericalMercator: true,
                    displayOutsideMaxExtent: true // Will not appear with certain zooms without this option
                }
            );
            map = new OpenLayers.Map("map",{
                layers:[osm,bwms],
                center: cent,
                zoom: 10
            });
//          map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
            map.addControl( new OpenLayers.Control.LayerSwitcher() );

        }

    </script>
</head>
<body onload="init()">
    <div style="width:500px; height:500px" id="map"></div>
</body>
</html>

The OSM tiles are correctly displayed but the other layer does not appear on the map. I guess it is a projection problem, since the OSM tiles are in EPSG:900913, but isn't Geoserver supposed to feed me a reprojected map directly? With Firebug, I can see that the request has correctly been treated, but return blank 256x256 tiles. The request is also made for a SRC EPSG:900913, so the problem must be server-side.

What am I missing? The layer is feeded to Geoserver via PostGIS (in the OpenGeo framework). Am I supposed to put some specific settings client-side?

As a consistency check, I also used the Geoserver "preview layer" tool with OpenLayers, to see if the layer is correctly dispayed, and it is. However, if I declare a SRS 900913 in addition to the native 32632, I also get blank tiles in the tool. So I guess the answer is probably related to Geoserver and not OpenLayers. I really don't understand what I'm missing... Any help would be most welcome!

  • 1
    try with WMS version 1.1.0 instead of 1.3.0 - there may be an "interesting" axis order issue with 1.3 – Ian Turton Jun 24 '13 at 12:32
  • Also I don't think you need to set spherical mercator true – Ian Turton Jun 24 '13 at 12:32
  • Tried to change the version (I tried 1.1.0 and 1.1.1), didn't do anything, I still have blank tiles – Bulkilol Jun 24 '13 at 13:18
  • I don't know if it is relevant, but I just noticed that if I use the above code (ie in EPSG:900913), I get geowebcache-cache-result: MISS, while the preview tool has nothing of the sort. – Bulkilol Jun 24 '13 at 15:11
  • does anything show up in the GWC preview/demo page? – Ian Turton Jun 24 '13 at 15:23
2

I finally found the answer to my question:

What I needed to do was to reproject from EPSG:32632 to 4326. This is done by defining a "declared layer" to 4326 and setting the option "reproject native to declare". This is not however the end of the story. You still need to recompute the associated BBox. On the geoserver GUI, this is done by clicking on "compute from data" AND "compute from native bounds".

The problem was that the query from OpenLayers was done with the correct BBOX in the projection 900913, but since the BBox on geoserver were incorrect, it was looking for an area where there were no data, ie return blank tiles.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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