--- /srv/reproducible-results/rbuild-debian/r-b-build.vNGFDogr/b1/openlayers_2.13.1+ds2-10_i386.changes
+++ /srv/reproducible-results/rbuild-debian/r-b-build.vNGFDogr/b2/openlayers_2.13.1+ds2-10_i386.changes
├── Files
│ @@ -1,2 +1,2 @@
│
│ - cb91a6b8575e4068f69c2c211e993efc 724396 javascript optional libjs-openlayers_2.13.1+ds2-10_all.deb
│ + e10e99197b80e8001ad4aeb43e1d6b32 721476 javascript optional libjs-openlayers_2.13.1+ds2-10_all.deb
├── libjs-openlayers_2.13.1+ds2-10_all.deb
│ ├── file list
│ │ @@ -1,3 +1,3 @@
│ │ -rw-r--r-- 0 0 0 4 2023-01-14 13:27:41.000000 debian-binary
│ │ --rw-r--r-- 0 0 0 3676 2023-01-14 13:27:41.000000 control.tar.xz
│ │ --rw-r--r-- 0 0 0 720528 2023-01-14 13:27:41.000000 data.tar.xz
│ │ +-rw-r--r-- 0 0 0 3680 2023-01-14 13:27:41.000000 control.tar.xz
│ │ +-rw-r--r-- 0 0 0 717604 2023-01-14 13:27:41.000000 data.tar.xz
│ ├── control.tar.xz
│ │ ├── control.tar
│ │ │ ├── ./md5sums
│ │ │ │ ├── ./md5sums
│ │ │ │ │┄ Files differ
│ ├── data.tar.xz
│ │ ├── data.tar
│ │ │ ├── ./usr/share/javascript/openlayers/OpenLayers.js
│ │ │ │ ├── js-beautify {}
│ │ │ │ │ @@ -52,14 +52,37 @@
│ │ │ │ │ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
│ │ │ │ │ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
│ │ │ │ │ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
│ │ │ │ │ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
│ │ │ │ │ * POSSIBILITY OF SUCH DAMAGE.
│ │ │ │ │ */
│ │ │ │ │ /* ======================================================================
│ │ │ │ │ + Rico/license.js
│ │ │ │ │ + ====================================================================== */
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * @license Apache 2
│ │ │ │ │ + *
│ │ │ │ │ + * Contains portions of Rico
│ │ │ │ │ + *
│ │ │ │ │ + * Copyright 2005 Sabre Airline Solutions
│ │ │ │ │ + *
│ │ │ │ │ + * Licensed under the Apache License, Version 2.0 (the "License"); you
│ │ │ │ │ + * may not use this file except in compliance with the License. You
│ │ │ │ │ + * may obtain a copy of the License at
│ │ │ │ │ + *
│ │ │ │ │ + * http://www.apache.org/licenses/LICENSE-2.0
│ │ │ │ │ + *
│ │ │ │ │ + * Unless required by applicable law or agreed to in writing, software
│ │ │ │ │ + * distributed under the License is distributed on an "AS IS" BASIS,
│ │ │ │ │ + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
│ │ │ │ │ + * implied. See the License for the specific language governing
│ │ │ │ │ + * permissions and limitations under the License.
│ │ │ │ │ + */
│ │ │ │ │ +/* ======================================================================
│ │ │ │ │ OpenLayers/SingleFile.js
│ │ │ │ │ ====================================================================== */
│ │ │ │ │
│ │ │ │ │ /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ * full text of the license. */
│ │ │ │ │ @@ -263,14 +286,268 @@
│ │ │ │ │ source.hasOwnProperty && source.hasOwnProperty("toString")) {
│ │ │ │ │ destination.toString = source.toString;
│ │ │ │ │ }
│ │ │ │ │ }
│ │ │ │ │ return destination;
│ │ │ │ │ };
│ │ │ │ │ /* ======================================================================
│ │ │ │ │ + OpenLayers/Console.js
│ │ │ │ │ + ====================================================================== */
│ │ │ │ │ +
│ │ │ │ │ +/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ + * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ + * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ + * full text of the license. */
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * @requires OpenLayers/BaseTypes/Class.js
│ │ │ │ │ + */
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Namespace: OpenLayers.Console
│ │ │ │ │ + * The OpenLayers.Console namespace is used for debugging and error logging.
│ │ │ │ │ + * If the Firebug Lite (../Firebug/firebug.js) is included before this script,
│ │ │ │ │ + * calls to OpenLayers.Console methods will get redirected to window.console.
│ │ │ │ │ + * This makes use of the Firebug extension where available and allows for
│ │ │ │ │ + * cross-browser debugging Firebug style.
│ │ │ │ │ + *
│ │ │ │ │ + * Note:
│ │ │ │ │ + * Note that behavior will differ with the Firebug extention and Firebug Lite.
│ │ │ │ │ + * Most notably, the Firebug Lite console does not currently allow for
│ │ │ │ │ + * hyperlinks to code or for clicking on object to explore their properties.
│ │ │ │ │ + *
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Console = {
│ │ │ │ │ + /**
│ │ │ │ │ + * Create empty functions for all console methods. The real value of these
│ │ │ │ │ + * properties will be set if Firebug Lite (../Firebug/firebug.js script) is
│ │ │ │ │ + * included. We explicitly require the Firebug Lite script to trigger
│ │ │ │ │ + * functionality of the OpenLayers.Console methods.
│ │ │ │ │ + */
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: log
│ │ │ │ │ + * Log an object in the console. The Firebug Lite console logs string
│ │ │ │ │ + * representation of objects. Given multiple arguments, they will
│ │ │ │ │ + * be cast to strings and logged with a space delimiter. If the first
│ │ │ │ │ + * argument is a string with printf-like formatting, subsequent arguments
│ │ │ │ │ + * will be used in string substitution. Any additional arguments (beyond
│ │ │ │ │ + * the number substituted in a format string) will be appended in a space-
│ │ │ │ │ + * delimited line.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * object - {Object}
│ │ │ │ │ + */
│ │ │ │ │ + log: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: debug
│ │ │ │ │ + * Writes a message to the console, including a hyperlink to the line
│ │ │ │ │ + * where it was called.
│ │ │ │ │ + *
│ │ │ │ │ + * May be called with multiple arguments as with OpenLayers.Console.log().
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * object - {Object}
│ │ │ │ │ + */
│ │ │ │ │ + debug: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: info
│ │ │ │ │ + * Writes a message to the console with the visual "info" icon and color
│ │ │ │ │ + * coding and a hyperlink to the line where it was called.
│ │ │ │ │ + *
│ │ │ │ │ + * May be called with multiple arguments as with OpenLayers.Console.log().
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * object - {Object}
│ │ │ │ │ + */
│ │ │ │ │ + info: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: warn
│ │ │ │ │ + * Writes a message to the console with the visual "warning" icon and
│ │ │ │ │ + * color coding and a hyperlink to the line where it was called.
│ │ │ │ │ + *
│ │ │ │ │ + * May be called with multiple arguments as with OpenLayers.Console.log().
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * object - {Object}
│ │ │ │ │ + */
│ │ │ │ │ + warn: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: error
│ │ │ │ │ + * Writes a message to the console with the visual "error" icon and color
│ │ │ │ │ + * coding and a hyperlink to the line where it was called.
│ │ │ │ │ + *
│ │ │ │ │ + * May be called with multiple arguments as with OpenLayers.Console.log().
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * object - {Object}
│ │ │ │ │ + */
│ │ │ │ │ + error: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: userError
│ │ │ │ │ + * A single interface for showing error messages to the user. The default
│ │ │ │ │ + * behavior is a Javascript alert, though this can be overridden by
│ │ │ │ │ + * reassigning OpenLayers.Console.userError to a different function.
│ │ │ │ │ + *
│ │ │ │ │ + * Expects a single error message
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * error - {Object}
│ │ │ │ │ + */
│ │ │ │ │ + userError: function(error) {
│ │ │ │ │ + alert(error);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: assert
│ │ │ │ │ + * Tests that an expression is true. If not, it will write a message to
│ │ │ │ │ + * the console and throw an exception.
│ │ │ │ │ + *
│ │ │ │ │ + * May be called with multiple arguments as with OpenLayers.Console.log().
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * object - {Object}
│ │ │ │ │ + */
│ │ │ │ │ + assert: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: dir
│ │ │ │ │ + * Prints an interactive listing of all properties of the object. This
│ │ │ │ │ + * looks identical to the view that you would see in the DOM tab.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * object - {Object}
│ │ │ │ │ + */
│ │ │ │ │ + dir: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: dirxml
│ │ │ │ │ + * Prints the XML source tree of an HTML or XML element. This looks
│ │ │ │ │ + * identical to the view that you would see in the HTML tab. You can click
│ │ │ │ │ + * on any node to inspect it in the HTML tab.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * object - {Object}
│ │ │ │ │ + */
│ │ │ │ │ + dirxml: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: trace
│ │ │ │ │ + * Prints an interactive stack trace of JavaScript execution at the point
│ │ │ │ │ + * where it is called. The stack trace details the functions on the stack,
│ │ │ │ │ + * as well as the values that were passed as arguments to each function.
│ │ │ │ │ + * You can click each function to take you to its source in the Script tab,
│ │ │ │ │ + * and click each argument value to inspect it in the DOM or HTML tabs.
│ │ │ │ │ + *
│ │ │ │ │ + */
│ │ │ │ │ + trace: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: group
│ │ │ │ │ + * Writes a message to the console and opens a nested block to indent all
│ │ │ │ │ + * future messages sent to the console. Call OpenLayers.Console.groupEnd()
│ │ │ │ │ + * to close the block.
│ │ │ │ │ + *
│ │ │ │ │ + * May be called with multiple arguments as with OpenLayers.Console.log().
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * object - {Object}
│ │ │ │ │ + */
│ │ │ │ │ + group: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: groupEnd
│ │ │ │ │ + * Closes the most recently opened block created by a call to
│ │ │ │ │ + * OpenLayers.Console.group
│ │ │ │ │ + */
│ │ │ │ │ + groupEnd: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: time
│ │ │ │ │ + * Creates a new timer under the given name. Call
│ │ │ │ │ + * OpenLayers.Console.timeEnd(name)
│ │ │ │ │ + * with the same name to stop the timer and print the time elapsed.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * name - {String}
│ │ │ │ │ + */
│ │ │ │ │ + time: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: timeEnd
│ │ │ │ │ + * Stops a timer created by a call to OpenLayers.Console.time(name) and
│ │ │ │ │ + * writes the time elapsed.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * name - {String}
│ │ │ │ │ + */
│ │ │ │ │ + timeEnd: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: profile
│ │ │ │ │ + * Turns on the JavaScript profiler. The optional argument title would
│ │ │ │ │ + * contain the text to be printed in the header of the profile report.
│ │ │ │ │ + *
│ │ │ │ │ + * This function is not currently implemented in Firebug Lite.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * title - {String} Optional title for the profiler
│ │ │ │ │ + */
│ │ │ │ │ + profile: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: profileEnd
│ │ │ │ │ + * Turns off the JavaScript profiler and prints its report.
│ │ │ │ │ + *
│ │ │ │ │ + * This function is not currently implemented in Firebug Lite.
│ │ │ │ │ + */
│ │ │ │ │ + profileEnd: function() {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: count
│ │ │ │ │ + * Writes the number of times that the line of code where count was called
│ │ │ │ │ + * was executed. The optional argument title will print a message in
│ │ │ │ │ + * addition to the number of the count.
│ │ │ │ │ + *
│ │ │ │ │ + * This function is not currently implemented in Firebug Lite.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * title - {String} Optional title to be printed with count
│ │ │ │ │ + */
│ │ │ │ │ + count: function() {},
│ │ │ │ │ +
│ │ │ │ │ + CLASS_NAME: "OpenLayers.Console"
│ │ │ │ │ +};
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Execute an anonymous function to extend the OpenLayers.Console namespace
│ │ │ │ │ + * if the firebug.js script is included. This closure is used so that the
│ │ │ │ │ + * "scripts" and "i" variables don't pollute the global namespace.
│ │ │ │ │ + */
│ │ │ │ │ +(function() {
│ │ │ │ │ + /**
│ │ │ │ │ + * If Firebug Lite is included (before this script), re-route all
│ │ │ │ │ + * OpenLayers.Console calls to the console object.
│ │ │ │ │ + */
│ │ │ │ │ + var scripts = document.getElementsByTagName("script");
│ │ │ │ │ + for (var i = 0, len = scripts.length; i < len; ++i) {
│ │ │ │ │ + if (scripts[i].src.indexOf("firebug.js") != -1) {
│ │ │ │ │ + if (console) {
│ │ │ │ │ + OpenLayers.Util.extend(OpenLayers.Console, console);
│ │ │ │ │ + break;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ +})();
│ │ │ │ │ +/* ======================================================================
│ │ │ │ │ OpenLayers/BaseTypes.js
│ │ │ │ │ ====================================================================== */
│ │ │ │ │
│ │ │ │ │ /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ * full text of the license. */
│ │ │ │ │ @@ -1589,207 +1866,14 @@
│ │ │ │ │
│ │ │ │ │ opp += (quadrant.charAt(0) == 't') ? 'b' : 't';
│ │ │ │ │ opp += (quadrant.charAt(1) == 'l') ? 'r' : 'l';
│ │ │ │ │
│ │ │ │ │ return opp;
│ │ │ │ │ };
│ │ │ │ │ /* ======================================================================
│ │ │ │ │ - OpenLayers/BaseTypes/Element.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/Util.js
│ │ │ │ │ - * @requires OpenLayers/BaseTypes.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Namespace: OpenLayers.Element
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Element = {
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: visible
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {DOMElement}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} Is the element visible?
│ │ │ │ │ - */
│ │ │ │ │ - visible: function(element) {
│ │ │ │ │ - return OpenLayers.Util.getElement(element).style.display != 'none';
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: toggle
│ │ │ │ │ - * Toggle the visibility of element(s) passed in
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {DOMElement} Actually user can pass any number of elements
│ │ │ │ │ - */
│ │ │ │ │ - toggle: function() {
│ │ │ │ │ - for (var i = 0, len = arguments.length; i < len; i++) {
│ │ │ │ │ - var element = OpenLayers.Util.getElement(arguments[i]);
│ │ │ │ │ - var display = OpenLayers.Element.visible(element) ? 'none' :
│ │ │ │ │ - '';
│ │ │ │ │ - element.style.display = display;
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: remove
│ │ │ │ │ - * Remove the specified element from the DOM.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {DOMElement}
│ │ │ │ │ - */
│ │ │ │ │ - remove: function(element) {
│ │ │ │ │ - element = OpenLayers.Util.getElement(element);
│ │ │ │ │ - element.parentNode.removeChild(element);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: getHeight
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {DOMElement}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Integer} The offset height of the element passed in
│ │ │ │ │ - */
│ │ │ │ │ - getHeight: function(element) {
│ │ │ │ │ - element = OpenLayers.Util.getElement(element);
│ │ │ │ │ - return element.offsetHeight;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Function: hasClass
│ │ │ │ │ - * Tests if an element has the given CSS class name.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {DOMElement} A DOM element node.
│ │ │ │ │ - * name - {String} The CSS class name to search for.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} The element has the given class name.
│ │ │ │ │ - */
│ │ │ │ │ - hasClass: function(element, name) {
│ │ │ │ │ - var names = element.className;
│ │ │ │ │ - return (!!names && new RegExp("(^|\\s)" + name + "(\\s|$)").test(names));
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Function: addClass
│ │ │ │ │ - * Add a CSS class name to an element. Safe where element already has
│ │ │ │ │ - * the class name.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {DOMElement} A DOM element node.
│ │ │ │ │ - * name - {String} The CSS class name to add.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {DOMElement} The element.
│ │ │ │ │ - */
│ │ │ │ │ - addClass: function(element, name) {
│ │ │ │ │ - if (!OpenLayers.Element.hasClass(element, name)) {
│ │ │ │ │ - element.className += (element.className ? " " : "") + name;
│ │ │ │ │ - }
│ │ │ │ │ - return element;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Function: removeClass
│ │ │ │ │ - * Remove a CSS class name from an element. Safe where element does not
│ │ │ │ │ - * have the class name.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {DOMElement} A DOM element node.
│ │ │ │ │ - * name - {String} The CSS class name to remove.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {DOMElement} The element.
│ │ │ │ │ - */
│ │ │ │ │ - removeClass: function(element, name) {
│ │ │ │ │ - var names = element.className;
│ │ │ │ │ - if (names) {
│ │ │ │ │ - element.className = OpenLayers.String.trim(
│ │ │ │ │ - names.replace(
│ │ │ │ │ - new RegExp("(^|\\s+)" + name + "(\\s+|$)"), " "
│ │ │ │ │ - )
│ │ │ │ │ - );
│ │ │ │ │ - }
│ │ │ │ │ - return element;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Function: toggleClass
│ │ │ │ │ - * Remove a CSS class name from an element if it exists. Add the class name
│ │ │ │ │ - * if it doesn't exist.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {DOMElement} A DOM element node.
│ │ │ │ │ - * name - {String} The CSS class name to toggle.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {DOMElement} The element.
│ │ │ │ │ - */
│ │ │ │ │ - toggleClass: function(element, name) {
│ │ │ │ │ - if (OpenLayers.Element.hasClass(element, name)) {
│ │ │ │ │ - OpenLayers.Element.removeClass(element, name);
│ │ │ │ │ - } else {
│ │ │ │ │ - OpenLayers.Element.addClass(element, name);
│ │ │ │ │ - }
│ │ │ │ │ - return element;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: getStyle
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {DOMElement}
│ │ │ │ │ - * style - {?}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {?}
│ │ │ │ │ - */
│ │ │ │ │ - getStyle: function(element, style) {
│ │ │ │ │ - element = OpenLayers.Util.getElement(element);
│ │ │ │ │ -
│ │ │ │ │ - var value = null;
│ │ │ │ │ - if (element && element.style) {
│ │ │ │ │ - value = element.style[OpenLayers.String.camelize(style)];
│ │ │ │ │ - if (!value) {
│ │ │ │ │ - if (document.defaultView &&
│ │ │ │ │ - document.defaultView.getComputedStyle) {
│ │ │ │ │ -
│ │ │ │ │ - var css = document.defaultView.getComputedStyle(element, null);
│ │ │ │ │ - value = css ? css.getPropertyValue(style) : null;
│ │ │ │ │ - } else if (element.currentStyle) {
│ │ │ │ │ - value = element.currentStyle[OpenLayers.String.camelize(style)];
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - var positions = ['left', 'top', 'right', 'bottom'];
│ │ │ │ │ - if (window.opera &&
│ │ │ │ │ - (OpenLayers.Util.indexOf(positions, style) != -1) &&
│ │ │ │ │ - (OpenLayers.Element.getStyle(element, 'position') == 'static')) {
│ │ │ │ │ - value = 'auto';
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - return value == 'auto' ? null : value;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ -};
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ OpenLayers/BaseTypes/LonLat.js
│ │ │ │ │ ====================================================================== */
│ │ │ │ │
│ │ │ │ │ /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ * full text of the license. */
│ │ │ │ │ @@ -2243,268 +2327,14 @@
│ │ │ │ │ }
│ │ │ │ │ return equals;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ CLASS_NAME: "OpenLayers.Size"
│ │ │ │ │ });
│ │ │ │ │ /* ======================================================================
│ │ │ │ │ - OpenLayers/Console.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/BaseTypes/Class.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Namespace: OpenLayers.Console
│ │ │ │ │ - * The OpenLayers.Console namespace is used for debugging and error logging.
│ │ │ │ │ - * If the Firebug Lite (../Firebug/firebug.js) is included before this script,
│ │ │ │ │ - * calls to OpenLayers.Console methods will get redirected to window.console.
│ │ │ │ │ - * This makes use of the Firebug extension where available and allows for
│ │ │ │ │ - * cross-browser debugging Firebug style.
│ │ │ │ │ - *
│ │ │ │ │ - * Note:
│ │ │ │ │ - * Note that behavior will differ with the Firebug extention and Firebug Lite.
│ │ │ │ │ - * Most notably, the Firebug Lite console does not currently allow for
│ │ │ │ │ - * hyperlinks to code or for clicking on object to explore their properties.
│ │ │ │ │ - *
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Console = {
│ │ │ │ │ - /**
│ │ │ │ │ - * Create empty functions for all console methods. The real value of these
│ │ │ │ │ - * properties will be set if Firebug Lite (../Firebug/firebug.js script) is
│ │ │ │ │ - * included. We explicitly require the Firebug Lite script to trigger
│ │ │ │ │ - * functionality of the OpenLayers.Console methods.
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: log
│ │ │ │ │ - * Log an object in the console. The Firebug Lite console logs string
│ │ │ │ │ - * representation of objects. Given multiple arguments, they will
│ │ │ │ │ - * be cast to strings and logged with a space delimiter. If the first
│ │ │ │ │ - * argument is a string with printf-like formatting, subsequent arguments
│ │ │ │ │ - * will be used in string substitution. Any additional arguments (beyond
│ │ │ │ │ - * the number substituted in a format string) will be appended in a space-
│ │ │ │ │ - * delimited line.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * object - {Object}
│ │ │ │ │ - */
│ │ │ │ │ - log: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: debug
│ │ │ │ │ - * Writes a message to the console, including a hyperlink to the line
│ │ │ │ │ - * where it was called.
│ │ │ │ │ - *
│ │ │ │ │ - * May be called with multiple arguments as with OpenLayers.Console.log().
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * object - {Object}
│ │ │ │ │ - */
│ │ │ │ │ - debug: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: info
│ │ │ │ │ - * Writes a message to the console with the visual "info" icon and color
│ │ │ │ │ - * coding and a hyperlink to the line where it was called.
│ │ │ │ │ - *
│ │ │ │ │ - * May be called with multiple arguments as with OpenLayers.Console.log().
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * object - {Object}
│ │ │ │ │ - */
│ │ │ │ │ - info: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: warn
│ │ │ │ │ - * Writes a message to the console with the visual "warning" icon and
│ │ │ │ │ - * color coding and a hyperlink to the line where it was called.
│ │ │ │ │ - *
│ │ │ │ │ - * May be called with multiple arguments as with OpenLayers.Console.log().
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * object - {Object}
│ │ │ │ │ - */
│ │ │ │ │ - warn: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: error
│ │ │ │ │ - * Writes a message to the console with the visual "error" icon and color
│ │ │ │ │ - * coding and a hyperlink to the line where it was called.
│ │ │ │ │ - *
│ │ │ │ │ - * May be called with multiple arguments as with OpenLayers.Console.log().
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * object - {Object}
│ │ │ │ │ - */
│ │ │ │ │ - error: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: userError
│ │ │ │ │ - * A single interface for showing error messages to the user. The default
│ │ │ │ │ - * behavior is a Javascript alert, though this can be overridden by
│ │ │ │ │ - * reassigning OpenLayers.Console.userError to a different function.
│ │ │ │ │ - *
│ │ │ │ │ - * Expects a single error message
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * error - {Object}
│ │ │ │ │ - */
│ │ │ │ │ - userError: function(error) {
│ │ │ │ │ - alert(error);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: assert
│ │ │ │ │ - * Tests that an expression is true. If not, it will write a message to
│ │ │ │ │ - * the console and throw an exception.
│ │ │ │ │ - *
│ │ │ │ │ - * May be called with multiple arguments as with OpenLayers.Console.log().
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * object - {Object}
│ │ │ │ │ - */
│ │ │ │ │ - assert: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: dir
│ │ │ │ │ - * Prints an interactive listing of all properties of the object. This
│ │ │ │ │ - * looks identical to the view that you would see in the DOM tab.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * object - {Object}
│ │ │ │ │ - */
│ │ │ │ │ - dir: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: dirxml
│ │ │ │ │ - * Prints the XML source tree of an HTML or XML element. This looks
│ │ │ │ │ - * identical to the view that you would see in the HTML tab. You can click
│ │ │ │ │ - * on any node to inspect it in the HTML tab.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * object - {Object}
│ │ │ │ │ - */
│ │ │ │ │ - dirxml: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: trace
│ │ │ │ │ - * Prints an interactive stack trace of JavaScript execution at the point
│ │ │ │ │ - * where it is called. The stack trace details the functions on the stack,
│ │ │ │ │ - * as well as the values that were passed as arguments to each function.
│ │ │ │ │ - * You can click each function to take you to its source in the Script tab,
│ │ │ │ │ - * and click each argument value to inspect it in the DOM or HTML tabs.
│ │ │ │ │ - *
│ │ │ │ │ - */
│ │ │ │ │ - trace: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: group
│ │ │ │ │ - * Writes a message to the console and opens a nested block to indent all
│ │ │ │ │ - * future messages sent to the console. Call OpenLayers.Console.groupEnd()
│ │ │ │ │ - * to close the block.
│ │ │ │ │ - *
│ │ │ │ │ - * May be called with multiple arguments as with OpenLayers.Console.log().
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * object - {Object}
│ │ │ │ │ - */
│ │ │ │ │ - group: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: groupEnd
│ │ │ │ │ - * Closes the most recently opened block created by a call to
│ │ │ │ │ - * OpenLayers.Console.group
│ │ │ │ │ - */
│ │ │ │ │ - groupEnd: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: time
│ │ │ │ │ - * Creates a new timer under the given name. Call
│ │ │ │ │ - * OpenLayers.Console.timeEnd(name)
│ │ │ │ │ - * with the same name to stop the timer and print the time elapsed.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * name - {String}
│ │ │ │ │ - */
│ │ │ │ │ - time: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: timeEnd
│ │ │ │ │ - * Stops a timer created by a call to OpenLayers.Console.time(name) and
│ │ │ │ │ - * writes the time elapsed.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * name - {String}
│ │ │ │ │ - */
│ │ │ │ │ - timeEnd: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: profile
│ │ │ │ │ - * Turns on the JavaScript profiler. The optional argument title would
│ │ │ │ │ - * contain the text to be printed in the header of the profile report.
│ │ │ │ │ - *
│ │ │ │ │ - * This function is not currently implemented in Firebug Lite.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * title - {String} Optional title for the profiler
│ │ │ │ │ - */
│ │ │ │ │ - profile: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: profileEnd
│ │ │ │ │ - * Turns off the JavaScript profiler and prints its report.
│ │ │ │ │ - *
│ │ │ │ │ - * This function is not currently implemented in Firebug Lite.
│ │ │ │ │ - */
│ │ │ │ │ - profileEnd: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIFunction: count
│ │ │ │ │ - * Writes the number of times that the line of code where count was called
│ │ │ │ │ - * was executed. The optional argument title will print a message in
│ │ │ │ │ - * addition to the number of the count.
│ │ │ │ │ - *
│ │ │ │ │ - * This function is not currently implemented in Firebug Lite.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * title - {String} Optional title to be printed with count
│ │ │ │ │ - */
│ │ │ │ │ - count: function() {},
│ │ │ │ │ -
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Console"
│ │ │ │ │ -};
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Execute an anonymous function to extend the OpenLayers.Console namespace
│ │ │ │ │ - * if the firebug.js script is included. This closure is used so that the
│ │ │ │ │ - * "scripts" and "i" variables don't pollute the global namespace.
│ │ │ │ │ - */
│ │ │ │ │ -(function() {
│ │ │ │ │ - /**
│ │ │ │ │ - * If Firebug Lite is included (before this script), re-route all
│ │ │ │ │ - * OpenLayers.Console calls to the console object.
│ │ │ │ │ - */
│ │ │ │ │ - var scripts = document.getElementsByTagName("script");
│ │ │ │ │ - for (var i = 0, len = scripts.length; i < len; ++i) {
│ │ │ │ │ - if (scripts[i].src.indexOf("firebug.js") != -1) {
│ │ │ │ │ - if (console) {
│ │ │ │ │ - OpenLayers.Util.extend(OpenLayers.Console, console);
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ -})();
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ OpenLayers/Lang.js
│ │ │ │ │ ====================================================================== */
│ │ │ │ │
│ │ │ │ │ /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ * full text of the license. */
│ │ │ │ │ @@ -4426,14 +4256,1347 @@
│ │ │ │ │ } else {
│ │ │ │ │ str += coordinate < 0 ? OpenLayers.i18n("S") : OpenLayers.i18n("N");
│ │ │ │ │ }
│ │ │ │ │ return str;
│ │ │ │ │ };
│ │ │ │ │
│ │ │ │ │ /* ======================================================================
│ │ │ │ │ + OpenLayers/BaseTypes/Element.js
│ │ │ │ │ + ====================================================================== */
│ │ │ │ │ +
│ │ │ │ │ +/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ + * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ + * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ + * full text of the license. */
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * @requires OpenLayers/Util.js
│ │ │ │ │ + * @requires OpenLayers/BaseTypes.js
│ │ │ │ │ + */
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Namespace: OpenLayers.Element
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Element = {
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: visible
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * element - {DOMElement}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean} Is the element visible?
│ │ │ │ │ + */
│ │ │ │ │ + visible: function(element) {
│ │ │ │ │ + return OpenLayers.Util.getElement(element).style.display != 'none';
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: toggle
│ │ │ │ │ + * Toggle the visibility of element(s) passed in
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * element - {DOMElement} Actually user can pass any number of elements
│ │ │ │ │ + */
│ │ │ │ │ + toggle: function() {
│ │ │ │ │ + for (var i = 0, len = arguments.length; i < len; i++) {
│ │ │ │ │ + var element = OpenLayers.Util.getElement(arguments[i]);
│ │ │ │ │ + var display = OpenLayers.Element.visible(element) ? 'none' :
│ │ │ │ │ + '';
│ │ │ │ │ + element.style.display = display;
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: remove
│ │ │ │ │ + * Remove the specified element from the DOM.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * element - {DOMElement}
│ │ │ │ │ + */
│ │ │ │ │ + remove: function(element) {
│ │ │ │ │ + element = OpenLayers.Util.getElement(element);
│ │ │ │ │ + element.parentNode.removeChild(element);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: getHeight
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * element - {DOMElement}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Integer} The offset height of the element passed in
│ │ │ │ │ + */
│ │ │ │ │ + getHeight: function(element) {
│ │ │ │ │ + element = OpenLayers.Util.getElement(element);
│ │ │ │ │ + return element.offsetHeight;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Function: hasClass
│ │ │ │ │ + * Tests if an element has the given CSS class name.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * element - {DOMElement} A DOM element node.
│ │ │ │ │ + * name - {String} The CSS class name to search for.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean} The element has the given class name.
│ │ │ │ │ + */
│ │ │ │ │ + hasClass: function(element, name) {
│ │ │ │ │ + var names = element.className;
│ │ │ │ │ + return (!!names && new RegExp("(^|\\s)" + name + "(\\s|$)").test(names));
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Function: addClass
│ │ │ │ │ + * Add a CSS class name to an element. Safe where element already has
│ │ │ │ │ + * the class name.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * element - {DOMElement} A DOM element node.
│ │ │ │ │ + * name - {String} The CSS class name to add.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {DOMElement} The element.
│ │ │ │ │ + */
│ │ │ │ │ + addClass: function(element, name) {
│ │ │ │ │ + if (!OpenLayers.Element.hasClass(element, name)) {
│ │ │ │ │ + element.className += (element.className ? " " : "") + name;
│ │ │ │ │ + }
│ │ │ │ │ + return element;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Function: removeClass
│ │ │ │ │ + * Remove a CSS class name from an element. Safe where element does not
│ │ │ │ │ + * have the class name.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * element - {DOMElement} A DOM element node.
│ │ │ │ │ + * name - {String} The CSS class name to remove.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {DOMElement} The element.
│ │ │ │ │ + */
│ │ │ │ │ + removeClass: function(element, name) {
│ │ │ │ │ + var names = element.className;
│ │ │ │ │ + if (names) {
│ │ │ │ │ + element.className = OpenLayers.String.trim(
│ │ │ │ │ + names.replace(
│ │ │ │ │ + new RegExp("(^|\\s+)" + name + "(\\s+|$)"), " "
│ │ │ │ │ + )
│ │ │ │ │ + );
│ │ │ │ │ + }
│ │ │ │ │ + return element;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Function: toggleClass
│ │ │ │ │ + * Remove a CSS class name from an element if it exists. Add the class name
│ │ │ │ │ + * if it doesn't exist.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * element - {DOMElement} A DOM element node.
│ │ │ │ │ + * name - {String} The CSS class name to toggle.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {DOMElement} The element.
│ │ │ │ │ + */
│ │ │ │ │ + toggleClass: function(element, name) {
│ │ │ │ │ + if (OpenLayers.Element.hasClass(element, name)) {
│ │ │ │ │ + OpenLayers.Element.removeClass(element, name);
│ │ │ │ │ + } else {
│ │ │ │ │ + OpenLayers.Element.addClass(element, name);
│ │ │ │ │ + }
│ │ │ │ │ + return element;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIFunction: getStyle
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * element - {DOMElement}
│ │ │ │ │ + * style - {?}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {?}
│ │ │ │ │ + */
│ │ │ │ │ + getStyle: function(element, style) {
│ │ │ │ │ + element = OpenLayers.Util.getElement(element);
│ │ │ │ │ +
│ │ │ │ │ + var value = null;
│ │ │ │ │ + if (element && element.style) {
│ │ │ │ │ + value = element.style[OpenLayers.String.camelize(style)];
│ │ │ │ │ + if (!value) {
│ │ │ │ │ + if (document.defaultView &&
│ │ │ │ │ + document.defaultView.getComputedStyle) {
│ │ │ │ │ +
│ │ │ │ │ + var css = document.defaultView.getComputedStyle(element, null);
│ │ │ │ │ + value = css ? css.getPropertyValue(style) : null;
│ │ │ │ │ + } else if (element.currentStyle) {
│ │ │ │ │ + value = element.currentStyle[OpenLayers.String.camelize(style)];
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + var positions = ['left', 'top', 'right', 'bottom'];
│ │ │ │ │ + if (window.opera &&
│ │ │ │ │ + (OpenLayers.Util.indexOf(positions, style) != -1) &&
│ │ │ │ │ + (OpenLayers.Element.getStyle(element, 'position') == 'static')) {
│ │ │ │ │ + value = 'auto';
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + return value == 'auto' ? null : value;
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ +};
│ │ │ │ │ +/* ======================================================================
│ │ │ │ │ + Rico/Color.js
│ │ │ │ │ + ====================================================================== */
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * @requires Rico/license.js
│ │ │ │ │ + * @requires OpenLayers/Console.js
│ │ │ │ │ + * @requires OpenLayers/BaseTypes/Class.js
│ │ │ │ │ + * @requires OpenLayers/BaseTypes/Element.js
│ │ │ │ │ + */
│ │ │ │ │ +
│ │ │ │ │ +
│ │ │ │ │ +/*
│ │ │ │ │ + * This file has been edited substantially from the Rico-released version by
│ │ │ │ │ + * the OpenLayers development team.
│ │ │ │ │ + */
│ │ │ │ │ +
│ │ │ │ │ +OpenLayers.Console.warn("OpenLayers.Rico is deprecated");
│ │ │ │ │ +
│ │ │ │ │ +OpenLayers.Rico = OpenLayers.Rico || {};
│ │ │ │ │ +OpenLayers.Rico.Color = OpenLayers.Class({
│ │ │ │ │ +
│ │ │ │ │ + initialize: function(red, green, blue) {
│ │ │ │ │ + this.rgb = {
│ │ │ │ │ + r: red,
│ │ │ │ │ + g: green,
│ │ │ │ │ + b: blue
│ │ │ │ │ + };
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + setRed: function(r) {
│ │ │ │ │ + this.rgb.r = r;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + setGreen: function(g) {
│ │ │ │ │ + this.rgb.g = g;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + setBlue: function(b) {
│ │ │ │ │ + this.rgb.b = b;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + setHue: function(h) {
│ │ │ │ │ +
│ │ │ │ │ + // get an HSB model, and set the new hue...
│ │ │ │ │ + var hsb = this.asHSB();
│ │ │ │ │ + hsb.h = h;
│ │ │ │ │ +
│ │ │ │ │ + // convert back to RGB...
│ │ │ │ │ + this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + setSaturation: function(s) {
│ │ │ │ │ + // get an HSB model, and set the new hue...
│ │ │ │ │ + var hsb = this.asHSB();
│ │ │ │ │ + hsb.s = s;
│ │ │ │ │ +
│ │ │ │ │ + // convert back to RGB and set values...
│ │ │ │ │ + this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + setBrightness: function(b) {
│ │ │ │ │ + // get an HSB model, and set the new hue...
│ │ │ │ │ + var hsb = this.asHSB();
│ │ │ │ │ + hsb.b = b;
│ │ │ │ │ +
│ │ │ │ │ + // convert back to RGB and set values...
│ │ │ │ │ + this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + darken: function(percent) {
│ │ │ │ │ + var hsb = this.asHSB();
│ │ │ │ │ + this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, Math.max(hsb.b - percent, 0));
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + brighten: function(percent) {
│ │ │ │ │ + var hsb = this.asHSB();
│ │ │ │ │ + this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, Math.min(hsb.b + percent, 1));
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + blend: function(other) {
│ │ │ │ │ + this.rgb.r = Math.floor((this.rgb.r + other.rgb.r) / 2);
│ │ │ │ │ + this.rgb.g = Math.floor((this.rgb.g + other.rgb.g) / 2);
│ │ │ │ │ + this.rgb.b = Math.floor((this.rgb.b + other.rgb.b) / 2);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + isBright: function() {
│ │ │ │ │ + var hsb = this.asHSB();
│ │ │ │ │ + return this.asHSB().b > 0.5;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + isDark: function() {
│ │ │ │ │ + return !this.isBright();
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + asRGB: function() {
│ │ │ │ │ + return "rgb(" + this.rgb.r + "," + this.rgb.g + "," + this.rgb.b + ")";
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + asHex: function() {
│ │ │ │ │ + return "#" + this.rgb.r.toColorPart() + this.rgb.g.toColorPart() + this.rgb.b.toColorPart();
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + asHSB: function() {
│ │ │ │ │ + return OpenLayers.Rico.Color.RGBtoHSB(this.rgb.r, this.rgb.g, this.rgb.b);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + toString: function() {
│ │ │ │ │ + return this.asHex();
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ +});
│ │ │ │ │ +
│ │ │ │ │ +OpenLayers.Rico.Color.createFromHex = function(hexCode) {
│ │ │ │ │ + if (hexCode.length == 4) {
│ │ │ │ │ + var shortHexCode = hexCode;
│ │ │ │ │ + var hexCode = '#';
│ │ │ │ │ + for (var i = 1; i < 4; i++) {
│ │ │ │ │ + hexCode += (shortHexCode.charAt(i) +
│ │ │ │ │ + shortHexCode.charAt(i));
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + if (hexCode.indexOf('#') == 0) {
│ │ │ │ │ + hexCode = hexCode.substring(1);
│ │ │ │ │ + }
│ │ │ │ │ + var red = hexCode.substring(0, 2);
│ │ │ │ │ + var green = hexCode.substring(2, 4);
│ │ │ │ │ + var blue = hexCode.substring(4, 6);
│ │ │ │ │ + return new OpenLayers.Rico.Color(parseInt(red, 16), parseInt(green, 16), parseInt(blue, 16));
│ │ │ │ │ +};
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Factory method for creating a color from the background of
│ │ │ │ │ + * an HTML element.
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Rico.Color.createColorFromBackground = function(elem) {
│ │ │ │ │ +
│ │ │ │ │ + var actualColor =
│ │ │ │ │ + OpenLayers.Element.getStyle(OpenLayers.Util.getElement(elem),
│ │ │ │ │ + "backgroundColor");
│ │ │ │ │ +
│ │ │ │ │ + if (actualColor == "transparent" && elem.parentNode) {
│ │ │ │ │ + return OpenLayers.Rico.Color.createColorFromBackground(elem.parentNode);
│ │ │ │ │ + }
│ │ │ │ │ + if (actualColor == null) {
│ │ │ │ │ + return new OpenLayers.Rico.Color(255, 255, 255);
│ │ │ │ │ + }
│ │ │ │ │ + if (actualColor.indexOf("rgb(") == 0) {
│ │ │ │ │ + var colors = actualColor.substring(4, actualColor.length - 1);
│ │ │ │ │ + var colorArray = colors.split(",");
│ │ │ │ │ + return new OpenLayers.Rico.Color(parseInt(colorArray[0]),
│ │ │ │ │ + parseInt(colorArray[1]),
│ │ │ │ │ + parseInt(colorArray[2]));
│ │ │ │ │ +
│ │ │ │ │ + } else if (actualColor.indexOf("#") == 0) {
│ │ │ │ │ + return OpenLayers.Rico.Color.createFromHex(actualColor);
│ │ │ │ │ + } else {
│ │ │ │ │ + return new OpenLayers.Rico.Color(255, 255, 255);
│ │ │ │ │ + }
│ │ │ │ │ +};
│ │ │ │ │ +
│ │ │ │ │ +OpenLayers.Rico.Color.HSBtoRGB = function(hue, saturation, brightness) {
│ │ │ │ │ +
│ │ │ │ │ + var red = 0;
│ │ │ │ │ + var green = 0;
│ │ │ │ │ + var blue = 0;
│ │ │ │ │ +
│ │ │ │ │ + if (saturation == 0) {
│ │ │ │ │ + red = parseInt(brightness * 255.0 + 0.5);
│ │ │ │ │ + green = red;
│ │ │ │ │ + blue = red;
│ │ │ │ │ + } else {
│ │ │ │ │ + var h = (hue - Math.floor(hue)) * 6.0;
│ │ │ │ │ + var f = h - Math.floor(h);
│ │ │ │ │ + var p = brightness * (1.0 - saturation);
│ │ │ │ │ + var q = brightness * (1.0 - saturation * f);
│ │ │ │ │ + var t = brightness * (1.0 - (saturation * (1.0 - f)));
│ │ │ │ │ +
│ │ │ │ │ + switch (parseInt(h)) {
│ │ │ │ │ + case 0:
│ │ │ │ │ + red = (brightness * 255.0 + 0.5);
│ │ │ │ │ + green = (t * 255.0 + 0.5);
│ │ │ │ │ + blue = (p * 255.0 + 0.5);
│ │ │ │ │ + break;
│ │ │ │ │ + case 1:
│ │ │ │ │ + red = (q * 255.0 + 0.5);
│ │ │ │ │ + green = (brightness * 255.0 + 0.5);
│ │ │ │ │ + blue = (p * 255.0 + 0.5);
│ │ │ │ │ + break;
│ │ │ │ │ + case 2:
│ │ │ │ │ + red = (p * 255.0 + 0.5);
│ │ │ │ │ + green = (brightness * 255.0 + 0.5);
│ │ │ │ │ + blue = (t * 255.0 + 0.5);
│ │ │ │ │ + break;
│ │ │ │ │ + case 3:
│ │ │ │ │ + red = (p * 255.0 + 0.5);
│ │ │ │ │ + green = (q * 255.0 + 0.5);
│ │ │ │ │ + blue = (brightness * 255.0 + 0.5);
│ │ │ │ │ + break;
│ │ │ │ │ + case 4:
│ │ │ │ │ + red = (t * 255.0 + 0.5);
│ │ │ │ │ + green = (p * 255.0 + 0.5);
│ │ │ │ │ + blue = (brightness * 255.0 + 0.5);
│ │ │ │ │ + break;
│ │ │ │ │ + case 5:
│ │ │ │ │ + red = (brightness * 255.0 + 0.5);
│ │ │ │ │ + green = (p * 255.0 + 0.5);
│ │ │ │ │ + blue = (q * 255.0 + 0.5);
│ │ │ │ │ + break;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + return {
│ │ │ │ │ + r: parseInt(red),
│ │ │ │ │ + g: parseInt(green),
│ │ │ │ │ + b: parseInt(blue)
│ │ │ │ │ + };
│ │ │ │ │ +};
│ │ │ │ │ +
│ │ │ │ │ +OpenLayers.Rico.Color.RGBtoHSB = function(r, g, b) {
│ │ │ │ │ +
│ │ │ │ │ + var hue;
│ │ │ │ │ + var saturation;
│ │ │ │ │ + var brightness;
│ │ │ │ │ +
│ │ │ │ │ + var cmax = (r > g) ? r : g;
│ │ │ │ │ + if (b > cmax) {
│ │ │ │ │ + cmax = b;
│ │ │ │ │ + }
│ │ │ │ │ + var cmin = (r < g) ? r : g;
│ │ │ │ │ + if (b < cmin) {
│ │ │ │ │ + cmin = b;
│ │ │ │ │ + }
│ │ │ │ │ + brightness = cmax / 255.0;
│ │ │ │ │ + if (cmax != 0) {
│ │ │ │ │ + saturation = (cmax - cmin) / cmax;
│ │ │ │ │ + } else {
│ │ │ │ │ + saturation = 0;
│ │ │ │ │ + }
│ │ │ │ │ + if (saturation == 0) {
│ │ │ │ │ + hue = 0;
│ │ │ │ │ + } else {
│ │ │ │ │ + var redc = (cmax - r) / (cmax - cmin);
│ │ │ │ │ + var greenc = (cmax - g) / (cmax - cmin);
│ │ │ │ │ + var bluec = (cmax - b) / (cmax - cmin);
│ │ │ │ │ +
│ │ │ │ │ + if (r == cmax) {
│ │ │ │ │ + hue = bluec - greenc;
│ │ │ │ │ + } else if (g == cmax) {
│ │ │ │ │ + hue = 2.0 + redc - bluec;
│ │ │ │ │ + } else {
│ │ │ │ │ + hue = 4.0 + greenc - redc;
│ │ │ │ │ + }
│ │ │ │ │ + hue = hue / 6.0;
│ │ │ │ │ + if (hue < 0) {
│ │ │ │ │ + hue = hue + 1.0;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + return {
│ │ │ │ │ + h: hue,
│ │ │ │ │ + s: saturation,
│ │ │ │ │ + b: brightness
│ │ │ │ │ + };
│ │ │ │ │ +};
│ │ │ │ │ +
│ │ │ │ │ +/* ======================================================================
│ │ │ │ │ + Rico/Corner.js
│ │ │ │ │ + ====================================================================== */
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * @requires OpenLayers/Console.js
│ │ │ │ │ + * @requires Rico/Color.js
│ │ │ │ │ + */
│ │ │ │ │ +
│ │ │ │ │ +
│ │ │ │ │ +/*
│ │ │ │ │ + * This file has been edited substantially from the Rico-released
│ │ │ │ │ + * version by the OpenLayers development team.
│ │ │ │ │ + *
│ │ │ │ │ + * Copyright 2005 Sabre Airline Solutions
│ │ │ │ │ + *
│ │ │ │ │ + * Licensed under the Apache License, Version 2.0 (the "License");
│ │ │ │ │ + * you may not use this file except in compliance with the
│ │ │ │ │ + * License. You may obtain a copy of the License at
│ │ │ │ │ + *
│ │ │ │ │ + * http://www.apache.org/licenses/LICENSE-2.0
│ │ │ │ │ + *
│ │ │ │ │ + * Unless required by applicable law or agreed to in writing, software
│ │ │ │ │ + * distributed under the * License is distributed on an "AS IS" BASIS,
│ │ │ │ │ + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or
│ │ │ │ │ + * implied. See the License for the specific language governing
│ │ │ │ │ + * permissions * and limitations under the License.
│ │ │ │ │ + *
│ │ │ │ │ + */
│ │ │ │ │ +
│ │ │ │ │ +OpenLayers.Console.warn("OpenLayers.Rico is deprecated");
│ │ │ │ │ +
│ │ │ │ │ +OpenLayers.Rico = OpenLayers.Rico || {};
│ │ │ │ │ +OpenLayers.Rico.Corner = {
│ │ │ │ │ +
│ │ │ │ │ + round: function(e, options) {
│ │ │ │ │ + e = OpenLayers.Util.getElement(e);
│ │ │ │ │ + this._setOptions(options);
│ │ │ │ │ +
│ │ │ │ │ + var color = this.options.color;
│ │ │ │ │ + if (this.options.color == "fromElement") {
│ │ │ │ │ + color = this._background(e);
│ │ │ │ │ + }
│ │ │ │ │ + var bgColor = this.options.bgColor;
│ │ │ │ │ + if (this.options.bgColor == "fromParent") {
│ │ │ │ │ + bgColor = this._background(e.offsetParent);
│ │ │ │ │ + }
│ │ │ │ │ + this._roundCornersImpl(e, color, bgColor);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /** This is a helper function to change the background
│ │ │ │ │ + * color of
that has had Rico rounded corners added.
│ │ │ │ │ + *
│ │ │ │ │ + * It seems we cannot just set the background color for the
│ │ │ │ │ + * outer
so each
element used to create the
│ │ │ │ │ + * corners must have its background color set individually.
│ │ │ │ │ + *
│ │ │ │ │ + * @param {DOM} theDiv - A child of the outer that was
│ │ │ │ │ + * supplied to the `round` method.
│ │ │ │ │ + *
│ │ │ │ │ + * @param {String} newColor - The new background color to use.
│ │ │ │ │ + */
│ │ │ │ │ + changeColor: function(theDiv, newColor) {
│ │ │ │ │ +
│ │ │ │ │ + theDiv.style.backgroundColor = newColor;
│ │ │ │ │ +
│ │ │ │ │ + var spanElements = theDiv.parentNode.getElementsByTagName("span");
│ │ │ │ │ +
│ │ │ │ │ + for (var currIdx = 0; currIdx < spanElements.length; currIdx++) {
│ │ │ │ │ + spanElements[currIdx].style.backgroundColor = newColor;
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ +
│ │ │ │ │ + /** This is a helper function to change the background
│ │ │ │ │ + * opacity of
that has had Rico rounded corners added.
│ │ │ │ │ + *
│ │ │ │ │ + * See changeColor (above) for algorithm explanation
│ │ │ │ │ + *
│ │ │ │ │ + * @param {DOM} theDiv A child of the outer
that was
│ │ │ │ │ + * supplied to the `round` method.
│ │ │ │ │ + *
│ │ │ │ │ + * @param {int} newOpacity The new opacity to use (0-1).
│ │ │ │ │ + */
│ │ │ │ │ + changeOpacity: function(theDiv, newOpacity) {
│ │ │ │ │ +
│ │ │ │ │ + var mozillaOpacity = newOpacity;
│ │ │ │ │ + var ieOpacity = 'alpha(opacity=' + newOpacity * 100 + ')';
│ │ │ │ │ +
│ │ │ │ │ + theDiv.style.opacity = mozillaOpacity;
│ │ │ │ │ + theDiv.style.filter = ieOpacity;
│ │ │ │ │ +
│ │ │ │ │ + var spanElements = theDiv.parentNode.getElementsByTagName("span");
│ │ │ │ │ +
│ │ │ │ │ + for (var currIdx = 0; currIdx < spanElements.length; currIdx++) {
│ │ │ │ │ + spanElements[currIdx].style.opacity = mozillaOpacity;
│ │ │ │ │ + spanElements[currIdx].style.filter = ieOpacity;
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /** this function takes care of redoing the rico cornering
│ │ │ │ │ + *
│ │ │ │ │ + * you can't just call updateRicoCorners() again and pass it a
│ │ │ │ │ + * new options string. you have to first remove the divs that
│ │ │ │ │ + * rico puts on top and below the content div.
│ │ │ │ │ + *
│ │ │ │ │ + * @param {DOM} theDiv - A child of the outer
that was
│ │ │ │ │ + * supplied to the `round` method.
│ │ │ │ │ + *
│ │ │ │ │ + * @param {Object} options - list of options
│ │ │ │ │ + */
│ │ │ │ │ + reRound: function(theDiv, options) {
│ │ │ │ │ +
│ │ │ │ │ + var topRico = theDiv.parentNode.childNodes[0];
│ │ │ │ │ + //theDiv would be theDiv.parentNode.childNodes[1]
│ │ │ │ │ + var bottomRico = theDiv.parentNode.childNodes[2];
│ │ │ │ │ +
│ │ │ │ │ + theDiv.parentNode.removeChild(topRico);
│ │ │ │ │ + theDiv.parentNode.removeChild(bottomRico);
│ │ │ │ │ +
│ │ │ │ │ + this.round(theDiv.parentNode, options);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _roundCornersImpl: function(e, color, bgColor) {
│ │ │ │ │ + if (this.options.border) {
│ │ │ │ │ + this._renderBorder(e, bgColor);
│ │ │ │ │ + }
│ │ │ │ │ + if (this._isTopRounded()) {
│ │ │ │ │ + this._roundTopCorners(e, color, bgColor);
│ │ │ │ │ + }
│ │ │ │ │ + if (this._isBottomRounded()) {
│ │ │ │ │ + this._roundBottomCorners(e, color, bgColor);
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _renderBorder: function(el, bgColor) {
│ │ │ │ │ + var borderValue = "1px solid " + this._borderColor(bgColor);
│ │ │ │ │ + var borderL = "border-left: " + borderValue;
│ │ │ │ │ + var borderR = "border-right: " + borderValue;
│ │ │ │ │ + var style = "style='" + borderL + ";" + borderR + "'";
│ │ │ │ │ + el.innerHTML = "
" + el.innerHTML + "
";
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _roundTopCorners: function(el, color, bgColor) {
│ │ │ │ │ + var corner = this._createCorner(bgColor);
│ │ │ │ │ + for (var i = 0; i < this.options.numSlices; i++) {
│ │ │ │ │ + corner.appendChild(this._createCornerSlice(color, bgColor, i, "top"));
│ │ │ │ │ + }
│ │ │ │ │ + el.style.paddingTop = 0;
│ │ │ │ │ + el.insertBefore(corner, el.firstChild);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _roundBottomCorners: function(el, color, bgColor) {
│ │ │ │ │ + var corner = this._createCorner(bgColor);
│ │ │ │ │ + for (var i = (this.options.numSlices - 1); i >= 0; i--) {
│ │ │ │ │ + corner.appendChild(this._createCornerSlice(color, bgColor, i, "bottom"));
│ │ │ │ │ + }
│ │ │ │ │ + el.style.paddingBottom = 0;
│ │ │ │ │ + el.appendChild(corner);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _createCorner: function(bgColor) {
│ │ │ │ │ + var corner = document.createElement("div");
│ │ │ │ │ + corner.style.backgroundColor = (this._isTransparent() ? "transparent" : bgColor);
│ │ │ │ │ + return corner;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _createCornerSlice: function(color, bgColor, n, position) {
│ │ │ │ │ + var slice = document.createElement("span");
│ │ │ │ │ +
│ │ │ │ │ + var inStyle = slice.style;
│ │ │ │ │ + inStyle.backgroundColor = color;
│ │ │ │ │ + inStyle.display = "block";
│ │ │ │ │ + inStyle.height = "1px";
│ │ │ │ │ + inStyle.overflow = "hidden";
│ │ │ │ │ + inStyle.fontSize = "1px";
│ │ │ │ │ +
│ │ │ │ │ + var borderColor = this._borderColor(color, bgColor);
│ │ │ │ │ + if (this.options.border && n == 0) {
│ │ │ │ │ + inStyle.borderTopStyle = "solid";
│ │ │ │ │ + inStyle.borderTopWidth = "1px";
│ │ │ │ │ + inStyle.borderLeftWidth = "0px";
│ │ │ │ │ + inStyle.borderRightWidth = "0px";
│ │ │ │ │ + inStyle.borderBottomWidth = "0px";
│ │ │ │ │ + inStyle.height = "0px"; // assumes css compliant box model
│ │ │ │ │ + inStyle.borderColor = borderColor;
│ │ │ │ │ + } else if (borderColor) {
│ │ │ │ │ + inStyle.borderColor = borderColor;
│ │ │ │ │ + inStyle.borderStyle = "solid";
│ │ │ │ │ + inStyle.borderWidth = "0px 1px";
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + if (!this.options.compact && (n == (this.options.numSlices - 1))) {
│ │ │ │ │ + inStyle.height = "2px";
│ │ │ │ │ + }
│ │ │ │ │ + this._setMargin(slice, n, position);
│ │ │ │ │ + this._setBorder(slice, n, position);
│ │ │ │ │ + return slice;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _setOptions: function(options) {
│ │ │ │ │ + this.options = {
│ │ │ │ │ + corners: "all",
│ │ │ │ │ + color: "fromElement",
│ │ │ │ │ + bgColor: "fromParent",
│ │ │ │ │ + blend: true,
│ │ │ │ │ + border: false,
│ │ │ │ │ + compact: false
│ │ │ │ │ + };
│ │ │ │ │ + OpenLayers.Util.extend(this.options, options || {});
│ │ │ │ │ +
│ │ │ │ │ + this.options.numSlices = this.options.compact ? 2 : 4;
│ │ │ │ │ + if (this._isTransparent()) {
│ │ │ │ │ + this.options.blend = false;
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _whichSideTop: function() {
│ │ │ │ │ + if (this._hasString(this.options.corners, "all", "top")) {
│ │ │ │ │ + return "";
│ │ │ │ │ + }
│ │ │ │ │ + if (this.options.corners.indexOf("tl") >= 0 && this.options.corners.indexOf("tr") >= 0) {
│ │ │ │ │ + return "";
│ │ │ │ │ + }
│ │ │ │ │ + if (this.options.corners.indexOf("tl") >= 0) {
│ │ │ │ │ + return "left";
│ │ │ │ │ + } else if (this.options.corners.indexOf("tr") >= 0) {
│ │ │ │ │ + return "right";
│ │ │ │ │ + }
│ │ │ │ │ + return "";
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _whichSideBottom: function() {
│ │ │ │ │ + if (this._hasString(this.options.corners, "all", "bottom")) {
│ │ │ │ │ + return "";
│ │ │ │ │ + }
│ │ │ │ │ + if (this.options.corners.indexOf("bl") >= 0 && this.options.corners.indexOf("br") >= 0) {
│ │ │ │ │ + return "";
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + if (this.options.corners.indexOf("bl") >= 0) {
│ │ │ │ │ + return "left";
│ │ │ │ │ + } else if (this.options.corners.indexOf("br") >= 0) {
│ │ │ │ │ + return "right";
│ │ │ │ │ + }
│ │ │ │ │ + return "";
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _borderColor: function(color, bgColor) {
│ │ │ │ │ + if (color == "transparent") {
│ │ │ │ │ + return bgColor;
│ │ │ │ │ + } else if (this.options.border) {
│ │ │ │ │ + return this.options.border;
│ │ │ │ │ + } else if (this.options.blend) {
│ │ │ │ │ + return this._blend(bgColor, color);
│ │ │ │ │ + } else {
│ │ │ │ │ + return "";
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ +
│ │ │ │ │ + _setMargin: function(el, n, corners) {
│ │ │ │ │ + var marginSize = this._marginSize(n);
│ │ │ │ │ + var whichSide = corners == "top" ? this._whichSideTop() : this._whichSideBottom();
│ │ │ │ │ +
│ │ │ │ │ + if (whichSide == "left") {
│ │ │ │ │ + el.style.marginLeft = marginSize + "px";
│ │ │ │ │ + el.style.marginRight = "0px";
│ │ │ │ │ + } else if (whichSide == "right") {
│ │ │ │ │ + el.style.marginRight = marginSize + "px";
│ │ │ │ │ + el.style.marginLeft = "0px";
│ │ │ │ │ + } else {
│ │ │ │ │ + el.style.marginLeft = marginSize + "px";
│ │ │ │ │ + el.style.marginRight = marginSize + "px";
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _setBorder: function(el, n, corners) {
│ │ │ │ │ + var borderSize = this._borderSize(n);
│ │ │ │ │ + var whichSide = corners == "top" ? this._whichSideTop() : this._whichSideBottom();
│ │ │ │ │ + if (whichSide == "left") {
│ │ │ │ │ + el.style.borderLeftWidth = borderSize + "px";
│ │ │ │ │ + el.style.borderRightWidth = "0px";
│ │ │ │ │ + } else if (whichSide == "right") {
│ │ │ │ │ + el.style.borderRightWidth = borderSize + "px";
│ │ │ │ │ + el.style.borderLeftWidth = "0px";
│ │ │ │ │ + } else {
│ │ │ │ │ + el.style.borderLeftWidth = borderSize + "px";
│ │ │ │ │ + el.style.borderRightWidth = borderSize + "px";
│ │ │ │ │ + }
│ │ │ │ │ + if (this.options.border != false) {
│ │ │ │ │ + el.style.borderLeftWidth = borderSize + "px";
│ │ │ │ │ + el.style.borderRightWidth = borderSize + "px";
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _marginSize: function(n) {
│ │ │ │ │ + if (this._isTransparent()) {
│ │ │ │ │ + return 0;
│ │ │ │ │ + }
│ │ │ │ │ + var marginSizes = [5, 3, 2, 1];
│ │ │ │ │ + var blendedMarginSizes = [3, 2, 1, 0];
│ │ │ │ │ + var compactMarginSizes = [2, 1];
│ │ │ │ │ + var smBlendedMarginSizes = [1, 0];
│ │ │ │ │ +
│ │ │ │ │ + if (this.options.compact && this.options.blend) {
│ │ │ │ │ + return smBlendedMarginSizes[n];
│ │ │ │ │ + } else if (this.options.compact) {
│ │ │ │ │ + return compactMarginSizes[n];
│ │ │ │ │ + } else if (this.options.blend) {
│ │ │ │ │ + return blendedMarginSizes[n];
│ │ │ │ │ + } else {
│ │ │ │ │ + return marginSizes[n];
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _borderSize: function(n) {
│ │ │ │ │ + var transparentBorderSizes = [5, 3, 2, 1];
│ │ │ │ │ + var blendedBorderSizes = [2, 1, 1, 1];
│ │ │ │ │ + var compactBorderSizes = [1, 0];
│ │ │ │ │ + var actualBorderSizes = [0, 2, 0, 0];
│ │ │ │ │ +
│ │ │ │ │ + if (this.options.compact && (this.options.blend || this._isTransparent())) {
│ │ │ │ │ + return 1;
│ │ │ │ │ + } else if (this.options.compact) {
│ │ │ │ │ + return compactBorderSizes[n];
│ │ │ │ │ + } else if (this.options.blend) {
│ │ │ │ │ + return blendedBorderSizes[n];
│ │ │ │ │ + } else if (this.options.border) {
│ │ │ │ │ + return actualBorderSizes[n];
│ │ │ │ │ + } else if (this._isTransparent()) {
│ │ │ │ │ + return transparentBorderSizes[n];
│ │ │ │ │ + }
│ │ │ │ │ + return 0;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + _hasString: function(str) {
│ │ │ │ │ + for (var i = 1; i < arguments.length; i++)
│ │ │ │ │ + if (str.indexOf(arguments[i]) >= 0) {
│ │ │ │ │ + return true;
│ │ │ │ │ + } return false;
│ │ │ │ │ + },
│ │ │ │ │ + _blend: function(c1, c2) {
│ │ │ │ │ + var cc1 = OpenLayers.Rico.Color.createFromHex(c1);
│ │ │ │ │ + cc1.blend(OpenLayers.Rico.Color.createFromHex(c2));
│ │ │ │ │ + return cc1;
│ │ │ │ │ + },
│ │ │ │ │ + _background: function(el) {
│ │ │ │ │ + try {
│ │ │ │ │ + return OpenLayers.Rico.Color.createColorFromBackground(el).asHex();
│ │ │ │ │ + } catch (err) {
│ │ │ │ │ + return "#ffffff";
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ + _isTransparent: function() {
│ │ │ │ │ + return this.options.color == "transparent";
│ │ │ │ │ + },
│ │ │ │ │ + _isTopRounded: function() {
│ │ │ │ │ + return this._hasString(this.options.corners, "all", "top", "tl", "tr");
│ │ │ │ │ + },
│ │ │ │ │ + _isBottomRounded: function() {
│ │ │ │ │ + return this._hasString(this.options.corners, "all", "bottom", "bl", "br");
│ │ │ │ │ + },
│ │ │ │ │ + _hasSingleTextChild: function(el) {
│ │ │ │ │ + return el.childNodes.length == 1 && el.childNodes[0].nodeType == 3;
│ │ │ │ │ + }
│ │ │ │ │ +};
│ │ │ │ │ +/* ======================================================================
│ │ │ │ │ + OpenLayers/Geometry.js
│ │ │ │ │ + ====================================================================== */
│ │ │ │ │ +
│ │ │ │ │ +/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ + * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ + * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ + * full text of the license. */
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * @requires OpenLayers/BaseTypes/Class.js
│ │ │ │ │ + */
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Class: OpenLayers.Geometry
│ │ │ │ │ + * A Geometry is a description of a geographic object. Create an instance of
│ │ │ │ │ + * this class with the
constructor. This is a base class,
│ │ │ │ │ + * typical geometry types are described by subclasses of this class.
│ │ │ │ │ + *
│ │ │ │ │ + * Note that if you use the method, you must
│ │ │ │ │ + * explicitly include the OpenLayers.Format.WKT in your build.
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Geometry = OpenLayers.Class({
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: id
│ │ │ │ │ + * {String} A unique identifier for this geometry.
│ │ │ │ │ + */
│ │ │ │ │ + id: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: parent
│ │ │ │ │ + * {}This is set when a Geometry is added as component
│ │ │ │ │ + * of another geometry
│ │ │ │ │ + */
│ │ │ │ │ + parent: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: bounds
│ │ │ │ │ + * {} The bounds of this geometry
│ │ │ │ │ + */
│ │ │ │ │ + bounds: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constructor: OpenLayers.Geometry
│ │ │ │ │ + * Creates a geometry object.
│ │ │ │ │ + */
│ │ │ │ │ + initialize: function() {
│ │ │ │ │ + this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: destroy
│ │ │ │ │ + * Destroy this geometry.
│ │ │ │ │ + */
│ │ │ │ │ + destroy: function() {
│ │ │ │ │ + this.id = null;
│ │ │ │ │ + this.bounds = null;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: clone
│ │ │ │ │ + * Create a clone of this geometry. Does not set any non-standard
│ │ │ │ │ + * properties of the cloned geometry.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {} An exact clone of this geometry.
│ │ │ │ │ + */
│ │ │ │ │ + clone: function() {
│ │ │ │ │ + return new OpenLayers.Geometry();
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: setBounds
│ │ │ │ │ + * Set the bounds for this Geometry.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * bounds - {}
│ │ │ │ │ + */
│ │ │ │ │ + setBounds: function(bounds) {
│ │ │ │ │ + if (bounds) {
│ │ │ │ │ + this.bounds = bounds.clone();
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: clearBounds
│ │ │ │ │ + * Nullify this components bounds and that of its parent as well.
│ │ │ │ │ + */
│ │ │ │ │ + clearBounds: function() {
│ │ │ │ │ + this.bounds = null;
│ │ │ │ │ + if (this.parent) {
│ │ │ │ │ + this.parent.clearBounds();
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: extendBounds
│ │ │ │ │ + * Extend the existing bounds to include the new bounds.
│ │ │ │ │ + * If geometry's bounds is not yet set, then set a new Bounds.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * newBounds - {}
│ │ │ │ │ + */
│ │ │ │ │ + extendBounds: function(newBounds) {
│ │ │ │ │ + var bounds = this.getBounds();
│ │ │ │ │ + if (!bounds) {
│ │ │ │ │ + this.setBounds(newBounds);
│ │ │ │ │ + } else {
│ │ │ │ │ + this.bounds.extend(newBounds);
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: getBounds
│ │ │ │ │ + * Get the bounds for this Geometry. If bounds is not set, it
│ │ │ │ │ + * is calculated again, this makes queries faster.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {}
│ │ │ │ │ + */
│ │ │ │ │ + getBounds: function() {
│ │ │ │ │ + if (this.bounds == null) {
│ │ │ │ │ + this.calculateBounds();
│ │ │ │ │ + }
│ │ │ │ │ + return this.bounds;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: calculateBounds
│ │ │ │ │ + * Recalculate the bounds for the geometry.
│ │ │ │ │ + */
│ │ │ │ │ + calculateBounds: function() {
│ │ │ │ │ + //
│ │ │ │ │ + // This should be overridden by subclasses.
│ │ │ │ │ + //
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: distanceTo
│ │ │ │ │ + * Calculate the closest distance between two geometries (on the x-y plane).
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * geometry - {} The target geometry.
│ │ │ │ │ + * options - {Object} Optional properties for configuring the distance
│ │ │ │ │ + * calculation.
│ │ │ │ │ + *
│ │ │ │ │ + * Valid options depend on the specific geometry type.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Number | Object} The distance between this geometry and the target.
│ │ │ │ │ + * If details is true, the return will be an object with distance,
│ │ │ │ │ + * x0, y0, x1, and x2 properties. The x0 and y0 properties represent
│ │ │ │ │ + * the coordinates of the closest point on this geometry. The x1 and y1
│ │ │ │ │ + * properties represent the coordinates of the closest point on the
│ │ │ │ │ + * target geometry.
│ │ │ │ │ + */
│ │ │ │ │ + distanceTo: function(geometry, options) {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: getVertices
│ │ │ │ │ + * Return a list of all points in this geometry.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * nodes - {Boolean} For lines, only return vertices that are
│ │ │ │ │ + * endpoints. If false, for lines, only vertices that are not
│ │ │ │ │ + * endpoints will be returned. If not provided, all vertices will
│ │ │ │ │ + * be returned.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Array} A list of all vertices in the geometry.
│ │ │ │ │ + */
│ │ │ │ │ + getVertices: function(nodes) {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: atPoint
│ │ │ │ │ + * Note - This is only an approximation based on the bounds of the
│ │ │ │ │ + * geometry.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * lonlat - {|Object} OpenLayers.LonLat or an
│ │ │ │ │ + * object with a 'lon' and 'lat' properties.
│ │ │ │ │ + * toleranceLon - {float} Optional tolerance in Geometric Coords
│ │ │ │ │ + * toleranceLat - {float} Optional tolerance in Geographic Coords
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean} Whether or not the geometry is at the specified location
│ │ │ │ │ + */
│ │ │ │ │ + atPoint: function(lonlat, toleranceLon, toleranceLat) {
│ │ │ │ │ + var atPoint = false;
│ │ │ │ │ + var bounds = this.getBounds();
│ │ │ │ │ + if ((bounds != null) && (lonlat != null)) {
│ │ │ │ │ +
│ │ │ │ │ + var dX = (toleranceLon != null) ? toleranceLon : 0;
│ │ │ │ │ + var dY = (toleranceLat != null) ? toleranceLat : 0;
│ │ │ │ │ +
│ │ │ │ │ + var toleranceBounds =
│ │ │ │ │ + new OpenLayers.Bounds(this.bounds.left - dX,
│ │ │ │ │ + this.bounds.bottom - dY,
│ │ │ │ │ + this.bounds.right + dX,
│ │ │ │ │ + this.bounds.top + dY);
│ │ │ │ │ +
│ │ │ │ │ + atPoint = toleranceBounds.containsLonLat(lonlat);
│ │ │ │ │ + }
│ │ │ │ │ + return atPoint;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: getLength
│ │ │ │ │ + * Calculate the length of this geometry. This method is defined in
│ │ │ │ │ + * subclasses.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Float} The length of the collection by summing its parts
│ │ │ │ │ + */
│ │ │ │ │ + getLength: function() {
│ │ │ │ │ + //to be overridden by geometries that actually have a length
│ │ │ │ │ + //
│ │ │ │ │ + return 0.0;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: getArea
│ │ │ │ │ + * Calculate the area of this geometry. This method is defined in subclasses.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Float} The area of the collection by summing its parts
│ │ │ │ │ + */
│ │ │ │ │ + getArea: function() {
│ │ │ │ │ + //to be overridden by geometries that actually have an area
│ │ │ │ │ + //
│ │ │ │ │ + return 0.0;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: getCentroid
│ │ │ │ │ + * Calculate the centroid of this geometry. This method is defined in subclasses.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {} The centroid of the collection
│ │ │ │ │ + */
│ │ │ │ │ + getCentroid: function() {
│ │ │ │ │ + return null;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: toString
│ │ │ │ │ + * Returns a text representation of the geometry. If the WKT format is
│ │ │ │ │ + * included in a build, this will be the Well-Known Text
│ │ │ │ │ + * representation.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {String} String representation of this geometry.
│ │ │ │ │ + */
│ │ │ │ │ + toString: function() {
│ │ │ │ │ + var string;
│ │ │ │ │ + if (OpenLayers.Format && OpenLayers.Format.WKT) {
│ │ │ │ │ + string = OpenLayers.Format.WKT.prototype.write(
│ │ │ │ │ + new OpenLayers.Feature.Vector(this)
│ │ │ │ │ + );
│ │ │ │ │ + } else {
│ │ │ │ │ + string = Object.prototype.toString.call(this);
│ │ │ │ │ + }
│ │ │ │ │ + return string;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + CLASS_NAME: "OpenLayers.Geometry"
│ │ │ │ │ +});
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Function: OpenLayers.Geometry.fromWKT
│ │ │ │ │ + * Generate a geometry given a Well-Known Text string. For this method to
│ │ │ │ │ + * work, you must include the OpenLayers.Format.WKT in your build
│ │ │ │ │ + * explicitly.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * wkt - {String} A string representing the geometry in Well-Known Text.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {} A geometry of the appropriate class.
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Geometry.fromWKT = function(wkt) {
│ │ │ │ │ + var geom;
│ │ │ │ │ + if (OpenLayers.Format && OpenLayers.Format.WKT) {
│ │ │ │ │ + var format = OpenLayers.Geometry.fromWKT.format;
│ │ │ │ │ + if (!format) {
│ │ │ │ │ + format = new OpenLayers.Format.WKT();
│ │ │ │ │ + OpenLayers.Geometry.fromWKT.format = format;
│ │ │ │ │ + }
│ │ │ │ │ + var result = format.read(wkt);
│ │ │ │ │ + if (result instanceof OpenLayers.Feature.Vector) {
│ │ │ │ │ + geom = result.geometry;
│ │ │ │ │ + } else if (OpenLayers.Util.isArray(result)) {
│ │ │ │ │ + var len = result.length;
│ │ │ │ │ + var components = new Array(len);
│ │ │ │ │ + for (var i = 0; i < len; ++i) {
│ │ │ │ │ + components[i] = result[i].geometry;
│ │ │ │ │ + }
│ │ │ │ │ + geom = new OpenLayers.Geometry.Collection(components);
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + return geom;
│ │ │ │ │ +};
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Method: OpenLayers.Geometry.segmentsIntersect
│ │ │ │ │ + * Determine whether two line segments intersect. Optionally calculates
│ │ │ │ │ + * and returns the intersection point. This function is optimized for
│ │ │ │ │ + * cases where seg1.x2 >= seg2.x1 || seg2.x2 >= seg1.x1. In those
│ │ │ │ │ + * obvious cases where there is no intersection, the function should
│ │ │ │ │ + * not be called.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * seg1 - {Object} Object representing a segment with properties x1, y1, x2,
│ │ │ │ │ + * and y2. The start point is represented by x1 and y1. The end point
│ │ │ │ │ + * is represented by x2 and y2. Start and end are ordered so that x1 < x2.
│ │ │ │ │ + * seg2 - {Object} Object representing a segment with properties x1, y1, x2,
│ │ │ │ │ + * and y2. The start point is represented by x1 and y1. The end point
│ │ │ │ │ + * is represented by x2 and y2. Start and end are ordered so that x1 < x2.
│ │ │ │ │ + * options - {Object} Optional properties for calculating the intersection.
│ │ │ │ │ + *
│ │ │ │ │ + * Valid options:
│ │ │ │ │ + * point - {Boolean} Return the intersection point. If false, the actual
│ │ │ │ │ + * intersection point will not be calculated. If true and the segments
│ │ │ │ │ + * intersect, the intersection point will be returned. If true and
│ │ │ │ │ + * the segments do not intersect, false will be returned. If true and
│ │ │ │ │ + * the segments are coincident, true will be returned.
│ │ │ │ │ + * tolerance - {Number} If a non-null value is provided, if the segments are
│ │ │ │ │ + * within the tolerance distance, this will be considered an intersection.
│ │ │ │ │ + * In addition, if the point option is true and the calculated intersection
│ │ │ │ │ + * is within the tolerance distance of an end point, the endpoint will be
│ │ │ │ │ + * returned instead of the calculated intersection. Further, if the
│ │ │ │ │ + * intersection is within the tolerance of endpoints on both segments, or
│ │ │ │ │ + * if two segment endpoints are within the tolerance distance of eachother
│ │ │ │ │ + * (but no intersection is otherwise calculated), an endpoint on the
│ │ │ │ │ + * first segment provided will be returned.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean | } The two segments intersect.
│ │ │ │ │ + * If the point argument is true, the return will be the intersection
│ │ │ │ │ + * point or false if none exists. If point is true and the segments
│ │ │ │ │ + * are coincident, return will be true (and the instersection is equal
│ │ │ │ │ + * to the shorter segment).
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Geometry.segmentsIntersect = function(seg1, seg2, options) {
│ │ │ │ │ + var point = options && options.point;
│ │ │ │ │ + var tolerance = options && options.tolerance;
│ │ │ │ │ + var intersection = false;
│ │ │ │ │ + var x11_21 = seg1.x1 - seg2.x1;
│ │ │ │ │ + var y11_21 = seg1.y1 - seg2.y1;
│ │ │ │ │ + var x12_11 = seg1.x2 - seg1.x1;
│ │ │ │ │ + var y12_11 = seg1.y2 - seg1.y1;
│ │ │ │ │ + var y22_21 = seg2.y2 - seg2.y1;
│ │ │ │ │ + var x22_21 = seg2.x2 - seg2.x1;
│ │ │ │ │ + var d = (y22_21 * x12_11) - (x22_21 * y12_11);
│ │ │ │ │ + var n1 = (x22_21 * y11_21) - (y22_21 * x11_21);
│ │ │ │ │ + var n2 = (x12_11 * y11_21) - (y12_11 * x11_21);
│ │ │ │ │ + if (d == 0) {
│ │ │ │ │ + // parallel
│ │ │ │ │ + if (n1 == 0 && n2 == 0) {
│ │ │ │ │ + // coincident
│ │ │ │ │ + intersection = true;
│ │ │ │ │ + }
│ │ │ │ │ + } else {
│ │ │ │ │ + var along1 = n1 / d;
│ │ │ │ │ + var along2 = n2 / d;
│ │ │ │ │ + if (along1 >= 0 && along1 <= 1 && along2 >= 0 && along2 <= 1) {
│ │ │ │ │ + // intersect
│ │ │ │ │ + if (!point) {
│ │ │ │ │ + intersection = true;
│ │ │ │ │ + } else {
│ │ │ │ │ + // calculate the intersection point
│ │ │ │ │ + var x = seg1.x1 + (along1 * x12_11);
│ │ │ │ │ + var y = seg1.y1 + (along1 * y12_11);
│ │ │ │ │ + intersection = new OpenLayers.Geometry.Point(x, y);
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + if (tolerance) {
│ │ │ │ │ + var dist;
│ │ │ │ │ + if (intersection) {
│ │ │ │ │ + if (point) {
│ │ │ │ │ + var segs = [seg1, seg2];
│ │ │ │ │ + var seg, x, y;
│ │ │ │ │ + // check segment endpoints for proximity to intersection
│ │ │ │ │ + // set intersection to first endpoint within the tolerance
│ │ │ │ │ + outer: for (var i = 0; i < 2; ++i) {
│ │ │ │ │ + seg = segs[i];
│ │ │ │ │ + for (var j = 1; j < 3; ++j) {
│ │ │ │ │ + x = seg["x" + j];
│ │ │ │ │ + y = seg["y" + j];
│ │ │ │ │ + dist = Math.sqrt(
│ │ │ │ │ + Math.pow(x - intersection.x, 2) +
│ │ │ │ │ + Math.pow(y - intersection.y, 2)
│ │ │ │ │ + );
│ │ │ │ │ + if (dist < tolerance) {
│ │ │ │ │ + intersection.x = x;
│ │ │ │ │ + intersection.y = y;
│ │ │ │ │ + break outer;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + }
│ │ │ │ │ + } else {
│ │ │ │ │ + // no calculated intersection, but segments could be within
│ │ │ │ │ + // the tolerance of one another
│ │ │ │ │ + var segs = [seg1, seg2];
│ │ │ │ │ + var source, target, x, y, p, result;
│ │ │ │ │ + // check segment endpoints for proximity to intersection
│ │ │ │ │ + // set intersection to first endpoint within the tolerance
│ │ │ │ │ + outer: for (var i = 0; i < 2; ++i) {
│ │ │ │ │ + source = segs[i];
│ │ │ │ │ + target = segs[(i + 1) % 2];
│ │ │ │ │ + for (var j = 1; j < 3; ++j) {
│ │ │ │ │ + p = {
│ │ │ │ │ + x: source["x" + j],
│ │ │ │ │ + y: source["y" + j]
│ │ │ │ │ + };
│ │ │ │ │ + result = OpenLayers.Geometry.distanceToSegment(p, target);
│ │ │ │ │ + if (result.distance < tolerance) {
│ │ │ │ │ + if (point) {
│ │ │ │ │ + intersection = new OpenLayers.Geometry.Point(p.x, p.y);
│ │ │ │ │ + } else {
│ │ │ │ │ + intersection = true;
│ │ │ │ │ + }
│ │ │ │ │ + break outer;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + return intersection;
│ │ │ │ │ +};
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Function: OpenLayers.Geometry.distanceToSegment
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * point - {Object} An object with x and y properties representing the
│ │ │ │ │ + * point coordinates.
│ │ │ │ │ + * segment - {Object} An object with x1, y1, x2, and y2 properties
│ │ │ │ │ + * representing endpoint coordinates.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Object} An object with distance, along, x, and y properties. The distance
│ │ │ │ │ + * will be the shortest distance between the input point and segment.
│ │ │ │ │ + * The x and y properties represent the coordinates along the segment
│ │ │ │ │ + * where the shortest distance meets the segment. The along attribute
│ │ │ │ │ + * describes how far between the two segment points the given point is.
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Geometry.distanceToSegment = function(point, segment) {
│ │ │ │ │ + var result = OpenLayers.Geometry.distanceSquaredToSegment(point, segment);
│ │ │ │ │ + result.distance = Math.sqrt(result.distance);
│ │ │ │ │ + return result;
│ │ │ │ │ +};
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Function: OpenLayers.Geometry.distanceSquaredToSegment
│ │ │ │ │ + *
│ │ │ │ │ + * Usually the distanceToSegment function should be used. This variant however
│ │ │ │ │ + * can be used for comparisons where the exact distance is not important.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * point - {Object} An object with x and y properties representing the
│ │ │ │ │ + * point coordinates.
│ │ │ │ │ + * segment - {Object} An object with x1, y1, x2, and y2 properties
│ │ │ │ │ + * representing endpoint coordinates.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Object} An object with squared distance, along, x, and y properties.
│ │ │ │ │ + * The distance will be the shortest distance between the input point and
│ │ │ │ │ + * segment. The x and y properties represent the coordinates along the
│ │ │ │ │ + * segment where the shortest distance meets the segment. The along
│ │ │ │ │ + * attribute describes how far between the two segment points the given
│ │ │ │ │ + * point is.
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Geometry.distanceSquaredToSegment = function(point, segment) {
│ │ │ │ │ + var x0 = point.x;
│ │ │ │ │ + var y0 = point.y;
│ │ │ │ │ + var x1 = segment.x1;
│ │ │ │ │ + var y1 = segment.y1;
│ │ │ │ │ + var x2 = segment.x2;
│ │ │ │ │ + var y2 = segment.y2;
│ │ │ │ │ + var dx = x2 - x1;
│ │ │ │ │ + var dy = y2 - y1;
│ │ │ │ │ + var along = ((dx * (x0 - x1)) + (dy * (y0 - y1))) /
│ │ │ │ │ + (Math.pow(dx, 2) + Math.pow(dy, 2));
│ │ │ │ │ + var x, y;
│ │ │ │ │ + if (along <= 0.0) {
│ │ │ │ │ + x = x1;
│ │ │ │ │ + y = y1;
│ │ │ │ │ + } else if (along >= 1.0) {
│ │ │ │ │ + x = x2;
│ │ │ │ │ + y = y2;
│ │ │ │ │ + } else {
│ │ │ │ │ + x = x1 + along * dx;
│ │ │ │ │ + y = y1 + along * dy;
│ │ │ │ │ + }
│ │ │ │ │ + return {
│ │ │ │ │ + distance: Math.pow(x - x0, 2) + Math.pow(y - y0, 2),
│ │ │ │ │ + x: x,
│ │ │ │ │ + y: y,
│ │ │ │ │ + along: along
│ │ │ │ │ + };
│ │ │ │ │ +};
│ │ │ │ │ +/* ======================================================================
│ │ │ │ │ OpenLayers/Feature.js
│ │ │ │ │ ====================================================================== */
│ │ │ │ │
│ │ │ │ │ /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ * full text of the license. */
│ │ │ │ │ @@ -5169,5578 +6332,1334 @@
│ │ │ │ │
│ │ │ │ │ },
│ │ │ │ │ 'delete': {
│ │ │ │ │ display: "none"
│ │ │ │ │ }
│ │ │ │ │ };
│ │ │ │ │ /* ======================================================================
│ │ │ │ │ - OpenLayers/Style.js
│ │ │ │ │ + OpenLayers/Format.js
│ │ │ │ │ ====================================================================== */
│ │ │ │ │
│ │ │ │ │ /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ * full text of the license. */
│ │ │ │ │
│ │ │ │ │ -
│ │ │ │ │ /**
│ │ │ │ │ * @requires OpenLayers/BaseTypes/Class.js
│ │ │ │ │ * @requires OpenLayers/Util.js
│ │ │ │ │ - * @requires OpenLayers/Feature/Vector.js
│ │ │ │ │ */
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Class: OpenLayers.Style
│ │ │ │ │ - * This class represents a UserStyle obtained
│ │ │ │ │ - * from a SLD, containing styling rules.
│ │ │ │ │ + * Class: OpenLayers.Format
│ │ │ │ │ + * Base class for format reading/writing a variety of formats. Subclasses
│ │ │ │ │ + * of OpenLayers.Format are expected to have read and write methods.
│ │ │ │ │ */
│ │ │ │ │ -OpenLayers.Style = OpenLayers.Class({
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: id
│ │ │ │ │ - * {String} A unique id for this session.
│ │ │ │ │ - */
│ │ │ │ │ - id: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: name
│ │ │ │ │ - * {String}
│ │ │ │ │ - */
│ │ │ │ │ - name: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: title
│ │ │ │ │ - * {String} Title of this style (set if included in SLD)
│ │ │ │ │ - */
│ │ │ │ │ - title: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: description
│ │ │ │ │ - * {String} Description of this style (set if abstract is included in SLD)
│ │ │ │ │ - */
│ │ │ │ │ - description: null,
│ │ │ │ │ +OpenLayers.Format = OpenLayers.Class({
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: layerName
│ │ │ │ │ - * {} name of the layer that this style belongs to, usually
│ │ │ │ │ - * according to the NamedLayer attribute of an SLD document.
│ │ │ │ │ + * Property: options
│ │ │ │ │ + * {Object} A reference to options passed to the constructor.
│ │ │ │ │ */
│ │ │ │ │ - layerName: null,
│ │ │ │ │ + options: null,
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: isDefault
│ │ │ │ │ - * {Boolean}
│ │ │ │ │ - */
│ │ │ │ │ - isDefault: false,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: rules
│ │ │ │ │ - * {Array()}
│ │ │ │ │ + * APIProperty: externalProjection
│ │ │ │ │ + * {} When passed a externalProjection and
│ │ │ │ │ + * internalProjection, the format will reproject the geometries it
│ │ │ │ │ + * reads or writes. The externalProjection is the projection used by
│ │ │ │ │ + * the content which is passed into read or which comes out of write.
│ │ │ │ │ + * In order to reproject, a projection transformation function for the
│ │ │ │ │ + * specified projections must be available. This support may be
│ │ │ │ │ + * provided via proj4js or via a custom transformation function. See
│ │ │ │ │ + * {} for more information on
│ │ │ │ │ + * custom transformations.
│ │ │ │ │ */
│ │ │ │ │ - rules: null,
│ │ │ │ │ + externalProjection: null,
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: context
│ │ │ │ │ - * {Object} An optional object with properties that symbolizers' property
│ │ │ │ │ - * values should be evaluated against. If no context is specified,
│ │ │ │ │ - * feature.attributes will be used
│ │ │ │ │ + * APIProperty: internalProjection
│ │ │ │ │ + * {} When passed a externalProjection and
│ │ │ │ │ + * internalProjection, the format will reproject the geometries it
│ │ │ │ │ + * reads or writes. The internalProjection is the projection used by
│ │ │ │ │ + * the geometries which are returned by read or which are passed into
│ │ │ │ │ + * write. In order to reproject, a projection transformation function
│ │ │ │ │ + * for the specified projections must be available. This support may be
│ │ │ │ │ + * provided via proj4js or via a custom transformation function. See
│ │ │ │ │ + * {} for more information on
│ │ │ │ │ + * custom transformations.
│ │ │ │ │ */
│ │ │ │ │ - context: null,
│ │ │ │ │ + internalProjection: null,
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Property: defaultStyle
│ │ │ │ │ - * {Object} hash of style properties to use as default for merging
│ │ │ │ │ - * rule-based style symbolizers onto. If no rules are defined,
│ │ │ │ │ - * createSymbolizer will return this style. If is set to
│ │ │ │ │ - * true, the defaultStyle will only be taken into account if there are
│ │ │ │ │ - * rules defined.
│ │ │ │ │ + * APIProperty: data
│ │ │ │ │ + * {Object} When is true, this is the parsed string sent to
│ │ │ │ │ + * .
│ │ │ │ │ */
│ │ │ │ │ - defaultStyle: null,
│ │ │ │ │ + data: null,
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Property: defaultsPerSymbolizer
│ │ │ │ │ - * {Boolean} If set to true, the will extend the symbolizer
│ │ │ │ │ - * of every rule. Properties of the will also be used to set
│ │ │ │ │ - * missing symbolizer properties if the symbolizer has stroke, fill or
│ │ │ │ │ - * graphic set to true. Default is false.
│ │ │ │ │ + * APIProperty: keepData
│ │ │ │ │ + * {Object} Maintain a reference () to the most recently read data.
│ │ │ │ │ + * Default is false.
│ │ │ │ │ */
│ │ │ │ │ - defaultsPerSymbolizer: false,
│ │ │ │ │ + keepData: false,
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Property: propertyStyles
│ │ │ │ │ - * {Hash of Boolean} cache of style properties that need to be parsed for
│ │ │ │ │ - * propertyNames. Property names are keys, values won't be used.
│ │ │ │ │ - */
│ │ │ │ │ - propertyStyles: null,
│ │ │ │ │ -
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constructor: OpenLayers.Style
│ │ │ │ │ - * Creates a UserStyle.
│ │ │ │ │ + * Constructor: OpenLayers.Format
│ │ │ │ │ + * Instances of this class are not useful. See one of the subclasses.
│ │ │ │ │ *
│ │ │ │ │ * Parameters:
│ │ │ │ │ - * style - {Object} Optional hash of style properties that will be
│ │ │ │ │ - * used as default style for this style object. This style
│ │ │ │ │ - * applies if no rules are specified. Symbolizers defined in
│ │ │ │ │ - * rules will extend this default style.
│ │ │ │ │ * options - {Object} An optional object with properties to set on the
│ │ │ │ │ - * style.
│ │ │ │ │ + * format
│ │ │ │ │ *
│ │ │ │ │ * Valid options:
│ │ │ │ │ - * rules - {Array()} List of rules to be added to the
│ │ │ │ │ - * style.
│ │ │ │ │ - *
│ │ │ │ │ + * keepData - {Boolean} If true, upon , the data property will be
│ │ │ │ │ + * set to the parsed object (e.g. the json or xml object).
│ │ │ │ │ + *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * {}
│ │ │ │ │ + * An instance of OpenLayers.Format
│ │ │ │ │ */
│ │ │ │ │ - initialize: function(style, options) {
│ │ │ │ │ -
│ │ │ │ │ + initialize: function(options) {
│ │ │ │ │ OpenLayers.Util.extend(this, options);
│ │ │ │ │ - this.rules = [];
│ │ │ │ │ - if (options && options.rules) {
│ │ │ │ │ - this.addRules(options.rules);
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // use the default style from OpenLayers.Feature.Vector if no style
│ │ │ │ │ - // was given in the constructor
│ │ │ │ │ - this.setDefaultStyle(style ||
│ │ │ │ │ - OpenLayers.Feature.Vector.style["default"]);
│ │ │ │ │ -
│ │ │ │ │ - this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
│ │ │ │ │ + this.options = options;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ + /**
│ │ │ │ │ * APIMethod: destroy
│ │ │ │ │ - * nullify references to prevent circular references and memory leaks
│ │ │ │ │ + * Clean up.
│ │ │ │ │ */
│ │ │ │ │ - destroy: function() {
│ │ │ │ │ - for (var i = 0, len = this.rules.length; i < len; i++) {
│ │ │ │ │ - this.rules[i].destroy();
│ │ │ │ │ - this.rules[i] = null;
│ │ │ │ │ - }
│ │ │ │ │ - this.rules = null;
│ │ │ │ │ - this.defaultStyle = null;
│ │ │ │ │ - },
│ │ │ │ │ + destroy: function() {},
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Method: createSymbolizer
│ │ │ │ │ - * creates a style by applying all feature-dependent rules to the base
│ │ │ │ │ - * style.
│ │ │ │ │ + * Method: read
│ │ │ │ │ + * Read data from a string, and return an object whose type depends on the
│ │ │ │ │ + * subclass.
│ │ │ │ │ *
│ │ │ │ │ * Parameters:
│ │ │ │ │ - * feature - {} feature to evaluate rules for
│ │ │ │ │ - *
│ │ │ │ │ + * data - {string} Data to read/parse.
│ │ │ │ │ + *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * {Object} symbolizer hash
│ │ │ │ │ + * Depends on the subclass
│ │ │ │ │ */
│ │ │ │ │ - createSymbolizer: function(feature) {
│ │ │ │ │ - var style = this.defaultsPerSymbolizer ? {} : this.createLiterals(
│ │ │ │ │ - OpenLayers.Util.extend({}, this.defaultStyle), feature);
│ │ │ │ │ -
│ │ │ │ │ - var rules = this.rules;
│ │ │ │ │ -
│ │ │ │ │ - var rule, context;
│ │ │ │ │ - var elseRules = [];
│ │ │ │ │ - var appliedRules = false;
│ │ │ │ │ - for (var i = 0, len = rules.length; i < len; i++) {
│ │ │ │ │ - rule = rules[i];
│ │ │ │ │ - // does the rule apply?
│ │ │ │ │ - var applies = rule.evaluate(feature);
│ │ │ │ │ -
│ │ │ │ │ - if (applies) {
│ │ │ │ │ - if (rule instanceof OpenLayers.Rule && rule.elseFilter) {
│ │ │ │ │ - elseRules.push(rule);
│ │ │ │ │ - } else {
│ │ │ │ │ - appliedRules = true;
│ │ │ │ │ - this.applySymbolizer(rule, style, feature);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // if no other rules apply, apply the rules with else filters
│ │ │ │ │ - if (appliedRules == false && elseRules.length > 0) {
│ │ │ │ │ - appliedRules = true;
│ │ │ │ │ - for (var i = 0, len = elseRules.length; i < len; i++) {
│ │ │ │ │ - this.applySymbolizer(elseRules[i], style, feature);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // don't display if there were rules but none applied
│ │ │ │ │ - if (rules.length > 0 && appliedRules == false) {
│ │ │ │ │ - style.display = "none";
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - if (style.label != null && typeof style.label !== "string") {
│ │ │ │ │ - style.label = String(style.label);
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - return style;
│ │ │ │ │ + read: function(data) {
│ │ │ │ │ + throw new Error('Read not implemented.');
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Method: applySymbolizer
│ │ │ │ │ + * Method: write
│ │ │ │ │ + * Accept an object, and return a string.
│ │ │ │ │ *
│ │ │ │ │ * Parameters:
│ │ │ │ │ - * rule - {}
│ │ │ │ │ - * style - {Object}
│ │ │ │ │ - * feature - {}
│ │ │ │ │ + * object - {Object} Object to be serialized
│ │ │ │ │ *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * {Object} A style with new symbolizer applied.
│ │ │ │ │ + * {String} A string representation of the object.
│ │ │ │ │ */
│ │ │ │ │ - applySymbolizer: function(rule, style, feature) {
│ │ │ │ │ - var symbolizerPrefix = feature.geometry ?
│ │ │ │ │ - this.getSymbolizerPrefix(feature.geometry) :
│ │ │ │ │ - OpenLayers.Style.SYMBOLIZER_PREFIXES[0];
│ │ │ │ │ + write: function(object) {
│ │ │ │ │ + throw new Error('Write not implemented.');
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ - var symbolizer = rule.symbolizer[symbolizerPrefix] || rule.symbolizer;
│ │ │ │ │ + CLASS_NAME: "OpenLayers.Format"
│ │ │ │ │ +});
│ │ │ │ │ +/* ======================================================================
│ │ │ │ │ + OpenLayers/Geometry/Point.js
│ │ │ │ │ + ====================================================================== */
│ │ │ │ │
│ │ │ │ │ - if (this.defaultsPerSymbolizer === true) {
│ │ │ │ │ - var defaults = this.defaultStyle;
│ │ │ │ │ - OpenLayers.Util.applyDefaults(symbolizer, {
│ │ │ │ │ - pointRadius: defaults.pointRadius
│ │ │ │ │ - });
│ │ │ │ │ - if (symbolizer.stroke === true || symbolizer.graphic === true) {
│ │ │ │ │ - OpenLayers.Util.applyDefaults(symbolizer, {
│ │ │ │ │ - strokeWidth: defaults.strokeWidth,
│ │ │ │ │ - strokeColor: defaults.strokeColor,
│ │ │ │ │ - strokeOpacity: defaults.strokeOpacity,
│ │ │ │ │ - strokeDashstyle: defaults.strokeDashstyle,
│ │ │ │ │ - strokeLinecap: defaults.strokeLinecap
│ │ │ │ │ - });
│ │ │ │ │ - }
│ │ │ │ │ - if (symbolizer.fill === true || symbolizer.graphic === true) {
│ │ │ │ │ - OpenLayers.Util.applyDefaults(symbolizer, {
│ │ │ │ │ - fillColor: defaults.fillColor,
│ │ │ │ │ - fillOpacity: defaults.fillOpacity
│ │ │ │ │ - });
│ │ │ │ │ - }
│ │ │ │ │ - if (symbolizer.graphic === true) {
│ │ │ │ │ - OpenLayers.Util.applyDefaults(symbolizer, {
│ │ │ │ │ - pointRadius: this.defaultStyle.pointRadius,
│ │ │ │ │ - externalGraphic: this.defaultStyle.externalGraphic,
│ │ │ │ │ - graphicName: this.defaultStyle.graphicName,
│ │ │ │ │ - graphicOpacity: this.defaultStyle.graphicOpacity,
│ │ │ │ │ - graphicWidth: this.defaultStyle.graphicWidth,
│ │ │ │ │ - graphicHeight: this.defaultStyle.graphicHeight,
│ │ │ │ │ - graphicXOffset: this.defaultStyle.graphicXOffset,
│ │ │ │ │ - graphicYOffset: this.defaultStyle.graphicYOffset
│ │ │ │ │ - });
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ +/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ + * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ + * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ + * full text of the license. */
│ │ │ │ │
│ │ │ │ │ - // merge the style with the current style
│ │ │ │ │ - return this.createLiterals(
│ │ │ │ │ - OpenLayers.Util.extend(style, symbolizer), feature);
│ │ │ │ │ - },
│ │ │ │ │ +/**
│ │ │ │ │ + * @requires OpenLayers/Geometry.js
│ │ │ │ │ + */
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: createLiterals
│ │ │ │ │ - * creates literals for all style properties that have an entry in
│ │ │ │ │ - * .
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * style - {Object} style to create literals for. Will be modified
│ │ │ │ │ - * inline.
│ │ │ │ │ - * feature - {Object}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Object} the modified style
│ │ │ │ │ +/**
│ │ │ │ │ + * Class: OpenLayers.Geometry.Point
│ │ │ │ │ + * Point geometry class.
│ │ │ │ │ + *
│ │ │ │ │ + * Inherits from:
│ │ │ │ │ + * -
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Geometry.Point = OpenLayers.Class(OpenLayers.Geometry, {
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIProperty: x
│ │ │ │ │ + * {float}
│ │ │ │ │ */
│ │ │ │ │ - createLiterals: function(style, feature) {
│ │ │ │ │ - var context = OpenLayers.Util.extend({}, feature.attributes || feature.data);
│ │ │ │ │ - OpenLayers.Util.extend(context, this.context);
│ │ │ │ │ + x: null,
│ │ │ │ │
│ │ │ │ │ - for (var i in this.propertyStyles) {
│ │ │ │ │ - style[i] = OpenLayers.Style.createLiteral(style[i], context, feature, i);
│ │ │ │ │ - }
│ │ │ │ │ - return style;
│ │ │ │ │ - },
│ │ │ │ │ + /**
│ │ │ │ │ + * APIProperty: y
│ │ │ │ │ + * {float}
│ │ │ │ │ + */
│ │ │ │ │ + y: null,
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Method: findPropertyStyles
│ │ │ │ │ - * Looks into all rules for this style and the defaultStyle to collect
│ │ │ │ │ - * all the style hash property names containing ${...} strings that have
│ │ │ │ │ - * to be replaced using the createLiteral method before returning them.
│ │ │ │ │ + * Constructor: OpenLayers.Geometry.Point
│ │ │ │ │ + * Construct a point geometry.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * x - {float}
│ │ │ │ │ + * y - {float}
│ │ │ │ │ *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Object} hash of property names that need createLiteral parsing. The
│ │ │ │ │ - * name of the property is the key, and the value is true;
│ │ │ │ │ */
│ │ │ │ │ - findPropertyStyles: function() {
│ │ │ │ │ - var propertyStyles = {};
│ │ │ │ │ -
│ │ │ │ │ - // check the default style
│ │ │ │ │ - var style = this.defaultStyle;
│ │ │ │ │ - this.addPropertyStyles(propertyStyles, style);
│ │ │ │ │ + initialize: function(x, y) {
│ │ │ │ │ + OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
│ │ │ │ │
│ │ │ │ │ - // walk through all rules to check for properties in their symbolizer
│ │ │ │ │ - var rules = this.rules;
│ │ │ │ │ - var symbolizer, value;
│ │ │ │ │ - for (var i = 0, len = rules.length; i < len; i++) {
│ │ │ │ │ - symbolizer = rules[i].symbolizer;
│ │ │ │ │ - for (var key in symbolizer) {
│ │ │ │ │ - value = symbolizer[key];
│ │ │ │ │ - if (typeof value == "object") {
│ │ │ │ │ - // symbolizer key is "Point", "Line" or "Polygon"
│ │ │ │ │ - this.addPropertyStyles(propertyStyles, value);
│ │ │ │ │ - } else {
│ │ │ │ │ - // symbolizer is a hash of style properties
│ │ │ │ │ - this.addPropertyStyles(propertyStyles, symbolizer);
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - return propertyStyles;
│ │ │ │ │ + this.x = parseFloat(x);
│ │ │ │ │ + this.y = parseFloat(y);
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Method: addPropertyStyles
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * propertyStyles - {Object} hash to add new property styles to. Will be
│ │ │ │ │ - * modified inline
│ │ │ │ │ - * symbolizer - {Object} search this symbolizer for property styles
│ │ │ │ │ + * APIMethod: clone
│ │ │ │ │ *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * {Object} propertyStyles hash
│ │ │ │ │ + * {} An exact clone of this OpenLayers.Geometry.Point
│ │ │ │ │ */
│ │ │ │ │ - addPropertyStyles: function(propertyStyles, symbolizer) {
│ │ │ │ │ - var property;
│ │ │ │ │ - for (var key in symbolizer) {
│ │ │ │ │ - property = symbolizer[key];
│ │ │ │ │ - if (typeof property == "string" &&
│ │ │ │ │ - property.match(/\$\{\w+\}/)) {
│ │ │ │ │ - propertyStyles[key] = true;
│ │ │ │ │ - }
│ │ │ │ │ + clone: function(obj) {
│ │ │ │ │ + if (obj == null) {
│ │ │ │ │ + obj = new OpenLayers.Geometry.Point(this.x, this.y);
│ │ │ │ │ }
│ │ │ │ │ - return propertyStyles;
│ │ │ │ │ - },
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: addRules
│ │ │ │ │ - * Adds rules to this style.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * rules - {Array()}
│ │ │ │ │ - */
│ │ │ │ │ - addRules: function(rules) {
│ │ │ │ │ - Array.prototype.push.apply(this.rules, rules);
│ │ │ │ │ - this.propertyStyles = this.findPropertyStyles();
│ │ │ │ │ + // catch any randomly tagged-on properties
│ │ │ │ │ + OpenLayers.Util.applyDefaults(obj, this);
│ │ │ │ │ +
│ │ │ │ │ + return obj;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: setDefaultStyle
│ │ │ │ │ - * Sets the default style for this style object.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * style - {Object} Hash of style properties
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: calculateBounds
│ │ │ │ │ + * Create a new Bounds based on the lon/lat
│ │ │ │ │ */
│ │ │ │ │ - setDefaultStyle: function(style) {
│ │ │ │ │ - this.defaultStyle = style;
│ │ │ │ │ - this.propertyStyles = this.findPropertyStyles();
│ │ │ │ │ + calculateBounds: function() {
│ │ │ │ │ + this.bounds = new OpenLayers.Bounds(this.x, this.y,
│ │ │ │ │ + this.x, this.y);
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Method: getSymbolizerPrefix
│ │ │ │ │ - * Returns the correct symbolizer prefix according to the
│ │ │ │ │ - * geometry type of the passed geometry
│ │ │ │ │ - *
│ │ │ │ │ + * APIMethod: distanceTo
│ │ │ │ │ + * Calculate the closest distance between two geometries (on the x-y plane).
│ │ │ │ │ + *
│ │ │ │ │ * Parameters:
│ │ │ │ │ - * geometry - {}
│ │ │ │ │ - *
│ │ │ │ │ + * geometry - {} The target geometry.
│ │ │ │ │ + * options - {Object} Optional properties for configuring the distance
│ │ │ │ │ + * calculation.
│ │ │ │ │ + *
│ │ │ │ │ + * Valid options:
│ │ │ │ │ + * details - {Boolean} Return details from the distance calculation.
│ │ │ │ │ + * Default is false.
│ │ │ │ │ + * edge - {Boolean} Calculate the distance from this geometry to the
│ │ │ │ │ + * nearest edge of the target geometry. Default is true. If true,
│ │ │ │ │ + * calling distanceTo from a geometry that is wholly contained within
│ │ │ │ │ + * the target will result in a non-zero distance. If false, whenever
│ │ │ │ │ + * geometries intersect, calling distanceTo will return 0. If false,
│ │ │ │ │ + * details cannot be returned.
│ │ │ │ │ + *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * {String} key of the according symbolizer
│ │ │ │ │ + * {Number | Object} The distance between this geometry and the target.
│ │ │ │ │ + * If details is true, the return will be an object with distance,
│ │ │ │ │ + * x0, y0, x1, and x2 properties. The x0 and y0 properties represent
│ │ │ │ │ + * the coordinates of the closest point on this geometry. The x1 and y1
│ │ │ │ │ + * properties represent the coordinates of the closest point on the
│ │ │ │ │ + * target geometry.
│ │ │ │ │ */
│ │ │ │ │ - getSymbolizerPrefix: function(geometry) {
│ │ │ │ │ - var prefixes = OpenLayers.Style.SYMBOLIZER_PREFIXES;
│ │ │ │ │ - for (var i = 0, len = prefixes.length; i < len; i++) {
│ │ │ │ │ - if (geometry.CLASS_NAME.indexOf(prefixes[i]) != -1) {
│ │ │ │ │ - return prefixes[i];
│ │ │ │ │ + distanceTo: function(geometry, options) {
│ │ │ │ │ + var edge = !(options && options.edge === false);
│ │ │ │ │ + var details = edge && options && options.details;
│ │ │ │ │ + var distance, x0, y0, x1, y1, result;
│ │ │ │ │ + if (geometry instanceof OpenLayers.Geometry.Point) {
│ │ │ │ │ + x0 = this.x;
│ │ │ │ │ + y0 = this.y;
│ │ │ │ │ + x1 = geometry.x;
│ │ │ │ │ + y1 = geometry.y;
│ │ │ │ │ + distance = Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));
│ │ │ │ │ + result = !details ?
│ │ │ │ │ + distance : {
│ │ │ │ │ + x0: x0,
│ │ │ │ │ + y0: y0,
│ │ │ │ │ + x1: x1,
│ │ │ │ │ + y1: y1,
│ │ │ │ │ + distance: distance
│ │ │ │ │ + };
│ │ │ │ │ + } else {
│ │ │ │ │ + result = geometry.distanceTo(this, options);
│ │ │ │ │ + if (details) {
│ │ │ │ │ + // switch coord order since this geom is target
│ │ │ │ │ + result = {
│ │ │ │ │ + x0: result.x1,
│ │ │ │ │ + y0: result.y1,
│ │ │ │ │ + x1: result.x0,
│ │ │ │ │ + y1: result.y0,
│ │ │ │ │ + distance: result.distance
│ │ │ │ │ + };
│ │ │ │ │ }
│ │ │ │ │ }
│ │ │ │ │ + return result;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: clone
│ │ │ │ │ - * Clones this style.
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: equals
│ │ │ │ │ + * Determine whether another geometry is equivalent to this one. Geometries
│ │ │ │ │ + * are considered equivalent if all components have the same coordinates.
│ │ │ │ │ *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * geom - {} The geometry to test.
│ │ │ │ │ + *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * {} Clone of this style.
│ │ │ │ │ + * {Boolean} The supplied geometry is equivalent to this geometry.
│ │ │ │ │ */
│ │ │ │ │ - clone: function() {
│ │ │ │ │ - var options = OpenLayers.Util.extend({}, this);
│ │ │ │ │ - // clone rules
│ │ │ │ │ - if (this.rules) {
│ │ │ │ │ - options.rules = [];
│ │ │ │ │ - for (var i = 0, len = this.rules.length; i < len; ++i) {
│ │ │ │ │ - options.rules.push(this.rules[i].clone());
│ │ │ │ │ - }
│ │ │ │ │ + equals: function(geom) {
│ │ │ │ │ + var equals = false;
│ │ │ │ │ + if (geom != null) {
│ │ │ │ │ + equals = ((this.x == geom.x && this.y == geom.y) ||
│ │ │ │ │ + (isNaN(this.x) && isNaN(this.y) && isNaN(geom.x) && isNaN(geom.y)));
│ │ │ │ │ }
│ │ │ │ │ - // clone context
│ │ │ │ │ - options.context = this.context && OpenLayers.Util.extend({}, this.context);
│ │ │ │ │ - //clone default style
│ │ │ │ │ - var defaultStyle = OpenLayers.Util.extend({}, this.defaultStyle);
│ │ │ │ │ - return new OpenLayers.Style(defaultStyle, options);
│ │ │ │ │ + return equals;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Style"
│ │ │ │ │ -});
│ │ │ │ │ -
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Function: createLiteral
│ │ │ │ │ - * converts a style value holding a combination of PropertyName and Literal
│ │ │ │ │ - * into a Literal, taking the property values from the passed features.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * value - {String} value to parse. If this string contains a construct like
│ │ │ │ │ - * "foo ${bar}", then "foo " will be taken as literal, and "${bar}"
│ │ │ │ │ - * will be replaced by the value of the "bar" attribute of the passed
│ │ │ │ │ - * feature.
│ │ │ │ │ - * context - {Object} context to take attribute values from
│ │ │ │ │ - * feature - {} optional feature to pass to
│ │ │ │ │ - * for evaluating functions in the
│ │ │ │ │ - * context.
│ │ │ │ │ - * property - {String} optional, name of the property for which the literal is
│ │ │ │ │ - * being created for evaluating functions in the context.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {String} the parsed value. In the example of the value parameter above, the
│ │ │ │ │ - * result would be "foo valueOfBar", assuming that the passed feature has an
│ │ │ │ │ - * attribute named "bar" with the value "valueOfBar".
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Style.createLiteral = function(value, context, feature, property) {
│ │ │ │ │ - if (typeof value == "string" && value.indexOf("${") != -1) {
│ │ │ │ │ - value = OpenLayers.String.format(value, context, [feature, property]);
│ │ │ │ │ - value = (isNaN(value) || !value) ? value : parseFloat(value);
│ │ │ │ │ - }
│ │ │ │ │ - return value;
│ │ │ │ │ -};
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Constant: OpenLayers.Style.SYMBOLIZER_PREFIXES
│ │ │ │ │ - * {Array} prefixes of the sld symbolizers. These are the
│ │ │ │ │ - * same as the main geometry types
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Style.SYMBOLIZER_PREFIXES = ['Point', 'Line', 'Polygon', 'Text',
│ │ │ │ │ - 'Raster'
│ │ │ │ │ -];
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Rule.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/BaseTypes/Class.js
│ │ │ │ │ - * @requires OpenLayers/Util.js
│ │ │ │ │ - * @requires OpenLayers/Style.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Class: OpenLayers.Rule
│ │ │ │ │ - * This class represents an SLD Rule, as being used for rule-based SLD styling.
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Rule = OpenLayers.Class({
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: id
│ │ │ │ │ - * {String} A unique id for this session.
│ │ │ │ │ - */
│ │ │ │ │ - id: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: name
│ │ │ │ │ - * {String} name of this rule
│ │ │ │ │ - */
│ │ │ │ │ - name: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: title
│ │ │ │ │ - * {String} Title of this rule (set if included in SLD)
│ │ │ │ │ - */
│ │ │ │ │ - title: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: description
│ │ │ │ │ - * {String} Description of this rule (set if abstract is included in SLD)
│ │ │ │ │ - */
│ │ │ │ │ - description: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: context
│ │ │ │ │ - * {Object} An optional object with properties that the rule should be
│ │ │ │ │ - * evaluated against. If no context is specified, feature.attributes will
│ │ │ │ │ - * be used.
│ │ │ │ │ - */
│ │ │ │ │ - context: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: filter
│ │ │ │ │ - * {} Optional filter for the rule.
│ │ │ │ │ - */
│ │ │ │ │ - filter: null,
│ │ │ │ │ -
│ │ │ │ │ /**
│ │ │ │ │ - * Property: elseFilter
│ │ │ │ │ - * {Boolean} Determines whether this rule is only to be applied only if
│ │ │ │ │ - * no other rules match (ElseFilter according to the SLD specification).
│ │ │ │ │ - * Default is false. For instances of OpenLayers.Rule, if elseFilter is
│ │ │ │ │ - * false, the rule will always apply. For subclasses, the else property is
│ │ │ │ │ - * ignored.
│ │ │ │ │ + * Method: toShortString
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {String} Shortened String representation of Point object.
│ │ │ │ │ + * (ex. "5, 42")
│ │ │ │ │ */
│ │ │ │ │ - elseFilter: false,
│ │ │ │ │ + toShortString: function() {
│ │ │ │ │ + return (this.x + ", " + this.y);
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Property: symbolizer
│ │ │ │ │ - * {Object} Symbolizer or hash of symbolizers for this rule. If hash of
│ │ │ │ │ - * symbolizers, keys are one or more of ["Point", "Line", "Polygon"]. The
│ │ │ │ │ - * latter if useful if it is required to style e.g. vertices of a line
│ │ │ │ │ - * with a point symbolizer. Note, however, that this is not implemented
│ │ │ │ │ - * yet in OpenLayers, but it is the way how symbolizers are defined in
│ │ │ │ │ - * SLD.
│ │ │ │ │ + * APIMethod: move
│ │ │ │ │ + * Moves a geometry by the given displacement along positive x and y axes.
│ │ │ │ │ + * This modifies the position of the geometry and clears the cached
│ │ │ │ │ + * bounds.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * x - {Float} Distance to move geometry in positive x direction.
│ │ │ │ │ + * y - {Float} Distance to move geometry in positive y direction.
│ │ │ │ │ */
│ │ │ │ │ - symbolizer: null,
│ │ │ │ │ + move: function(x, y) {
│ │ │ │ │ + this.x = this.x + x;
│ │ │ │ │ + this.y = this.y + y;
│ │ │ │ │ + this.clearBounds();
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Property: symbolizers
│ │ │ │ │ - * {Array} Collection of symbolizers associated with this rule. If
│ │ │ │ │ - * provided at construction, the symbolizers array has precedence
│ │ │ │ │ - * over the deprecated symbolizer property. Note that multiple
│ │ │ │ │ - * symbolizers are not currently supported by the vector renderers.
│ │ │ │ │ - * Rules with multiple symbolizers are currently only useful for
│ │ │ │ │ - * maintaining elements in an SLD document.
│ │ │ │ │ + * APIMethod: rotate
│ │ │ │ │ + * Rotate a point around another.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * angle - {Float} Rotation angle in degrees (measured counterclockwise
│ │ │ │ │ + * from the positive x-axis)
│ │ │ │ │ + * origin - {} Center point for the rotation
│ │ │ │ │ */
│ │ │ │ │ - symbolizers: null,
│ │ │ │ │ + rotate: function(angle, origin) {
│ │ │ │ │ + angle *= Math.PI / 180;
│ │ │ │ │ + var radius = this.distanceTo(origin);
│ │ │ │ │ + var theta = angle + Math.atan2(this.y - origin.y, this.x - origin.x);
│ │ │ │ │ + this.x = origin.x + (radius * Math.cos(theta));
│ │ │ │ │ + this.y = origin.y + (radius * Math.sin(theta));
│ │ │ │ │ + this.clearBounds();
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: minScaleDenominator
│ │ │ │ │ - * {Number} or {String} minimum scale at which to draw the feature.
│ │ │ │ │ - * In the case of a String, this can be a combination of text and
│ │ │ │ │ - * propertyNames in the form "literal ${propertyName}"
│ │ │ │ │ + * APIMethod: getCentroid
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {} The centroid of the collection
│ │ │ │ │ */
│ │ │ │ │ - minScaleDenominator: null,
│ │ │ │ │ + getCentroid: function() {
│ │ │ │ │ + return new OpenLayers.Geometry.Point(this.x, this.y);
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: maxScaleDenominator
│ │ │ │ │ - * {Number} or {String} maximum scale at which to draw the feature.
│ │ │ │ │ - * In the case of a String, this can be a combination of text and
│ │ │ │ │ - * propertyNames in the form "literal ${propertyName}"
│ │ │ │ │ - */
│ │ │ │ │ - maxScaleDenominator: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constructor: OpenLayers.Rule
│ │ │ │ │ - * Creates a Rule.
│ │ │ │ │ + * APIMethod: resize
│ │ │ │ │ + * Resize a point relative to some origin. For points, this has the effect
│ │ │ │ │ + * of scaling a vector (from the origin to the point). This method is
│ │ │ │ │ + * more useful on geometry collection subclasses.
│ │ │ │ │ *
│ │ │ │ │ * Parameters:
│ │ │ │ │ - * options - {Object} An optional object with properties to set on the
│ │ │ │ │ - * rule
│ │ │ │ │ + * scale - {Float} Ratio of the new distance from the origin to the old
│ │ │ │ │ + * distance from the origin. A scale of 2 doubles the
│ │ │ │ │ + * distance between the point and origin.
│ │ │ │ │ + * origin - {} Point of origin for resizing
│ │ │ │ │ + * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.
│ │ │ │ │ *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * {}
│ │ │ │ │ - */
│ │ │ │ │ - initialize: function(options) {
│ │ │ │ │ - this.symbolizer = {};
│ │ │ │ │ - OpenLayers.Util.extend(this, options);
│ │ │ │ │ - if (this.symbolizers) {
│ │ │ │ │ - delete this.symbolizer;
│ │ │ │ │ - }
│ │ │ │ │ - this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: destroy
│ │ │ │ │ - * nullify references to prevent circular references and memory leaks
│ │ │ │ │ + * {} - The current geometry.
│ │ │ │ │ */
│ │ │ │ │ - destroy: function() {
│ │ │ │ │ - for (var i in this.symbolizer) {
│ │ │ │ │ - this.symbolizer[i] = null;
│ │ │ │ │ - }
│ │ │ │ │ - this.symbolizer = null;
│ │ │ │ │ - delete this.symbolizers;
│ │ │ │ │ + resize: function(scale, origin, ratio) {
│ │ │ │ │ + ratio = (ratio == undefined) ? 1 : ratio;
│ │ │ │ │ + this.x = origin.x + (scale * ratio * (this.x - origin.x));
│ │ │ │ │ + this.y = origin.y + (scale * (this.y - origin.y));
│ │ │ │ │ + this.clearBounds();
│ │ │ │ │ + return this;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIMethod: evaluate
│ │ │ │ │ - * evaluates this rule for a specific feature
│ │ │ │ │ - *
│ │ │ │ │ + * APIMethod: intersects
│ │ │ │ │ + * Determine if the input geometry intersects this one.
│ │ │ │ │ + *
│ │ │ │ │ * Parameters:
│ │ │ │ │ - * feature - {} feature to apply the rule to.
│ │ │ │ │ - *
│ │ │ │ │ + * geometry - {} Any type of geometry.
│ │ │ │ │ + *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * {Boolean} true if the rule applies, false if it does not.
│ │ │ │ │ - * This rule is the default rule and always returns true.
│ │ │ │ │ + * {Boolean} The input geometry intersects this one.
│ │ │ │ │ */
│ │ │ │ │ - evaluate: function(feature) {
│ │ │ │ │ - var context = this.getContext(feature);
│ │ │ │ │ - var applies = true;
│ │ │ │ │ -
│ │ │ │ │ - if (this.minScaleDenominator || this.maxScaleDenominator) {
│ │ │ │ │ - var scale = feature.layer.map.getScale();
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // check if within minScale/maxScale bounds
│ │ │ │ │ - if (this.minScaleDenominator) {
│ │ │ │ │ - applies = scale >= OpenLayers.Style.createLiteral(
│ │ │ │ │ - this.minScaleDenominator, context);
│ │ │ │ │ - }
│ │ │ │ │ - if (applies && this.maxScaleDenominator) {
│ │ │ │ │ - applies = scale < OpenLayers.Style.createLiteral(
│ │ │ │ │ - this.maxScaleDenominator, context);
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // check if optional filter applies
│ │ │ │ │ - if (applies && this.filter) {
│ │ │ │ │ - // feature id filters get the feature, others get the context
│ │ │ │ │ - if (this.filter.CLASS_NAME == "OpenLayers.Filter.FeatureId") {
│ │ │ │ │ - applies = this.filter.evaluate(feature);
│ │ │ │ │ - } else {
│ │ │ │ │ - applies = this.filter.evaluate(context);
│ │ │ │ │ - }
│ │ │ │ │ + intersects: function(geometry) {
│ │ │ │ │ + var intersect = false;
│ │ │ │ │ + if (geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
│ │ │ │ │ + intersect = this.equals(geometry);
│ │ │ │ │ + } else {
│ │ │ │ │ + intersect = geometry.intersects(this);
│ │ │ │ │ }
│ │ │ │ │ -
│ │ │ │ │ - return applies;
│ │ │ │ │ + return intersect;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Method: getContext
│ │ │ │ │ - * Gets the context for evaluating this rule
│ │ │ │ │ + * APIMethod: transform
│ │ │ │ │ + * Translate the x,y properties of the point from source to dest.
│ │ │ │ │ *
│ │ │ │ │ - * Paramters:
│ │ │ │ │ - * feature - {} feature to take the context from if
│ │ │ │ │ - * none is specified.
│ │ │ │ │ - */
│ │ │ │ │ - getContext: function(feature) {
│ │ │ │ │ - var context = this.context;
│ │ │ │ │ - if (!context) {
│ │ │ │ │ - context = feature.attributes || feature.data;
│ │ │ │ │ - }
│ │ │ │ │ - if (typeof this.context == "function") {
│ │ │ │ │ - context = this.context(feature);
│ │ │ │ │ - }
│ │ │ │ │ - return context;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: clone
│ │ │ │ │ - * Clones this rule.
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * source - {}
│ │ │ │ │ + * dest - {}
│ │ │ │ │ *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * {} Clone of this rule.
│ │ │ │ │ + * {}
│ │ │ │ │ */
│ │ │ │ │ - clone: function() {
│ │ │ │ │ - var options = OpenLayers.Util.extend({}, this);
│ │ │ │ │ - if (this.symbolizers) {
│ │ │ │ │ - // clone symbolizers
│ │ │ │ │ - var len = this.symbolizers.length;
│ │ │ │ │ - options.symbolizers = new Array(len);
│ │ │ │ │ - for (var i = 0; i < len; ++i) {
│ │ │ │ │ - options.symbolizers[i] = this.symbolizers[i].clone();
│ │ │ │ │ - }
│ │ │ │ │ - } else {
│ │ │ │ │ - // clone symbolizer
│ │ │ │ │ - options.symbolizer = {};
│ │ │ │ │ - var value, type;
│ │ │ │ │ - for (var key in this.symbolizer) {
│ │ │ │ │ - value = this.symbolizer[key];
│ │ │ │ │ - type = typeof value;
│ │ │ │ │ - if (type === "object") {
│ │ │ │ │ - options.symbolizer[key] = OpenLayers.Util.extend({}, value);
│ │ │ │ │ - } else if (type === "string") {
│ │ │ │ │ - options.symbolizer[key] = value;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ + transform: function(source, dest) {
│ │ │ │ │ + if ((source && dest)) {
│ │ │ │ │ + OpenLayers.Projection.transform(
│ │ │ │ │ + this, source, dest);
│ │ │ │ │ + this.bounds = null;
│ │ │ │ │ }
│ │ │ │ │ - // clone filter
│ │ │ │ │ - options.filter = this.filter && this.filter.clone();
│ │ │ │ │ - // clone context
│ │ │ │ │ - options.context = this.context && OpenLayers.Util.extend({}, this.context);
│ │ │ │ │ - return new OpenLayers.Rule(options);
│ │ │ │ │ + return this;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Rule"
│ │ │ │ │ -});
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Symbolizer.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/BaseTypes/Class.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Class: OpenLayers.Symbolizer
│ │ │ │ │ - * Base class representing a symbolizer used for feature rendering.
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Symbolizer = OpenLayers.Class({
│ │ │ │ │ -
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: zIndex
│ │ │ │ │ - * {Number} The zIndex determines the rendering order for a symbolizer.
│ │ │ │ │ - * Symbolizers with larger zIndex values are rendered over symbolizers
│ │ │ │ │ - * with smaller zIndex values. Default is 0.
│ │ │ │ │ - */
│ │ │ │ │ - zIndex: 0,
│ │ │ │ │ -
│ │ │ │ │ /**
│ │ │ │ │ - * Constructor: OpenLayers.Symbolizer
│ │ │ │ │ - * Instances of this class are not useful. See one of the subclasses.
│ │ │ │ │ + * APIMethod: getVertices
│ │ │ │ │ + * Return a list of all points in this geometry.
│ │ │ │ │ *
│ │ │ │ │ * Parameters:
│ │ │ │ │ - * config - {Object} An object containing properties to be set on the
│ │ │ │ │ - * symbolizer. Any documented symbolizer property can be set at
│ │ │ │ │ - * construction.
│ │ │ │ │ + * nodes - {Boolean} For lines, only return vertices that are
│ │ │ │ │ + * endpoints. If false, for lines, only vertices that are not
│ │ │ │ │ + * endpoints will be returned. If not provided, all vertices will
│ │ │ │ │ + * be returned.
│ │ │ │ │ *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * A new symbolizer.
│ │ │ │ │ - */
│ │ │ │ │ - initialize: function(config) {
│ │ │ │ │ - OpenLayers.Util.extend(this, config);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: clone
│ │ │ │ │ - * Create a copy of this symbolizer.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns a symbolizer of the same type with the same properties.
│ │ │ │ │ + * {Array} A list of all vertices in the geometry.
│ │ │ │ │ */
│ │ │ │ │ - clone: function() {
│ │ │ │ │ - var Type = eval(this.CLASS_NAME);
│ │ │ │ │ - return new Type(OpenLayers.Util.extend({}, this));
│ │ │ │ │ + getVertices: function(nodes) {
│ │ │ │ │ + return [this];
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Symbolizer"
│ │ │ │ │ -
│ │ │ │ │ + CLASS_NAME: "OpenLayers.Geometry.Point"
│ │ │ │ │ });
│ │ │ │ │ -
│ │ │ │ │ /* ======================================================================
│ │ │ │ │ - OpenLayers/Symbolizer/Point.js
│ │ │ │ │ + OpenLayers/Geometry/Collection.js
│ │ │ │ │ ====================================================================== */
│ │ │ │ │
│ │ │ │ │ /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ * full text of the license. */
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * @requires OpenLayers/Symbolizer.js
│ │ │ │ │ + * @requires OpenLayers/Geometry.js
│ │ │ │ │ */
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Class: OpenLayers.Symbolizer.Point
│ │ │ │ │ - * A symbolizer used to render point features.
│ │ │ │ │ + * Class: OpenLayers.Geometry.Collection
│ │ │ │ │ + * A Collection is exactly what it sounds like: A collection of different
│ │ │ │ │ + * Geometries. These are stored in the local parameter (which
│ │ │ │ │ + * can be passed as a parameter to the constructor).
│ │ │ │ │ + *
│ │ │ │ │ + * As new geometries are added to the collection, they are NOT cloned.
│ │ │ │ │ + * When removing geometries, they need to be specified by reference (ie you
│ │ │ │ │ + * have to pass in the *exact* geometry to be removed).
│ │ │ │ │ + *
│ │ │ │ │ + * The and functions here merely iterate through
│ │ │ │ │ + * the components, summing their respective areas and lengths.
│ │ │ │ │ + *
│ │ │ │ │ + * Create a new instance with the constructor.
│ │ │ │ │ + *
│ │ │ │ │ + * Inherits from:
│ │ │ │ │ + * -
│ │ │ │ │ */
│ │ │ │ │ -OpenLayers.Symbolizer.Point = OpenLayers.Class(OpenLayers.Symbolizer, {
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: strokeColor
│ │ │ │ │ - * {String} Color for line stroke. This is a RGB hex value (e.g. "#ff0000"
│ │ │ │ │ - * for red).
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: strokeOpacity
│ │ │ │ │ - * {Number} Stroke opacity (0-1).
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ - */
│ │ │ │ │ +OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: strokeWidth
│ │ │ │ │ - * {Number} Pixel stroke width.
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * APIProperty: components
│ │ │ │ │ + * {Array()} The component parts of this geometry
│ │ │ │ │ */
│ │ │ │ │ + components: null,
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: strokeLinecap
│ │ │ │ │ - * {String} Stroke cap type ("butt", "round", or "square").
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * Property: componentTypes
│ │ │ │ │ + * {Array(String)} An array of class names representing the types of
│ │ │ │ │ + * components that the collection can include. A null value means the
│ │ │ │ │ + * component types are not restricted.
│ │ │ │ │ */
│ │ │ │ │ + componentTypes: null,
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Property: strokeDashstyle
│ │ │ │ │ - * {String} Stroke dash style according to the SLD spec. Note that the
│ │ │ │ │ - * OpenLayers values for strokeDashstyle ("dot", "dash", "dashdot",
│ │ │ │ │ - * "longdash", "longdashdot", or "solid") will not work in SLD, but
│ │ │ │ │ - * most SLD patterns will render correctly in OpenLayers.
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * Constructor: OpenLayers.Geometry.Collection
│ │ │ │ │ + * Creates a Geometry Collection -- a list of geoms.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * components - {Array()} Optional array of geometries
│ │ │ │ │ + *
│ │ │ │ │ */
│ │ │ │ │ + initialize: function(components) {
│ │ │ │ │ + OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
│ │ │ │ │ + this.components = [];
│ │ │ │ │ + if (components != null) {
│ │ │ │ │ + this.addComponents(components);
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: fillColor
│ │ │ │ │ - * {String} RGB hex fill color (e.g. "#ff0000" for red).
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * APIMethod: destroy
│ │ │ │ │ + * Destroy this geometry.
│ │ │ │ │ */
│ │ │ │ │ + destroy: function() {
│ │ │ │ │ + this.components.length = 0;
│ │ │ │ │ + this.components = null;
│ │ │ │ │ + OpenLayers.Geometry.prototype.destroy.apply(this, arguments);
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: fillOpacity
│ │ │ │ │ - * {Number} Fill opacity (0-1).
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * APIMethod: clone
│ │ │ │ │ + * Clone this geometry.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {} An exact clone of this collection
│ │ │ │ │ */
│ │ │ │ │ + clone: function() {
│ │ │ │ │ + var geometry = eval("new " + this.CLASS_NAME + "()");
│ │ │ │ │ + for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ + geometry.addComponent(this.components[i].clone());
│ │ │ │ │ + }
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: pointRadius
│ │ │ │ │ - * {Number} Pixel point radius.
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ - */
│ │ │ │ │ + // catch any randomly tagged-on properties
│ │ │ │ │ + OpenLayers.Util.applyDefaults(geometry, this);
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: externalGraphic
│ │ │ │ │ - * {String} Url to an external graphic that will be used for rendering
│ │ │ │ │ - * points.
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ - */
│ │ │ │ │ + return geometry;
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: graphicWidth
│ │ │ │ │ - * {Number} Pixel width for sizing an external graphic.
│ │ │ │ │ + * Method: getComponentsString
│ │ │ │ │ + * Get a string representing the components for this collection
│ │ │ │ │ *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {String} A string representation of the components of this geometry
│ │ │ │ │ */
│ │ │ │ │ + getComponentsString: function() {
│ │ │ │ │ + var strings = [];
│ │ │ │ │ + for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ + strings.push(this.components[i].toShortString());
│ │ │ │ │ + }
│ │ │ │ │ + return strings.join(",");
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: graphicHeight
│ │ │ │ │ - * {Number} Pixel height for sizing an external graphic.
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * APIMethod: calculateBounds
│ │ │ │ │ + * Recalculate the bounds by iterating through the components and
│ │ │ │ │ + * calling calling extendBounds() on each item.
│ │ │ │ │ */
│ │ │ │ │ + calculateBounds: function() {
│ │ │ │ │ + this.bounds = null;
│ │ │ │ │ + var bounds = new OpenLayers.Bounds();
│ │ │ │ │ + var components = this.components;
│ │ │ │ │ + if (components) {
│ │ │ │ │ + for (var i = 0, len = components.length; i < len; i++) {
│ │ │ │ │ + bounds.extend(components[i].getBounds());
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + // to preserve old behavior, we only set bounds if non-null
│ │ │ │ │ + // in the future, we could add bounds.isEmpty()
│ │ │ │ │ + if (bounds.left != null && bounds.bottom != null &&
│ │ │ │ │ + bounds.right != null && bounds.top != null) {
│ │ │ │ │ + this.setBounds(bounds);
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: graphicOpacity
│ │ │ │ │ - * {Number} Opacity (0-1) for an external graphic.
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * APIMethod: addComponents
│ │ │ │ │ + * Add components to this geometry.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * components - {Array()} An array of geometries to add
│ │ │ │ │ */
│ │ │ │ │ + addComponents: function(components) {
│ │ │ │ │ + if (!(OpenLayers.Util.isArray(components))) {
│ │ │ │ │ + components = [components];
│ │ │ │ │ + }
│ │ │ │ │ + for (var i = 0, len = components.length; i < len; i++) {
│ │ │ │ │ + this.addComponent(components[i]);
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: graphicXOffset
│ │ │ │ │ - * {Number} Pixel offset along the positive x axis for displacing an
│ │ │ │ │ - * external graphic.
│ │ │ │ │ + * Method: addComponent
│ │ │ │ │ + * Add a new component (geometry) to the collection. If this.componentTypes
│ │ │ │ │ + * is set, then the component class name must be in the componentTypes array.
│ │ │ │ │ + *
│ │ │ │ │ + * The bounds cache is reset.
│ │ │ │ │ *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * component - {} A geometry to add
│ │ │ │ │ + * index - {int} Optional index into the array to insert the component
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean} The component geometry was successfully added
│ │ │ │ │ */
│ │ │ │ │ + addComponent: function(component, index) {
│ │ │ │ │ + var added = false;
│ │ │ │ │ + if (component) {
│ │ │ │ │ + if (this.componentTypes == null ||
│ │ │ │ │ + (OpenLayers.Util.indexOf(this.componentTypes,
│ │ │ │ │ + component.CLASS_NAME) > -1)) {
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: graphicYOffset
│ │ │ │ │ - * {Number} Pixel offset along the positive y axis for displacing an
│ │ │ │ │ - * external graphic.
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ - */
│ │ │ │ │ + if (index != null && (index < this.components.length)) {
│ │ │ │ │ + var components1 = this.components.slice(0, index);
│ │ │ │ │ + var components2 = this.components.slice(index,
│ │ │ │ │ + this.components.length);
│ │ │ │ │ + components1.push(component);
│ │ │ │ │ + this.components = components1.concat(components2);
│ │ │ │ │ + } else {
│ │ │ │ │ + this.components.push(component);
│ │ │ │ │ + }
│ │ │ │ │ + component.parent = this;
│ │ │ │ │ + this.clearBounds();
│ │ │ │ │ + added = true;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + return added;
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: rotation
│ │ │ │ │ - * {Number} The rotation of a graphic in the clockwise direction about its
│ │ │ │ │ - * center point (or any point off center as specified by
│ │ │ │ │ - * and ).
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * APIMethod: removeComponents
│ │ │ │ │ + * Remove components from this geometry.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * components - {Array()} The components to be removed
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean} A component was removed.
│ │ │ │ │ */
│ │ │ │ │ + removeComponents: function(components) {
│ │ │ │ │ + var removed = false;
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: graphicName
│ │ │ │ │ - * {String} Named graphic to use when rendering points. Supported values
│ │ │ │ │ - * include "circle", "square", "star", "x", "cross", and "triangle".
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ - */
│ │ │ │ │ + if (!(OpenLayers.Util.isArray(components))) {
│ │ │ │ │ + components = [components];
│ │ │ │ │ + }
│ │ │ │ │ + for (var i = components.length - 1; i >= 0; --i) {
│ │ │ │ │ + removed = this.removeComponent(components[i]) || removed;
│ │ │ │ │ + }
│ │ │ │ │ + return removed;
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Constructor: OpenLayers.Symbolizer.Point
│ │ │ │ │ - * Create a symbolizer for rendering points.
│ │ │ │ │ + * Method: removeComponent
│ │ │ │ │ + * Remove a component from this geometry.
│ │ │ │ │ *
│ │ │ │ │ * Parameters:
│ │ │ │ │ - * config - {Object} An object containing properties to be set on the
│ │ │ │ │ - * symbolizer. Any documented symbolizer property can be set at
│ │ │ │ │ - * construction.
│ │ │ │ │ + * component - {}
│ │ │ │ │ *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * A new point symbolizer.
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean} The component was removed.
│ │ │ │ │ */
│ │ │ │ │ - initialize: function(config) {
│ │ │ │ │ - OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Symbolizer.Point"
│ │ │ │ │ -
│ │ │ │ │ -});
│ │ │ │ │ -
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Symbolizer/Line.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/Symbolizer.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Class: OpenLayers.Symbolizer.Line
│ │ │ │ │ - * A symbolizer used to render line features.
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Symbolizer.Line = OpenLayers.Class(OpenLayers.Symbolizer, {
│ │ │ │ │ + removeComponent: function(component) {
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: strokeColor
│ │ │ │ │ - * {String} Color for line stroke. This is a RGB hex value (e.g. "#ff0000"
│ │ │ │ │ - * for red).
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ - */
│ │ │ │ │ + OpenLayers.Util.removeItem(this.components, component);
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: strokeOpacity
│ │ │ │ │ - * {Number} Stroke opacity (0-1).
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ - */
│ │ │ │ │ + // clearBounds() so that it gets recalculated on the next call
│ │ │ │ │ + // to this.getBounds();
│ │ │ │ │ + this.clearBounds();
│ │ │ │ │ + return true;
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: strokeWidth
│ │ │ │ │ - * {Number} Pixel stroke width.
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * APIMethod: getLength
│ │ │ │ │ + * Calculate the length of this geometry
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Float} The length of the geometry
│ │ │ │ │ */
│ │ │ │ │ + getLength: function() {
│ │ │ │ │ + var length = 0.0;
│ │ │ │ │ + for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ + length += this.components[i].getLength();
│ │ │ │ │ + }
│ │ │ │ │ + return length;
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: strokeLinecap
│ │ │ │ │ - * {String} Stroke cap type ("butt", "round", or "square").
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * APIMethod: getArea
│ │ │ │ │ + * Calculate the area of this geometry. Note how this function is overridden
│ │ │ │ │ + * in .
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Float} The area of the collection by summing its parts
│ │ │ │ │ */
│ │ │ │ │ + getArea: function() {
│ │ │ │ │ + var area = 0.0;
│ │ │ │ │ + for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ + area += this.components[i].getArea();
│ │ │ │ │ + }
│ │ │ │ │ + return area;
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: strokeDashstyle
│ │ │ │ │ - * {String} Stroke dash style according to the SLD spec. Note that the
│ │ │ │ │ - * OpenLayers values for strokeDashstyle ("dot", "dash", "dashdot",
│ │ │ │ │ - * "longdash", "longdashdot", or "solid") will not work in SLD, but
│ │ │ │ │ - * most SLD patterns will render correctly in OpenLayers.
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: getGeodesicArea
│ │ │ │ │ + * Calculate the approximate area of the polygon were it projected onto
│ │ │ │ │ + * the earth.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * projection - {} The spatial reference system
│ │ │ │ │ + * for the geometry coordinates. If not provided, Geographic/WGS84 is
│ │ │ │ │ + * assumed.
│ │ │ │ │ *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * Reference:
│ │ │ │ │ + * Robert. G. Chamberlain and William H. Duquette, "Some Algorithms for
│ │ │ │ │ + * Polygons on a Sphere", JPL Publication 07-03, Jet Propulsion
│ │ │ │ │ + * Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {float} The approximate geodesic area of the geometry in square meters.
│ │ │ │ │ */
│ │ │ │ │ + getGeodesicArea: function(projection) {
│ │ │ │ │ + var area = 0.0;
│ │ │ │ │ + for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ + area += this.components[i].getGeodesicArea(projection);
│ │ │ │ │ + }
│ │ │ │ │ + return area;
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Constructor: OpenLayers.Symbolizer.Line
│ │ │ │ │ - * Create a symbolizer for rendering lines.
│ │ │ │ │ + * APIMethod: getCentroid
│ │ │ │ │ + *
│ │ │ │ │ + * Compute the centroid for this geometry collection.
│ │ │ │ │ *
│ │ │ │ │ * Parameters:
│ │ │ │ │ - * config - {Object} An object containing properties to be set on the
│ │ │ │ │ - * symbolizer. Any documented symbolizer property can be set at
│ │ │ │ │ - * construction.
│ │ │ │ │ + * weighted - {Boolean} Perform the getCentroid computation recursively,
│ │ │ │ │ + * returning an area weighted average of all geometries in this collection.
│ │ │ │ │ *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * A new line symbolizer.
│ │ │ │ │ + * {} The centroid of the collection
│ │ │ │ │ */
│ │ │ │ │ - initialize: function(config) {
│ │ │ │ │ - OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Symbolizer.Line"
│ │ │ │ │ -
│ │ │ │ │ -});
│ │ │ │ │ -
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Symbolizer/Polygon.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/Symbolizer.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Class: OpenLayers.Symbolizer.Polygon
│ │ │ │ │ - * A symbolizer used to render line features.
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Symbolizer.Polygon = OpenLayers.Class(OpenLayers.Symbolizer, {
│ │ │ │ │ + getCentroid: function(weighted) {
│ │ │ │ │ + if (!weighted) {
│ │ │ │ │ + return this.components.length && this.components[0].getCentroid();
│ │ │ │ │ + }
│ │ │ │ │ + var len = this.components.length;
│ │ │ │ │ + if (!len) {
│ │ │ │ │ + return false;
│ │ │ │ │ + }
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: strokeColor
│ │ │ │ │ - * {String} Color for line stroke. This is a RGB hex value (e.g. "#ff0000"
│ │ │ │ │ - * for red).
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ - */
│ │ │ │ │ + var areas = [];
│ │ │ │ │ + var centroids = [];
│ │ │ │ │ + var areaSum = 0;
│ │ │ │ │ + var minArea = Number.MAX_VALUE;
│ │ │ │ │ + var component;
│ │ │ │ │ + for (var i = 0; i < len; ++i) {
│ │ │ │ │ + component = this.components[i];
│ │ │ │ │ + var area = component.getArea();
│ │ │ │ │ + var centroid = component.getCentroid(true);
│ │ │ │ │ + if (isNaN(area) || isNaN(centroid.x) || isNaN(centroid.y)) {
│ │ │ │ │ + continue;
│ │ │ │ │ + }
│ │ │ │ │ + areas.push(area);
│ │ │ │ │ + areaSum += area;
│ │ │ │ │ + minArea = (area < minArea && area > 0) ? area : minArea;
│ │ │ │ │ + centroids.push(centroid);
│ │ │ │ │ + }
│ │ │ │ │ + len = areas.length;
│ │ │ │ │ + if (areaSum === 0) {
│ │ │ │ │ + // all the components in this collection have 0 area
│ │ │ │ │ + // probably a collection of points -- weight all the points the same
│ │ │ │ │ + for (var i = 0; i < len; ++i) {
│ │ │ │ │ + areas[i] = 1;
│ │ │ │ │ + }
│ │ │ │ │ + areaSum = areas.length;
│ │ │ │ │ + } else {
│ │ │ │ │ + // normalize all the areas where the smallest area will get
│ │ │ │ │ + // a value of 1
│ │ │ │ │ + for (var i = 0; i < len; ++i) {
│ │ │ │ │ + areas[i] /= minArea;
│ │ │ │ │ + }
│ │ │ │ │ + areaSum /= minArea;
│ │ │ │ │ + }
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: strokeOpacity
│ │ │ │ │ - * {Number} Stroke opacity (0-1).
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ - */
│ │ │ │ │ + var xSum = 0,
│ │ │ │ │ + ySum = 0,
│ │ │ │ │ + centroid, area;
│ │ │ │ │ + for (var i = 0; i < len; ++i) {
│ │ │ │ │ + centroid = centroids[i];
│ │ │ │ │ + area = areas[i];
│ │ │ │ │ + xSum += centroid.x * area;
│ │ │ │ │ + ySum += centroid.y * area;
│ │ │ │ │ + }
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: strokeWidth
│ │ │ │ │ - * {Number} Pixel stroke width.
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ - */
│ │ │ │ │ + return new OpenLayers.Geometry.Point(xSum / areaSum, ySum / areaSum);
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: strokeLinecap
│ │ │ │ │ - * {String} Stroke cap type ("butt", "round", or "square").
│ │ │ │ │ + * APIMethod: getGeodesicLength
│ │ │ │ │ + * Calculate the approximate length of the geometry were it projected onto
│ │ │ │ │ + * the earth.
│ │ │ │ │ + *
│ │ │ │ │ + * projection - {} The spatial reference system
│ │ │ │ │ + * for the geometry coordinates. If not provided, Geographic/WGS84 is
│ │ │ │ │ + * assumed.
│ │ │ │ │ *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Float} The appoximate geodesic length of the geometry in meters.
│ │ │ │ │ */
│ │ │ │ │ + getGeodesicLength: function(projection) {
│ │ │ │ │ + var length = 0.0;
│ │ │ │ │ + for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ + length += this.components[i].getGeodesicLength(projection);
│ │ │ │ │ + }
│ │ │ │ │ + return length;
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Property: strokeDashstyle
│ │ │ │ │ - * {String} Stroke dash style according to the SLD spec. Note that the
│ │ │ │ │ - * OpenLayers values for strokeDashstyle ("dot", "dash", "dashdot",
│ │ │ │ │ - * "longdash", "longdashdot", or "solid") will not work in SLD, but
│ │ │ │ │ - * most SLD patterns will render correctly in OpenLayers.
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * APIMethod: move
│ │ │ │ │ + * Moves a geometry by the given displacement along positive x and y axes.
│ │ │ │ │ + * This modifies the position of the geometry and clears the cached
│ │ │ │ │ + * bounds.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * x - {Float} Distance to move geometry in positive x direction.
│ │ │ │ │ + * y - {Float} Distance to move geometry in positive y direction.
│ │ │ │ │ */
│ │ │ │ │ + move: function(x, y) {
│ │ │ │ │ + for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ + this.components[i].move(x, y);
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: fillColor
│ │ │ │ │ - * {String} RGB hex fill color (e.g. "#ff0000" for red).
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * APIMethod: rotate
│ │ │ │ │ + * Rotate a geometry around some origin
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * angle - {Float} Rotation angle in degrees (measured counterclockwise
│ │ │ │ │ + * from the positive x-axis)
│ │ │ │ │ + * origin - {} Center point for the rotation
│ │ │ │ │ */
│ │ │ │ │ + rotate: function(angle, origin) {
│ │ │ │ │ + for (var i = 0, len = this.components.length; i < len; ++i) {
│ │ │ │ │ + this.components[i].rotate(angle, origin);
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: fillOpacity
│ │ │ │ │ - * {Number} Fill opacity (0-1).
│ │ │ │ │ + * APIMethod: resize
│ │ │ │ │ + * Resize a geometry relative to some origin. Use this method to apply
│ │ │ │ │ + * a uniform scaling to a geometry.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * scale - {Float} Factor by which to scale the geometry. A scale of 2
│ │ │ │ │ + * doubles the size of the geometry in each dimension
│ │ │ │ │ + * (lines, for example, will be twice as long, and polygons
│ │ │ │ │ + * will have four times the area).
│ │ │ │ │ + * origin - {} Point of origin for resizing
│ │ │ │ │ + * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.
│ │ │ │ │ *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {} - The current geometry.
│ │ │ │ │ */
│ │ │ │ │ + resize: function(scale, origin, ratio) {
│ │ │ │ │ + for (var i = 0; i < this.components.length; ++i) {
│ │ │ │ │ + this.components[i].resize(scale, origin, ratio);
│ │ │ │ │ + }
│ │ │ │ │ + return this;
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Constructor: OpenLayers.Symbolizer.Polygon
│ │ │ │ │ - * Create a symbolizer for rendering polygons.
│ │ │ │ │ + * APIMethod: distanceTo
│ │ │ │ │ + * Calculate the closest distance between two geometries (on the x-y plane).
│ │ │ │ │ *
│ │ │ │ │ * Parameters:
│ │ │ │ │ - * config - {Object} An object containing properties to be set on the
│ │ │ │ │ - * symbolizer. Any documented symbolizer property can be set at
│ │ │ │ │ - * construction.
│ │ │ │ │ + * geometry - {} The target geometry.
│ │ │ │ │ + * options - {Object} Optional properties for configuring the distance
│ │ │ │ │ + * calculation.
│ │ │ │ │ + *
│ │ │ │ │ + * Valid options:
│ │ │ │ │ + * details - {Boolean} Return details from the distance calculation.
│ │ │ │ │ + * Default is false.
│ │ │ │ │ + * edge - {Boolean} Calculate the distance from this geometry to the
│ │ │ │ │ + * nearest edge of the target geometry. Default is true. If true,
│ │ │ │ │ + * calling distanceTo from a geometry that is wholly contained within
│ │ │ │ │ + * the target will result in a non-zero distance. If false, whenever
│ │ │ │ │ + * geometries intersect, calling distanceTo will return 0. If false,
│ │ │ │ │ + * details cannot be returned.
│ │ │ │ │ *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * A new polygon symbolizer.
│ │ │ │ │ + * {Number | Object} The distance between this geometry and the target.
│ │ │ │ │ + * If details is true, the return will be an object with distance,
│ │ │ │ │ + * x0, y0, x1, and y1 properties. The x0 and y0 properties represent
│ │ │ │ │ + * the coordinates of the closest point on this geometry. The x1 and y1
│ │ │ │ │ + * properties represent the coordinates of the closest point on the
│ │ │ │ │ + * target geometry.
│ │ │ │ │ */
│ │ │ │ │ - initialize: function(config) {
│ │ │ │ │ - OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);
│ │ │ │ │ + distanceTo: function(geometry, options) {
│ │ │ │ │ + var edge = !(options && options.edge === false);
│ │ │ │ │ + var details = edge && options && options.details;
│ │ │ │ │ + var result, best, distance;
│ │ │ │ │ + var min = Number.POSITIVE_INFINITY;
│ │ │ │ │ + for (var i = 0, len = this.components.length; i < len; ++i) {
│ │ │ │ │ + result = this.components[i].distanceTo(geometry, options);
│ │ │ │ │ + distance = details ? result.distance : result;
│ │ │ │ │ + if (distance < min) {
│ │ │ │ │ + min = distance;
│ │ │ │ │ + best = result;
│ │ │ │ │ + if (min == 0) {
│ │ │ │ │ + break;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + return best;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Symbolizer.Polygon"
│ │ │ │ │ -
│ │ │ │ │ -});
│ │ │ │ │ -
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Symbolizer/Text.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/Symbolizer.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Class: OpenLayers.Symbolizer.Text
│ │ │ │ │ - * A symbolizer used to render text labels for features.
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Symbolizer.Text = OpenLayers.Class(OpenLayers.Symbolizer, {
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: label
│ │ │ │ │ - * {String} The text for the label.
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: fontFamily
│ │ │ │ │ - * {String} The font family for the label.
│ │ │ │ │ + * APIMethod: equals
│ │ │ │ │ + * Determine whether another geometry is equivalent to this one. Geometries
│ │ │ │ │ + * are considered equivalent if all components have the same coordinates.
│ │ │ │ │ *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * geometry - {} The geometry to test.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean} The supplied geometry is equivalent to this geometry.
│ │ │ │ │ */
│ │ │ │ │ + equals: function(geometry) {
│ │ │ │ │ + var equivalent = true;
│ │ │ │ │ + if (!geometry || !geometry.CLASS_NAME ||
│ │ │ │ │ + (this.CLASS_NAME != geometry.CLASS_NAME)) {
│ │ │ │ │ + equivalent = false;
│ │ │ │ │ + } else if (!(OpenLayers.Util.isArray(geometry.components)) ||
│ │ │ │ │ + (geometry.components.length != this.components.length)) {
│ │ │ │ │ + equivalent = false;
│ │ │ │ │ + } else {
│ │ │ │ │ + for (var i = 0, len = this.components.length; i < len; ++i) {
│ │ │ │ │ + if (!this.components[i].equals(geometry.components[i])) {
│ │ │ │ │ + equivalent = false;
│ │ │ │ │ + break;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + return equivalent;
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: fontSize
│ │ │ │ │ - * {String} The font size for the label.
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: transform
│ │ │ │ │ + * Reproject the components geometry from source to dest.
│ │ │ │ │ *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: fontWeight
│ │ │ │ │ - * {String} The font weight for the label.
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * source - {}
│ │ │ │ │ + * dest - {}
│ │ │ │ │ *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {}
│ │ │ │ │ */
│ │ │ │ │ + transform: function(source, dest) {
│ │ │ │ │ + if (source && dest) {
│ │ │ │ │ + for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ + var component = this.components[i];
│ │ │ │ │ + component.transform(source, dest);
│ │ │ │ │ + }
│ │ │ │ │ + this.bounds = null;
│ │ │ │ │ + }
│ │ │ │ │ + return this;
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Property: fontStyle
│ │ │ │ │ - * {String} The font style for the label.
│ │ │ │ │ - *
│ │ │ │ │ - * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.
│ │ │ │ │ + * APIMethod: intersects
│ │ │ │ │ + * Determine if the input geometry intersects this one.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * geometry - {} Any type of geometry.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean} The input geometry intersects this one.
│ │ │ │ │ */
│ │ │ │ │ + intersects: function(geometry) {
│ │ │ │ │ + var intersect = false;
│ │ │ │ │ + for (var i = 0, len = this.components.length; i < len; ++i) {
│ │ │ │ │ + intersect = geometry.intersects(this.components[i]);
│ │ │ │ │ + if (intersect) {
│ │ │ │ │ + break;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + return intersect;
│ │ │ │ │ + },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Constructor: OpenLayers.Symbolizer.Text
│ │ │ │ │ - * Create a symbolizer for rendering text labels.
│ │ │ │ │ + * APIMethod: getVertices
│ │ │ │ │ + * Return a list of all points in this geometry.
│ │ │ │ │ *
│ │ │ │ │ * Parameters:
│ │ │ │ │ - * config - {Object} An object containing properties to be set on the
│ │ │ │ │ - * symbolizer. Any documented symbolizer property can be set at
│ │ │ │ │ - * construction.
│ │ │ │ │ + * nodes - {Boolean} For lines, only return vertices that are
│ │ │ │ │ + * endpoints. If false, for lines, only vertices that are not
│ │ │ │ │ + * endpoints will be returned. If not provided, all vertices will
│ │ │ │ │ + * be returned.
│ │ │ │ │ *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * A new text symbolizer.
│ │ │ │ │ + * {Array} A list of all vertices in the geometry.
│ │ │ │ │ */
│ │ │ │ │ - initialize: function(config) {
│ │ │ │ │ - OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);
│ │ │ │ │ + getVertices: function(nodes) {
│ │ │ │ │ + var vertices = [];
│ │ │ │ │ + for (var i = 0, len = this.components.length; i < len; ++i) {
│ │ │ │ │ + Array.prototype.push.apply(
│ │ │ │ │ + vertices, this.components[i].getVertices(nodes)
│ │ │ │ │ + );
│ │ │ │ │ + }
│ │ │ │ │ + return vertices;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Symbolizer.Text"
│ │ │ │ │
│ │ │ │ │ + CLASS_NAME: "OpenLayers.Geometry.Collection"
│ │ │ │ │ });
│ │ │ │ │ -
│ │ │ │ │ /* ======================================================================
│ │ │ │ │ - OpenLayers/Symbolizer/Raster.js
│ │ │ │ │ + OpenLayers/Geometry/MultiPoint.js
│ │ │ │ │ ====================================================================== */
│ │ │ │ │
│ │ │ │ │ /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ * full text of the license. */
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * @requires OpenLayers/Symbolizer.js
│ │ │ │ │ + * @requires OpenLayers/Geometry/Collection.js
│ │ │ │ │ + * @requires OpenLayers/Geometry/Point.js
│ │ │ │ │ */
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Class: OpenLayers.Symbolizer.Raster
│ │ │ │ │ - * A symbolizer used to render raster images.
│ │ │ │ │ + * Class: OpenLayers.Geometry.MultiPoint
│ │ │ │ │ + * MultiPoint is a collection of Points. Create a new instance with the
│ │ │ │ │ + * constructor.
│ │ │ │ │ + *
│ │ │ │ │ + * Inherits from:
│ │ │ │ │ + * -
│ │ │ │ │ + * -
│ │ │ │ │ */
│ │ │ │ │ -OpenLayers.Symbolizer.Raster = OpenLayers.Class(OpenLayers.Symbolizer, {
│ │ │ │ │ +OpenLayers.Geometry.MultiPoint = OpenLayers.Class(
│ │ │ │ │ + OpenLayers.Geometry.Collection, {
│ │ │ │ │
│ │ │ │ │ - /**
│ │ │ │ │ - * Constructor: OpenLayers.Symbolizer.Raster
│ │ │ │ │ - * Create a symbolizer for rendering rasters.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * config - {Object} An object containing properties to be set on the
│ │ │ │ │ - * symbolizer. Any documented symbolizer property can be set at
│ │ │ │ │ - * construction.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * A new raster symbolizer.
│ │ │ │ │ - */
│ │ │ │ │ - initialize: function(config) {
│ │ │ │ │ - OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);
│ │ │ │ │ - },
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: componentTypes
│ │ │ │ │ + * {Array(String)} An array of class names representing the types of
│ │ │ │ │ + * components that the collection can include. A null value means the
│ │ │ │ │ + * component types are not restricted.
│ │ │ │ │ + */
│ │ │ │ │ + componentTypes: ["OpenLayers.Geometry.Point"],
│ │ │ │ │
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Symbolizer.Raster"
│ │ │ │ │ + /**
│ │ │ │ │ + * Constructor: OpenLayers.Geometry.MultiPoint
│ │ │ │ │ + * Create a new MultiPoint Geometry
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * components - {Array()}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {}
│ │ │ │ │ + */
│ │ │ │ │
│ │ │ │ │ -});
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: addPoint
│ │ │ │ │ + * Wrapper for
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * point - {} Point to be added
│ │ │ │ │ + * index - {Integer} Optional index
│ │ │ │ │ + */
│ │ │ │ │ + addPoint: function(point, index) {
│ │ │ │ │ + this.addComponent(point, index);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: removePoint
│ │ │ │ │ + * Wrapper for
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * point - {} Point to be removed
│ │ │ │ │ + */
│ │ │ │ │ + removePoint: function(point) {
│ │ │ │ │ + this.removeComponent(point);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + CLASS_NAME: "OpenLayers.Geometry.MultiPoint"
│ │ │ │ │ + });
│ │ │ │ │ /* ======================================================================
│ │ │ │ │ - OpenLayers/Style2.js
│ │ │ │ │ + OpenLayers/Geometry/Curve.js
│ │ │ │ │ ====================================================================== */
│ │ │ │ │
│ │ │ │ │ /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ * full text of the license. */
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * @requires OpenLayers/BaseTypes/Class.js
│ │ │ │ │ - * @requires OpenLayers/Rule.js
│ │ │ │ │ - * @requires OpenLayers/Symbolizer/Point.js
│ │ │ │ │ - * @requires OpenLayers/Symbolizer/Line.js
│ │ │ │ │ - * @requires OpenLayers/Symbolizer/Polygon.js
│ │ │ │ │ - * @requires OpenLayers/Symbolizer/Text.js
│ │ │ │ │ - * @requires OpenLayers/Symbolizer/Raster.js
│ │ │ │ │ + * @requires OpenLayers/Geometry/MultiPoint.js
│ │ │ │ │ */
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Class: OpenLayers.Style2
│ │ │ │ │ - * This class represents a collection of rules for rendering features.
│ │ │ │ │ + * Class: OpenLayers.Geometry.Curve
│ │ │ │ │ + * A Curve is a MultiPoint, whose points are assumed to be connected. To
│ │ │ │ │ + * this end, we provide a "getLength()" function, which iterates through
│ │ │ │ │ + * the points, summing the distances between them.
│ │ │ │ │ + *
│ │ │ │ │ + * Inherits:
│ │ │ │ │ + * -
│ │ │ │ │ */
│ │ │ │ │ -OpenLayers.Style2 = OpenLayers.Class({
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: id
│ │ │ │ │ - * {String} A unique id for this session.
│ │ │ │ │ - */
│ │ │ │ │ - id: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: name
│ │ │ │ │ - * {String} Style identifier.
│ │ │ │ │ - */
│ │ │ │ │ - name: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: title
│ │ │ │ │ - * {String} Title of this style.
│ │ │ │ │ - */
│ │ │ │ │ - title: null,
│ │ │ │ │ +OpenLayers.Geometry.Curve = OpenLayers.Class(OpenLayers.Geometry.MultiPoint, {
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: description
│ │ │ │ │ - * {String} Description of this style.
│ │ │ │ │ + * Property: componentTypes
│ │ │ │ │ + * {Array(String)} An array of class names representing the types of
│ │ │ │ │ + * components that the collection can include. A null
│ │ │ │ │ + * value means the component types are not restricted.
│ │ │ │ │ */
│ │ │ │ │ - description: null,
│ │ │ │ │ + componentTypes: ["OpenLayers.Geometry.Point"],
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: layerName
│ │ │ │ │ - * {} Name of the layer that this style belongs to, usually
│ │ │ │ │ - * according to the NamedLayer attribute of an SLD document.
│ │ │ │ │ + * Constructor: OpenLayers.Geometry.Curve
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * point - {Array()}
│ │ │ │ │ */
│ │ │ │ │ - layerName: null,
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIProperty: isDefault
│ │ │ │ │ - * {Boolean}
│ │ │ │ │ - */
│ │ │ │ │ - isDefault: false,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: rules
│ │ │ │ │ - * {Array()} Collection of rendering rules.
│ │ │ │ │ - */
│ │ │ │ │ - rules: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constructor: OpenLayers.Style2
│ │ │ │ │ - * Creates a style representing a collection of rendering rules.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * config - {Object} An object containing properties to be set on the
│ │ │ │ │ - * style. Any documented properties may be set at construction.
│ │ │ │ │ - *
│ │ │ │ │ + * APIMethod: getLength
│ │ │ │ │ + *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * {} A new style object.
│ │ │ │ │ - */
│ │ │ │ │ - initialize: function(config) {
│ │ │ │ │ - OpenLayers.Util.extend(this, config);
│ │ │ │ │ - this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: destroy
│ │ │ │ │ - * nullify references to prevent circular references and memory leaks
│ │ │ │ │ + * {Float} The length of the curve
│ │ │ │ │ */
│ │ │ │ │ - destroy: function() {
│ │ │ │ │ - for (var i = 0, len = this.rules.length; i < len; i++) {
│ │ │ │ │ - this.rules[i].destroy();
│ │ │ │ │ + getLength: function() {
│ │ │ │ │ + var length = 0.0;
│ │ │ │ │ + if (this.components && (this.components.length > 1)) {
│ │ │ │ │ + for (var i = 1, len = this.components.length; i < len; i++) {
│ │ │ │ │ + length += this.components[i - 1].distanceTo(this.components[i]);
│ │ │ │ │ + }
│ │ │ │ │ }
│ │ │ │ │ - delete this.rules;
│ │ │ │ │ + return length;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIMethod: clone
│ │ │ │ │ - * Clones this style.
│ │ │ │ │ + * APIMethod: getGeodesicLength
│ │ │ │ │ + * Calculate the approximate length of the geometry were it projected onto
│ │ │ │ │ + * the earth.
│ │ │ │ │ + *
│ │ │ │ │ + * projection - {} The spatial reference system
│ │ │ │ │ + * for the geometry coordinates. If not provided, Geographic/WGS84 is
│ │ │ │ │ + * assumed.
│ │ │ │ │ *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * {} Clone of this style.
│ │ │ │ │ + * {Float} The appoximate geodesic length of the geometry in meters.
│ │ │ │ │ */
│ │ │ │ │ - clone: function() {
│ │ │ │ │ - var config = OpenLayers.Util.extend({}, this);
│ │ │ │ │ - // clone rules
│ │ │ │ │ - if (this.rules) {
│ │ │ │ │ - config.rules = [];
│ │ │ │ │ - for (var i = 0, len = this.rules.length; i < len; ++i) {
│ │ │ │ │ - config.rules.push(this.rules[i].clone());
│ │ │ │ │ + getGeodesicLength: function(projection) {
│ │ │ │ │ + var geom = this; // so we can work with a clone if needed
│ │ │ │ │ + if (projection) {
│ │ │ │ │ + var gg = new OpenLayers.Projection("EPSG:4326");
│ │ │ │ │ + if (!gg.equals(projection)) {
│ │ │ │ │ + geom = this.clone().transform(projection, gg);
│ │ │ │ │ }
│ │ │ │ │ }
│ │ │ │ │ - return new OpenLayers.Style2(config);
│ │ │ │ │ + var length = 0.0;
│ │ │ │ │ + if (geom.components && (geom.components.length > 1)) {
│ │ │ │ │ + var p1, p2;
│ │ │ │ │ + for (var i = 1, len = geom.components.length; i < len; i++) {
│ │ │ │ │ + p1 = geom.components[i - 1];
│ │ │ │ │ + p2 = geom.components[i];
│ │ │ │ │ + // this returns km and requires lon/lat properties
│ │ │ │ │ + length += OpenLayers.Util.distVincenty({
│ │ │ │ │ + lon: p1.x,
│ │ │ │ │ + lat: p1.y
│ │ │ │ │ + }, {
│ │ │ │ │ + lon: p2.x,
│ │ │ │ │ + lat: p2.y
│ │ │ │ │ + });
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + // convert to m
│ │ │ │ │ + return length * 1000;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Style2"
│ │ │ │ │ + CLASS_NAME: "OpenLayers.Geometry.Curve"
│ │ │ │ │ });
│ │ │ │ │ /* ======================================================================
│ │ │ │ │ - OpenLayers/Projection.js
│ │ │ │ │ + OpenLayers/Geometry/LineString.js
│ │ │ │ │ ====================================================================== */
│ │ │ │ │
│ │ │ │ │ /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ * full text of the license. */
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * @requires OpenLayers/BaseTypes/Class.js
│ │ │ │ │ - * @requires OpenLayers/Util.js
│ │ │ │ │ + * @requires OpenLayers/Geometry/Curve.js
│ │ │ │ │ */
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Namespace: OpenLayers.Projection
│ │ │ │ │ - * Methods for coordinate transforms between coordinate systems. By default,
│ │ │ │ │ - * OpenLayers ships with the ability to transform coordinates between
│ │ │ │ │ - * geographic (EPSG:4326) and web or spherical mercator (EPSG:900913 et al.)
│ │ │ │ │ - * coordinate reference systems. See the method for details
│ │ │ │ │ - * on usage.
│ │ │ │ │ - *
│ │ │ │ │ - * Additional transforms may be added by using the
│ │ │ │ │ - * library. If the proj4js library is included, the method
│ │ │ │ │ - * will work between any two coordinate reference systems with proj4js
│ │ │ │ │ - * definitions.
│ │ │ │ │ - *
│ │ │ │ │ - * If the proj4js library is not included, or if you wish to allow transforms
│ │ │ │ │ - * between arbitrary coordinate reference systems, use the
│ │ │ │ │ - * method to register a custom transform method.
│ │ │ │ │ + * Class: OpenLayers.Geometry.LineString
│ │ │ │ │ + * A LineString is a Curve which, once two points have been added to it, can
│ │ │ │ │ + * never be less than two points long.
│ │ │ │ │ + *
│ │ │ │ │ + * Inherits from:
│ │ │ │ │ + * -
│ │ │ │ │ */
│ │ │ │ │ -OpenLayers.Projection = OpenLayers.Class({
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: proj
│ │ │ │ │ - * {Object} Proj4js.Proj instance.
│ │ │ │ │ - */
│ │ │ │ │ - proj: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: projCode
│ │ │ │ │ - * {String}
│ │ │ │ │ - */
│ │ │ │ │ - projCode: null,
│ │ │ │ │ +OpenLayers.Geometry.LineString = OpenLayers.Class(OpenLayers.Geometry.Curve, {
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Property: titleRegEx
│ │ │ │ │ - * {RegExp} regular expression to strip the title from a proj4js definition
│ │ │ │ │ + * Constructor: OpenLayers.Geometry.LineString
│ │ │ │ │ + * Create a new LineString geometry
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * points - {Array()} An array of points used to
│ │ │ │ │ + * generate the linestring
│ │ │ │ │ + *
│ │ │ │ │ */
│ │ │ │ │ - titleRegEx: /\+title=[^\+]*/,
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * Constructor: OpenLayers.Projection
│ │ │ │ │ - * This class offers several methods for interacting with a wrapped
│ │ │ │ │ - * pro4js projection object.
│ │ │ │ │ + * APIMethod: removeComponent
│ │ │ │ │ + * Only allows removal of a point if there are three or more points in
│ │ │ │ │ + * the linestring. (otherwise the result would be just a single point)
│ │ │ │ │ *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * projCode - {String} A string identifying the Well Known Identifier for
│ │ │ │ │ - * the projection.
│ │ │ │ │ - * options - {Object} An optional object to set additional properties
│ │ │ │ │ - * on the projection.
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * point - {} The point to be removed
│ │ │ │ │ *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {} A projection object.
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean} The component was removed.
│ │ │ │ │ */
│ │ │ │ │ - initialize: function(projCode, options) {
│ │ │ │ │ - OpenLayers.Util.extend(this, options);
│ │ │ │ │ - this.projCode = projCode;
│ │ │ │ │ - if (typeof Proj4js == "object") {
│ │ │ │ │ - this.proj = new Proj4js.Proj(projCode);
│ │ │ │ │ + removeComponent: function(point) {
│ │ │ │ │ + var removed = this.components && (this.components.length > 2);
│ │ │ │ │ + if (removed) {
│ │ │ │ │ + OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,
│ │ │ │ │ + arguments);
│ │ │ │ │ }
│ │ │ │ │ + return removed;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIMethod: getCode
│ │ │ │ │ - * Get the string SRS code.
│ │ │ │ │ + * APIMethod: intersects
│ │ │ │ │ + * Test for instersection between two geometries. This is a cheapo
│ │ │ │ │ + * implementation of the Bently-Ottmann algorigithm. It doesn't
│ │ │ │ │ + * really keep track of a sweep line data structure. It is closer
│ │ │ │ │ + * to the brute force method, except that segments are sorted and
│ │ │ │ │ + * potential intersections are only calculated when bounding boxes
│ │ │ │ │ + * intersect.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * geometry - {}
│ │ │ │ │ *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * {String} The SRS code.
│ │ │ │ │ + * {Boolean} The input geometry intersects this geometry.
│ │ │ │ │ */
│ │ │ │ │ - getCode: function() {
│ │ │ │ │ - return this.proj ? this.proj.srsCode : this.projCode;
│ │ │ │ │ + intersects: function(geometry) {
│ │ │ │ │ + var intersect = false;
│ │ │ │ │ + var type = geometry.CLASS_NAME;
│ │ │ │ │ + if (type == "OpenLayers.Geometry.LineString" ||
│ │ │ │ │ + type == "OpenLayers.Geometry.LinearRing" ||
│ │ │ │ │ + type == "OpenLayers.Geometry.Point") {
│ │ │ │ │ + var segs1 = this.getSortedSegments();
│ │ │ │ │ + var segs2;
│ │ │ │ │ + if (type == "OpenLayers.Geometry.Point") {
│ │ │ │ │ + segs2 = [{
│ │ │ │ │ + x1: geometry.x,
│ │ │ │ │ + y1: geometry.y,
│ │ │ │ │ + x2: geometry.x,
│ │ │ │ │ + y2: geometry.y
│ │ │ │ │ + }];
│ │ │ │ │ + } else {
│ │ │ │ │ + segs2 = geometry.getSortedSegments();
│ │ │ │ │ + }
│ │ │ │ │ + var seg1, seg1x1, seg1x2, seg1y1, seg1y2,
│ │ │ │ │ + seg2, seg2y1, seg2y2;
│ │ │ │ │ + // sweep right
│ │ │ │ │ + outer: for (var i = 0, len = segs1.length; i < len; ++i) {
│ │ │ │ │ + seg1 = segs1[i];
│ │ │ │ │ + seg1x1 = seg1.x1;
│ │ │ │ │ + seg1x2 = seg1.x2;
│ │ │ │ │ + seg1y1 = seg1.y1;
│ │ │ │ │ + seg1y2 = seg1.y2;
│ │ │ │ │ + inner: for (var j = 0, jlen = segs2.length; j < jlen; ++j) {
│ │ │ │ │ + seg2 = segs2[j];
│ │ │ │ │ + if (seg2.x1 > seg1x2) {
│ │ │ │ │ + // seg1 still left of seg2
│ │ │ │ │ + break;
│ │ │ │ │ + }
│ │ │ │ │ + if (seg2.x2 < seg1x1) {
│ │ │ │ │ + // seg2 still left of seg1
│ │ │ │ │ + continue;
│ │ │ │ │ + }
│ │ │ │ │ + seg2y1 = seg2.y1;
│ │ │ │ │ + seg2y2 = seg2.y2;
│ │ │ │ │ + if (Math.min(seg2y1, seg2y2) > Math.max(seg1y1, seg1y2)) {
│ │ │ │ │ + // seg2 above seg1
│ │ │ │ │ + continue;
│ │ │ │ │ + }
│ │ │ │ │ + if (Math.max(seg2y1, seg2y2) < Math.min(seg1y1, seg1y2)) {
│ │ │ │ │ + // seg2 below seg1
│ │ │ │ │ + continue;
│ │ │ │ │ + }
│ │ │ │ │ + if (OpenLayers.Geometry.segmentsIntersect(seg1, seg2)) {
│ │ │ │ │ + intersect = true;
│ │ │ │ │ + break outer;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + } else {
│ │ │ │ │ + intersect = geometry.intersects(this);
│ │ │ │ │ + }
│ │ │ │ │ + return intersect;
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ - * APIMethod: getUnits
│ │ │ │ │ - * Get the units string for the projection -- returns null if
│ │ │ │ │ - * proj4js is not available.
│ │ │ │ │ + * Method: getSortedSegments
│ │ │ │ │ *
│ │ │ │ │ * Returns:
│ │ │ │ │ - * {String} The units abbreviation.
│ │ │ │ │ + * {Array} An array of segment objects. Segment objects have properties
│ │ │ │ │ + * x1, y1, x2, and y2. The start point is represented by x1 and y1.
│ │ │ │ │ + * The end point is represented by x2 and y2. Start and end are
│ │ │ │ │ + * ordered so that x1 < x2.
│ │ │ │ │ */
│ │ │ │ │ - getUnits: function() {
│ │ │ │ │ - return this.proj ? this.proj.units : null;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: toString
│ │ │ │ │ - * Convert projection to string (getCode wrapper).
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {String} The projection code.
│ │ │ │ │ - */
│ │ │ │ │ - toString: function() {
│ │ │ │ │ - return this.getCode();
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: equals
│ │ │ │ │ - * Test equality of two projection instances. Determines equality based
│ │ │ │ │ - * soley on the projection code.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} The two projections are equivalent.
│ │ │ │ │ - */
│ │ │ │ │ - equals: function(projection) {
│ │ │ │ │ - var p = projection,
│ │ │ │ │ - equals = false;
│ │ │ │ │ - if (p) {
│ │ │ │ │ - if (!(p instanceof OpenLayers.Projection)) {
│ │ │ │ │ - p = new OpenLayers.Projection(p);
│ │ │ │ │ - }
│ │ │ │ │ - if ((typeof Proj4js == "object") && this.proj.defData && p.proj.defData) {
│ │ │ │ │ - equals = this.proj.defData.replace(this.titleRegEx, "") ==
│ │ │ │ │ - p.proj.defData.replace(this.titleRegEx, "");
│ │ │ │ │ - } else if (p.getCode) {
│ │ │ │ │ - var source = this.getCode(),
│ │ │ │ │ - target = p.getCode();
│ │ │ │ │ - equals = source == target ||
│ │ │ │ │ - !!OpenLayers.Projection.transforms[source] &&
│ │ │ │ │ - OpenLayers.Projection.transforms[source][target] ===
│ │ │ │ │ - OpenLayers.Projection.nullTransform;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - return equals;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /* Method: destroy
│ │ │ │ │ - * Destroy projection object.
│ │ │ │ │ - */
│ │ │ │ │ - destroy: function() {
│ │ │ │ │ - delete this.proj;
│ │ │ │ │ - delete this.projCode;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Projection"
│ │ │ │ │ -});
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Property: transforms
│ │ │ │ │ - * {Object} Transforms is an object, with from properties, each of which may
│ │ │ │ │ - * have a to property. This allows you to define projections without
│ │ │ │ │ - * requiring support for proj4js to be included.
│ │ │ │ │ - *
│ │ │ │ │ - * This object has keys which correspond to a 'source' projection object. The
│ │ │ │ │ - * keys should be strings, corresponding to the projection.getCode() value.
│ │ │ │ │ - * Each source projection object should have a set of destination projection
│ │ │ │ │ - * keys included in the object.
│ │ │ │ │ - *
│ │ │ │ │ - * Each value in the destination object should be a transformation function,
│ │ │ │ │ - * where the function is expected to be passed an object with a .x and a .y
│ │ │ │ │ - * property. The function should return the object, with the .x and .y
│ │ │ │ │ - * transformed according to the transformation function.
│ │ │ │ │ - *
│ │ │ │ │ - * Note - Properties on this object should not be set directly. To add a
│ │ │ │ │ - * transform method to this object, use the method. For an
│ │ │ │ │ - * example of usage, see the OpenLayers.Layer.SphericalMercator file.
│ │ │ │ │ - */
│ │ │ │ │ -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
│ │ │ │ │ - * Set a custom transform method between two projections. Use this method in
│ │ │ │ │ - * cases where the proj4js lib is not available or where custom projections
│ │ │ │ │ - * need to be handled.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * from - {String} The code for the source projection
│ │ │ │ │ - * to - {String} the code for the destination projection
│ │ │ │ │ - * method - {Function} A function that takes a point as an argument and
│ │ │ │ │ - * transforms that point from the source to the destination projection
│ │ │ │ │ - * in place. The original point should be modified.
│ │ │ │ │ - */
│ │ │ │ │ -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]) {
│ │ │ │ │ - OpenLayers.Projection.transforms[from] = {};
│ │ │ │ │ - }
│ │ │ │ │ - OpenLayers.Projection.transforms[from][to] = method;
│ │ │ │ │ -};
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * APIMethod: transform
│ │ │ │ │ - * Transform a point coordinate from one projection to another. Note that
│ │ │ │ │ - * the input point is transformed in place.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * point - { | Object} An object with x and y
│ │ │ │ │ - * properties representing coordinates in those dimensions.
│ │ │ │ │ - * source - {OpenLayers.Projection} Source map coordinate system
│ │ │ │ │ - * dest - {OpenLayers.Projection} Destination map coordinate system
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * point - {object} A transformed coordinate. The original point is modified.
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Projection.transform = function(point, source, dest) {
│ │ │ │ │ - if (source && dest) {
│ │ │ │ │ - if (!(source instanceof OpenLayers.Projection)) {
│ │ │ │ │ - source = new OpenLayers.Projection(source);
│ │ │ │ │ - }
│ │ │ │ │ - if (!(dest instanceof OpenLayers.Projection)) {
│ │ │ │ │ - dest = new OpenLayers.Projection(dest);
│ │ │ │ │ - }
│ │ │ │ │ - if (source.proj && dest.proj) {
│ │ │ │ │ - point = Proj4js.transform(source.proj, dest.proj, point);
│ │ │ │ │ - } else {
│ │ │ │ │ - var sourceCode = source.getCode();
│ │ │ │ │ - var destCode = dest.getCode();
│ │ │ │ │ - var transforms = OpenLayers.Projection.transforms;
│ │ │ │ │ - if (transforms[sourceCode] && transforms[sourceCode][destCode]) {
│ │ │ │ │ - transforms[sourceCode][destCode](point);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - return point;
│ │ │ │ │ -};
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * APIFunction: nullTransform
│ │ │ │ │ - * A null transformation - useful for defining projection aliases when
│ │ │ │ │ - * proj4js is not available:
│ │ │ │ │ - *
│ │ │ │ │ - * (code)
│ │ │ │ │ - * OpenLayers.Projection.addTransform("EPSG:3857", "EPSG:900913",
│ │ │ │ │ - * OpenLayers.Projection.nullTransform);
│ │ │ │ │ - * OpenLayers.Projection.addTransform("EPSG:900913", "EPSG:3857",
│ │ │ │ │ - * OpenLayers.Projection.nullTransform);
│ │ │ │ │ - * (end)
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Projection.nullTransform = function(point) {
│ │ │ │ │ - return point;
│ │ │ │ │ -};
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Note: Transforms for web mercator <-> geographic
│ │ │ │ │ - * OpenLayers recognizes EPSG:3857, EPSG:900913, EPSG:102113 and EPSG:102100.
│ │ │ │ │ - * OpenLayers originally started referring to EPSG:900913 as web mercator.
│ │ │ │ │ - * The EPSG has declared EPSG:3857 to be web mercator.
│ │ │ │ │ - * 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.
│ │ │ │ │ - * 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() {
│ │ │ │ │ -
│ │ │ │ │ - var pole = 20037508.34;
│ │ │ │ │ -
│ │ │ │ │ - function inverseMercator(xy) {
│ │ │ │ │ - xy.x = 180 * xy.x / pole;
│ │ │ │ │ - xy.y = 180 / Math.PI * (2 * Math.atan(Math.exp((xy.y / pole) * Math.PI)) - Math.PI / 2);
│ │ │ │ │ - return xy;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - function forwardMercator(xy) {
│ │ │ │ │ - xy.x = xy.x * pole / 180;
│ │ │ │ │ - var y = Math.log(Math.tan((90 + xy.y) * Math.PI / 360)) / Math.PI * pole;
│ │ │ │ │ - xy.y = Math.max(-20037508.34, Math.min(y, 20037508.34));
│ │ │ │ │ - return xy;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - function map(base, codes) {
│ │ │ │ │ - var add = OpenLayers.Projection.addTransform;
│ │ │ │ │ - var same = OpenLayers.Projection.nullTransform;
│ │ │ │ │ - var i, len, code, other, j;
│ │ │ │ │ - for (i = 0, len = codes.length; i < len; ++i) {
│ │ │ │ │ - code = codes[i];
│ │ │ │ │ - add(base, code, forwardMercator);
│ │ │ │ │ - add(code, base, inverseMercator);
│ │ │ │ │ - for (j = i + 1; j < len; ++j) {
│ │ │ │ │ - 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);
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ -})();
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Events.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/Util.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Namespace: OpenLayers.Event
│ │ │ │ │ - * Utility functions for event handling.
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Event = {
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: observers
│ │ │ │ │ - * {Object} A hashtable cache of the event observers. Keyed by
│ │ │ │ │ - * element._eventCacheID
│ │ │ │ │ - */
│ │ │ │ │ - observers: false,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constant: KEY_SPACE
│ │ │ │ │ - * {int}
│ │ │ │ │ - */
│ │ │ │ │ - KEY_SPACE: 32,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constant: KEY_BACKSPACE
│ │ │ │ │ - * {int}
│ │ │ │ │ - */
│ │ │ │ │ - KEY_BACKSPACE: 8,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constant: KEY_TAB
│ │ │ │ │ - * {int}
│ │ │ │ │ - */
│ │ │ │ │ - KEY_TAB: 9,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constant: KEY_RETURN
│ │ │ │ │ - * {int}
│ │ │ │ │ - */
│ │ │ │ │ - KEY_RETURN: 13,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constant: KEY_ESC
│ │ │ │ │ - * {int}
│ │ │ │ │ - */
│ │ │ │ │ - KEY_ESC: 27,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constant: KEY_LEFT
│ │ │ │ │ - * {int}
│ │ │ │ │ - */
│ │ │ │ │ - KEY_LEFT: 37,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constant: KEY_UP
│ │ │ │ │ - * {int}
│ │ │ │ │ - */
│ │ │ │ │ - KEY_UP: 38,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constant: KEY_RIGHT
│ │ │ │ │ - * {int}
│ │ │ │ │ - */
│ │ │ │ │ - KEY_RIGHT: 39,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constant: KEY_DOWN
│ │ │ │ │ - * {int}
│ │ │ │ │ - */
│ │ │ │ │ - KEY_DOWN: 40,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constant: KEY_DELETE
│ │ │ │ │ - * {int}
│ │ │ │ │ - */
│ │ │ │ │ - KEY_DELETE: 46,
│ │ │ │ │ -
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: element
│ │ │ │ │ - * Cross browser event element detection.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * event - {Event}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {DOMElement} The element that caused the event
│ │ │ │ │ - */
│ │ │ │ │ - element: function(event) {
│ │ │ │ │ - return event.target || event.srcElement;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: isSingleTouch
│ │ │ │ │ - * Determine whether event was caused by a single touch
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * event - {Event}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean}
│ │ │ │ │ - */
│ │ │ │ │ - isSingleTouch: function(event) {
│ │ │ │ │ - return event.touches && event.touches.length == 1;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: isMultiTouch
│ │ │ │ │ - * Determine whether event was caused by a multi touch
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * event - {Event}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean}
│ │ │ │ │ - */
│ │ │ │ │ - isMultiTouch: function(event) {
│ │ │ │ │ - return event.touches && event.touches.length > 1;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: isLeftClick
│ │ │ │ │ - * Determine whether event was caused by a left click.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * event - {Event}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean}
│ │ │ │ │ - */
│ │ │ │ │ - isLeftClick: function(event) {
│ │ │ │ │ - return (((event.which) && (event.which == 1)) ||
│ │ │ │ │ - ((event.button) && (event.button == 1)));
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: isRightClick
│ │ │ │ │ - * Determine whether event was caused by a right mouse click.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * event - {Event}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean}
│ │ │ │ │ - */
│ │ │ │ │ - isRightClick: function(event) {
│ │ │ │ │ - return (((event.which) && (event.which == 3)) ||
│ │ │ │ │ - ((event.button) && (event.button == 2)));
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: stop
│ │ │ │ │ - * Stops an event from propagating.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * event - {Event}
│ │ │ │ │ - * allowDefault - {Boolean} If true, we stop the event chain but
│ │ │ │ │ - * still allow the default browser behaviour (text selection,
│ │ │ │ │ - * radio-button clicking, etc). Default is false.
│ │ │ │ │ - */
│ │ │ │ │ - stop: function(event, allowDefault) {
│ │ │ │ │ -
│ │ │ │ │ - if (!allowDefault) {
│ │ │ │ │ - OpenLayers.Event.preventDefault(event);
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - if (event.stopPropagation) {
│ │ │ │ │ - event.stopPropagation();
│ │ │ │ │ - } else {
│ │ │ │ │ - event.cancelBubble = true;
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: preventDefault
│ │ │ │ │ - * Cancels the event if it is cancelable, without stopping further
│ │ │ │ │ - * propagation of the event.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * event - {Event}
│ │ │ │ │ - */
│ │ │ │ │ - preventDefault: function(event) {
│ │ │ │ │ - if (event.preventDefault) {
│ │ │ │ │ - event.preventDefault();
│ │ │ │ │ - } else {
│ │ │ │ │ - event.returnValue = false;
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: findElement
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * event - {Event}
│ │ │ │ │ - * tagName - {String}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {DOMElement} The first node with the given tagName, starting from the
│ │ │ │ │ - * node the event was triggered on and traversing the DOM upwards
│ │ │ │ │ - */
│ │ │ │ │ - findElement: function(event, tagName) {
│ │ │ │ │ - var element = OpenLayers.Event.element(event);
│ │ │ │ │ - while (element.parentNode && (!element.tagName ||
│ │ │ │ │ - (element.tagName.toUpperCase() != tagName.toUpperCase()))) {
│ │ │ │ │ - element = element.parentNode;
│ │ │ │ │ - }
│ │ │ │ │ - return element;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: observe
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * elementParam - {DOMElement || String}
│ │ │ │ │ - * name - {String}
│ │ │ │ │ - * observer - {function}
│ │ │ │ │ - * useCapture - {Boolean}
│ │ │ │ │ - */
│ │ │ │ │ - observe: function(elementParam, name, observer, useCapture) {
│ │ │ │ │ - var element = OpenLayers.Util.getElement(elementParam);
│ │ │ │ │ - useCapture = useCapture || false;
│ │ │ │ │ -
│ │ │ │ │ - if (name == 'keypress' &&
│ │ │ │ │ - (navigator.appVersion.match(/Konqueror|Safari|KHTML/) ||
│ │ │ │ │ - element.attachEvent)) {
│ │ │ │ │ - name = 'keydown';
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - //if observers cache has not yet been created, create it
│ │ │ │ │ - if (!this.observers) {
│ │ │ │ │ - this.observers = {};
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - //if not already assigned, make a new unique cache ID
│ │ │ │ │ - if (!element._eventCacheID) {
│ │ │ │ │ - var idPrefix = "eventCacheID_";
│ │ │ │ │ - if (element.id) {
│ │ │ │ │ - idPrefix = element.id + "_" + idPrefix;
│ │ │ │ │ - }
│ │ │ │ │ - element._eventCacheID = OpenLayers.Util.createUniqueID(idPrefix);
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - var cacheID = element._eventCacheID;
│ │ │ │ │ -
│ │ │ │ │ - //if there is not yet a hash entry for this element, add one
│ │ │ │ │ - if (!this.observers[cacheID]) {
│ │ │ │ │ - this.observers[cacheID] = [];
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - //add a new observer to this element's list
│ │ │ │ │ - this.observers[cacheID].push({
│ │ │ │ │ - 'element': element,
│ │ │ │ │ - 'name': name,
│ │ │ │ │ - 'observer': observer,
│ │ │ │ │ - 'useCapture': useCapture
│ │ │ │ │ - });
│ │ │ │ │ -
│ │ │ │ │ - //add the actual browser event listener
│ │ │ │ │ - if (element.addEventListener) {
│ │ │ │ │ - element.addEventListener(name, observer, useCapture);
│ │ │ │ │ - } else if (element.attachEvent) {
│ │ │ │ │ - element.attachEvent('on' + name, observer);
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: stopObservingElement
│ │ │ │ │ - * Given the id of an element to stop observing, cycle through the
│ │ │ │ │ - * element's cached observers, calling stopObserving on each one,
│ │ │ │ │ - * skipping those entries which can no longer be removed.
│ │ │ │ │ - *
│ │ │ │ │ - * parameters:
│ │ │ │ │ - * elementParam - {DOMElement || String}
│ │ │ │ │ - */
│ │ │ │ │ - stopObservingElement: function(elementParam) {
│ │ │ │ │ - var element = OpenLayers.Util.getElement(elementParam);
│ │ │ │ │ - var cacheID = element._eventCacheID;
│ │ │ │ │ -
│ │ │ │ │ - this._removeElementObservers(OpenLayers.Event.observers[cacheID]);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: _removeElementObservers
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * elementObservers - {Array(Object)} Array of (element, name,
│ │ │ │ │ - * observer, usecapture) objects,
│ │ │ │ │ - * taken directly from hashtable
│ │ │ │ │ - */
│ │ │ │ │ - _removeElementObservers: function(elementObservers) {
│ │ │ │ │ - if (elementObservers) {
│ │ │ │ │ - for (var i = elementObservers.length - 1; i >= 0; i--) {
│ │ │ │ │ - var entry = elementObservers[i];
│ │ │ │ │ - OpenLayers.Event.stopObserving.apply(this, [
│ │ │ │ │ - entry.element, entry.name, entry.observer, entry.useCapture
│ │ │ │ │ - ]);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: stopObserving
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * elementParam - {DOMElement || String}
│ │ │ │ │ - * name - {String}
│ │ │ │ │ - * observer - {function}
│ │ │ │ │ - * useCapture - {Boolean}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} Whether or not the event observer was removed
│ │ │ │ │ - */
│ │ │ │ │ - stopObserving: function(elementParam, name, observer, useCapture) {
│ │ │ │ │ - useCapture = useCapture || false;
│ │ │ │ │ -
│ │ │ │ │ - var element = OpenLayers.Util.getElement(elementParam);
│ │ │ │ │ - var cacheID = element._eventCacheID;
│ │ │ │ │ -
│ │ │ │ │ - if (name == 'keypress') {
│ │ │ │ │ - if (navigator.appVersion.match(/Konqueror|Safari|KHTML/) ||
│ │ │ │ │ - element.detachEvent) {
│ │ │ │ │ - name = 'keydown';
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // find element's entry in this.observers cache and remove it
│ │ │ │ │ - var foundEntry = false;
│ │ │ │ │ - var elementObservers = OpenLayers.Event.observers[cacheID];
│ │ │ │ │ - if (elementObservers) {
│ │ │ │ │ -
│ │ │ │ │ - // find the specific event type in the element's list
│ │ │ │ │ - var i = 0;
│ │ │ │ │ - while (!foundEntry && i < elementObservers.length) {
│ │ │ │ │ - var cacheEntry = elementObservers[i];
│ │ │ │ │ -
│ │ │ │ │ - if ((cacheEntry.name == name) &&
│ │ │ │ │ - (cacheEntry.observer == observer) &&
│ │ │ │ │ - (cacheEntry.useCapture == useCapture)) {
│ │ │ │ │ -
│ │ │ │ │ - elementObservers.splice(i, 1);
│ │ │ │ │ - if (elementObservers.length == 0) {
│ │ │ │ │ - delete OpenLayers.Event.observers[cacheID];
│ │ │ │ │ - }
│ │ │ │ │ - foundEntry = true;
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - i++;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - //actually remove the event listener from browser
│ │ │ │ │ - if (foundEntry) {
│ │ │ │ │ - if (element.removeEventListener) {
│ │ │ │ │ - element.removeEventListener(name, observer, useCapture);
│ │ │ │ │ - } else if (element && element.detachEvent) {
│ │ │ │ │ - element.detachEvent('on' + name, observer);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - return foundEntry;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: unloadCache
│ │ │ │ │ - * Cycle through all the element entries in the events cache and call
│ │ │ │ │ - * stopObservingElement on each.
│ │ │ │ │ - */
│ │ │ │ │ - unloadCache: function() {
│ │ │ │ │ - // check for OpenLayers.Event before checking for observers, because
│ │ │ │ │ - // OpenLayers.Event may be undefined in IE if no map instance was
│ │ │ │ │ - // created
│ │ │ │ │ - if (OpenLayers.Event && OpenLayers.Event.observers) {
│ │ │ │ │ - for (var cacheID in OpenLayers.Event.observers) {
│ │ │ │ │ - var elementObservers = OpenLayers.Event.observers[cacheID];
│ │ │ │ │ - OpenLayers.Event._removeElementObservers.apply(this,
│ │ │ │ │ - [elementObservers]);
│ │ │ │ │ - }
│ │ │ │ │ - OpenLayers.Event.observers = false;
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Event"
│ │ │ │ │ -};
│ │ │ │ │ -
│ │ │ │ │ -/* prevent memory leaks in IE */
│ │ │ │ │ -OpenLayers.Event.observe(window, 'unload', OpenLayers.Event.unloadCache, false);
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Class: OpenLayers.Events
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Events = OpenLayers.Class({
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constant: BROWSER_EVENTS
│ │ │ │ │ - * {Array(String)} supported events
│ │ │ │ │ - */
│ │ │ │ │ - BROWSER_EVENTS: [
│ │ │ │ │ - "mouseover", "mouseout",
│ │ │ │ │ - "mousedown", "mouseup", "mousemove",
│ │ │ │ │ - "click", "dblclick", "rightclick", "dblrightclick",
│ │ │ │ │ - "resize", "focus", "blur",
│ │ │ │ │ - "touchstart", "touchmove", "touchend",
│ │ │ │ │ - "keydown"
│ │ │ │ │ - ],
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: listeners
│ │ │ │ │ - * {Object} Hashtable of Array(Function): events listener functions
│ │ │ │ │ - */
│ │ │ │ │ - listeners: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: object
│ │ │ │ │ - * {Object} the code object issuing application events
│ │ │ │ │ - */
│ │ │ │ │ - object: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: element
│ │ │ │ │ - * {DOMElement} the DOM element receiving browser events
│ │ │ │ │ - */
│ │ │ │ │ - element: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: eventHandler
│ │ │ │ │ - * {Function} bound event handler attached to elements
│ │ │ │ │ - */
│ │ │ │ │ - eventHandler: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: fallThrough
│ │ │ │ │ - * {Boolean}
│ │ │ │ │ - */
│ │ │ │ │ - fallThrough: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: includeXY
│ │ │ │ │ - * {Boolean} Should the .xy property automatically be created for browser
│ │ │ │ │ - * mouse events? In general, this should be false. If it is true, then
│ │ │ │ │ - * mouse events will automatically generate a '.xy' property on the
│ │ │ │ │ - * event object that is passed. (Prior to OpenLayers 2.7, this was true
│ │ │ │ │ - * by default.) Otherwise, you can call the getMousePosition on the
│ │ │ │ │ - * relevant events handler on the object available via the 'evt.object'
│ │ │ │ │ - * property of the evt object. So, for most events, you can call:
│ │ │ │ │ - * function named(evt) {
│ │ │ │ │ - * this.xy = this.object.events.getMousePosition(evt)
│ │ │ │ │ - * }
│ │ │ │ │ - *
│ │ │ │ │ - * This option typically defaults to false for performance reasons:
│ │ │ │ │ - * when creating an events object whose primary purpose is to manage
│ │ │ │ │ - * relatively positioned mouse events within a div, it may make
│ │ │ │ │ - * sense to set it to true.
│ │ │ │ │ - *
│ │ │ │ │ - * This option is also used to control whether the events object caches
│ │ │ │ │ - * offsets. If this is false, it will not: the reason for this is that
│ │ │ │ │ - * it is only expected to be called many times if the includeXY property
│ │ │ │ │ - * is set to true. If you set this to true, you are expected to clear
│ │ │ │ │ - * the offset cache manually (using this.clearMouseCache()) if:
│ │ │ │ │ - * the border of the element changes
│ │ │ │ │ - * the location of the element in the page changes
│ │ │ │ │ - */
│ │ │ │ │ - includeXY: false,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: extensions
│ │ │ │ │ - * {Object} Event extensions registered with this instance. Keys are
│ │ │ │ │ - * event types, values are {OpenLayers.Events.*} extension instances or
│ │ │ │ │ - * {Boolean} for events that an instantiated extension provides in
│ │ │ │ │ - * addition to the one it was created for.
│ │ │ │ │ - *
│ │ │ │ │ - * Extensions create an event in addition to browser events, which usually
│ │ │ │ │ - * fires when a sequence of browser events is completed. Extensions are
│ │ │ │ │ - * automatically instantiated when a listener is registered for an event
│ │ │ │ │ - * provided by an extension.
│ │ │ │ │ - *
│ │ │ │ │ - * Extensions are created in the namespace using
│ │ │ │ │ - * , and named after the event they provide.
│ │ │ │ │ - * The constructor receives the target instance as
│ │ │ │ │ - * argument. Extensions that need to capture browser events before they
│ │ │ │ │ - * propagate can register their listeners events using , with
│ │ │ │ │ - * {extension: true} as 4th argument.
│ │ │ │ │ - *
│ │ │ │ │ - * If an extension creates more than one event, an alias for each event
│ │ │ │ │ - * type should be created and reference the same class. The constructor
│ │ │ │ │ - * should set a reference in the target's extensions registry to itself.
│ │ │ │ │ - *
│ │ │ │ │ - * Below is a minimal extension that provides the "foostart" and "fooend"
│ │ │ │ │ - * event types, which replace the native "click" event type if clicked on
│ │ │ │ │ - * an element with the css class "foo":
│ │ │ │ │ - *
│ │ │ │ │ - * (code)
│ │ │ │ │ - * OpenLayers.Events.foostart = OpenLayers.Class({
│ │ │ │ │ - * initialize: function(target) {
│ │ │ │ │ - * this.target = target;
│ │ │ │ │ - * this.target.register("click", this, this.doStuff, {extension: true});
│ │ │ │ │ - * // only required if extension provides more than one event type
│ │ │ │ │ - * this.target.extensions["foostart"] = true;
│ │ │ │ │ - * this.target.extensions["fooend"] = true;
│ │ │ │ │ - * },
│ │ │ │ │ - * destroy: function() {
│ │ │ │ │ - * var target = this.target;
│ │ │ │ │ - * target.unregister("click", this, this.doStuff);
│ │ │ │ │ - * delete this.target;
│ │ │ │ │ - * // only required if extension provides more than one event type
│ │ │ │ │ - * delete target.extensions["foostart"];
│ │ │ │ │ - * delete target.extensions["fooend"];
│ │ │ │ │ - * },
│ │ │ │ │ - * doStuff: function(evt) {
│ │ │ │ │ - * var propagate = true;
│ │ │ │ │ - * if (OpenLayers.Event.element(evt).className === "foo") {
│ │ │ │ │ - * propagate = false;
│ │ │ │ │ - * var target = this.target;
│ │ │ │ │ - * target.triggerEvent("foostart");
│ │ │ │ │ - * window.setTimeout(function() {
│ │ │ │ │ - * target.triggerEvent("fooend");
│ │ │ │ │ - * }, 1000);
│ │ │ │ │ - * }
│ │ │ │ │ - * return propagate;
│ │ │ │ │ - * }
│ │ │ │ │ - * });
│ │ │ │ │ - * // only required if extension provides more than one event type
│ │ │ │ │ - * OpenLayers.Events.fooend = OpenLayers.Events.foostart;
│ │ │ │ │ - * (end)
│ │ │ │ │ - *
│ │ │ │ │ - */
│ │ │ │ │ - extensions: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: extensionCount
│ │ │ │ │ - * {Object} Keys are event types (like in ), values are the
│ │ │ │ │ - * number of extension listeners for each event type.
│ │ │ │ │ - */
│ │ │ │ │ - extensionCount: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: clearMouseListener
│ │ │ │ │ - * A version of that is bound to this instance so that
│ │ │ │ │ - * it can be used with and
│ │ │ │ │ - * .
│ │ │ │ │ - */
│ │ │ │ │ - clearMouseListener: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constructor: OpenLayers.Events
│ │ │ │ │ - * Construct an OpenLayers.Events object.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * object - {Object} The js object to which this Events object is being added
│ │ │ │ │ - * element - {DOMElement} A dom element to respond to browser events
│ │ │ │ │ - * eventTypes - {Array(String)} Deprecated. Array of custom application
│ │ │ │ │ - * events. A listener may be registered for any named event, regardless
│ │ │ │ │ - * of the values provided here.
│ │ │ │ │ - * fallThrough - {Boolean} Allow events to fall through after these have
│ │ │ │ │ - * been handled?
│ │ │ │ │ - * options - {Object} Options for the events object.
│ │ │ │ │ - */
│ │ │ │ │ - initialize: function(object, element, eventTypes, fallThrough, options) {
│ │ │ │ │ - OpenLayers.Util.extend(this, options);
│ │ │ │ │ - this.object = object;
│ │ │ │ │ - this.fallThrough = fallThrough;
│ │ │ │ │ - this.listeners = {};
│ │ │ │ │ - this.extensions = {};
│ │ │ │ │ - this.extensionCount = {};
│ │ │ │ │ - this._msTouches = [];
│ │ │ │ │ -
│ │ │ │ │ - // if a dom element is specified, add a listeners list
│ │ │ │ │ - // for browser events on the element and register them
│ │ │ │ │ - if (element != null) {
│ │ │ │ │ - this.attachToElement(element);
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: destroy
│ │ │ │ │ - */
│ │ │ │ │ - destroy: function() {
│ │ │ │ │ - for (var e in this.extensions) {
│ │ │ │ │ - if (typeof this.extensions[e] !== "boolean") {
│ │ │ │ │ - this.extensions[e].destroy();
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - this.extensions = null;
│ │ │ │ │ - if (this.element) {
│ │ │ │ │ - OpenLayers.Event.stopObservingElement(this.element);
│ │ │ │ │ - if (this.element.hasScrollEvent) {
│ │ │ │ │ - OpenLayers.Event.stopObserving(
│ │ │ │ │ - window, "scroll", this.clearMouseListener
│ │ │ │ │ - );
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - this.element = null;
│ │ │ │ │ -
│ │ │ │ │ - this.listeners = null;
│ │ │ │ │ - this.object = null;
│ │ │ │ │ - this.fallThrough = null;
│ │ │ │ │ - this.eventHandler = null;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: addEventType
│ │ │ │ │ - * Deprecated. Any event can be triggered without adding it first.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * eventName - {String}
│ │ │ │ │ - */
│ │ │ │ │ - addEventType: function(eventName) {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: attachToElement
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {HTMLDOMElement} a DOM element to attach browser events to
│ │ │ │ │ - */
│ │ │ │ │ - attachToElement: function(element) {
│ │ │ │ │ - if (this.element) {
│ │ │ │ │ - OpenLayers.Event.stopObservingElement(this.element);
│ │ │ │ │ - } else {
│ │ │ │ │ - // keep a bound copy of handleBrowserEvent() so that we can
│ │ │ │ │ - // pass the same function to both Event.observe() and .stopObserving()
│ │ │ │ │ - this.eventHandler = OpenLayers.Function.bindAsEventListener(
│ │ │ │ │ - this.handleBrowserEvent, this
│ │ │ │ │ - );
│ │ │ │ │ -
│ │ │ │ │ - // to be used with observe and stopObserving
│ │ │ │ │ - this.clearMouseListener = OpenLayers.Function.bind(
│ │ │ │ │ - this.clearMouseCache, this
│ │ │ │ │ - );
│ │ │ │ │ - }
│ │ │ │ │ - this.element = element;
│ │ │ │ │ - var msTouch = !!window.navigator.msMaxTouchPoints;
│ │ │ │ │ - var type;
│ │ │ │ │ - for (var i = 0, len = this.BROWSER_EVENTS.length; i < len; i++) {
│ │ │ │ │ - type = this.BROWSER_EVENTS[i];
│ │ │ │ │ - // register the event cross-browser
│ │ │ │ │ - OpenLayers.Event.observe(element, type, this.eventHandler);
│ │ │ │ │ - if (msTouch && type.indexOf('touch') === 0) {
│ │ │ │ │ - this.addMsTouchListener(element, type, this.eventHandler);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - // disable dragstart in IE so that mousedown/move/up works normally
│ │ │ │ │ - OpenLayers.Event.observe(element, "dragstart", OpenLayers.Event.stop);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: on
│ │ │ │ │ - * Convenience method for registering listeners with a common scope.
│ │ │ │ │ - * Internally, this method calls as shown in the examples
│ │ │ │ │ - * below.
│ │ │ │ │ - *
│ │ │ │ │ - * Example use:
│ │ │ │ │ - * (code)
│ │ │ │ │ - * // register a single listener for the "loadstart" event
│ │ │ │ │ - * events.on({"loadstart": loadStartListener});
│ │ │ │ │ - *
│ │ │ │ │ - * // this is equivalent to the following
│ │ │ │ │ - * events.register("loadstart", undefined, loadStartListener);
│ │ │ │ │ - *
│ │ │ │ │ - * // register multiple listeners to be called with the same `this` object
│ │ │ │ │ - * events.on({
│ │ │ │ │ - * "loadstart": loadStartListener,
│ │ │ │ │ - * "loadend": loadEndListener,
│ │ │ │ │ - * scope: object
│ │ │ │ │ - * });
│ │ │ │ │ - *
│ │ │ │ │ - * // this is equivalent to the following
│ │ │ │ │ - * events.register("loadstart", object, loadStartListener);
│ │ │ │ │ - * events.register("loadend", object, loadEndListener);
│ │ │ │ │ - * (end)
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * object - {Object}
│ │ │ │ │ - */
│ │ │ │ │ - on: function(object) {
│ │ │ │ │ - for (var type in object) {
│ │ │ │ │ - if (type != "scope" && object.hasOwnProperty(type)) {
│ │ │ │ │ - this.register(type, object.scope, object[type]);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: register
│ │ │ │ │ - * Register an event on the events object.
│ │ │ │ │ - *
│ │ │ │ │ - * When the event is triggered, the 'func' function will be called, in the
│ │ │ │ │ - * context of 'obj'. Imagine we were to register an event, specifying an
│ │ │ │ │ - * OpenLayers.Bounds Object as 'obj'. When the event is triggered, the
│ │ │ │ │ - * context in the callback function will be our Bounds object. This means
│ │ │ │ │ - * that within our callback function, we can access the properties and
│ │ │ │ │ - * methods of the Bounds object through the "this" variable. So our
│ │ │ │ │ - * callback could execute something like:
│ │ │ │ │ - * : leftStr = "Left: " + this.left;
│ │ │ │ │ - *
│ │ │ │ │ - * or
│ │ │ │ │ - *
│ │ │ │ │ - * : centerStr = "Center: " + this.getCenterLonLat();
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * type - {String} Name of the event to register
│ │ │ │ │ - * obj - {Object} The object to bind the context to for the callback#.
│ │ │ │ │ - * If no object is specified, default is the Events's 'object' property.
│ │ │ │ │ - * func - {Function} The callback function. If no callback is
│ │ │ │ │ - * specified, this function does nothing.
│ │ │ │ │ - * priority - {Boolean|Object} If true, adds the new listener to the
│ │ │ │ │ - * *front* of the events queue instead of to the end.
│ │ │ │ │ - *
│ │ │ │ │ - * Valid options for priority:
│ │ │ │ │ - * extension - {Boolean} If true, then the event will be registered as
│ │ │ │ │ - * extension event. Extension events are handled before all other
│ │ │ │ │ - * events.
│ │ │ │ │ - */
│ │ │ │ │ - register: function(type, obj, func, priority) {
│ │ │ │ │ - if (type in OpenLayers.Events && !this.extensions[type]) {
│ │ │ │ │ - this.extensions[type] = new OpenLayers.Events[type](this);
│ │ │ │ │ - }
│ │ │ │ │ - if (func != null) {
│ │ │ │ │ - if (obj == null) {
│ │ │ │ │ - obj = this.object;
│ │ │ │ │ - }
│ │ │ │ │ - var listeners = this.listeners[type];
│ │ │ │ │ - if (!listeners) {
│ │ │ │ │ - listeners = [];
│ │ │ │ │ - this.listeners[type] = listeners;
│ │ │ │ │ - this.extensionCount[type] = 0;
│ │ │ │ │ - }
│ │ │ │ │ - var listener = {
│ │ │ │ │ - obj: obj,
│ │ │ │ │ - func: func
│ │ │ │ │ - };
│ │ │ │ │ - if (priority) {
│ │ │ │ │ - listeners.splice(this.extensionCount[type], 0, listener);
│ │ │ │ │ - if (typeof priority === "object" && priority.extension) {
│ │ │ │ │ - this.extensionCount[type]++;
│ │ │ │ │ - }
│ │ │ │ │ - } else {
│ │ │ │ │ - listeners.push(listener);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: registerPriority
│ │ │ │ │ - * Same as register() but adds the new listener to the *front* of the
│ │ │ │ │ - * events queue instead of to the end.
│ │ │ │ │ - *
│ │ │ │ │ - * TODO: get rid of this in 3.0 - Decide whether listeners should be
│ │ │ │ │ - * called in the order they were registered or in reverse order.
│ │ │ │ │ - *
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * type - {String} Name of the event to register
│ │ │ │ │ - * obj - {Object} The object to bind the context to for the callback#.
│ │ │ │ │ - * If no object is specified, default is the Events's
│ │ │ │ │ - * 'object' property.
│ │ │ │ │ - * func - {Function} The callback function. If no callback is
│ │ │ │ │ - * specified, this function does nothing.
│ │ │ │ │ - */
│ │ │ │ │ - registerPriority: function(type, obj, func) {
│ │ │ │ │ - this.register(type, obj, func, true);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: un
│ │ │ │ │ - * Convenience method for unregistering listeners with a common scope.
│ │ │ │ │ - * Internally, this method calls as shown in the examples
│ │ │ │ │ - * below.
│ │ │ │ │ - *
│ │ │ │ │ - * Example use:
│ │ │ │ │ - * (code)
│ │ │ │ │ - * // unregister a single listener for the "loadstart" event
│ │ │ │ │ - * events.un({"loadstart": loadStartListener});
│ │ │ │ │ - *
│ │ │ │ │ - * // this is equivalent to the following
│ │ │ │ │ - * events.unregister("loadstart", undefined, loadStartListener);
│ │ │ │ │ - *
│ │ │ │ │ - * // unregister multiple listeners with the same `this` object
│ │ │ │ │ - * events.un({
│ │ │ │ │ - * "loadstart": loadStartListener,
│ │ │ │ │ - * "loadend": loadEndListener,
│ │ │ │ │ - * scope: object
│ │ │ │ │ - * });
│ │ │ │ │ - *
│ │ │ │ │ - * // this is equivalent to the following
│ │ │ │ │ - * events.unregister("loadstart", object, loadStartListener);
│ │ │ │ │ - * events.unregister("loadend", object, loadEndListener);
│ │ │ │ │ - * (end)
│ │ │ │ │ - */
│ │ │ │ │ - un: function(object) {
│ │ │ │ │ - for (var type in object) {
│ │ │ │ │ - if (type != "scope" && object.hasOwnProperty(type)) {
│ │ │ │ │ - this.unregister(type, object.scope, object[type]);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: unregister
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * type - {String}
│ │ │ │ │ - * obj - {Object} If none specified, defaults to this.object
│ │ │ │ │ - * func - {Function}
│ │ │ │ │ - */
│ │ │ │ │ - unregister: function(type, obj, func) {
│ │ │ │ │ - if (obj == null) {
│ │ │ │ │ - obj = this.object;
│ │ │ │ │ - }
│ │ │ │ │ - var listeners = this.listeners[type];
│ │ │ │ │ - if (listeners != null) {
│ │ │ │ │ - for (var i = 0, len = listeners.length; i < len; i++) {
│ │ │ │ │ - if (listeners[i].obj == obj && listeners[i].func == func) {
│ │ │ │ │ - listeners.splice(i, 1);
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: remove
│ │ │ │ │ - * Remove all listeners for a given event type. If type is not registered,
│ │ │ │ │ - * does nothing.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * type - {String}
│ │ │ │ │ - */
│ │ │ │ │ - remove: function(type) {
│ │ │ │ │ - if (this.listeners[type] != null) {
│ │ │ │ │ - this.listeners[type] = [];
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: triggerEvent
│ │ │ │ │ - * Trigger a specified registered event.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * type - {String}
│ │ │ │ │ - * evt - {Event || Object} will be passed to the listeners.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} The last listener return. If a listener returns false, the
│ │ │ │ │ - * chain of listeners will stop getting called.
│ │ │ │ │ - */
│ │ │ │ │ - triggerEvent: function(type, evt) {
│ │ │ │ │ - var listeners = this.listeners[type];
│ │ │ │ │ -
│ │ │ │ │ - // fast path
│ │ │ │ │ - if (!listeners || listeners.length == 0) {
│ │ │ │ │ - return undefined;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // prep evt object with object & div references
│ │ │ │ │ - if (evt == null) {
│ │ │ │ │ - evt = {};
│ │ │ │ │ - }
│ │ │ │ │ - evt.object = this.object;
│ │ │ │ │ - evt.element = this.element;
│ │ │ │ │ - if (!evt.type) {
│ │ │ │ │ - evt.type = type;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // execute all callbacks registered for specified type
│ │ │ │ │ - // get a clone of the listeners array to
│ │ │ │ │ - // allow for splicing during callbacks
│ │ │ │ │ - listeners = listeners.slice();
│ │ │ │ │ - var continueChain;
│ │ │ │ │ - for (var i = 0, len = listeners.length; i < len; i++) {
│ │ │ │ │ - var callback = listeners[i];
│ │ │ │ │ - // bind the context to callback.obj
│ │ │ │ │ - continueChain = callback.func.apply(callback.obj, [evt]);
│ │ │ │ │ -
│ │ │ │ │ - if ((continueChain != undefined) && (continueChain == false)) {
│ │ │ │ │ - // if callback returns false, execute no more callbacks.
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - // don't fall through to other DOM elements
│ │ │ │ │ - if (!this.fallThrough) {
│ │ │ │ │ - OpenLayers.Event.stop(evt, true);
│ │ │ │ │ - }
│ │ │ │ │ - return continueChain;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: handleBrowserEvent
│ │ │ │ │ - * Basically just a wrapper to the triggerEvent() function, but takes
│ │ │ │ │ - * care to set a property 'xy' on the event with the current mouse
│ │ │ │ │ - * position.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * evt - {Event}
│ │ │ │ │ - */
│ │ │ │ │ - handleBrowserEvent: function(evt) {
│ │ │ │ │ - var type = evt.type,
│ │ │ │ │ - listeners = this.listeners[type];
│ │ │ │ │ - if (!listeners || listeners.length == 0) {
│ │ │ │ │ - // noone's listening, bail out
│ │ │ │ │ - return;
│ │ │ │ │ - }
│ │ │ │ │ - // add clientX & clientY to all events - corresponds to average x, y
│ │ │ │ │ - var touches = evt.touches;
│ │ │ │ │ - if (touches && touches[0]) {
│ │ │ │ │ - var x = 0;
│ │ │ │ │ - var y = 0;
│ │ │ │ │ - var num = touches.length;
│ │ │ │ │ - var touch;
│ │ │ │ │ - for (var i = 0; i < num; ++i) {
│ │ │ │ │ - touch = this.getTouchClientXY(touches[i]);
│ │ │ │ │ - x += touch.clientX;
│ │ │ │ │ - y += touch.clientY;
│ │ │ │ │ - }
│ │ │ │ │ - evt.clientX = x / num;
│ │ │ │ │ - evt.clientY = y / num;
│ │ │ │ │ - }
│ │ │ │ │ - if (this.includeXY) {
│ │ │ │ │ - evt.xy = this.getMousePosition(evt);
│ │ │ │ │ - }
│ │ │ │ │ - this.triggerEvent(type, evt);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: getTouchClientXY
│ │ │ │ │ - * WebKit has a few bugs for clientX/clientY. This method detects them
│ │ │ │ │ - * and calculate the correct values.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * evt - {Touch} a Touch object from a TouchEvent
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Object} An object with only clientX and clientY properties with the
│ │ │ │ │ - * calculated values.
│ │ │ │ │ - */
│ │ │ │ │ - getTouchClientXY: function(evt) {
│ │ │ │ │ - // olMochWin is to override window, used for testing
│ │ │ │ │ - var win = window.olMockWin || window,
│ │ │ │ │ - winPageX = win.pageXOffset,
│ │ │ │ │ - winPageY = win.pageYOffset,
│ │ │ │ │ - x = evt.clientX,
│ │ │ │ │ - y = evt.clientY;
│ │ │ │ │ -
│ │ │ │ │ - if (evt.pageY === 0 && Math.floor(y) > Math.floor(evt.pageY) ||
│ │ │ │ │ - evt.pageX === 0 && Math.floor(x) > Math.floor(evt.pageX)) {
│ │ │ │ │ - // iOS4 include scroll offset in clientX/Y
│ │ │ │ │ - x = x - winPageX;
│ │ │ │ │ - y = y - winPageY;
│ │ │ │ │ - } else if (y < (evt.pageY - winPageY) || x < (evt.pageX - winPageX)) {
│ │ │ │ │ - // Some Android browsers have totally bogus values for clientX/Y
│ │ │ │ │ - // when scrolling/zooming a page
│ │ │ │ │ - x = evt.pageX - winPageX;
│ │ │ │ │ - y = evt.pageY - winPageY;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - evt.olClientX = x;
│ │ │ │ │ - evt.olClientY = y;
│ │ │ │ │ -
│ │ │ │ │ - return {
│ │ │ │ │ - clientX: x,
│ │ │ │ │ - clientY: y
│ │ │ │ │ - };
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: clearMouseCache
│ │ │ │ │ - * Clear cached data about the mouse position. This should be called any
│ │ │ │ │ - * time the element that events are registered on changes position
│ │ │ │ │ - * within the page.
│ │ │ │ │ - */
│ │ │ │ │ - clearMouseCache: function() {
│ │ │ │ │ - this.element.scrolls = null;
│ │ │ │ │ - this.element.lefttop = null;
│ │ │ │ │ - this.element.offsets = null;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: getMousePosition
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * evt - {Event}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {} The current xy coordinate of the mouse, adjusted
│ │ │ │ │ - * for offsets
│ │ │ │ │ - */
│ │ │ │ │ - getMousePosition: function(evt) {
│ │ │ │ │ - if (!this.includeXY) {
│ │ │ │ │ - this.clearMouseCache();
│ │ │ │ │ - } else if (!this.element.hasScrollEvent) {
│ │ │ │ │ - OpenLayers.Event.observe(window, "scroll", this.clearMouseListener);
│ │ │ │ │ - this.element.hasScrollEvent = true;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - if (!this.element.scrolls) {
│ │ │ │ │ - var viewportElement = OpenLayers.Util.getViewportElement();
│ │ │ │ │ - this.element.scrolls = [
│ │ │ │ │ - window.pageXOffset || viewportElement.scrollLeft,
│ │ │ │ │ - window.pageYOffset || viewportElement.scrollTop
│ │ │ │ │ - ];
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - if (!this.element.lefttop) {
│ │ │ │ │ - this.element.lefttop = [
│ │ │ │ │ - (document.documentElement.clientLeft || 0),
│ │ │ │ │ - (document.documentElement.clientTop || 0)
│ │ │ │ │ - ];
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - if (!this.element.offsets) {
│ │ │ │ │ - this.element.offsets = OpenLayers.Util.pagePosition(this.element);
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - return new OpenLayers.Pixel(
│ │ │ │ │ - (evt.clientX + this.element.scrolls[0]) - this.element.offsets[0] -
│ │ │ │ │ - this.element.lefttop[0],
│ │ │ │ │ - (evt.clientY + this.element.scrolls[1]) - this.element.offsets[1] -
│ │ │ │ │ - this.element.lefttop[1]
│ │ │ │ │ - );
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: addMsTouchListener
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {DOMElement} The DOM element to register the listener on
│ │ │ │ │ - * type - {String} The event type
│ │ │ │ │ - * handler - {Function} the handler
│ │ │ │ │ - */
│ │ │ │ │ - addMsTouchListener: function(element, type, handler) {
│ │ │ │ │ - var eventHandler = this.eventHandler;
│ │ │ │ │ - var touches = this._msTouches;
│ │ │ │ │ -
│ │ │ │ │ - function msHandler(evt) {
│ │ │ │ │ - handler(OpenLayers.Util.applyDefaults({
│ │ │ │ │ - stopPropagation: function() {
│ │ │ │ │ - for (var i = touches.length - 1; i >= 0; --i) {
│ │ │ │ │ - touches[i].stopPropagation();
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ - preventDefault: function() {
│ │ │ │ │ - for (var i = touches.length - 1; i >= 0; --i) {
│ │ │ │ │ - touches[i].preventDefault();
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ - type: type
│ │ │ │ │ - }, evt));
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - switch (type) {
│ │ │ │ │ - case 'touchstart':
│ │ │ │ │ - return this.addMsTouchListenerStart(element, type, msHandler);
│ │ │ │ │ - case 'touchend':
│ │ │ │ │ - return this.addMsTouchListenerEnd(element, type, msHandler);
│ │ │ │ │ - case 'touchmove':
│ │ │ │ │ - return this.addMsTouchListenerMove(element, type, msHandler);
│ │ │ │ │ - default:
│ │ │ │ │ - throw 'Unknown touch event type';
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: addMsTouchListenerStart
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {DOMElement} The DOM element to register the listener on
│ │ │ │ │ - * type - {String} The event type
│ │ │ │ │ - * handler - {Function} the handler
│ │ │ │ │ - */
│ │ │ │ │ - addMsTouchListenerStart: function(element, type, handler) {
│ │ │ │ │ - var touches = this._msTouches;
│ │ │ │ │ -
│ │ │ │ │ - var cb = function(e) {
│ │ │ │ │ -
│ │ │ │ │ - var alreadyInArray = false;
│ │ │ │ │ - for (var i = 0, ii = touches.length; i < ii; ++i) {
│ │ │ │ │ - if (touches[i].pointerId == e.pointerId) {
│ │ │ │ │ - alreadyInArray = true;
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - if (!alreadyInArray) {
│ │ │ │ │ - touches.push(e);
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - e.touches = touches.slice();
│ │ │ │ │ - handler(e);
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - OpenLayers.Event.observe(element, 'MSPointerDown', cb);
│ │ │ │ │ -
│ │ │ │ │ - // Need to also listen for end events to keep the _msTouches list
│ │ │ │ │ - // accurate
│ │ │ │ │ - var internalCb = function(e) {
│ │ │ │ │ - for (var i = 0, ii = touches.length; i < ii; ++i) {
│ │ │ │ │ - if (touches[i].pointerId == e.pointerId) {
│ │ │ │ │ - touches.splice(i, 1);
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - };
│ │ │ │ │ - OpenLayers.Event.observe(element, 'MSPointerUp', internalCb);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: addMsTouchListenerMove
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {DOMElement} The DOM element to register the listener on
│ │ │ │ │ - * type - {String} The event type
│ │ │ │ │ - * handler - {Function} the handler
│ │ │ │ │ - */
│ │ │ │ │ - addMsTouchListenerMove: function(element, type, handler) {
│ │ │ │ │ - var touches = this._msTouches;
│ │ │ │ │ - var cb = function(e) {
│ │ │ │ │ -
│ │ │ │ │ - //Don't fire touch moves when mouse isn't down
│ │ │ │ │ - if (e.pointerType == e.MSPOINTER_TYPE_MOUSE && e.buttons == 0) {
│ │ │ │ │ - return;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - if (touches.length == 1 && touches[0].pageX == e.pageX &&
│ │ │ │ │ - touches[0].pageY == e.pageY) {
│ │ │ │ │ - // don't trigger event when pointer has not moved
│ │ │ │ │ - return;
│ │ │ │ │ - }
│ │ │ │ │ - for (var i = 0, ii = touches.length; i < ii; ++i) {
│ │ │ │ │ - if (touches[i].pointerId == e.pointerId) {
│ │ │ │ │ - touches[i] = e;
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - e.touches = touches.slice();
│ │ │ │ │ - handler(e);
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - OpenLayers.Event.observe(element, 'MSPointerMove', cb);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: addMsTouchListenerEnd
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * element - {DOMElement} The DOM element to register the listener on
│ │ │ │ │ - * type - {String} The event type
│ │ │ │ │ - * handler - {Function} the handler
│ │ │ │ │ - */
│ │ │ │ │ - addMsTouchListenerEnd: function(element, type, handler) {
│ │ │ │ │ - var touches = this._msTouches;
│ │ │ │ │ -
│ │ │ │ │ - var cb = function(e) {
│ │ │ │ │ -
│ │ │ │ │ - for (var i = 0, ii = touches.length; i < ii; ++i) {
│ │ │ │ │ - if (touches[i].pointerId == e.pointerId) {
│ │ │ │ │ - touches.splice(i, 1);
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - e.touches = touches.slice();
│ │ │ │ │ - handler(e);
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - OpenLayers.Event.observe(element, 'MSPointerUp', cb);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Events"
│ │ │ │ │ -});
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Request/XMLHttpRequest.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -// XMLHttpRequest.js Copyright (C) 2010 Sergey Ilinsky (http://www.ilinsky.com)
│ │ │ │ │ -//
│ │ │ │ │ -// Licensed under the Apache License, Version 2.0 (the "License");
│ │ │ │ │ -// you may not use this file except in compliance with the License.
│ │ │ │ │ -// You may obtain a copy of the License at
│ │ │ │ │ -//
│ │ │ │ │ -// http://www.apache.org/licenses/LICENSE-2.0
│ │ │ │ │ -//
│ │ │ │ │ -// Unless required by applicable law or agreed to in writing, software
│ │ │ │ │ -// distributed under the License is distributed on an "AS IS" BASIS,
│ │ │ │ │ -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
│ │ │ │ │ -// See the License for the specific language governing permissions and
│ │ │ │ │ -// limitations under the License.
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/Request.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -(function() {
│ │ │ │ │ -
│ │ │ │ │ - // Save reference to earlier defined object implementation (if any)
│ │ │ │ │ - var oXMLHttpRequest = window.XMLHttpRequest;
│ │ │ │ │ -
│ │ │ │ │ - // Define on browser type
│ │ │ │ │ - var bGecko = !!window.controllers,
│ │ │ │ │ - bIE = window.document.all && !window.opera,
│ │ │ │ │ - bIE7 = bIE && window.navigator.userAgent.match(/MSIE 7.0/);
│ │ │ │ │ -
│ │ │ │ │ - // Enables "XMLHttpRequest()" call next to "new XMLHttpReques()"
│ │ │ │ │ - function fXMLHttpRequest() {
│ │ │ │ │ - this._object = oXMLHttpRequest && !bIE7 ? new oXMLHttpRequest : new window.ActiveXObject("Microsoft.XMLHTTP");
│ │ │ │ │ - this._listeners = [];
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - // Constructor
│ │ │ │ │ - function cXMLHttpRequest() {
│ │ │ │ │ - return new fXMLHttpRequest;
│ │ │ │ │ - };
│ │ │ │ │ - cXMLHttpRequest.prototype = fXMLHttpRequest.prototype;
│ │ │ │ │ -
│ │ │ │ │ - // BUGFIX: Firefox with Firebug installed would break pages if not executed
│ │ │ │ │ - if (bGecko && oXMLHttpRequest.wrapped)
│ │ │ │ │ - cXMLHttpRequest.wrapped = oXMLHttpRequest.wrapped;
│ │ │ │ │ -
│ │ │ │ │ - // Constants
│ │ │ │ │ - cXMLHttpRequest.UNSENT = 0;
│ │ │ │ │ - cXMLHttpRequest.OPENED = 1;
│ │ │ │ │ - cXMLHttpRequest.HEADERS_RECEIVED = 2;
│ │ │ │ │ - cXMLHttpRequest.LOADING = 3;
│ │ │ │ │ - cXMLHttpRequest.DONE = 4;
│ │ │ │ │ -
│ │ │ │ │ - // Public Properties
│ │ │ │ │ - cXMLHttpRequest.prototype.readyState = cXMLHttpRequest.UNSENT;
│ │ │ │ │ - cXMLHttpRequest.prototype.responseText = '';
│ │ │ │ │ - cXMLHttpRequest.prototype.responseXML = null;
│ │ │ │ │ - cXMLHttpRequest.prototype.status = 0;
│ │ │ │ │ - cXMLHttpRequest.prototype.statusText = '';
│ │ │ │ │ -
│ │ │ │ │ - // Priority proposal
│ │ │ │ │ - cXMLHttpRequest.prototype.priority = "NORMAL";
│ │ │ │ │ -
│ │ │ │ │ - // Instance-level Events Handlers
│ │ │ │ │ - cXMLHttpRequest.prototype.onreadystatechange = null;
│ │ │ │ │ -
│ │ │ │ │ - // Class-level Events Handlers
│ │ │ │ │ - cXMLHttpRequest.onreadystatechange = null;
│ │ │ │ │ - cXMLHttpRequest.onopen = null;
│ │ │ │ │ - cXMLHttpRequest.onsend = null;
│ │ │ │ │ - cXMLHttpRequest.onabort = null;
│ │ │ │ │ -
│ │ │ │ │ - // Public Methods
│ │ │ │ │ - cXMLHttpRequest.prototype.open = function(sMethod, sUrl, bAsync, sUser, sPassword) {
│ │ │ │ │ - // Delete headers, required when object is reused
│ │ │ │ │ - delete this._headers;
│ │ │ │ │ -
│ │ │ │ │ - // When bAsync parameter value is omitted, use true as default
│ │ │ │ │ - if (arguments.length < 3)
│ │ │ │ │ - bAsync = true;
│ │ │ │ │ -
│ │ │ │ │ - // Save async parameter for fixing Gecko bug with missing readystatechange in synchronous requests
│ │ │ │ │ - this._async = bAsync;
│ │ │ │ │ -
│ │ │ │ │ - // Set the onreadystatechange handler
│ │ │ │ │ - var oRequest = this,
│ │ │ │ │ - nState = this.readyState,
│ │ │ │ │ - fOnUnload;
│ │ │ │ │ -
│ │ │ │ │ - // BUGFIX: IE - memory leak on page unload (inter-page leak)
│ │ │ │ │ - if (bIE && bAsync) {
│ │ │ │ │ - fOnUnload = function() {
│ │ │ │ │ - if (nState != cXMLHttpRequest.DONE) {
│ │ │ │ │ - fCleanTransport(oRequest);
│ │ │ │ │ - // Safe to abort here since onreadystatechange handler removed
│ │ │ │ │ - oRequest.abort();
│ │ │ │ │ - }
│ │ │ │ │ - };
│ │ │ │ │ - window.attachEvent("onunload", fOnUnload);
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // Add method sniffer
│ │ │ │ │ - if (cXMLHttpRequest.onopen)
│ │ │ │ │ - cXMLHttpRequest.onopen.apply(this, arguments);
│ │ │ │ │ -
│ │ │ │ │ - if (arguments.length > 4)
│ │ │ │ │ - this._object.open(sMethod, sUrl, bAsync, sUser, sPassword);
│ │ │ │ │ - else
│ │ │ │ │ - if (arguments.length > 3)
│ │ │ │ │ - this._object.open(sMethod, sUrl, bAsync, sUser);
│ │ │ │ │ - else
│ │ │ │ │ - this._object.open(sMethod, sUrl, bAsync);
│ │ │ │ │ -
│ │ │ │ │ - this.readyState = cXMLHttpRequest.OPENED;
│ │ │ │ │ - fReadyStateChange(this);
│ │ │ │ │ -
│ │ │ │ │ - this._object.onreadystatechange = function() {
│ │ │ │ │ - if (bGecko && !bAsync)
│ │ │ │ │ - return;
│ │ │ │ │ -
│ │ │ │ │ - // Synchronize state
│ │ │ │ │ - oRequest.readyState = oRequest._object.readyState;
│ │ │ │ │ -
│ │ │ │ │ - //
│ │ │ │ │ - fSynchronizeValues(oRequest);
│ │ │ │ │ -
│ │ │ │ │ - // BUGFIX: Firefox fires unnecessary DONE when aborting
│ │ │ │ │ - if (oRequest._aborted) {
│ │ │ │ │ - // Reset readyState to UNSENT
│ │ │ │ │ - oRequest.readyState = cXMLHttpRequest.UNSENT;
│ │ │ │ │ -
│ │ │ │ │ - // Return now
│ │ │ │ │ - return;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - if (oRequest.readyState == cXMLHttpRequest.DONE) {
│ │ │ │ │ - // Free up queue
│ │ │ │ │ - delete oRequest._data;
│ │ │ │ │ - /* if (bAsync)
│ │ │ │ │ - fQueue_remove(oRequest);*/
│ │ │ │ │ - //
│ │ │ │ │ - fCleanTransport(oRequest);
│ │ │ │ │ - // Uncomment this block if you need a fix for IE cache
│ │ │ │ │ - /*
│ │ │ │ │ - // BUGFIX: IE - cache issue
│ │ │ │ │ - if (!oRequest._object.getResponseHeader("Date")) {
│ │ │ │ │ - // Save object to cache
│ │ │ │ │ - oRequest._cached = oRequest._object;
│ │ │ │ │ -
│ │ │ │ │ - // Instantiate a new transport object
│ │ │ │ │ - cXMLHttpRequest.call(oRequest);
│ │ │ │ │ -
│ │ │ │ │ - // Re-send request
│ │ │ │ │ - if (sUser) {
│ │ │ │ │ - if (sPassword)
│ │ │ │ │ - oRequest._object.open(sMethod, sUrl, bAsync, sUser, sPassword);
│ │ │ │ │ - else
│ │ │ │ │ - oRequest._object.open(sMethod, sUrl, bAsync, sUser);
│ │ │ │ │ - }
│ │ │ │ │ - else
│ │ │ │ │ - oRequest._object.open(sMethod, sUrl, bAsync);
│ │ │ │ │ - oRequest._object.setRequestHeader("If-Modified-Since", oRequest._cached.getResponseHeader("Last-Modified") || new window.Date(0));
│ │ │ │ │ - // Copy headers set
│ │ │ │ │ - if (oRequest._headers)
│ │ │ │ │ - for (var sHeader in oRequest._headers)
│ │ │ │ │ - if (typeof oRequest._headers[sHeader] == "string") // Some frameworks prototype objects with functions
│ │ │ │ │ - oRequest._object.setRequestHeader(sHeader, oRequest._headers[sHeader]);
│ │ │ │ │ -
│ │ │ │ │ - oRequest._object.onreadystatechange = function() {
│ │ │ │ │ - // Synchronize state
│ │ │ │ │ - oRequest.readyState = oRequest._object.readyState;
│ │ │ │ │ -
│ │ │ │ │ - if (oRequest._aborted) {
│ │ │ │ │ - //
│ │ │ │ │ - oRequest.readyState = cXMLHttpRequest.UNSENT;
│ │ │ │ │ -
│ │ │ │ │ - // Return
│ │ │ │ │ - return;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - if (oRequest.readyState == cXMLHttpRequest.DONE) {
│ │ │ │ │ - // Clean Object
│ │ │ │ │ - fCleanTransport(oRequest);
│ │ │ │ │ -
│ │ │ │ │ - // get cached request
│ │ │ │ │ - if (oRequest.status == 304)
│ │ │ │ │ - oRequest._object = oRequest._cached;
│ │ │ │ │ -
│ │ │ │ │ - //
│ │ │ │ │ - delete oRequest._cached;
│ │ │ │ │ -
│ │ │ │ │ - //
│ │ │ │ │ - fSynchronizeValues(oRequest);
│ │ │ │ │ -
│ │ │ │ │ - //
│ │ │ │ │ - fReadyStateChange(oRequest);
│ │ │ │ │ -
│ │ │ │ │ - // BUGFIX: IE - memory leak in interrupted
│ │ │ │ │ - if (bIE && bAsync)
│ │ │ │ │ - window.detachEvent("onunload", fOnUnload);
│ │ │ │ │ - }
│ │ │ │ │ - };
│ │ │ │ │ - oRequest._object.send(null);
│ │ │ │ │ -
│ │ │ │ │ - // Return now - wait until re-sent request is finished
│ │ │ │ │ - return;
│ │ │ │ │ - };
│ │ │ │ │ - */
│ │ │ │ │ - // BUGFIX: IE - memory leak in interrupted
│ │ │ │ │ - if (bIE && bAsync)
│ │ │ │ │ - window.detachEvent("onunload", fOnUnload);
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // BUGFIX: Some browsers (Internet Explorer, Gecko) fire OPEN readystate twice
│ │ │ │ │ - if (nState != oRequest.readyState)
│ │ │ │ │ - fReadyStateChange(oRequest);
│ │ │ │ │ -
│ │ │ │ │ - nState = oRequest.readyState;
│ │ │ │ │ - }
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - function fXMLHttpRequest_send(oRequest) {
│ │ │ │ │ - oRequest._object.send(oRequest._data);
│ │ │ │ │ -
│ │ │ │ │ - // BUGFIX: Gecko - missing readystatechange calls in synchronous requests
│ │ │ │ │ - if (bGecko && !oRequest._async) {
│ │ │ │ │ - oRequest.readyState = cXMLHttpRequest.OPENED;
│ │ │ │ │ -
│ │ │ │ │ - // Synchronize state
│ │ │ │ │ - fSynchronizeValues(oRequest);
│ │ │ │ │ -
│ │ │ │ │ - // Simulate missing states
│ │ │ │ │ - while (oRequest.readyState < cXMLHttpRequest.DONE) {
│ │ │ │ │ - oRequest.readyState++;
│ │ │ │ │ - fReadyStateChange(oRequest);
│ │ │ │ │ - // Check if we are aborted
│ │ │ │ │ - if (oRequest._aborted)
│ │ │ │ │ - return;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - };
│ │ │ │ │ - cXMLHttpRequest.prototype.send = function(vData) {
│ │ │ │ │ - // Add method sniffer
│ │ │ │ │ - if (cXMLHttpRequest.onsend)
│ │ │ │ │ - cXMLHttpRequest.onsend.apply(this, arguments);
│ │ │ │ │ -
│ │ │ │ │ - if (!arguments.length)
│ │ │ │ │ - vData = null;
│ │ │ │ │ -
│ │ │ │ │ - // BUGFIX: Safari - fails sending documents created/modified dynamically, so an explicit serialization required
│ │ │ │ │ - // BUGFIX: IE - rewrites any custom mime-type to "text/xml" in case an XMLNode is sent
│ │ │ │ │ - // BUGFIX: Gecko - fails sending Element (this is up to the implementation either to standard)
│ │ │ │ │ - if (vData && vData.nodeType) {
│ │ │ │ │ - vData = window.XMLSerializer ? new window.XMLSerializer().serializeToString(vData) : vData.xml;
│ │ │ │ │ - if (!this._headers["Content-Type"])
│ │ │ │ │ - this._object.setRequestHeader("Content-Type", "application/xml");
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - this._data = vData;
│ │ │ │ │ - /*
│ │ │ │ │ - // Add to queue
│ │ │ │ │ - if (this._async)
│ │ │ │ │ - fQueue_add(this);
│ │ │ │ │ - else*/
│ │ │ │ │ - fXMLHttpRequest_send(this);
│ │ │ │ │ - };
│ │ │ │ │ - cXMLHttpRequest.prototype.abort = function() {
│ │ │ │ │ - // Add method sniffer
│ │ │ │ │ - if (cXMLHttpRequest.onabort)
│ │ │ │ │ - cXMLHttpRequest.onabort.apply(this, arguments);
│ │ │ │ │ -
│ │ │ │ │ - // BUGFIX: Gecko - unnecessary DONE when aborting
│ │ │ │ │ - if (this.readyState > cXMLHttpRequest.UNSENT)
│ │ │ │ │ - this._aborted = true;
│ │ │ │ │ -
│ │ │ │ │ - this._object.abort();
│ │ │ │ │ -
│ │ │ │ │ - // BUGFIX: IE - memory leak
│ │ │ │ │ - fCleanTransport(this);
│ │ │ │ │ -
│ │ │ │ │ - this.readyState = cXMLHttpRequest.UNSENT;
│ │ │ │ │ -
│ │ │ │ │ - delete this._data;
│ │ │ │ │ - /* if (this._async)
│ │ │ │ │ - fQueue_remove(this);*/
│ │ │ │ │ - };
│ │ │ │ │ - cXMLHttpRequest.prototype.getAllResponseHeaders = function() {
│ │ │ │ │ - return this._object.getAllResponseHeaders();
│ │ │ │ │ - };
│ │ │ │ │ - cXMLHttpRequest.prototype.getResponseHeader = function(sName) {
│ │ │ │ │ - return this._object.getResponseHeader(sName);
│ │ │ │ │ - };
│ │ │ │ │ - cXMLHttpRequest.prototype.setRequestHeader = function(sName, sValue) {
│ │ │ │ │ - // BUGFIX: IE - cache issue
│ │ │ │ │ - if (!this._headers)
│ │ │ │ │ - this._headers = {};
│ │ │ │ │ - this._headers[sName] = sValue;
│ │ │ │ │ -
│ │ │ │ │ - return this._object.setRequestHeader(sName, sValue);
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - // EventTarget interface implementation
│ │ │ │ │ - cXMLHttpRequest.prototype.addEventListener = function(sName, fHandler, bUseCapture) {
│ │ │ │ │ - for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)
│ │ │ │ │ - if (oListener[0] == sName && oListener[1] == fHandler && oListener[2] == bUseCapture)
│ │ │ │ │ - return;
│ │ │ │ │ - // Add listener
│ │ │ │ │ - this._listeners.push([sName, fHandler, bUseCapture]);
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - cXMLHttpRequest.prototype.removeEventListener = function(sName, fHandler, bUseCapture) {
│ │ │ │ │ - for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)
│ │ │ │ │ - if (oListener[0] == sName && oListener[1] == fHandler && oListener[2] == bUseCapture)
│ │ │ │ │ - break;
│ │ │ │ │ - // Remove listener
│ │ │ │ │ - if (oListener)
│ │ │ │ │ - this._listeners.splice(nIndex, 1);
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - cXMLHttpRequest.prototype.dispatchEvent = function(oEvent) {
│ │ │ │ │ - var oEventPseudo = {
│ │ │ │ │ - 'type': oEvent.type,
│ │ │ │ │ - 'target': this,
│ │ │ │ │ - 'currentTarget': this,
│ │ │ │ │ - 'eventPhase': 2,
│ │ │ │ │ - 'bubbles': oEvent.bubbles,
│ │ │ │ │ - 'cancelable': oEvent.cancelable,
│ │ │ │ │ - 'timeStamp': oEvent.timeStamp,
│ │ │ │ │ - 'stopPropagation': function() {}, // There is no flow
│ │ │ │ │ - 'preventDefault': function() {}, // There is no default action
│ │ │ │ │ - 'initEvent': function() {} // Original event object should be initialized
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - // Execute onreadystatechange
│ │ │ │ │ - if (oEventPseudo.type == "readystatechange" && this.onreadystatechange)
│ │ │ │ │ - (this.onreadystatechange.handleEvent || this.onreadystatechange).apply(this, [oEventPseudo]);
│ │ │ │ │ -
│ │ │ │ │ - // Execute listeners
│ │ │ │ │ - for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)
│ │ │ │ │ - if (oListener[0] == oEventPseudo.type && !oListener[2])
│ │ │ │ │ - (oListener[1].handleEvent || oListener[1]).apply(this, [oEventPseudo]);
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - //
│ │ │ │ │ - cXMLHttpRequest.prototype.toString = function() {
│ │ │ │ │ - return '[' + "object" + ' ' + "XMLHttpRequest" + ']';
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - cXMLHttpRequest.toString = function() {
│ │ │ │ │ - return '[' + "XMLHttpRequest" + ']';
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - // Helper function
│ │ │ │ │ - function fReadyStateChange(oRequest) {
│ │ │ │ │ - // Sniffing code
│ │ │ │ │ - if (cXMLHttpRequest.onreadystatechange)
│ │ │ │ │ - cXMLHttpRequest.onreadystatechange.apply(oRequest);
│ │ │ │ │ -
│ │ │ │ │ - // Fake event
│ │ │ │ │ - oRequest.dispatchEvent({
│ │ │ │ │ - 'type': "readystatechange",
│ │ │ │ │ - 'bubbles': false,
│ │ │ │ │ - 'cancelable': false,
│ │ │ │ │ - 'timeStamp': new Date + 0
│ │ │ │ │ - });
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - function fGetDocument(oRequest) {
│ │ │ │ │ - var oDocument = oRequest.responseXML,
│ │ │ │ │ - sResponse = oRequest.responseText;
│ │ │ │ │ - // Try parsing responseText
│ │ │ │ │ - if (bIE && sResponse && oDocument && !oDocument.documentElement && oRequest.getResponseHeader("Content-Type").match(/[^\/]+\/[^\+]+\+xml/)) {
│ │ │ │ │ - oDocument = new window.ActiveXObject("Microsoft.XMLDOM");
│ │ │ │ │ - oDocument.async = false;
│ │ │ │ │ - oDocument.validateOnParse = false;
│ │ │ │ │ - oDocument.loadXML(sResponse);
│ │ │ │ │ - }
│ │ │ │ │ - // Check if there is no error in document
│ │ │ │ │ - if (oDocument)
│ │ │ │ │ - if ((bIE && oDocument.parseError != 0) || !oDocument.documentElement || (oDocument.documentElement && oDocument.documentElement.tagName == "parsererror"))
│ │ │ │ │ - return null;
│ │ │ │ │ - return oDocument;
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - function fSynchronizeValues(oRequest) {
│ │ │ │ │ - try {
│ │ │ │ │ - oRequest.responseText = oRequest._object.responseText;
│ │ │ │ │ - } catch (e) {}
│ │ │ │ │ - try {
│ │ │ │ │ - oRequest.responseXML = fGetDocument(oRequest._object);
│ │ │ │ │ - } catch (e) {}
│ │ │ │ │ - try {
│ │ │ │ │ - oRequest.status = oRequest._object.status;
│ │ │ │ │ - } catch (e) {}
│ │ │ │ │ - try {
│ │ │ │ │ - oRequest.statusText = oRequest._object.statusText;
│ │ │ │ │ - } catch (e) {}
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - function fCleanTransport(oRequest) {
│ │ │ │ │ - // BUGFIX: IE - memory leak (on-page leak)
│ │ │ │ │ - oRequest._object.onreadystatechange = new window.Function;
│ │ │ │ │ - };
│ │ │ │ │ - /*
│ │ │ │ │ - // Queue manager
│ │ │ │ │ - var oQueuePending = {"CRITICAL":[],"HIGH":[],"NORMAL":[],"LOW":[],"LOWEST":[]},
│ │ │ │ │ - aQueueRunning = [];
│ │ │ │ │ - function fQueue_add(oRequest) {
│ │ │ │ │ - oQueuePending[oRequest.priority in oQueuePending ? oRequest.priority : "NORMAL"].push(oRequest);
│ │ │ │ │ - //
│ │ │ │ │ - setTimeout(fQueue_process);
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - function fQueue_remove(oRequest) {
│ │ │ │ │ - for (var nIndex = 0, bFound = false; nIndex < aQueueRunning.length; nIndex++)
│ │ │ │ │ - if (bFound)
│ │ │ │ │ - aQueueRunning[nIndex - 1] = aQueueRunning[nIndex];
│ │ │ │ │ - else
│ │ │ │ │ - if (aQueueRunning[nIndex] == oRequest)
│ │ │ │ │ - bFound = true;
│ │ │ │ │ - if (bFound)
│ │ │ │ │ - aQueueRunning.length--;
│ │ │ │ │ - //
│ │ │ │ │ - setTimeout(fQueue_process);
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - function fQueue_process() {
│ │ │ │ │ - if (aQueueRunning.length < 6) {
│ │ │ │ │ - for (var sPriority in oQueuePending) {
│ │ │ │ │ - if (oQueuePending[sPriority].length) {
│ │ │ │ │ - var oRequest = oQueuePending[sPriority][0];
│ │ │ │ │ - oQueuePending[sPriority] = oQueuePending[sPriority].slice(1);
│ │ │ │ │ - //
│ │ │ │ │ - aQueueRunning.push(oRequest);
│ │ │ │ │ - // Send request
│ │ │ │ │ - fXMLHttpRequest_send(oRequest);
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - };
│ │ │ │ │ - */
│ │ │ │ │ - // Internet Explorer 5.0 (missing apply)
│ │ │ │ │ - if (!window.Function.prototype.apply) {
│ │ │ │ │ - window.Function.prototype.apply = function(oRequest, oArguments) {
│ │ │ │ │ - if (!oArguments)
│ │ │ │ │ - oArguments = [];
│ │ │ │ │ - oRequest.__func = this;
│ │ │ │ │ - oRequest.__func(oArguments[0], oArguments[1], oArguments[2], oArguments[3], oArguments[4]);
│ │ │ │ │ - delete oRequest.__func;
│ │ │ │ │ - };
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - // Register new object with window
│ │ │ │ │ - /**
│ │ │ │ │ - * Class: OpenLayers.Request.XMLHttpRequest
│ │ │ │ │ - * Standard-compliant (W3C) cross-browser implementation of the
│ │ │ │ │ - * XMLHttpRequest object. From
│ │ │ │ │ - * http://code.google.com/p/xmlhttprequest/.
│ │ │ │ │ - */
│ │ │ │ │ - if (!OpenLayers.Request) {
│ │ │ │ │ - /**
│ │ │ │ │ - * This allows for OpenLayers/Request.js to be included
│ │ │ │ │ - * before or after this script.
│ │ │ │ │ - */
│ │ │ │ │ - OpenLayers.Request = {};
│ │ │ │ │ - }
│ │ │ │ │ - OpenLayers.Request.XMLHttpRequest = cXMLHttpRequest;
│ │ │ │ │ -})();
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Request.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/Events.js
│ │ │ │ │ - * @requires OpenLayers/Request/XMLHttpRequest.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * TODO: deprecate me
│ │ │ │ │ - * Use OpenLayers.Request.proxy instead.
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.ProxyHost = "";
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Namespace: OpenLayers.Request
│ │ │ │ │ - * The OpenLayers.Request namespace contains convenience methods for working
│ │ │ │ │ - * with XMLHttpRequests. These methods work with a cross-browser
│ │ │ │ │ - * W3C compliant class.
│ │ │ │ │ - */
│ │ │ │ │ -if (!OpenLayers.Request) {
│ │ │ │ │ - /**
│ │ │ │ │ - * This allows for OpenLayers/Request/XMLHttpRequest.js to be included
│ │ │ │ │ - * before or after this script.
│ │ │ │ │ - */
│ │ │ │ │ - OpenLayers.Request = {};
│ │ │ │ │ -}
│ │ │ │ │ -OpenLayers.Util.extend(OpenLayers.Request, {
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constant: DEFAULT_CONFIG
│ │ │ │ │ - * {Object} Default configuration for all requests.
│ │ │ │ │ - */
│ │ │ │ │ - DEFAULT_CONFIG: {
│ │ │ │ │ - method: "GET",
│ │ │ │ │ - url: window.location.href,
│ │ │ │ │ - async: true,
│ │ │ │ │ - user: undefined,
│ │ │ │ │ - password: undefined,
│ │ │ │ │ - params: null,
│ │ │ │ │ - proxy: OpenLayers.ProxyHost,
│ │ │ │ │ - headers: {},
│ │ │ │ │ - data: null,
│ │ │ │ │ - callback: function() {},
│ │ │ │ │ - success: null,
│ │ │ │ │ - failure: null,
│ │ │ │ │ - scope: null
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constant: URL_SPLIT_REGEX
│ │ │ │ │ - */
│ │ │ │ │ - URL_SPLIT_REGEX: /([^:]*:)\/\/([^:]*:?[^@]*@)?([^:\/\?]*):?([^\/\?]*)/,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: events
│ │ │ │ │ - * {} An events object that handles all
│ │ │ │ │ - * events on the {} object.
│ │ │ │ │ - *
│ │ │ │ │ - * All event listeners will receive an event object with three properties:
│ │ │ │ │ - * request - {} The request object.
│ │ │ │ │ - * config - {Object} The config object sent to the specific request method.
│ │ │ │ │ - * requestUrl - {String} The request url.
│ │ │ │ │ - *
│ │ │ │ │ - * Supported event types:
│ │ │ │ │ - * complete - Triggered when we have a response from the request, if a
│ │ │ │ │ - * listener returns false, no further response processing will take
│ │ │ │ │ - * place.
│ │ │ │ │ - * success - Triggered when the HTTP response has a success code (200-299).
│ │ │ │ │ - * failure - Triggered when the HTTP response does not have a success code.
│ │ │ │ │ - */
│ │ │ │ │ - events: new OpenLayers.Events(this),
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: makeSameOrigin
│ │ │ │ │ - * Using the specified proxy, returns a same origin url of the provided url.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * url - {String} An arbitrary url
│ │ │ │ │ - * proxy {String|Function} The proxy to use to make the provided url a
│ │ │ │ │ - * same origin url.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns
│ │ │ │ │ - * {String} the same origin url. If no proxy is provided, the returned url
│ │ │ │ │ - * will be the same as the provided url.
│ │ │ │ │ - */
│ │ │ │ │ - makeSameOrigin: function(url, proxy) {
│ │ │ │ │ - var sameOrigin = url.indexOf("http") !== 0;
│ │ │ │ │ - var urlParts = !sameOrigin && url.match(this.URL_SPLIT_REGEX);
│ │ │ │ │ - if (urlParts) {
│ │ │ │ │ - var location = window.location;
│ │ │ │ │ - sameOrigin =
│ │ │ │ │ - urlParts[1] == location.protocol &&
│ │ │ │ │ - urlParts[3] == location.hostname;
│ │ │ │ │ - var uPort = urlParts[4],
│ │ │ │ │ - lPort = location.port;
│ │ │ │ │ - if (uPort != 80 && uPort != "" || lPort != "80" && lPort != "") {
│ │ │ │ │ - sameOrigin = sameOrigin && uPort == lPort;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - if (!sameOrigin) {
│ │ │ │ │ - if (proxy) {
│ │ │ │ │ - if (typeof proxy == "function") {
│ │ │ │ │ - url = proxy(url);
│ │ │ │ │ - } else {
│ │ │ │ │ - url = proxy + encodeURIComponent(url);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - return url;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: issue
│ │ │ │ │ - * Create a new XMLHttpRequest object, open it, set any headers, bind
│ │ │ │ │ - * a callback to done state, and send any data. It is recommended that
│ │ │ │ │ - * you use one , , , , , or .
│ │ │ │ │ - * This method is only documented to provide detail on the configuration
│ │ │ │ │ - * options available to all request methods.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * config - {Object} Object containing properties for configuring the
│ │ │ │ │ - * request. Allowed configuration properties are described below.
│ │ │ │ │ - * This object is modified and should not be reused.
│ │ │ │ │ - *
│ │ │ │ │ - * Allowed config properties:
│ │ │ │ │ - * method - {String} One of GET, POST, PUT, DELETE, HEAD, or
│ │ │ │ │ - * OPTIONS. Default is GET.
│ │ │ │ │ - * url - {String} URL for the request.
│ │ │ │ │ - * async - {Boolean} Open an asynchronous request. Default is true.
│ │ │ │ │ - * user - {String} User for relevant authentication scheme. Set
│ │ │ │ │ - * to null to clear current user.
│ │ │ │ │ - * password - {String} Password for relevant authentication scheme.
│ │ │ │ │ - * Set to null to clear current password.
│ │ │ │ │ - * proxy - {String} Optional proxy. Defaults to
│ │ │ │ │ - * .
│ │ │ │ │ - * params - {Object} Any key:value pairs to be appended to the
│ │ │ │ │ - * url as a query string. Assumes url doesn't already include a query
│ │ │ │ │ - * string or hash. Typically, this is only appropriate for
│ │ │ │ │ - * requests where the query string will be appended to the url.
│ │ │ │ │ - * Parameter values that are arrays will be
│ │ │ │ │ - * concatenated with a comma (note that this goes against form-encoding)
│ │ │ │ │ - * as is done with .
│ │ │ │ │ - * headers - {Object} Object with header:value pairs to be set on
│ │ │ │ │ - * the request.
│ │ │ │ │ - * data - {String | Document} Optional data to send with the request.
│ │ │ │ │ - * Typically, this is only used with and requests.
│ │ │ │ │ - * Make sure to provide the appropriate "Content-Type" header for your
│ │ │ │ │ - * data. For and requests, the content type defaults to
│ │ │ │ │ - * "application-xml". If your data is a different content type, or
│ │ │ │ │ - * if you are using a different HTTP method, set the "Content-Type"
│ │ │ │ │ - * header to match your data type.
│ │ │ │ │ - * callback - {Function} Function to call when request is done.
│ │ │ │ │ - * To determine if the request failed, check request.status (200
│ │ │ │ │ - * indicates success).
│ │ │ │ │ - * success - {Function} Optional function to call if request status is in
│ │ │ │ │ - * the 200s. This will be called in addition to callback above and
│ │ │ │ │ - * would typically only be used as an alternative.
│ │ │ │ │ - * failure - {Function} Optional function to call if request status is not
│ │ │ │ │ - * in the 200s. This will be called in addition to callback above and
│ │ │ │ │ - * would typically only be used as an alternative.
│ │ │ │ │ - * scope - {Object} If callback is a public method on some object,
│ │ │ │ │ - * set the scope to that object.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {XMLHttpRequest} Request object. To abort the request before a response
│ │ │ │ │ - * is received, call abort() on the request object.
│ │ │ │ │ - */
│ │ │ │ │ - issue: function(config) {
│ │ │ │ │ - // apply default config - proxy host may have changed
│ │ │ │ │ - var defaultConfig = OpenLayers.Util.extend(
│ │ │ │ │ - this.DEFAULT_CONFIG, {
│ │ │ │ │ - proxy: OpenLayers.ProxyHost
│ │ │ │ │ - }
│ │ │ │ │ - );
│ │ │ │ │ - config = config || {};
│ │ │ │ │ - config.headers = config.headers || {};
│ │ │ │ │ - config = OpenLayers.Util.applyDefaults(config, defaultConfig);
│ │ │ │ │ - config.headers = OpenLayers.Util.applyDefaults(config.headers, defaultConfig.headers);
│ │ │ │ │ - // Always set the "X-Requested-With" header to signal that this request
│ │ │ │ │ - // was issued through the XHR-object. Since header keys are case
│ │ │ │ │ - // insensitive and we want to allow overriding of the "X-Requested-With"
│ │ │ │ │ - // header through the user we cannot use applyDefaults, but have to
│ │ │ │ │ - // check manually whether we were called with a "X-Requested-With"
│ │ │ │ │ - // header.
│ │ │ │ │ - var customRequestedWithHeader = false,
│ │ │ │ │ - headerKey;
│ │ │ │ │ - for (headerKey in config.headers) {
│ │ │ │ │ - if (config.headers.hasOwnProperty(headerKey)) {
│ │ │ │ │ - if (headerKey.toLowerCase() === 'x-requested-with') {
│ │ │ │ │ - customRequestedWithHeader = true;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - if (customRequestedWithHeader === false) {
│ │ │ │ │ - // we did not have a custom "X-Requested-With" header
│ │ │ │ │ - config.headers['X-Requested-With'] = 'XMLHttpRequest';
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // create request, open, and set headers
│ │ │ │ │ - var request = new OpenLayers.Request.XMLHttpRequest();
│ │ │ │ │ - var url = OpenLayers.Util.urlAppend(config.url,
│ │ │ │ │ - OpenLayers.Util.getParameterString(config.params || {}));
│ │ │ │ │ - url = OpenLayers.Request.makeSameOrigin(url, config.proxy);
│ │ │ │ │ - request.open(
│ │ │ │ │ - config.method, url, config.async, config.user, config.password
│ │ │ │ │ - );
│ │ │ │ │ - for (var header in config.headers) {
│ │ │ │ │ - request.setRequestHeader(header, config.headers[header]);
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - var events = this.events;
│ │ │ │ │ -
│ │ │ │ │ - // we want to execute runCallbacks with "this" as the
│ │ │ │ │ - // execution scope
│ │ │ │ │ - var self = this;
│ │ │ │ │ -
│ │ │ │ │ - request.onreadystatechange = function() {
│ │ │ │ │ - if (request.readyState == OpenLayers.Request.XMLHttpRequest.DONE) {
│ │ │ │ │ - var proceed = events.triggerEvent(
│ │ │ │ │ - "complete", {
│ │ │ │ │ - request: request,
│ │ │ │ │ - config: config,
│ │ │ │ │ - requestUrl: url
│ │ │ │ │ - }
│ │ │ │ │ - );
│ │ │ │ │ - if (proceed !== false) {
│ │ │ │ │ - self.runCallbacks({
│ │ │ │ │ - request: request,
│ │ │ │ │ - config: config,
│ │ │ │ │ - requestUrl: url
│ │ │ │ │ - });
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - };
│ │ │ │ │ -
│ │ │ │ │ - // send request (optionally with data) and return
│ │ │ │ │ - // call in a timeout for asynchronous requests so the return is
│ │ │ │ │ - // available before readyState == 4 for cached docs
│ │ │ │ │ - if (config.async === false) {
│ │ │ │ │ - request.send(config.data);
│ │ │ │ │ - } else {
│ │ │ │ │ - window.setTimeout(function() {
│ │ │ │ │ - if (request.readyState !== 0) { // W3C: 0-UNSENT
│ │ │ │ │ - request.send(config.data);
│ │ │ │ │ - }
│ │ │ │ │ - }, 0);
│ │ │ │ │ - }
│ │ │ │ │ - return request;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: runCallbacks
│ │ │ │ │ - * Calls the complete, success and failure callbacks. Application
│ │ │ │ │ - * can listen to the "complete" event, have the listener
│ │ │ │ │ - * display a confirm window and always return false, and
│ │ │ │ │ - * execute OpenLayers.Request.runCallbacks if the user
│ │ │ │ │ - * hits "yes" in the confirm window.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * options - {Object} Hash containing request, config and requestUrl keys
│ │ │ │ │ - */
│ │ │ │ │ - runCallbacks: function(options) {
│ │ │ │ │ - var request = options.request;
│ │ │ │ │ - var config = options.config;
│ │ │ │ │ -
│ │ │ │ │ - // bind callbacks to readyState 4 (done)
│ │ │ │ │ - var complete = (config.scope) ?
│ │ │ │ │ - OpenLayers.Function.bind(config.callback, config.scope) :
│ │ │ │ │ - config.callback;
│ │ │ │ │ -
│ │ │ │ │ - // optional success callback
│ │ │ │ │ - var success;
│ │ │ │ │ - if (config.success) {
│ │ │ │ │ - success = (config.scope) ?
│ │ │ │ │ - OpenLayers.Function.bind(config.success, config.scope) :
│ │ │ │ │ - config.success;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // optional failure callback
│ │ │ │ │ - var failure;
│ │ │ │ │ - if (config.failure) {
│ │ │ │ │ - failure = (config.scope) ?
│ │ │ │ │ - OpenLayers.Function.bind(config.failure, config.scope) :
│ │ │ │ │ - config.failure;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - if (OpenLayers.Util.createUrlObject(config.url).protocol == "file:" &&
│ │ │ │ │ - request.responseText) {
│ │ │ │ │ - request.status = 200;
│ │ │ │ │ - }
│ │ │ │ │ - complete(request);
│ │ │ │ │ -
│ │ │ │ │ - if (!request.status || (request.status >= 200 && request.status < 300)) {
│ │ │ │ │ - this.events.triggerEvent("success", options);
│ │ │ │ │ - if (success) {
│ │ │ │ │ - success(request);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - if (request.status && (request.status < 200 || request.status >= 300)) {
│ │ │ │ │ - this.events.triggerEvent("failure", options);
│ │ │ │ │ - if (failure) {
│ │ │ │ │ - failure(request);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: GET
│ │ │ │ │ - * Send an HTTP GET request. Additional configuration properties are
│ │ │ │ │ - * documented in the method, with the method property set
│ │ │ │ │ - * to GET.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * config - {Object} Object with properties for configuring the request.
│ │ │ │ │ - * See the method for documentation of allowed properties.
│ │ │ │ │ - * This object is modified and should not be reused.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {XMLHttpRequest} Request object.
│ │ │ │ │ - */
│ │ │ │ │ - GET: function(config) {
│ │ │ │ │ - config = OpenLayers.Util.extend(config, {
│ │ │ │ │ - method: "GET"
│ │ │ │ │ - });
│ │ │ │ │ - return OpenLayers.Request.issue(config);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: POST
│ │ │ │ │ - * Send a POST request. Additional configuration properties are
│ │ │ │ │ - * documented in the method, with the method property set
│ │ │ │ │ - * to POST and "Content-Type" header set to "application/xml".
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * config - {Object} Object with properties for configuring the request.
│ │ │ │ │ - * See the method for documentation of allowed properties. The
│ │ │ │ │ - * default "Content-Type" header will be set to "application-xml" if
│ │ │ │ │ - * none is provided. This object is modified and should not be reused.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {XMLHttpRequest} Request object.
│ │ │ │ │ - */
│ │ │ │ │ - POST: function(config) {
│ │ │ │ │ - config = OpenLayers.Util.extend(config, {
│ │ │ │ │ - method: "POST"
│ │ │ │ │ - });
│ │ │ │ │ - // set content type to application/xml if it isn't already set
│ │ │ │ │ - config.headers = config.headers ? config.headers : {};
│ │ │ │ │ - if (!("CONTENT-TYPE" in OpenLayers.Util.upperCaseObject(config.headers))) {
│ │ │ │ │ - config.headers["Content-Type"] = "application/xml";
│ │ │ │ │ - }
│ │ │ │ │ - return OpenLayers.Request.issue(config);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: PUT
│ │ │ │ │ - * Send an HTTP PUT request. Additional configuration properties are
│ │ │ │ │ - * documented in the method, with the method property set
│ │ │ │ │ - * to PUT and "Content-Type" header set to "application/xml".
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * config - {Object} Object with properties for configuring the request.
│ │ │ │ │ - * See the method for documentation of allowed properties. The
│ │ │ │ │ - * default "Content-Type" header will be set to "application-xml" if
│ │ │ │ │ - * none is provided. This object is modified and should not be reused.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {XMLHttpRequest} Request object.
│ │ │ │ │ - */
│ │ │ │ │ - PUT: function(config) {
│ │ │ │ │ - config = OpenLayers.Util.extend(config, {
│ │ │ │ │ - method: "PUT"
│ │ │ │ │ - });
│ │ │ │ │ - // set content type to application/xml if it isn't already set
│ │ │ │ │ - config.headers = config.headers ? config.headers : {};
│ │ │ │ │ - if (!("CONTENT-TYPE" in OpenLayers.Util.upperCaseObject(config.headers))) {
│ │ │ │ │ - config.headers["Content-Type"] = "application/xml";
│ │ │ │ │ - }
│ │ │ │ │ - return OpenLayers.Request.issue(config);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: DELETE
│ │ │ │ │ - * Send an HTTP DELETE request. Additional configuration properties are
│ │ │ │ │ - * documented in the method, with the method property set
│ │ │ │ │ - * to DELETE.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * config - {Object} Object with properties for configuring the request.
│ │ │ │ │ - * See the method for documentation of allowed properties.
│ │ │ │ │ - * This object is modified and should not be reused.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {XMLHttpRequest} Request object.
│ │ │ │ │ - */
│ │ │ │ │ - DELETE: function(config) {
│ │ │ │ │ - config = OpenLayers.Util.extend(config, {
│ │ │ │ │ - method: "DELETE"
│ │ │ │ │ - });
│ │ │ │ │ - return OpenLayers.Request.issue(config);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: HEAD
│ │ │ │ │ - * Send an HTTP HEAD request. Additional configuration properties are
│ │ │ │ │ - * documented in the method, with the method property set
│ │ │ │ │ - * to HEAD.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * config - {Object} Object with properties for configuring the request.
│ │ │ │ │ - * See the method for documentation of allowed properties.
│ │ │ │ │ - * This object is modified and should not be reused.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {XMLHttpRequest} Request object.
│ │ │ │ │ - */
│ │ │ │ │ - HEAD: function(config) {
│ │ │ │ │ - config = OpenLayers.Util.extend(config, {
│ │ │ │ │ - method: "HEAD"
│ │ │ │ │ - });
│ │ │ │ │ - return OpenLayers.Request.issue(config);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: OPTIONS
│ │ │ │ │ - * Send an HTTP OPTIONS request. Additional configuration properties are
│ │ │ │ │ - * documented in the method, with the method property set
│ │ │ │ │ - * to OPTIONS.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * config - {Object} Object with properties for configuring the request.
│ │ │ │ │ - * See the method for documentation of allowed properties.
│ │ │ │ │ - * This object is modified and should not be reused.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {XMLHttpRequest} Request object.
│ │ │ │ │ - */
│ │ │ │ │ - OPTIONS: function(config) {
│ │ │ │ │ - config = OpenLayers.Util.extend(config, {
│ │ │ │ │ - method: "OPTIONS"
│ │ │ │ │ - });
│ │ │ │ │ - return OpenLayers.Request.issue(config);
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ -});
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Geometry.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/BaseTypes/Class.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Class: OpenLayers.Geometry
│ │ │ │ │ - * A Geometry is a description of a geographic object. Create an instance of
│ │ │ │ │ - * this class with the constructor. This is a base class,
│ │ │ │ │ - * typical geometry types are described by subclasses of this class.
│ │ │ │ │ - *
│ │ │ │ │ - * Note that if you use the method, you must
│ │ │ │ │ - * explicitly include the OpenLayers.Format.WKT in your build.
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Geometry = OpenLayers.Class({
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: id
│ │ │ │ │ - * {String} A unique identifier for this geometry.
│ │ │ │ │ - */
│ │ │ │ │ - id: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: parent
│ │ │ │ │ - * {}This is set when a Geometry is added as component
│ │ │ │ │ - * of another geometry
│ │ │ │ │ - */
│ │ │ │ │ - parent: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: bounds
│ │ │ │ │ - * {} The bounds of this geometry
│ │ │ │ │ - */
│ │ │ │ │ - bounds: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constructor: OpenLayers.Geometry
│ │ │ │ │ - * Creates a geometry object.
│ │ │ │ │ - */
│ │ │ │ │ - initialize: function() {
│ │ │ │ │ - this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: destroy
│ │ │ │ │ - * Destroy this geometry.
│ │ │ │ │ - */
│ │ │ │ │ - destroy: function() {
│ │ │ │ │ - this.id = null;
│ │ │ │ │ - this.bounds = null;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: clone
│ │ │ │ │ - * Create a clone of this geometry. Does not set any non-standard
│ │ │ │ │ - * properties of the cloned geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {} An exact clone of this geometry.
│ │ │ │ │ - */
│ │ │ │ │ - clone: function() {
│ │ │ │ │ - return new OpenLayers.Geometry();
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: setBounds
│ │ │ │ │ - * Set the bounds for this Geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * bounds - {}
│ │ │ │ │ - */
│ │ │ │ │ - setBounds: function(bounds) {
│ │ │ │ │ - if (bounds) {
│ │ │ │ │ - this.bounds = bounds.clone();
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: clearBounds
│ │ │ │ │ - * Nullify this components bounds and that of its parent as well.
│ │ │ │ │ - */
│ │ │ │ │ - clearBounds: function() {
│ │ │ │ │ - this.bounds = null;
│ │ │ │ │ - if (this.parent) {
│ │ │ │ │ - this.parent.clearBounds();
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: extendBounds
│ │ │ │ │ - * Extend the existing bounds to include the new bounds.
│ │ │ │ │ - * If geometry's bounds is not yet set, then set a new Bounds.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * newBounds - {}
│ │ │ │ │ - */
│ │ │ │ │ - extendBounds: function(newBounds) {
│ │ │ │ │ - var bounds = this.getBounds();
│ │ │ │ │ - if (!bounds) {
│ │ │ │ │ - this.setBounds(newBounds);
│ │ │ │ │ - } else {
│ │ │ │ │ - this.bounds.extend(newBounds);
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: getBounds
│ │ │ │ │ - * Get the bounds for this Geometry. If bounds is not set, it
│ │ │ │ │ - * is calculated again, this makes queries faster.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {}
│ │ │ │ │ - */
│ │ │ │ │ - getBounds: function() {
│ │ │ │ │ - if (this.bounds == null) {
│ │ │ │ │ - this.calculateBounds();
│ │ │ │ │ - }
│ │ │ │ │ - return this.bounds;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: calculateBounds
│ │ │ │ │ - * Recalculate the bounds for the geometry.
│ │ │ │ │ - */
│ │ │ │ │ - calculateBounds: function() {
│ │ │ │ │ - //
│ │ │ │ │ - // This should be overridden by subclasses.
│ │ │ │ │ - //
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: distanceTo
│ │ │ │ │ - * Calculate the closest distance between two geometries (on the x-y plane).
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * geometry - {} The target geometry.
│ │ │ │ │ - * options - {Object} Optional properties for configuring the distance
│ │ │ │ │ - * calculation.
│ │ │ │ │ - *
│ │ │ │ │ - * Valid options depend on the specific geometry type.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Number | Object} The distance between this geometry and the target.
│ │ │ │ │ - * If details is true, the return will be an object with distance,
│ │ │ │ │ - * x0, y0, x1, and x2 properties. The x0 and y0 properties represent
│ │ │ │ │ - * the coordinates of the closest point on this geometry. The x1 and y1
│ │ │ │ │ - * properties represent the coordinates of the closest point on the
│ │ │ │ │ - * target geometry.
│ │ │ │ │ - */
│ │ │ │ │ - distanceTo: function(geometry, options) {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: getVertices
│ │ │ │ │ - * Return a list of all points in this geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * nodes - {Boolean} For lines, only return vertices that are
│ │ │ │ │ - * endpoints. If false, for lines, only vertices that are not
│ │ │ │ │ - * endpoints will be returned. If not provided, all vertices will
│ │ │ │ │ - * be returned.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Array} A list of all vertices in the geometry.
│ │ │ │ │ - */
│ │ │ │ │ - getVertices: function(nodes) {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: atPoint
│ │ │ │ │ - * Note - This is only an approximation based on the bounds of the
│ │ │ │ │ - * geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * lonlat - {|Object} OpenLayers.LonLat or an
│ │ │ │ │ - * object with a 'lon' and 'lat' properties.
│ │ │ │ │ - * toleranceLon - {float} Optional tolerance in Geometric Coords
│ │ │ │ │ - * toleranceLat - {float} Optional tolerance in Geographic Coords
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} Whether or not the geometry is at the specified location
│ │ │ │ │ - */
│ │ │ │ │ - atPoint: function(lonlat, toleranceLon, toleranceLat) {
│ │ │ │ │ - var atPoint = false;
│ │ │ │ │ - var bounds = this.getBounds();
│ │ │ │ │ - if ((bounds != null) && (lonlat != null)) {
│ │ │ │ │ -
│ │ │ │ │ - var dX = (toleranceLon != null) ? toleranceLon : 0;
│ │ │ │ │ - var dY = (toleranceLat != null) ? toleranceLat : 0;
│ │ │ │ │ -
│ │ │ │ │ - var toleranceBounds =
│ │ │ │ │ - new OpenLayers.Bounds(this.bounds.left - dX,
│ │ │ │ │ - this.bounds.bottom - dY,
│ │ │ │ │ - this.bounds.right + dX,
│ │ │ │ │ - this.bounds.top + dY);
│ │ │ │ │ -
│ │ │ │ │ - atPoint = toleranceBounds.containsLonLat(lonlat);
│ │ │ │ │ - }
│ │ │ │ │ - return atPoint;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: getLength
│ │ │ │ │ - * Calculate the length of this geometry. This method is defined in
│ │ │ │ │ - * subclasses.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Float} The length of the collection by summing its parts
│ │ │ │ │ - */
│ │ │ │ │ - getLength: function() {
│ │ │ │ │ - //to be overridden by geometries that actually have a length
│ │ │ │ │ - //
│ │ │ │ │ - return 0.0;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: getArea
│ │ │ │ │ - * Calculate the area of this geometry. This method is defined in subclasses.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Float} The area of the collection by summing its parts
│ │ │ │ │ - */
│ │ │ │ │ - getArea: function() {
│ │ │ │ │ - //to be overridden by geometries that actually have an area
│ │ │ │ │ - //
│ │ │ │ │ - return 0.0;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: getCentroid
│ │ │ │ │ - * Calculate the centroid of this geometry. This method is defined in subclasses.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {} The centroid of the collection
│ │ │ │ │ - */
│ │ │ │ │ - getCentroid: function() {
│ │ │ │ │ - return null;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: toString
│ │ │ │ │ - * Returns a text representation of the geometry. If the WKT format is
│ │ │ │ │ - * included in a build, this will be the Well-Known Text
│ │ │ │ │ - * representation.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {String} String representation of this geometry.
│ │ │ │ │ - */
│ │ │ │ │ - toString: function() {
│ │ │ │ │ - var string;
│ │ │ │ │ - if (OpenLayers.Format && OpenLayers.Format.WKT) {
│ │ │ │ │ - string = OpenLayers.Format.WKT.prototype.write(
│ │ │ │ │ - new OpenLayers.Feature.Vector(this)
│ │ │ │ │ - );
│ │ │ │ │ - } else {
│ │ │ │ │ - string = Object.prototype.toString.call(this);
│ │ │ │ │ - }
│ │ │ │ │ - return string;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Geometry"
│ │ │ │ │ -});
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Function: OpenLayers.Geometry.fromWKT
│ │ │ │ │ - * Generate a geometry given a Well-Known Text string. For this method to
│ │ │ │ │ - * work, you must include the OpenLayers.Format.WKT in your build
│ │ │ │ │ - * explicitly.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * wkt - {String} A string representing the geometry in Well-Known Text.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {} A geometry of the appropriate class.
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Geometry.fromWKT = function(wkt) {
│ │ │ │ │ - var geom;
│ │ │ │ │ - if (OpenLayers.Format && OpenLayers.Format.WKT) {
│ │ │ │ │ - var format = OpenLayers.Geometry.fromWKT.format;
│ │ │ │ │ - if (!format) {
│ │ │ │ │ - format = new OpenLayers.Format.WKT();
│ │ │ │ │ - OpenLayers.Geometry.fromWKT.format = format;
│ │ │ │ │ - }
│ │ │ │ │ - var result = format.read(wkt);
│ │ │ │ │ - if (result instanceof OpenLayers.Feature.Vector) {
│ │ │ │ │ - geom = result.geometry;
│ │ │ │ │ - } else if (OpenLayers.Util.isArray(result)) {
│ │ │ │ │ - var len = result.length;
│ │ │ │ │ - var components = new Array(len);
│ │ │ │ │ - for (var i = 0; i < len; ++i) {
│ │ │ │ │ - components[i] = result[i].geometry;
│ │ │ │ │ - }
│ │ │ │ │ - geom = new OpenLayers.Geometry.Collection(components);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - return geom;
│ │ │ │ │ -};
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Method: OpenLayers.Geometry.segmentsIntersect
│ │ │ │ │ - * Determine whether two line segments intersect. Optionally calculates
│ │ │ │ │ - * and returns the intersection point. This function is optimized for
│ │ │ │ │ - * cases where seg1.x2 >= seg2.x1 || seg2.x2 >= seg1.x1. In those
│ │ │ │ │ - * obvious cases where there is no intersection, the function should
│ │ │ │ │ - * not be called.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * seg1 - {Object} Object representing a segment with properties x1, y1, x2,
│ │ │ │ │ - * and y2. The start point is represented by x1 and y1. The end point
│ │ │ │ │ - * is represented by x2 and y2. Start and end are ordered so that x1 < x2.
│ │ │ │ │ - * seg2 - {Object} Object representing a segment with properties x1, y1, x2,
│ │ │ │ │ - * and y2. The start point is represented by x1 and y1. The end point
│ │ │ │ │ - * is represented by x2 and y2. Start and end are ordered so that x1 < x2.
│ │ │ │ │ - * options - {Object} Optional properties for calculating the intersection.
│ │ │ │ │ - *
│ │ │ │ │ - * Valid options:
│ │ │ │ │ - * point - {Boolean} Return the intersection point. If false, the actual
│ │ │ │ │ - * intersection point will not be calculated. If true and the segments
│ │ │ │ │ - * intersect, the intersection point will be returned. If true and
│ │ │ │ │ - * the segments do not intersect, false will be returned. If true and
│ │ │ │ │ - * the segments are coincident, true will be returned.
│ │ │ │ │ - * tolerance - {Number} If a non-null value is provided, if the segments are
│ │ │ │ │ - * within the tolerance distance, this will be considered an intersection.
│ │ │ │ │ - * In addition, if the point option is true and the calculated intersection
│ │ │ │ │ - * is within the tolerance distance of an end point, the endpoint will be
│ │ │ │ │ - * returned instead of the calculated intersection. Further, if the
│ │ │ │ │ - * intersection is within the tolerance of endpoints on both segments, or
│ │ │ │ │ - * if two segment endpoints are within the tolerance distance of eachother
│ │ │ │ │ - * (but no intersection is otherwise calculated), an endpoint on the
│ │ │ │ │ - * first segment provided will be returned.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean | } The two segments intersect.
│ │ │ │ │ - * If the point argument is true, the return will be the intersection
│ │ │ │ │ - * point or false if none exists. If point is true and the segments
│ │ │ │ │ - * are coincident, return will be true (and the instersection is equal
│ │ │ │ │ - * to the shorter segment).
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Geometry.segmentsIntersect = function(seg1, seg2, options) {
│ │ │ │ │ - var point = options && options.point;
│ │ │ │ │ - var tolerance = options && options.tolerance;
│ │ │ │ │ - var intersection = false;
│ │ │ │ │ - var x11_21 = seg1.x1 - seg2.x1;
│ │ │ │ │ - var y11_21 = seg1.y1 - seg2.y1;
│ │ │ │ │ - var x12_11 = seg1.x2 - seg1.x1;
│ │ │ │ │ - var y12_11 = seg1.y2 - seg1.y1;
│ │ │ │ │ - var y22_21 = seg2.y2 - seg2.y1;
│ │ │ │ │ - var x22_21 = seg2.x2 - seg2.x1;
│ │ │ │ │ - var d = (y22_21 * x12_11) - (x22_21 * y12_11);
│ │ │ │ │ - var n1 = (x22_21 * y11_21) - (y22_21 * x11_21);
│ │ │ │ │ - var n2 = (x12_11 * y11_21) - (y12_11 * x11_21);
│ │ │ │ │ - if (d == 0) {
│ │ │ │ │ - // parallel
│ │ │ │ │ - if (n1 == 0 && n2 == 0) {
│ │ │ │ │ - // coincident
│ │ │ │ │ - intersection = true;
│ │ │ │ │ - }
│ │ │ │ │ - } else {
│ │ │ │ │ - var along1 = n1 / d;
│ │ │ │ │ - var along2 = n2 / d;
│ │ │ │ │ - if (along1 >= 0 && along1 <= 1 && along2 >= 0 && along2 <= 1) {
│ │ │ │ │ - // intersect
│ │ │ │ │ - if (!point) {
│ │ │ │ │ - intersection = true;
│ │ │ │ │ - } else {
│ │ │ │ │ - // calculate the intersection point
│ │ │ │ │ - var x = seg1.x1 + (along1 * x12_11);
│ │ │ │ │ - var y = seg1.y1 + (along1 * y12_11);
│ │ │ │ │ - intersection = new OpenLayers.Geometry.Point(x, y);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - if (tolerance) {
│ │ │ │ │ - var dist;
│ │ │ │ │ - if (intersection) {
│ │ │ │ │ - if (point) {
│ │ │ │ │ - var segs = [seg1, seg2];
│ │ │ │ │ - var seg, x, y;
│ │ │ │ │ - // check segment endpoints for proximity to intersection
│ │ │ │ │ - // set intersection to first endpoint within the tolerance
│ │ │ │ │ - outer: for (var i = 0; i < 2; ++i) {
│ │ │ │ │ - seg = segs[i];
│ │ │ │ │ - for (var j = 1; j < 3; ++j) {
│ │ │ │ │ - x = seg["x" + j];
│ │ │ │ │ - y = seg["y" + j];
│ │ │ │ │ - dist = Math.sqrt(
│ │ │ │ │ - Math.pow(x - intersection.x, 2) +
│ │ │ │ │ - Math.pow(y - intersection.y, 2)
│ │ │ │ │ - );
│ │ │ │ │ - if (dist < tolerance) {
│ │ │ │ │ - intersection.x = x;
│ │ │ │ │ - intersection.y = y;
│ │ │ │ │ - break outer;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - }
│ │ │ │ │ - } else {
│ │ │ │ │ - // no calculated intersection, but segments could be within
│ │ │ │ │ - // the tolerance of one another
│ │ │ │ │ - var segs = [seg1, seg2];
│ │ │ │ │ - var source, target, x, y, p, result;
│ │ │ │ │ - // check segment endpoints for proximity to intersection
│ │ │ │ │ - // set intersection to first endpoint within the tolerance
│ │ │ │ │ - outer: for (var i = 0; i < 2; ++i) {
│ │ │ │ │ - source = segs[i];
│ │ │ │ │ - target = segs[(i + 1) % 2];
│ │ │ │ │ - for (var j = 1; j < 3; ++j) {
│ │ │ │ │ - p = {
│ │ │ │ │ - x: source["x" + j],
│ │ │ │ │ - y: source["y" + j]
│ │ │ │ │ - };
│ │ │ │ │ - result = OpenLayers.Geometry.distanceToSegment(p, target);
│ │ │ │ │ - if (result.distance < tolerance) {
│ │ │ │ │ - if (point) {
│ │ │ │ │ - intersection = new OpenLayers.Geometry.Point(p.x, p.y);
│ │ │ │ │ - } else {
│ │ │ │ │ - intersection = true;
│ │ │ │ │ - }
│ │ │ │ │ - break outer;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - return intersection;
│ │ │ │ │ -};
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Function: OpenLayers.Geometry.distanceToSegment
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * point - {Object} An object with x and y properties representing the
│ │ │ │ │ - * point coordinates.
│ │ │ │ │ - * segment - {Object} An object with x1, y1, x2, and y2 properties
│ │ │ │ │ - * representing endpoint coordinates.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Object} An object with distance, along, x, and y properties. The distance
│ │ │ │ │ - * will be the shortest distance between the input point and segment.
│ │ │ │ │ - * The x and y properties represent the coordinates along the segment
│ │ │ │ │ - * where the shortest distance meets the segment. The along attribute
│ │ │ │ │ - * describes how far between the two segment points the given point is.
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Geometry.distanceToSegment = function(point, segment) {
│ │ │ │ │ - var result = OpenLayers.Geometry.distanceSquaredToSegment(point, segment);
│ │ │ │ │ - result.distance = Math.sqrt(result.distance);
│ │ │ │ │ - return result;
│ │ │ │ │ -};
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Function: OpenLayers.Geometry.distanceSquaredToSegment
│ │ │ │ │ - *
│ │ │ │ │ - * Usually the distanceToSegment function should be used. This variant however
│ │ │ │ │ - * can be used for comparisons where the exact distance is not important.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * point - {Object} An object with x and y properties representing the
│ │ │ │ │ - * point coordinates.
│ │ │ │ │ - * segment - {Object} An object with x1, y1, x2, and y2 properties
│ │ │ │ │ - * representing endpoint coordinates.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Object} An object with squared distance, along, x, and y properties.
│ │ │ │ │ - * The distance will be the shortest distance between the input point and
│ │ │ │ │ - * segment. The x and y properties represent the coordinates along the
│ │ │ │ │ - * segment where the shortest distance meets the segment. The along
│ │ │ │ │ - * attribute describes how far between the two segment points the given
│ │ │ │ │ - * point is.
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Geometry.distanceSquaredToSegment = function(point, segment) {
│ │ │ │ │ - var x0 = point.x;
│ │ │ │ │ - var y0 = point.y;
│ │ │ │ │ - var x1 = segment.x1;
│ │ │ │ │ - var y1 = segment.y1;
│ │ │ │ │ - var x2 = segment.x2;
│ │ │ │ │ - var y2 = segment.y2;
│ │ │ │ │ - var dx = x2 - x1;
│ │ │ │ │ - var dy = y2 - y1;
│ │ │ │ │ - var along = ((dx * (x0 - x1)) + (dy * (y0 - y1))) /
│ │ │ │ │ - (Math.pow(dx, 2) + Math.pow(dy, 2));
│ │ │ │ │ - var x, y;
│ │ │ │ │ - if (along <= 0.0) {
│ │ │ │ │ - x = x1;
│ │ │ │ │ - y = y1;
│ │ │ │ │ - } else if (along >= 1.0) {
│ │ │ │ │ - x = x2;
│ │ │ │ │ - y = y2;
│ │ │ │ │ - } else {
│ │ │ │ │ - x = x1 + along * dx;
│ │ │ │ │ - y = y1 + along * dy;
│ │ │ │ │ - }
│ │ │ │ │ - return {
│ │ │ │ │ - distance: Math.pow(x - x0, 2) + Math.pow(y - y0, 2),
│ │ │ │ │ - x: x,
│ │ │ │ │ - y: y,
│ │ │ │ │ - along: along
│ │ │ │ │ - };
│ │ │ │ │ -};
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Format.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/BaseTypes/Class.js
│ │ │ │ │ - * @requires OpenLayers/Util.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Class: OpenLayers.Format
│ │ │ │ │ - * Base class for format reading/writing a variety of formats. Subclasses
│ │ │ │ │ - * of OpenLayers.Format are expected to have read and write methods.
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Format = OpenLayers.Class({
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: options
│ │ │ │ │ - * {Object} A reference to options passed to the constructor.
│ │ │ │ │ - */
│ │ │ │ │ - options: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: externalProjection
│ │ │ │ │ - * {} When passed a externalProjection and
│ │ │ │ │ - * internalProjection, the format will reproject the geometries it
│ │ │ │ │ - * reads or writes. The externalProjection is the projection used by
│ │ │ │ │ - * the content which is passed into read or which comes out of write.
│ │ │ │ │ - * In order to reproject, a projection transformation function for the
│ │ │ │ │ - * specified projections must be available. This support may be
│ │ │ │ │ - * provided via proj4js or via a custom transformation function. See
│ │ │ │ │ - * {} for more information on
│ │ │ │ │ - * custom transformations.
│ │ │ │ │ - */
│ │ │ │ │ - externalProjection: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: internalProjection
│ │ │ │ │ - * {} When passed a externalProjection and
│ │ │ │ │ - * internalProjection, the format will reproject the geometries it
│ │ │ │ │ - * reads or writes. The internalProjection is the projection used by
│ │ │ │ │ - * the geometries which are returned by read or which are passed into
│ │ │ │ │ - * write. In order to reproject, a projection transformation function
│ │ │ │ │ - * for the specified projections must be available. This support may be
│ │ │ │ │ - * provided via proj4js or via a custom transformation function. See
│ │ │ │ │ - * {} for more information on
│ │ │ │ │ - * custom transformations.
│ │ │ │ │ - */
│ │ │ │ │ - internalProjection: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: data
│ │ │ │ │ - * {Object} When is true, this is the parsed string sent to
│ │ │ │ │ - * .
│ │ │ │ │ - */
│ │ │ │ │ - data: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: keepData
│ │ │ │ │ - * {Object} Maintain a reference () to the most recently read data.
│ │ │ │ │ - * Default is false.
│ │ │ │ │ - */
│ │ │ │ │ - keepData: false,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constructor: OpenLayers.Format
│ │ │ │ │ - * Instances of this class are not useful. See one of the subclasses.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * options - {Object} An optional object with properties to set on the
│ │ │ │ │ - * format
│ │ │ │ │ - *
│ │ │ │ │ - * Valid options:
│ │ │ │ │ - * keepData - {Boolean} If true, upon , the data property will be
│ │ │ │ │ - * set to the parsed object (e.g. the json or xml object).
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * An instance of OpenLayers.Format
│ │ │ │ │ - */
│ │ │ │ │ - initialize: function(options) {
│ │ │ │ │ - OpenLayers.Util.extend(this, options);
│ │ │ │ │ - this.options = options;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: destroy
│ │ │ │ │ - * Clean up.
│ │ │ │ │ - */
│ │ │ │ │ - destroy: function() {},
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: read
│ │ │ │ │ - * Read data from a string, and return an object whose type depends on the
│ │ │ │ │ - * subclass.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * data - {string} Data to read/parse.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * Depends on the subclass
│ │ │ │ │ - */
│ │ │ │ │ - read: function(data) {
│ │ │ │ │ - throw new Error('Read not implemented.');
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: write
│ │ │ │ │ - * Accept an object, and return a string.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * object - {Object} Object to be serialized
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {String} A string representation of the object.
│ │ │ │ │ - */
│ │ │ │ │ - write: function(object) {
│ │ │ │ │ - throw new Error('Write not implemented.');
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Format"
│ │ │ │ │ -});
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Geometry/Point.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/Geometry.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Class: OpenLayers.Geometry.Point
│ │ │ │ │ - * Point geometry class.
│ │ │ │ │ - *
│ │ │ │ │ - * Inherits from:
│ │ │ │ │ - * -
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Geometry.Point = OpenLayers.Class(OpenLayers.Geometry, {
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: x
│ │ │ │ │ - * {float}
│ │ │ │ │ - */
│ │ │ │ │ - x: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: y
│ │ │ │ │ - * {float}
│ │ │ │ │ - */
│ │ │ │ │ - y: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constructor: OpenLayers.Geometry.Point
│ │ │ │ │ - * Construct a point geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * x - {float}
│ │ │ │ │ - * y - {float}
│ │ │ │ │ - *
│ │ │ │ │ - */
│ │ │ │ │ - initialize: function(x, y) {
│ │ │ │ │ - OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
│ │ │ │ │ -
│ │ │ │ │ - this.x = parseFloat(x);
│ │ │ │ │ - this.y = parseFloat(y);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: clone
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {} An exact clone of this OpenLayers.Geometry.Point
│ │ │ │ │ - */
│ │ │ │ │ - clone: function(obj) {
│ │ │ │ │ - if (obj == null) {
│ │ │ │ │ - obj = new OpenLayers.Geometry.Point(this.x, this.y);
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // catch any randomly tagged-on properties
│ │ │ │ │ - OpenLayers.Util.applyDefaults(obj, this);
│ │ │ │ │ -
│ │ │ │ │ - return obj;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: calculateBounds
│ │ │ │ │ - * Create a new Bounds based on the lon/lat
│ │ │ │ │ - */
│ │ │ │ │ - calculateBounds: function() {
│ │ │ │ │ - this.bounds = new OpenLayers.Bounds(this.x, this.y,
│ │ │ │ │ - this.x, this.y);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: distanceTo
│ │ │ │ │ - * Calculate the closest distance between two geometries (on the x-y plane).
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * geometry - {} The target geometry.
│ │ │ │ │ - * options - {Object} Optional properties for configuring the distance
│ │ │ │ │ - * calculation.
│ │ │ │ │ - *
│ │ │ │ │ - * Valid options:
│ │ │ │ │ - * details - {Boolean} Return details from the distance calculation.
│ │ │ │ │ - * Default is false.
│ │ │ │ │ - * edge - {Boolean} Calculate the distance from this geometry to the
│ │ │ │ │ - * nearest edge of the target geometry. Default is true. If true,
│ │ │ │ │ - * calling distanceTo from a geometry that is wholly contained within
│ │ │ │ │ - * the target will result in a non-zero distance. If false, whenever
│ │ │ │ │ - * geometries intersect, calling distanceTo will return 0. If false,
│ │ │ │ │ - * details cannot be returned.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Number | Object} The distance between this geometry and the target.
│ │ │ │ │ - * If details is true, the return will be an object with distance,
│ │ │ │ │ - * x0, y0, x1, and x2 properties. The x0 and y0 properties represent
│ │ │ │ │ - * the coordinates of the closest point on this geometry. The x1 and y1
│ │ │ │ │ - * properties represent the coordinates of the closest point on the
│ │ │ │ │ - * target geometry.
│ │ │ │ │ - */
│ │ │ │ │ - distanceTo: function(geometry, options) {
│ │ │ │ │ - var edge = !(options && options.edge === false);
│ │ │ │ │ - var details = edge && options && options.details;
│ │ │ │ │ - var distance, x0, y0, x1, y1, result;
│ │ │ │ │ - if (geometry instanceof OpenLayers.Geometry.Point) {
│ │ │ │ │ - x0 = this.x;
│ │ │ │ │ - y0 = this.y;
│ │ │ │ │ - x1 = geometry.x;
│ │ │ │ │ - y1 = geometry.y;
│ │ │ │ │ - distance = Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));
│ │ │ │ │ - result = !details ?
│ │ │ │ │ - distance : {
│ │ │ │ │ - x0: x0,
│ │ │ │ │ - y0: y0,
│ │ │ │ │ - x1: x1,
│ │ │ │ │ - y1: y1,
│ │ │ │ │ - distance: distance
│ │ │ │ │ - };
│ │ │ │ │ - } else {
│ │ │ │ │ - result = geometry.distanceTo(this, options);
│ │ │ │ │ - if (details) {
│ │ │ │ │ - // switch coord order since this geom is target
│ │ │ │ │ - result = {
│ │ │ │ │ - x0: result.x1,
│ │ │ │ │ - y0: result.y1,
│ │ │ │ │ - x1: result.x0,
│ │ │ │ │ - y1: result.y0,
│ │ │ │ │ - distance: result.distance
│ │ │ │ │ - };
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - return result;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: equals
│ │ │ │ │ - * Determine whether another geometry is equivalent to this one. Geometries
│ │ │ │ │ - * are considered equivalent if all components have the same coordinates.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * geom - {} The geometry to test.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} The supplied geometry is equivalent to this geometry.
│ │ │ │ │ - */
│ │ │ │ │ - equals: function(geom) {
│ │ │ │ │ - var equals = false;
│ │ │ │ │ - if (geom != null) {
│ │ │ │ │ - equals = ((this.x == geom.x && this.y == geom.y) ||
│ │ │ │ │ - (isNaN(this.x) && isNaN(this.y) && isNaN(geom.x) && isNaN(geom.y)));
│ │ │ │ │ - }
│ │ │ │ │ - return equals;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: toShortString
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {String} Shortened String representation of Point object.
│ │ │ │ │ - * (ex. "5, 42")
│ │ │ │ │ - */
│ │ │ │ │ - toShortString: function() {
│ │ │ │ │ - return (this.x + ", " + this.y);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: move
│ │ │ │ │ - * Moves a geometry by the given displacement along positive x and y axes.
│ │ │ │ │ - * This modifies the position of the geometry and clears the cached
│ │ │ │ │ - * bounds.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * x - {Float} Distance to move geometry in positive x direction.
│ │ │ │ │ - * y - {Float} Distance to move geometry in positive y direction.
│ │ │ │ │ - */
│ │ │ │ │ - move: function(x, y) {
│ │ │ │ │ - this.x = this.x + x;
│ │ │ │ │ - this.y = this.y + y;
│ │ │ │ │ - this.clearBounds();
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: rotate
│ │ │ │ │ - * Rotate a point around another.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * angle - {Float} Rotation angle in degrees (measured counterclockwise
│ │ │ │ │ - * from the positive x-axis)
│ │ │ │ │ - * origin - {} Center point for the rotation
│ │ │ │ │ - */
│ │ │ │ │ - rotate: function(angle, origin) {
│ │ │ │ │ - angle *= Math.PI / 180;
│ │ │ │ │ - var radius = this.distanceTo(origin);
│ │ │ │ │ - var theta = angle + Math.atan2(this.y - origin.y, this.x - origin.x);
│ │ │ │ │ - this.x = origin.x + (radius * Math.cos(theta));
│ │ │ │ │ - this.y = origin.y + (radius * Math.sin(theta));
│ │ │ │ │ - this.clearBounds();
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: getCentroid
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {} The centroid of the collection
│ │ │ │ │ - */
│ │ │ │ │ - getCentroid: function() {
│ │ │ │ │ - return new OpenLayers.Geometry.Point(this.x, this.y);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: resize
│ │ │ │ │ - * Resize a point relative to some origin. For points, this has the effect
│ │ │ │ │ - * of scaling a vector (from the origin to the point). This method is
│ │ │ │ │ - * more useful on geometry collection subclasses.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * scale - {Float} Ratio of the new distance from the origin to the old
│ │ │ │ │ - * distance from the origin. A scale of 2 doubles the
│ │ │ │ │ - * distance between the point and origin.
│ │ │ │ │ - * origin - {} Point of origin for resizing
│ │ │ │ │ - * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {} - The current geometry.
│ │ │ │ │ - */
│ │ │ │ │ - resize: function(scale, origin, ratio) {
│ │ │ │ │ - ratio = (ratio == undefined) ? 1 : ratio;
│ │ │ │ │ - this.x = origin.x + (scale * ratio * (this.x - origin.x));
│ │ │ │ │ - this.y = origin.y + (scale * (this.y - origin.y));
│ │ │ │ │ - this.clearBounds();
│ │ │ │ │ - return this;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: intersects
│ │ │ │ │ - * Determine if the input geometry intersects this one.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * geometry - {} Any type of geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} The input geometry intersects this one.
│ │ │ │ │ - */
│ │ │ │ │ - intersects: function(geometry) {
│ │ │ │ │ - var intersect = false;
│ │ │ │ │ - if (geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
│ │ │ │ │ - intersect = this.equals(geometry);
│ │ │ │ │ - } else {
│ │ │ │ │ - intersect = geometry.intersects(this);
│ │ │ │ │ - }
│ │ │ │ │ - return intersect;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: transform
│ │ │ │ │ - * Translate the x,y properties of the point from source to dest.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * source - {}
│ │ │ │ │ - * dest - {}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {}
│ │ │ │ │ - */
│ │ │ │ │ - transform: function(source, dest) {
│ │ │ │ │ - if ((source && dest)) {
│ │ │ │ │ - OpenLayers.Projection.transform(
│ │ │ │ │ - this, source, dest);
│ │ │ │ │ - this.bounds = null;
│ │ │ │ │ - }
│ │ │ │ │ - return this;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: getVertices
│ │ │ │ │ - * Return a list of all points in this geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * nodes - {Boolean} For lines, only return vertices that are
│ │ │ │ │ - * endpoints. If false, for lines, only vertices that are not
│ │ │ │ │ - * endpoints will be returned. If not provided, all vertices will
│ │ │ │ │ - * be returned.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Array} A list of all vertices in the geometry.
│ │ │ │ │ - */
│ │ │ │ │ - getVertices: function(nodes) {
│ │ │ │ │ - return [this];
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Geometry.Point"
│ │ │ │ │ -});
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Geometry/Collection.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/Geometry.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Class: OpenLayers.Geometry.Collection
│ │ │ │ │ - * A Collection is exactly what it sounds like: A collection of different
│ │ │ │ │ - * Geometries. These are stored in the local parameter (which
│ │ │ │ │ - * can be passed as a parameter to the constructor).
│ │ │ │ │ - *
│ │ │ │ │ - * As new geometries are added to the collection, they are NOT cloned.
│ │ │ │ │ - * When removing geometries, they need to be specified by reference (ie you
│ │ │ │ │ - * have to pass in the *exact* geometry to be removed).
│ │ │ │ │ - *
│ │ │ │ │ - * The and functions here merely iterate through
│ │ │ │ │ - * the components, summing their respective areas and lengths.
│ │ │ │ │ - *
│ │ │ │ │ - * Create a new instance with the constructor.
│ │ │ │ │ - *
│ │ │ │ │ - * Inherits from:
│ │ │ │ │ - * -
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIProperty: components
│ │ │ │ │ - * {Array()} The component parts of this geometry
│ │ │ │ │ - */
│ │ │ │ │ - components: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: componentTypes
│ │ │ │ │ - * {Array(String)} An array of class names representing the types of
│ │ │ │ │ - * components that the collection can include. A null value means the
│ │ │ │ │ - * component types are not restricted.
│ │ │ │ │ - */
│ │ │ │ │ - componentTypes: null,
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constructor: OpenLayers.Geometry.Collection
│ │ │ │ │ - * Creates a Geometry Collection -- a list of geoms.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * components - {Array()} Optional array of geometries
│ │ │ │ │ - *
│ │ │ │ │ - */
│ │ │ │ │ - initialize: function(components) {
│ │ │ │ │ - OpenLayers.Geometry.prototype.initialize.apply(this, arguments);
│ │ │ │ │ - this.components = [];
│ │ │ │ │ - if (components != null) {
│ │ │ │ │ - this.addComponents(components);
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: destroy
│ │ │ │ │ - * Destroy this geometry.
│ │ │ │ │ - */
│ │ │ │ │ - destroy: function() {
│ │ │ │ │ - this.components.length = 0;
│ │ │ │ │ - this.components = null;
│ │ │ │ │ - OpenLayers.Geometry.prototype.destroy.apply(this, arguments);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: clone
│ │ │ │ │ - * Clone this geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {} An exact clone of this collection
│ │ │ │ │ - */
│ │ │ │ │ - clone: function() {
│ │ │ │ │ - var geometry = eval("new " + this.CLASS_NAME + "()");
│ │ │ │ │ - for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ - geometry.addComponent(this.components[i].clone());
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - // catch any randomly tagged-on properties
│ │ │ │ │ - OpenLayers.Util.applyDefaults(geometry, this);
│ │ │ │ │ -
│ │ │ │ │ - return geometry;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: getComponentsString
│ │ │ │ │ - * Get a string representing the components for this collection
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {String} A string representation of the components of this geometry
│ │ │ │ │ - */
│ │ │ │ │ - getComponentsString: function() {
│ │ │ │ │ - var strings = [];
│ │ │ │ │ - for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ - strings.push(this.components[i].toShortString());
│ │ │ │ │ - }
│ │ │ │ │ - return strings.join(",");
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: calculateBounds
│ │ │ │ │ - * Recalculate the bounds by iterating through the components and
│ │ │ │ │ - * calling calling extendBounds() on each item.
│ │ │ │ │ - */
│ │ │ │ │ - calculateBounds: function() {
│ │ │ │ │ - this.bounds = null;
│ │ │ │ │ - var bounds = new OpenLayers.Bounds();
│ │ │ │ │ - var components = this.components;
│ │ │ │ │ - if (components) {
│ │ │ │ │ - for (var i = 0, len = components.length; i < len; i++) {
│ │ │ │ │ - bounds.extend(components[i].getBounds());
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - // to preserve old behavior, we only set bounds if non-null
│ │ │ │ │ - // in the future, we could add bounds.isEmpty()
│ │ │ │ │ - if (bounds.left != null && bounds.bottom != null &&
│ │ │ │ │ - bounds.right != null && bounds.top != null) {
│ │ │ │ │ - this.setBounds(bounds);
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: addComponents
│ │ │ │ │ - * Add components to this geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * components - {Array()} An array of geometries to add
│ │ │ │ │ - */
│ │ │ │ │ - addComponents: function(components) {
│ │ │ │ │ - if (!(OpenLayers.Util.isArray(components))) {
│ │ │ │ │ - components = [components];
│ │ │ │ │ - }
│ │ │ │ │ - for (var i = 0, len = components.length; i < len; i++) {
│ │ │ │ │ - this.addComponent(components[i]);
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: addComponent
│ │ │ │ │ - * Add a new component (geometry) to the collection. If this.componentTypes
│ │ │ │ │ - * is set, then the component class name must be in the componentTypes array.
│ │ │ │ │ - *
│ │ │ │ │ - * The bounds cache is reset.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * component - {} A geometry to add
│ │ │ │ │ - * index - {int} Optional index into the array to insert the component
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} The component geometry was successfully added
│ │ │ │ │ - */
│ │ │ │ │ - addComponent: function(component, index) {
│ │ │ │ │ - var added = false;
│ │ │ │ │ - if (component) {
│ │ │ │ │ - if (this.componentTypes == null ||
│ │ │ │ │ - (OpenLayers.Util.indexOf(this.componentTypes,
│ │ │ │ │ - component.CLASS_NAME) > -1)) {
│ │ │ │ │ -
│ │ │ │ │ - if (index != null && (index < this.components.length)) {
│ │ │ │ │ - var components1 = this.components.slice(0, index);
│ │ │ │ │ - var components2 = this.components.slice(index,
│ │ │ │ │ - this.components.length);
│ │ │ │ │ - components1.push(component);
│ │ │ │ │ - this.components = components1.concat(components2);
│ │ │ │ │ - } else {
│ │ │ │ │ - this.components.push(component);
│ │ │ │ │ - }
│ │ │ │ │ - component.parent = this;
│ │ │ │ │ - this.clearBounds();
│ │ │ │ │ - added = true;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - return added;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: removeComponents
│ │ │ │ │ - * Remove components from this geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * components - {Array()} The components to be removed
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} A component was removed.
│ │ │ │ │ - */
│ │ │ │ │ - removeComponents: function(components) {
│ │ │ │ │ - var removed = false;
│ │ │ │ │ -
│ │ │ │ │ - if (!(OpenLayers.Util.isArray(components))) {
│ │ │ │ │ - components = [components];
│ │ │ │ │ - }
│ │ │ │ │ - for (var i = components.length - 1; i >= 0; --i) {
│ │ │ │ │ - removed = this.removeComponent(components[i]) || removed;
│ │ │ │ │ - }
│ │ │ │ │ - return removed;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: removeComponent
│ │ │ │ │ - * Remove a component from this geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * component - {}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} The component was removed.
│ │ │ │ │ - */
│ │ │ │ │ - removeComponent: function(component) {
│ │ │ │ │ -
│ │ │ │ │ - OpenLayers.Util.removeItem(this.components, component);
│ │ │ │ │ -
│ │ │ │ │ - // clearBounds() so that it gets recalculated on the next call
│ │ │ │ │ - // to this.getBounds();
│ │ │ │ │ - this.clearBounds();
│ │ │ │ │ - return true;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: getLength
│ │ │ │ │ - * Calculate the length of this geometry
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Float} The length of the geometry
│ │ │ │ │ - */
│ │ │ │ │ - getLength: function() {
│ │ │ │ │ - var length = 0.0;
│ │ │ │ │ - for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ - length += this.components[i].getLength();
│ │ │ │ │ - }
│ │ │ │ │ - return length;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: getArea
│ │ │ │ │ - * Calculate the area of this geometry. Note how this function is overridden
│ │ │ │ │ - * in .
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Float} The area of the collection by summing its parts
│ │ │ │ │ - */
│ │ │ │ │ - getArea: function() {
│ │ │ │ │ - var area = 0.0;
│ │ │ │ │ - for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ - area += this.components[i].getArea();
│ │ │ │ │ - }
│ │ │ │ │ - return area;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: getGeodesicArea
│ │ │ │ │ - * Calculate the approximate area of the polygon were it projected onto
│ │ │ │ │ - * the earth.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * projection - {} The spatial reference system
│ │ │ │ │ - * for the geometry coordinates. If not provided, Geographic/WGS84 is
│ │ │ │ │ - * assumed.
│ │ │ │ │ - *
│ │ │ │ │ - * Reference:
│ │ │ │ │ - * Robert. G. Chamberlain and William H. Duquette, "Some Algorithms for
│ │ │ │ │ - * Polygons on a Sphere", JPL Publication 07-03, Jet Propulsion
│ │ │ │ │ - * Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {float} The approximate geodesic area of the geometry in square meters.
│ │ │ │ │ - */
│ │ │ │ │ - getGeodesicArea: function(projection) {
│ │ │ │ │ - var area = 0.0;
│ │ │ │ │ - for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ - area += this.components[i].getGeodesicArea(projection);
│ │ │ │ │ - }
│ │ │ │ │ - return area;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: getCentroid
│ │ │ │ │ - *
│ │ │ │ │ - * Compute the centroid for this geometry collection.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * weighted - {Boolean} Perform the getCentroid computation recursively,
│ │ │ │ │ - * returning an area weighted average of all geometries in this collection.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {} The centroid of the collection
│ │ │ │ │ - */
│ │ │ │ │ - getCentroid: function(weighted) {
│ │ │ │ │ - if (!weighted) {
│ │ │ │ │ - return this.components.length && this.components[0].getCentroid();
│ │ │ │ │ - }
│ │ │ │ │ - var len = this.components.length;
│ │ │ │ │ - if (!len) {
│ │ │ │ │ - return false;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - var areas = [];
│ │ │ │ │ - var centroids = [];
│ │ │ │ │ - var areaSum = 0;
│ │ │ │ │ - var minArea = Number.MAX_VALUE;
│ │ │ │ │ - var component;
│ │ │ │ │ - for (var i = 0; i < len; ++i) {
│ │ │ │ │ - component = this.components[i];
│ │ │ │ │ - var area = component.getArea();
│ │ │ │ │ - var centroid = component.getCentroid(true);
│ │ │ │ │ - if (isNaN(area) || isNaN(centroid.x) || isNaN(centroid.y)) {
│ │ │ │ │ - continue;
│ │ │ │ │ - }
│ │ │ │ │ - areas.push(area);
│ │ │ │ │ - areaSum += area;
│ │ │ │ │ - minArea = (area < minArea && area > 0) ? area : minArea;
│ │ │ │ │ - centroids.push(centroid);
│ │ │ │ │ - }
│ │ │ │ │ - len = areas.length;
│ │ │ │ │ - if (areaSum === 0) {
│ │ │ │ │ - // all the components in this collection have 0 area
│ │ │ │ │ - // probably a collection of points -- weight all the points the same
│ │ │ │ │ - for (var i = 0; i < len; ++i) {
│ │ │ │ │ - areas[i] = 1;
│ │ │ │ │ - }
│ │ │ │ │ - areaSum = areas.length;
│ │ │ │ │ - } else {
│ │ │ │ │ - // normalize all the areas where the smallest area will get
│ │ │ │ │ - // a value of 1
│ │ │ │ │ - for (var i = 0; i < len; ++i) {
│ │ │ │ │ - areas[i] /= minArea;
│ │ │ │ │ - }
│ │ │ │ │ - areaSum /= minArea;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - var xSum = 0,
│ │ │ │ │ - ySum = 0,
│ │ │ │ │ - centroid, area;
│ │ │ │ │ - for (var i = 0; i < len; ++i) {
│ │ │ │ │ - centroid = centroids[i];
│ │ │ │ │ - area = areas[i];
│ │ │ │ │ - xSum += centroid.x * area;
│ │ │ │ │ - ySum += centroid.y * area;
│ │ │ │ │ - }
│ │ │ │ │ -
│ │ │ │ │ - return new OpenLayers.Geometry.Point(xSum / areaSum, ySum / areaSum);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: getGeodesicLength
│ │ │ │ │ - * Calculate the approximate length of the geometry were it projected onto
│ │ │ │ │ - * the earth.
│ │ │ │ │ - *
│ │ │ │ │ - * projection - {} The spatial reference system
│ │ │ │ │ - * for the geometry coordinates. If not provided, Geographic/WGS84 is
│ │ │ │ │ - * assumed.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Float} The appoximate geodesic length of the geometry in meters.
│ │ │ │ │ - */
│ │ │ │ │ - getGeodesicLength: function(projection) {
│ │ │ │ │ - var length = 0.0;
│ │ │ │ │ - for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ - length += this.components[i].getGeodesicLength(projection);
│ │ │ │ │ - }
│ │ │ │ │ - return length;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: move
│ │ │ │ │ - * Moves a geometry by the given displacement along positive x and y axes.
│ │ │ │ │ - * This modifies the position of the geometry and clears the cached
│ │ │ │ │ - * bounds.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * x - {Float} Distance to move geometry in positive x direction.
│ │ │ │ │ - * y - {Float} Distance to move geometry in positive y direction.
│ │ │ │ │ - */
│ │ │ │ │ - move: function(x, y) {
│ │ │ │ │ - for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ - this.components[i].move(x, y);
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: rotate
│ │ │ │ │ - * Rotate a geometry around some origin
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * angle - {Float} Rotation angle in degrees (measured counterclockwise
│ │ │ │ │ - * from the positive x-axis)
│ │ │ │ │ - * origin - {} Center point for the rotation
│ │ │ │ │ - */
│ │ │ │ │ - rotate: function(angle, origin) {
│ │ │ │ │ - for (var i = 0, len = this.components.length; i < len; ++i) {
│ │ │ │ │ - this.components[i].rotate(angle, origin);
│ │ │ │ │ - }
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: resize
│ │ │ │ │ - * Resize a geometry relative to some origin. Use this method to apply
│ │ │ │ │ - * a uniform scaling to a geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * scale - {Float} Factor by which to scale the geometry. A scale of 2
│ │ │ │ │ - * doubles the size of the geometry in each dimension
│ │ │ │ │ - * (lines, for example, will be twice as long, and polygons
│ │ │ │ │ - * will have four times the area).
│ │ │ │ │ - * origin - {} Point of origin for resizing
│ │ │ │ │ - * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {} - The current geometry.
│ │ │ │ │ - */
│ │ │ │ │ - resize: function(scale, origin, ratio) {
│ │ │ │ │ - for (var i = 0; i < this.components.length; ++i) {
│ │ │ │ │ - this.components[i].resize(scale, origin, ratio);
│ │ │ │ │ - }
│ │ │ │ │ - return this;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: distanceTo
│ │ │ │ │ - * Calculate the closest distance between two geometries (on the x-y plane).
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * geometry - {} The target geometry.
│ │ │ │ │ - * options - {Object} Optional properties for configuring the distance
│ │ │ │ │ - * calculation.
│ │ │ │ │ - *
│ │ │ │ │ - * Valid options:
│ │ │ │ │ - * details - {Boolean} Return details from the distance calculation.
│ │ │ │ │ - * Default is false.
│ │ │ │ │ - * edge - {Boolean} Calculate the distance from this geometry to the
│ │ │ │ │ - * nearest edge of the target geometry. Default is true. If true,
│ │ │ │ │ - * calling distanceTo from a geometry that is wholly contained within
│ │ │ │ │ - * the target will result in a non-zero distance. If false, whenever
│ │ │ │ │ - * geometries intersect, calling distanceTo will return 0. If false,
│ │ │ │ │ - * details cannot be returned.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Number | Object} The distance between this geometry and the target.
│ │ │ │ │ - * If details is true, the return will be an object with distance,
│ │ │ │ │ - * x0, y0, x1, and y1 properties. The x0 and y0 properties represent
│ │ │ │ │ - * the coordinates of the closest point on this geometry. The x1 and y1
│ │ │ │ │ - * properties represent the coordinates of the closest point on the
│ │ │ │ │ - * target geometry.
│ │ │ │ │ - */
│ │ │ │ │ - distanceTo: function(geometry, options) {
│ │ │ │ │ - var edge = !(options && options.edge === false);
│ │ │ │ │ - var details = edge && options && options.details;
│ │ │ │ │ - var result, best, distance;
│ │ │ │ │ - var min = Number.POSITIVE_INFINITY;
│ │ │ │ │ - for (var i = 0, len = this.components.length; i < len; ++i) {
│ │ │ │ │ - result = this.components[i].distanceTo(geometry, options);
│ │ │ │ │ - distance = details ? result.distance : result;
│ │ │ │ │ - if (distance < min) {
│ │ │ │ │ - min = distance;
│ │ │ │ │ - best = result;
│ │ │ │ │ - if (min == 0) {
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - return best;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: equals
│ │ │ │ │ - * Determine whether another geometry is equivalent to this one. Geometries
│ │ │ │ │ - * are considered equivalent if all components have the same coordinates.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * geometry - {} The geometry to test.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} The supplied geometry is equivalent to this geometry.
│ │ │ │ │ - */
│ │ │ │ │ - equals: function(geometry) {
│ │ │ │ │ - var equivalent = true;
│ │ │ │ │ - if (!geometry || !geometry.CLASS_NAME ||
│ │ │ │ │ - (this.CLASS_NAME != geometry.CLASS_NAME)) {
│ │ │ │ │ - equivalent = false;
│ │ │ │ │ - } else if (!(OpenLayers.Util.isArray(geometry.components)) ||
│ │ │ │ │ - (geometry.components.length != this.components.length)) {
│ │ │ │ │ - equivalent = false;
│ │ │ │ │ - } else {
│ │ │ │ │ - for (var i = 0, len = this.components.length; i < len; ++i) {
│ │ │ │ │ - if (!this.components[i].equals(geometry.components[i])) {
│ │ │ │ │ - equivalent = false;
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - return equivalent;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: transform
│ │ │ │ │ - * Reproject the components geometry from source to dest.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * source - {}
│ │ │ │ │ - * dest - {}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {}
│ │ │ │ │ - */
│ │ │ │ │ - transform: function(source, dest) {
│ │ │ │ │ - if (source && dest) {
│ │ │ │ │ - for (var i = 0, len = this.components.length; i < len; i++) {
│ │ │ │ │ - var component = this.components[i];
│ │ │ │ │ - component.transform(source, dest);
│ │ │ │ │ - }
│ │ │ │ │ - this.bounds = null;
│ │ │ │ │ - }
│ │ │ │ │ - return this;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: intersects
│ │ │ │ │ - * Determine if the input geometry intersects this one.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * geometry - {} Any type of geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} The input geometry intersects this one.
│ │ │ │ │ - */
│ │ │ │ │ - intersects: function(geometry) {
│ │ │ │ │ - var intersect = false;
│ │ │ │ │ - for (var i = 0, len = this.components.length; i < len; ++i) {
│ │ │ │ │ - intersect = geometry.intersects(this.components[i]);
│ │ │ │ │ - if (intersect) {
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - return intersect;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: getVertices
│ │ │ │ │ - * Return a list of all points in this geometry.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * nodes - {Boolean} For lines, only return vertices that are
│ │ │ │ │ - * endpoints. If false, for lines, only vertices that are not
│ │ │ │ │ - * endpoints will be returned. If not provided, all vertices will
│ │ │ │ │ - * be returned.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Array} A list of all vertices in the geometry.
│ │ │ │ │ - */
│ │ │ │ │ - getVertices: function(nodes) {
│ │ │ │ │ - var vertices = [];
│ │ │ │ │ - for (var i = 0, len = this.components.length; i < len; ++i) {
│ │ │ │ │ - Array.prototype.push.apply(
│ │ │ │ │ - vertices, this.components[i].getVertices(nodes)
│ │ │ │ │ - );
│ │ │ │ │ - }
│ │ │ │ │ - return vertices;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ -
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Geometry.Collection"
│ │ │ │ │ -});
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Geometry/MultiPoint.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/Geometry/Collection.js
│ │ │ │ │ - * @requires OpenLayers/Geometry/Point.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Class: OpenLayers.Geometry.MultiPoint
│ │ │ │ │ - * MultiPoint is a collection of Points. Create a new instance with the
│ │ │ │ │ - * constructor.
│ │ │ │ │ - *
│ │ │ │ │ - * Inherits from:
│ │ │ │ │ - * -
│ │ │ │ │ - * -
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Geometry.MultiPoint = OpenLayers.Class(
│ │ │ │ │ - OpenLayers.Geometry.Collection, {
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: componentTypes
│ │ │ │ │ - * {Array(String)} An array of class names representing the types of
│ │ │ │ │ - * components that the collection can include. A null value means the
│ │ │ │ │ - * component types are not restricted.
│ │ │ │ │ - */
│ │ │ │ │ - componentTypes: ["OpenLayers.Geometry.Point"],
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constructor: OpenLayers.Geometry.MultiPoint
│ │ │ │ │ - * Create a new MultiPoint Geometry
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * components - {Array()}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {}
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: addPoint
│ │ │ │ │ - * Wrapper for
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * point - {} Point to be added
│ │ │ │ │ - * index - {Integer} Optional index
│ │ │ │ │ - */
│ │ │ │ │ - addPoint: function(point, index) {
│ │ │ │ │ - this.addComponent(point, index);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: removePoint
│ │ │ │ │ - * Wrapper for
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * point - {} Point to be removed
│ │ │ │ │ - */
│ │ │ │ │ - removePoint: function(point) {
│ │ │ │ │ - this.removeComponent(point);
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Geometry.MultiPoint"
│ │ │ │ │ - });
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Geometry/Curve.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/Geometry/MultiPoint.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Class: OpenLayers.Geometry.Curve
│ │ │ │ │ - * A Curve is a MultiPoint, whose points are assumed to be connected. To
│ │ │ │ │ - * this end, we provide a "getLength()" function, which iterates through
│ │ │ │ │ - * the points, summing the distances between them.
│ │ │ │ │ - *
│ │ │ │ │ - * Inherits:
│ │ │ │ │ - * -
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Geometry.Curve = OpenLayers.Class(OpenLayers.Geometry.MultiPoint, {
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Property: componentTypes
│ │ │ │ │ - * {Array(String)} An array of class names representing the types of
│ │ │ │ │ - * components that the collection can include. A null
│ │ │ │ │ - * value means the component types are not restricted.
│ │ │ │ │ - */
│ │ │ │ │ - componentTypes: ["OpenLayers.Geometry.Point"],
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constructor: OpenLayers.Geometry.Curve
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * point - {Array()}
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: getLength
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Float} The length of the curve
│ │ │ │ │ - */
│ │ │ │ │ - getLength: function() {
│ │ │ │ │ - var length = 0.0;
│ │ │ │ │ - if (this.components && (this.components.length > 1)) {
│ │ │ │ │ - for (var i = 1, len = this.components.length; i < len; i++) {
│ │ │ │ │ - length += this.components[i - 1].distanceTo(this.components[i]);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - return length;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: getGeodesicLength
│ │ │ │ │ - * Calculate the approximate length of the geometry were it projected onto
│ │ │ │ │ - * the earth.
│ │ │ │ │ - *
│ │ │ │ │ - * projection - {} The spatial reference system
│ │ │ │ │ - * for the geometry coordinates. If not provided, Geographic/WGS84 is
│ │ │ │ │ - * assumed.
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Float} The appoximate geodesic length of the geometry in meters.
│ │ │ │ │ - */
│ │ │ │ │ - getGeodesicLength: function(projection) {
│ │ │ │ │ - var geom = this; // so we can work with a clone if needed
│ │ │ │ │ - if (projection) {
│ │ │ │ │ - var gg = new OpenLayers.Projection("EPSG:4326");
│ │ │ │ │ - if (!gg.equals(projection)) {
│ │ │ │ │ - geom = this.clone().transform(projection, gg);
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - var length = 0.0;
│ │ │ │ │ - if (geom.components && (geom.components.length > 1)) {
│ │ │ │ │ - var p1, p2;
│ │ │ │ │ - for (var i = 1, len = geom.components.length; i < len; i++) {
│ │ │ │ │ - p1 = geom.components[i - 1];
│ │ │ │ │ - p2 = geom.components[i];
│ │ │ │ │ - // this returns km and requires lon/lat properties
│ │ │ │ │ - length += OpenLayers.Util.distVincenty({
│ │ │ │ │ - lon: p1.x,
│ │ │ │ │ - lat: p1.y
│ │ │ │ │ - }, {
│ │ │ │ │ - lon: p2.x,
│ │ │ │ │ - lat: p2.y
│ │ │ │ │ - });
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - // convert to m
│ │ │ │ │ - return length * 1000;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - CLASS_NAME: "OpenLayers.Geometry.Curve"
│ │ │ │ │ -});
│ │ │ │ │ -/* ======================================================================
│ │ │ │ │ - OpenLayers/Geometry/LineString.js
│ │ │ │ │ - ====================================================================== */
│ │ │ │ │ -
│ │ │ │ │ -/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ - * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ - * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ - * full text of the license. */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * @requires OpenLayers/Geometry/Curve.js
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ -/**
│ │ │ │ │ - * Class: OpenLayers.Geometry.LineString
│ │ │ │ │ - * A LineString is a Curve which, once two points have been added to it, can
│ │ │ │ │ - * never be less than two points long.
│ │ │ │ │ - *
│ │ │ │ │ - * Inherits from:
│ │ │ │ │ - * -
│ │ │ │ │ - */
│ │ │ │ │ -OpenLayers.Geometry.LineString = OpenLayers.Class(OpenLayers.Geometry.Curve, {
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Constructor: OpenLayers.Geometry.LineString
│ │ │ │ │ - * Create a new LineString geometry
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * points - {Array()} An array of points used to
│ │ │ │ │ - * generate the linestring
│ │ │ │ │ - *
│ │ │ │ │ - */
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: removeComponent
│ │ │ │ │ - * Only allows removal of a point if there are three or more points in
│ │ │ │ │ - * the linestring. (otherwise the result would be just a single point)
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * point - {} The point to be removed
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} The component was removed.
│ │ │ │ │ - */
│ │ │ │ │ - removeComponent: function(point) {
│ │ │ │ │ - var removed = this.components && (this.components.length > 2);
│ │ │ │ │ - if (removed) {
│ │ │ │ │ - OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,
│ │ │ │ │ - arguments);
│ │ │ │ │ - }
│ │ │ │ │ - return removed;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * APIMethod: intersects
│ │ │ │ │ - * Test for instersection between two geometries. This is a cheapo
│ │ │ │ │ - * implementation of the Bently-Ottmann algorigithm. It doesn't
│ │ │ │ │ - * really keep track of a sweep line data structure. It is closer
│ │ │ │ │ - * to the brute force method, except that segments are sorted and
│ │ │ │ │ - * potential intersections are only calculated when bounding boxes
│ │ │ │ │ - * intersect.
│ │ │ │ │ - *
│ │ │ │ │ - * Parameters:
│ │ │ │ │ - * geometry - {}
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Boolean} The input geometry intersects this geometry.
│ │ │ │ │ - */
│ │ │ │ │ - intersects: function(geometry) {
│ │ │ │ │ - var intersect = false;
│ │ │ │ │ - var type = geometry.CLASS_NAME;
│ │ │ │ │ - if (type == "OpenLayers.Geometry.LineString" ||
│ │ │ │ │ - type == "OpenLayers.Geometry.LinearRing" ||
│ │ │ │ │ - type == "OpenLayers.Geometry.Point") {
│ │ │ │ │ - var segs1 = this.getSortedSegments();
│ │ │ │ │ - var segs2;
│ │ │ │ │ - if (type == "OpenLayers.Geometry.Point") {
│ │ │ │ │ - segs2 = [{
│ │ │ │ │ - x1: geometry.x,
│ │ │ │ │ - y1: geometry.y,
│ │ │ │ │ - x2: geometry.x,
│ │ │ │ │ - y2: geometry.y
│ │ │ │ │ - }];
│ │ │ │ │ - } else {
│ │ │ │ │ - segs2 = geometry.getSortedSegments();
│ │ │ │ │ - }
│ │ │ │ │ - var seg1, seg1x1, seg1x2, seg1y1, seg1y2,
│ │ │ │ │ - seg2, seg2y1, seg2y2;
│ │ │ │ │ - // sweep right
│ │ │ │ │ - outer: for (var i = 0, len = segs1.length; i < len; ++i) {
│ │ │ │ │ - seg1 = segs1[i];
│ │ │ │ │ - seg1x1 = seg1.x1;
│ │ │ │ │ - seg1x2 = seg1.x2;
│ │ │ │ │ - seg1y1 = seg1.y1;
│ │ │ │ │ - seg1y2 = seg1.y2;
│ │ │ │ │ - inner: for (var j = 0, jlen = segs2.length; j < jlen; ++j) {
│ │ │ │ │ - seg2 = segs2[j];
│ │ │ │ │ - if (seg2.x1 > seg1x2) {
│ │ │ │ │ - // seg1 still left of seg2
│ │ │ │ │ - break;
│ │ │ │ │ - }
│ │ │ │ │ - if (seg2.x2 < seg1x1) {
│ │ │ │ │ - // seg2 still left of seg1
│ │ │ │ │ - continue;
│ │ │ │ │ - }
│ │ │ │ │ - seg2y1 = seg2.y1;
│ │ │ │ │ - seg2y2 = seg2.y2;
│ │ │ │ │ - if (Math.min(seg2y1, seg2y2) > Math.max(seg1y1, seg1y2)) {
│ │ │ │ │ - // seg2 above seg1
│ │ │ │ │ - continue;
│ │ │ │ │ - }
│ │ │ │ │ - if (Math.max(seg2y1, seg2y2) < Math.min(seg1y1, seg1y2)) {
│ │ │ │ │ - // seg2 below seg1
│ │ │ │ │ - continue;
│ │ │ │ │ - }
│ │ │ │ │ - if (OpenLayers.Geometry.segmentsIntersect(seg1, seg2)) {
│ │ │ │ │ - intersect = true;
│ │ │ │ │ - break outer;
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - } else {
│ │ │ │ │ - intersect = geometry.intersects(this);
│ │ │ │ │ - }
│ │ │ │ │ - return intersect;
│ │ │ │ │ - },
│ │ │ │ │ -
│ │ │ │ │ - /**
│ │ │ │ │ - * Method: getSortedSegments
│ │ │ │ │ - *
│ │ │ │ │ - * Returns:
│ │ │ │ │ - * {Array} An array of segment objects. Segment objects have properties
│ │ │ │ │ - * x1, y1, x2, and y2. The start point is represented by x1 and y1.
│ │ │ │ │ - * The end point is represented by x2 and y2. Start and end are
│ │ │ │ │ - * ordered so that x1 < x2.
│ │ │ │ │ - */
│ │ │ │ │ - getSortedSegments: function() {
│ │ │ │ │ - var numSeg = this.components.length - 1;
│ │ │ │ │ - var segments = new Array(numSeg),
│ │ │ │ │ - point1, point2;
│ │ │ │ │ - for (var i = 0; i < numSeg; ++i) {
│ │ │ │ │ - point1 = this.components[i];
│ │ │ │ │ - point2 = this.components[i + 1];
│ │ │ │ │ - if (point1.x < point2.x) {
│ │ │ │ │ - segments[i] = {
│ │ │ │ │ - x1: point1.x,
│ │ │ │ │ - y1: point1.y,
│ │ │ │ │ - x2: point2.x,
│ │ │ │ │ - y2: point2.y
│ │ │ │ │ - };
│ │ │ │ │ - } else {
│ │ │ │ │ - segments[i] = {
│ │ │ │ │ - x1: point2.x,
│ │ │ │ │ - y1: point2.y,
│ │ │ │ │ - x2: point1.x,
│ │ │ │ │ - y2: point1.y
│ │ │ │ │ - };
│ │ │ │ │ - }
│ │ │ │ │ - }
│ │ │ │ │ - // more efficient to define this somewhere static
│ │ │ │ │ - function byX1(seg1, seg2) {
│ │ │ │ │ - return seg1.x1 - seg2.x1;
│ │ │ │ │ - }
│ │ │ │ │ - return segments.sort(byX1);
│ │ │ │ │ + getSortedSegments: function() {
│ │ │ │ │ + var numSeg = this.components.length - 1;
│ │ │ │ │ + var segments = new Array(numSeg),
│ │ │ │ │ + point1, point2;
│ │ │ │ │ + for (var i = 0; i < numSeg; ++i) {
│ │ │ │ │ + point1 = this.components[i];
│ │ │ │ │ + point2 = this.components[i + 1];
│ │ │ │ │ + if (point1.x < point2.x) {
│ │ │ │ │ + segments[i] = {
│ │ │ │ │ + x1: point1.x,
│ │ │ │ │ + y1: point1.y,
│ │ │ │ │ + x2: point2.x,
│ │ │ │ │ + y2: point2.y
│ │ │ │ │ + };
│ │ │ │ │ + } else {
│ │ │ │ │ + segments[i] = {
│ │ │ │ │ + x1: point2.x,
│ │ │ │ │ + y1: point2.y,
│ │ │ │ │ + x2: point1.x,
│ │ │ │ │ + y2: point1.y
│ │ │ │ │ + };
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + // more efficient to define this somewhere static
│ │ │ │ │ + function byX1(seg1, seg2) {
│ │ │ │ │ + return seg1.x1 - seg2.x1;
│ │ │ │ │ + }
│ │ │ │ │ + return segments.sort(byX1);
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ /**
│ │ │ │ │ * Method: splitWithSegment
│ │ │ │ │ * Split this geometry with the given segment.
│ │ │ │ │ *
│ │ │ │ │ * Parameters:
│ │ │ │ │ @@ -15781,14 +12700,467 @@
│ │ │ │ │ * Constant: OpenLayers.Format.WFST.DEFAULTS
│ │ │ │ │ * {Object} Default properties for the WFST format.
│ │ │ │ │ */
│ │ │ │ │ OpenLayers.Format.WFST.DEFAULTS = {
│ │ │ │ │ "version": "1.0.0"
│ │ │ │ │ };
│ │ │ │ │ /* ======================================================================
│ │ │ │ │ + OpenLayers/Style.js
│ │ │ │ │ + ====================================================================== */
│ │ │ │ │ +
│ │ │ │ │ +/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ + * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ + * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ + * full text of the license. */
│ │ │ │ │ +
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * @requires OpenLayers/BaseTypes/Class.js
│ │ │ │ │ + * @requires OpenLayers/Util.js
│ │ │ │ │ + * @requires OpenLayers/Feature/Vector.js
│ │ │ │ │ + */
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Class: OpenLayers.Style
│ │ │ │ │ + * This class represents a UserStyle obtained
│ │ │ │ │ + * from a SLD, containing styling rules.
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Style = OpenLayers.Class({
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: id
│ │ │ │ │ + * {String} A unique id for this session.
│ │ │ │ │ + */
│ │ │ │ │ + id: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIProperty: name
│ │ │ │ │ + * {String}
│ │ │ │ │ + */
│ │ │ │ │ + name: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: title
│ │ │ │ │ + * {String} Title of this style (set if included in SLD)
│ │ │ │ │ + */
│ │ │ │ │ + title: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: description
│ │ │ │ │ + * {String} Description of this style (set if abstract is included in SLD)
│ │ │ │ │ + */
│ │ │ │ │ + description: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIProperty: layerName
│ │ │ │ │ + * {} name of the layer that this style belongs to, usually
│ │ │ │ │ + * according to the NamedLayer attribute of an SLD document.
│ │ │ │ │ + */
│ │ │ │ │ + layerName: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIProperty: isDefault
│ │ │ │ │ + * {Boolean}
│ │ │ │ │ + */
│ │ │ │ │ + isDefault: false,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: rules
│ │ │ │ │ + * {Array()}
│ │ │ │ │ + */
│ │ │ │ │ + rules: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIProperty: context
│ │ │ │ │ + * {Object} An optional object with properties that symbolizers' property
│ │ │ │ │ + * values should be evaluated against. If no context is specified,
│ │ │ │ │ + * feature.attributes will be used
│ │ │ │ │ + */
│ │ │ │ │ + context: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: defaultStyle
│ │ │ │ │ + * {Object} hash of style properties to use as default for merging
│ │ │ │ │ + * rule-based style symbolizers onto. If no rules are defined,
│ │ │ │ │ + * createSymbolizer will return this style. If is set to
│ │ │ │ │ + * true, the defaultStyle will only be taken into account if there are
│ │ │ │ │ + * rules defined.
│ │ │ │ │ + */
│ │ │ │ │ + defaultStyle: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: defaultsPerSymbolizer
│ │ │ │ │ + * {Boolean} If set to true, the will extend the symbolizer
│ │ │ │ │ + * of every rule. Properties of the will also be used to set
│ │ │ │ │ + * missing symbolizer properties if the symbolizer has stroke, fill or
│ │ │ │ │ + * graphic set to true. Default is false.
│ │ │ │ │ + */
│ │ │ │ │ + defaultsPerSymbolizer: false,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: propertyStyles
│ │ │ │ │ + * {Hash of Boolean} cache of style properties that need to be parsed for
│ │ │ │ │ + * propertyNames. Property names are keys, values won't be used.
│ │ │ │ │ + */
│ │ │ │ │ + propertyStyles: null,
│ │ │ │ │ +
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constructor: OpenLayers.Style
│ │ │ │ │ + * Creates a UserStyle.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * style - {Object} Optional hash of style properties that will be
│ │ │ │ │ + * used as default style for this style object. This style
│ │ │ │ │ + * applies if no rules are specified. Symbolizers defined in
│ │ │ │ │ + * rules will extend this default style.
│ │ │ │ │ + * options - {Object} An optional object with properties to set on the
│ │ │ │ │ + * style.
│ │ │ │ │ + *
│ │ │ │ │ + * Valid options:
│ │ │ │ │ + * rules - {Array()} List of rules to be added to the
│ │ │ │ │ + * style.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {}
│ │ │ │ │ + */
│ │ │ │ │ + initialize: function(style, options) {
│ │ │ │ │ +
│ │ │ │ │ + OpenLayers.Util.extend(this, options);
│ │ │ │ │ + this.rules = [];
│ │ │ │ │ + if (options && options.rules) {
│ │ │ │ │ + this.addRules(options.rules);
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + // use the default style from OpenLayers.Feature.Vector if no style
│ │ │ │ │ + // was given in the constructor
│ │ │ │ │ + this.setDefaultStyle(style ||
│ │ │ │ │ + OpenLayers.Feature.Vector.style["default"]);
│ │ │ │ │ +
│ │ │ │ │ + this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: destroy
│ │ │ │ │ + * nullify references to prevent circular references and memory leaks
│ │ │ │ │ + */
│ │ │ │ │ + destroy: function() {
│ │ │ │ │ + for (var i = 0, len = this.rules.length; i < len; i++) {
│ │ │ │ │ + this.rules[i].destroy();
│ │ │ │ │ + this.rules[i] = null;
│ │ │ │ │ + }
│ │ │ │ │ + this.rules = null;
│ │ │ │ │ + this.defaultStyle = null;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: createSymbolizer
│ │ │ │ │ + * creates a style by applying all feature-dependent rules to the base
│ │ │ │ │ + * style.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * feature - {} feature to evaluate rules for
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Object} symbolizer hash
│ │ │ │ │ + */
│ │ │ │ │ + createSymbolizer: function(feature) {
│ │ │ │ │ + var style = this.defaultsPerSymbolizer ? {} : this.createLiterals(
│ │ │ │ │ + OpenLayers.Util.extend({}, this.defaultStyle), feature);
│ │ │ │ │ +
│ │ │ │ │ + var rules = this.rules;
│ │ │ │ │ +
│ │ │ │ │ + var rule, context;
│ │ │ │ │ + var elseRules = [];
│ │ │ │ │ + var appliedRules = false;
│ │ │ │ │ + for (var i = 0, len = rules.length; i < len; i++) {
│ │ │ │ │ + rule = rules[i];
│ │ │ │ │ + // does the rule apply?
│ │ │ │ │ + var applies = rule.evaluate(feature);
│ │ │ │ │ +
│ │ │ │ │ + if (applies) {
│ │ │ │ │ + if (rule instanceof OpenLayers.Rule && rule.elseFilter) {
│ │ │ │ │ + elseRules.push(rule);
│ │ │ │ │ + } else {
│ │ │ │ │ + appliedRules = true;
│ │ │ │ │ + this.applySymbolizer(rule, style, feature);
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + // if no other rules apply, apply the rules with else filters
│ │ │ │ │ + if (appliedRules == false && elseRules.length > 0) {
│ │ │ │ │ + appliedRules = true;
│ │ │ │ │ + for (var i = 0, len = elseRules.length; i < len; i++) {
│ │ │ │ │ + this.applySymbolizer(elseRules[i], style, feature);
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + // don't display if there were rules but none applied
│ │ │ │ │ + if (rules.length > 0 && appliedRules == false) {
│ │ │ │ │ + style.display = "none";
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + if (style.label != null && typeof style.label !== "string") {
│ │ │ │ │ + style.label = String(style.label);
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + return style;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: applySymbolizer
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * rule - {}
│ │ │ │ │ + * style - {Object}
│ │ │ │ │ + * feature - {}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Object} A style with new symbolizer applied.
│ │ │ │ │ + */
│ │ │ │ │ + applySymbolizer: function(rule, style, feature) {
│ │ │ │ │ + var symbolizerPrefix = feature.geometry ?
│ │ │ │ │ + this.getSymbolizerPrefix(feature.geometry) :
│ │ │ │ │ + OpenLayers.Style.SYMBOLIZER_PREFIXES[0];
│ │ │ │ │ +
│ │ │ │ │ + var symbolizer = rule.symbolizer[symbolizerPrefix] || rule.symbolizer;
│ │ │ │ │ +
│ │ │ │ │ + if (this.defaultsPerSymbolizer === true) {
│ │ │ │ │ + var defaults = this.defaultStyle;
│ │ │ │ │ + OpenLayers.Util.applyDefaults(symbolizer, {
│ │ │ │ │ + pointRadius: defaults.pointRadius
│ │ │ │ │ + });
│ │ │ │ │ + if (symbolizer.stroke === true || symbolizer.graphic === true) {
│ │ │ │ │ + OpenLayers.Util.applyDefaults(symbolizer, {
│ │ │ │ │ + strokeWidth: defaults.strokeWidth,
│ │ │ │ │ + strokeColor: defaults.strokeColor,
│ │ │ │ │ + strokeOpacity: defaults.strokeOpacity,
│ │ │ │ │ + strokeDashstyle: defaults.strokeDashstyle,
│ │ │ │ │ + strokeLinecap: defaults.strokeLinecap
│ │ │ │ │ + });
│ │ │ │ │ + }
│ │ │ │ │ + if (symbolizer.fill === true || symbolizer.graphic === true) {
│ │ │ │ │ + OpenLayers.Util.applyDefaults(symbolizer, {
│ │ │ │ │ + fillColor: defaults.fillColor,
│ │ │ │ │ + fillOpacity: defaults.fillOpacity
│ │ │ │ │ + });
│ │ │ │ │ + }
│ │ │ │ │ + if (symbolizer.graphic === true) {
│ │ │ │ │ + OpenLayers.Util.applyDefaults(symbolizer, {
│ │ │ │ │ + pointRadius: this.defaultStyle.pointRadius,
│ │ │ │ │ + externalGraphic: this.defaultStyle.externalGraphic,
│ │ │ │ │ + graphicName: this.defaultStyle.graphicName,
│ │ │ │ │ + graphicOpacity: this.defaultStyle.graphicOpacity,
│ │ │ │ │ + graphicWidth: this.defaultStyle.graphicWidth,
│ │ │ │ │ + graphicHeight: this.defaultStyle.graphicHeight,
│ │ │ │ │ + graphicXOffset: this.defaultStyle.graphicXOffset,
│ │ │ │ │ + graphicYOffset: this.defaultStyle.graphicYOffset
│ │ │ │ │ + });
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + // merge the style with the current style
│ │ │ │ │ + return this.createLiterals(
│ │ │ │ │ + OpenLayers.Util.extend(style, symbolizer), feature);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: createLiterals
│ │ │ │ │ + * creates literals for all style properties that have an entry in
│ │ │ │ │ + * .
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * style - {Object} style to create literals for. Will be modified
│ │ │ │ │ + * inline.
│ │ │ │ │ + * feature - {Object}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Object} the modified style
│ │ │ │ │ + */
│ │ │ │ │ + createLiterals: function(style, feature) {
│ │ │ │ │ + var context = OpenLayers.Util.extend({}, feature.attributes || feature.data);
│ │ │ │ │ + OpenLayers.Util.extend(context, this.context);
│ │ │ │ │ +
│ │ │ │ │ + for (var i in this.propertyStyles) {
│ │ │ │ │ + style[i] = OpenLayers.Style.createLiteral(style[i], context, feature, i);
│ │ │ │ │ + }
│ │ │ │ │ + return style;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: findPropertyStyles
│ │ │ │ │ + * Looks into all rules for this style and the defaultStyle to collect
│ │ │ │ │ + * all the style hash property names containing ${...} strings that have
│ │ │ │ │ + * to be replaced using the createLiteral method before returning them.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Object} hash of property names that need createLiteral parsing. The
│ │ │ │ │ + * name of the property is the key, and the value is true;
│ │ │ │ │ + */
│ │ │ │ │ + findPropertyStyles: function() {
│ │ │ │ │ + var propertyStyles = {};
│ │ │ │ │ +
│ │ │ │ │ + // check the default style
│ │ │ │ │ + var style = this.defaultStyle;
│ │ │ │ │ + this.addPropertyStyles(propertyStyles, style);
│ │ │ │ │ +
│ │ │ │ │ + // walk through all rules to check for properties in their symbolizer
│ │ │ │ │ + var rules = this.rules;
│ │ │ │ │ + var symbolizer, value;
│ │ │ │ │ + for (var i = 0, len = rules.length; i < len; i++) {
│ │ │ │ │ + symbolizer = rules[i].symbolizer;
│ │ │ │ │ + for (var key in symbolizer) {
│ │ │ │ │ + value = symbolizer[key];
│ │ │ │ │ + if (typeof value == "object") {
│ │ │ │ │ + // symbolizer key is "Point", "Line" or "Polygon"
│ │ │ │ │ + this.addPropertyStyles(propertyStyles, value);
│ │ │ │ │ + } else {
│ │ │ │ │ + // symbolizer is a hash of style properties
│ │ │ │ │ + this.addPropertyStyles(propertyStyles, symbolizer);
│ │ │ │ │ + break;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + return propertyStyles;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: addPropertyStyles
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * propertyStyles - {Object} hash to add new property styles to. Will be
│ │ │ │ │ + * modified inline
│ │ │ │ │ + * symbolizer - {Object} search this symbolizer for property styles
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Object} propertyStyles hash
│ │ │ │ │ + */
│ │ │ │ │ + addPropertyStyles: function(propertyStyles, symbolizer) {
│ │ │ │ │ + var property;
│ │ │ │ │ + for (var key in symbolizer) {
│ │ │ │ │ + property = symbolizer[key];
│ │ │ │ │ + if (typeof property == "string" &&
│ │ │ │ │ + property.match(/\$\{\w+\}/)) {
│ │ │ │ │ + propertyStyles[key] = true;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + return propertyStyles;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: addRules
│ │ │ │ │ + * Adds rules to this style.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * rules - {Array()}
│ │ │ │ │ + */
│ │ │ │ │ + addRules: function(rules) {
│ │ │ │ │ + Array.prototype.push.apply(this.rules, rules);
│ │ │ │ │ + this.propertyStyles = this.findPropertyStyles();
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: setDefaultStyle
│ │ │ │ │ + * Sets the default style for this style object.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * style - {Object} Hash of style properties
│ │ │ │ │ + */
│ │ │ │ │ + setDefaultStyle: function(style) {
│ │ │ │ │ + this.defaultStyle = style;
│ │ │ │ │ + this.propertyStyles = this.findPropertyStyles();
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: getSymbolizerPrefix
│ │ │ │ │ + * Returns the correct symbolizer prefix according to the
│ │ │ │ │ + * geometry type of the passed geometry
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * geometry - {}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {String} key of the according symbolizer
│ │ │ │ │ + */
│ │ │ │ │ + getSymbolizerPrefix: function(geometry) {
│ │ │ │ │ + var prefixes = OpenLayers.Style.SYMBOLIZER_PREFIXES;
│ │ │ │ │ + for (var i = 0, len = prefixes.length; i < len; i++) {
│ │ │ │ │ + if (geometry.CLASS_NAME.indexOf(prefixes[i]) != -1) {
│ │ │ │ │ + return prefixes[i];
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: clone
│ │ │ │ │ + * Clones this style.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {} Clone of this style.
│ │ │ │ │ + */
│ │ │ │ │ + clone: function() {
│ │ │ │ │ + var options = OpenLayers.Util.extend({}, this);
│ │ │ │ │ + // clone rules
│ │ │ │ │ + if (this.rules) {
│ │ │ │ │ + options.rules = [];
│ │ │ │ │ + for (var i = 0, len = this.rules.length; i < len; ++i) {
│ │ │ │ │ + options.rules.push(this.rules[i].clone());
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + // clone context
│ │ │ │ │ + options.context = this.context && OpenLayers.Util.extend({}, this.context);
│ │ │ │ │ + //clone default style
│ │ │ │ │ + var defaultStyle = OpenLayers.Util.extend({}, this.defaultStyle);
│ │ │ │ │ + return new OpenLayers.Style(defaultStyle, options);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + CLASS_NAME: "OpenLayers.Style"
│ │ │ │ │ +});
│ │ │ │ │ +
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Function: createLiteral
│ │ │ │ │ + * converts a style value holding a combination of PropertyName and Literal
│ │ │ │ │ + * into a Literal, taking the property values from the passed features.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * value - {String} value to parse. If this string contains a construct like
│ │ │ │ │ + * "foo ${bar}", then "foo " will be taken as literal, and "${bar}"
│ │ │ │ │ + * will be replaced by the value of the "bar" attribute of the passed
│ │ │ │ │ + * feature.
│ │ │ │ │ + * context - {Object} context to take attribute values from
│ │ │ │ │ + * feature - {} optional feature to pass to
│ │ │ │ │ + * for evaluating functions in the
│ │ │ │ │ + * context.
│ │ │ │ │ + * property - {String} optional, name of the property for which the literal is
│ │ │ │ │ + * being created for evaluating functions in the context.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {String} the parsed value. In the example of the value parameter above, the
│ │ │ │ │ + * result would be "foo valueOfBar", assuming that the passed feature has an
│ │ │ │ │ + * attribute named "bar" with the value "valueOfBar".
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Style.createLiteral = function(value, context, feature, property) {
│ │ │ │ │ + if (typeof value == "string" && value.indexOf("${") != -1) {
│ │ │ │ │ + value = OpenLayers.String.format(value, context, [feature, property]);
│ │ │ │ │ + value = (isNaN(value) || !value) ? value : parseFloat(value);
│ │ │ │ │ + }
│ │ │ │ │ + return value;
│ │ │ │ │ +};
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Constant: OpenLayers.Style.SYMBOLIZER_PREFIXES
│ │ │ │ │ + * {Array} prefixes of the sld symbolizers. These are the
│ │ │ │ │ + * same as the main geometry types
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Style.SYMBOLIZER_PREFIXES = ['Point', 'Line', 'Polygon', 'Text',
│ │ │ │ │ + 'Raster'
│ │ │ │ │ +];
│ │ │ │ │ +/* ======================================================================
│ │ │ │ │ OpenLayers/Filter.js
│ │ │ │ │ ====================================================================== */
│ │ │ │ │
│ │ │ │ │ /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ * full text of the license. */
│ │ │ │ │ @@ -20677,14 +18049,2113 @@
│ │ │ │ │ "ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers["ows"]
│ │ │ │ │ },
│ │ │ │ │
│ │ │ │ │ CLASS_NAME: "OpenLayers.Format.WPSExecute"
│ │ │ │ │
│ │ │ │ │ });
│ │ │ │ │ /* ======================================================================
│ │ │ │ │ + OpenLayers/Events.js
│ │ │ │ │ + ====================================================================== */
│ │ │ │ │ +
│ │ │ │ │ +/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
│ │ │ │ │ + * full list of contributors). Published under the 2-clause BSD license.
│ │ │ │ │ + * See license.txt in the OpenLayers distribution or repository for the
│ │ │ │ │ + * full text of the license. */
│ │ │ │ │ +
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * @requires OpenLayers/Util.js
│ │ │ │ │ + */
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Namespace: OpenLayers.Event
│ │ │ │ │ + * Utility functions for event handling.
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Event = {
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: observers
│ │ │ │ │ + * {Object} A hashtable cache of the event observers. Keyed by
│ │ │ │ │ + * element._eventCacheID
│ │ │ │ │ + */
│ │ │ │ │ + observers: false,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constant: KEY_SPACE
│ │ │ │ │ + * {int}
│ │ │ │ │ + */
│ │ │ │ │ + KEY_SPACE: 32,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constant: KEY_BACKSPACE
│ │ │ │ │ + * {int}
│ │ │ │ │ + */
│ │ │ │ │ + KEY_BACKSPACE: 8,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constant: KEY_TAB
│ │ │ │ │ + * {int}
│ │ │ │ │ + */
│ │ │ │ │ + KEY_TAB: 9,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constant: KEY_RETURN
│ │ │ │ │ + * {int}
│ │ │ │ │ + */
│ │ │ │ │ + KEY_RETURN: 13,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constant: KEY_ESC
│ │ │ │ │ + * {int}
│ │ │ │ │ + */
│ │ │ │ │ + KEY_ESC: 27,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constant: KEY_LEFT
│ │ │ │ │ + * {int}
│ │ │ │ │ + */
│ │ │ │ │ + KEY_LEFT: 37,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constant: KEY_UP
│ │ │ │ │ + * {int}
│ │ │ │ │ + */
│ │ │ │ │ + KEY_UP: 38,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constant: KEY_RIGHT
│ │ │ │ │ + * {int}
│ │ │ │ │ + */
│ │ │ │ │ + KEY_RIGHT: 39,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constant: KEY_DOWN
│ │ │ │ │ + * {int}
│ │ │ │ │ + */
│ │ │ │ │ + KEY_DOWN: 40,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constant: KEY_DELETE
│ │ │ │ │ + * {int}
│ │ │ │ │ + */
│ │ │ │ │ + KEY_DELETE: 46,
│ │ │ │ │ +
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: element
│ │ │ │ │ + * Cross browser event element detection.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * event - {Event}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {DOMElement} The element that caused the event
│ │ │ │ │ + */
│ │ │ │ │ + element: function(event) {
│ │ │ │ │ + return event.target || event.srcElement;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: isSingleTouch
│ │ │ │ │ + * Determine whether event was caused by a single touch
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * event - {Event}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean}
│ │ │ │ │ + */
│ │ │ │ │ + isSingleTouch: function(event) {
│ │ │ │ │ + return event.touches && event.touches.length == 1;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: isMultiTouch
│ │ │ │ │ + * Determine whether event was caused by a multi touch
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * event - {Event}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean}
│ │ │ │ │ + */
│ │ │ │ │ + isMultiTouch: function(event) {
│ │ │ │ │ + return event.touches && event.touches.length > 1;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: isLeftClick
│ │ │ │ │ + * Determine whether event was caused by a left click.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * event - {Event}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean}
│ │ │ │ │ + */
│ │ │ │ │ + isLeftClick: function(event) {
│ │ │ │ │ + return (((event.which) && (event.which == 1)) ||
│ │ │ │ │ + ((event.button) && (event.button == 1)));
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: isRightClick
│ │ │ │ │ + * Determine whether event was caused by a right mouse click.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * event - {Event}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean}
│ │ │ │ │ + */
│ │ │ │ │ + isRightClick: function(event) {
│ │ │ │ │ + return (((event.which) && (event.which == 3)) ||
│ │ │ │ │ + ((event.button) && (event.button == 2)));
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: stop
│ │ │ │ │ + * Stops an event from propagating.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * event - {Event}
│ │ │ │ │ + * allowDefault - {Boolean} If true, we stop the event chain but
│ │ │ │ │ + * still allow the default browser behaviour (text selection,
│ │ │ │ │ + * radio-button clicking, etc). Default is false.
│ │ │ │ │ + */
│ │ │ │ │ + stop: function(event, allowDefault) {
│ │ │ │ │ +
│ │ │ │ │ + if (!allowDefault) {
│ │ │ │ │ + OpenLayers.Event.preventDefault(event);
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + if (event.stopPropagation) {
│ │ │ │ │ + event.stopPropagation();
│ │ │ │ │ + } else {
│ │ │ │ │ + event.cancelBubble = true;
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: preventDefault
│ │ │ │ │ + * Cancels the event if it is cancelable, without stopping further
│ │ │ │ │ + * propagation of the event.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * event - {Event}
│ │ │ │ │ + */
│ │ │ │ │ + preventDefault: function(event) {
│ │ │ │ │ + if (event.preventDefault) {
│ │ │ │ │ + event.preventDefault();
│ │ │ │ │ + } else {
│ │ │ │ │ + event.returnValue = false;
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: findElement
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * event - {Event}
│ │ │ │ │ + * tagName - {String}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {DOMElement} The first node with the given tagName, starting from the
│ │ │ │ │ + * node the event was triggered on and traversing the DOM upwards
│ │ │ │ │ + */
│ │ │ │ │ + findElement: function(event, tagName) {
│ │ │ │ │ + var element = OpenLayers.Event.element(event);
│ │ │ │ │ + while (element.parentNode && (!element.tagName ||
│ │ │ │ │ + (element.tagName.toUpperCase() != tagName.toUpperCase()))) {
│ │ │ │ │ + element = element.parentNode;
│ │ │ │ │ + }
│ │ │ │ │ + return element;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: observe
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * elementParam - {DOMElement || String}
│ │ │ │ │ + * name - {String}
│ │ │ │ │ + * observer - {function}
│ │ │ │ │ + * useCapture - {Boolean}
│ │ │ │ │ + */
│ │ │ │ │ + observe: function(elementParam, name, observer, useCapture) {
│ │ │ │ │ + var element = OpenLayers.Util.getElement(elementParam);
│ │ │ │ │ + useCapture = useCapture || false;
│ │ │ │ │ +
│ │ │ │ │ + if (name == 'keypress' &&
│ │ │ │ │ + (navigator.appVersion.match(/Konqueror|Safari|KHTML/) ||
│ │ │ │ │ + element.attachEvent)) {
│ │ │ │ │ + name = 'keydown';
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + //if observers cache has not yet been created, create it
│ │ │ │ │ + if (!this.observers) {
│ │ │ │ │ + this.observers = {};
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + //if not already assigned, make a new unique cache ID
│ │ │ │ │ + if (!element._eventCacheID) {
│ │ │ │ │ + var idPrefix = "eventCacheID_";
│ │ │ │ │ + if (element.id) {
│ │ │ │ │ + idPrefix = element.id + "_" + idPrefix;
│ │ │ │ │ + }
│ │ │ │ │ + element._eventCacheID = OpenLayers.Util.createUniqueID(idPrefix);
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + var cacheID = element._eventCacheID;
│ │ │ │ │ +
│ │ │ │ │ + //if there is not yet a hash entry for this element, add one
│ │ │ │ │ + if (!this.observers[cacheID]) {
│ │ │ │ │ + this.observers[cacheID] = [];
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + //add a new observer to this element's list
│ │ │ │ │ + this.observers[cacheID].push({
│ │ │ │ │ + 'element': element,
│ │ │ │ │ + 'name': name,
│ │ │ │ │ + 'observer': observer,
│ │ │ │ │ + 'useCapture': useCapture
│ │ │ │ │ + });
│ │ │ │ │ +
│ │ │ │ │ + //add the actual browser event listener
│ │ │ │ │ + if (element.addEventListener) {
│ │ │ │ │ + element.addEventListener(name, observer, useCapture);
│ │ │ │ │ + } else if (element.attachEvent) {
│ │ │ │ │ + element.attachEvent('on' + name, observer);
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: stopObservingElement
│ │ │ │ │ + * Given the id of an element to stop observing, cycle through the
│ │ │ │ │ + * element's cached observers, calling stopObserving on each one,
│ │ │ │ │ + * skipping those entries which can no longer be removed.
│ │ │ │ │ + *
│ │ │ │ │ + * parameters:
│ │ │ │ │ + * elementParam - {DOMElement || String}
│ │ │ │ │ + */
│ │ │ │ │ + stopObservingElement: function(elementParam) {
│ │ │ │ │ + var element = OpenLayers.Util.getElement(elementParam);
│ │ │ │ │ + var cacheID = element._eventCacheID;
│ │ │ │ │ +
│ │ │ │ │ + this._removeElementObservers(OpenLayers.Event.observers[cacheID]);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: _removeElementObservers
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * elementObservers - {Array(Object)} Array of (element, name,
│ │ │ │ │ + * observer, usecapture) objects,
│ │ │ │ │ + * taken directly from hashtable
│ │ │ │ │ + */
│ │ │ │ │ + _removeElementObservers: function(elementObservers) {
│ │ │ │ │ + if (elementObservers) {
│ │ │ │ │ + for (var i = elementObservers.length - 1; i >= 0; i--) {
│ │ │ │ │ + var entry = elementObservers[i];
│ │ │ │ │ + OpenLayers.Event.stopObserving.apply(this, [
│ │ │ │ │ + entry.element, entry.name, entry.observer, entry.useCapture
│ │ │ │ │ + ]);
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: stopObserving
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * elementParam - {DOMElement || String}
│ │ │ │ │ + * name - {String}
│ │ │ │ │ + * observer - {function}
│ │ │ │ │ + * useCapture - {Boolean}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean} Whether or not the event observer was removed
│ │ │ │ │ + */
│ │ │ │ │ + stopObserving: function(elementParam, name, observer, useCapture) {
│ │ │ │ │ + useCapture = useCapture || false;
│ │ │ │ │ +
│ │ │ │ │ + var element = OpenLayers.Util.getElement(elementParam);
│ │ │ │ │ + var cacheID = element._eventCacheID;
│ │ │ │ │ +
│ │ │ │ │ + if (name == 'keypress') {
│ │ │ │ │ + if (navigator.appVersion.match(/Konqueror|Safari|KHTML/) ||
│ │ │ │ │ + element.detachEvent) {
│ │ │ │ │ + name = 'keydown';
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + // find element's entry in this.observers cache and remove it
│ │ │ │ │ + var foundEntry = false;
│ │ │ │ │ + var elementObservers = OpenLayers.Event.observers[cacheID];
│ │ │ │ │ + if (elementObservers) {
│ │ │ │ │ +
│ │ │ │ │ + // find the specific event type in the element's list
│ │ │ │ │ + var i = 0;
│ │ │ │ │ + while (!foundEntry && i < elementObservers.length) {
│ │ │ │ │ + var cacheEntry = elementObservers[i];
│ │ │ │ │ +
│ │ │ │ │ + if ((cacheEntry.name == name) &&
│ │ │ │ │ + (cacheEntry.observer == observer) &&
│ │ │ │ │ + (cacheEntry.useCapture == useCapture)) {
│ │ │ │ │ +
│ │ │ │ │ + elementObservers.splice(i, 1);
│ │ │ │ │ + if (elementObservers.length == 0) {
│ │ │ │ │ + delete OpenLayers.Event.observers[cacheID];
│ │ │ │ │ + }
│ │ │ │ │ + foundEntry = true;
│ │ │ │ │ + break;
│ │ │ │ │ + }
│ │ │ │ │ + i++;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + //actually remove the event listener from browser
│ │ │ │ │ + if (foundEntry) {
│ │ │ │ │ + if (element.removeEventListener) {
│ │ │ │ │ + element.removeEventListener(name, observer, useCapture);
│ │ │ │ │ + } else if (element && element.detachEvent) {
│ │ │ │ │ + element.detachEvent('on' + name, observer);
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + return foundEntry;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: unloadCache
│ │ │ │ │ + * Cycle through all the element entries in the events cache and call
│ │ │ │ │ + * stopObservingElement on each.
│ │ │ │ │ + */
│ │ │ │ │ + unloadCache: function() {
│ │ │ │ │ + // check for OpenLayers.Event before checking for observers, because
│ │ │ │ │ + // OpenLayers.Event may be undefined in IE if no map instance was
│ │ │ │ │ + // created
│ │ │ │ │ + if (OpenLayers.Event && OpenLayers.Event.observers) {
│ │ │ │ │ + for (var cacheID in OpenLayers.Event.observers) {
│ │ │ │ │ + var elementObservers = OpenLayers.Event.observers[cacheID];
│ │ │ │ │ + OpenLayers.Event._removeElementObservers.apply(this,
│ │ │ │ │ + [elementObservers]);
│ │ │ │ │ + }
│ │ │ │ │ + OpenLayers.Event.observers = false;
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + CLASS_NAME: "OpenLayers.Event"
│ │ │ │ │ +};
│ │ │ │ │ +
│ │ │ │ │ +/* prevent memory leaks in IE */
│ │ │ │ │ +OpenLayers.Event.observe(window, 'unload', OpenLayers.Event.unloadCache, false);
│ │ │ │ │ +
│ │ │ │ │ +/**
│ │ │ │ │ + * Class: OpenLayers.Events
│ │ │ │ │ + */
│ │ │ │ │ +OpenLayers.Events = OpenLayers.Class({
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constant: BROWSER_EVENTS
│ │ │ │ │ + * {Array(String)} supported events
│ │ │ │ │ + */
│ │ │ │ │ + BROWSER_EVENTS: [
│ │ │ │ │ + "mouseover", "mouseout",
│ │ │ │ │ + "mousedown", "mouseup", "mousemove",
│ │ │ │ │ + "click", "dblclick", "rightclick", "dblrightclick",
│ │ │ │ │ + "resize", "focus", "blur",
│ │ │ │ │ + "touchstart", "touchmove", "touchend",
│ │ │ │ │ + "keydown"
│ │ │ │ │ + ],
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: listeners
│ │ │ │ │ + * {Object} Hashtable of Array(Function): events listener functions
│ │ │ │ │ + */
│ │ │ │ │ + listeners: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: object
│ │ │ │ │ + * {Object} the code object issuing application events
│ │ │ │ │ + */
│ │ │ │ │ + object: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: element
│ │ │ │ │ + * {DOMElement} the DOM element receiving browser events
│ │ │ │ │ + */
│ │ │ │ │ + element: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: eventHandler
│ │ │ │ │ + * {Function} bound event handler attached to elements
│ │ │ │ │ + */
│ │ │ │ │ + eventHandler: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIProperty: fallThrough
│ │ │ │ │ + * {Boolean}
│ │ │ │ │ + */
│ │ │ │ │ + fallThrough: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIProperty: includeXY
│ │ │ │ │ + * {Boolean} Should the .xy property automatically be created for browser
│ │ │ │ │ + * mouse events? In general, this should be false. If it is true, then
│ │ │ │ │ + * mouse events will automatically generate a '.xy' property on the
│ │ │ │ │ + * event object that is passed. (Prior to OpenLayers 2.7, this was true
│ │ │ │ │ + * by default.) Otherwise, you can call the getMousePosition on the
│ │ │ │ │ + * relevant events handler on the object available via the 'evt.object'
│ │ │ │ │ + * property of the evt object. So, for most events, you can call:
│ │ │ │ │ + * function named(evt) {
│ │ │ │ │ + * this.xy = this.object.events.getMousePosition(evt)
│ │ │ │ │ + * }
│ │ │ │ │ + *
│ │ │ │ │ + * This option typically defaults to false for performance reasons:
│ │ │ │ │ + * when creating an events object whose primary purpose is to manage
│ │ │ │ │ + * relatively positioned mouse events within a div, it may make
│ │ │ │ │ + * sense to set it to true.
│ │ │ │ │ + *
│ │ │ │ │ + * This option is also used to control whether the events object caches
│ │ │ │ │ + * offsets. If this is false, it will not: the reason for this is that
│ │ │ │ │ + * it is only expected to be called many times if the includeXY property
│ │ │ │ │ + * is set to true. If you set this to true, you are expected to clear
│ │ │ │ │ + * the offset cache manually (using this.clearMouseCache()) if:
│ │ │ │ │ + * the border of the element changes
│ │ │ │ │ + * the location of the element in the page changes
│ │ │ │ │ + */
│ │ │ │ │ + includeXY: false,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIProperty: extensions
│ │ │ │ │ + * {Object} Event extensions registered with this instance. Keys are
│ │ │ │ │ + * event types, values are {OpenLayers.Events.*} extension instances or
│ │ │ │ │ + * {Boolean} for events that an instantiated extension provides in
│ │ │ │ │ + * addition to the one it was created for.
│ │ │ │ │ + *
│ │ │ │ │ + * Extensions create an event in addition to browser events, which usually
│ │ │ │ │ + * fires when a sequence of browser events is completed. Extensions are
│ │ │ │ │ + * automatically instantiated when a listener is registered for an event
│ │ │ │ │ + * provided by an extension.
│ │ │ │ │ + *
│ │ │ │ │ + * Extensions are created in the namespace using
│ │ │ │ │ + * , and named after the event they provide.
│ │ │ │ │ + * The constructor receives the target instance as
│ │ │ │ │ + * argument. Extensions that need to capture browser events before they
│ │ │ │ │ + * propagate can register their listeners events using , with
│ │ │ │ │ + * {extension: true} as 4th argument.
│ │ │ │ │ + *
│ │ │ │ │ + * If an extension creates more than one event, an alias for each event
│ │ │ │ │ + * type should be created and reference the same class. The constructor
│ │ │ │ │ + * should set a reference in the target's extensions registry to itself.
│ │ │ │ │ + *
│ │ │ │ │ + * Below is a minimal extension that provides the "foostart" and "fooend"
│ │ │ │ │ + * event types, which replace the native "click" event type if clicked on
│ │ │ │ │ + * an element with the css class "foo":
│ │ │ │ │ + *
│ │ │ │ │ + * (code)
│ │ │ │ │ + * OpenLayers.Events.foostart = OpenLayers.Class({
│ │ │ │ │ + * initialize: function(target) {
│ │ │ │ │ + * this.target = target;
│ │ │ │ │ + * this.target.register("click", this, this.doStuff, {extension: true});
│ │ │ │ │ + * // only required if extension provides more than one event type
│ │ │ │ │ + * this.target.extensions["foostart"] = true;
│ │ │ │ │ + * this.target.extensions["fooend"] = true;
│ │ │ │ │ + * },
│ │ │ │ │ + * destroy: function() {
│ │ │ │ │ + * var target = this.target;
│ │ │ │ │ + * target.unregister("click", this, this.doStuff);
│ │ │ │ │ + * delete this.target;
│ │ │ │ │ + * // only required if extension provides more than one event type
│ │ │ │ │ + * delete target.extensions["foostart"];
│ │ │ │ │ + * delete target.extensions["fooend"];
│ │ │ │ │ + * },
│ │ │ │ │ + * doStuff: function(evt) {
│ │ │ │ │ + * var propagate = true;
│ │ │ │ │ + * if (OpenLayers.Event.element(evt).className === "foo") {
│ │ │ │ │ + * propagate = false;
│ │ │ │ │ + * var target = this.target;
│ │ │ │ │ + * target.triggerEvent("foostart");
│ │ │ │ │ + * window.setTimeout(function() {
│ │ │ │ │ + * target.triggerEvent("fooend");
│ │ │ │ │ + * }, 1000);
│ │ │ │ │ + * }
│ │ │ │ │ + * return propagate;
│ │ │ │ │ + * }
│ │ │ │ │ + * });
│ │ │ │ │ + * // only required if extension provides more than one event type
│ │ │ │ │ + * OpenLayers.Events.fooend = OpenLayers.Events.foostart;
│ │ │ │ │ + * (end)
│ │ │ │ │ + *
│ │ │ │ │ + */
│ │ │ │ │ + extensions: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Property: extensionCount
│ │ │ │ │ + * {Object} Keys are event types (like in ), values are the
│ │ │ │ │ + * number of extension listeners for each event type.
│ │ │ │ │ + */
│ │ │ │ │ + extensionCount: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: clearMouseListener
│ │ │ │ │ + * A version of that is bound to this instance so that
│ │ │ │ │ + * it can be used with and
│ │ │ │ │ + * .
│ │ │ │ │ + */
│ │ │ │ │ + clearMouseListener: null,
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Constructor: OpenLayers.Events
│ │ │ │ │ + * Construct an OpenLayers.Events object.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * object - {Object} The js object to which this Events object is being added
│ │ │ │ │ + * element - {DOMElement} A dom element to respond to browser events
│ │ │ │ │ + * eventTypes - {Array(String)} Deprecated. Array of custom application
│ │ │ │ │ + * events. A listener may be registered for any named event, regardless
│ │ │ │ │ + * of the values provided here.
│ │ │ │ │ + * fallThrough - {Boolean} Allow events to fall through after these have
│ │ │ │ │ + * been handled?
│ │ │ │ │ + * options - {Object} Options for the events object.
│ │ │ │ │ + */
│ │ │ │ │ + initialize: function(object, element, eventTypes, fallThrough, options) {
│ │ │ │ │ + OpenLayers.Util.extend(this, options);
│ │ │ │ │ + this.object = object;
│ │ │ │ │ + this.fallThrough = fallThrough;
│ │ │ │ │ + this.listeners = {};
│ │ │ │ │ + this.extensions = {};
│ │ │ │ │ + this.extensionCount = {};
│ │ │ │ │ + this._msTouches = [];
│ │ │ │ │ +
│ │ │ │ │ + // if a dom element is specified, add a listeners list
│ │ │ │ │ + // for browser events on the element and register them
│ │ │ │ │ + if (element != null) {
│ │ │ │ │ + this.attachToElement(element);
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: destroy
│ │ │ │ │ + */
│ │ │ │ │ + destroy: function() {
│ │ │ │ │ + for (var e in this.extensions) {
│ │ │ │ │ + if (typeof this.extensions[e] !== "boolean") {
│ │ │ │ │ + this.extensions[e].destroy();
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + this.extensions = null;
│ │ │ │ │ + if (this.element) {
│ │ │ │ │ + OpenLayers.Event.stopObservingElement(this.element);
│ │ │ │ │ + if (this.element.hasScrollEvent) {
│ │ │ │ │ + OpenLayers.Event.stopObserving(
│ │ │ │ │ + window, "scroll", this.clearMouseListener
│ │ │ │ │ + );
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + this.element = null;
│ │ │ │ │ +
│ │ │ │ │ + this.listeners = null;
│ │ │ │ │ + this.object = null;
│ │ │ │ │ + this.fallThrough = null;
│ │ │ │ │ + this.eventHandler = null;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: addEventType
│ │ │ │ │ + * Deprecated. Any event can be triggered without adding it first.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * eventName - {String}
│ │ │ │ │ + */
│ │ │ │ │ + addEventType: function(eventName) {},
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: attachToElement
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * element - {HTMLDOMElement} a DOM element to attach browser events to
│ │ │ │ │ + */
│ │ │ │ │ + attachToElement: function(element) {
│ │ │ │ │ + if (this.element) {
│ │ │ │ │ + OpenLayers.Event.stopObservingElement(this.element);
│ │ │ │ │ + } else {
│ │ │ │ │ + // keep a bound copy of handleBrowserEvent() so that we can
│ │ │ │ │ + // pass the same function to both Event.observe() and .stopObserving()
│ │ │ │ │ + this.eventHandler = OpenLayers.Function.bindAsEventListener(
│ │ │ │ │ + this.handleBrowserEvent, this
│ │ │ │ │ + );
│ │ │ │ │ +
│ │ │ │ │ + // to be used with observe and stopObserving
│ │ │ │ │ + this.clearMouseListener = OpenLayers.Function.bind(
│ │ │ │ │ + this.clearMouseCache, this
│ │ │ │ │ + );
│ │ │ │ │ + }
│ │ │ │ │ + this.element = element;
│ │ │ │ │ + var msTouch = !!window.navigator.msMaxTouchPoints;
│ │ │ │ │ + var type;
│ │ │ │ │ + for (var i = 0, len = this.BROWSER_EVENTS.length; i < len; i++) {
│ │ │ │ │ + type = this.BROWSER_EVENTS[i];
│ │ │ │ │ + // register the event cross-browser
│ │ │ │ │ + OpenLayers.Event.observe(element, type, this.eventHandler);
│ │ │ │ │ + if (msTouch && type.indexOf('touch') === 0) {
│ │ │ │ │ + this.addMsTouchListener(element, type, this.eventHandler);
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + // disable dragstart in IE so that mousedown/move/up works normally
│ │ │ │ │ + OpenLayers.Event.observe(element, "dragstart", OpenLayers.Event.stop);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: on
│ │ │ │ │ + * Convenience method for registering listeners with a common scope.
│ │ │ │ │ + * Internally, this method calls as shown in the examples
│ │ │ │ │ + * below.
│ │ │ │ │ + *
│ │ │ │ │ + * Example use:
│ │ │ │ │ + * (code)
│ │ │ │ │ + * // register a single listener for the "loadstart" event
│ │ │ │ │ + * events.on({"loadstart": loadStartListener});
│ │ │ │ │ + *
│ │ │ │ │ + * // this is equivalent to the following
│ │ │ │ │ + * events.register("loadstart", undefined, loadStartListener);
│ │ │ │ │ + *
│ │ │ │ │ + * // register multiple listeners to be called with the same `this` object
│ │ │ │ │ + * events.on({
│ │ │ │ │ + * "loadstart": loadStartListener,
│ │ │ │ │ + * "loadend": loadEndListener,
│ │ │ │ │ + * scope: object
│ │ │ │ │ + * });
│ │ │ │ │ + *
│ │ │ │ │ + * // this is equivalent to the following
│ │ │ │ │ + * events.register("loadstart", object, loadStartListener);
│ │ │ │ │ + * events.register("loadend", object, loadEndListener);
│ │ │ │ │ + * (end)
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * object - {Object}
│ │ │ │ │ + */
│ │ │ │ │ + on: function(object) {
│ │ │ │ │ + for (var type in object) {
│ │ │ │ │ + if (type != "scope" && object.hasOwnProperty(type)) {
│ │ │ │ │ + this.register(type, object.scope, object[type]);
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: register
│ │ │ │ │ + * Register an event on the events object.
│ │ │ │ │ + *
│ │ │ │ │ + * When the event is triggered, the 'func' function will be called, in the
│ │ │ │ │ + * context of 'obj'. Imagine we were to register an event, specifying an
│ │ │ │ │ + * OpenLayers.Bounds Object as 'obj'. When the event is triggered, the
│ │ │ │ │ + * context in the callback function will be our Bounds object. This means
│ │ │ │ │ + * that within our callback function, we can access the properties and
│ │ │ │ │ + * methods of the Bounds object through the "this" variable. So our
│ │ │ │ │ + * callback could execute something like:
│ │ │ │ │ + * : leftStr = "Left: " + this.left;
│ │ │ │ │ + *
│ │ │ │ │ + * or
│ │ │ │ │ + *
│ │ │ │ │ + * : centerStr = "Center: " + this.getCenterLonLat();
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * type - {String} Name of the event to register
│ │ │ │ │ + * obj - {Object} The object to bind the context to for the callback#.
│ │ │ │ │ + * If no object is specified, default is the Events's 'object' property.
│ │ │ │ │ + * func - {Function} The callback function. If no callback is
│ │ │ │ │ + * specified, this function does nothing.
│ │ │ │ │ + * priority - {Boolean|Object} If true, adds the new listener to the
│ │ │ │ │ + * *front* of the events queue instead of to the end.
│ │ │ │ │ + *
│ │ │ │ │ + * Valid options for priority:
│ │ │ │ │ + * extension - {Boolean} If true, then the event will be registered as
│ │ │ │ │ + * extension event. Extension events are handled before all other
│ │ │ │ │ + * events.
│ │ │ │ │ + */
│ │ │ │ │ + register: function(type, obj, func, priority) {
│ │ │ │ │ + if (type in OpenLayers.Events && !this.extensions[type]) {
│ │ │ │ │ + this.extensions[type] = new OpenLayers.Events[type](this);
│ │ │ │ │ + }
│ │ │ │ │ + if (func != null) {
│ │ │ │ │ + if (obj == null) {
│ │ │ │ │ + obj = this.object;
│ │ │ │ │ + }
│ │ │ │ │ + var listeners = this.listeners[type];
│ │ │ │ │ + if (!listeners) {
│ │ │ │ │ + listeners = [];
│ │ │ │ │ + this.listeners[type] = listeners;
│ │ │ │ │ + this.extensionCount[type] = 0;
│ │ │ │ │ + }
│ │ │ │ │ + var listener = {
│ │ │ │ │ + obj: obj,
│ │ │ │ │ + func: func
│ │ │ │ │ + };
│ │ │ │ │ + if (priority) {
│ │ │ │ │ + listeners.splice(this.extensionCount[type], 0, listener);
│ │ │ │ │ + if (typeof priority === "object" && priority.extension) {
│ │ │ │ │ + this.extensionCount[type]++;
│ │ │ │ │ + }
│ │ │ │ │ + } else {
│ │ │ │ │ + listeners.push(listener);
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: registerPriority
│ │ │ │ │ + * Same as register() but adds the new listener to the *front* of the
│ │ │ │ │ + * events queue instead of to the end.
│ │ │ │ │ + *
│ │ │ │ │ + * TODO: get rid of this in 3.0 - Decide whether listeners should be
│ │ │ │ │ + * called in the order they were registered or in reverse order.
│ │ │ │ │ + *
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * type - {String} Name of the event to register
│ │ │ │ │ + * obj - {Object} The object to bind the context to for the callback#.
│ │ │ │ │ + * If no object is specified, default is the Events's
│ │ │ │ │ + * 'object' property.
│ │ │ │ │ + * func - {Function} The callback function. If no callback is
│ │ │ │ │ + * specified, this function does nothing.
│ │ │ │ │ + */
│ │ │ │ │ + registerPriority: function(type, obj, func) {
│ │ │ │ │ + this.register(type, obj, func, true);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: un
│ │ │ │ │ + * Convenience method for unregistering listeners with a common scope.
│ │ │ │ │ + * Internally, this method calls as shown in the examples
│ │ │ │ │ + * below.
│ │ │ │ │ + *
│ │ │ │ │ + * Example use:
│ │ │ │ │ + * (code)
│ │ │ │ │ + * // unregister a single listener for the "loadstart" event
│ │ │ │ │ + * events.un({"loadstart": loadStartListener});
│ │ │ │ │ + *
│ │ │ │ │ + * // this is equivalent to the following
│ │ │ │ │ + * events.unregister("loadstart", undefined, loadStartListener);
│ │ │ │ │ + *
│ │ │ │ │ + * // unregister multiple listeners with the same `this` object
│ │ │ │ │ + * events.un({
│ │ │ │ │ + * "loadstart": loadStartListener,
│ │ │ │ │ + * "loadend": loadEndListener,
│ │ │ │ │ + * scope: object
│ │ │ │ │ + * });
│ │ │ │ │ + *
│ │ │ │ │ + * // this is equivalent to the following
│ │ │ │ │ + * events.unregister("loadstart", object, loadStartListener);
│ │ │ │ │ + * events.unregister("loadend", object, loadEndListener);
│ │ │ │ │ + * (end)
│ │ │ │ │ + */
│ │ │ │ │ + un: function(object) {
│ │ │ │ │ + for (var type in object) {
│ │ │ │ │ + if (type != "scope" && object.hasOwnProperty(type)) {
│ │ │ │ │ + this.unregister(type, object.scope, object[type]);
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: unregister
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * type - {String}
│ │ │ │ │ + * obj - {Object} If none specified, defaults to this.object
│ │ │ │ │ + * func - {Function}
│ │ │ │ │ + */
│ │ │ │ │ + unregister: function(type, obj, func) {
│ │ │ │ │ + if (obj == null) {
│ │ │ │ │ + obj = this.object;
│ │ │ │ │ + }
│ │ │ │ │ + var listeners = this.listeners[type];
│ │ │ │ │ + if (listeners != null) {
│ │ │ │ │ + for (var i = 0, len = listeners.length; i < len; i++) {
│ │ │ │ │ + if (listeners[i].obj == obj && listeners[i].func == func) {
│ │ │ │ │ + listeners.splice(i, 1);
│ │ │ │ │ + break;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: remove
│ │ │ │ │ + * Remove all listeners for a given event type. If type is not registered,
│ │ │ │ │ + * does nothing.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * type - {String}
│ │ │ │ │ + */
│ │ │ │ │ + remove: function(type) {
│ │ │ │ │ + if (this.listeners[type] != null) {
│ │ │ │ │ + this.listeners[type] = [];
│ │ │ │ │ + }
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: triggerEvent
│ │ │ │ │ + * Trigger a specified registered event.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * type - {String}
│ │ │ │ │ + * evt - {Event || Object} will be passed to the listeners.
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Boolean} The last listener return. If a listener returns false, the
│ │ │ │ │ + * chain of listeners will stop getting called.
│ │ │ │ │ + */
│ │ │ │ │ + triggerEvent: function(type, evt) {
│ │ │ │ │ + var listeners = this.listeners[type];
│ │ │ │ │ +
│ │ │ │ │ + // fast path
│ │ │ │ │ + if (!listeners || listeners.length == 0) {
│ │ │ │ │ + return undefined;
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + // prep evt object with object & div references
│ │ │ │ │ + if (evt == null) {
│ │ │ │ │ + evt = {};
│ │ │ │ │ + }
│ │ │ │ │ + evt.object = this.object;
│ │ │ │ │ + evt.element = this.element;
│ │ │ │ │ + if (!evt.type) {
│ │ │ │ │ + evt.type = type;
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + // execute all callbacks registered for specified type
│ │ │ │ │ + // get a clone of the listeners array to
│ │ │ │ │ + // allow for splicing during callbacks
│ │ │ │ │ + listeners = listeners.slice();
│ │ │ │ │ + var continueChain;
│ │ │ │ │ + for (var i = 0, len = listeners.length; i < len; i++) {
│ │ │ │ │ + var callback = listeners[i];
│ │ │ │ │ + // bind the context to callback.obj
│ │ │ │ │ + continueChain = callback.func.apply(callback.obj, [evt]);
│ │ │ │ │ +
│ │ │ │ │ + if ((continueChain != undefined) && (continueChain == false)) {
│ │ │ │ │ + // if callback returns false, execute no more callbacks.
│ │ │ │ │ + break;
│ │ │ │ │ + }
│ │ │ │ │ + }
│ │ │ │ │ + // don't fall through to other DOM elements
│ │ │ │ │ + if (!this.fallThrough) {
│ │ │ │ │ + OpenLayers.Event.stop(evt, true);
│ │ │ │ │ + }
│ │ │ │ │ + return continueChain;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: handleBrowserEvent
│ │ │ │ │ + * Basically just a wrapper to the triggerEvent() function, but takes
│ │ │ │ │ + * care to set a property 'xy' on the event with the current mouse
│ │ │ │ │ + * position.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * evt - {Event}
│ │ │ │ │ + */
│ │ │ │ │ + handleBrowserEvent: function(evt) {
│ │ │ │ │ + var type = evt.type,
│ │ │ │ │ + listeners = this.listeners[type];
│ │ │ │ │ + if (!listeners || listeners.length == 0) {
│ │ │ │ │ + // noone's listening, bail out
│ │ │ │ │ + return;
│ │ │ │ │ + }
│ │ │ │ │ + // add clientX & clientY to all events - corresponds to average x, y
│ │ │ │ │ + var touches = evt.touches;
│ │ │ │ │ + if (touches && touches[0]) {
│ │ │ │ │ + var x = 0;
│ │ │ │ │ + var y = 0;
│ │ │ │ │ + var num = touches.length;
│ │ │ │ │ + var touch;
│ │ │ │ │ + for (var i = 0; i < num; ++i) {
│ │ │ │ │ + touch = this.getTouchClientXY(touches[i]);
│ │ │ │ │ + x += touch.clientX;
│ │ │ │ │ + y += touch.clientY;
│ │ │ │ │ + }
│ │ │ │ │ + evt.clientX = x / num;
│ │ │ │ │ + evt.clientY = y / num;
│ │ │ │ │ + }
│ │ │ │ │ + if (this.includeXY) {
│ │ │ │ │ + evt.xy = this.getMousePosition(evt);
│ │ │ │ │ + }
│ │ │ │ │ + this.triggerEvent(type, evt);
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: getTouchClientXY
│ │ │ │ │ + * WebKit has a few bugs for clientX/clientY. This method detects them
│ │ │ │ │ + * and calculate the correct values.
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * evt - {Touch} a Touch object from a TouchEvent
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {Object} An object with only clientX and clientY properties with the
│ │ │ │ │ + * calculated values.
│ │ │ │ │ + */
│ │ │ │ │ + getTouchClientXY: function(evt) {
│ │ │ │ │ + // olMochWin is to override window, used for testing
│ │ │ │ │ + var win = window.olMockWin || window,
│ │ │ │ │ + winPageX = win.pageXOffset,
│ │ │ │ │ + winPageY = win.pageYOffset,
│ │ │ │ │ + x = evt.clientX,
│ │ │ │ │ + y = evt.clientY;
│ │ │ │ │ +
│ │ │ │ │ + if (evt.pageY === 0 && Math.floor(y) > Math.floor(evt.pageY) ||
│ │ │ │ │ + evt.pageX === 0 && Math.floor(x) > Math.floor(evt.pageX)) {
│ │ │ │ │ + // iOS4 include scroll offset in clientX/Y
│ │ │ │ │ + x = x - winPageX;
│ │ │ │ │ + y = y - winPageY;
│ │ │ │ │ + } else if (y < (evt.pageY - winPageY) || x < (evt.pageX - winPageX)) {
│ │ │ │ │ + // Some Android browsers have totally bogus values for clientX/Y
│ │ │ │ │ + // when scrolling/zooming a page
│ │ │ │ │ + x = evt.pageX - winPageX;
│ │ │ │ │ + y = evt.pageY - winPageY;
│ │ │ │ │ + }
│ │ │ │ │ +
│ │ │ │ │ + evt.olClientX = x;
│ │ │ │ │ + evt.olClientY = y;
│ │ │ │ │ +
│ │ │ │ │ + return {
│ │ │ │ │ + clientX: x,
│ │ │ │ │ + clientY: y
│ │ │ │ │ + };
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * APIMethod: clearMouseCache
│ │ │ │ │ + * Clear cached data about the mouse position. This should be called any
│ │ │ │ │ + * time the element that events are registered on changes position
│ │ │ │ │ + * within the page.
│ │ │ │ │ + */
│ │ │ │ │ + clearMouseCache: function() {
│ │ │ │ │ + this.element.scrolls = null;
│ │ │ │ │ + this.element.lefttop = null;
│ │ │ │ │ + this.element.offsets = null;
│ │ │ │ │ + },
│ │ │ │ │ +
│ │ │ │ │ + /**
│ │ │ │ │ + * Method: getMousePosition
│ │ │ │ │ + *
│ │ │ │ │ + * Parameters:
│ │ │ │ │ + * evt - {Event}
│ │ │ │ │ + *
│ │ │ │ │ + * Returns:
│ │ │ │ │ + * {