New OpenLayers.Projection.defaults property #219

Merged
merged 9 commits into from Feb 16, 2012

5 participants

@ahocevar
OpenLayers member

This allows us to simplify the map and layer configuration, because now the projection also defines defaults for maxExtent, maxResolution and units.

This change also adds transforms for SRS aliases for EPSG:4326 and centralizes axis order information in OpenLayers.Projection.defaults.

ahocevar and others added some commits Feb 15, 2012
@ahocevar ahocevar New OpenLayers.Projection.defaults property.
This allows us to simplify the map and layer configuration, because now the projection also defines defaults for maxExtent, maxResolution and units.
This change also adds transforms for SRS aliases for EPSG:4326 and centralizes axis order information in OpenLayers.Projection.defaults.
11966d2
@fredj fredj If sphericalMercator, use default values from Projection.defaults a40ae7e
@fredj fredj Simplify parent call (don't use intermediate array) cd3ffa2
@fredj fredj Don't compute limit if it's not needed 147b32b
@ahocevar ahocevar Merge pull request #3 from fredj/proj-defaults
Proj defaults
1b57783
@ahocevar ahocevar Use the layer's projection.
In setMap, the layer gets the map's projection if it doesn't have its own. And since a layer can have a different SRS code than the map (but a compatible one, i.e. with OpenLayers.Projection.transforms[mapProj][layerProj] being OpenLayer.Projection.nullTransform), the axis order can be different.
2e423df
@tschaub
OpenLayers member

Thanks for working on this. The maxExtent and units properties make good sense. It's a little funny to force someone to describe the maxResolution of a projection. The convention we're using for defaults is to have a max resolution that is related to the maxExtent and tileSize. In my opinion, it would make more sense to calculate the maxResolution default rather than push another coupled value into the projection defaults.

@ahocevar
OpenLayers member

@tschaub Sounds good - so you mean a calculation based on the assumption that the validity extent's height matches the tile height at zoom level 0?

@ahocevar
OpenLayers member

I had tried this in addOptions, but there are too many ways to calculate resolutions when maxResolution is not set, so many tests failed with that. This is why the code ended up where it is now.

@fredj
OpenLayers member

Looks very good to me, please merge.
Thanks for working on this @ahocevar

(more example may be simplified but this can be done later)

@ahocevar ahocevar merged commit 2fe882f into openlayers:master Feb 16, 2012
@tonio tonio commented on the diff Feb 16, 2012
lib/OpenLayers/Layer/XYZ.js
- options = OpenLayers.Util.extend({
- maxExtent: new OpenLayers.Bounds(
- -128 * 156543.03390625,
- -128 * 156543.03390625,
- 128 * 156543.03390625,
- 128 * 156543.03390625
- ),
- maxResolution: 156543.03390625,
- numZoomLevels: 19,
- units: "m",
- projection: "EPSG:900913"
- }, options);
+ options = options || {};
+ if (options.sphericalMercator || this.sphericalMercator) {
+ options.projection = new OpenLayers.Projection('EPSG:900913');
+ options.numZoomLevels = 19;
@tonio
OpenLayers member
tonio added a line comment Feb 16, 2012

Previously, numZoomLevels were preserved.
It just break one of my app where I have a bigger number of zoom levels. I think it should be set only if it’s not already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fredj
OpenLayers member

@tonio please try 5d79b68

@tonio
OpenLayers member

@fredj Works for me, and looks good!

Thanks, please merge.

@elemoine
OpenLayers member

@ahocevar This commit should have changed the TMS.html test file. This file still has

OpenLayers.Projection.defaults["EPSG:4326"].maxResolution

when setting maxResolution.

This makes me wonder how come this test passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment