Ticket #2914 (closed feature: fixed)

Opened 3 years ago

Last modified 3 years ago

Respect layer projection if it equals the map projection

Reported by: ahocevar Owned by: ahocevar
Priority: minor Milestone: 2.11 Release
Component: Layer.WMS Version: 2.10
Keywords: Cc:
State: Complete

Description

With several projection codes available for the same projection, but WMS servers that do not support all of these, it makes sense to respect the layer projection for WMS GetMap requests when they equal the map projection.

Let's say our map is in EPSG:3857, the official web mercator EPSG code, but it uses a layer that only supports the equal EPSG:900913 projection, we should be able to do:

var map = new OpenLayers.Map("map", {
    projection: "EPSG:3857"
    /* ... */
});
var layer = new OpenLayers.Layer.WMS("mywms", "/path/to/wms",
    {layers: "world"},
    {projection: "EPSG:900913"}
);

Attachments

openlayers-2914.patch Download (2.9 KB) - added by ahocevar 3 years ago.
proof of concept - no tests yet
openlayers-2914.2.patch Download (7.3 KB) - added by ahocevar 3 years ago.
with tests; also works for unknown projections now
2914.patch Download (7.5 KB) - added by tschaub 3 years ago.
respect layer projection if it equals map projection

Change History

Changed 3 years ago by ahocevar

proof of concept - no tests yet

Changed 3 years ago by ahocevar

  • state set to Review

Tests pass in Safari 5. Thanks for any review.

Changed 3 years ago by ahocevar

with tests; also works for unknown projections now

Changed 3 years ago by tschaub

  • owner changed from euzuro to tschaub
  • status changed from new to assigned

Thanks for taking this on. I think this looks like a great solution. I had previously thought about supporting projection aliases (as a property on a projection object), but I think handling it with a null transform is a good solution.

Changed 3 years ago by tschaub

respect layer projection if it equals map projection

Changed 3 years ago by tschaub

  • owner changed from tschaub to ahocevar
  • status changed from assigned to new
  • state changed from Review to Commit

Two minor changes in my patch:

  • I changed the ; to a , in Projection.js to avoid setting the global equals.
  • I made it so window.Proj4js is deleted if it didn't exist before in the Projection.js test so other tests running after it aren't fooled.

I think this looks like a very solid solution to handling projections with different aliases. Thanks for the great patch.

Changed 3 years ago by ahocevar

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed
Note: See TracTickets for help on using tickets.