Ticket #2631 (closed bug: invalid)

Opened 5 years ago

Last modified 5 years ago

WMS layer always sends "EPSG:900913" if Google is the baselayer and "sphericalMercator" is set to "true"

Reported by: august Owned by: euzuro
Priority: minor Milestone: 2.10 Release
Component: Layer.WMS Version: 2.9
Keywords: SRS, CRS Cc: anakintang@…
State:

Description

When you use Google as baselayer and set "sphericalMercator" to "true", the map's projection somehow sticks to EPSG:900913. So if you now have a WMS overlay, the GetMap request will always be sent with "SRS=EPSG:900913". In this case it's not possible to overlay a WMS which doesn't use "EPSG:900913" for sphericaMercator projection

Change History

Changed 5 years ago by elemoine

  • status changed from new to closed
  • resolution set to invalid

The map projection is the default projection of WMS layers. If you want a specific projection for a WMS layer set the "srs" in the WMS layer parameters.

Changed 5 years ago by august

Right, WMS layer srs should overwrite map's srs. But here is the code that reproduces the problem:

function initEpsg102113() {

var lon = -122.6335; var lat = 45.4447;

var center_mercator = OpenLayers.Layer.SphericalMercator.forwardMercator(lon, lat); center_mercator_x = center_mercator.lon; center_mercator_y = center_mercator.lat;

var zoom = 3;

// clear array to simulate a wrong axis order request

var options = {

projection: "EPSG:102113", units: "m",

maxResolution: 156543.0339,

maxExtent: new OpenLayers.Bounds(-20037508.3392, -20037508.3392, 20037508.3392, 20037508.3392),

};

map = new OpenLayers.Map('map', options); var gmap = new OpenLayers.Layer.Google(

"Google Streets", // the default {

numZoomLevels: 20, sphericalMercator: true, isBaseLayer: true,

}

); var layer = new OpenLayers.Layer.WMS(

"GeoWebcache WMS service", " http://sazabi:8080/geowebcache-1.2.2/service/wms?", {

layers: 'arcgis-online-wms', version: '1.1.1', srs: 'epsg:102113', transparent: true

}, {

singleTile: false, isBaseLayer: false

}

); map.addLayers([gmap,layer]); map.setCenter(new OpenLayers.LonLat(center_mercator_x, center_mercator_y), zoom);

}

I even set map's projection to something other than "EPSG:900913", but I still it 900913 being sent out to WMS. Is there anything I did wrong in the code?

Thanks

Changed 5 years ago by ahocevar

  • state Needs Discussion deleted

Your Google layer is the base layer. The WMS layer is an overlay. Base layers determine the projection of the map. WMS layers cannot be reprojected in OpenLayers. So what you see is expected behavior. Remove {{{isBaseLayer: false}} on the WMS layer, and it will become a base layer (and not overlay on the Google layer any more), but be requested in your desired projection.

Changed 5 years ago by crschmidt

I think that august is trying to use a code other than 900913, but has the same meaning. This is not possible with our current setup.

august, if you want to do this, you can change the projection of the layer after you create it, but before you add it to the map:

  var l = new OpenLayers.Layer.Google("g", {sphericalMercator: true});
  l.projection = "EPSG:100135";
  map.addLayer(l);

The current design is intended (but possibly not ideal). A ticket to change this might be something like "It should be possible to override the SRS string for an overly WMS layer, to support WMS services which use non-standard/different EPSG codes which have the same meaning as the base layer."

Changed 5 years ago by august

Hi crschmidt,

That is exactly what I meant, and thanks for clarifying it. The use case is like ArcGIS Server WMS is not recognizing EPSG:900913, but instead, it may use EPSG:102113, EPSG:3785 in which the result map can be overlay on Google base layer.

Thanks a lot!

Note: See TracTickets for help on using tickets.