1
|
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
2
|
* full list of contributors). Published under the 2-clause BSD license.
|
3
|
* See license.txt in the OpenLayers distribution or repository for the
|
4
|
* full text of the license. */
|
5
|
|
6
|
|
7
|
/**
|
8
|
* @requires OpenLayers/Layer/Grid.js
|
9
|
*/
|
10
|
|
11
|
/**
|
12
|
* Class: OpenLayers.Layer.WorldWind
|
13
|
*
|
14
|
* Inherits from:
|
15
|
* - <OpenLayers.Layer.Grid>
|
16
|
*/
|
17
|
OpenLayers.Layer.WorldWind = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
18
|
|
19
|
DEFAULT_PARAMS: {
|
20
|
},
|
21
|
|
22
|
/**
|
23
|
* APIProperty: isBaseLayer
|
24
|
* {Boolean} WorldWind layer is a base layer by default.
|
25
|
*/
|
26
|
isBaseLayer: true,
|
27
|
|
28
|
/**
|
29
|
* APIProperty: lzd
|
30
|
* {Float} LevelZeroTileSizeDegrees
|
31
|
*/
|
32
|
lzd: null,
|
33
|
|
34
|
/**
|
35
|
* APIProperty: zoomLevels
|
36
|
* {Integer} Number of zoom levels.
|
37
|
*/
|
38
|
zoomLevels: null,
|
39
|
|
40
|
/**
|
41
|
* Constructor: OpenLayers.Layer.WorldWind
|
42
|
*
|
43
|
* Parameters:
|
44
|
* name - {String} Name of Layer
|
45
|
* url - {String} Base URL
|
46
|
* lzd - {Float} Level zero tile size degrees
|
47
|
* zoomLevels - {Integer} number of zoom levels
|
48
|
* params - {Object} additional parameters
|
49
|
* options - {Object} additional options
|
50
|
*/
|
51
|
initialize: function(name, url, lzd, zoomLevels, params, options) {
|
52
|
this.lzd = lzd;
|
53
|
this.zoomLevels = zoomLevels;
|
54
|
var newArguments = [];
|
55
|
newArguments.push(name, url, params, options);
|
56
|
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
57
|
this.params = OpenLayers.Util.applyDefaults(
|
58
|
this.params, this.DEFAULT_PARAMS
|
59
|
);
|
60
|
},
|
61
|
|
62
|
/**
|
63
|
* Method: getZoom
|
64
|
* Convert map zoom to WW zoom.
|
65
|
*/
|
66
|
getZoom: function () {
|
67
|
var zoom = this.map.getZoom();
|
68
|
var extent = this.map.getMaxExtent();
|
69
|
zoom = zoom - Math.log(this.maxResolution / (this.lzd/512))/Math.log(2);
|
70
|
return zoom;
|
71
|
},
|
72
|
|
73
|
/**
|
74
|
* Method: getURL
|
75
|
*
|
76
|
* Parameters:
|
77
|
* bounds - {<OpenLayers.Bounds>}
|
78
|
*
|
79
|
* Returns:
|
80
|
* {String} A string with the layer's url and parameters and also the
|
81
|
* passed-in bounds and appropriate tile size specified as
|
82
|
* parameters
|
83
|
*/
|
84
|
getURL: function (bounds) {
|
85
|
bounds = this.adjustBounds(bounds);
|
86
|
var zoom = this.getZoom();
|
87
|
var extent = this.map.getMaxExtent();
|
88
|
var deg = this.lzd/Math.pow(2,this.getZoom());
|
89
|
var x = Math.floor((bounds.left - extent.left)/deg);
|
90
|
var y = Math.floor((bounds.bottom - extent.bottom)/deg);
|
91
|
if (this.map.getResolution() <= (this.lzd/512)
|
92
|
&& this.getZoom() <= this.zoomLevels) {
|
93
|
return this.getFullRequestString(
|
94
|
{ L: zoom,
|
95
|
X: x,
|
96
|
Y: y
|
97
|
});
|
98
|
} else {
|
99
|
return OpenLayers.Util.getImageLocation("blank.gif");
|
100
|
}
|
101
|
|
102
|
},
|
103
|
|
104
|
CLASS_NAME: "OpenLayers.Layer.WorldWind"
|
105
|
});
|