1

Setup:

  • ArcSDE 9.3.2
  • Oracle 11g
  • GeoServer 2.1.4
  • OpenLayers (latest build)
  • OpenStreetMap
  • InternetExplorer 7.0/ Google Chrome

EDIT: I have updated information just below the screen shots

Problem:

I am trying to take some feature classes from our arcsde and overlay them with OSM, originally i was trying to keep them in their native projection of BC_Albers (EPSG:42102) but i couldn't get them to overlay properly. So i consigned my self to having to do a reprojection of my data from 42102 to 4326.

I did the reprojection this morning and then modified my openlayers test page to view the data. I can view my featureset by itself just fine, I can view the OSM layer by itself just fine but when I try and combine the two all I get is OSM.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="/openlayers/OpenLayers.js"></script>
<script type="text/javascript" src="/scripts/jquery.js"></script>
<script type="text/javascript">
    $(document).ready(function ()
    {

        var bounds = new OpenLayers.Bounds(
                -127.998497751, 49.138495421,
                -114.19842900799999, 60.000008341
            );
        var options = {
            maxExtents:bounds,
            projection: "EPSG:4326",
            units: 'degrees'
        };
        var map = new OpenLayers.Map('map', options);


        var copi = new OpenLayers.Layer.WMS(
        "Div 51 COPI", "http://wldev1.canfor.ca:8080/geoserver/WIM/wms",
        {
            layers: 'WIM:FOREST_WIM.WEB_COPI_TRAPPER',
            format: 'image/gif',
            transparent: 'true'
        }
        );
        map.addLayer(new OpenLayers.Layer.OSM());
        map.addLayer(copi);
        map.addControl(new OpenLayers.Control.LayerSwitcher({ 'ascending': false }));
        map.addControl(new OpenLayers.Control.Navigation());
        map.zoomToMaxExtent();//bounds, true);

    });
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="map" style="clear:both;width:800px;height:400px;border:2px solid green;"></div>
</div>
        <div id="wrapper">
        <div id="location">location</div>
        <div id="scale">
        </div>
    </div>
</form>
</body>
</html>

Layers In ArcMap Overlay Layer without OSM Overlay Layer with OSM

it appears it may have something to do with the way that openlayers is changing the EPSG:

without OSM on map: http://wldev1.canfor.ca:8080/geoserver/WIM/wms?LAYERS=WIM%3AFOREST_WIM.WEB_COPI_TRAPPER&FORMAT=image%2Fgif&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=-180,-90,0,90&WIDTH=256&HEIGHT=256

WITH OSM on map: http://wldev1.canfor.ca:8080/geoserver/WIM/wms?LAYERS=WIM%3AFOREST_WIM.WEB_COPI_TRAPPER&FORMAT=image%2Fgif&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A900913&BBOX=-180,-90,10018574.17,10018664.17&WIDTH=256&HEIGHT=256

0

2 Answers 2

2

As @drnextgis states the displayProjection property of the map is only really about the system in which coordinate values are displayed to users (behind the scenes I think OpenLayers is doing a transform).

When you add an OSM layer to the map it becomes the base layer, it is the base layer that then informs the projection of the map. So, since OpenStreetMap is EPSG:900913 all WMS layer requests will default to that value if one is not set on the layer itself. If one is set then the data is requested using that one instead, in your case EPSG:4326. Since your source data is being served by GeoServer it is capable of doing the transformation itself so you don't need to worry about it on the client.

Remove the projection: "EPSG:4326" property from your map options object and let OpenLayers handle it based on the base OSM layer.

1
  • Correct and thanks for settin gme back on the straight path i admit to tunnel vision on this one and as i said below i hadn't realized i'd actually changed my base projection to get everything working. Was just one of those cases where not realizing what i'm seeing or what i actually did. Commented Aug 7, 2012 at 20:28
0

So i found an answer while browsing around and looking at how people had included other layers in their solutions from different sources and found the displayProjection option. Which i made use of as demonstrated below. This also had the side benefit of increasing my server's response time.

        var options = {
            projection: new OpenLayers.Projection("EPSG:900913"),
            displayProjection: new OpenLayers.Projection("EPSG:4326"),
            units: 'degrees'
        };
        var map = new OpenLayers.Map('map', options);
2
  • 1
    displayProjection is used by several controls only to display data to user, not for definition the projection of the layer.
    – drnextgis
    Commented Aug 3, 2012 at 3:17
  • :) what happened is i hadn't realized i switched the projections around when i wrote the answer. In my mind i was still seeing the 4326 as the base projection not realizing i had actually moved it around. Commented Aug 7, 2012 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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