[OpenLayers-Users] SphericalMercator and SRS aliases epsg:900913, epsg:3857, epsg:3785, epsg:102113

Anne Blankert anne.blankert at geodan.nl
Sat Jul 24 20:02:42 EDT 2010


I agree with Phil, their should be built-in support for spherical mercator
aliases after all. The (now) documented work-around does not work if you
need to overlay multiple layers from providers that each support a different
alias.

The idea that Phil published seems to be the best solution I've seen so far.
As long as this type of solution is not part of OpenLayers, this kind of
override can do the trick. The code that Phil provided depends on Ext and
the word 'arcgis' in the Url. I modified it slightly to remove the
dependencies and support a new layer option 'sphericalmercatoralias'. 

// override OpenLayers.WMS.getFullRequestString class member function
OpenLayers.Layer.WMS.prototype.getFullRequestString = function(newParams,
altUrl) { 
	var projectionCode = this.map.getProjection(); 
	if (this.options.sphericalmercatoralias)
	{
		if(projectionCode == 'EPSG:900913' || projectionCode == 'EPSG:102113' ||
projectionCode == 'EPSG:3857') { 
			this.params.SRS = this.options.sphericalmercatoralias; 
		} else { 
			this.params.SRS = (projectionCode == "none") ? null : projectionCode; 
		} 
	}
	return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply( this,
arguments); 
}

After this override, you can set a new layeroption 'sphericalmercatoralias'
to tell OpenLayers to use that instead of the default as follows:

layer = new OpenLayers.Layer.WMS(title, url, {layers},
{sphericalmercatoralias: "EPSG:102113"});



Phil Scadden wrote:
> 
> .
>> What do other people think about providing the EPSG aliases by default in
>> the OL library?
>>    
> good idea. AGS uses 102113 and I use an override to manage this 
> projection issue. eg
> 
>              Ext.override(OpenLayers.Layer.WMS, {
>                  getFullRequestString:function(newParams, altUrl) {
>                      var projectionCode = this.map.getProjection();
>                      if (this.url == null) isAGS ==0;
>                      else var isAGS = this.url.search(/arcgis/);
>                      if((projectionCode == 'EPSG:900913') && (isAGS >=0))
> {
>                          this.params.SRS = 'EPSG:102113';
>                      } else {
>                          this.params.SRS = (projectionCode == "none") ? 
> null : projectionCode;
>                      }
> 
>                      return 
> OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(
>                                                                  this, 
> arguments);
>                  }
>              });
> 
> 

-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/SphericalMercator-and-SRS-aliases-epsg-900913-epsg-3857-epsg-3785-epsg-102113-tp5311417p5334027.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list