Project

General

Profile

« Previous | Next » 

Revision 8673

use local release of OpenLayers api so that it works over https with our secure deployments (openlayers.org does not offer the api from their servers using https).

View differences:

lib/style/skins/sanparks/spatial/map.jsp
37 37
<html>
38 38
  <head>
39 39
    <link rel="stylesheet" type="text/css" href="<%=STYLE_COMMON_URL%>/spatial/map.css" />
40
    <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
40
    <script src="<%=STYLE_COMMON_URL%>/spatial/OpenLayers-2.13.1/OpenLayers.js"></script>
41 41
    <script src="<%=STYLE_COMMON_URL%>/spatial/map.js"></script>
42 42
    <script type="text/javascript">
43 43
        function init() {	
lib/style/skins/saeon/spatial/map.jsp
37 37
<html>
38 38
  <head>
39 39
    <link rel="stylesheet" type="text/css" href="<%=STYLE_COMMON_URL%>/spatial/map.css" />
40
    <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
40
    <script src="<%=STYLE_COMMON_URL%>/spatial/OpenLayers-2.13.1/OpenLayers.js"></script>
41 41
    <script src="<%=STYLE_COMMON_URL%>/spatial/map.js"></script>
42 42
    <script type="text/javascript">
43 43
        function init() {	
lib/style/common/spatial/OpenLayers-2.13.1/OpenLayers.debug.js
1
/*
2

  
3
  OpenLayers.js -- OpenLayers Map Viewer Library
4

  
5
  Copyright (c) 2006-2013 by OpenLayers Contributors
6
  Published under the 2-clause BSD license.
7
  See http://openlayers.org/dev/license.txt for the full text of the license, and http://openlayers.org/dev/authors.txt for full list of contributors.
8

  
9
  Includes compressed code under the following licenses:
10

  
11
  (For uncompressed versions of the code used, please see the
12
  OpenLayers Github repository: <https://github.com/openlayers/openlayers>)
13

  
14
*/
15

  
16
/**
17
 * Contains XMLHttpRequest.js <http://code.google.com/p/xmlhttprequest/>
18
 * Copyright 2007 Sergey Ilinsky (http://www.ilinsky.com)
19
 *
20
 * Licensed under the Apache License, Version 2.0 (the "License");
21
 * you may not use this file except in compliance with the License.
22
 * You may obtain a copy of the License at
23
 * http://www.apache.org/licenses/LICENSE-2.0
24
 */
25

  
26
/**
27
 * OpenLayers.Util.pagePosition is based on Yahoo's getXY method, which is
28
 * Copyright (c) 2006, Yahoo! Inc.
29
 * All rights reserved.
30
 * 
31
 * Redistribution and use of this software in source and binary forms, with or
32
 * without modification, are permitted provided that the following conditions
33
 * are met:
34
 * 
35
 * * Redistributions of source code must retain the above copyright notice,
36
 *   this list of conditions and the following disclaimer.
37
 * 
38
 * * Redistributions in binary form must reproduce the above copyright notice,
39
 *   this list of conditions and the following disclaimer in the documentation
40
 *   and/or other materials provided with the distribution.
41
 * 
42
 * * Neither the name of Yahoo! Inc. nor the names of its contributors may be
43
 *   used to endorse or promote products derived from this software without
44
 *   specific prior written permission of Yahoo! Inc.
45
 * 
46
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
47
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
50
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
51
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
52
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
53
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
54
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
55
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
56
 * POSSIBILITY OF SUCH DAMAGE.
57
 */
58
/* ======================================================================
59
    OpenLayers/SingleFile.js
60
   ====================================================================== */
61

  
62
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
63
 * full list of contributors). Published under the 2-clause BSD license.
64
 * See license.txt in the OpenLayers distribution or repository for the
65
 * full text of the license. */
66

  
67
var OpenLayers = {
68
    /**
69
     * Constant: VERSION_NUMBER
70
     */
71
    VERSION_NUMBER: "Release 2.13.1",
72

  
73
    /**
74
     * Constant: singleFile
75
     * TODO: remove this in 3.0 when we stop supporting build profiles that
76
     * include OpenLayers.js
77
     */
78
    singleFile: true,
79

  
80
    /**
81
     * Method: _getScriptLocation
82
     * Return the path to this script. This is also implemented in
83
     * OpenLayers.js
84
     *
85
     * Returns:
86
     * {String} Path to this script
87
     */
88
    _getScriptLocation: (function() {
89
        var r = new RegExp("(^|(.*?\\/))(OpenLayers[^\\/]*?\\.js)(\\?|$)"),
90
            s = document.getElementsByTagName('script'),
91
            src, m, l = "";
92
        for(var i=0, len=s.length; i<len; i++) {
93
            src = s[i].getAttribute('src');
94
            if(src) {
95
                m = src.match(r);
96
                if(m) {
97
                    l = m[1];
98
                    break;
99
                }
100
            }
101
        }
102
        return (function() { return l; });
103
    })(),
104
    
105
    /**
106
     * Property: ImgPath
107
     * {String} Set this to the path where control images are stored, a path  
108
     * given here must end with a slash. If set to '' (which is the default) 
109
     * OpenLayers will use its script location + "img/".
110
     * 
111
     * You will need to set this property when you have a singlefile build of 
112
     * OpenLayers that either is not named "OpenLayers.js" or if you move
113
     * the file in a way such that the image directory cannot be derived from 
114
     * the script location.
115
     * 
116
     * If your custom OpenLayers build is named "my-custom-ol.js" and the images
117
     * of OpenLayers are in a folder "/resources/external/images/ol" a correct
118
     * way of including OpenLayers in your HTML would be:
119
     * 
120
     * (code)
121
     *   <script src="/path/to/my-custom-ol.js" type="text/javascript"></script>
122
     *   <script type="text/javascript">
123
     *      // tell OpenLayers where the control images are
124
     *      // remember the trailing slash
125
     *      OpenLayers.ImgPath = "/resources/external/images/ol/";
126
     *   </script>
127
     * (end code)
128
     * 
129
     * Please remember that when your OpenLayers script is not named 
130
     * "OpenLayers.js" you will have to make sure that the default theme is 
131
     * loaded into the page by including an appropriate <link>-tag, 
132
     * e.g.:
133
     * 
134
     * (code)
135
     *   <link rel="stylesheet" href="/path/to/default/style.css"  type="text/css">
136
     * (end code)
137
     */
138
    ImgPath : ''
139
};
140
/* ======================================================================
141
    OpenLayers/BaseTypes/Class.js
142
   ====================================================================== */
143

  
144
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
145
 * full list of contributors). Published under the 2-clause BSD license.
146
 * See license.txt in the OpenLayers distribution or repository for the
147
 * full text of the license. */
148

  
149
/**
150
 * @requires OpenLayers/SingleFile.js
151
 */
152

  
153
/**
154
 * Constructor: OpenLayers.Class
155
 * Base class used to construct all other classes. Includes support for 
156
 *     multiple inheritance. 
157
 *     
158
 * This constructor is new in OpenLayers 2.5.  At OpenLayers 3.0, the old 
159
 *     syntax for creating classes and dealing with inheritance 
160
 *     will be removed.
161
 * 
162
 * To create a new OpenLayers-style class, use the following syntax:
163
 * (code)
164
 *     var MyClass = OpenLayers.Class(prototype);
165
 * (end)
166
 *
167
 * To create a new OpenLayers-style class with multiple inheritance, use the
168
 *     following syntax:
169
 * (code)
170
 *     var MyClass = OpenLayers.Class(Class1, Class2, prototype);
171
 * (end)
172
 * 
173
 * Note that instanceof reflection will only reveal Class1 as superclass.
174
 *
175
 */
176
OpenLayers.Class = function() {
177
    var len = arguments.length;
178
    var P = arguments[0];
179
    var F = arguments[len-1];
180

  
181
    var C = typeof F.initialize == "function" ?
182
        F.initialize :
183
        function(){ P.prototype.initialize.apply(this, arguments); };
184

  
185
    if (len > 1) {
186
        var newArgs = [C, P].concat(
187
                Array.prototype.slice.call(arguments).slice(1, len-1), F);
188
        OpenLayers.inherit.apply(null, newArgs);
189
    } else {
190
        C.prototype = F;
191
    }
192
    return C;
193
};
194

  
195
/**
196
 * Function: OpenLayers.inherit
197
 *
198
 * Parameters:
199
 * C - {Object} the class that inherits
200
 * P - {Object} the superclass to inherit from
201
 *
202
 * In addition to the mandatory C and P parameters, an arbitrary number of
203
 * objects can be passed, which will extend C.
204
 */
205
OpenLayers.inherit = function(C, P) {
206
   var F = function() {};
207
   F.prototype = P.prototype;
208
   C.prototype = new F;
209
   var i, l, o;
210
   for(i=2, l=arguments.length; i<l; i++) {
211
       o = arguments[i];
212
       if(typeof o === "function") {
213
           o = o.prototype;
214
       }
215
       OpenLayers.Util.extend(C.prototype, o);
216
   }
217
};
218

  
219
/**
220
 * APIFunction: extend
221
 * Copy all properties of a source object to a destination object.  Modifies
222
 *     the passed in destination object.  Any properties on the source object
223
 *     that are set to undefined will not be (re)set on the destination object.
224
 *
225
 * Parameters:
226
 * destination - {Object} The object that will be modified
227
 * source - {Object} The object with properties to be set on the destination
228
 *
229
 * Returns:
230
 * {Object} The destination object.
231
 */
232
OpenLayers.Util = OpenLayers.Util || {};
233
OpenLayers.Util.extend = function(destination, source) {
234
    destination = destination || {};
235
    if (source) {
236
        for (var property in source) {
237
            var value = source[property];
238
            if (value !== undefined) {
239
                destination[property] = value;
240
            }
241
        }
242

  
243
        /**
244
         * IE doesn't include the toString property when iterating over an object's
245
         * properties with the for(property in object) syntax.  Explicitly check if
246
         * the source has its own toString property.
247
         */
248

  
249
        /*
250
         * FF/Windows < 2.0.0.13 reports "Illegal operation on WrappedNative
251
         * prototype object" when calling hawOwnProperty if the source object
252
         * is an instance of window.Event.
253
         */
254

  
255
        var sourceIsEvt = typeof window.Event == "function"
256
                          && source instanceof window.Event;
257

  
258
        if (!sourceIsEvt
259
           && source.hasOwnProperty && source.hasOwnProperty("toString")) {
260
            destination.toString = source.toString;
261
        }
262
    }
263
    return destination;
264
};
265
/* ======================================================================
266
    OpenLayers/BaseTypes.js
267
   ====================================================================== */
268

  
269
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
270
 * full list of contributors). Published under the 2-clause BSD license.
271
 * See license.txt in the OpenLayers distribution or repository for the
272
 * full text of the license. */
273

  
274
/**
275
 * @requires OpenLayers/SingleFile.js
276
 */
277

  
278
/** 
279
 * Header: OpenLayers Base Types
280
 * OpenLayers custom string, number and function functions are described here.
281
 */
282

  
283
/**
284
 * Namespace: OpenLayers.String
285
 * Contains convenience functions for string manipulation.
286
 */
