1
|
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
|
2
|
<html>
|
3
|
<head>
|
4
|
<title>
|
5
|
<a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008 Overview
|
6
|
</title>
|
7
|
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
|
8
|
<script>
|
9
|
function asd() {
|
10
|
|
11
|
parent.document.title="Extent.js Overview";
|
12
|
|
13
|
}
|
14
|
</script>
|
15
|
</head>
|
16
|
<body bgcolor="white" onload="asd();">
|
17
|
|
18
|
<!-- ========== START OF NAVBAR ========== -->
|
19
|
<a name="navbar_top"><!-- --></a>
|
20
|
<table border="0" width="100%" cellpadding="1" cellspacing="0">
|
21
|
<tr>
|
22
|
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
|
23
|
<a name="navbar_top_firstrow"><!-- --></a>
|
24
|
<table border="0" cellpadding="0" cellspacing="3">
|
25
|
<tr align="center" valign="top">
|
26
|
|
27
|
|
28
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
|
29
|
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
|
30
|
|
31
|
|
32
|
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
|
33
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
|
34
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
|
35
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
|
36
|
</tr>
|
37
|
</table>
|
38
|
</td>
|
39
|
<td bgcolor="#EEEEFF" align="right" valign="top">
|
40
|
<em>
|
41
|
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
|
42
|
</td>
|
43
|
</tr>
|
44
|
|
45
|
<tr>
|
46
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
47
|
PREV
|
48
|
NEXT</font></td>
|
49
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
50
|
<a href="index.html" target="_top"><b>FRAMES</b></a>
|
51
|
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
|
52
|
|
53
|
<script>
|
54
|
<!--
|
55
|
if(window==top) {
|
56
|
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
|
57
|
}
|
58
|
//-->
|
59
|
</script>
|
60
|
<noscript>
|
61
|
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
|
62
|
</noscript>
|
63
|
</font></td>
|
64
|
</tr>
|
65
|
</table>
|
66
|
<!-- =========== END OF NAVBAR =========== -->
|
67
|
|
68
|
<hr>
|
69
|
<center>
|
70
|
|
71
|
<h2>Extent.js</h2>
|
72
|
|
73
|
</center>
|
74
|
|
75
|
|
76
|
|
77
|
|
78
|
<h4>Summary</h4>
|
79
|
<p>
|
80
|
|
81
|
No overview generated for 'Extent.js'<BR/><BR/>
|
82
|
|
83
|
</p>
|
84
|
|
85
|
<hr>
|
86
|
|
87
|
|
88
|
<table border="1" cellpadding="3" cellspacing="0" width="100%">
|
89
|
<tr bgcolor="#CCCCFF" class="TableHeadingColor">
|
90
|
<td colspan=2><font size="+2">
|
91
|
|
92
|
<b>Class Summary</b>
|
93
|
|
94
|
</font></td>
|
95
|
</tr>
|
96
|
|
97
|
<tr bgcolor="white" class="TableRowColor">
|
98
|
<td width="15%"><b><a href="Extent.html">Extent</a></b></td>
|
99
|
<td> </td>
|
100
|
</tr>
|
101
|
|
102
|
</table>
|
103
|
<hr/>
|
104
|
|
105
|
|
106
|
<!-- ========== METHOD SUMMARY =========== -->
|
107
|
|
108
|
<!-- ========== END METHOD SUMMARY =========== -->
|
109
|
|
110
|
|
111
|
<pre class="sourceview"><span class="comment">/*
|
112
|
Author: Mike Adair mike.adairATccrs.nrcan.gc.ca
|
113
|
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
|
114
|
$Id: Extent.js 3067 2007-08-03 09:25:59Z jseb.baklouti $
|
115
|
*/</span>
|
116
|
|
117
|
|
118
|
var Rearth = 6378137.0; // Radius of the earth (sphere); different from Proj value?
|
119
|
var degToMeter = Rearth*2*Math.PI/360;
|
120
|
<span class="comment">//var mbScaleFactor = 72 * 39.3701; //PixelsPerInch*InchesPerMapUnit; magic numbers </span>
|
121
|
<span class="comment"> //need to determine magic number for lat/lon</span>
|
122
|
var mbScaleFactor = 3571.428; //magic number, <span class="reserved">for</span> Geoserver SLD compatibility
|
123
|
<span class="comment"> // 1/0.00028 (0.28 mm "is a common actual size for</span>
|
124
|
<span class="comment"> // contemporary display" as written in the SLD specification ...</span>
|
125
|
|
126
|
<span class="comment">/*
|
127
|
* FD 2005/03/04 : minScale et maxScale
|
128
|
* DGR : should be in config ?
|
129
|
*/</span>
|
130
|
var minScale = 1000;
|
131
|
var maxScale = 200000;
|
132
|
|
133
|
<span class="comment">/**
|
134
|
* A tool designed to handle geography calculations for widgets which render
|
135
|
* the model in 2D.
|
136
|
* Use of this tool requires that it's model implements get/setWindowHeight/Width
|
137
|
* methods.
|
138
|
* Encapsulates all geography and image size aspects of a geographic object
|
139
|
* displayed in a rectangular area on the screen.
|
140
|
* All coordinates are handled as points which is a 2 element array, where x is
|
141
|
* the first element and y is the second. Coordinates are either pixel and lixel
|
142
|
* (pl) relative to the top left of the extent or projection XY values (xy).
|
143
|
*
|
144
|
* <span class="attrib">@constructor</span>
|
145
|
* <span class="attrib">@param</span> model the model document that this extent represents
|
146
|
* <span class="attrib">@param</span> initialRes (optional) if supplied the extent resolution will be set to this value
|
147
|
*/</span>
|
148
|
<span class="reserved">function</span> Extent( model, initialRes ) {
|
149
|
<span class="reserved">this</span>.model = model;
|
150
|
<span class="reserved">this</span>.id = model.id + <span class="literal">"_MbExtent"</span> + mbIds.getId();
|
151
|
<span class="reserved">this</span>.size = new Array();
|
152
|
<span class="reserved">this</span>.res = new Array();
|
153
|
<span class="reserved">this</span>.zoomBy = 4;
|
154
|
|
155
|
<span class="comment">/**
|
156
|
* Returns the bounding box as stored in the model
|
157
|
* <span class="attrib">@return</span> array with the bounding box
|
158
|
*/</span>
|
159
|
<span class="reserved">this</span>.getBbox = <span class="reserved">function</span>() {
|
160
|
var bbox = <span class="reserved">this</span>.model.getBoundingBox();
|
161
|
<span class="reserved">return</span> bbox;
|
162
|
}
|
163
|
|
164
|
<span class="comment">/**
|
165
|
* Recalculates a given bbox and stores a proper aspect one in the model
|
166
|
* <span class="attrib">@param</span> bbox an array with a bounding box
|
167
|
*/</span>
|
168
|
<span class="reserved">this</span>.setBbox = <span class="reserved">function</span>(bbox){
|
169
|
size = <span class="reserved">this</span>.getSize();
|
170
|
res = Math.max((bbox[2] - bbox[0])/size[0], (bbox[3] - bbox[1])/size[1]);
|
171
|
scale=<span class="reserved">this</span>.getFixedScale(res);
|
172
|
center = new Array((bbox[1]-bbox[3])/2,(bbox[0]-bbox[2])/2);//center=horizontal,vertical
|
173
|
half = new Array(size[0]/2,size[1]/2);
|
174
|
bbox = new Array(center[0]-half[0]*scale, center[1]-half[1]*scale, center[0]+half[0]*scale,center[1]+half[1]*scale);
|
175
|
<span class="reserved">this</span>.model.setBoundingBox(bbox);
|
176
|
}
|
177
|
|
178
|
<span class="comment">/**
|
179
|
* Returns the window size as stored in the model
|
180
|
* <span class="attrib">@return</span> array with the window size
|
181
|
*/</span>
|
182
|
<span class="reserved">this</span>.getSize = <span class="reserved">function</span>() {
|
183
|
size= new Array();
|
184
|
size[0] = <span class="reserved">this</span>.model.getWindowWidth();
|
185
|
size[1] = <span class="reserved">this</span>.model.getWindowHeight();
|
186
|
<span class="reserved">return</span> size;
|
187
|
}
|
188
|
|
189
|
<span class="comment">/**
|
190
|
* Stores a given window size in the model.
|
191
|
* Can be used in the future for dynamic window resizing
|
192
|
* <span class="attrib">@param</span> size an array with a window size
|
193
|
*/</span>
|
194
|
<span class="reserved">this</span>.setSize = <span class="reserved">function</span>(size){
|
195
|
<span class="reserved">this</span>.model.setWindowWidth(size[0]);
|
196
|
<span class="reserved">this</span>.model.setWindowHeight(size[1]);
|
197
|
}
|
198
|
|
199
|
<span class="comment">/**
|
200
|
* When given a res, it recalculates it to match the zoomlevels, when present and returns a fixed scale.
|
201
|
* When no res is given it returns the maximum resolution
|
202
|
* <span class="attrib">@param</span> res optional resolution to be checked
|
203
|
* <span class="attrib">@return</span> fixedScale the resolution to display the map with
|
204
|
*/</span>
|
205
|
<span class="reserved">this</span>.getFixedScale = <span class="reserved">function</span>(res) {
|
206
|
<span class="reserved">if</span> (<span class="reserved">this</span>.zoomLevels){
|
207
|
<span class="reserved">if</span> (!res) {
|
208
|
<span class="reserved">this</span>.setResolution( new Array(<span class="reserved">this</span>.model.getWindowWidth(), <span class="reserved">this</span>.model.getWindowHeight() ) );
|
209
|
res = Math.max(<span class="reserved">this</span>.res[0],<span class="reserved">this</span>.res[1]);
|
210
|
|
211
|
}
|
212
|
var sortstring = <span class="literal">"function sort(a,b){return b-a}"</span>;
|
213
|
var evalsort= eval(sortstring);
|
214
|
var zoomLevels = <span class="reserved">this</span>.zoomLevels.sort(evalsort);
|
215
|
var i=0;
|
216
|
<span class="reserved">while</span>(zoomLevels[i] >= res){
|
217
|
i++;
|
218
|
}
|
219
|
<span class="reserved">if</span>(i==0) {
|
220
|
i=1;
|
221
|
}
|
222
|
<span class="reserved">this</span>.fixedScale = zoomLevels[i-1];
|
223
|
}
|
224
|
<span class="reserved">else</span> <span class="reserved">this</span>.fixedScale = Math.max(<span class="reserved">this</span>.res[0],<span class="reserved">this</span>.res[1]);
|
225
|
<span class="reserved">return</span> <span class="reserved">this</span>.fixedScale;
|
226
|
|
227
|
}
|
228
|
|
229
|
<span class="comment">/*
|
230
|
* Sets the zoomLevels in the extent
|
231
|
* <span class="attrib">@param</span> enabled boolean to enable or disable zoomLevels support
|
232
|
* <span class="attrib">@param</span> zoomLevels an array containing a fixed set of zoomLevels
|
233
|
*/</span>
|
234
|
<span class="reserved">this</span>.setZoomLevels = <span class="reserved">function</span>(enabled,zoomLevels){
|
235
|
<span class="reserved">if</span>(enabled) {
|
236
|
<span class="reserved">this</span>.zoomLevels = zoomLevels;
|
237
|
}
|
238
|
<span class="reserved">else</span> <span class="reserved">this</span>.zoomLevels = null;
|
239
|
}
|
240
|
|
241
|
<span class="comment">/*
|
242
|
* Recalculates the lr and ul to a proper aspect. It also takes into account zoomLevels when present.
|
243
|
*/</span>
|
244
|
<span class="reserved">this</span>.checkBbox = <span class="reserved">function</span>() {
|
245
|
var center = <span class="reserved">this</span>.getCenter();
|
246
|
var half = new Array(<span class="reserved">this</span>.size[0]/2, <span class="reserved">this</span>.size[1]/2);
|
247
|
var res = <span class="reserved">this</span>.getFixedScale();
|
248
|
<span class="reserved">this</span>.lr = new Array(center[0]+half[0]*res, center[1]-half[1]*res);
|
249
|
<span class="reserved">this</span>.ul = new Array(center[0]-half[0]*res, center[1]+half[1]*res);
|
250
|
}
|
251
|
<span class="comment">/**
|
252
|
* Returns the XY center of this extent
|
253
|
* <span class="attrib">@return</span> array of XY for th center of the extent
|
254
|
*/</span>
|
255
|
<span class="reserved">this</span>.getCenter = <span class="reserved">function</span>() {
|
256
|
<span class="reserved">return</span> new Array((<span class="reserved">this</span>.ul[0]+<span class="reserved">this</span>.lr[0])/2, (<span class="reserved">this</span>.ul[1]+<span class="reserved">this</span>.lr[1])/2);
|
257
|
}
|
258
|
|
259
|
<span class="comment">/**
|
260
|
* Returns XY coordinates for given pixel line coords w.r.t. top left corner
|
261
|
* <span class="attrib">@param</span> pl pixel line in extent to calculate
|
262
|
* <span class="attrib">@return</span> point array of XY coordinates
|
263
|
*/</span>
|
264
|
<span class="reserved">this</span>.getXY = <span class="reserved">function</span>(pl) {
|
265
|
<span class="comment"> //switch(this.model.getSRS()) {</span>
|
266
|
<span class="comment"> // case "EPSG:GMAPS": //<span class="attrib">@TODO</span> Cleanup this hack</span>
|
267
|
<span class="comment"> // gmap=this.model.getParam("gmap");</span>
|
268
|
<span class="comment"> // if(gmap){</span>
|
269
|
<span class="comment"> // p=new GPoint(pl[0],pl[1]);</span>
|
270
|
<span class="comment"> // latlng=gmap.fromDivPixelToLatLng(p);</span>
|
271
|
<span class="comment"> // latlng=new Array(latlng.lng(),latlng.lat());</span>
|
272
|
<span class="comment"> // }</span>
|
273
|
<span class="comment"> // else alert("Extent: gmap not defined");</span>
|
274
|
<span class="comment"> // break;</span>
|
275
|
<span class="comment"> // default:</span>
|
276
|
<span class="comment"> // latlng=new Array(this.ul[0]+pl[0]*this.res[0],this.ul[1]- pl[1]*this.res[1]);</span>
|
277
|
<span class="comment"> // break;</span>
|
278
|
<span class="comment"> //}</span>
|
279
|
latlng=new Array(<span class="reserved">this</span>.ul[0]+pl[0]*<span class="reserved">this</span>.res[0],<span class="reserved">this</span>.ul[1]- pl[1]*<span class="reserved">this</span>.res[1]);
|
280
|
<span class="reserved">return</span> latlng;
|
281
|
}
|
282
|
|
283
|
<span class="comment">/**
|
284
|
* Returns pixel/line coordinates for given XY projection coords
|
285
|
* <span class="attrib">@param</span> xy projection XY coordinate to calculate
|
286
|
* <span class="attrib">@return</span> point array of pxiel/line coordinates w.r.t. top left corner
|
287
|
*/</span>
|
288
|
<span class="reserved">this</span>.getPL = <span class="reserved">function</span>(xy) {
|
289
|
<span class="comment"> //switch(this.model.getSRS()) {</span>
|
290
|
<span class="comment"> // case "EPSG:GMAPS": //<span class="attrib">@TODO</span> Cleanup this hack</span>
|
291
|
<span class="comment"> // return xy;</span>
|
292
|
<span class="comment"> //}</span>
|
293
|
|
294
|
var p = Math.floor( (xy[0]-<span class="reserved">this</span>.ul[0])/<span class="reserved">this</span>.res[0] );
|
295
|
var l = Math.floor( (<span class="reserved">this</span>.ul[1]-xy[1])/<span class="reserved">this</span>.res[1] );
|
296
|
<span class="reserved">return</span> new Array(p,l);
|
297
|
}
|
298
|
|
299
|
<span class="comment">/**
|
300
|
* Adjust the extent so that it is centered at given XY coordinate with given
|
301
|
* resolution. Extent width and height remain fixed. Optionally check to
|
302
|
* ensure that it doesn't go beyond available extent.
|
303
|
*
|
304
|
* <span class="attrib">@param</span> center projection XY coordinate to center at
|
305
|
* <span class="attrib">@param</span> newres resolution to display at
|
306
|
* <span class="attrib">@param</span> limitExtent ensure that the extent doesn't go beyond available bbox (TBD: not complete/tested)
|
307
|
* <span class="attrib">@return</span> none
|
308
|
*/</span>
|
309
|
<span class="reserved">this</span>.centerAt = <span class="reserved">function</span>(center, newres, limitExtent) {
|
310
|
var half = new Array(<span class="reserved">this</span>.size[0]/2, <span class="reserved">this</span>.size[1]/2);
|
311
|
<span class="comment">/*
|
312
|
* FD 2005/03/04 : respect de minScale et maxScale
|
313
|
* DGR : scale constraints
|
314
|
var nRmin= minScale/mbScaleFactor;
|
315
|
var nRmax= maxScale/mbScaleFactor;
|
316
|
if (newres < nRmin) {
|
317
|
newres= nRmin ;
|
318
|
}
|
319
|
if (newres > nRmax) {
|
320
|
newres= nRmax ;
|
321
|
}
|
322
|
*/</span>
|
323
|
<span class="reserved">if</span> (<span class="reserved">this</span>.zoomLevels) {
|
324
|
newres=<span class="reserved">this</span>.getFixedScale(newres);
|
325
|
}
|
326
|
<span class="reserved">this</span>.lr = new Array(center[0]+half[0]*newres, center[1]-half[1]*newres);
|
327
|
<span class="reserved">this</span>.ul = new Array(center[0]-half[0]*newres, center[1]+half[1]*newres);
|
328
|
<span class="comment">
|
329
|
//make sure the request doesn't extend beyond the available model</span>
|
330
|
<span class="comment"> //TBD this block not tested</span>
|
331
|
<span class="reserved">if</span> ( limitExtent ) {
|
332
|
var xShift = 0;
|
333
|
<span class="reserved">if</span> ( <span class="reserved">this</span>.lr[0] > ContextExtent.lr[0] ) xShift = ContextExtent.lr[0] - <span class="reserved">this</span>.lr[0];
|
334
|
<span class="reserved">if</span> ( <span class="reserved">this</span>.ul[0] < ContextExtent.ul[0] ) xShift = ContextExtent.ul[0] - <span class="reserved">this</span>.ul[0];
|
335
|
<span class="reserved">this</span>.lr[0] += xShift;
|
336
|
<span class="reserved">this</span>.ul[0] += xShift;
|
337
|
|
338
|
var yShift = 0;
|
339
|
<span class="reserved">if</span> ( <span class="reserved">this</span>.lr[1] < ContextExtent.lr[1] ) yShift = ContextExtent.lr[1] - <span class="reserved">this</span>.lr[1];
|
340
|
<span class="reserved">if</span> ( <span class="reserved">this</span>.ul[1] > ContextExtent.ul[1] ) yShift = ContextExtent.ul[1] - <span class="reserved">this</span>.ul[1];
|
341
|
<span class="reserved">this</span>.lr[1] += yShift;
|
342
|
<span class="reserved">this</span>.ul[1] += yShift;
|
343
|
}
|
344
|
|
345
|
<span class="reserved">this</span>.model.setBoundingBox( new Array(<span class="reserved">this</span>.ul[0], <span class="reserved">this</span>.lr[1], <span class="reserved">this</span>.lr[0], <span class="reserved">this</span>.ul[1]) );
|
346
|
<span class="comment"> //this.setResolution(size);</span>
|
347
|
<span class="reserved">this</span>.setSize(newres);
|
348
|
}
|
349
|
|
350
|
<span class="comment">/**
|
351
|
* Adjust the extent to the given bbox. Resolution is recalculated.
|
352
|
* Extent width and height remain fixed.
|
353
|
* <span class="attrib">@param</span> ul upper left coordinate of bbox in XY projection coords
|
354
|
* <span class="attrib">@param</span> lr lower right coordinate of bbox in XY projection coords
|
355
|
*/</span>
|
356
|
<span class="reserved">this</span>.zoomToBox = <span class="reserved">function</span>(ul, lr) { //pass in xy
|
357
|
var center = new Array((ul[0]+lr[0])/2, (ul[1]+lr[1])/2);
|
358
|
newres = Math.max((lr[0] - ul[0])/<span class="reserved">this</span>.size[0], (ul[1] - lr[1])/<span class="reserved">this</span>.size[1]);
|
359
|
<span class="reserved">this</span>.centerAt( center, newres );
|
360
|
}
|
361
|
|
362
|
<span class="comment">/**
|
363
|
* Adjust the width and height to that bbox is displayed at specified resolution
|
364
|
* <span class="attrib">@param</span> res the resolution to be set
|
365
|
*/</span>
|
366
|
<span class="comment"> //TBD update the model doc</span>
|
367
|
<span class="reserved">this</span>.setSize = <span class="reserved">function</span>(res) { //pass in a resolution and width, height are recalculated
|
368
|
<span class="reserved">this</span>.res[0] = <span class="reserved">this</span>.res[1] = res;
|
369
|
<span class="reserved">this</span>.size[0] = (<span class="reserved">this</span>.lr[0] - <span class="reserved">this</span>.ul[0])/<span class="reserved">this</span>.res[0];
|
370
|
<span class="reserved">this</span>.size[1] = (<span class="reserved">this</span>.ul[1] - <span class="reserved">this</span>.lr[1])/<span class="reserved">this</span>.res[1];
|
371
|
<span class="reserved">this</span>.width = Math.ceil(<span class="reserved">this</span>.size[0]);
|
372
|
<span class="reserved">this</span>.height = Math.ceil(<span class="reserved">this</span>.size[1]);
|
373
|
}
|
374
|
|
375
|
<span class="comment">/**
|
376
|
* Adjust the resolution so the bbox fits in the specified width and height
|
377
|
* <span class="attrib">@param</span> size width, height array passed in
|
378
|
*/</span>
|
379
|
<span class="comment"> //TBD update the model doc</span>
|
380
|
<span class="reserved">this</span>.setResolution = <span class="reserved">function</span>(size) { //pass in a width, height and res is recalculated
|
381
|
<span class="reserved">this</span>.size[0] = size[0];
|
382
|
<span class="reserved">this</span>.size[1] = size[1];
|
383
|
<span class="reserved">this</span>.res[0] = (<span class="reserved">this</span>.lr[0] - <span class="reserved">this</span>.ul[0])/<span class="reserved">this</span>.size[0];
|
384
|
<span class="reserved">this</span>.res[1] = (<span class="reserved">this</span>.ul[1] - <span class="reserved">this</span>.lr[1])/<span class="reserved">this</span>.size[1];
|
385
|
<span class="reserved">this</span>.width = Math.ceil(<span class="reserved">this</span>.size[0]);
|
386
|
<span class="reserved">this</span>.height = Math.ceil(<span class="reserved">this</span>.size[1]);
|
387
|
}
|
388
|
|
389
|
<span class="comment">/**
|
390
|
* Returns the map scale denominator for the current extent resolution
|
391
|
* <span class="attrib">@return</span> map scale denominator
|
392
|
*/</span>
|
393
|
<span class="reserved">this</span>.getScale = <span class="reserved">function</span>() {
|
394
|
var pixRes = null;
|
395
|
switch(<span class="reserved">this</span>.model.getSRS()) {
|
396
|
case <span class="literal">"EPSG:GMAPS"</span>:
|
397
|
break;
|
398
|
case <span class="literal">"EPSG:4326"</span>: //all projection codes in degrees
|
399
|
case <span class="literal">"EPSG:4269"</span>:
|
400
|
pixRes = <span class="reserved">this</span>.res[0]*degToMeter;
|
401
|
break;
|
402
|
default: //all projection codes in meters
|
403
|
pixRes = <span class="reserved">this</span>.res[0];
|
404
|
break;
|
405
|
}
|
406
|
<span class="reserved">return</span> mbScaleFactor*pixRes;
|
407
|
}
|
408
|
|
409
|
<span class="comment">/**
|
410
|
* Sets the model's resolution from mapScale input value. The map center
|
411
|
* remains fixed.
|
412
|
* <span class="attrib">@param</span> scale map scale denominator value
|
413
|
*/</span>
|
414
|
<span class="reserved">this</span>.setScale = <span class="reserved">function</span>(scale) {
|
415
|
var newRes = null;
|
416
|
<span class="comment">/*
|
417
|
* FD 2005/03/04
|
418
|
* On contraint l'echelle min et max de l'application.
|
419
|
* A externaliser dans le fichier de config de l'application ;-)
|
420
|
* DGR : should be in the config
|
421
|
if (scale < minScale) {
|
422
|
scale= minScale ;
|
423
|
}
|
424
|
if (scale > maxScale) {
|
425
|
scale= maxScale ;
|
426
|
}
|
427
|
*/</span>
|
428
|
switch(<span class="reserved">this</span>.model.getSRS()) {
|
429
|
case <span class="literal">"EPSG:4326"</span>: //all projection codes in degrees
|
430
|
case <span class="literal">"EPSG:4269"</span>:
|
431
|
<span class="comment"> //convert to resolution in degrees</span>
|
432
|
newRes = scale/(mbScaleFactor*degToMeter);
|
433
|
break;
|
434
|
default: //all projection codes in meters
|
435
|
newRes = scale/mbScaleFactor;
|
436
|
break;
|
437
|
}
|
438
|
<span class="reserved">this</span>.centerAt(<span class="reserved">this</span>.getCenter(), newRes );
|
439
|
}
|
440
|
|
441
|
|
442
|
<span class="comment">/**
|
443
|
* Initialization of the Extent tool, called as a loadModel event listener.
|
444
|
* <span class="attrib">@param</span> extent the object being initialized
|
445
|
* <span class="attrib">@param</span> initialRes (optional) if supplied the extent resolution will be set to this value
|
446
|
*/</span>
|
447
|
<span class="reserved">this</span>.init = <span class="reserved">function</span>(extent, initialRes) {
|
448
|
var bbox = extent.model.getBoundingBox();
|
449
|
extent.ul = new Array(bbox[0],bbox[3]);
|
450
|
extent.lr = new Array(bbox[2],bbox[1]);
|
451
|
<span class="comment">/*
|
452
|
TBD: when called as a listener this gets a bbox array passed in, not initialRes value
|
453
|
if ( initialRes ) {
|
454
|
extent.setSize( initialRes );
|
455
|
} else {
|
456
|
extent.setResolution( new Array(extent.model.getWindowWidth(), extent.model.getWindowHeight() ) );
|
457
|
}
|
458
|
*/</span>
|
459
|
extent.setResolution( new Array(extent.model.getWindowWidth(), extent.model.getWindowHeight() ) );
|
460
|
extent.checkBbox();
|
461
|
}
|
462
|
<span class="reserved">if</span> ( initialRes ) <span class="reserved">this</span>.init(<span class="reserved">this</span>, initialRes);
|
463
|
|
464
|
|
465
|
<span class="reserved">this</span>.firstInit = <span class="reserved">function</span>(extent, initialRes) {
|
466
|
extent.init(extent, initialRes);
|
467
|
<span class="comment"> //TBD: this causes 2 paint() calls on initial load, not sure why it's here - MA</span>
|
468
|
<span class="comment"> //extent.zoomToBox(extent.ul,extent.lr);</span>
|
469
|
}
|
470
|
|
471
|
}
|
472
|
|
473
|
|
474
|
|
475
|
</pre>
|
476
|
<hr>
|
477
|
|
478
|
|
479
|
|
480
|
<!-- ========== START OF NAVBAR ========== -->
|
481
|
<a name="navbar_top"><!-- --></a>
|
482
|
<table border="0" width="100%" cellpadding="1" cellspacing="0">
|
483
|
<tr>
|
484
|
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
|
485
|
<a name="navbar_top_firstrow"><!-- --></a>
|
486
|
<table border="0" cellpadding="0" cellspacing="3">
|
487
|
<tr align="center" valign="top">
|
488
|
|
489
|
|
490
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
|
491
|
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
|
492
|
|
493
|
|
494
|
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
|
495
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
|
496
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
|
497
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
|
498
|
</tr>
|
499
|
</table>
|
500
|
</td>
|
501
|
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
|
502
|
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
|
503
|
</td>
|
504
|
</tr>
|
505
|
|
506
|
<tr>
|
507
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
508
|
PREV
|
509
|
NEXT</font></td>
|
510
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
511
|
<a href="index.html" target="_top"><b>FRAMES</b></a>
|
512
|
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
|
513
|
|
514
|
<script>
|
515
|
<!--
|
516
|
if(window==top) {
|
517
|
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
|
518
|
}
|
519
|
//-->
|
520
|
</script>
|
521
|
<noscript>
|
522
|
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
|
523
|
</noscript>
|
524
|
</font></td>
|
525
|
</tr>
|
526
|
</table>
|
527
|
<!-- =========== END OF NAVBAR =========== -->
|
528
|
|
529
|
<hr>
|
530
|
<font size="-1">
|
531
|
|
532
|
</font>
|
533
|
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Sun Apr 27 20:30:54 2008</div>
|
534
|
</body>
|
535
|
</html>
|