Merge pull request #219 from ahocevar/proj-defaults

New OpenLayers.Projection.defaults property. r=@tschaub,@fredj
This commit is contained in:
ahocevar
2012-02-16 01:29:29 -08:00
27 changed files with 151 additions and 167 deletions
+1 -6
View File
@@ -5,12 +5,7 @@ function init() {
map = new OpenLayers.Map({ map = new OpenLayers.Map({
div: "map", div: "map",
projection: new OpenLayers.Projection("EPSG:900913"), projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"), displayProjection: new OpenLayers.Projection("EPSG:4326")
units: "m",
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(
-20037508, -20037508, 20037508, 20037508
)
}); });
var g = new OpenLayers.Layer.Google("Google Layer", { var g = new OpenLayers.Layer.Google("Google Layer", {
-4
View File
@@ -5,10 +5,6 @@ function init() {
map = new OpenLayers.Map({ map = new OpenLayers.Map({
div: "map", div: "map",
projection: "EPSG:900913", projection: "EPSG:900913",
units: "m",
maxExtent: new OpenLayers.Bounds(
-20037508.34, -20037508.34, 20037508.34, 20037508.34
),
controls: [], controls: [],
fractionalZoom: true fractionalZoom: true
}); });
-5
View File
@@ -41,12 +41,7 @@ var init = function (onSelectFeatureFunction) {
div: "map", div: "map",
theme: null, theme: null,
projection: sm, projection: sm,
units: "m",
numZoomLevels: 18, numZoomLevels: 18,
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(
-20037508.34, -20037508.34, 20037508.34, 20037508.34
),
controls: [ controls: [
new OpenLayers.Control.Attribution(), new OpenLayers.Control.Attribution(),
new OpenLayers.Control.TouchNavigation({ new OpenLayers.Control.TouchNavigation({
-5
View File
@@ -41,12 +41,7 @@ function init() {
map = new OpenLayers.Map({ map = new OpenLayers.Map({
div: 'map', div: 'map',
projection: 'EPSG:900913', projection: 'EPSG:900913',
units: 'm',
numZoomLevels: 18, numZoomLevels: 18,
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(
-20037508.34, -20037508.34, 20037508.34, 20037508.34
),
controls: [ controls: [
new OpenLayers.Control.TouchNavigation({ new OpenLayers.Control.TouchNavigation({
dragPanOptions: { dragPanOptions: {
-5
View File
@@ -5,12 +5,7 @@ function init() {
div: "map", div: "map",
theme: null, theme: null,
projection: new OpenLayers.Projection("EPSG:900913"), projection: new OpenLayers.Projection("EPSG:900913"),
units: "m",
numZoomLevels: 18, numZoomLevels: 18,
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(
-20037508.34, -20037508.34, 20037508.34, 20037508.34
),
controls: [ controls: [
new OpenLayers.Control.TouchNavigation({ new OpenLayers.Control.TouchNavigation({
dragPanOptions: { dragPanOptions: {
+1 -6
View File
@@ -3,12 +3,7 @@ var map;
function init() { function init() {
map = new OpenLayers.Map({ map = new OpenLayers.Map({
div: "map", div: "map",
projection: new OpenLayers.Projection("EPSG:900913"), projection: new OpenLayers.Projection("EPSG:900913")
units: "m",
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(
-20037508, -20037508, 20037508, 20037508.34
)
}); });
var osm = new OpenLayers.Layer.OSM(); var osm = new OpenLayers.Layer.OSM();
+1 -2
View File
@@ -91,8 +91,7 @@
maxExtent: new OpenLayers.Bounds(-8242894.927728, 4965204.031195, maxExtent: new OpenLayers.Bounds(-8242894.927728, 4965204.031195,
-8227290.161511, 4994963.723637), -8227290.161511, 4994963.723637),
maxResolution: 116.24879860156216, maxResolution: 116.24879860156216,
projection: "EPSG:900913", projection: "EPSG:900913"
units: "m"
}; };
var map2 = new OpenLayers.Map('map2', mapOptions); var map2 = new OpenLayers.Map('map2', mapOptions);
+5 -5
View File
@@ -12,7 +12,10 @@
<link rel="stylesheet" href="style.css" type="text/css"> <link rel="stylesheet" href="style.css" type="text/css">
<style type="text/css"> <style type="text/css">
.olControlAttribution { .olControlAttribution {
bottom: 0px bottom: 0px;
left: 2px;
right: inherit;
width: 400px;
} }
#map { #map {
height: 512px; height: 512px;
@@ -42,10 +45,7 @@
div: "map", div: "map",
projection: "EPSG:900913", projection: "EPSG:900913",
displayProjection: "EPSG:4326", displayProjection: "EPSG:4326",
units: "m", numZoomLevels: 18
numZoomLevels: 18,
maxResolution: 156543.0339,
maxExtent: [-20037508, -20037508, 20037508, 20037508],
}); });
// create Google Mercator layers // create Google Mercator layers
+1 -5
View File
@@ -31,11 +31,7 @@
function init(){ function init(){
var options = { var options = {
projection: new OpenLayers.Projection("EPSG:900913"), projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"), displayProjection: new OpenLayers.Projection("EPSG:4326")
units: "m",
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
20037508.34, 20037508.34)
}; };
map = new OpenLayers.Map('map', options); map = new OpenLayers.Map('map', options);
var mapnik = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)"); var mapnik = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)");
-3
View File
@@ -38,9 +38,6 @@ function init() {
map = new OpenLayers.Map('map', { map = new OpenLayers.Map('map', {
projection: new OpenLayers.Projection("EPSG:900913"), projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"), displayProjection: new OpenLayers.Projection("EPSG:4326"),
units: "m",
maxResolution: 20037508.34 / 128,
maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508),
restrictedExtent: extent, restrictedExtent: extent,
controls: [ controls: [
new OpenLayers.Control.PanZoom(), new OpenLayers.Control.PanZoom(),
+1 -6
View File
@@ -7,12 +7,7 @@ function init() {
var mercator = new OpenLayers.Projection("EPSG:900913"); var mercator = new OpenLayers.Projection("EPSG:900913");
map = new OpenLayers.Map('map', { map = new OpenLayers.Map('map', {
projection: mercator, projection: mercator
units: "m",
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(
-20037508, -20037508, 20037508, 20037508
)
}); });
var g = new OpenLayers.Layer.Google("Google Layer", { var g = new OpenLayers.Layer.Google("Google Layer", {
+1 -6
View File
@@ -47,12 +47,7 @@ function init() {
map = new OpenLayers.Map({ map = new OpenLayers.Map({
div: "map", div: "map",
projection: "EPSG:900913", projection: "EPSG:900913"
units: "m",
maxExtent: new OpenLayers.Bounds(
-20037508.34, -20037508.34, 20037508.34, 20037508.34
),
maxResolution: 156543.0339
}); });
var osm = new OpenLayers.Layer.OSM(); var osm = new OpenLayers.Layer.OSM();
+1 -6
View File
@@ -5,12 +5,7 @@ function init() {
map = new OpenLayers.Map({ map = new OpenLayers.Map({
div: "map", div: "map",
projection: "EPSG:900913", projection: "EPSG:900913"
units: "m",
maxExtent: new OpenLayers.Bounds(
-20037508.34, -20037508.34, 20037508.34, 20037508.34
),
maxResolution: 156543.0339
}); });
var osm = new OpenLayers.Layer.OSM(); var osm = new OpenLayers.Layer.OSM();
+1 -6
View File
@@ -4,12 +4,7 @@ function init() {
map = new OpenLayers.Map({ map = new OpenLayers.Map({
div: "map", div: "map",
projection: "EPSG:900913", projection: "EPSG:900913"
units: "m",
maxExtent: new OpenLayers.Bounds(
-20037508.34, -20037508.34, 20037508.34, 20037508.34
),
maxResolution: 156543.0339
}); });
var osm = new OpenLayers.Layer.OSM(); var osm = new OpenLayers.Layer.OSM();
+23 -8
View File
@@ -255,8 +255,8 @@ OpenLayers.Layer = OpenLayers.Class({
* APIProperty: maxResolution * APIProperty: maxResolution
* {Float} Default max is 360 deg / 256 px, which corresponds to * {Float} Default max is 360 deg / 256 px, which corresponds to
* zoom level 0 on gmaps. Specify a different value in the layer * zoom level 0 on gmaps. Specify a different value in the layer
* options if you are not using a geographic projection and * options if you are not using the default <OpenLayers.Map.tileSize>
* displaying the whole world. * and displaying the whole world.
*/ */
maxResolution: null, maxResolution: null,
@@ -473,8 +473,18 @@ OpenLayers.Layer = OpenLayers.Class({
this.options = {}; this.options = {};
} }
// allow array for extents
if (newOptions) { if (newOptions) {
// make sure this.projection references a projection object
if(typeof newOptions.projection == "string") {
newOptions.projection = new OpenLayers.Projection(newOptions.projection);
}
if (newOptions.projection) {
// get maxResolution, units and maxExtent from projection defaults if
// they are not defined already
OpenLayers.Util.applyDefaults(newOptions,
OpenLayers.Projection.defaults[newOptions.projection.getCode()]);
}
// allow array for extents
if (newOptions.maxExtent && !(newOptions.maxExtent instanceof OpenLayers.Bounds)) { if (newOptions.maxExtent && !(newOptions.maxExtent instanceof OpenLayers.Bounds)) {
newOptions.maxExtent = new OpenLayers.Bounds(newOptions.maxExtent); newOptions.maxExtent = new OpenLayers.Bounds(newOptions.maxExtent);
} }
@@ -489,11 +499,6 @@ OpenLayers.Layer = OpenLayers.Class({
// add new options to this // add new options to this
OpenLayers.Util.extend(this, newOptions); OpenLayers.Util.extend(this, newOptions);
// make sure this.projection references a projection object
if(typeof this.projection == "string") {
this.projection = new OpenLayers.Projection(this.projection);
}
// get the units from the projection, if we have a projection // get the units from the projection, if we have a projection
// and it it has units // and it it has units
if(this.projection && this.projection.getUnits()) { if(this.projection && this.projection.getUnits()) {
@@ -885,6 +890,16 @@ OpenLayers.Layer = OpenLayers.Class({
props.resolutions = this.resolutionsFromScales(props.scales); props.resolutions = this.resolutionsFromScales(props.scales);
} }
if(props.resolutions == null) { if(props.resolutions == null) {
var maxExtent = this.maxExtent;
if (!props.maxResolution && maxExtent) {
// maxResolution for default grid sets assumes that at zoom
// level zero, the whole world fits on one tile.
var tileSize = this.tileSize || this.map.getTileSize();
props.maxResolution = Math.max(
maxExtent.getWidth() / tileSize.w,
maxExtent.getHeight() / tileSize.h
);
}
props.resolutions = this.calculateResolutions(props); props.resolutions = this.calculateResolutions(props);
} }
} }
-16
View File
@@ -30,29 +30,13 @@ OpenLayers.Layer.Google.v3 = {
* *
* (code) * (code)
* { * {
* maxExtent: new OpenLayers.Bounds(
* -128 * 156543.03390625,
* -128 * 156543.03390625,
* 128 * 156543.03390625,
* 128 * 156543.03390625
* ),
* sphericalMercator: true, * sphericalMercator: true,
* maxResolution: 156543.03390625,
* units: "m",
* projection: "EPSG:900913" * projection: "EPSG:900913"
* } * }
* (end) * (end)
*/ */
DEFAULTS: { DEFAULTS: {
maxExtent: new OpenLayers.Bounds(
-128 * 156543.03390625,
-128 * 156543.03390625,
128 * 156543.03390625,
128 * 156543.03390625
),
sphericalMercator: true, sphericalMercator: true,
maxResolution: 156543.03390625,
units: "m",
projection: "EPSG:900913" projection: "EPSG:900913"
}, },
+7 -4
View File
@@ -56,9 +56,11 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
* Property: yx * Property: yx
* {Object} Keys in this object are EPSG codes for which the axis order * {Object} Keys in this object are EPSG codes for which the axis order
* is to be reversed (yx instead of xy, LatLon instead of LonLat), with * is to be reversed (yx instead of xy, LatLon instead of LonLat), with
* true as value. This is only relevant for WMS versions >= 1.3.0. * true as value. This is only relevant for WMS versions >= 1.3.0, and
* only if yx is not set in <OpenLayers.Projection.defaults> for the
* used projection.
*/ */
yx: {'EPSG:4326': true}, yx: {},
/** /**
* Constructor: OpenLayers.Layer.WMS * Constructor: OpenLayers.Layer.WMS
@@ -173,8 +175,9 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
* {Boolean} true if the axis order is reversed, false otherwise. * {Boolean} true if the axis order is reversed, false otherwise.
*/ */
reverseAxisOrder: function() { reverseAxisOrder: function() {
return (parseFloat(this.params.VERSION) >= 1.3 && var projCode = this.projection.getCode();
!!this.yx[this.map.getProjectionObject().getCode()]); return parseFloat(this.params.VERSION) >= 1.3 &&
!!(this.yx[projCode] || OpenLayers.Projection.defaults[projCode].yx);
}, },
/** /**
+10 -21
View File
@@ -70,24 +70,14 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, {
* options - {Object} Hashtable of extra options to tag onto the layer * options - {Object} Hashtable of extra options to tag onto the layer
*/ */
initialize: function(name, url, options) { initialize: function(name, url, options) {
if (options && options.sphericalMercator || this.sphericalMercator) { options = options || {};
options = OpenLayers.Util.extend({ if (options.sphericalMercator || this.sphericalMercator) {
maxExtent: new OpenLayers.Bounds( options.projection = new OpenLayers.Projection('EPSG:900913');
-128 * 156543.03390625, options.numZoomLevels = 19;
-128 * 156543.03390625,
128 * 156543.03390625,
128 * 156543.03390625
),
maxResolution: 156543.03390625,
numZoomLevels: 19,
units: "m",
projection: "EPSG:900913"
}, options);
} }
url = url || this.url; OpenLayers.Layer.Grid.prototype.initialize.apply(this, [
name = name || this.name; name || this.name, url || this.url, {}, options
var newArguments = [name, url, {}, options]; ]);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
}, },
/** /**
@@ -157,10 +147,9 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, {
OpenLayers.Util.indexOf(resolutions, res) : OpenLayers.Util.indexOf(resolutions, res) :
this.getServerZoom() + this.zoomOffset; this.getServerZoom() + this.zoomOffset;
var limit = Math.pow(2, z); if (this.wrapDateLine) {
if (this.wrapDateLine) var limit = Math.pow(2, z);
{ x = ((x % limit) + limit) % limit;
x = ((x % limit) + limit) % limit;
} }
return {'x': x, 'y': y, 'z': z}; return {'x': x, 'y': y, 'z': z};
+17 -13
View File
@@ -8,6 +8,7 @@
* @requires OpenLayers/Util.js * @requires OpenLayers/Util.js
* @requires OpenLayers/Events.js * @requires OpenLayers/Events.js
* @requires OpenLayers/Tween.js * @requires OpenLayers/Tween.js
* @requires OpenLayers/Projection.js
*/ */
/** /**
@@ -248,17 +249,19 @@ OpenLayers.Map = OpenLayers.Class({
/** /**
* APIProperty: projection * APIProperty: projection
* {String} Set in the map options to override the default projection * {String} Set in the map options to override the default projection
* string this map - also set maxExtent, maxResolution, and * string this map. When using a projection other than EPSG:4326
* units if appropriate. Default is "EPSG:4326". * (CRS:84, Geographic) or EPSG:3857 (EPSG:900913, Web Mercator),
* also set maxExtent and maxResolution. Default is "EPSG:4326".
*/ */
projection: "EPSG:4326", projection: "EPSG:4326",
/** /**
* APIProperty: units * APIProperty: units
* {String} The map units. Defaults to 'degrees'. Possible values are * {String} The map units. Possible values are 'degrees' (or 'dd'), 'm',
* 'degrees' (or 'dd'), 'm', 'ft', 'km', 'mi', 'inches'. * 'ft', 'km', 'mi', 'inches'. Only required if the projection default
* should be overridden.
*/ */
units: 'degrees', units: null,
/** /**
* APIProperty: resolutions * APIProperty: resolutions
@@ -271,12 +274,10 @@ OpenLayers.Map = OpenLayers.Class({
/** /**
* APIProperty: maxResolution * APIProperty: maxResolution
* {Float} Default max is 360 deg / 256 px, which corresponds to * {Float} Required if you are not displaying the whole world on a tile
* zoom level 0 on gmaps. Specify a different value in the map * with the size specified in <tileSize>.
* options if you are not using a geographic projection and
* displaying the whole world.
*/ */
maxResolution: 1.40625, maxResolution: null,
/** /**
* APIProperty: minResolution * APIProperty: minResolution
@@ -342,7 +343,8 @@ OpenLayers.Map = OpenLayers.Class({
/** /**
* APIProperty: displayProjection * APIProperty: displayProjection
* {<OpenLayers.Projection>} Requires proj4js support.Projection used by * {<OpenLayers.Projection>} Requires proj4js support for projections other
* than EPSG:4326 or EPSG:900913/EPSG:3857. Projection used by
* several controls to display data to user. If this property is set, * several controls to display data to user. If this property is set,
* it will be set on any control which has a null displayProjection * it will be set on any control which has a null displayProjection
* property at the time the control is added to the map. * property at the time the control is added to the map.
@@ -471,8 +473,6 @@ OpenLayers.Map = OpenLayers.Class({
this.tileSize = new OpenLayers.Size(OpenLayers.Map.TILE_WIDTH, this.tileSize = new OpenLayers.Size(OpenLayers.Map.TILE_WIDTH,
OpenLayers.Map.TILE_HEIGHT); OpenLayers.Map.TILE_HEIGHT);
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
this.paddingForPopups = new OpenLayers.Bounds(15, 15, 15, 15); this.paddingForPopups = new OpenLayers.Bounds(15, 15, 15, 15);
this.theme = OpenLayers._getScriptLocation() + this.theme = OpenLayers._getScriptLocation() +
@@ -481,6 +481,10 @@ OpenLayers.Map = OpenLayers.Class({
// now override default options // now override default options
OpenLayers.Util.extend(this, options); OpenLayers.Util.extend(this, options);
var projCode = this.projection instanceof OpenLayers.Projection ?
this.projection.projCode : this.projection;
OpenLayers.Util.applyDefaults(this, OpenLayers.Projection.defaults[projCode]);
// allow extents to be arrays // allow extents to be arrays
if (this.maxExtent && !(this.maxExtent instanceof OpenLayers.Bounds)) { if (this.maxExtent && !(this.maxExtent instanceof OpenLayers.Bounds)) {
this.maxExtent = new OpenLayers.Bounds(this.maxExtent); this.maxExtent = new OpenLayers.Bounds(this.maxExtent);
+60 -18
View File
@@ -142,7 +142,7 @@ OpenLayers.Projection = OpenLayers.Class({
/** /**
* Property: transforms * Property: transforms
* Transforms is an object, with from properties, each of which may * {Object} Transforms is an object, with from properties, each of which may
* have a to property. This allows you to define projections without * have a to property. This allows you to define projections without
* requiring support for proj4js to be included. * requiring support for proj4js to be included.
* *
@@ -162,6 +162,30 @@ OpenLayers.Projection = OpenLayers.Class({
*/ */
OpenLayers.Projection.transforms = {}; OpenLayers.Projection.transforms = {};
/**
* APIProperty: defaults
* {Object} Defaults for the SRS codes known to OpenLayers (currently
* EPSG:4326, CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, EPSG:900913, EPSG:3857,
* EPSG:102113 and EPSG:102100). Keys are the SRS code, values are units,
* maxExtent (the validity extent for the SRS) and yx (true if this SRS is
* known to have a reverse axis order).
*/
OpenLayers.Projection.defaults = {
"EPSG:4326": {
units: "degrees",
maxExtent: [-180, -90, 180, 90],
yx: true
},
"CRS:84": {
units: "degrees",
maxExtent: [-180, -90, 180, 90]
},
"EPSG:900913": {
units: "m",
maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34]
}
};
/** /**
* APIMethod: addTransform * APIMethod: addTransform
* Set a custom transform method between two projections. Use this method in * Set a custom transform method between two projections. Use this method in
@@ -176,6 +200,12 @@ OpenLayers.Projection.transforms = {};
* in place. The original point should be modified. * in place. The original point should be modified.
*/ */
OpenLayers.Projection.addTransform = function(from, to, method) { OpenLayers.Projection.addTransform = function(from, to, method) {
if (method === OpenLayers.Projection.nullTransform) {
var defaults = OpenLayers.Projection.defaults[from];
if (defaults && !OpenLayers.Projection.defaults[to]) {
OpenLayers.Projection.defaults[to] = defaults;
}
}
if(!OpenLayers.Projection.transforms[from]) { if(!OpenLayers.Projection.transforms[from]) {
OpenLayers.Projection.transforms[from] = {}; OpenLayers.Projection.transforms[from] = {};
} }
@@ -235,12 +265,15 @@ OpenLayers.Projection.nullTransform = function(point) {
}; };
/** /**
* Note: Transforms for web mercator <-> EPSG:4326 * Note: Transforms for web mercator <-> geographic
* OpenLayers recognizes EPSG:3857, EPSG:900913, EPSG:102113 and EPSG:102100. * OpenLayers recognizes EPSG:3857, EPSG:900913, EPSG:102113 and EPSG:102100.
* OpenLayers originally started referring to EPSG:900913 as web mercator. * OpenLayers originally started referring to EPSG:900913 as web mercator.
* The EPSG has declared EPSG:3857 to be web mercator. * The EPSG has declared EPSG:3857 to be web mercator.
* ArcGIS 10 recognizes the EPSG:3857, EPSG:102113, and EPSG:102100 as * ArcGIS 10 recognizes the EPSG:3857, EPSG:102113, and EPSG:102100 as
* equivalent. See http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2009/11/20/ArcGIS-Online-moving-to-Google-_2F00_-Bing-tiling-scheme_3A00_-What-does-this-mean-for-you_3F00_.aspx#12084 * equivalent. See http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2009/11/20/ArcGIS-Online-moving-to-Google-_2F00_-Bing-tiling-scheme_3A00_-What-does-this-mean-for-you_3F00_.aspx#12084.
* For geographic, OpenLayers recognizes EPSG:4326, CRS:84 and
* urn:ogc:def:crs:EPSG:6.6:4326. OpenLayers also knows about the reverse axis
* order for EPSG:4326.
*/ */
(function() { (function() {
@@ -258,22 +291,31 @@ OpenLayers.Projection.nullTransform = function(point) {
return xy; return xy;
} }
// list of equivalent codes for web mercator function map(base, codes) {
var codes = ["EPSG:900913", "EPSG:3857", "EPSG:102113", "EPSG:102100"]; var add = OpenLayers.Projection.addTransform;
var same = OpenLayers.Projection.nullTransform;
var add = OpenLayers.Projection.addTransform; var i, len, code, other, j;
var same = OpenLayers.Projection.nullTransform; for (i=0, len=codes.length; i<len; ++i) {
code = codes[i];
var i, len, code, other, j; add(base, code, forwardMercator);
for (i=0, len=codes.length; i<len; ++i) { add(code, base, inverseMercator);
code = codes[i]; for (j=i+1; j<len; ++j) {
add("EPSG:4326", code, forwardMercator); other = codes[j];
add(code, "EPSG:4326", inverseMercator); add(code, other, same);
for (j=i+1; j<len; ++j) { add(other, code, same);
other = codes[j]; }
add(code, other, same);
add(other, code, same);
} }
} }
// list of equivalent codes for web mercator
var mercator = ["EPSG:900913", "EPSG:3857", "EPSG:102113", "EPSG:102100"],
geographic = ["CRS:84", "urn:ogc:def:crs:EPSG:6.6:4326", "EPSG:4326"],
i;
for (i=mercator.length-1; i>=0; --i) {
map(mercator[i], geographic);
}
for (i=geographic.length-1; i>=0; --i) {
map(geographic[i], mercator);
}
})(); })();
+7 -6
View File
@@ -291,18 +291,18 @@
t.plan(5); t.plan(5);
var map = new OpenLayers.Map("map", { var map = new OpenLayers.Map("map", {
getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));} getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));}
} });
); var geographic = new OpenLayers.Projection("EPSG:4326");
var a = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", { var a = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", {
layers: "a,b,c,d", layers: "a,b,c,d",
styles: "a,b,c,d" styles: "a,b,c,d"
}); }, {projection: geographic});
var b = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", { var b = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", {
layers: ["a","b","c","d"], layers: ["a","b","c","d"],
styles: ["a","b","c","d"] styles: ["a","b","c","d"]
}); }, {projection: geographic});
var c = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", { var c = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", {
layers: ["a","b","c","d"] layers: ["a","b","c","d"]
@@ -310,13 +310,13 @@
var d = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", { var d = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", {
layers: "a,b,c,d" layers: "a,b,c,d"
}); }, {projection: geographic});
var click = new OpenLayers.Control.WMSGetFeatureInfo({ var click = new OpenLayers.Control.WMSGetFeatureInfo({
featureType: 'type', featureType: 'type',
featureNS: 'ns', featureNS: 'ns',
layers: [a, b, c, d] layers: [a, b, c, d]
}); }, {projection: geographic});
map.addControl(click); map.addControl(click);
@@ -399,6 +399,7 @@
var c = new OpenLayers.Layer.WMS( var c = new OpenLayers.Layer.WMS(
null, ["http://c.mirror/wms", "http://d.mirror/wms"], {layers: "c"} null, ["http://c.mirror/wms", "http://d.mirror/wms"], {layers: "c"}
); );
map.addLayers([a, b, c]);
var control = new OpenLayers.Control.WMSGetFeatureInfo({ var control = new OpenLayers.Control.WMSGetFeatureInfo({
url: "http://host/wms", url: "http://host/wms",
+2 -2
View File
@@ -268,10 +268,10 @@
map.destroy(); map.destroy();
map = new OpenLayers.Map("map"); map = new OpenLayers.Map("map");
layer = new OpenLayers.Layer("test", {projection: "EPSG:4326"}); layer = new OpenLayers.Layer("test", {projection: "unknown"});
map.addLayer(layer); map.addLayer(layer);
t.eq(layer.alwaysInRange, true, t.eq(layer.alwaysInRange, true,
"alwaysInRange true if only get projection."); "alwaysInRange true if unknown projection is set.");
map.destroy(); map.destroy();
map = new OpenLayers.Map("map"); map = new OpenLayers.Map("map");
+2 -2
View File
@@ -178,7 +178,7 @@
var map = new OpenLayers.Map({ var map = new OpenLayers.Map({
div: "map", div: "map",
maxResolution: OpenLayers.Map.prototype.maxResolution / Math.pow(2, offset) maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset)
}); });
var layer = new OpenLayers.Layer.TMS("TMS", "", { var layer = new OpenLayers.Layer.TMS("TMS", "", {
layername: "basic", layername: "basic",
@@ -200,7 +200,7 @@
var map = new OpenLayers.Map({ var map = new OpenLayers.Map({
div: "map", div: "map",
maxResolution: OpenLayers.Map.prototype.maxResolution / Math.pow(2, offset) maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset)
}); });
var layer = new OpenLayers.Layer.TMS("TMS", "", { var layer = new OpenLayers.Layer.TMS("TMS", "", {
layername: "basic", layername: "basic",
+1
View File
@@ -388,6 +388,7 @@
var map = new OpenLayers.Map({ var map = new OpenLayers.Map({
div: "map", div: "map",
maxExtent: new OpenLayers.Bounds(-185, -95, 185, 95), maxExtent: new OpenLayers.Bounds(-185, -95, 185, 95),
maxResolution: 1.40625,
layers: [dummy, unconstrained, constrained], layers: [dummy, unconstrained, constrained],
center: new OpenLayers.LonLat(0, 0), center: new OpenLayers.LonLat(0, 0),
zoom: 1 zoom: 1
+2
View File
@@ -137,6 +137,7 @@
style: "blue_marble", style: "blue_marble",
matrixSet: "arcgis_online", matrixSet: "arcgis_online",
tileSize: new OpenLayers.Size(512, 512), tileSize: new OpenLayers.Size(512, 512),
maxResolution: 1.40625,
requestEncoding: "REST" requestEncoding: "REST"
}); });
map.addLayer(layer1); map.addLayer(layer1);
@@ -157,6 +158,7 @@
style: "blue_marble", style: "blue_marble",
matrixSet: "arcgis_online", matrixSet: "arcgis_online",
tileSize: new OpenLayers.Size(512, 512), tileSize: new OpenLayers.Size(512, 512),
maxResolution: 1.40625,
requestEncoding: "REST" requestEncoding: "REST"
}); });
map.addLayer(layer1); map.addLayer(layer1);
+2 -2
View File
@@ -195,7 +195,7 @@
var map = new OpenLayers.Map({ var map = new OpenLayers.Map({
div: "map", div: "map",
maxResolution: OpenLayers.Map.prototype.maxResolution / Math.pow(2, offset) maxResolution: 1.40625 / Math.pow(2, offset)
}); });
var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset}); var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset});
map.addLayer(layer); map.addLayer(layer);
@@ -211,7 +211,7 @@
var map = new OpenLayers.Map({ var map = new OpenLayers.Map({
div: "map", div: "map",
maxResolution: OpenLayers.Map.prototype.maxResolution / Math.pow(2, offset) maxResolution: 1.40625 / Math.pow(2, offset)
}); });
var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset}); var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset});
map.addLayer(layer); map.addLayer(layer);
+2 -2
View File
@@ -302,7 +302,7 @@
function test_fromWMSLayer(t) { function test_fromWMSLayer(t) {
t.plan(9); t.plan(9);
var map = new OpenLayers.Map("map", { var map = new OpenLayers.Map("map", {
projection: "EPSG:1234" projection: "CRS:84"
}); });
var layer = new OpenLayers.Layer.WMS("foo", "htttp://foo/ows", var layer = new OpenLayers.Layer.WMS("foo", "htttp://foo/ows",
{layers: "topp:states"} {layers: "topp:states"}
@@ -312,7 +312,7 @@
t.eq(protocol.url, "htttp://foo/ows", "url taken from wms layer"); t.eq(protocol.url, "htttp://foo/ows", "url taken from wms layer");
t.eq(protocol.featurePrefix, "topp", "feature prefix correctly extracted"); t.eq(protocol.featurePrefix, "topp", "feature prefix correctly extracted");
t.eq(protocol.featureType, "states", "typeName correctly extracted"); t.eq(protocol.featureType, "states", "typeName correctly extracted");
t.eq(protocol.srsName, "EPSG:1234", "srsName set correctly"); t.eq(protocol.srsName, "CRS:84", "srsName set correctly");
t.eq(protocol.version, "1.1.0", "version set correctly"); t.eq(protocol.version, "1.1.0", "version set correctly");
t.eq(protocol.format.geometryName, null, "format's geometryName set to null"); t.eq(protocol.format.geometryName, null, "format's geometryName set to null");