287
OpenLayers.String = {
288

  
289
    /**
290
     * APIFunction: startsWith
291
     * Test whether a string starts with another string. 
292
     * 
293
     * Parameters:
294
     * str - {String} The string to test.
295
     * sub - {String} The substring to look for.
296
     *  
297
     * Returns:
298
     * {Boolean} The first string starts with the second.
299
     */
300
    startsWith: function(str, sub) {
301
        return (str.indexOf(sub) == 0);
302
    },
303

  
304
    /**
305
     * APIFunction: contains
306
     * Test whether a string contains another string.
307
     * 
308
     * Parameters:
309
     * str - {String} The string to test.
310
     * sub - {String} The substring to look for.
311
     * 
312
     * Returns:
313
     * {Boolean} The first string contains the second.
314
     */
315
    contains: function(str, sub) {
316
        return (str.indexOf(sub) != -1);
317
    },
318
    
319
    /**
320
     * APIFunction: trim
321
     * Removes leading and trailing whitespace characters from a string.
322
     * 
323
     * Parameters:
324
     * str - {String} The (potentially) space padded string.  This string is not
325
     *     modified.
326
     * 
327
     * Returns:
328
     * {String} A trimmed version of the string with all leading and 
329
     *     trailing spaces removed.
330
     */
331
    trim: function(str) {
332
        return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
333
    },
334
    
335
    /**
336
     * APIFunction: camelize
337
     * Camel-case a hyphenated string. 
338
     *     Ex. "chicken-head" becomes "chickenHead", and
339
     *     "-chicken-head" becomes "ChickenHead".
340
     *
341
     * Parameters:
342
     * str - {String} The string to be camelized.  The original is not modified.
343
     * 
344
     * Returns:
345
     * {String} The string, camelized
346
     */
347
    camelize: function(str) {
348
        var oStringList = str.split('-');
349
        var camelizedString = oStringList[0];
350
        for (var i=1, len=oStringList.length; i<len; i++) {
351
            var s = oStringList[i];
352
            camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
353
        }
354
        return camelizedString;
355
    },
356
    
357
    /**
358
     * APIFunction: format
359
     * Given a string with tokens in the form ${token}, return a string
360
     *     with tokens replaced with properties from the given context
361
     *     object.  Represent a literal "${" by doubling it, e.g. "${${".
362
     *
363
     * Parameters:
364
     * template - {String} A string with tokens to be replaced.  A template
365
     *     has the form "literal ${token}" where the token will be replaced
366
     *     by the value of context["token"].
367
     * context - {Object} An optional object with properties corresponding
368
     *     to the tokens in the format string.  If no context is sent, the
369
     *     window object will be used.
370
     * args - {Array} Optional arguments to pass to any functions found in
371
     *     the context.  If a context property is a function, the token
372
     *     will be replaced by the return from the function called with
373
     *     these arguments.
374
     *
375
     * Returns:
376
     * {String} A string with tokens replaced from the context object.
377
     */
378
    format: function(template, context, args) {
379
        if(!context) {
380
            context = window;
381
        }
382

  
383
        // Example matching: 
384
        // str   = ${foo.bar}
385
        // match = foo.bar
386
        var replacer = function(str, match) {
387
            var replacement;
388

  
389
            // Loop through all subs. Example: ${a.b.c}
390
            // 0 -> replacement = context[a];
391
            // 1 -> replacement = context[a][b];
392
            // 2 -> replacement = context[a][b][c];
393
            var subs = match.split(/\.+/);
394
            for (var i=0; i< subs.length; i++) {
395
                if (i == 0) {
396
                    replacement = context;
397
                }
398
                if (replacement === undefined) {
399
                    break;
400
                }
401
                replacement = replacement[subs[i]];
402
            }
403

  
404
            if(typeof replacement == "function") {
405
                replacement = args ?
406
                    replacement.apply(null, args) :
407
                    replacement();
408
            }
409

  
410
            // If replacement is undefined, return the string 'undefined'.
411
            // This is a workaround for a bugs in browsers not properly 
412
            // dealing with non-participating groups in regular expressions:
413
            // http://blog.stevenlevithan.com/archives/npcg-javascript
414
            if (typeof replacement == 'undefined') {
415
                return 'undefined';
416
            } else {
417
                return replacement; 
418
            }
419
        };
420

  
421
        return template.replace(OpenLayers.String.tokenRegEx, replacer);
422
    },
423

  
424
    /**
425
     * Property: tokenRegEx
426
     * Used to find tokens in a string.
427
     * Examples: ${a}, ${a.b.c}, ${a-b}, ${5}
428
     */
429
    tokenRegEx:  /\$\{([\w.]+?)\}/g,
430
    
431
    /**
432
     * Property: numberRegEx
433
     * Used to test strings as numbers.
434
     */
435
    numberRegEx: /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/,
436
    
437
    /**
438
     * APIFunction: isNumeric
439
     * Determine whether a string contains only a numeric value.
440
     *
441
     * Examples:
442
     * (code)
443
     * OpenLayers.String.isNumeric("6.02e23") // true
444
     * OpenLayers.String.isNumeric("12 dozen") // false
445
     * OpenLayers.String.isNumeric("4") // true
446
     * OpenLayers.String.isNumeric(" 4 ") // false
447
     * (end)
448
     *
449
     * Returns:
450
     * {Boolean} String contains only a number.
451
     */
452
    isNumeric: function(value) {
453
        return OpenLayers.String.numberRegEx.test(value);
454
    },
455
    
456
    /**
457
     * APIFunction: numericIf
458
     * Converts a string that appears to be a numeric value into a number.
459
     * 
460
     * Parameters:
461
     * value - {String}
462
     * trimWhitespace - {Boolean}
463
     *
464
     * Returns:
465
     * {Number|String} a Number if the passed value is a number, a String
466
     *     otherwise. 
467
     */
468
    numericIf: function(value, trimWhitespace) {
469
        var originalValue = value;
470
        if (trimWhitespace === true && value != null && value.replace) {
471
            value = value.replace(/^\s*|\s*$/g, "");
472
        }
473
        return OpenLayers.String.isNumeric(value) ? parseFloat(value) : originalValue;
474
    }
475

  
476
};
477

  
478
/**
479
 * Namespace: OpenLayers.Number
480
 * Contains convenience functions for manipulating numbers.
481
 */
482
OpenLayers.Number = {
483

  
484
    /**
485
     * Property: decimalSeparator
486
     * Decimal separator to use when formatting numbers.
487
     */
488
    decimalSeparator: ".",
489
    
490
    /**
491
     * Property: thousandsSeparator
492
     * Thousands separator to use when formatting numbers.
493
     */
494
    thousandsSeparator: ",",
495
    
496
    /**
497
     * APIFunction: limitSigDigs
498
     * Limit the number of significant digits on a float.
499
     * 
500
     * Parameters:
501
     * num - {Float}
502
     * sig - {Integer}
503
     * 
504
     * Returns:
505
     * {Float} The number, rounded to the specified number of significant
506
     *     digits.
507
     */
508
    limitSigDigs: function(num, sig) {
509
        var fig = 0;
510
        if (sig > 0) {
511
            fig = parseFloat(num.toPrecision(sig));
512
        }
513
        return fig;
514
    },
515
    
516
    /**
517
     * APIFunction: format
518
     * Formats a number for output.
519
     * 
520
     * Parameters:
521
     * num  - {Float}
522
     * dec  - {Integer} Number of decimal places to round to.
523
     *        Defaults to 0. Set to null to leave decimal places unchanged.
524
     * tsep - {String} Thousands separator.
525
     *        Default is ",".
526
     * dsep - {String} Decimal separator.
527
     *        Default is ".".
528
     *
529
     * Returns:
530
     * {String} A string representing the formatted number.
531
     */
532
    format: function(num, dec, tsep, dsep) {
533
        dec = (typeof dec != "undefined") ? dec : 0; 
534
        tsep = (typeof tsep != "undefined") ? tsep :
535
            OpenLayers.Number.thousandsSeparator; 
536
        dsep = (typeof dsep != "undefined") ? dsep :
537
            OpenLayers.Number.decimalSeparator;
538

  
539
        if (dec != null) {
540
            num = parseFloat(num.toFixed(dec));
541
        }
542

  
543
        var parts = num.toString().split(".");
544
        if (parts.length == 1 && dec == null) {
545
            // integer where we do not want to touch the decimals
546
            dec = 0;
547
        }
548
        
549
        var integer = parts[0];
550
        if (tsep) {
551
            var thousands = /(-?[0-9]+)([0-9]{3})/; 
552
            while(thousands.test(integer)) { 
553
                integer = integer.replace(thousands, "$1" + tsep + "$2"); 
554
            }
555
        }
556
        
557
        var str;
558
        if (dec == 0) {
559
            str = integer;
560
        } else {
561
            var rem = parts.length > 1 ? parts[1] : "0";
562
            if (dec != null) {
563
                rem = rem + new Array(dec - rem.length + 1).join("0");
564
            }
565
            str = integer + dsep + rem;
566
        }
567
        return str;
568
    },
569

  
570
    /**
571
     * Method: zeroPad
572
     * Create a zero padded string optionally with a radix for casting numbers.
573
     *
574
     * Parameters:
575
     * num - {Number} The number to be zero padded.
576
     * len - {Number} The length of the string to be returned.
577
     * radix - {Number} An integer between 2 and 36 specifying the base to use
578
     *     for representing numeric values.
579
     */
580
    zeroPad: function(num, len, radix) {
581
        var str = num.toString(radix || 10);
582
        while (str.length < len) {
583
            str = "0" + str;
584
        }
585
        return str;
586
    }    
587
};
588

  
589
/**
590
 * Namespace: OpenLayers.Function
591
 * Contains convenience functions for function manipulation.
592
 */
593
OpenLayers.Function = {
594
    /**
595
     * APIFunction: bind
596
     * Bind a function to an object.  Method to easily create closures with
597
     *     'this' altered.
598
     * 
599
     * Parameters:
600
     * func - {Function} Input function.
601
     * object - {Object} The object to bind to the input function (as this).
602
     * 
603
     * Returns:
604
     * {Function} A closure with 'this' set to the passed in object.
605
     */
606
    bind: function(func, object) {
607
        // create a reference to all arguments past the second one
608
        var args = Array.prototype.slice.apply(arguments, [2]);
609
        return function() {
610
            // Push on any additional arguments from the actual function call.
611
            // These will come after those sent to the bind call.
612
            var newArgs = args.concat(
613
                Array.prototype.slice.apply(arguments, [0])
614
            );
615
            return func.apply(object, newArgs);
616
        };
617
    },
618
    
619
    /**
620
     * APIFunction: bindAsEventListener
621
     * Bind a function to an object, and configure it to receive the event
622
     *     object as first parameter when called. 
623
     * 
624
     * Parameters:
625
     * func - {Function} Input function to serve as an event listener.
626
     * object - {Object} A reference to this.
627
     * 
628
     * Returns:
629
     * {Function}
630
     */
631
    bindAsEventListener: function(func, object) {
632
        return function(event) {
633
            return func.call(object, event || window.event);
634
        };
635
    },
636
    
637
    /**
638
     * APIFunction: False
639
     * A simple function to that just does "return false". We use this to 
640
     * avoid attaching anonymous functions to DOM event handlers, which 
641
     * causes "issues" on IE<8.
642
     * 
643
     * Usage:
644
     * document.onclick = OpenLayers.Function.False;
645
     * 
646
     * Returns:
647
     * {Boolean}
648
     */
649
    False : function() {
650
        return false;
651
    },
652

  
653
    /**
654
     * APIFunction: True
655
     * A simple function to that just does "return true". We use this to 
656
     * avoid attaching anonymous functions to DOM event handlers, which 
657
     * causes "issues" on IE<8.
658
     * 
659
     * Usage:
660
     * document.onclick = OpenLayers.Function.True;
661
     * 
662
     * Returns:
663
     * {Boolean}
664
     */
665
    True : function() {
666
        return true;
667
    },
668
    
669
    /**
670
     * APIFunction: Void
671
     * A reusable function that returns ``undefined``.
672
     *
673
     * Returns:
674
     * {undefined}
675
     */
676
    Void: function() {}
677

  
678
};
679

  
680
/**
681
 * Namespace: OpenLayers.Array
682
 * Contains convenience functions for array manipulation.
683
 */
684
OpenLayers.Array = {
685

  
686
    /**
687
     * APIMethod: filter
688
     * Filter an array.  Provides the functionality of the
689
     *     Array.prototype.filter extension to the ECMA-262 standard.  Where
690
     *     available, Array.prototype.filter will be used.
691
     *
692
     * Based on well known example from http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/filter
693
     *
694
     * Parameters:
695
     * array - {Array} The array to be filtered.  This array is not mutated.
696
     *     Elements added to this array by the callback will not be visited.
697
     * callback - {Function} A function that is called for each element in
698
     *     the array.  If this function returns true, the element will be
699
     *     included in the return.  The function will be called with three
700
     *     arguments: the element in the array, the index of that element, and
701
     *     the array itself.  If the optional caller parameter is specified
702
     *     the callback will be called with this set to caller.
703
     * caller - {Object} Optional object to be set as this when the callback
704
     *     is called.
705
     *
706
     * Returns:
707
     * {Array} An array of elements from the passed in array for which the
708
     *     callback returns true.
709
     */
710
    filter: function(array, callback, caller) {
711
        var selected = [];
712
        if (Array.prototype.filter) {
713
            selected = array.filter(callback, caller);
714
        } else {
715
            var len = array.length;
716
            if (typeof callback != "function") {
717
                throw new TypeError();
718
            }
719
            for(var i=0; i<len; i++) {
720
                if (i in array) {
721
                    var val = array[i];
722
                    if (callback.call(caller, val, i, array)) {
723
                        selected.push(val);
724
                    }
725
                }
726
            }        
727
        }
728
        return selected;
729
    }
730
    
731
};
732
/* ======================================================================
733
    OpenLayers/BaseTypes/Bounds.js
734
   ====================================================================== */
735

  
736
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
737
 * full list of contributors). Published under the 2-clause BSD license.
738
 * See license.txt in the OpenLayers distribution or repository for the
739
 * full text of the license. */
740

  
741
/**
742
 * @requires OpenLayers/BaseTypes/Class.js
743
 */
744

  
745
/**
746
 * Class: OpenLayers.Bounds
747
 * Instances of this class represent bounding boxes.  Data stored as left,
748
 * bottom, right, top floats. All values are initialized to null, however,
749
 * you should make sure you set them before using the bounds for anything.
750
 * 
751
 * Possible use case:
752
 * (code)
753
 *     bounds = new OpenLayers.Bounds();
754
 *     bounds.extend(new OpenLayers.LonLat(4,5));
755
 *     bounds.extend(new OpenLayers.LonLat(5,6));
756
 *     bounds.toBBOX(); // returns 4,5,5,6
757
 * (end)
758
 */
759
OpenLayers.Bounds = OpenLayers.Class({
760

  
761
    /**
762
     * Property: left
763
     * {Number} Minimum horizontal coordinate.
764
     */
765
    left: null,
766

  
767
    /**
768
     * Property: bottom
769
     * {Number} Minimum vertical coordinate.
770
     */
771
    bottom: null,
772

  
773
    /**
774
     * Property: right
775
     * {Number} Maximum horizontal coordinate.
776
     */
777
    right: null,
778

  
779
    /**
780
     * Property: top
781
     * {Number} Maximum vertical coordinate.
782
     */
783
    top: null,
784
    
785
    /**
786
     * Property: centerLonLat
787
     * {<OpenLayers.LonLat>} A cached center location.  This should not be
788
     *     accessed directly.  Use <getCenterLonLat> instead.
789
     */
790
    centerLonLat: null,
791

  
792
    /**
793
     * Constructor: OpenLayers.Bounds
794
     * Construct a new bounds object. Coordinates can either be passed as four
795
     * arguments, or as a single argument.
796
     *
797
     * Parameters (four arguments):
798
     * left - {Number} The left bounds of the box.  Note that for width
799
     *        calculations, this is assumed to be less than the right value.
800
     * bottom - {Number} The bottom bounds of the box.  Note that for height
801
     *          calculations, this is assumed to be less than the top value.
802
     * right - {Number} The right bounds.
803
     * top - {Number} The top bounds.
804
     *
805
     * Parameters (single argument):
806
     * bounds - {Array(Number)} [left, bottom, right, top]
807
     */
808
    initialize: function(left, bottom, right, top) {
809
        if (OpenLayers.Util.isArray(left)) {
810
            top = left[3];
811
            right = left[2];
812
            bottom = left[1];
813
            left = left[0];
814
        }
815
        if (left != null) {
816
            this.left = OpenLayers.Util.toFloat(left);
817
        }
818
        if (bottom != null) {
819
            this.bottom = OpenLayers.Util.toFloat(bottom);
820
        }
821
        if (right != null) {
822
            this.right = OpenLayers.Util.toFloat(right);
823
        }
824
        if (top != null) {
825
            this.top = OpenLayers.Util.toFloat(top);
826
        }
827
    },
828

  
829
    /**
830
     * Method: clone
831
     * Create a cloned instance of this bounds.
832
     *
833
     * Returns:
834
     * {<OpenLayers.Bounds>} A fresh copy of the bounds
835
     */
836
    clone:function() {
837
        return new OpenLayers.Bounds(this.left, this.bottom, 
838
                                     this.right, this.top);
839
    },
840

  
841
    /**
842
     * Method: equals
843
     * Test a two bounds for equivalence.
844
     *
845
     * Parameters:
846
     * bounds - {<OpenLayers.Bounds>}
847
     *
848
     * Returns:
849
     * {Boolean} The passed-in bounds object has the same left,
850
     *           right, top, bottom components as this.  Note that if bounds 
851
     *           passed in is null, returns false.
852
     */
853
    equals:function(bounds) {
854
        var equals = false;
855
        if (bounds != null) {
856
            equals = ((this.left == bounds.left) && 
857
                      (this.right == bounds.right) &&
858
                      (this.top == bounds.top) && 
859
                      (this.bottom == bounds.bottom));
860
        }
861
        return equals;
862
    },
863

  
864
    /** 
865
     * APIMethod: toString
866
     * Returns a string representation of the bounds object.
867
     * 
868
     * Returns:
869
     * {String} String representation of bounds object. 
870
     */
871
    toString:function() {
872
        return [this.left, this.bottom, this.right, this.top].join(",");
873
    },
874

  
875
    /**
876
     * APIMethod: toArray
877
     * Returns an array representation of the bounds object.
878
     *
879
     * Returns an array of left, bottom, right, top properties, or -- when the
880
     *     optional parameter is true -- an array of the  bottom, left, top,
881
     *     right properties.
882
     *
883
     * Parameters:
884
     * reverseAxisOrder - {Boolean} Should we reverse the axis order?
885
     *
886
     * Returns:
887
     * {Array} array of left, bottom, right, top
888
     */
889
    toArray: function(reverseAxisOrder) {
890
        if (reverseAxisOrder === true) {
891
            return [this.bottom, this.left, this.top, this.right];
892
        } else {
893
            return [this.left, this.bottom, this.right, this.top];
894
        }
895
    },    
896

  
897
    /** 
898
     * APIMethod: toBBOX
899
     * Returns a boundingbox-string representation of the bounds object.
900
     * 
901
     * Parameters:
902
     * decimal - {Integer} How many significant digits in the bbox coords?
903
     *                     Default is 6
904
     * reverseAxisOrder - {Boolean} Should we reverse the axis order?
905
     * 
906
     * Returns:
907
     * {String} Simple String representation of bounds object.
908
     *          (e.g. "5,42,10,45")
909
     */
910
    toBBOX:function(decimal, reverseAxisOrder) {
911
        if (decimal== null) {
912
            decimal = 6; 
913
        }
914
        var mult = Math.pow(10, decimal);
915
        var xmin = Math.round(this.left * mult) / mult;
916
        var ymin = Math.round(this.bottom * mult) / mult;
917
        var xmax = Math.round(this.right * mult) / mult;
918
        var ymax = Math.round(this.top * mult) / mult;
919
        if (reverseAxisOrder === true) {
920
            return ymin + "," + xmin + "," + ymax + "," + xmax;
921
        } else {
922
            return xmin + "," + ymin + "," + xmax + "," + ymax;
923
        }
924
    },
925
 
926
    /**
927
     * APIMethod: toGeometry
928
     * Create a new polygon geometry based on this bounds.
929
     *
930
     * Returns:
931
     * {<OpenLayers.Geometry.Polygon>} A new polygon with the coordinates
932
     *     of this bounds.
933
     */
934
    toGeometry: function() {
935
        return new OpenLayers.Geometry.Polygon([
936
            new OpenLayers.Geometry.LinearRing([
937
                new OpenLayers.Geometry.Point(this.left, this.bottom),
938
                new OpenLayers.Geometry.Point(this.right, this.bottom),
939
                new OpenLayers.Geometry.Point(this.right, this.top),
940
                new OpenLayers.Geometry.Point(this.left, this.top)
941
            ])
942
        ]);
943
    },
944
    
945
    /**
946
     * APIMethod: getWidth
947
     * Returns the width of the bounds.
948
     * 
949
     * Returns:
950
     * {Float} The width of the bounds (right minus left).
951
     */
952
    getWidth:function() {
953
        return (this.right - this.left);
954
    },
955

  
956
    /**
957
     * APIMethod: getHeight
958
     * Returns the height of the bounds.
959
     * 
960
     * Returns:
961
     * {Float} The height of the bounds (top minus bottom).
962
     */
963
    getHeight:function() {
964
        return (this.top - this.bottom);
965
    },
966

  
967
    /**
968
     * APIMethod: getSize
969
     * Returns an <OpenLayers.Size> object of the bounds.
970
     * 
971
     * Returns:
972
     * {<OpenLayers.Size>} The size of the bounds.
973
     */
974
    getSize:function() {
975
        return new OpenLayers.Size(this.getWidth(), this.getHeight());
976
    },
977

  
978
    /**
979
     * APIMethod: getCenterPixel
980
     * Returns the <OpenLayers.Pixel> object which represents the center of the
981
     *     bounds.
982
     * 
983
     * Returns:
984
     * {<OpenLayers.Pixel>} The center of the bounds in pixel space.
985
     */
986
    getCenterPixel:function() {
987
        return new OpenLayers.Pixel( (this.left + this.right) / 2,
988
                                     (this.bottom + this.top) / 2);
989
    },
990

  
991
    /**
992
     * APIMethod: getCenterLonLat
993
     * Returns the <OpenLayers.LonLat> object which represents the center of the
994
     *     bounds.
995
     *
996
     * Returns:
997
     * {<OpenLayers.LonLat>} The center of the bounds in map space.
998
     */
999
    getCenterLonLat:function() {
1000
        if(!this.centerLonLat) {
1001
            this.centerLonLat = new OpenLayers.LonLat(
1002
                (this.left + this.right) / 2, (this.bottom + this.top) / 2
1003
            );
1004
        }
1005
        return this.centerLonLat;
1006
    },
1007

  
1008
    /**
1009
     * APIMethod: scale
1010
     * Scales the bounds around a pixel or lonlat. Note that the new 
1011
     *     bounds may return non-integer properties, even if a pixel
1012
     *     is passed. 
1013
     * 
1014
     * Parameters:
1015
     * ratio - {Float} 
1016
     * origin - {<OpenLayers.Pixel> or <OpenLayers.LonLat>}
1017
     *          Default is center.
1018
     *
1019
     * Returns:
1020
     * {<OpenLayers.Bounds>} A new bounds that is scaled by ratio
1021
     *                      from origin.
1022
     */
1023
    scale: function(ratio, origin){
1024
        if(origin == null){
1025
            origin = this.getCenterLonLat();
1026
        }
1027
        
1028
        var origx,origy;
1029

  
1030
        // get origin coordinates
1031
        if(origin.CLASS_NAME == "OpenLayers.LonLat"){
1032
            origx = origin.lon;
1033
            origy = origin.lat;
1034
        } else {
1035
            origx = origin.x;
1036
            origy = origin.y;
1037
        }
1038

  
1039
        var left = (this.left - origx) * ratio + origx;
1040
        var bottom = (this.bottom - origy) * ratio + origy;
1041
        var right = (this.right - origx) * ratio + origx;
1042
        var top = (this.top - origy) * ratio + origy;
1043
        
1044
        return new OpenLayers.Bounds(left, bottom, right, top);
1045
    },
1046

  
1047
    /**
1048
     * APIMethod: add
1049
     * Shifts the coordinates of the bound by the given horizontal and vertical
1050
     *     deltas.
1051
     *
1052
     * (start code)
1053
     * var bounds = new OpenLayers.Bounds(0, 0, 10, 10);
1054
     * bounds.toString();
1055
     * // => "0,0,10,10"
1056
     *
1057
     * bounds.add(-1.5, 4).toString();
1058
     * // => "-1.5,4,8.5,14"
1059
     * (end)
1060
     *
1061
     * This method will throw a TypeError if it is passed null as an argument.
1062
     *
1063
     * Parameters:
1064
     * x - {Float} horizontal delta
1065
     * y - {Float} vertical delta
1066
     *
1067
     * Returns:
1068
     * {<OpenLayers.Bounds>} A new bounds whose coordinates are the same as
1069
     *     this, but shifted by the passed-in x and y values.
1070
     */
1071
    add:function(x, y) {
1072
        if ( (x == null) || (y == null) ) {
1073
            throw new TypeError('Bounds.add cannot receive null values');
1074
        }
1075
        return new OpenLayers.Bounds(this.left + x, this.bottom + y,
1076
                                     this.right + x, this.top + y);
1077
    },
1078
    
1079
    /**
1080
     * APIMethod: extend
1081
     * Extend the bounds to include the <OpenLayers.LonLat>,
1082
     *     <OpenLayers.Geometry.Point> or <OpenLayers.Bounds> specified.
1083
     *
1084
     * Please note that this function assumes that left < right and
1085
     *     bottom < top.
1086
     *
1087
     * Parameters:
1088
     * object - {<OpenLayers.LonLat>, <OpenLayers.Geometry.Point> or
1089
     *     <OpenLayers.Bounds>} The object to be included in the new bounds
1090
     *     object.
1091
     */
1092
    extend:function(object) {
1093
        if (object) {
1094
            switch(object.CLASS_NAME) {
1095
                case "OpenLayers.LonLat":
1096
                    this.extendXY(object.lon, object.lat);
1097
                    break;
1098
                case "OpenLayers.Geometry.Point":
1099
                    this.extendXY(object.x, object.y);
1100
                    break;
1101

  
1102
                case "OpenLayers.Bounds":
1103
                    // clear cached center location
1104
                    this.centerLonLat = null;
1105

  
1106
                    if ( (this.left == null) || (object.left < this.left)) {
1107
                        this.left = object.left;
1108
                    }
1109
                    if ( (this.bottom == null) || (object.bottom < this.bottom) ) {
1110
                        this.bottom = object.bottom;
1111
                    }
1112
                    if ( (this.right == null) || (object.right > this.right) ) {
1113
                        this.right = object.right;
1114
                    }
1115
                    if ( (this.top == null) || (object.top > this.top) ) {
1116
                        this.top = object.top;
1117
                    }
1118
                    break;
1119
            }
1120
        }
1121
    },
1122

  
1123
    /**
1124
     * APIMethod: extendXY
1125
     * Extend the bounds to include the XY coordinate specified.
1126
     *
1127
     * Parameters:
1128
     * x - {number} The X part of the the coordinate.
1129
     * y - {number} The Y part of the the coordinate.
1130
     */
1131
    extendXY:function(x, y) {
1132
        // clear cached center location
1133
        this.centerLonLat = null;
1134

  
1135
        if ((this.left == null) || (x < this.left)) {
1136
            this.left = x;
1137
        }
1138
        if ((this.bottom == null) || (y < this.bottom)) {
1139
            this.bottom = y;
1140
        }
1141
        if ((this.right == null) || (x > this.right)) {
1142
            this.right = x;
1143
        }
1144
        if ((this.top == null) || (y > this.top)) {
1145
            this.top = y;
1146
        }
1147
    },
1148

  
1149
    /**
1150
     * APIMethod: containsLonLat
1151
     * Returns whether the bounds object contains the given <OpenLayers.LonLat>.
1152
     * 
1153
     * Parameters:
1154
     * ll - {<OpenLayers.LonLat>|Object} OpenLayers.LonLat or an
1155
     *     object with a 'lon' and 'lat' properties.
1156
     * options - {Object} Optional parameters
1157
     *
1158
     * Acceptable options:
1159
     * inclusive - {Boolean} Whether or not to include the border.
1160
     *     Default is true.
1161
     * worldBounds - {<OpenLayers.Bounds>} If a worldBounds is provided, the
1162
     *     ll will be considered as contained if it exceeds the world bounds,
1163
     *     but can be wrapped around the dateline so it is contained by this
1164
     *     bounds.
1165
     *
1166
     * Returns:
1167
     * {Boolean} The passed-in lonlat is within this bounds.
1168
     */
1169
    containsLonLat: function(ll, options) {
1170
        if (typeof options === "boolean") {
1171
            options =  {inclusive: options};
1172
        }
1173
        options = options || {};
1174
        var contains = this.contains(ll.lon, ll.lat, options.inclusive),
1175
            worldBounds = options.worldBounds;
1176
        if (worldBounds && !contains) {
1177
            var worldWidth = worldBounds.getWidth();
1178
            var worldCenterX = (worldBounds.left + worldBounds.right) / 2;
1179
            var worldsAway = Math.round((ll.lon - worldCenterX) / worldWidth);
1180
            contains = this.containsLonLat({
1181
                lon: ll.lon - worldsAway * worldWidth,
1182
                lat: ll.lat
1183
            }, {inclusive: options.inclusive});
1184
        }
1185
        return contains;
1186
    },
1187

  
1188
    /**
1189
     * APIMethod: containsPixel
1190
     * Returns whether the bounds object contains the given <OpenLayers.Pixel>.
1191
     * 
1192
     * Parameters:
1193
     * px - {<OpenLayers.Pixel>}
1194
     * inclusive - {Boolean} Whether or not to include the border. Default is
1195
     *     true.
1196
     *
1197
     * Returns:
1198
     * {Boolean} The passed-in pixel is within this bounds.
1199
     */
1200
    containsPixel:function(px, inclusive) {
1201
        return this.contains(px.x, px.y, inclusive);
1202
    },
1203
    
1204
    /**
1205
     * APIMethod: contains
1206
     * Returns whether the bounds object contains the given x and y.
1207
     * 
1208
     * Parameters:
1209
     * x - {Float}
1210
     * y - {Float}
1211
     * inclusive - {Boolean} Whether or not to include the border. Default is
1212
     *     true.
1213
     *
1214
     * Returns:
1215
     * {Boolean} Whether or not the passed-in coordinates are within this
1216
     *     bounds.
1217
     */
1218
    contains:function(x, y, inclusive) {
1219
        //set default
1220
        if (inclusive == null) {
1221
            inclusive = true;
1222
        }
1223

  
1224
        if (x == null || y == null) {
1225
            return false;
1226
        }
1227

  
1228
        x = OpenLayers.Util.toFloat(x);
1229
        y = OpenLayers.Util.toFloat(y);
1230

  
1231
        var contains = false;
1232
        if (inclusive) {
1233
            contains = ((x >= this.left) && (x <= this.right) && 
1234
                        (y >= this.bottom) && (y <= this.top));
1235
        } else {
1236
            contains = ((x > this.left) && (x < this.right) && 
1237
                        (y > this.bottom) && (y < this.top));
1238
        }              
1239
        return contains;
1240
    },
1241

  
1242
    /**
1243
     * APIMethod: intersectsBounds
1244
     * Determine whether the target bounds intersects this bounds.  Bounds are
1245
     *     considered intersecting if any of their edges intersect or if one
1246
     *     bounds contains the other.
1247
     * 
1248
     * Parameters:
1249
     * bounds - {<OpenLayers.Bounds>} The target bounds.
1250
     * options - {Object} Optional parameters.
1251
     * 
1252
     * Acceptable options:
1253
     * inclusive - {Boolean} Treat coincident borders as intersecting.  Default
1254
     *     is true.  If false, bounds that do not overlap but only touch at the
1255
     *     border will not be considered as intersecting.
1256
     * worldBounds - {<OpenLayers.Bounds>} If a worldBounds is provided, two
1257
     *     bounds will be considered as intersecting if they intersect when 
1258
     *     shifted to within the world bounds.  This applies only to bounds that
1259
     *     cross or are completely outside the world bounds.
1260
     *
1261
     * Returns:
1262
     * {Boolean} The passed-in bounds object intersects this bounds.
1263
     */
1264
    intersectsBounds:function(bounds, options) {
1265
        if (typeof options === "boolean") {
1266
            options =  {inclusive: options};
1267
        }
1268
        options = options || {};
1269
        if (options.worldBounds) {
1270
            var self = this.wrapDateLine(options.worldBounds);
1271
            bounds = bounds.wrapDateLine(options.worldBounds);
1272
        } else {
1273
            self = this;
1274
        }
1275
        if (options.inclusive == null) {
1276
            options.inclusive = true;
1277
        }
1278
        var intersects = false;
1279
        var mightTouch = (
1280
            self.left == bounds.right ||
1281
            self.right == bounds.left ||
1282
            self.top == bounds.bottom ||
1283
            self.bottom == bounds.top
1284
        );
1285
        
1286
        // if the two bounds only touch at an edge, and inclusive is false,
1287
        // then the bounds don't *really* intersect.
1288
        if (options.inclusive || !mightTouch) {
1289
            // otherwise, if one of the boundaries even partially contains another,
1290
            // inclusive of the edges, then they do intersect.
1291
            var inBottom = (
1292
                ((bounds.bottom >= self.bottom) && (bounds.bottom <= self.top)) ||
1293
                ((self.bottom >= bounds.bottom) && (self.bottom <= bounds.top))
1294
            );
1295
            var inTop = (
1296
                ((bounds.top >= self.bottom) && (bounds.top <= self.top)) ||
1297
                ((self.top > bounds.bottom) && (self.top < bounds.top))
1298
            );
1299
            var inLeft = (
1300
                ((bounds.left >= self.left) && (bounds.left <= self.right)) ||
1301
                ((self.left >= bounds.left) && (self.left <= bounds.right))
1302
            );
1303
            var inRight = (
1304
                ((bounds.right >= self.left) && (bounds.right <= self.right)) ||
1305
                ((self.right >= bounds.left) && (self.right <= bounds.right))
1306
            );
1307
            intersects = ((inBottom || inTop) && (inLeft || inRight));
1308
        }
1309
        // document me
1310
        if (options.worldBounds && !intersects) {
1311
            var world = options.worldBounds;
1312
            var width = world.getWidth();
1313
            var selfCrosses = !world.containsBounds(self);
1314
            var boundsCrosses = !world.containsBounds(bounds);
1315
            if (selfCrosses && !boundsCrosses) {
1316
                bounds = bounds.add(-width, 0);
1317
                intersects = self.intersectsBounds(bounds, {inclusive: options.inclusive});
1318
            } else if (boundsCrosses && !selfCrosses) {
1319
                self = self.add(-width, 0);
1320
                intersects = bounds.intersectsBounds(self, {inclusive: options.inclusive});                
1321
            }
1322
        }
1323
        return intersects;
1324
    },
1325
    
1326
    /**
1327
     * APIMethod: containsBounds
1328
     * Returns whether the bounds object contains the given <OpenLayers.Bounds>.
1329
     * 
1330
     * bounds - {<OpenLayers.Bounds>} The target bounds.
1331
     * partial - {Boolean} If any of the target corners is within this bounds
1332
     *     consider the bounds contained.  Default is false.  If false, the
1333
     *     entire target bounds must be contained within this bounds.
1334
     * inclusive - {Boolean} Treat shared edges as contained.  Default is
1335
     *     true.
1336
     *
1337
     * Returns:
1338
     * {Boolean} The passed-in bounds object is contained within this bounds. 
1339
     */
1340
    containsBounds:function(bounds, partial, inclusive) {
1341
        if (partial == null) {
1342
            partial = false;
1343
        }
1344
        if (inclusive == null) {
1345
            inclusive = true;
1346
        }
1347
        var bottomLeft  = this.contains(bounds.left, bounds.bottom, inclusive);
1348
        var bottomRight = this.contains(bounds.right, bounds.bottom, inclusive);
1349
        var topLeft  = this.contains(bounds.left, bounds.top, inclusive);
1350
        var topRight = this.contains(bounds.right, bounds.top, inclusive);
1351
        
1352
        return (partial) ? (bottomLeft || bottomRight || topLeft || topRight)
1353
                         : (bottomLeft && bottomRight && topLeft && topRight);
1354
    },
1355

  
1356
    /** 
1357
     * APIMethod: determineQuadrant
1358
     * Returns the the quadrant ("br", "tr", "tl", "bl") in which the given
1359
     *     <OpenLayers.LonLat> lies.
1360
     *
1361
     * Parameters:
1362
     * lonlat - {<OpenLayers.LonLat>}
1363
     *
1364
     * Returns:
1365
     * {String} The quadrant ("br" "tr" "tl" "bl") of the bounds in which the
1366
     *     coordinate lies.
1367
     */
1368
    determineQuadrant: function(lonlat) {
1369
    
1370
        var quadrant = "";
1371
        var center = this.getCenterLonLat();
1372
        
1373
        quadrant += (lonlat.lat < center.lat) ? "b" : "t";
1374
        quadrant += (lonlat.lon < center.lon) ? "l" : "r";
1375
    
1376
        return quadrant; 
1377
    },
1378
    
1379
    /**
1380
     * APIMethod: transform
1381
     * Transform the Bounds object from source to dest. 
1382
     *
1383
     * Parameters: 
1384
     * source - {<OpenLayers.Projection>} Source projection. 
1385
     * dest   - {<OpenLayers.Projection>} Destination projection. 
1386
     *
1387
     * Returns:
1388
     * {<OpenLayers.Bounds>} Itself, for use in chaining operations.
1389
     */
1390
    transform: function(source, dest) {
1391
        // clear cached center location
1392
        this.centerLonLat = null;
1393
        var ll = OpenLayers.Projection.transform(
1394
            {'x': this.left, 'y': this.bottom}, source, dest);
1395
        var lr = OpenLayers.Projection.transform(
1396
            {'x': this.right, 'y': this.bottom}, source, dest);
1397
        var ul = OpenLayers.Projection.transform(
1398
            {'x': this.left, 'y': this.top}, source, dest);
1399
        var ur = OpenLayers.Projection.transform(
1400
            {'x': this.right, 'y': this.top}, source, dest);
1401
        this.left   = Math.min(ll.x, ul.x);
1402
        this.bottom = Math.min(ll.y, lr.y);
1403
        this.right  = Math.max(lr.x, ur.x);
1404
        this.top    = Math.max(ul.y, ur.y);
1405
        return this;
1406
    },
1407

  
1408
    /**
1409
     * APIMethod: wrapDateLine
1410
     * Wraps the bounds object around the dateline.
1411
     *  
1412
     * Parameters:
1413
     * maxExtent - {<OpenLayers.Bounds>}
1414
     * options - {Object} Some possible options are:
1415
     *
1416
     * Allowed Options:
1417
     *                    leftTolerance - {float} Allow for a margin of error 
1418
     *                                            with the 'left' value of this 
1419
     *                                            bound.
1420
     *                                            Default is 0.
1421
     *                    rightTolerance - {float} Allow for a margin of error 
1422
     *                                             with the 'right' value of 
1423
     *                                             this bound.
1424
     *                                             Default is 0.
1425
     * 
1426
     * Returns:
1427
     * {<OpenLayers.Bounds>} A copy of this bounds, but wrapped around the 
1428
     *                       "dateline" (as specified by the borders of 
1429
     *                       maxExtent). Note that this function only returns 
1430
     *                       a different bounds value if this bounds is 
1431
     *                       *entirely* outside of the maxExtent. If this 
1432
     *                       bounds straddles the dateline (is part in/part 
1433
     *                       out of maxExtent), the returned bounds will always 
1434
     *                       cross the left edge of the given maxExtent.
1435
     *.
1436
     */
1437
    wrapDateLine: function(maxExtent, options) {    
1438
        options = options || {};
1439
        
1440
        var leftTolerance = options.leftTolerance || 0;
1441
        var rightTolerance = options.rightTolerance || 0;
1442

  
1443
        var newBounds = this.clone();
1444
    
1445
        if (maxExtent) {
1446
            var width = maxExtent.getWidth();
1447

  
1448
            //shift right?
1449
            while (newBounds.left < maxExtent.left && 
1450
                   newBounds.right - rightTolerance <= maxExtent.left ) { 
1451
                newBounds = newBounds.add(width, 0);
1452
            }
1453

  
1454
            //shift left?
1455
            while (newBounds.left + leftTolerance >= maxExtent.right && 
1456
                   newBounds.right > maxExtent.right ) { 
1457
                newBounds = newBounds.add(-width, 0);
1458
            }
1459
           
1460
            // crosses right only? force left
1461
            var newLeft = newBounds.left + leftTolerance;
1462
            if (newLeft < maxExtent.right && newLeft > maxExtent.left && 
1463
                   newBounds.right - rightTolerance > maxExtent.right) {
1464
                newBounds = newBounds.add(-width, 0);
1465
            }
1466
        }
1467
                
1468
        return newBounds;
1469
    },
1470

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff