{"diffoscope-json-version": 1, "source1": "/srv/reproducible-results/rbuild-debian/r-b-build.WFi1oveG/b1/openlayers_2.13.1+ds2-11_armhf.changes", "source2": "/srv/reproducible-results/rbuild-debian/r-b-build.WFi1oveG/b2/openlayers_2.13.1+ds2-11_armhf.changes", "unified_diff": null, "details": [{"source1": "Files", "source2": "Files", "unified_diff": "@@ -1,2 +1,2 @@\n \n- 89c9f630ac374cee7a597165edaad466 730180 javascript optional libjs-openlayers_2.13.1+ds2-11_all.deb\n+ 900775a3f4c9cba8e59249a737338a58 717832 javascript optional libjs-openlayers_2.13.1+ds2-11_all.deb\n"}, {"source1": "libjs-openlayers_2.13.1+ds2-11_all.deb", "source2": "libjs-openlayers_2.13.1+ds2-11_all.deb", "unified_diff": null, "details": [{"source1": "file list", "source2": "file list", "unified_diff": "@@ -1,3 +1,3 @@\n -rw-r--r-- 0 0 0 4 2025-03-06 18:35:30.000000 debian-binary\n--rw-r--r-- 0 0 0 3684 2025-03-06 18:35:30.000000 control.tar.xz\n--rw-r--r-- 0 0 0 726304 2025-03-06 18:35:30.000000 data.tar.xz\n+-rw-r--r-- 0 0 0 3680 2025-03-06 18:35:30.000000 control.tar.xz\n+-rw-r--r-- 0 0 0 713960 2025-03-06 18:35:30.000000 data.tar.xz\n"}, {"source1": "control.tar.xz", "source2": "control.tar.xz", "unified_diff": null, "details": [{"source1": "control.tar", "source2": "control.tar", "unified_diff": null, "details": [{"source1": "./md5sums", "source2": "./md5sums", "unified_diff": null, "details": [{"source1": "./md5sums", "source2": "./md5sums", "comments": ["Files differ"], "unified_diff": null}]}]}]}, {"source1": "data.tar.xz", "source2": "data.tar.xz", "unified_diff": null, "details": [{"source1": "data.tar", "source2": "data.tar", "unified_diff": null, "details": [{"source1": "./usr/share/javascript/openlayers/OpenLayers.js", "source2": "./usr/share/javascript/openlayers/OpenLayers.js", "unified_diff": null, "details": [{"source1": "js-beautify {}", "source2": "js-beautify {}", "unified_diff": "@@ -52,37 +52,14 @@\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \n * POSSIBILITY OF SUCH DAMAGE.\n */\n /* ======================================================================\n- Rico/license.js\n- ====================================================================== */\n-\n-/**\n- * @license Apache 2 \n- * \n- * Contains portions of Rico \n- * \n- * Copyright 2005 Sabre Airline Solutions \n- *\n- * Licensed under the Apache License, Version 2.0 (the \"License\"); you\n- * may not use this file except in compliance with the License. You\n- * may obtain a copy of the License at\n- *\n- * http://www.apache.org/licenses/LICENSE-2.0 \n- *\n- * Unless required by applicable law or agreed to in writing, software\n- * distributed under the License is distributed on an \"AS IS\" BASIS,\n- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n- * implied. See the License for the specific language governing\n- * permissions and limitations under the License. \n- */\n-/* ======================================================================\n OpenLayers/SingleFile.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -159,395 +136,14 @@\n * (code)\n * \n * (end code)\n */\n ImgPath: ''\n };\n /* ======================================================================\n- OpenLayers/BaseTypes/Class.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/SingleFile.js\n- */\n-\n-/**\n- * Constructor: OpenLayers.Class\n- * Base class used to construct all other classes. Includes support for \n- * multiple inheritance. \n- * \n- * This constructor is new in OpenLayers 2.5. At OpenLayers 3.0, the old \n- * syntax for creating classes and dealing with inheritance \n- * will be removed.\n- * \n- * To create a new OpenLayers-style class, use the following syntax:\n- * (code)\n- * var MyClass = OpenLayers.Class(prototype);\n- * (end)\n- *\n- * To create a new OpenLayers-style class with multiple inheritance, use the\n- * following syntax:\n- * (code)\n- * var MyClass = OpenLayers.Class(Class1, Class2, prototype);\n- * (end)\n- * \n- * Note that instanceof reflection will only reveal Class1 as superclass.\n- *\n- */\n-OpenLayers.Class = function() {\n- var len = arguments.length;\n- var P = arguments[0];\n- var F = arguments[len - 1];\n-\n- var C = typeof F.initialize == \"function\" ?\n- F.initialize :\n- function() {\n- P.prototype.initialize.apply(this, arguments);\n- };\n-\n- if (len > 1) {\n- var newArgs = [C, P].concat(\n- Array.prototype.slice.call(arguments).slice(1, len - 1), F);\n- OpenLayers.inherit.apply(null, newArgs);\n- } else {\n- C.prototype = F;\n- }\n- return C;\n-};\n-\n-/**\n- * Function: OpenLayers.inherit\n- *\n- * Parameters:\n- * C - {Object} the class that inherits\n- * P - {Object} the superclass to inherit from\n- *\n- * In addition to the mandatory C and P parameters, an arbitrary number of\n- * objects can be passed, which will extend C.\n- */\n-OpenLayers.inherit = function(C, P) {\n- var F = function() {};\n- F.prototype = P.prototype;\n- C.prototype = new F;\n- var i, l, o;\n- for (i = 2, l = arguments.length; i < l; i++) {\n- o = arguments[i];\n- if (typeof o === \"function\") {\n- o = o.prototype;\n- }\n- OpenLayers.Util.extend(C.prototype, o);\n- }\n-};\n-\n-/**\n- * APIFunction: extend\n- * Copy all properties of a source object to a destination object. Modifies\n- * the passed in destination object. Any properties on the source object\n- * that are set to undefined will not be (re)set on the destination object.\n- *\n- * Parameters:\n- * destination - {Object} The object that will be modified\n- * source - {Object} The object with properties to be set on the destination\n- *\n- * Returns:\n- * {Object} The destination object.\n- */\n-OpenLayers.Util = OpenLayers.Util || {};\n-OpenLayers.Util.extend = function(destination, source) {\n- destination = destination || {};\n- if (source) {\n- for (var property in source) {\n- var value = source[property];\n- if (value !== undefined) {\n- destination[property] = value;\n- }\n- }\n-\n- /**\n- * IE doesn't include the toString property when iterating over an object's\n- * properties with the for(property in object) syntax. Explicitly check if\n- * the source has its own toString property.\n- */\n-\n- /*\n- * FF/Windows < 2.0.0.13 reports \"Illegal operation on WrappedNative\n- * prototype object\" when calling hawOwnProperty if the source object\n- * is an instance of window.Event.\n- */\n-\n- var sourceIsEvt = typeof window.Event == \"function\" &&\n- source instanceof window.Event;\n-\n- if (!sourceIsEvt &&\n- source.hasOwnProperty && source.hasOwnProperty(\"toString\")) {\n- destination.toString = source.toString;\n- }\n- }\n- return destination;\n-};\n-/* ======================================================================\n- OpenLayers/Console.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- */\n-\n-/**\n- * Namespace: OpenLayers.Console\n- * The OpenLayers.Console namespace is used for debugging and error logging.\n- * If the Firebug Lite (../Firebug/firebug.js) is included before this script,\n- * calls to OpenLayers.Console methods will get redirected to window.console.\n- * This makes use of the Firebug extension where available and allows for\n- * cross-browser debugging Firebug style.\n- *\n- * Note:\n- * Note that behavior will differ with the Firebug extention and Firebug Lite.\n- * Most notably, the Firebug Lite console does not currently allow for\n- * hyperlinks to code or for clicking on object to explore their properties.\n- * \n- */\n-OpenLayers.Console = {\n- /**\n- * Create empty functions for all console methods. The real value of these\n- * properties will be set if Firebug Lite (../Firebug/firebug.js script) is\n- * included. We explicitly require the Firebug Lite script to trigger\n- * functionality of the OpenLayers.Console methods.\n- */\n-\n- /**\n- * APIFunction: log\n- * Log an object in the console. The Firebug Lite console logs string\n- * representation of objects. Given multiple arguments, they will\n- * be cast to strings and logged with a space delimiter. If the first\n- * argument is a string with printf-like formatting, subsequent arguments\n- * will be used in string substitution. Any additional arguments (beyond\n- * the number substituted in a format string) will be appended in a space-\n- * delimited line.\n- * \n- * Parameters:\n- * object - {Object}\n- */\n- log: function() {},\n-\n- /**\n- * APIFunction: debug\n- * Writes a message to the console, including a hyperlink to the line\n- * where it was called.\n- *\n- * May be called with multiple arguments as with OpenLayers.Console.log().\n- * \n- * Parameters:\n- * object - {Object}\n- */\n- debug: function() {},\n-\n- /**\n- * APIFunction: info\n- * Writes a message to the console with the visual \"info\" icon and color\n- * coding and a hyperlink to the line where it was called.\n- *\n- * May be called with multiple arguments as with OpenLayers.Console.log().\n- * \n- * Parameters:\n- * object - {Object}\n- */\n- info: function() {},\n-\n- /**\n- * APIFunction: warn\n- * Writes a message to the console with the visual \"warning\" icon and\n- * color coding and a hyperlink to the line where it was called.\n- *\n- * May be called with multiple arguments as with OpenLayers.Console.log().\n- * \n- * Parameters:\n- * object - {Object}\n- */\n- warn: function() {},\n-\n- /**\n- * APIFunction: error\n- * Writes a message to the console with the visual \"error\" icon and color\n- * coding and a hyperlink to the line where it was called.\n- *\n- * May be called with multiple arguments as with OpenLayers.Console.log().\n- * \n- * Parameters:\n- * object - {Object}\n- */\n- error: function() {},\n-\n- /**\n- * APIFunction: userError\n- * A single interface for showing error messages to the user. The default\n- * behavior is a Javascript alert, though this can be overridden by\n- * reassigning OpenLayers.Console.userError to a different function.\n- *\n- * Expects a single error message\n- * \n- * Parameters:\n- * error - {Object}\n- */\n- userError: function(error) {\n- alert(error);\n- },\n-\n- /**\n- * APIFunction: assert\n- * Tests that an expression is true. If not, it will write a message to\n- * the console and throw an exception.\n- *\n- * May be called with multiple arguments as with OpenLayers.Console.log().\n- * \n- * Parameters:\n- * object - {Object}\n- */\n- assert: function() {},\n-\n- /**\n- * APIFunction: dir\n- * Prints an interactive listing of all properties of the object. This\n- * looks identical to the view that you would see in the DOM tab.\n- * \n- * Parameters:\n- * object - {Object}\n- */\n- dir: function() {},\n-\n- /**\n- * APIFunction: dirxml\n- * Prints the XML source tree of an HTML or XML element. This looks\n- * identical to the view that you would see in the HTML tab. You can click\n- * on any node to inspect it in the HTML tab.\n- * \n- * Parameters:\n- * object - {Object}\n- */\n- dirxml: function() {},\n-\n- /**\n- * APIFunction: trace\n- * Prints an interactive stack trace of JavaScript execution at the point\n- * where it is called. The stack trace details the functions on the stack,\n- * as well as the values that were passed as arguments to each function.\n- * You can click each function to take you to its source in the Script tab,\n- * and click each argument value to inspect it in the DOM or HTML tabs.\n- * \n- */\n- trace: function() {},\n-\n- /**\n- * APIFunction: group\n- * Writes a message to the console and opens a nested block to indent all\n- * future messages sent to the console. Call OpenLayers.Console.groupEnd()\n- * to close the block.\n- *\n- * May be called with multiple arguments as with OpenLayers.Console.log().\n- * \n- * Parameters:\n- * object - {Object}\n- */\n- group: function() {},\n-\n- /**\n- * APIFunction: groupEnd\n- * Closes the most recently opened block created by a call to\n- * OpenLayers.Console.group\n- */\n- groupEnd: function() {},\n-\n- /**\n- * APIFunction: time\n- * Creates a new timer under the given name. Call\n- * OpenLayers.Console.timeEnd(name)\n- * with the same name to stop the timer and print the time elapsed.\n- *\n- * Parameters:\n- * name - {String}\n- */\n- time: function() {},\n-\n- /**\n- * APIFunction: timeEnd\n- * Stops a timer created by a call to OpenLayers.Console.time(name) and\n- * writes the time elapsed.\n- *\n- * Parameters:\n- * name - {String}\n- */\n- timeEnd: function() {},\n-\n- /**\n- * APIFunction: profile\n- * Turns on the JavaScript profiler. The optional argument title would\n- * contain the text to be printed in the header of the profile report.\n- *\n- * This function is not currently implemented in Firebug Lite.\n- * \n- * Parameters:\n- * title - {String} Optional title for the profiler\n- */\n- profile: function() {},\n-\n- /**\n- * APIFunction: profileEnd\n- * Turns off the JavaScript profiler and prints its report.\n- * \n- * This function is not currently implemented in Firebug Lite.\n- */\n- profileEnd: function() {},\n-\n- /**\n- * APIFunction: count\n- * Writes the number of times that the line of code where count was called\n- * was executed. The optional argument title will print a message in\n- * addition to the number of the count.\n- *\n- * This function is not currently implemented in Firebug Lite.\n- *\n- * Parameters:\n- * title - {String} Optional title to be printed with count\n- */\n- count: function() {},\n-\n- CLASS_NAME: \"OpenLayers.Console\"\n-};\n-\n-/**\n- * Execute an anonymous function to extend the OpenLayers.Console namespace\n- * if the firebug.js script is included. This closure is used so that the\n- * \"scripts\" and \"i\" variables don't pollute the global namespace.\n- */\n-(function() {\n- /**\n- * If Firebug Lite is included (before this script), re-route all\n- * OpenLayers.Console calls to the console object.\n- */\n- var scripts = document.getElementsByTagName(\"script\");\n- for (var i = 0, len = scripts.length; i < len; ++i) {\n- if (scripts[i].src.indexOf(\"firebug.js\") != -1) {\n- if (console) {\n- OpenLayers.Util.extend(OpenLayers.Console, console);\n- break;\n- }\n- }\n- }\n-})();\n-/* ======================================================================\n OpenLayers/BaseTypes.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -1007,14 +603,141 @@\n }\n }\n return selected;\n }\n \n };\n /* ======================================================================\n+ OpenLayers/BaseTypes/Class.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/SingleFile.js\n+ */\n+\n+/**\n+ * Constructor: OpenLayers.Class\n+ * Base class used to construct all other classes. Includes support for \n+ * multiple inheritance. \n+ * \n+ * This constructor is new in OpenLayers 2.5. At OpenLayers 3.0, the old \n+ * syntax for creating classes and dealing with inheritance \n+ * will be removed.\n+ * \n+ * To create a new OpenLayers-style class, use the following syntax:\n+ * (code)\n+ * var MyClass = OpenLayers.Class(prototype);\n+ * (end)\n+ *\n+ * To create a new OpenLayers-style class with multiple inheritance, use the\n+ * following syntax:\n+ * (code)\n+ * var MyClass = OpenLayers.Class(Class1, Class2, prototype);\n+ * (end)\n+ * \n+ * Note that instanceof reflection will only reveal Class1 as superclass.\n+ *\n+ */\n+OpenLayers.Class = function() {\n+ var len = arguments.length;\n+ var P = arguments[0];\n+ var F = arguments[len - 1];\n+\n+ var C = typeof F.initialize == \"function\" ?\n+ F.initialize :\n+ function() {\n+ P.prototype.initialize.apply(this, arguments);\n+ };\n+\n+ if (len > 1) {\n+ var newArgs = [C, P].concat(\n+ Array.prototype.slice.call(arguments).slice(1, len - 1), F);\n+ OpenLayers.inherit.apply(null, newArgs);\n+ } else {\n+ C.prototype = F;\n+ }\n+ return C;\n+};\n+\n+/**\n+ * Function: OpenLayers.inherit\n+ *\n+ * Parameters:\n+ * C - {Object} the class that inherits\n+ * P - {Object} the superclass to inherit from\n+ *\n+ * In addition to the mandatory C and P parameters, an arbitrary number of\n+ * objects can be passed, which will extend C.\n+ */\n+OpenLayers.inherit = function(C, P) {\n+ var F = function() {};\n+ F.prototype = P.prototype;\n+ C.prototype = new F;\n+ var i, l, o;\n+ for (i = 2, l = arguments.length; i < l; i++) {\n+ o = arguments[i];\n+ if (typeof o === \"function\") {\n+ o = o.prototype;\n+ }\n+ OpenLayers.Util.extend(C.prototype, o);\n+ }\n+};\n+\n+/**\n+ * APIFunction: extend\n+ * Copy all properties of a source object to a destination object. Modifies\n+ * the passed in destination object. Any properties on the source object\n+ * that are set to undefined will not be (re)set on the destination object.\n+ *\n+ * Parameters:\n+ * destination - {Object} The object that will be modified\n+ * source - {Object} The object with properties to be set on the destination\n+ *\n+ * Returns:\n+ * {Object} The destination object.\n+ */\n+OpenLayers.Util = OpenLayers.Util || {};\n+OpenLayers.Util.extend = function(destination, source) {\n+ destination = destination || {};\n+ if (source) {\n+ for (var property in source) {\n+ var value = source[property];\n+ if (value !== undefined) {\n+ destination[property] = value;\n+ }\n+ }\n+\n+ /**\n+ * IE doesn't include the toString property when iterating over an object's\n+ * properties with the for(property in object) syntax. Explicitly check if\n+ * the source has its own toString property.\n+ */\n+\n+ /*\n+ * FF/Windows < 2.0.0.13 reports \"Illegal operation on WrappedNative\n+ * prototype object\" when calling hawOwnProperty if the source object\n+ * is an instance of window.Event.\n+ */\n+\n+ var sourceIsEvt = typeof window.Event == \"function\" &&\n+ source instanceof window.Event;\n+\n+ if (!sourceIsEvt &&\n+ source.hasOwnProperty && source.hasOwnProperty(\"toString\")) {\n+ destination.toString = source.toString;\n+ }\n+ }\n+ return destination;\n+};\n+/* ======================================================================\n OpenLayers/BaseTypes/Bounds.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -1866,14 +1589,207 @@\n \n opp += (quadrant.charAt(0) == 't') ? 'b' : 't';\n opp += (quadrant.charAt(1) == 'l') ? 'r' : 'l';\n \n return opp;\n };\n /* ======================================================================\n+ OpenLayers/BaseTypes/Element.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Util.js\n+ * @requires OpenLayers/BaseTypes.js\n+ */\n+\n+/**\n+ * Namespace: OpenLayers.Element\n+ */\n+OpenLayers.Element = {\n+\n+ /**\n+ * APIFunction: visible\n+ * \n+ * Parameters: \n+ * element - {DOMElement}\n+ * \n+ * Returns:\n+ * {Boolean} Is the element visible?\n+ */\n+ visible: function(element) {\n+ return OpenLayers.Util.getElement(element).style.display != 'none';\n+ },\n+\n+ /**\n+ * APIFunction: toggle\n+ * Toggle the visibility of element(s) passed in\n+ * \n+ * Parameters:\n+ * element - {DOMElement} Actually user can pass any number of elements\n+ */\n+ toggle: function() {\n+ for (var i = 0, len = arguments.length; i < len; i++) {\n+ var element = OpenLayers.Util.getElement(arguments[i]);\n+ var display = OpenLayers.Element.visible(element) ? 'none' :\n+ '';\n+ element.style.display = display;\n+ }\n+ },\n+\n+ /**\n+ * APIFunction: remove\n+ * Remove the specified element from the DOM.\n+ * \n+ * Parameters:\n+ * element - {DOMElement}\n+ */\n+ remove: function(element) {\n+ element = OpenLayers.Util.getElement(element);\n+ element.parentNode.removeChild(element);\n+ },\n+\n+ /**\n+ * APIFunction: getHeight\n+ * \n+ * Parameters:\n+ * element - {DOMElement}\n+ * \n+ * Returns:\n+ * {Integer} The offset height of the element passed in\n+ */\n+ getHeight: function(element) {\n+ element = OpenLayers.Util.getElement(element);\n+ return element.offsetHeight;\n+ },\n+\n+ /**\n+ * Function: hasClass\n+ * Tests if an element has the given CSS class name.\n+ *\n+ * Parameters:\n+ * element - {DOMElement} A DOM element node.\n+ * name - {String} The CSS class name to search for.\n+ *\n+ * Returns:\n+ * {Boolean} The element has the given class name.\n+ */\n+ hasClass: function(element, name) {\n+ var names = element.className;\n+ return (!!names && new RegExp(\"(^|\\\\s)\" + name + \"(\\\\s|$)\").test(names));\n+ },\n+\n+ /**\n+ * Function: addClass\n+ * Add a CSS class name to an element. Safe where element already has\n+ * the class name.\n+ *\n+ * Parameters:\n+ * element - {DOMElement} A DOM element node.\n+ * name - {String} The CSS class name to add.\n+ *\n+ * Returns:\n+ * {DOMElement} The element.\n+ */\n+ addClass: function(element, name) {\n+ if (!OpenLayers.Element.hasClass(element, name)) {\n+ element.className += (element.className ? \" \" : \"\") + name;\n+ }\n+ return element;\n+ },\n+\n+ /**\n+ * Function: removeClass\n+ * Remove a CSS class name from an element. Safe where element does not\n+ * have the class name.\n+ *\n+ * Parameters:\n+ * element - {DOMElement} A DOM element node.\n+ * name - {String} The CSS class name to remove.\n+ *\n+ * Returns:\n+ * {DOMElement} The element.\n+ */\n+ removeClass: function(element, name) {\n+ var names = element.className;\n+ if (names) {\n+ element.className = OpenLayers.String.trim(\n+ names.replace(\n+ new RegExp(\"(^|\\\\s+)\" + name + \"(\\\\s+|$)\"), \" \"\n+ )\n+ );\n+ }\n+ return element;\n+ },\n+\n+ /**\n+ * Function: toggleClass\n+ * Remove a CSS class name from an element if it exists. Add the class name\n+ * if it doesn't exist.\n+ *\n+ * Parameters:\n+ * element - {DOMElement} A DOM element node.\n+ * name - {String} The CSS class name to toggle.\n+ *\n+ * Returns:\n+ * {DOMElement} The element.\n+ */\n+ toggleClass: function(element, name) {\n+ if (OpenLayers.Element.hasClass(element, name)) {\n+ OpenLayers.Element.removeClass(element, name);\n+ } else {\n+ OpenLayers.Element.addClass(element, name);\n+ }\n+ return element;\n+ },\n+\n+ /**\n+ * APIFunction: getStyle\n+ * \n+ * Parameters:\n+ * element - {DOMElement}\n+ * style - {?}\n+ * \n+ * Returns:\n+ * {?}\n+ */\n+ getStyle: function(element, style) {\n+ element = OpenLayers.Util.getElement(element);\n+\n+ var value = null;\n+ if (element && element.style) {\n+ value = element.style[OpenLayers.String.camelize(style)];\n+ if (!value) {\n+ if (document.defaultView &&\n+ document.defaultView.getComputedStyle) {\n+\n+ var css = document.defaultView.getComputedStyle(element, null);\n+ value = css ? css.getPropertyValue(style) : null;\n+ } else if (element.currentStyle) {\n+ value = element.currentStyle[OpenLayers.String.camelize(style)];\n+ }\n+ }\n+\n+ var positions = ['left', 'top', 'right', 'bottom'];\n+ if (window.opera &&\n+ (OpenLayers.Util.indexOf(positions, style) != -1) &&\n+ (OpenLayers.Element.getStyle(element, 'position') == 'static')) {\n+ value = 'auto';\n+ }\n+ }\n+\n+ return value == 'auto' ? null : value;\n+ }\n+\n+};\n+/* ======================================================================\n OpenLayers/BaseTypes/LonLat.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -2327,14 +2243,268 @@\n }\n return equals;\n },\n \n CLASS_NAME: \"OpenLayers.Size\"\n });\n /* ======================================================================\n+ OpenLayers/Console.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ */\n+\n+/**\n+ * Namespace: OpenLayers.Console\n+ * The OpenLayers.Console namespace is used for debugging and error logging.\n+ * If the Firebug Lite (../Firebug/firebug.js) is included before this script,\n+ * calls to OpenLayers.Console methods will get redirected to window.console.\n+ * This makes use of the Firebug extension where available and allows for\n+ * cross-browser debugging Firebug style.\n+ *\n+ * Note:\n+ * Note that behavior will differ with the Firebug extention and Firebug Lite.\n+ * Most notably, the Firebug Lite console does not currently allow for\n+ * hyperlinks to code or for clicking on object to explore their properties.\n+ * \n+ */\n+OpenLayers.Console = {\n+ /**\n+ * Create empty functions for all console methods. The real value of these\n+ * properties will be set if Firebug Lite (../Firebug/firebug.js script) is\n+ * included. We explicitly require the Firebug Lite script to trigger\n+ * functionality of the OpenLayers.Console methods.\n+ */\n+\n+ /**\n+ * APIFunction: log\n+ * Log an object in the console. The Firebug Lite console logs string\n+ * representation of objects. Given multiple arguments, they will\n+ * be cast to strings and logged with a space delimiter. If the first\n+ * argument is a string with printf-like formatting, subsequent arguments\n+ * will be used in string substitution. Any additional arguments (beyond\n+ * the number substituted in a format string) will be appended in a space-\n+ * delimited line.\n+ * \n+ * Parameters:\n+ * object - {Object}\n+ */\n+ log: function() {},\n+\n+ /**\n+ * APIFunction: debug\n+ * Writes a message to the console, including a hyperlink to the line\n+ * where it was called.\n+ *\n+ * May be called with multiple arguments as with OpenLayers.Console.log().\n+ * \n+ * Parameters:\n+ * object - {Object}\n+ */\n+ debug: function() {},\n+\n+ /**\n+ * APIFunction: info\n+ * Writes a message to the console with the visual \"info\" icon and color\n+ * coding and a hyperlink to the line where it was called.\n+ *\n+ * May be called with multiple arguments as with OpenLayers.Console.log().\n+ * \n+ * Parameters:\n+ * object - {Object}\n+ */\n+ info: function() {},\n+\n+ /**\n+ * APIFunction: warn\n+ * Writes a message to the console with the visual \"warning\" icon and\n+ * color coding and a hyperlink to the line where it was called.\n+ *\n+ * May be called with multiple arguments as with OpenLayers.Console.log().\n+ * \n+ * Parameters:\n+ * object - {Object}\n+ */\n+ warn: function() {},\n+\n+ /**\n+ * APIFunction: error\n+ * Writes a message to the console with the visual \"error\" icon and color\n+ * coding and a hyperlink to the line where it was called.\n+ *\n+ * May be called with multiple arguments as with OpenLayers.Console.log().\n+ * \n+ * Parameters:\n+ * object - {Object}\n+ */\n+ error: function() {},\n+\n+ /**\n+ * APIFunction: userError\n+ * A single interface for showing error messages to the user. The default\n+ * behavior is a Javascript alert, though this can be overridden by\n+ * reassigning OpenLayers.Console.userError to a different function.\n+ *\n+ * Expects a single error message\n+ * \n+ * Parameters:\n+ * error - {Object}\n+ */\n+ userError: function(error) {\n+ alert(error);\n+ },\n+\n+ /**\n+ * APIFunction: assert\n+ * Tests that an expression is true. If not, it will write a message to\n+ * the console and throw an exception.\n+ *\n+ * May be called with multiple arguments as with OpenLayers.Console.log().\n+ * \n+ * Parameters:\n+ * object - {Object}\n+ */\n+ assert: function() {},\n+\n+ /**\n+ * APIFunction: dir\n+ * Prints an interactive listing of all properties of the object. This\n+ * looks identical to the view that you would see in the DOM tab.\n+ * \n+ * Parameters:\n+ * object - {Object}\n+ */\n+ dir: function() {},\n+\n+ /**\n+ * APIFunction: dirxml\n+ * Prints the XML source tree of an HTML or XML element. This looks\n+ * identical to the view that you would see in the HTML tab. You can click\n+ * on any node to inspect it in the HTML tab.\n+ * \n+ * Parameters:\n+ * object - {Object}\n+ */\n+ dirxml: function() {},\n+\n+ /**\n+ * APIFunction: trace\n+ * Prints an interactive stack trace of JavaScript execution at the point\n+ * where it is called. The stack trace details the functions on the stack,\n+ * as well as the values that were passed as arguments to each function.\n+ * You can click each function to take you to its source in the Script tab,\n+ * and click each argument value to inspect it in the DOM or HTML tabs.\n+ * \n+ */\n+ trace: function() {},\n+\n+ /**\n+ * APIFunction: group\n+ * Writes a message to the console and opens a nested block to indent all\n+ * future messages sent to the console. Call OpenLayers.Console.groupEnd()\n+ * to close the block.\n+ *\n+ * May be called with multiple arguments as with OpenLayers.Console.log().\n+ * \n+ * Parameters:\n+ * object - {Object}\n+ */\n+ group: function() {},\n+\n+ /**\n+ * APIFunction: groupEnd\n+ * Closes the most recently opened block created by a call to\n+ * OpenLayers.Console.group\n+ */\n+ groupEnd: function() {},\n+\n+ /**\n+ * APIFunction: time\n+ * Creates a new timer under the given name. Call\n+ * OpenLayers.Console.timeEnd(name)\n+ * with the same name to stop the timer and print the time elapsed.\n+ *\n+ * Parameters:\n+ * name - {String}\n+ */\n+ time: function() {},\n+\n+ /**\n+ * APIFunction: timeEnd\n+ * Stops a timer created by a call to OpenLayers.Console.time(name) and\n+ * writes the time elapsed.\n+ *\n+ * Parameters:\n+ * name - {String}\n+ */\n+ timeEnd: function() {},\n+\n+ /**\n+ * APIFunction: profile\n+ * Turns on the JavaScript profiler. The optional argument title would\n+ * contain the text to be printed in the header of the profile report.\n+ *\n+ * This function is not currently implemented in Firebug Lite.\n+ * \n+ * Parameters:\n+ * title - {String} Optional title for the profiler\n+ */\n+ profile: function() {},\n+\n+ /**\n+ * APIFunction: profileEnd\n+ * Turns off the JavaScript profiler and prints its report.\n+ * \n+ * This function is not currently implemented in Firebug Lite.\n+ */\n+ profileEnd: function() {},\n+\n+ /**\n+ * APIFunction: count\n+ * Writes the number of times that the line of code where count was called\n+ * was executed. The optional argument title will print a message in\n+ * addition to the number of the count.\n+ *\n+ * This function is not currently implemented in Firebug Lite.\n+ *\n+ * Parameters:\n+ * title - {String} Optional title to be printed with count\n+ */\n+ count: function() {},\n+\n+ CLASS_NAME: \"OpenLayers.Console\"\n+};\n+\n+/**\n+ * Execute an anonymous function to extend the OpenLayers.Console namespace\n+ * if the firebug.js script is included. This closure is used so that the\n+ * \"scripts\" and \"i\" variables don't pollute the global namespace.\n+ */\n+(function() {\n+ /**\n+ * If Firebug Lite is included (before this script), re-route all\n+ * OpenLayers.Console calls to the console object.\n+ */\n+ var scripts = document.getElementsByTagName(\"script\");\n+ for (var i = 0, len = scripts.length; i < len; ++i) {\n+ if (scripts[i].src.indexOf(\"firebug.js\") != -1) {\n+ if (console) {\n+ OpenLayers.Util.extend(OpenLayers.Console, console);\n+ break;\n+ }\n+ }\n+ }\n+})();\n+/* ======================================================================\n OpenLayers/Lang.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -4256,840 +4426,579 @@\n } else {\n str += coordinate < 0 ? OpenLayers.i18n(\"S\") : OpenLayers.i18n(\"N\");\n }\n return str;\n };\n \n /* ======================================================================\n- OpenLayers/BaseTypes/Element.js\n+ OpenLayers/Format.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n+ * @requires OpenLayers/BaseTypes/Class.js\n * @requires OpenLayers/Util.js\n- * @requires OpenLayers/BaseTypes.js\n */\n \n /**\n- * Namespace: OpenLayers.Element\n+ * Class: OpenLayers.Format\n+ * Base class for format reading/writing a variety of formats. Subclasses\n+ * of OpenLayers.Format are expected to have read and write methods.\n */\n-OpenLayers.Element = {\n+OpenLayers.Format = OpenLayers.Class({\n \n /**\n- * APIFunction: visible\n- * \n- * Parameters: \n- * element - {DOMElement}\n- * \n- * Returns:\n- * {Boolean} Is the element visible?\n+ * Property: options\n+ * {Object} A reference to options passed to the constructor.\n */\n- visible: function(element) {\n- return OpenLayers.Util.getElement(element).style.display != 'none';\n- },\n+ options: null,\n \n /**\n- * APIFunction: toggle\n- * Toggle the visibility of element(s) passed in\n- * \n- * Parameters:\n- * element - {DOMElement} Actually user can pass any number of elements\n+ * APIProperty: externalProjection\n+ * {} When passed a externalProjection and\n+ * internalProjection, the format will reproject the geometries it\n+ * reads or writes. The externalProjection is the projection used by\n+ * the content which is passed into read or which comes out of write.\n+ * In order to reproject, a projection transformation function for the\n+ * specified projections must be available. This support may be \n+ * provided via proj4js or via a custom transformation function. See\n+ * {} for more information on\n+ * custom transformations.\n */\n- toggle: function() {\n- for (var i = 0, len = arguments.length; i < len; i++) {\n- var element = OpenLayers.Util.getElement(arguments[i]);\n- var display = OpenLayers.Element.visible(element) ? 'none' :\n- '';\n- element.style.display = display;\n- }\n- },\n+ externalProjection: null,\n \n /**\n- * APIFunction: remove\n- * Remove the specified element from the DOM.\n- * \n- * Parameters:\n- * element - {DOMElement}\n+ * APIProperty: internalProjection\n+ * {} When passed a externalProjection and\n+ * internalProjection, the format will reproject the geometries it\n+ * reads or writes. The internalProjection is the projection used by\n+ * the geometries which are returned by read or which are passed into\n+ * write. In order to reproject, a projection transformation function\n+ * for the specified projections must be available. This support may be\n+ * provided via proj4js or via a custom transformation function. See\n+ * {} for more information on\n+ * custom transformations.\n */\n- remove: function(element) {\n- element = OpenLayers.Util.getElement(element);\n- element.parentNode.removeChild(element);\n- },\n+ internalProjection: null,\n \n /**\n- * APIFunction: getHeight\n- * \n- * Parameters:\n- * element - {DOMElement}\n- * \n- * Returns:\n- * {Integer} The offset height of the element passed in\n+ * APIProperty: data\n+ * {Object} When is true, this is the parsed string sent to\n+ * .\n */\n- getHeight: function(element) {\n- element = OpenLayers.Util.getElement(element);\n- return element.offsetHeight;\n- },\n+ data: null,\n \n /**\n- * Function: hasClass\n- * Tests if an element has the given CSS class name.\n- *\n- * Parameters:\n- * element - {DOMElement} A DOM element node.\n- * name - {String} The CSS class name to search for.\n- *\n- * Returns:\n- * {Boolean} The element has the given class name.\n+ * APIProperty: keepData\n+ * {Object} Maintain a reference () to the most recently read data.\n+ * Default is false.\n */\n- hasClass: function(element, name) {\n- var names = element.className;\n- return (!!names && new RegExp(\"(^|\\\\s)\" + name + \"(\\\\s|$)\").test(names));\n- },\n+ keepData: false,\n \n /**\n- * Function: addClass\n- * Add a CSS class name to an element. Safe where element already has\n- * the class name.\n+ * Constructor: OpenLayers.Format\n+ * Instances of this class are not useful. See one of the subclasses.\n *\n * Parameters:\n- * element - {DOMElement} A DOM element node.\n- * name - {String} The CSS class name to add.\n+ * options - {Object} An optional object with properties to set on the\n+ * format\n+ *\n+ * Valid options:\n+ * keepData - {Boolean} If true, upon , the data property will be\n+ * set to the parsed object (e.g. the json or xml object).\n *\n * Returns:\n- * {DOMElement} The element.\n+ * An instance of OpenLayers.Format\n */\n- addClass: function(element, name) {\n- if (!OpenLayers.Element.hasClass(element, name)) {\n- element.className += (element.className ? \" \" : \"\") + name;\n- }\n- return element;\n+ initialize: function(options) {\n+ OpenLayers.Util.extend(this, options);\n+ this.options = options;\n },\n \n /**\n- * Function: removeClass\n- * Remove a CSS class name from an element. Safe where element does not\n- * have the class name.\n- *\n- * Parameters:\n- * element - {DOMElement} A DOM element node.\n- * name - {String} The CSS class name to remove.\n- *\n- * Returns:\n- * {DOMElement} The element.\n+ * APIMethod: destroy\n+ * Clean up.\n */\n- removeClass: function(element, name) {\n- var names = element.className;\n- if (names) {\n- element.className = OpenLayers.String.trim(\n- names.replace(\n- new RegExp(\"(^|\\\\s+)\" + name + \"(\\\\s+|$)\"), \" \"\n- )\n- );\n- }\n- return element;\n- },\n+ destroy: function() {},\n \n /**\n- * Function: toggleClass\n- * Remove a CSS class name from an element if it exists. Add the class name\n- * if it doesn't exist.\n- *\n+ * Method: read\n+ * Read data from a string, and return an object whose type depends on the\n+ * subclass. \n+ * \n * Parameters:\n- * element - {DOMElement} A DOM element node.\n- * name - {String} The CSS class name to toggle.\n+ * data - {string} Data to read/parse.\n *\n * Returns:\n- * {DOMElement} The element.\n+ * Depends on the subclass\n */\n- toggleClass: function(element, name) {\n- if (OpenLayers.Element.hasClass(element, name)) {\n- OpenLayers.Element.removeClass(element, name);\n- } else {\n- OpenLayers.Element.addClass(element, name);\n- }\n- return element;\n+ read: function(data) {\n+ throw new Error('Read not implemented.');\n },\n \n /**\n- * APIFunction: getStyle\n- * \n+ * Method: write\n+ * Accept an object, and return a string. \n+ *\n * Parameters:\n- * element - {DOMElement}\n- * style - {?}\n- * \n+ * object - {Object} Object to be serialized\n+ *\n * Returns:\n- * {?}\n+ * {String} A string representation of the object.\n */\n- getStyle: function(element, style) {\n- element = OpenLayers.Util.getElement(element);\n-\n- var value = null;\n- if (element && element.style) {\n- value = element.style[OpenLayers.String.camelize(style)];\n- if (!value) {\n- if (document.defaultView &&\n- document.defaultView.getComputedStyle) {\n-\n- var css = document.defaultView.getComputedStyle(element, null);\n- value = css ? css.getPropertyValue(style) : null;\n- } else if (element.currentStyle) {\n- value = element.currentStyle[OpenLayers.String.camelize(style)];\n- }\n- }\n-\n- var positions = ['left', 'top', 'right', 'bottom'];\n- if (window.opera &&\n- (OpenLayers.Util.indexOf(positions, style) != -1) &&\n- (OpenLayers.Element.getStyle(element, 'position') == 'static')) {\n- value = 'auto';\n- }\n- }\n-\n- return value == 'auto' ? null : value;\n- }\n+ write: function(object) {\n+ throw new Error('Write not implemented.');\n+ },\n \n-};\n+ CLASS_NAME: \"OpenLayers.Format\"\n+});\n /* ======================================================================\n- Rico/Color.js\n+ OpenLayers/Tile.js\n ====================================================================== */\n \n-/** \n- * @requires Rico/license.js\n- * @requires OpenLayers/Console.js\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/BaseTypes/Element.js\n- */\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n \n-/*\n- * This file has been edited substantially from the Rico-released version by\n- * the OpenLayers development team.\n+/**\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Util.js\n */\n \n-OpenLayers.Console.warn(\"OpenLayers.Rico is deprecated\");\n-\n-OpenLayers.Rico = OpenLayers.Rico || {};\n-OpenLayers.Rico.Color = OpenLayers.Class({\n-\n- initialize: function(red, green, blue) {\n- this.rgb = {\n- r: red,\n- g: green,\n- b: blue\n- };\n- },\n-\n- setRed: function(r) {\n- this.rgb.r = r;\n- },\n-\n- setGreen: function(g) {\n- this.rgb.g = g;\n- },\n-\n- setBlue: function(b) {\n- this.rgb.b = b;\n- },\n-\n- setHue: function(h) {\n-\n- // get an HSB model, and set the new hue...\n- var hsb = this.asHSB();\n- hsb.h = h;\n-\n- // convert back to RGB...\n- this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b);\n- },\n-\n- setSaturation: function(s) {\n- // get an HSB model, and set the new hue...\n- var hsb = this.asHSB();\n- hsb.s = s;\n-\n- // convert back to RGB and set values...\n- this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b);\n- },\n-\n- setBrightness: function(b) {\n- // get an HSB model, and set the new hue...\n- var hsb = this.asHSB();\n- hsb.b = b;\n-\n- // convert back to RGB and set values...\n- this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b);\n- },\n-\n- darken: function(percent) {\n- var hsb = this.asHSB();\n- this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, Math.max(hsb.b - percent, 0));\n- },\n-\n- brighten: function(percent) {\n- var hsb = this.asHSB();\n- this.rgb = OpenLayers.Rico.Color.HSBtoRGB(hsb.h, hsb.s, Math.min(hsb.b + percent, 1));\n- },\n-\n- blend: function(other) {\n- this.rgb.r = Math.floor((this.rgb.r + other.rgb.r) / 2);\n- this.rgb.g = Math.floor((this.rgb.g + other.rgb.g) / 2);\n- this.rgb.b = Math.floor((this.rgb.b + other.rgb.b) / 2);\n- },\n-\n- isBright: function() {\n- var hsb = this.asHSB();\n- return this.asHSB().b > 0.5;\n- },\n-\n- isDark: function() {\n- return !this.isBright();\n- },\n-\n- asRGB: function() {\n- return \"rgb(\" + this.rgb.r + \",\" + this.rgb.g + \",\" + this.rgb.b + \")\";\n- },\n-\n- asHex: function() {\n- return \"#\" + this.rgb.r.toColorPart() + this.rgb.g.toColorPart() + this.rgb.b.toColorPart();\n- },\n-\n- asHSB: function() {\n- return OpenLayers.Rico.Color.RGBtoHSB(this.rgb.r, this.rgb.g, this.rgb.b);\n- },\n-\n- toString: function() {\n- return this.asHex();\n- }\n-\n-});\n-\n-OpenLayers.Rico.Color.createFromHex = function(hexCode) {\n- if (hexCode.length == 4) {\n- var shortHexCode = hexCode;\n- var hexCode = '#';\n- for (var i = 1; i < 4; i++) {\n- hexCode += (shortHexCode.charAt(i) +\n- shortHexCode.charAt(i));\n- }\n- }\n- if (hexCode.indexOf('#') == 0) {\n- hexCode = hexCode.substring(1);\n- }\n- var red = hexCode.substring(0, 2);\n- var green = hexCode.substring(2, 4);\n- var blue = hexCode.substring(4, 6);\n- return new OpenLayers.Rico.Color(parseInt(red, 16), parseInt(green, 16), parseInt(blue, 16));\n-};\n-\n /**\n- * Factory method for creating a color from the background of\n- * an HTML element.\n+ * Class: OpenLayers.Tile \n+ * This is a class designed to designate a single tile, however\n+ * it is explicitly designed to do relatively little. Tiles store \n+ * information about themselves -- such as the URL that they are related\n+ * to, and their size - but do not add themselves to the layer div \n+ * automatically, for example. Create a new tile with the \n+ * constructor, or a subclass. \n+ * \n+ * TBD 3.0 - remove reference to url in above paragraph\n+ * \n */\n-OpenLayers.Rico.Color.createColorFromBackground = function(elem) {\n-\n- var actualColor =\n- OpenLayers.Element.getStyle(OpenLayers.Util.getElement(elem),\n- \"backgroundColor\");\n+OpenLayers.Tile = OpenLayers.Class({\n \n- if (actualColor == \"transparent\" && elem.parentNode) {\n- return OpenLayers.Rico.Color.createColorFromBackground(elem.parentNode);\n- }\n- if (actualColor == null) {\n- return new OpenLayers.Rico.Color(255, 255, 255);\n- }\n- if (actualColor.indexOf(\"rgb(\") == 0) {\n- var colors = actualColor.substring(4, actualColor.length - 1);\n- var colorArray = colors.split(\",\");\n- return new OpenLayers.Rico.Color(parseInt(colorArray[0]),\n- parseInt(colorArray[1]),\n- parseInt(colorArray[2]));\n+ /**\n+ * APIProperty: events\n+ * {} An events object that handles all \n+ * events on the tile.\n+ *\n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * tile.events.register(type, obj, listener);\n+ * (end)\n+ *\n+ * Supported event types:\n+ * beforedraw - Triggered before the tile is drawn. Used to defer\n+ * drawing to an animation queue. To defer drawing, listeners need\n+ * to return false, which will abort drawing. The queue handler needs\n+ * to call (true) to actually draw the tile.\n+ * loadstart - Triggered when tile loading starts.\n+ * loadend - Triggered when tile loading ends.\n+ * loaderror - Triggered before the loadend event (i.e. when the tile is\n+ * still hidden) if the tile could not be loaded.\n+ * reload - Triggered when an already loading tile is reloaded.\n+ * unload - Triggered before a tile is unloaded.\n+ */\n+ events: null,\n \n- } else if (actualColor.indexOf(\"#\") == 0) {\n- return OpenLayers.Rico.Color.createFromHex(actualColor);\n- } else {\n- return new OpenLayers.Rico.Color(255, 255, 255);\n- }\n-};\n+ /**\n+ * APIProperty: eventListeners\n+ * {Object} If set as an option at construction, the eventListeners\n+ * object will be registered with . Object\n+ * structure must be a listeners object as shown in the example for\n+ * the events.on method.\n+ *\n+ * This options can be set in the ``tileOptions`` option from\n+ * . For example, to be notified of the\n+ * ``loadend`` event of each tiles:\n+ * (code)\n+ * new OpenLayers.Layer.OSM('osm', 'http://tile.openstreetmap.org/${z}/${x}/${y}.png', {\n+ * tileOptions: {\n+ * eventListeners: {\n+ * 'loadend': function(evt) {\n+ * // do something on loadend\n+ * }\n+ * }\n+ * }\n+ * });\n+ * (end)\n+ */\n+ eventListeners: null,\n \n-OpenLayers.Rico.Color.HSBtoRGB = function(hue, saturation, brightness) {\n+ /**\n+ * Property: id \n+ * {String} null\n+ */\n+ id: null,\n \n- var red = 0;\n- var green = 0;\n- var blue = 0;\n+ /** \n+ * Property: layer \n+ * {} layer the tile is attached to \n+ */\n+ layer: null,\n \n- if (saturation == 0) {\n- red = parseInt(brightness * 255.0 + 0.5);\n- green = red;\n- blue = red;\n- } else {\n- var h = (hue - Math.floor(hue)) * 6.0;\n- var f = h - Math.floor(h);\n- var p = brightness * (1.0 - saturation);\n- var q = brightness * (1.0 - saturation * f);\n- var t = brightness * (1.0 - (saturation * (1.0 - f)));\n+ /**\n+ * Property: url\n+ * {String} url of the request.\n+ *\n+ * TBD 3.0 \n+ * Deprecated. The base tile class does not need an url. This should be \n+ * handled in subclasses. Does not belong here.\n+ */\n+ url: null,\n \n- switch (parseInt(h)) {\n- case 0:\n- red = (brightness * 255.0 + 0.5);\n- green = (t * 255.0 + 0.5);\n- blue = (p * 255.0 + 0.5);\n- break;\n- case 1:\n- red = (q * 255.0 + 0.5);\n- green = (brightness * 255.0 + 0.5);\n- blue = (p * 255.0 + 0.5);\n- break;\n- case 2:\n- red = (p * 255.0 + 0.5);\n- green = (brightness * 255.0 + 0.5);\n- blue = (t * 255.0 + 0.5);\n- break;\n- case 3:\n- red = (p * 255.0 + 0.5);\n- green = (q * 255.0 + 0.5);\n- blue = (brightness * 255.0 + 0.5);\n- break;\n- case 4:\n- red = (t * 255.0 + 0.5);\n- green = (p * 255.0 + 0.5);\n- blue = (brightness * 255.0 + 0.5);\n- break;\n- case 5:\n- red = (brightness * 255.0 + 0.5);\n- green = (p * 255.0 + 0.5);\n- blue = (q * 255.0 + 0.5);\n- break;\n- }\n- }\n+ /** \n+ * APIProperty: bounds \n+ * {} null\n+ */\n+ bounds: null,\n \n- return {\n- r: parseInt(red),\n- g: parseInt(green),\n- b: parseInt(blue)\n- };\n-};\n+ /** \n+ * Property: size \n+ * {} null\n+ */\n+ size: null,\n \n-OpenLayers.Rico.Color.RGBtoHSB = function(r, g, b) {\n+ /** \n+ * Property: position \n+ * {} Top Left pixel of the tile\n+ */\n+ position: null,\n \n- var hue;\n- var saturation;\n- var brightness;\n+ /**\n+ * Property: isLoading\n+ * {Boolean} Is the tile loading?\n+ */\n+ isLoading: false,\n \n- var cmax = (r > g) ? r : g;\n- if (b > cmax) {\n- cmax = b;\n- }\n- var cmin = (r < g) ? r : g;\n- if (b < cmin) {\n- cmin = b;\n- }\n- brightness = cmax / 255.0;\n- if (cmax != 0) {\n- saturation = (cmax - cmin) / cmax;\n- } else {\n- saturation = 0;\n- }\n- if (saturation == 0) {\n- hue = 0;\n- } else {\n- var redc = (cmax - r) / (cmax - cmin);\n- var greenc = (cmax - g) / (cmax - cmin);\n- var bluec = (cmax - b) / (cmax - cmin);\n+ /** TBD 3.0 -- remove 'url' from the list of parameters to the constructor.\n+ * there is no need for the base tile class to have a url.\n+ */\n \n- if (r == cmax) {\n- hue = bluec - greenc;\n- } else if (g == cmax) {\n- hue = 2.0 + redc - bluec;\n- } else {\n- hue = 4.0 + greenc - redc;\n- }\n- hue = hue / 6.0;\n- if (hue < 0) {\n- hue = hue + 1.0;\n+ /** \n+ * Constructor: OpenLayers.Tile\n+ * Constructor for a new instance.\n+ * \n+ * Parameters:\n+ * layer - {} layer that the tile will go in.\n+ * position - {}\n+ * bounds - {}\n+ * url - {}\n+ * size - {}\n+ * options - {Object}\n+ */\n+ initialize: function(layer, position, bounds, url, size, options) {\n+ this.layer = layer;\n+ this.position = position.clone();\n+ this.setBounds(bounds);\n+ this.url = url;\n+ if (size) {\n+ this.size = size.clone();\n }\n- }\n-\n- return {\n- h: hue,\n- s: saturation,\n- b: brightness\n- };\n-};\n-\n-/* ======================================================================\n- Rico/Corner.js\n- ====================================================================== */\n-\n-/**\n- * @requires OpenLayers/Console.js\n- * @requires Rico/Color.js\n- */\n-\n-\n-/*\n- * This file has been edited substantially from the Rico-released\n- * version by the OpenLayers development team.\n- * \n- * Copyright 2005 Sabre Airline Solutions \n- * \n- * Licensed under the Apache License, Version 2.0 (the \"License\");\n- * you may not use this file except in compliance with the\n- * License. You may obtain a copy of the License at\n- * \n- * http://www.apache.org/licenses/LICENSE-2.0 \n- * \n- * Unless required by applicable law or agreed to in writing, software\n- * distributed under the * License is distributed on an \"AS IS\" BASIS,\n- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or\n- * implied. See the License for the specific language governing\n- * permissions * and limitations under the License.\n- *\n- */\n-\n-OpenLayers.Console.warn(\"OpenLayers.Rico is deprecated\");\n \n-OpenLayers.Rico = OpenLayers.Rico || {};\n-OpenLayers.Rico.Corner = {\n+ //give the tile a unique id based on its BBOX.\n+ this.id = OpenLayers.Util.createUniqueID(\"Tile_\");\n \n- round: function(e, options) {\n- e = OpenLayers.Util.getElement(e);\n- this._setOptions(options);\n+ OpenLayers.Util.extend(this, options);\n \n- var color = this.options.color;\n- if (this.options.color == \"fromElement\") {\n- color = this._background(e);\n- }\n- var bgColor = this.options.bgColor;\n- if (this.options.bgColor == \"fromParent\") {\n- bgColor = this._background(e.offsetParent);\n+ this.events = new OpenLayers.Events(this);\n+ if (this.eventListeners instanceof Object) {\n+ this.events.on(this.eventListeners);\n }\n- this._roundCornersImpl(e, color, bgColor);\n },\n \n- /** This is a helper function to change the background\n- * color of
that has had Rico rounded corners added.\n- *\n- * It seems we cannot just set the background color for the\n- * outer
so each element used to create the\n- * corners must have its background color set individually.\n- *\n- * @param {DOM} theDiv - A child of the outer
that was\n- * supplied to the `round` method.\n- *\n- * @param {String} newColor - The new background color to use.\n+ /**\n+ * Method: unload\n+ * Call immediately before destroying if you are listening to tile\n+ * events, so that counters are properly handled if tile is still\n+ * loading at destroy-time. Will only fire an event if the tile is\n+ * still loading.\n */\n- changeColor: function(theDiv, newColor) {\n-\n- theDiv.style.backgroundColor = newColor;\n-\n- var spanElements = theDiv.parentNode.getElementsByTagName(\"span\");\n-\n- for (var currIdx = 0; currIdx < spanElements.length; currIdx++) {\n- spanElements[currIdx].style.backgroundColor = newColor;\n+ unload: function() {\n+ if (this.isLoading) {\n+ this.isLoading = false;\n+ this.events.triggerEvent(\"unload\");\n }\n },\n \n-\n- /** This is a helper function to change the background\n- * opacity of
that has had Rico rounded corners added.\n- *\n- * See changeColor (above) for algorithm explanation\n- *\n- * @param {DOM} theDiv A child of the outer
that was\n- * supplied to the `round` method.\n- *\n- * @param {int} newOpacity The new opacity to use (0-1).\n+ /** \n+ * APIMethod: destroy\n+ * Nullify references to prevent circular references and memory leaks.\n */\n- changeOpacity: function(theDiv, newOpacity) {\n-\n- var mozillaOpacity = newOpacity;\n- var ieOpacity = 'alpha(opacity=' + newOpacity * 100 + ')';\n-\n- theDiv.style.opacity = mozillaOpacity;\n- theDiv.style.filter = ieOpacity;\n-\n- var spanElements = theDiv.parentNode.getElementsByTagName(\"span\");\n+ destroy: function() {\n+ this.layer = null;\n+ this.bounds = null;\n+ this.size = null;\n+ this.position = null;\n \n- for (var currIdx = 0; currIdx < spanElements.length; currIdx++) {\n- spanElements[currIdx].style.opacity = mozillaOpacity;\n- spanElements[currIdx].style.filter = ieOpacity;\n+ if (this.eventListeners) {\n+ this.events.un(this.eventListeners);\n }\n-\n+ this.events.destroy();\n+ this.eventListeners = null;\n+ this.events = null;\n },\n \n- /** this function takes care of redoing the rico cornering\n- * \n- * you can't just call updateRicoCorners() again and pass it a \n- * new options string. you have to first remove the divs that \n- * rico puts on top and below the content div.\n- *\n- * @param {DOM} theDiv - A child of the outer
that was\n- * supplied to the `round` method.\n+ /**\n+ * Method: draw\n+ * Clear whatever is currently in the tile, then return whether or not \n+ * it should actually be re-drawn. This is an example implementation\n+ * that can be overridden by subclasses. The minimum thing to do here\n+ * is to call and return the result from .\n *\n- * @param {Object} options - list of options\n+ * Parameters:\n+ * force - {Boolean} If true, the tile will not be cleared and no beforedraw\n+ * event will be fired. This is used for drawing tiles asynchronously\n+ * after drawing has been cancelled by returning false from a beforedraw\n+ * listener.\n+ * \n+ * Returns:\n+ * {Boolean} Whether or not the tile should actually be drawn. Returns null\n+ * if a beforedraw listener returned false.\n */\n- reRound: function(theDiv, options) {\n-\n- var topRico = theDiv.parentNode.childNodes[0];\n- //theDiv would be theDiv.parentNode.childNodes[1]\n- var bottomRico = theDiv.parentNode.childNodes[2];\n-\n- theDiv.parentNode.removeChild(topRico);\n- theDiv.parentNode.removeChild(bottomRico);\n-\n- this.round(theDiv.parentNode, options);\n- },\n-\n- _roundCornersImpl: function(e, color, bgColor) {\n- if (this.options.border) {\n- this._renderBorder(e, bgColor);\n- }\n- if (this._isTopRounded()) {\n- this._roundTopCorners(e, color, bgColor);\n- }\n- if (this._isBottomRounded()) {\n- this._roundBottomCorners(e, color, bgColor);\n+ draw: function(force) {\n+ if (!force) {\n+ //clear tile's contents and mark as not drawn\n+ this.clear();\n }\n- },\n-\n- _renderBorder: function(el, bgColor) {\n- var borderValue = \"1px solid \" + this._borderColor(bgColor);\n- var borderL = \"border-left: \" + borderValue;\n- var borderR = \"border-right: \" + borderValue;\n- var style = \"style='\" + borderL + \";\" + borderR + \"'\";\n- el.innerHTML = \"
\" + el.innerHTML + \"
\";\n- },\n-\n- _roundTopCorners: function(el, color, bgColor) {\n- var corner = this._createCorner(bgColor);\n- for (var i = 0; i < this.options.numSlices; i++) {\n- corner.appendChild(this._createCornerSlice(color, bgColor, i, \"top\"));\n+ var draw = this.shouldDraw();\n+ if (draw && !force && this.events.triggerEvent(\"beforedraw\") === false) {\n+ draw = null;\n }\n- el.style.paddingTop = 0;\n- el.insertBefore(corner, el.firstChild);\n+ return draw;\n },\n \n- _roundBottomCorners: function(el, color, bgColor) {\n- var corner = this._createCorner(bgColor);\n- for (var i = (this.options.numSlices - 1); i >= 0; i--) {\n- corner.appendChild(this._createCornerSlice(color, bgColor, i, \"bottom\"));\n+ /**\n+ * Method: shouldDraw\n+ * Return whether or not the tile should actually be (re-)drawn. The only\n+ * case where we *wouldn't* want to draw the tile is if the tile is outside\n+ * its layer's maxExtent\n+ * \n+ * Returns:\n+ * {Boolean} Whether or not the tile should actually be drawn.\n+ */\n+ shouldDraw: function() {\n+ var withinMaxExtent = false,\n+ maxExtent = this.layer.maxExtent;\n+ if (maxExtent) {\n+ var map = this.layer.map;\n+ var worldBounds = map.baseLayer.wrapDateLine && map.getMaxExtent();\n+ if (this.bounds.intersectsBounds(maxExtent, {\n+ inclusive: false,\n+ worldBounds: worldBounds\n+ })) {\n+ withinMaxExtent = true;\n+ }\n }\n- el.style.paddingBottom = 0;\n- el.appendChild(corner);\n- },\n \n- _createCorner: function(bgColor) {\n- var corner = document.createElement(\"div\");\n- corner.style.backgroundColor = (this._isTransparent() ? \"transparent\" : bgColor);\n- return corner;\n+ return withinMaxExtent || this.layer.displayOutsideMaxExtent;\n },\n \n- _createCornerSlice: function(color, bgColor, n, position) {\n- var slice = document.createElement(\"span\");\n-\n- var inStyle = slice.style;\n- inStyle.backgroundColor = color;\n- inStyle.display = \"block\";\n- inStyle.height = \"1px\";\n- inStyle.overflow = \"hidden\";\n- inStyle.fontSize = \"1px\";\n-\n- var borderColor = this._borderColor(color, bgColor);\n- if (this.options.border && n == 0) {\n- inStyle.borderTopStyle = \"solid\";\n- inStyle.borderTopWidth = \"1px\";\n- inStyle.borderLeftWidth = \"0px\";\n- inStyle.borderRightWidth = \"0px\";\n- inStyle.borderBottomWidth = \"0px\";\n- inStyle.height = \"0px\"; // assumes css compliant box model\n- inStyle.borderColor = borderColor;\n- } else if (borderColor) {\n- inStyle.borderColor = borderColor;\n- inStyle.borderStyle = \"solid\";\n- inStyle.borderWidth = \"0px 1px\";\n- }\n-\n- if (!this.options.compact && (n == (this.options.numSlices - 1))) {\n- inStyle.height = \"2px\";\n+ /**\n+ * Method: setBounds\n+ * Sets the bounds on this instance\n+ *\n+ * Parameters:\n+ * bounds {}\n+ */\n+ setBounds: function(bounds) {\n+ bounds = bounds.clone();\n+ if (this.layer.map.baseLayer.wrapDateLine) {\n+ var worldExtent = this.layer.map.getMaxExtent(),\n+ tolerance = this.layer.map.getResolution();\n+ bounds = bounds.wrapDateLine(worldExtent, {\n+ leftTolerance: tolerance,\n+ rightTolerance: tolerance\n+ });\n }\n- this._setMargin(slice, n, position);\n- this._setBorder(slice, n, position);\n- return slice;\n+ this.bounds = bounds;\n },\n \n- _setOptions: function(options) {\n- this.options = {\n- corners: \"all\",\n- color: \"fromElement\",\n- bgColor: \"fromParent\",\n- blend: true,\n- border: false,\n- compact: false\n- };\n- OpenLayers.Util.extend(this.options, options || {});\n+ /** \n+ * Method: moveTo\n+ * Reposition the tile.\n+ *\n+ * Parameters:\n+ * bounds - {}\n+ * position - {}\n+ * redraw - {Boolean} Call draw method on tile after moving.\n+ * Default is true\n+ */\n+ moveTo: function(bounds, position, redraw) {\n+ if (redraw == null) {\n+ redraw = true;\n+ }\n \n- this.options.numSlices = this.options.compact ? 2 : 4;\n- if (this._isTransparent()) {\n- this.options.blend = false;\n+ this.setBounds(bounds);\n+ this.position = position.clone();\n+ if (redraw) {\n+ this.draw();\n }\n },\n \n- _whichSideTop: function() {\n- if (this._hasString(this.options.corners, \"all\", \"top\")) {\n- return \"\";\n- }\n- if (this.options.corners.indexOf(\"tl\") >= 0 && this.options.corners.indexOf(\"tr\") >= 0) {\n- return \"\";\n- }\n- if (this.options.corners.indexOf(\"tl\") >= 0) {\n- return \"left\";\n- } else if (this.options.corners.indexOf(\"tr\") >= 0) {\n- return \"right\";\n- }\n- return \"\";\n+ /** \n+ * Method: clear\n+ * Clear the tile of any bounds/position-related data so that it can \n+ * be reused in a new location.\n+ */\n+ clear: function(draw) {\n+ // to be extended by subclasses\n },\n \n- _whichSideBottom: function() {\n- if (this._hasString(this.options.corners, \"all\", \"bottom\")) {\n- return \"\";\n- }\n- if (this.options.corners.indexOf(\"bl\") >= 0 && this.options.corners.indexOf(\"br\") >= 0) {\n- return \"\";\n- }\n+ CLASS_NAME: \"OpenLayers.Tile\"\n+});\n+/* ======================================================================\n+ OpenLayers/Util/vendorPrefix.js\n+ ====================================================================== */\n \n- if (this.options.corners.indexOf(\"bl\") >= 0) {\n- return \"left\";\n- } else if (this.options.corners.indexOf(\"br\") >= 0) {\n- return \"right\";\n- }\n- return \"\";\n- },\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- _borderColor: function(color, bgColor) {\n- if (color == \"transparent\") {\n- return bgColor;\n- } else if (this.options.border) {\n- return this.options.border;\n- } else if (this.options.blend) {\n- return this._blend(bgColor, color);\n- } else {\n- return \"\";\n- }\n- },\n+/**\n+ * @requires OpenLayers/SingleFile.js\n+ */\n \n+OpenLayers.Util = OpenLayers.Util || {};\n+/**\n+ * Namespace: OpenLayers.Util.vendorPrefix\n+ * A collection of utility functions to detect vendor prefixed features\n+ */\n+OpenLayers.Util.vendorPrefix = (function() {\n+ \"use strict\";\n \n- _setMargin: function(el, n, corners) {\n- var marginSize = this._marginSize(n);\n- var whichSide = corners == \"top\" ? this._whichSideTop() : this._whichSideBottom();\n+ var VENDOR_PREFIXES = [\"\", \"O\", \"ms\", \"Moz\", \"Webkit\"],\n+ divStyle = document.createElement(\"div\").style,\n+ cssCache = {},\n+ jsCache = {};\n \n- if (whichSide == \"left\") {\n- el.style.marginLeft = marginSize + \"px\";\n- el.style.marginRight = \"0px\";\n- } else if (whichSide == \"right\") {\n- el.style.marginRight = marginSize + \"px\";\n- el.style.marginLeft = \"0px\";\n- } else {\n- el.style.marginLeft = marginSize + \"px\";\n- el.style.marginRight = marginSize + \"px\";\n- }\n- },\n \n- _setBorder: function(el, n, corners) {\n- var borderSize = this._borderSize(n);\n- var whichSide = corners == \"top\" ? this._whichSideTop() : this._whichSideBottom();\n- if (whichSide == \"left\") {\n- el.style.borderLeftWidth = borderSize + \"px\";\n- el.style.borderRightWidth = \"0px\";\n- } else if (whichSide == \"right\") {\n- el.style.borderRightWidth = borderSize + \"px\";\n- el.style.borderLeftWidth = \"0px\";\n- } else {\n- el.style.borderLeftWidth = borderSize + \"px\";\n- el.style.borderRightWidth = borderSize + \"px\";\n- }\n- if (this.options.border != false) {\n- el.style.borderLeftWidth = borderSize + \"px\";\n- el.style.borderRightWidth = borderSize + \"px\";\n+ /**\n+ * Function: domToCss\n+ * Converts a upper camel case DOM style property name to a CSS property\n+ * i.e. transformOrigin -> transform-origin\n+ * or WebkitTransformOrigin -> -webkit-transform-origin\n+ *\n+ * Parameters:\n+ * prefixedDom - {String} The property to convert\n+ *\n+ * Returns:\n+ * {String} The CSS property\n+ */\n+ function domToCss(prefixedDom) {\n+ if (!prefixedDom) {\n+ return null;\n }\n- },\n+ return prefixedDom.\n+ replace(/([A-Z])/g, function(c) {\n+ return \"-\" + c.toLowerCase();\n+ }).\n+ replace(/^ms-/, \"-ms-\");\n+ }\n \n- _marginSize: function(n) {\n- if (this._isTransparent()) {\n- return 0;\n+ /**\n+ * APIMethod: css\n+ * Detect which property is used for a CSS property\n+ *\n+ * Parameters:\n+ * property - {String} The standard (unprefixed) CSS property name\n+ *\n+ * Returns:\n+ * {String} The standard CSS property, prefixed property or null if not\n+ * supported\n+ */\n+ function css(property) {\n+ if (cssCache[property] === undefined) {\n+ var domProperty = property.\n+ replace(/(-[\\s\\S])/g, function(c) {\n+ return c.charAt(1).toUpperCase();\n+ });\n+ var prefixedDom = style(domProperty);\n+ cssCache[property] = domToCss(prefixedDom);\n }\n- var marginSizes = [5, 3, 2, 1];\n- var blendedMarginSizes = [3, 2, 1, 0];\n- var compactMarginSizes = [2, 1];\n- var smBlendedMarginSizes = [1, 0];\n+ return cssCache[property];\n+ }\n \n- if (this.options.compact && this.options.blend) {\n- return smBlendedMarginSizes[n];\n- } else if (this.options.compact) {\n- return compactMarginSizes[n];\n- } else if (this.options.blend) {\n- return blendedMarginSizes[n];\n- } else {\n- return marginSizes[n];\n- }\n- },\n+ /**\n+ * APIMethod: js\n+ * Detect which property is used for a JS property/method\n+ *\n+ * Parameters:\n+ * obj - {Object} The object to test on\n+ * property - {String} The standard (unprefixed) JS property name\n+ *\n+ * Returns:\n+ * {String} The standard JS property, prefixed property or null if not\n+ * supported\n+ */\n+ function js(obj, property) {\n+ if (jsCache[property] === undefined) {\n+ var tmpProp,\n+ i = 0,\n+ l = VENDOR_PREFIXES.length,\n+ prefix,\n+ isStyleObj = (typeof obj.cssText !== \"undefined\");\n \n- _borderSize: function(n) {\n- var transparentBorderSizes = [5, 3, 2, 1];\n- var blendedBorderSizes = [2, 1, 1, 1];\n- var compactBorderSizes = [1, 0];\n- var actualBorderSizes = [0, 2, 0, 0];\n+ jsCache[property] = null;\n+ for (; i < l; i++) {\n+ prefix = VENDOR_PREFIXES[i];\n+ if (prefix) {\n+ if (!isStyleObj) {\n+ // js prefix should be lower-case, while style\n+ // properties have upper case on first character\n+ prefix = prefix.toLowerCase();\n+ }\n+ tmpProp = prefix + property.charAt(0).toUpperCase() + property.slice(1);\n+ } else {\n+ tmpProp = property;\n+ }\n \n- if (this.options.compact && (this.options.blend || this._isTransparent())) {\n- return 1;\n- } else if (this.options.compact) {\n- return compactBorderSizes[n];\n- } else if (this.options.blend) {\n- return blendedBorderSizes[n];\n- } else if (this.options.border) {\n- return actualBorderSizes[n];\n- } else if (this._isTransparent()) {\n- return transparentBorderSizes[n];\n+ if (obj[tmpProp] !== undefined) {\n+ jsCache[property] = tmpProp;\n+ break;\n+ }\n+ }\n }\n- return 0;\n- },\n+ return jsCache[property];\n+ }\n \n- _hasString: function(str) {\n- for (var i = 1; i < arguments.length; i++)\n- if (str.indexOf(arguments[i]) >= 0) {\n- return true;\n- } return false;\n- },\n- _blend: function(c1, c2) {\n- var cc1 = OpenLayers.Rico.Color.createFromHex(c1);\n- cc1.blend(OpenLayers.Rico.Color.createFromHex(c2));\n- return cc1;\n- },\n- _background: function(el) {\n- try {\n- return OpenLayers.Rico.Color.createColorFromBackground(el).asHex();\n- } catch (err) {\n- return \"#ffffff\";\n- }\n- },\n- _isTransparent: function() {\n- return this.options.color == \"transparent\";\n- },\n- _isTopRounded: function() {\n- return this._hasString(this.options.corners, \"all\", \"top\", \"tl\", \"tr\");\n- },\n- _isBottomRounded: function() {\n- return this._hasString(this.options.corners, \"all\", \"bottom\", \"bl\", \"br\");\n- },\n- _hasSingleTextChild: function(el) {\n- return el.childNodes.length == 1 && el.childNodes[0].nodeType == 3;\n+ /**\n+ * APIMethod: style\n+ * Detect which property is used for a DOM style property\n+ *\n+ * Parameters:\n+ * property - {String} The standard (unprefixed) style property name\n+ *\n+ * Returns:\n+ * {String} The standard style property, prefixed property or null if not\n+ * supported\n+ */\n+ function style(property) {\n+ return js(divStyle, property);\n }\n-};\n+\n+ return {\n+ css: css,\n+ js: js,\n+ style: style,\n+\n+ // used for testing\n+ cssCache: cssCache,\n+ jsCache: jsCache\n+ };\n+}());\n /* ======================================================================\n OpenLayers/Events.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n@@ -6259,4625 +6168,996 @@\n \n OpenLayers.Event.observe(element, 'MSPointerUp', cb);\n },\n \n CLASS_NAME: \"OpenLayers.Events\"\n });\n /* ======================================================================\n- OpenLayers/Request/XMLHttpRequest.js\n+ OpenLayers/Animation.js\n ====================================================================== */\n \n-// XMLHttpRequest.js Copyright (C) 2010 Sergey Ilinsky (http://www.ilinsky.com)\n-//\n-// Licensed under the Apache License, Version 2.0 (the \"License\");\n-// you may not use this file except in compliance with the License.\n-// You may obtain a copy of the License at\n-//\n-// http://www.apache.org/licenses/LICENSE-2.0\n-//\n-// Unless required by applicable law or agreed to in writing, software\n-// distributed under the License is distributed on an \"AS IS\" BASIS,\n-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n-// See the License for the specific language governing permissions and\n-// limitations under the License.\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n /**\n- * @requires OpenLayers/Request.js\n+ * @requires OpenLayers/SingleFile.js\n+ * @requires OpenLayers/Util/vendorPrefix.js\n */\n \n-(function() {\n-\n- // Save reference to earlier defined object implementation (if any)\n- var oXMLHttpRequest = window.XMLHttpRequest;\n-\n- // Define on browser type\n- var bGecko = !!window.controllers,\n- bIE = window.document.all && !window.opera,\n- bIE7 = bIE && window.navigator.userAgent.match(/MSIE 7.0/);\n-\n- // Enables \"XMLHttpRequest()\" call next to \"new XMLHttpReques()\"\n- function fXMLHttpRequest() {\n- this._object = oXMLHttpRequest && !bIE7 ? new oXMLHttpRequest : new window.ActiveXObject(\"Microsoft.XMLHTTP\");\n- this._listeners = [];\n- };\n-\n- // Constructor\n- function cXMLHttpRequest() {\n- return new fXMLHttpRequest;\n- };\n- cXMLHttpRequest.prototype = fXMLHttpRequest.prototype;\n-\n- // BUGFIX: Firefox with Firebug installed would break pages if not executed\n- if (bGecko && oXMLHttpRequest.wrapped)\n- cXMLHttpRequest.wrapped = oXMLHttpRequest.wrapped;\n-\n- // Constants\n- cXMLHttpRequest.UNSENT = 0;\n- cXMLHttpRequest.OPENED = 1;\n- cXMLHttpRequest.HEADERS_RECEIVED = 2;\n- cXMLHttpRequest.LOADING = 3;\n- cXMLHttpRequest.DONE = 4;\n-\n- // Public Properties\n- cXMLHttpRequest.prototype.readyState = cXMLHttpRequest.UNSENT;\n- cXMLHttpRequest.prototype.responseText = '';\n- cXMLHttpRequest.prototype.responseXML = null;\n- cXMLHttpRequest.prototype.status = 0;\n- cXMLHttpRequest.prototype.statusText = '';\n-\n- // Priority proposal\n- cXMLHttpRequest.prototype.priority = \"NORMAL\";\n-\n- // Instance-level Events Handlers\n- cXMLHttpRequest.prototype.onreadystatechange = null;\n-\n- // Class-level Events Handlers\n- cXMLHttpRequest.onreadystatechange = null;\n- cXMLHttpRequest.onopen = null;\n- cXMLHttpRequest.onsend = null;\n- cXMLHttpRequest.onabort = null;\n-\n- // Public Methods\n- cXMLHttpRequest.prototype.open = function(sMethod, sUrl, bAsync, sUser, sPassword) {\n- // Delete headers, required when object is reused\n- delete this._headers;\n-\n- // When bAsync parameter value is omitted, use true as default\n- if (arguments.length < 3)\n- bAsync = true;\n-\n- // Save async parameter for fixing Gecko bug with missing readystatechange in synchronous requests\n- this._async = bAsync;\n+/**\n+ * Namespace: OpenLayers.Animation\n+ * A collection of utility functions for executing methods that repaint a \n+ * portion of the browser window. These methods take advantage of the\n+ * browser's scheduled repaints where requestAnimationFrame is available.\n+ */\n+OpenLayers.Animation = (function(window) {\n \n- // Set the onreadystatechange handler\n- var oRequest = this,\n- nState = this.readyState,\n- fOnUnload;\n+ /**\n+ * Property: isNative\n+ * {Boolean} true if a native requestAnimationFrame function is available\n+ */\n+ var requestAnimationFrame = OpenLayers.Util.vendorPrefix.js(window, \"requestAnimationFrame\");\n+ var isNative = !!(requestAnimationFrame);\n \n- // BUGFIX: IE - memory leak on page unload (inter-page leak)\n- if (bIE && bAsync) {\n- fOnUnload = function() {\n- if (nState != cXMLHttpRequest.DONE) {\n- fCleanTransport(oRequest);\n- // Safe to abort here since onreadystatechange handler removed\n- oRequest.abort();\n- }\n+ /**\n+ * Function: requestFrame\n+ * Schedule a function to be called at the next available animation frame.\n+ * Uses the native method where available. Where requestAnimationFrame is\n+ * not available, setTimeout will be called with a 16ms delay.\n+ *\n+ * Parameters:\n+ * callback - {Function} The function to be called at the next animation frame.\n+ * element - {DOMElement} Optional element that visually bounds the animation.\n+ */\n+ var requestFrame = (function() {\n+ var request = window[requestAnimationFrame] ||\n+ function(callback, element) {\n+ window.setTimeout(callback, 16);\n };\n- window.attachEvent(\"onunload\", fOnUnload);\n- }\n-\n- // Add method sniffer\n- if (cXMLHttpRequest.onopen)\n- cXMLHttpRequest.onopen.apply(this, arguments);\n-\n- if (arguments.length > 4)\n- this._object.open(sMethod, sUrl, bAsync, sUser, sPassword);\n- else\n- if (arguments.length > 3)\n- this._object.open(sMethod, sUrl, bAsync, sUser);\n- else\n- this._object.open(sMethod, sUrl, bAsync);\n-\n- this.readyState = cXMLHttpRequest.OPENED;\n- fReadyStateChange(this);\n-\n- this._object.onreadystatechange = function() {\n- if (bGecko && !bAsync)\n- return;\n-\n- // Synchronize state\n- oRequest.readyState = oRequest._object.readyState;\n-\n- //\n- fSynchronizeValues(oRequest);\n-\n- // BUGFIX: Firefox fires unnecessary DONE when aborting\n- if (oRequest._aborted) {\n- // Reset readyState to UNSENT\n- oRequest.readyState = cXMLHttpRequest.UNSENT;\n-\n- // Return now\n- return;\n- }\n-\n- if (oRequest.readyState == cXMLHttpRequest.DONE) {\n- // Free up queue\n- delete oRequest._data;\n- /* if (bAsync)\n- fQueue_remove(oRequest);*/\n- //\n- fCleanTransport(oRequest);\n- // Uncomment this block if you need a fix for IE cache\n- /*\n- // BUGFIX: IE - cache issue\n- if (!oRequest._object.getResponseHeader(\"Date\")) {\n- // Save object to cache\n- oRequest._cached = oRequest._object;\n-\n- // Instantiate a new transport object\n- cXMLHttpRequest.call(oRequest);\n-\n- // Re-send request\n- if (sUser) {\n- if (sPassword)\n- oRequest._object.open(sMethod, sUrl, bAsync, sUser, sPassword);\n- else\n- oRequest._object.open(sMethod, sUrl, bAsync, sUser);\n- }\n- else\n- oRequest._object.open(sMethod, sUrl, bAsync);\n- oRequest._object.setRequestHeader(\"If-Modified-Since\", oRequest._cached.getResponseHeader(\"Last-Modified\") || new window.Date(0));\n- // Copy headers set\n- if (oRequest._headers)\n- for (var sHeader in oRequest._headers)\n- if (typeof oRequest._headers[sHeader] == \"string\") // Some frameworks prototype objects with functions\n- oRequest._object.setRequestHeader(sHeader, oRequest._headers[sHeader]);\n-\n- oRequest._object.onreadystatechange = function() {\n- // Synchronize state\n- oRequest.readyState = oRequest._object.readyState;\n-\n- if (oRequest._aborted) {\n- //\n- oRequest.readyState = cXMLHttpRequest.UNSENT;\n-\n- // Return\n- return;\n- }\n-\n- if (oRequest.readyState == cXMLHttpRequest.DONE) {\n- // Clean Object\n- fCleanTransport(oRequest);\n-\n- // get cached request\n- if (oRequest.status == 304)\n- oRequest._object = oRequest._cached;\n-\n- //\n- delete oRequest._cached;\n-\n- //\n- fSynchronizeValues(oRequest);\n-\n- //\n- fReadyStateChange(oRequest);\n-\n- // BUGFIX: IE - memory leak in interrupted\n- if (bIE && bAsync)\n- window.detachEvent(\"onunload\", fOnUnload);\n- }\n- };\n- oRequest._object.send(null);\n-\n- // Return now - wait until re-sent request is finished\n- return;\n- };\n- */\n- // BUGFIX: IE - memory leak in interrupted\n- if (bIE && bAsync)\n- window.detachEvent(\"onunload\", fOnUnload);\n- }\n-\n- // BUGFIX: Some browsers (Internet Explorer, Gecko) fire OPEN readystate twice\n- if (nState != oRequest.readyState)\n- fReadyStateChange(oRequest);\n-\n- nState = oRequest.readyState;\n- }\n- };\n-\n- function fXMLHttpRequest_send(oRequest) {\n- oRequest._object.send(oRequest._data);\n-\n- // BUGFIX: Gecko - missing readystatechange calls in synchronous requests\n- if (bGecko && !oRequest._async) {\n- oRequest.readyState = cXMLHttpRequest.OPENED;\n-\n- // Synchronize state\n- fSynchronizeValues(oRequest);\n-\n- // Simulate missing states\n- while (oRequest.readyState < cXMLHttpRequest.DONE) {\n- oRequest.readyState++;\n- fReadyStateChange(oRequest);\n- // Check if we are aborted\n- if (oRequest._aborted)\n- return;\n- }\n- }\n- };\n- cXMLHttpRequest.prototype.send = function(vData) {\n- // Add method sniffer\n- if (cXMLHttpRequest.onsend)\n- cXMLHttpRequest.onsend.apply(this, arguments);\n-\n- if (!arguments.length)\n- vData = null;\n-\n- // BUGFIX: Safari - fails sending documents created/modified dynamically, so an explicit serialization required\n- // BUGFIX: IE - rewrites any custom mime-type to \"text/xml\" in case an XMLNode is sent\n- // BUGFIX: Gecko - fails sending Element (this is up to the implementation either to standard)\n- if (vData && vData.nodeType) {\n- vData = window.XMLSerializer ? new window.XMLSerializer().serializeToString(vData) : vData.xml;\n- if (!this._headers[\"Content-Type\"])\n- this._object.setRequestHeader(\"Content-Type\", \"application/xml\");\n- }\n-\n- this._data = vData;\n- /*\n- // Add to queue\n- if (this._async)\n- fQueue_add(this);\n- else*/\n- fXMLHttpRequest_send(this);\n- };\n- cXMLHttpRequest.prototype.abort = function() {\n- // Add method sniffer\n- if (cXMLHttpRequest.onabort)\n- cXMLHttpRequest.onabort.apply(this, arguments);\n-\n- // BUGFIX: Gecko - unnecessary DONE when aborting\n- if (this.readyState > cXMLHttpRequest.UNSENT)\n- this._aborted = true;\n-\n- this._object.abort();\n-\n- // BUGFIX: IE - memory leak\n- fCleanTransport(this);\n-\n- this.readyState = cXMLHttpRequest.UNSENT;\n-\n- delete this._data;\n- /* if (this._async)\n- fQueue_remove(this);*/\n- };\n- cXMLHttpRequest.prototype.getAllResponseHeaders = function() {\n- return this._object.getAllResponseHeaders();\n- };\n- cXMLHttpRequest.prototype.getResponseHeader = function(sName) {\n- return this._object.getResponseHeader(sName);\n- };\n- cXMLHttpRequest.prototype.setRequestHeader = function(sName, sValue) {\n- // BUGFIX: IE - cache issue\n- if (!this._headers)\n- this._headers = {};\n- this._headers[sName] = sValue;\n-\n- return this._object.setRequestHeader(sName, sValue);\n- };\n-\n- // EventTarget interface implementation\n- cXMLHttpRequest.prototype.addEventListener = function(sName, fHandler, bUseCapture) {\n- for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)\n- if (oListener[0] == sName && oListener[1] == fHandler && oListener[2] == bUseCapture)\n- return;\n- // Add listener\n- this._listeners.push([sName, fHandler, bUseCapture]);\n- };\n-\n- cXMLHttpRequest.prototype.removeEventListener = function(sName, fHandler, bUseCapture) {\n- for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)\n- if (oListener[0] == sName && oListener[1] == fHandler && oListener[2] == bUseCapture)\n- break;\n- // Remove listener\n- if (oListener)\n- this._listeners.splice(nIndex, 1);\n- };\n-\n- cXMLHttpRequest.prototype.dispatchEvent = function(oEvent) {\n- var oEventPseudo = {\n- 'type': oEvent.type,\n- 'target': this,\n- 'currentTarget': this,\n- 'eventPhase': 2,\n- 'bubbles': oEvent.bubbles,\n- 'cancelable': oEvent.cancelable,\n- 'timeStamp': oEvent.timeStamp,\n- 'stopPropagation': function() {}, // There is no flow\n- 'preventDefault': function() {}, // There is no default action\n- 'initEvent': function() {} // Original event object should be initialized\n- };\n-\n- // Execute onreadystatechange\n- if (oEventPseudo.type == \"readystatechange\" && this.onreadystatechange)\n- (this.onreadystatechange.handleEvent || this.onreadystatechange).apply(this, [oEventPseudo]);\n-\n- // Execute listeners\n- for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)\n- if (oListener[0] == oEventPseudo.type && !oListener[2])\n- (oListener[1].handleEvent || oListener[1]).apply(this, [oEventPseudo]);\n- };\n-\n- //\n- cXMLHttpRequest.prototype.toString = function() {\n- return '[' + \"object\" + ' ' + \"XMLHttpRequest\" + ']';\n- };\n-\n- cXMLHttpRequest.toString = function() {\n- return '[' + \"XMLHttpRequest\" + ']';\n- };\n-\n- // Helper function\n- function fReadyStateChange(oRequest) {\n- // Sniffing code\n- if (cXMLHttpRequest.onreadystatechange)\n- cXMLHttpRequest.onreadystatechange.apply(oRequest);\n-\n- // Fake event\n- oRequest.dispatchEvent({\n- 'type': \"readystatechange\",\n- 'bubbles': false,\n- 'cancelable': false,\n- 'timeStamp': new Date + 0\n- });\n- };\n-\n- function fGetDocument(oRequest) {\n- var oDocument = oRequest.responseXML,\n- sResponse = oRequest.responseText;\n- // Try parsing responseText\n- if (bIE && sResponse && oDocument && !oDocument.documentElement && oRequest.getResponseHeader(\"Content-Type\").match(/[^\\/]+\\/[^\\+]+\\+xml/)) {\n- oDocument = new window.ActiveXObject(\"Microsoft.XMLDOM\");\n- oDocument.async = false;\n- oDocument.validateOnParse = false;\n- oDocument.loadXML(sResponse);\n- }\n- // Check if there is no error in document\n- if (oDocument)\n- if ((bIE && oDocument.parseError != 0) || !oDocument.documentElement || (oDocument.documentElement && oDocument.documentElement.tagName == \"parsererror\"))\n- return null;\n- return oDocument;\n- };\n-\n- function fSynchronizeValues(oRequest) {\n- try {\n- oRequest.responseText = oRequest._object.responseText;\n- } catch (e) {}\n- try {\n- oRequest.responseXML = fGetDocument(oRequest._object);\n- } catch (e) {}\n- try {\n- oRequest.status = oRequest._object.status;\n- } catch (e) {}\n- try {\n- oRequest.statusText = oRequest._object.statusText;\n- } catch (e) {}\n- };\n-\n- function fCleanTransport(oRequest) {\n- // BUGFIX: IE - memory leak (on-page leak)\n- oRequest._object.onreadystatechange = new window.Function;\n- };\n- /*\n- // Queue manager\n- var oQueuePending = {\"CRITICAL\":[],\"HIGH\":[],\"NORMAL\":[],\"LOW\":[],\"LOWEST\":[]},\n- aQueueRunning = [];\n- function fQueue_add(oRequest) {\n- oQueuePending[oRequest.priority in oQueuePending ? oRequest.priority : \"NORMAL\"].push(oRequest);\n- //\n- setTimeout(fQueue_process);\n+ // bind to window to avoid illegal invocation of native function\n+ return function(callback, element) {\n+ request.apply(window, [callback, element]);\n };\n+ })();\n \n- function fQueue_remove(oRequest) {\n- for (var nIndex = 0, bFound = false; nIndex < aQueueRunning.length; nIndex++)\n- if (bFound)\n- aQueueRunning[nIndex - 1] = aQueueRunning[nIndex];\n- else\n- if (aQueueRunning[nIndex] == oRequest)\n- bFound = true;\n- if (bFound)\n- aQueueRunning.length--;\n- //\n- setTimeout(fQueue_process);\n- };\n+ // private variables for animation loops\n+ var counter = 0;\n+ var loops = {};\n \n- function fQueue_process() {\n- if (aQueueRunning.length < 6) {\n- for (var sPriority in oQueuePending) {\n- if (oQueuePending[sPriority].length) {\n- var oRequest = oQueuePending[sPriority][0];\n- oQueuePending[sPriority] = oQueuePending[sPriority].slice(1);\n- //\n- aQueueRunning.push(oRequest);\n- // Send request\n- fXMLHttpRequest_send(oRequest);\n- break;\n- }\n+ /**\n+ * Function: start\n+ * Executes a method with in series for some \n+ * duration.\n+ *\n+ * Parameters:\n+ * callback - {Function} The function to be called at the next animation frame.\n+ * duration - {Number} Optional duration for the loop. If not provided, the\n+ * animation loop will execute indefinitely.\n+ * element - {DOMElement} Optional element that visually bounds the animation.\n+ *\n+ * Returns:\n+ * {Number} Identifier for the animation loop. Used to stop animations with\n+ * .\n+ */\n+ function start(callback, duration, element) {\n+ duration = duration > 0 ? duration : Number.POSITIVE_INFINITY;\n+ var id = ++counter;\n+ var start = +new Date;\n+ loops[id] = function() {\n+ if (loops[id] && +new Date - start <= duration) {\n+ callback();\n+ if (loops[id]) {\n+ requestFrame(loops[id], element);\n }\n+ } else {\n+ delete loops[id];\n }\n };\n- */\n- // Internet Explorer 5.0 (missing apply)\n- if (!window.Function.prototype.apply) {\n- window.Function.prototype.apply = function(oRequest, oArguments) {\n- if (!oArguments)\n- oArguments = [];\n- oRequest.__func = this;\n- oRequest.__func(oArguments[0], oArguments[1], oArguments[2], oArguments[3], oArguments[4]);\n- delete oRequest.__func;\n- };\n- };\n+ requestFrame(loops[id], element);\n+ return id;\n+ }\n \n- // Register new object with window\n /**\n- * Class: OpenLayers.Request.XMLHttpRequest\n- * Standard-compliant (W3C) cross-browser implementation of the\n- * XMLHttpRequest object. From\n- * http://code.google.com/p/xmlhttprequest/.\n+ * Function: stop\n+ * Terminates an animation loop started with .\n+ *\n+ * Parameters:\n+ * id - {Number} Identifier returned from .\n */\n- if (!OpenLayers.Request) {\n- /**\n- * This allows for OpenLayers/Request.js to be included\n- * before or after this script.\n- */\n- OpenLayers.Request = {};\n+ function stop(id) {\n+ delete loops[id];\n }\n- OpenLayers.Request.XMLHttpRequest = cXMLHttpRequest;\n-})();\n+\n+ return {\n+ isNative: isNative,\n+ requestFrame: requestFrame,\n+ start: start,\n+ stop: stop\n+ };\n+\n+})(window);\n /* ======================================================================\n- OpenLayers/Request.js\n+ OpenLayers/Tween.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Events.js\n- * @requires OpenLayers/Request/XMLHttpRequest.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Animation.js\n */\n \n /**\n- * TODO: deprecate me\n- * Use OpenLayers.Request.proxy instead.\n+ * Namespace: OpenLayers.Tween\n */\n-OpenLayers.ProxyHost = \"\";\n+OpenLayers.Tween = OpenLayers.Class({\n \n-/**\n- * Namespace: OpenLayers.Request\n- * The OpenLayers.Request namespace contains convenience methods for working\n- * with XMLHttpRequests. These methods work with a cross-browser\n- * W3C compliant class.\n- */\n-if (!OpenLayers.Request) {\n /**\n- * This allows for OpenLayers/Request/XMLHttpRequest.js to be included\n- * before or after this script.\n+ * APIProperty: easing\n+ * {(Function)} Easing equation used for the animation\n+ * Defaultly set to OpenLayers.Easing.Expo.easeOut\n */\n- OpenLayers.Request = {};\n-}\n-OpenLayers.Util.extend(OpenLayers.Request, {\n+ easing: null,\n \n /**\n- * Constant: DEFAULT_CONFIG\n- * {Object} Default configuration for all requests.\n+ * APIProperty: begin\n+ * {Object} Values to start the animation with\n */\n- DEFAULT_CONFIG: {\n- method: \"GET\",\n- url: window.location.href,\n- async: true,\n- user: undefined,\n- password: undefined,\n- params: null,\n- proxy: OpenLayers.ProxyHost,\n- headers: {},\n- data: null,\n- callback: function() {},\n- success: null,\n- failure: null,\n- scope: null\n- },\n+ begin: null,\n \n /**\n- * Constant: URL_SPLIT_REGEX\n+ * APIProperty: finish\n+ * {Object} Values to finish the animation with\n */\n- URL_SPLIT_REGEX: /([^:]*:)\\/\\/([^:]*:?[^@]*@)?([^:\\/\\?]*):?([^\\/\\?]*)/,\n+ finish: null,\n \n /**\n- * APIProperty: events\n- * {} An events object that handles all \n- * events on the {} object.\n- *\n- * All event listeners will receive an event object with three properties:\n- * request - {} The request object.\n- * config - {Object} The config object sent to the specific request method.\n- * requestUrl - {String} The request url.\n- * \n- * Supported event types:\n- * complete - Triggered when we have a response from the request, if a\n- * listener returns false, no further response processing will take\n- * place.\n- * success - Triggered when the HTTP response has a success code (200-299).\n- * failure - Triggered when the HTTP response does not have a success code.\n+ * APIProperty: duration\n+ * {int} duration of the tween (number of steps)\n */\n- events: new OpenLayers.Events(this),\n+ duration: null,\n \n /**\n- * Method: makeSameOrigin\n- * Using the specified proxy, returns a same origin url of the provided url.\n- *\n- * Parameters:\n- * url - {String} An arbitrary url\n- * proxy {String|Function} The proxy to use to make the provided url a\n- * same origin url.\n- *\n- * Returns\n- * {String} the same origin url. If no proxy is provided, the returned url\n- * will be the same as the provided url.\n+ * APIProperty: callbacks\n+ * {Object} An object with start, eachStep and done properties whose values\n+ * are functions to be call during the animation. They are passed the\n+ * current computed value as argument.\n */\n- makeSameOrigin: function(url, proxy) {\n- var sameOrigin = url.indexOf(\"http\") !== 0;\n- var urlParts = !sameOrigin && url.match(this.URL_SPLIT_REGEX);\n- if (urlParts) {\n- var location = window.location;\n- sameOrigin =\n- urlParts[1] == location.protocol &&\n- urlParts[3] == location.hostname;\n- var uPort = urlParts[4],\n- lPort = location.port;\n- if (uPort != 80 && uPort != \"\" || lPort != \"80\" && lPort != \"\") {\n- sameOrigin = sameOrigin && uPort == lPort;\n- }\n- }\n- if (!sameOrigin) {\n- if (proxy) {\n- if (typeof proxy == \"function\") {\n- url = proxy(url);\n- } else {\n- url = proxy + encodeURIComponent(url);\n- }\n- }\n- }\n- return url;\n- },\n+ callbacks: null,\n \n /**\n- * APIMethod: issue\n- * Create a new XMLHttpRequest object, open it, set any headers, bind\n- * a callback to done state, and send any data. It is recommended that\n- * you use one , , , , , or .\n- * This method is only documented to provide detail on the configuration\n- * options available to all request methods.\n- *\n- * Parameters:\n- * config - {Object} Object containing properties for configuring the\n- * request. Allowed configuration properties are described below.\n- * This object is modified and should not be reused.\n- *\n- * Allowed config properties:\n- * method - {String} One of GET, POST, PUT, DELETE, HEAD, or\n- * OPTIONS. Default is GET.\n- * url - {String} URL for the request.\n- * async - {Boolean} Open an asynchronous request. Default is true.\n- * user - {String} User for relevant authentication scheme. Set\n- * to null to clear current user.\n- * password - {String} Password for relevant authentication scheme.\n- * Set to null to clear current password.\n- * proxy - {String} Optional proxy. Defaults to\n- * .\n- * params - {Object} Any key:value pairs to be appended to the\n- * url as a query string. Assumes url doesn't already include a query\n- * string or hash. Typically, this is only appropriate for \n- * requests where the query string will be appended to the url.\n- * Parameter values that are arrays will be\n- * concatenated with a comma (note that this goes against form-encoding)\n- * as is done with .\n- * headers - {Object} Object with header:value pairs to be set on\n- * the request.\n- * data - {String | Document} Optional data to send with the request.\n- * Typically, this is only used with and requests.\n- * Make sure to provide the appropriate \"Content-Type\" header for your\n- * data. For and requests, the content type defaults to\n- * \"application-xml\". If your data is a different content type, or\n- * if you are using a different HTTP method, set the \"Content-Type\"\n- * header to match your data type.\n- * callback - {Function} Function to call when request is done.\n- * To determine if the request failed, check request.status (200\n- * indicates success).\n- * success - {Function} Optional function to call if request status is in\n- * the 200s. This will be called in addition to callback above and\n- * would typically only be used as an alternative.\n- * failure - {Function} Optional function to call if request status is not\n- * in the 200s. This will be called in addition to callback above and\n- * would typically only be used as an alternative.\n- * scope - {Object} If callback is a public method on some object,\n- * set the scope to that object.\n- *\n- * Returns:\n- * {XMLHttpRequest} Request object. To abort the request before a response\n- * is received, call abort() on the request object.\n+ * Property: time\n+ * {int} Step counter\n */\n- issue: function(config) {\n- // apply default config - proxy host may have changed\n- var defaultConfig = OpenLayers.Util.extend(\n- this.DEFAULT_CONFIG, {\n- proxy: OpenLayers.ProxyHost\n- }\n- );\n- config = config || {};\n- config.headers = config.headers || {};\n- config = OpenLayers.Util.applyDefaults(config, defaultConfig);\n- config.headers = OpenLayers.Util.applyDefaults(config.headers, defaultConfig.headers);\n- // Always set the \"X-Requested-With\" header to signal that this request\n- // was issued through the XHR-object. Since header keys are case \n- // insensitive and we want to allow overriding of the \"X-Requested-With\"\n- // header through the user we cannot use applyDefaults, but have to \n- // check manually whether we were called with a \"X-Requested-With\"\n- // header.\n- var customRequestedWithHeader = false,\n- headerKey;\n- for (headerKey in config.headers) {\n- if (config.headers.hasOwnProperty(headerKey)) {\n- if (headerKey.toLowerCase() === 'x-requested-with') {\n- customRequestedWithHeader = true;\n- }\n- }\n- }\n- if (customRequestedWithHeader === false) {\n- // we did not have a custom \"X-Requested-With\" header\n- config.headers['X-Requested-With'] = 'XMLHttpRequest';\n- }\n+ time: null,\n \n- // create request, open, and set headers\n- var request = new OpenLayers.Request.XMLHttpRequest();\n- var url = OpenLayers.Util.urlAppend(config.url,\n- OpenLayers.Util.getParameterString(config.params || {}));\n- url = OpenLayers.Request.makeSameOrigin(url, config.proxy);\n- request.open(\n- config.method, url, config.async, config.user, config.password\n- );\n- for (var header in config.headers) {\n- request.setRequestHeader(header, config.headers[header]);\n- }\n+ /**\n+ * APIProperty: minFrameRate\n+ * {Number} The minimum framerate for animations in frames per second. After\n+ * each step, the time spent in the animation is compared to the calculated\n+ * time at this frame rate. If the animation runs longer than the calculated\n+ * time, the next step is skipped. Default is 30.\n+ */\n+ minFrameRate: null,\n \n- var events = this.events;\n+ /**\n+ * Property: startTime\n+ * {Number} The timestamp of the first execution step. Used for skipping\n+ * frames\n+ */\n+ startTime: null,\n \n- // we want to execute runCallbacks with \"this\" as the\n- // execution scope\n- var self = this;\n+ /**\n+ * Property: animationId\n+ * {int} Loop id returned by OpenLayers.Animation.start\n+ */\n+ animationId: null,\n \n- request.onreadystatechange = function() {\n- if (request.readyState == OpenLayers.Request.XMLHttpRequest.DONE) {\n- var proceed = events.triggerEvent(\n- \"complete\", {\n- request: request,\n- config: config,\n- requestUrl: url\n- }\n- );\n- if (proceed !== false) {\n- self.runCallbacks({\n- request: request,\n- config: config,\n- requestUrl: url\n- });\n- }\n- }\n- };\n+ /**\n+ * Property: playing\n+ * {Boolean} Tells if the easing is currently playing\n+ */\n+ playing: false,\n \n- // send request (optionally with data) and return\n- // call in a timeout for asynchronous requests so the return is\n- // available before readyState == 4 for cached docs\n- if (config.async === false) {\n- request.send(config.data);\n- } else {\n- window.setTimeout(function() {\n- if (request.readyState !== 0) { // W3C: 0-UNSENT\n- request.send(config.data);\n- }\n- }, 0);\n- }\n- return request;\n+ /** \n+ * Constructor: OpenLayers.Tween\n+ * Creates a Tween.\n+ *\n+ * Parameters:\n+ * easing - {(Function)} easing function method to use\n+ */\n+ initialize: function(easing) {\n+ this.easing = (easing) ? easing : OpenLayers.Easing.Expo.easeOut;\n },\n \n /**\n- * Method: runCallbacks\n- * Calls the complete, success and failure callbacks. Application\n- * can listen to the \"complete\" event, have the listener \n- * display a confirm window and always return false, and\n- * execute OpenLayers.Request.runCallbacks if the user\n- * hits \"yes\" in the confirm window.\n- *\n+ * APIMethod: start\n+ * Plays the Tween, and calls the callback method on each step\n+ * \n * Parameters:\n- * options - {Object} Hash containing request, config and requestUrl keys\n+ * begin - {Object} values to start the animation with\n+ * finish - {Object} values to finish the animation with\n+ * duration - {int} duration of the tween (number of steps)\n+ * options - {Object} hash of options (callbacks (start, eachStep, done),\n+ * minFrameRate)\n */\n- runCallbacks: function(options) {\n- var request = options.request;\n- var config = options.config;\n-\n- // bind callbacks to readyState 4 (done)\n- var complete = (config.scope) ?\n- OpenLayers.Function.bind(config.callback, config.scope) :\n- config.callback;\n-\n- // optional success callback\n- var success;\n- if (config.success) {\n- success = (config.scope) ?\n- OpenLayers.Function.bind(config.success, config.scope) :\n- config.success;\n+ start: function(begin, finish, duration, options) {\n+ this.playing = true;\n+ this.begin = begin;\n+ this.finish = finish;\n+ this.duration = duration;\n+ this.callbacks = options.callbacks;\n+ this.minFrameRate = options.minFrameRate || 30;\n+ this.time = 0;\n+ this.startTime = new Date().getTime();\n+ OpenLayers.Animation.stop(this.animationId);\n+ this.animationId = null;\n+ if (this.callbacks && this.callbacks.start) {\n+ this.callbacks.start.call(this, this.begin);\n }\n+ this.animationId = OpenLayers.Animation.start(\n+ OpenLayers.Function.bind(this.play, this)\n+ );\n+ },\n \n- // optional failure callback\n- var failure;\n- if (config.failure) {\n- failure = (config.scope) ?\n- OpenLayers.Function.bind(config.failure, config.scope) :\n- config.failure;\n+ /**\n+ * APIMethod: stop\n+ * Stops the Tween, and calls the done callback\n+ * Doesn't do anything if animation is already finished\n+ */\n+ stop: function() {\n+ if (!this.playing) {\n+ return;\n }\n \n- if (OpenLayers.Util.createUrlObject(config.url).protocol == \"file:\" &&\n- request.responseText) {\n- request.status = 200;\n+ if (this.callbacks && this.callbacks.done) {\n+ this.callbacks.done.call(this, this.finish);\n }\n- complete(request);\n+ OpenLayers.Animation.stop(this.animationId);\n+ this.animationId = null;\n+ this.playing = false;\n+ },\n \n- if (!request.status || (request.status >= 200 && request.status < 300)) {\n- this.events.triggerEvent(\"success\", options);\n- if (success) {\n- success(request);\n+ /**\n+ * Method: play\n+ * Calls the appropriate easing method\n+ */\n+ play: function() {\n+ var value = {};\n+ for (var i in this.begin) {\n+ var b = this.begin[i];\n+ var f = this.finish[i];\n+ if (b == null || f == null || isNaN(b) || isNaN(f)) {\n+ throw new TypeError('invalid value for Tween');\n }\n+\n+ var c = f - b;\n+ value[i] = this.easing.apply(this, [this.time, b, c, this.duration]);\n }\n- if (request.status && (request.status < 200 || request.status >= 300)) {\n- this.events.triggerEvent(\"failure\", options);\n- if (failure) {\n- failure(request);\n+ this.time++;\n+\n+ if (this.callbacks && this.callbacks.eachStep) {\n+ // skip frames if frame rate drops below threshold\n+ if ((new Date().getTime() - this.startTime) / this.time <= 1000 / this.minFrameRate) {\n+ this.callbacks.eachStep.call(this, value);\n }\n }\n+\n+ if (this.time > this.duration) {\n+ this.stop();\n+ }\n },\n \n /**\n- * APIMethod: GET\n- * Send an HTTP GET request. Additional configuration properties are\n- * documented in the method, with the method property set\n- * to GET.\n- *\n- * Parameters:\n- * config - {Object} Object with properties for configuring the request.\n- * See the method for documentation of allowed properties.\n- * This object is modified and should not be reused.\n+ * Create empty functions for all easing methods.\n+ */\n+ CLASS_NAME: \"OpenLayers.Tween\"\n+});\n+\n+/**\n+ * Namespace: OpenLayers.Easing\n+ * \n+ * Credits:\n+ * Easing Equations by Robert Penner, \n+ */\n+OpenLayers.Easing = {\n+ /**\n+ * Create empty functions for all easing methods.\n+ */\n+ CLASS_NAME: \"OpenLayers.Easing\"\n+};\n+\n+/**\n+ * Namespace: OpenLayers.Easing.Linear\n+ */\n+OpenLayers.Easing.Linear = {\n+\n+ /**\n+ * Function: easeIn\n * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n * Returns:\n- * {XMLHttpRequest} Request object.\n+ * {Float}\n */\n- GET: function(config) {\n- config = OpenLayers.Util.extend(config, {\n- method: \"GET\"\n- });\n- return OpenLayers.Request.issue(config);\n+ easeIn: function(t, b, c, d) {\n+ return c * t / d + b;\n },\n \n /**\n- * APIMethod: POST\n- * Send a POST request. Additional configuration properties are\n- * documented in the method, with the method property set\n- * to POST and \"Content-Type\" header set to \"application/xml\".\n- *\n- * Parameters:\n- * config - {Object} Object with properties for configuring the request.\n- * See the method for documentation of allowed properties. The\n- * default \"Content-Type\" header will be set to \"application-xml\" if\n- * none is provided. This object is modified and should not be reused.\n+ * Function: easeOut\n * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n * Returns:\n- * {XMLHttpRequest} Request object.\n+ * {Float}\n */\n- POST: function(config) {\n- config = OpenLayers.Util.extend(config, {\n- method: \"POST\"\n- });\n- // set content type to application/xml if it isn't already set\n- config.headers = config.headers ? config.headers : {};\n- if (!(\"CONTENT-TYPE\" in OpenLayers.Util.upperCaseObject(config.headers))) {\n- config.headers[\"Content-Type\"] = \"application/xml\";\n- }\n- return OpenLayers.Request.issue(config);\n+ easeOut: function(t, b, c, d) {\n+ return c * t / d + b;\n },\n \n /**\n- * APIMethod: PUT\n- * Send an HTTP PUT request. Additional configuration properties are\n- * documented in the method, with the method property set\n- * to PUT and \"Content-Type\" header set to \"application/xml\".\n- *\n- * Parameters:\n- * config - {Object} Object with properties for configuring the request.\n- * See the method for documentation of allowed properties. The\n- * default \"Content-Type\" header will be set to \"application-xml\" if\n- * none is provided. This object is modified and should not be reused.\n+ * Function: easeInOut\n * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n * Returns:\n- * {XMLHttpRequest} Request object.\n+ * {Float}\n */\n- PUT: function(config) {\n- config = OpenLayers.Util.extend(config, {\n- method: \"PUT\"\n- });\n- // set content type to application/xml if it isn't already set\n- config.headers = config.headers ? config.headers : {};\n- if (!(\"CONTENT-TYPE\" in OpenLayers.Util.upperCaseObject(config.headers))) {\n- config.headers[\"Content-Type\"] = \"application/xml\";\n- }\n- return OpenLayers.Request.issue(config);\n+ easeInOut: function(t, b, c, d) {\n+ return c * t / d + b;\n },\n \n+ CLASS_NAME: \"OpenLayers.Easing.Linear\"\n+};\n+\n+/**\n+ * Namespace: OpenLayers.Easing.Expo\n+ */\n+OpenLayers.Easing.Expo = {\n+\n /**\n- * APIMethod: DELETE\n- * Send an HTTP DELETE request. Additional configuration properties are\n- * documented in the method, with the method property set\n- * to DELETE.\n- *\n- * Parameters:\n- * config - {Object} Object with properties for configuring the request.\n- * See the method for documentation of allowed properties.\n- * This object is modified and should not be reused.\n+ * Function: easeIn\n * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n * Returns:\n- * {XMLHttpRequest} Request object.\n+ * {Float}\n */\n- DELETE: function(config) {\n- config = OpenLayers.Util.extend(config, {\n- method: \"DELETE\"\n- });\n- return OpenLayers.Request.issue(config);\n+ easeIn: function(t, b, c, d) {\n+ return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;\n },\n \n /**\n- * APIMethod: HEAD\n- * Send an HTTP HEAD request. Additional configuration properties are\n- * documented in the method, with the method property set\n- * to HEAD.\n- *\n+ * Function: easeOut\n+ * \n * Parameters:\n- * config - {Object} Object with properties for configuring the request.\n- * See the method for documentation of allowed properties.\n- * This object is modified and should not be reused.\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n+ * Returns:\n+ * {Float}\n+ */\n+ easeOut: function(t, b, c, d) {\n+ return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;\n+ },\n+\n+ /**\n+ * Function: easeInOut\n * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n * Returns:\n- * {XMLHttpRequest} Request object.\n+ * {Float}\n */\n- HEAD: function(config) {\n- config = OpenLayers.Util.extend(config, {\n- method: \"HEAD\"\n- });\n- return OpenLayers.Request.issue(config);\n+ easeInOut: function(t, b, c, d) {\n+ if (t == 0) return b;\n+ if (t == d) return b + c;\n+ if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;\n+ return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;\n },\n \n+ CLASS_NAME: \"OpenLayers.Easing.Expo\"\n+};\n+\n+/**\n+ * Namespace: OpenLayers.Easing.Quad\n+ */\n+OpenLayers.Easing.Quad = {\n+\n /**\n- * APIMethod: OPTIONS\n- * Send an HTTP OPTIONS request. Additional configuration properties are\n- * documented in the method, with the method property set\n- * to OPTIONS.\n+ * Function: easeIn\n+ * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n *\n+ * Returns:\n+ * {Float}\n+ */\n+ easeIn: function(t, b, c, d) {\n+ return c * (t /= d) * t + b;\n+ },\n+\n+ /**\n+ * Function: easeOut\n+ * \n * Parameters:\n- * config - {Object} Object with properties for configuring the request.\n- * See the method for documentation of allowed properties.\n- * This object is modified and should not be reused.\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n+ * Returns:\n+ * {Float}\n+ */\n+ easeOut: function(t, b, c, d) {\n+ return -c * (t /= d) * (t - 2) + b;\n+ },\n+\n+ /**\n+ * Function: easeInOut\n * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n * Returns:\n- * {XMLHttpRequest} Request object.\n+ * {Float}\n */\n- OPTIONS: function(config) {\n- config = OpenLayers.Util.extend(config, {\n- method: \"OPTIONS\"\n- });\n- return OpenLayers.Request.issue(config);\n- }\n+ easeInOut: function(t, b, c, d) {\n+ if ((t /= d / 2) < 1) return c / 2 * t * t + b;\n+ return -c / 2 * ((--t) * (t - 2) - 1) + b;\n+ },\n \n-});\n+ CLASS_NAME: \"OpenLayers.Easing.Quad\"\n+};\n /* ======================================================================\n- OpenLayers/Feature.js\n+ OpenLayers/Projection.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n * @requires OpenLayers/BaseTypes/Class.js\n * @requires OpenLayers/Util.js\n */\n \n /**\n- * Class: OpenLayers.Feature\n- * Features are combinations of geography and attributes. The OpenLayers.Feature\n- * class specifically combines a marker and a lonlat.\n+ * Namespace: OpenLayers.Projection\n+ * Methods for coordinate transforms between coordinate systems. By default,\n+ * OpenLayers ships with the ability to transform coordinates between\n+ * geographic (EPSG:4326) and web or spherical mercator (EPSG:900913 et al.)\n+ * coordinate reference systems. See the method for details\n+ * on usage.\n+ *\n+ * Additional transforms may be added by using the \n+ * library. If the proj4js library is included, the method \n+ * will work between any two coordinate reference systems with proj4js \n+ * definitions.\n+ *\n+ * If the proj4js library is not included, or if you wish to allow transforms\n+ * between arbitrary coordinate reference systems, use the \n+ * method to register a custom transform method.\n */\n-OpenLayers.Feature = OpenLayers.Class({\n-\n- /** \n- * Property: layer \n- * {} \n- */\n- layer: null,\n-\n- /** \n- * Property: id \n- * {String} \n- */\n- id: null,\n-\n- /** \n- * Property: lonlat \n- * {} \n- */\n- lonlat: null,\n-\n- /** \n- * Property: data \n- * {Object} \n- */\n- data: null,\n+OpenLayers.Projection = OpenLayers.Class({\n \n- /** \n- * Property: marker \n- * {} \n+ /**\n+ * Property: proj\n+ * {Object} Proj4js.Proj instance.\n */\n- marker: null,\n+ proj: null,\n \n /**\n- * APIProperty: popupClass\n- * {} The class which will be used to instantiate\n- * a new Popup. Default is .\n+ * Property: projCode\n+ * {String}\n */\n- popupClass: null,\n+ projCode: null,\n \n- /** \n- * Property: popup \n- * {} \n+ /**\n+ * Property: titleRegEx\n+ * {RegExp} regular expression to strip the title from a proj4js definition\n */\n- popup: null,\n+ titleRegEx: /\\+title=[^\\+]*/,\n \n- /** \n- * Constructor: OpenLayers.Feature\n- * Constructor for features.\n+ /**\n+ * Constructor: OpenLayers.Projection\n+ * This class offers several methods for interacting with a wrapped \n+ * pro4js projection object. \n *\n * Parameters:\n- * layer - {} \n- * lonlat - {} \n- * data - {Object} \n- * \n+ * projCode - {String} A string identifying the Well Known Identifier for\n+ * the projection.\n+ * options - {Object} An optional object to set additional properties\n+ * on the projection.\n+ *\n * Returns:\n- * {}\n- */\n- initialize: function(layer, lonlat, data) {\n- this.layer = layer;\n- this.lonlat = lonlat;\n- this.data = (data != null) ? data : {};\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n- },\n-\n- /** \n- * Method: destroy\n- * nullify references to prevent circular references and memory leaks\n+ * {} A projection object.\n */\n- destroy: function() {\n-\n- //remove the popup from the map\n- if ((this.layer != null) && (this.layer.map != null)) {\n- if (this.popup != null) {\n- this.layer.map.removePopup(this.popup);\n- }\n- }\n- // remove the marker from the layer\n- if (this.layer != null && this.marker != null) {\n- this.layer.removeMarker(this.marker);\n- }\n-\n- this.layer = null;\n- this.id = null;\n- this.lonlat = null;\n- this.data = null;\n- if (this.marker != null) {\n- this.destroyMarker(this.marker);\n- this.marker = null;\n- }\n- if (this.popup != null) {\n- this.destroyPopup(this.popup);\n- this.popup = null;\n+ initialize: function(projCode, options) {\n+ OpenLayers.Util.extend(this, options);\n+ this.projCode = projCode;\n+ if (typeof Proj4js == \"object\") {\n+ this.proj = new Proj4js.Proj(projCode);\n }\n },\n \n /**\n- * Method: onScreen\n- * \n+ * APIMethod: getCode\n+ * Get the string SRS code.\n+ *\n * Returns:\n- * {Boolean} Whether or not the feature is currently visible on screen\n- * (based on its 'lonlat' property)\n+ * {String} The SRS code.\n */\n- onScreen: function() {\n-\n- var onScreen = false;\n- if ((this.layer != null) && (this.layer.map != null)) {\n- var screenBounds = this.layer.map.getExtent();\n- onScreen = screenBounds.containsLonLat(this.lonlat);\n- }\n- return onScreen;\n+ getCode: function() {\n+ return this.proj ? this.proj.srsCode : this.projCode;\n },\n \n-\n /**\n- * Method: createMarker\n- * Based on the data associated with the Feature, create and return a marker object.\n+ * APIMethod: getUnits\n+ * Get the units string for the projection -- returns null if \n+ * proj4js is not available.\n *\n- * Returns: \n- * {} A Marker Object created from the 'lonlat' and 'icon' properties\n- * set in this.data. If no 'lonlat' is set, returns null. If no\n- * 'icon' is set, OpenLayers.Marker() will load the default image.\n- * \n- * Note - this.marker is set to return value\n- * \n+ * Returns:\n+ * {String} The units abbreviation.\n */\n- createMarker: function() {\n-\n- if (this.lonlat != null) {\n- this.marker = new OpenLayers.Marker(this.lonlat, this.data.icon);\n- }\n- return this.marker;\n+ getUnits: function() {\n+ return this.proj ? this.proj.units : null;\n },\n \n /**\n- * Method: destroyMarker\n- * Destroys marker.\n- * If user overrides the createMarker() function, s/he should be able\n- * to also specify an alternative function for destroying it\n+ * Method: toString\n+ * Convert projection to string (getCode wrapper).\n+ *\n+ * Returns:\n+ * {String} The projection code.\n */\n- destroyMarker: function() {\n- this.marker.destroy();\n+ toString: function() {\n+ return this.getCode();\n },\n \n /**\n- * Method: createPopup\n- * Creates a popup object created from the 'lonlat', 'popupSize',\n- * and 'popupContentHTML' properties set in this.data. It uses\n- * this.marker.icon as default anchor. \n- * \n- * If no 'lonlat' is set, returns null. \n- * If no this.marker has been created, no anchor is sent.\n+ * Method: equals\n+ * Test equality of two projection instances. Determines equality based\n+ * soley on the projection code.\n *\n- * Note - the returned popup object is 'owned' by the feature, so you\n- * cannot use the popup's destroy method to discard the popup.\n- * Instead, you must use the feature's destroyPopup\n- * \n- * Note - this.popup is set to return value\n- * \n- * Parameters: \n- * closeBox - {Boolean} create popup with closebox or not\n- * \n * Returns:\n- * {} Returns the created popup, which is also set\n- * as 'popup' property of this feature. Will be of whatever type\n- * specified by this feature's 'popupClass' property, but must be\n- * of type .\n- * \n+ * {Boolean} The two projections are equivalent.\n */\n- createPopup: function(closeBox) {\n-\n- if (this.lonlat != null) {\n- if (!this.popup) {\n- var anchor = (this.marker) ? this.marker.icon : null;\n- var popupClass = this.popupClass ?\n- this.popupClass : OpenLayers.Popup.Anchored;\n- this.popup = new popupClass(this.id + \"_popup\",\n- this.lonlat,\n- this.data.popupSize,\n- this.data.popupContentHTML,\n- anchor,\n- closeBox);\n+ equals: function(projection) {\n+ var p = projection,\n+ equals = false;\n+ if (p) {\n+ if (!(p instanceof OpenLayers.Projection)) {\n+ p = new OpenLayers.Projection(p);\n }\n- if (this.data.overflow != null) {\n- this.popup.contentDiv.style.overflow = this.data.overflow;\n+ if ((typeof Proj4js == \"object\") && this.proj.defData && p.proj.defData) {\n+ equals = this.proj.defData.replace(this.titleRegEx, \"\") ==\n+ p.proj.defData.replace(this.titleRegEx, \"\");\n+ } else if (p.getCode) {\n+ var source = this.getCode(),\n+ target = p.getCode();\n+ equals = source == target ||\n+ !!OpenLayers.Projection.transforms[source] &&\n+ OpenLayers.Projection.transforms[source][target] ===\n+ OpenLayers.Projection.nullTransform;\n }\n-\n- this.popup.feature = this;\n }\n- return this.popup;\n+ return equals;\n },\n \n-\n- /**\n- * Method: destroyPopup\n- * Destroys the popup created via createPopup.\n- *\n- * As with the marker, if user overrides the createPopup() function, s/he \n- * should also be able to override the destruction\n+ /* Method: destroy\n+ * Destroy projection object.\n */\n- destroyPopup: function() {\n- if (this.popup) {\n- this.popup.feature = null;\n- this.popup.destroy();\n- this.popup = null;\n- }\n+ destroy: function() {\n+ delete this.proj;\n+ delete this.projCode;\n },\n \n- CLASS_NAME: \"OpenLayers.Feature\"\n+ CLASS_NAME: \"OpenLayers.Projection\"\n });\n-/* ======================================================================\n- OpenLayers/Feature/Vector.js\n- ====================================================================== */\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+/**\n+ * Property: transforms\n+ * {Object} Transforms is an object, with from properties, each of which may\n+ * have a to property. This allows you to define projections without \n+ * requiring support for proj4js to be included.\n+ *\n+ * This object has keys which correspond to a 'source' projection object. The\n+ * keys should be strings, corresponding to the projection.getCode() value.\n+ * Each source projection object should have a set of destination projection\n+ * keys included in the object. \n+ * \n+ * Each value in the destination object should be a transformation function,\n+ * where the function is expected to be passed an object with a .x and a .y\n+ * property. The function should return the object, with the .x and .y\n+ * transformed according to the transformation function.\n+ *\n+ * Note - Properties on this object should not be set directly. To add a\n+ * transform method to this object, use the method. For an\n+ * example of usage, see the OpenLayers.Layer.SphericalMercator file.\n+ */\n+OpenLayers.Projection.transforms = {};\n \n-// TRASH THIS\n-OpenLayers.State = {\n- /** states */\n- UNKNOWN: 'Unknown',\n- INSERT: 'Insert',\n- UPDATE: 'Update',\n- DELETE: 'Delete'\n+/**\n+ * APIProperty: defaults\n+ * {Object} Defaults for the SRS codes known to OpenLayers (currently\n+ * EPSG:4326, CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, EPSG:900913, EPSG:3857,\n+ * EPSG:102113 and EPSG:102100). Keys are the SRS code, values are units,\n+ * maxExtent (the validity extent for the SRS) and yx (true if this SRS is\n+ * known to have a reverse axis order).\n+ */\n+OpenLayers.Projection.defaults = {\n+ \"EPSG:4326\": {\n+ units: \"degrees\",\n+ maxExtent: [-180, -90, 180, 90],\n+ yx: true\n+ },\n+ \"CRS:84\": {\n+ units: \"degrees\",\n+ maxExtent: [-180, -90, 180, 90]\n+ },\n+ \"EPSG:900913\": {\n+ units: \"m\",\n+ maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34]\n+ }\n };\n \n /**\n- * @requires OpenLayers/Feature.js\n- * @requires OpenLayers/Util.js\n+ * APIMethod: addTransform\n+ * Set a custom transform method between two projections. Use this method in\n+ * cases where the proj4js lib is not available or where custom projections\n+ * need to be handled.\n+ *\n+ * Parameters:\n+ * from - {String} The code for the source projection\n+ * to - {String} the code for the destination projection\n+ * method - {Function} A function that takes a point as an argument and\n+ * transforms that point from the source to the destination projection\n+ * in place. The original point should be modified.\n */\n+OpenLayers.Projection.addTransform = function(from, to, method) {\n+ if (method === OpenLayers.Projection.nullTransform) {\n+ var defaults = OpenLayers.Projection.defaults[from];\n+ if (defaults && !OpenLayers.Projection.defaults[to]) {\n+ OpenLayers.Projection.defaults[to] = defaults;\n+ }\n+ }\n+ if (!OpenLayers.Projection.transforms[from]) {\n+ OpenLayers.Projection.transforms[from] = {};\n+ }\n+ OpenLayers.Projection.transforms[from][to] = method;\n+};\n \n /**\n- * Class: OpenLayers.Feature.Vector\n- * Vector features use the OpenLayers.Geometry classes as geometry description.\n- * They have an 'attributes' property, which is the data object, and a 'style'\n- * property, the default values of which are defined in the \n- * objects.\n+ * APIMethod: transform\n+ * Transform a point coordinate from one projection to another. Note that\n+ * the input point is transformed in place.\n * \n- * Inherits from:\n- * - \n+ * Parameters:\n+ * point - { | Object} An object with x and y\n+ * properties representing coordinates in those dimensions.\n+ * source - {OpenLayers.Projection} Source map coordinate system\n+ * dest - {OpenLayers.Projection} Destination map coordinate system\n+ *\n+ * Returns:\n+ * point - {object} A transformed coordinate. The original point is modified.\n */\n-OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {\n+OpenLayers.Projection.transform = function(point, source, dest) {\n+ if (source && dest) {\n+ if (!(source instanceof OpenLayers.Projection)) {\n+ source = new OpenLayers.Projection(source);\n+ }\n+ if (!(dest instanceof OpenLayers.Projection)) {\n+ dest = new OpenLayers.Projection(dest);\n+ }\n+ if (source.proj && dest.proj) {\n+ point = Proj4js.transform(source.proj, dest.proj, point);\n+ } else {\n+ var sourceCode = source.getCode();\n+ var destCode = dest.getCode();\n+ var transforms = OpenLayers.Projection.transforms;\n+ if (transforms[sourceCode] && transforms[sourceCode][destCode]) {\n+ transforms[sourceCode][destCode](point);\n+ }\n+ }\n+ }\n+ return point;\n+};\n \n- /** \n- * Property: fid \n- * {String} \n- */\n- fid: null,\n+/**\n+ * APIFunction: nullTransform\n+ * A null transformation - useful for defining projection aliases when\n+ * proj4js is not available:\n+ *\n+ * (code)\n+ * OpenLayers.Projection.addTransform(\"EPSG:3857\", \"EPSG:900913\",\n+ * OpenLayers.Projection.nullTransform);\n+ * OpenLayers.Projection.addTransform(\"EPSG:900913\", \"EPSG:3857\",\n+ * OpenLayers.Projection.nullTransform);\n+ * (end)\n+ */\n+OpenLayers.Projection.nullTransform = function(point) {\n+ return point;\n+};\n \n- /** \n- * APIProperty: geometry \n- * {} \n- */\n- geometry: null,\n+/**\n+ * Note: Transforms for web mercator <-> geographic\n+ * OpenLayers recognizes EPSG:3857, EPSG:900913, EPSG:102113 and EPSG:102100.\n+ * OpenLayers originally started referring to EPSG:900913 as web mercator.\n+ * The EPSG has declared EPSG:3857 to be web mercator.\n+ * ArcGIS 10 recognizes the EPSG:3857, EPSG:102113, and EPSG:102100 as\n+ * 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.\n+ * For geographic, OpenLayers recognizes EPSG:4326, CRS:84 and\n+ * urn:ogc:def:crs:EPSG:6.6:4326. OpenLayers also knows about the reverse axis\n+ * order for EPSG:4326. \n+ */\n+(function() {\n \n- /** \n- * APIProperty: attributes \n- * {Object} This object holds arbitrary, serializable properties that\n- * describe the feature.\n- */\n- attributes: null,\n+ var pole = 20037508.34;\n \n- /**\n- * Property: bounds\n- * {} The box bounding that feature's geometry, that\n- * property can be set by an object when\n- * deserializing the feature, so in most cases it represents an\n- * information set by the server. \n- */\n- bounds: null,\n+ function inverseMercator(xy) {\n+ xy.x = 180 * xy.x / pole;\n+ xy.y = 180 / Math.PI * (2 * Math.atan(Math.exp((xy.y / pole) * Math.PI)) - Math.PI / 2);\n+ return xy;\n+ }\n \n- /** \n- * Property: state \n- * {String} \n- */\n- state: null,\n+ function forwardMercator(xy) {\n+ xy.x = xy.x * pole / 180;\n+ var y = Math.log(Math.tan((90 + xy.y) * Math.PI / 360)) / Math.PI * pole;\n+ xy.y = Math.max(-20037508.34, Math.min(y, 20037508.34));\n+ return xy;\n+ }\n \n- /** \n- * APIProperty: style \n- * {Object} \n- */\n- style: null,\n+ function map(base, codes) {\n+ var add = OpenLayers.Projection.addTransform;\n+ var same = OpenLayers.Projection.nullTransform;\n+ var i, len, code, other, j;\n+ for (i = 0, len = codes.length; i < len; ++i) {\n+ code = codes[i];\n+ add(base, code, forwardMercator);\n+ add(code, base, inverseMercator);\n+ for (j = i + 1; j < len; ++j) {\n+ other = codes[j];\n+ add(code, other, same);\n+ add(other, code, same);\n+ }\n+ }\n+ }\n \n- /**\n- * APIProperty: url\n- * {String} If this property is set it will be taken into account by\n- * {} when upadting or deleting the feature.\n- */\n- url: null,\n+ // list of equivalent codes for web mercator\n+ var mercator = [\"EPSG:900913\", \"EPSG:3857\", \"EPSG:102113\", \"EPSG:102100\"],\n+ geographic = [\"CRS:84\", \"urn:ogc:def:crs:EPSG:6.6:4326\", \"EPSG:4326\"],\n+ i;\n+ for (i = mercator.length - 1; i >= 0; --i) {\n+ map(mercator[i], geographic);\n+ }\n+ for (i = geographic.length - 1; i >= 0; --i) {\n+ map(geographic[i], mercator);\n+ }\n+\n+})();\n+/* ======================================================================\n+ OpenLayers/Map.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Util.js\n+ * @requires OpenLayers/Util/vendorPrefix.js\n+ * @requires OpenLayers/Events.js\n+ * @requires OpenLayers/Tween.js\n+ * @requires OpenLayers/Projection.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Map\n+ * Instances of OpenLayers.Map are interactive maps embedded in a web page.\n+ * Create a new map with the constructor.\n+ * \n+ * On their own maps do not provide much functionality. To extend a map\n+ * it's necessary to add controls () and \n+ * layers () to the map. \n+ */\n+OpenLayers.Map = OpenLayers.Class({\n \n /**\n- * Property: renderIntent\n- * {String} rendering intent currently being used\n+ * Constant: Z_INDEX_BASE\n+ * {Object} Base z-indexes for different classes of thing \n */\n- renderIntent: \"default\",\n+ Z_INDEX_BASE: {\n+ BaseLayer: 100,\n+ Overlay: 325,\n+ Feature: 725,\n+ Popup: 750,\n+ Control: 1000\n+ },\n \n /**\n- * APIProperty: modified\n- * {Object} An object with the originals of the geometry and attributes of\n- * the feature, if they were changed. Currently this property is only read\n- * by , and written by\n- * , which sets the geometry property.\n- * Applications can set the originals of modified attributes in the\n- * attributes property. Note that applications have to check if this\n- * object and the attributes property is already created before using it.\n- * After a change made with ModifyFeature, this object could look like\n+ * APIProperty: events\n+ * {}\n *\n+ * Register a listener for a particular event with the following syntax:\n * (code)\n- * {\n- * geometry: >Object\n- * }\n+ * map.events.register(type, obj, listener);\n * (end)\n *\n- * When an application has made changes to feature attributes, it could\n- * have set the attributes to something like this:\n+ * Listeners will be called with a reference to an event object. The\n+ * properties of this event depends on exactly what happened.\n *\n- * (code)\n- * {\n- * attributes: {\n- * myAttribute: \"original\"\n- * }\n- * }\n- * (end)\n+ * All event objects have at least the following properties:\n+ * object - {Object} A reference to map.events.object.\n+ * element - {DOMElement} A reference to map.events.element.\n *\n- * Note that only checks for truthy values in\n- * *modified.geometry* and the attribute names in *modified.attributes*,\n- * but it is recommended to set the original values (and not just true) as\n- * attribute value, so applications could use this information to undo\n- * changes.\n+ * Browser events have the following additional properties:\n+ * xy - {} The pixel location of the event (relative\n+ * to the the map viewport).\n+ *\n+ * Supported map event types:\n+ * preaddlayer - triggered before a layer has been added. The event\n+ * object will include a *layer* property that references the layer \n+ * to be added. When a listener returns \"false\" the adding will be \n+ * aborted.\n+ * addlayer - triggered after a layer has been added. The event object\n+ * will include a *layer* property that references the added layer.\n+ * preremovelayer - triggered before a layer has been removed. The event\n+ * object will include a *layer* property that references the layer \n+ * to be removed. When a listener returns \"false\" the removal will be \n+ * aborted.\n+ * removelayer - triggered after a layer has been removed. The event\n+ * object will include a *layer* property that references the removed\n+ * layer.\n+ * changelayer - triggered after a layer name change, order change,\n+ * opacity change, params change, visibility change (actual visibility,\n+ * not the layer's visibility property) or attribution change (due to\n+ * extent change). Listeners will receive an event object with *layer*\n+ * and *property* properties. The *layer* property will be a reference\n+ * to the changed layer. The *property* property will be a key to the\n+ * changed property (name, order, opacity, params, visibility or\n+ * attribution).\n+ * movestart - triggered after the start of a drag, pan, or zoom. The event\n+ * object may include a *zoomChanged* property that tells whether the\n+ * zoom has changed.\n+ * move - triggered after each drag, pan, or zoom\n+ * moveend - triggered after a drag, pan, or zoom completes\n+ * zoomend - triggered after a zoom completes\n+ * mouseover - triggered after mouseover the map\n+ * mouseout - triggered after mouseout the map\n+ * mousemove - triggered after mousemove the map\n+ * changebaselayer - triggered after the base layer changes\n+ * updatesize - triggered after the method was executed\n */\n- modified: null,\n \n- /** \n- * Constructor: OpenLayers.Feature.Vector\n- * Create a vector feature. \n- * \n- * Parameters:\n- * geometry - {} The geometry that this feature\n- * represents.\n- * attributes - {Object} An optional object that will be mapped to the\n- * property. \n- * style - {Object} An optional style object.\n+ /**\n+ * Property: id\n+ * {String} Unique identifier for the map\n */\n- initialize: function(geometry, attributes, style) {\n- OpenLayers.Feature.prototype.initialize.apply(this,\n- [null, null, attributes]);\n- this.lonlat = null;\n- this.geometry = geometry ? geometry : null;\n- this.state = null;\n- this.attributes = {};\n- if (attributes) {\n- this.attributes = OpenLayers.Util.extend(this.attributes,\n- attributes);\n- }\n- this.style = style ? style : null;\n- },\n+ id: null,\n \n- /** \n- * Method: destroy\n- * nullify references to prevent circular references and memory leaks\n+ /**\n+ * Property: fractionalZoom\n+ * {Boolean} For a base layer that supports it, allow the map resolution\n+ * to be set to a value between one of the values in the resolutions\n+ * array. Default is false.\n+ *\n+ * When fractionalZoom is set to true, it is possible to zoom to\n+ * an arbitrary extent. This requires a base layer from a source\n+ * that supports requests for arbitrary extents (i.e. not cached\n+ * tiles on a regular lattice). This means that fractionalZoom\n+ * will not work with commercial layers (Google, Yahoo, VE), layers\n+ * using TileCache, or any other pre-cached data sources.\n+ *\n+ * If you are using fractionalZoom, then you should also use\n+ * instead of layer.resolutions[zoom] as the\n+ * former works for non-integer zoom levels.\n */\n- destroy: function() {\n- if (this.layer) {\n- this.layer.removeFeatures(this);\n- this.layer = null;\n- }\n-\n- this.geometry = null;\n- this.modified = null;\n- OpenLayers.Feature.prototype.destroy.apply(this, arguments);\n- },\n+ fractionalZoom: false,\n \n /**\n- * Method: clone\n- * Create a clone of this vector feature. Does not set any non-standard\n- * properties.\n- *\n- * Returns:\n- * {} An exact clone of this vector feature.\n+ * APIProperty: events\n+ * {} An events object that handles all \n+ * events on the map\n */\n- clone: function() {\n- return new OpenLayers.Feature.Vector(\n- this.geometry ? this.geometry.clone() : null,\n- this.attributes,\n- this.style);\n- },\n+ events: null,\n \n /**\n- * Method: onScreen\n- * Determine whether the feature is within the map viewport. This method\n- * tests for an intersection between the geometry and the viewport\n- * bounds. If a more effecient but less precise geometry bounds\n- * intersection is desired, call the method with the boundsOnly\n- * parameter true.\n+ * APIProperty: allOverlays\n+ * {Boolean} Allow the map to function with \"overlays\" only. Defaults to\n+ * false. If true, the lowest layer in the draw order will act as\n+ * the base layer. In addition, if set to true, all layers will\n+ * have isBaseLayer set to false when they are added to the map.\n *\n- * Parameters:\n- * boundsOnly - {Boolean} Only test whether a feature's bounds intersects\n- * the viewport bounds. Default is false. If false, the feature's\n- * geometry must intersect the viewport for onScreen to return true.\n- * \n- * Returns:\n- * {Boolean} The feature is currently visible on screen (optionally\n- * based on its bounds if boundsOnly is true).\n+ * Note:\n+ * If you set map.allOverlays to true, then you *cannot* use\n+ * map.setBaseLayer or layer.setIsBaseLayer. With allOverlays true,\n+ * the lowest layer in the draw layer is the base layer. So, to change\n+ * the base layer, use or to set the layer\n+ * index to 0.\n */\n- onScreen: function(boundsOnly) {\n- var onScreen = false;\n- if (this.layer && this.layer.map) {\n- var screenBounds = this.layer.map.getExtent();\n- if (boundsOnly) {\n- var featureBounds = this.geometry.getBounds();\n- onScreen = screenBounds.intersectsBounds(featureBounds);\n- } else {\n- var screenPoly = screenBounds.toGeometry();\n- onScreen = screenPoly.intersects(this.geometry);\n- }\n- }\n- return onScreen;\n- },\n+ allOverlays: false,\n \n /**\n- * Method: getVisibility\n- * Determine whether the feature is displayed or not. It may not displayed\n- * because:\n- * - its style display property is set to 'none',\n- * - it doesn't belong to any layer,\n- * - the styleMap creates a symbolizer with display property set to 'none'\n- * for it,\n- * - the layer which it belongs to is not visible.\n- * \n- * Returns:\n- * {Boolean} The feature is currently displayed.\n+ * APIProperty: div\n+ * {DOMElement|String} The element that contains the map (or an id for\n+ * that element). If the constructor is called\n+ * with two arguments, this should be provided as the first argument.\n+ * Alternatively, the map constructor can be called with the options\n+ * object as the only argument. In this case (one argument), a\n+ * div property may or may not be provided. If the div property\n+ * is not provided, the map can be rendered to a container later\n+ * using the method.\n+ * \n+ * Note:\n+ * If you are calling after map construction, do not use\n+ * auto. Instead, divide your by your\n+ * maximum expected dimension.\n */\n- getVisibility: function() {\n- return !(this.style && this.style.display == 'none' ||\n- !this.layer ||\n- this.layer && this.layer.styleMap &&\n- this.layer.styleMap.createSymbolizer(this, this.renderIntent).display == 'none' ||\n- this.layer && !this.layer.getVisibility());\n- },\n+ div: null,\n \n /**\n- * Method: createMarker\n- * HACK - we need to decide if all vector features should be able to\n- * create markers\n- * \n- * Returns:\n- * {} For now just returns null\n+ * Property: dragging\n+ * {Boolean} The map is currently being dragged.\n */\n- createMarker: function() {\n- return null;\n- },\n+ dragging: false,\n \n /**\n- * Method: destroyMarker\n- * HACK - we need to decide if all vector features should be able to\n- * delete markers\n- * \n- * If user overrides the createMarker() function, s/he should be able\n- * to also specify an alternative function for destroying it\n+ * Property: size\n+ * {} Size of the main div (this.div)\n */\n- destroyMarker: function() {\n- // pass\n- },\n+ size: null,\n \n /**\n- * Method: createPopup\n- * HACK - we need to decide if all vector features should be able to\n- * create popups\n- * \n- * Returns:\n- * {} For now just returns null\n+ * Property: viewPortDiv\n+ * {HTMLDivElement} The element that represents the map viewport\n */\n- createPopup: function() {\n- return null;\n- },\n+ viewPortDiv: null,\n \n /**\n- * Method: atPoint\n- * Determins whether the feature intersects with the specified location.\n- * \n- * Parameters: \n- * lonlat - {|Object} OpenLayers.LonLat or an\n- * object with a 'lon' and 'lat' properties.\n- * toleranceLon - {float} Optional tolerance in Geometric Coords\n- * toleranceLat - {float} Optional tolerance in Geographic Coords\n- * \n- * Returns:\n- * {Boolean} Whether or not the feature is at the specified location\n- */\n- atPoint: function(lonlat, toleranceLon, toleranceLat) {\n- var atPoint = false;\n- if (this.geometry) {\n- atPoint = this.geometry.atPoint(lonlat, toleranceLon,\n- toleranceLat);\n- }\n- return atPoint;\n- },\n-\n- /**\n- * Method: destroyPopup\n- * HACK - we need to decide if all vector features should be able to\n- * delete popups\n- */\n- destroyPopup: function() {\n- // pass\n- },\n-\n- /**\n- * Method: move\n- * Moves the feature and redraws it at its new location\n- *\n- * Parameters:\n- * location - { or } the\n- * location to which to move the feature.\n- */\n- move: function(location) {\n-\n- if (!this.layer || !this.geometry.move) {\n- //do nothing if no layer or immoveable geometry\n- return undefined;\n- }\n-\n- var pixel;\n- if (location.CLASS_NAME == \"OpenLayers.LonLat\") {\n- pixel = this.layer.getViewPortPxFromLonLat(location);\n- } else {\n- pixel = location;\n- }\n-\n- var lastPixel = this.layer.getViewPortPxFromLonLat(this.geometry.getBounds().getCenterLonLat());\n- var res = this.layer.map.getResolution();\n- this.geometry.move(res * (pixel.x - lastPixel.x),\n- res * (lastPixel.y - pixel.y));\n- this.layer.drawFeature(this);\n- return lastPixel;\n- },\n-\n- /**\n- * Method: toState\n- * Sets the new state\n- *\n- * Parameters:\n- * state - {String} \n- */\n- toState: function(state) {\n- if (state == OpenLayers.State.UPDATE) {\n- switch (this.state) {\n- case OpenLayers.State.UNKNOWN:\n- case OpenLayers.State.DELETE:\n- this.state = state;\n- break;\n- case OpenLayers.State.UPDATE:\n- case OpenLayers.State.INSERT:\n- break;\n- }\n- } else if (state == OpenLayers.State.INSERT) {\n- switch (this.state) {\n- case OpenLayers.State.UNKNOWN:\n- break;\n- default:\n- this.state = state;\n- break;\n- }\n- } else if (state == OpenLayers.State.DELETE) {\n- switch (this.state) {\n- case OpenLayers.State.INSERT:\n- // the feature should be destroyed\n- break;\n- case OpenLayers.State.DELETE:\n- break;\n- case OpenLayers.State.UNKNOWN:\n- case OpenLayers.State.UPDATE:\n- this.state = state;\n- break;\n- }\n- } else if (state == OpenLayers.State.UNKNOWN) {\n- this.state = state;\n- }\n- },\n-\n- CLASS_NAME: \"OpenLayers.Feature.Vector\"\n-});\n-\n-\n-/**\n- * Constant: OpenLayers.Feature.Vector.style\n- * OpenLayers features can have a number of style attributes. The 'default' \n- * style will typically be used if no other style is specified. These\n- * styles correspond for the most part, to the styling properties defined\n- * by the SVG standard. \n- * Information on fill properties: http://www.w3.org/TR/SVG/painting.html#FillProperties\n- * Information on stroke properties: http://www.w3.org/TR/SVG/painting.html#StrokeProperties\n- *\n- * Symbolizer properties:\n- * fill - {Boolean} Set to false if no fill is desired.\n- * fillColor - {String} Hex fill color. Default is \"#ee9900\".\n- * fillOpacity - {Number} Fill opacity (0-1). Default is 0.4 \n- * stroke - {Boolean} Set to false if no stroke is desired.\n- * strokeColor - {String} Hex stroke color. Default is \"#ee9900\".\n- * strokeOpacity - {Number} Stroke opacity (0-1). Default is 1.\n- * strokeWidth - {Number} Pixel stroke width. Default is 1.\n- * strokeLinecap - {String} Stroke cap type. Default is \"round\". [butt | round | square]\n- * strokeDashstyle - {String} Stroke dash style. Default is \"solid\". [dot | dash | dashdot | longdash | longdashdot | solid]\n- * graphic - {Boolean} Set to false if no graphic is desired.\n- * pointRadius - {Number} Pixel point radius. Default is 6.\n- * pointerEvents - {String} Default is \"visiblePainted\".\n- * cursor - {String} Default is \"\".\n- * externalGraphic - {String} Url to an external graphic that will be used for rendering points.\n- * graphicWidth - {Number} Pixel width for sizing an external graphic.\n- * graphicHeight - {Number} Pixel height for sizing an external graphic.\n- * graphicOpacity - {Number} Opacity (0-1) for an external graphic.\n- * graphicXOffset - {Number} Pixel offset along the positive x axis for displacing an external graphic.\n- * graphicYOffset - {Number} Pixel offset along the positive y axis for displacing an external graphic.\n- * rotation - {Number} For point symbolizers, this is the rotation of a graphic in the clockwise direction about its center point (or any point off center as specified by graphicXOffset and graphicYOffset).\n- * graphicZIndex - {Number} The integer z-index value to use in rendering.\n- * graphicName - {String} Named graphic to use when rendering points. Supported values include \"circle\" (default),\n- * \"square\", \"star\", \"x\", \"cross\", \"triangle\".\n- * graphicTitle - {String} Tooltip when hovering over a feature. *deprecated*, use title instead\n- * title - {String} Tooltip when hovering over a feature. Not supported by the canvas renderer.\n- * backgroundGraphic - {String} Url to a graphic to be used as the background under an externalGraphic.\n- * backgroundGraphicZIndex - {Number} The integer z-index value to use in rendering the background graphic.\n- * backgroundXOffset - {Number} The x offset (in pixels) for the background graphic.\n- * backgroundYOffset - {Number} The y offset (in pixels) for the background graphic.\n- * backgroundHeight - {Number} The height of the background graphic. If not provided, the graphicHeight will be used.\n- * backgroundWidth - {Number} The width of the background width. If not provided, the graphicWidth will be used.\n- * label - {String} The text for an optional label. For browsers that use the canvas renderer, this requires either\n- * fillText or mozDrawText to be available.\n- * labelAlign - {String} Label alignment. This specifies the insertion point relative to the text. It is a string\n- * composed of two characters. The first character is for the horizontal alignment, the second for the vertical\n- * alignment. Valid values for horizontal alignment: \"l\"=left, \"c\"=center, \"r\"=right. Valid values for vertical\n- * alignment: \"t\"=top, \"m\"=middle, \"b\"=bottom. Example values: \"lt\", \"cm\", \"rb\". Default is \"cm\".\n- * labelXOffset - {Number} Pixel offset along the positive x axis for displacing the label. Not supported by the canvas renderer.\n- * labelYOffset - {Number} Pixel offset along the positive y axis for displacing the label. Not supported by the canvas renderer.\n- * labelSelect - {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls.\n- * Default is false.\n- * labelOutlineColor - {String} The color of the label outline. Default is 'white'. Only supported by the canvas & SVG renderers.\n- * labelOutlineWidth - {Number} The width of the label outline. Default is 3, set to 0 or null to disable. Only supported by the SVG renderers.\n- * labelOutlineOpacity - {Number} The opacity (0-1) of the label outline. Default is fontOpacity. Only supported by the canvas & SVG renderers.\n- * fontColor - {String} The font color for the label, to be provided like CSS.\n- * fontOpacity - {Number} Opacity (0-1) for the label\n- * fontFamily - {String} The font family for the label, to be provided like in CSS.\n- * fontSize - {String} The font size for the label, to be provided like in CSS.\n- * fontStyle - {String} The font style for the label, to be provided like in CSS.\n- * fontWeight - {String} The font weight for the label, to be provided like in CSS.\n- * display - {String} Symbolizers will have no effect if display is set to \"none\". All other values have no effect.\n- */\n-OpenLayers.Feature.Vector.style = {\n- 'default': {\n- fillColor: \"#ee9900\",\n- fillOpacity: 0.4,\n- hoverFillColor: \"white\",\n- hoverFillOpacity: 0.8,\n- strokeColor: \"#ee9900\",\n- strokeOpacity: 1,\n- strokeWidth: 1,\n- strokeLinecap: \"round\",\n- strokeDashstyle: \"solid\",\n- hoverStrokeColor: \"red\",\n- hoverStrokeOpacity: 1,\n- hoverStrokeWidth: 0.2,\n- pointRadius: 6,\n- hoverPointRadius: 1,\n- hoverPointUnit: \"%\",\n- pointerEvents: \"visiblePainted\",\n- cursor: \"inherit\",\n- fontColor: \"#000000\",\n- labelAlign: \"cm\",\n- labelOutlineColor: \"white\",\n- labelOutlineWidth: 3\n- },\n- 'select': {\n- fillColor: \"blue\",\n- fillOpacity: 0.4,\n- hoverFillColor: \"white\",\n- hoverFillOpacity: 0.8,\n- strokeColor: \"blue\",\n- strokeOpacity: 1,\n- strokeWidth: 2,\n- strokeLinecap: \"round\",\n- strokeDashstyle: \"solid\",\n- hoverStrokeColor: \"red\",\n- hoverStrokeOpacity: 1,\n- hoverStrokeWidth: 0.2,\n- pointRadius: 6,\n- hoverPointRadius: 1,\n- hoverPointUnit: \"%\",\n- pointerEvents: \"visiblePainted\",\n- cursor: \"pointer\",\n- fontColor: \"#000000\",\n- labelAlign: \"cm\",\n- labelOutlineColor: \"white\",\n- labelOutlineWidth: 3\n-\n- },\n- 'temporary': {\n- fillColor: \"#66cccc\",\n- fillOpacity: 0.2,\n- hoverFillColor: \"white\",\n- hoverFillOpacity: 0.8,\n- strokeColor: \"#66cccc\",\n- strokeOpacity: 1,\n- strokeLinecap: \"round\",\n- strokeWidth: 2,\n- strokeDashstyle: \"solid\",\n- hoverStrokeColor: \"red\",\n- hoverStrokeOpacity: 1,\n- hoverStrokeWidth: 0.2,\n- pointRadius: 6,\n- hoverPointRadius: 1,\n- hoverPointUnit: \"%\",\n- pointerEvents: \"visiblePainted\",\n- cursor: \"inherit\",\n- fontColor: \"#000000\",\n- labelAlign: \"cm\",\n- labelOutlineColor: \"white\",\n- labelOutlineWidth: 3\n-\n- },\n- 'delete': {\n- display: \"none\"\n- }\n-};\n-/* ======================================================================\n- OpenLayers/Style.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n- * @requires OpenLayers/Feature/Vector.js\n- */\n-\n-/**\n- * Class: OpenLayers.Style\n- * This class represents a UserStyle obtained\n- * from a SLD, containing styling rules.\n- */\n-OpenLayers.Style = OpenLayers.Class({\n-\n- /**\n- * Property: id\n- * {String} A unique id for this session.\n- */\n- id: null,\n-\n- /**\n- * APIProperty: name\n- * {String}\n- */\n- name: null,\n-\n- /**\n- * Property: title\n- * {String} Title of this style (set if included in SLD)\n- */\n- title: null,\n-\n- /**\n- * Property: description\n- * {String} Description of this style (set if abstract is included in SLD)\n- */\n- description: null,\n-\n- /**\n- * APIProperty: layerName\n- * {} name of the layer that this style belongs to, usually\n- * according to the NamedLayer attribute of an SLD document.\n- */\n- layerName: null,\n-\n- /**\n- * APIProperty: isDefault\n- * {Boolean}\n- */\n- isDefault: false,\n-\n- /** \n- * Property: rules \n- * {Array()}\n- */\n- rules: null,\n-\n- /**\n- * APIProperty: context\n- * {Object} An optional object with properties that symbolizers' property\n- * values should be evaluated against. If no context is specified,\n- * feature.attributes will be used\n- */\n- context: null,\n-\n- /**\n- * Property: defaultStyle\n- * {Object} hash of style properties to use as default for merging\n- * rule-based style symbolizers onto. If no rules are defined,\n- * createSymbolizer will return this style. If is set to\n- * true, the defaultStyle will only be taken into account if there are\n- * rules defined.\n- */\n- defaultStyle: null,\n-\n- /**\n- * Property: defaultsPerSymbolizer\n- * {Boolean} If set to true, the will extend the symbolizer\n- * of every rule. Properties of the will also be used to set\n- * missing symbolizer properties if the symbolizer has stroke, fill or\n- * graphic set to true. Default is false.\n- */\n- defaultsPerSymbolizer: false,\n-\n- /**\n- * Property: propertyStyles\n- * {Hash of Boolean} cache of style properties that need to be parsed for\n- * propertyNames. Property names are keys, values won't be used.\n- */\n- propertyStyles: null,\n-\n-\n- /** \n- * Constructor: OpenLayers.Style\n- * Creates a UserStyle.\n- *\n- * Parameters:\n- * style - {Object} Optional hash of style properties that will be\n- * used as default style for this style object. This style\n- * applies if no rules are specified. Symbolizers defined in\n- * rules will extend this default style.\n- * options - {Object} An optional object with properties to set on the\n- * style.\n- *\n- * Valid options:\n- * rules - {Array()} List of rules to be added to the\n- * style.\n- * \n- * Returns:\n- * {}\n- */\n- initialize: function(style, options) {\n-\n- OpenLayers.Util.extend(this, options);\n- this.rules = [];\n- if (options && options.rules) {\n- this.addRules(options.rules);\n- }\n-\n- // use the default style from OpenLayers.Feature.Vector if no style\n- // was given in the constructor\n- this.setDefaultStyle(style ||\n- OpenLayers.Feature.Vector.style[\"default\"]);\n-\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n- },\n-\n- /** \n- * APIMethod: destroy\n- * nullify references to prevent circular references and memory leaks\n- */\n- destroy: function() {\n- for (var i = 0, len = this.rules.length; i < len; i++) {\n- this.rules[i].destroy();\n- this.rules[i] = null;\n- }\n- this.rules = null;\n- this.defaultStyle = null;\n- },\n-\n- /**\n- * Method: createSymbolizer\n- * creates a style by applying all feature-dependent rules to the base\n- * style.\n- * \n- * Parameters:\n- * feature - {} feature to evaluate rules for\n- * \n- * Returns:\n- * {Object} symbolizer hash\n- */\n- createSymbolizer: function(feature) {\n- var style = this.defaultsPerSymbolizer ? {} : this.createLiterals(\n- OpenLayers.Util.extend({}, this.defaultStyle), feature);\n-\n- var rules = this.rules;\n-\n- var rule, context;\n- var elseRules = [];\n- var appliedRules = false;\n- for (var i = 0, len = rules.length; i < len; i++) {\n- rule = rules[i];\n- // does the rule apply?\n- var applies = rule.evaluate(feature);\n-\n- if (applies) {\n- if (rule instanceof OpenLayers.Rule && rule.elseFilter) {\n- elseRules.push(rule);\n- } else {\n- appliedRules = true;\n- this.applySymbolizer(rule, style, feature);\n- }\n- }\n- }\n-\n- // if no other rules apply, apply the rules with else filters\n- if (appliedRules == false && elseRules.length > 0) {\n- appliedRules = true;\n- for (var i = 0, len = elseRules.length; i < len; i++) {\n- this.applySymbolizer(elseRules[i], style, feature);\n- }\n- }\n-\n- // don't display if there were rules but none applied\n- if (rules.length > 0 && appliedRules == false) {\n- style.display = \"none\";\n- }\n-\n- if (style.label != null && typeof style.label !== \"string\") {\n- style.label = String(style.label);\n- }\n-\n- return style;\n- },\n-\n- /**\n- * Method: applySymbolizer\n- *\n- * Parameters:\n- * rule - {}\n- * style - {Object}\n- * feature - {}\n- *\n- * Returns:\n- * {Object} A style with new symbolizer applied.\n- */\n- applySymbolizer: function(rule, style, feature) {\n- var symbolizerPrefix = feature.geometry ?\n- this.getSymbolizerPrefix(feature.geometry) :\n- OpenLayers.Style.SYMBOLIZER_PREFIXES[0];\n-\n- var symbolizer = rule.symbolizer[symbolizerPrefix] || rule.symbolizer;\n-\n- if (this.defaultsPerSymbolizer === true) {\n- var defaults = this.defaultStyle;\n- OpenLayers.Util.applyDefaults(symbolizer, {\n- pointRadius: defaults.pointRadius\n- });\n- if (symbolizer.stroke === true || symbolizer.graphic === true) {\n- OpenLayers.Util.applyDefaults(symbolizer, {\n- strokeWidth: defaults.strokeWidth,\n- strokeColor: defaults.strokeColor,\n- strokeOpacity: defaults.strokeOpacity,\n- strokeDashstyle: defaults.strokeDashstyle,\n- strokeLinecap: defaults.strokeLinecap\n- });\n- }\n- if (symbolizer.fill === true || symbolizer.graphic === true) {\n- OpenLayers.Util.applyDefaults(symbolizer, {\n- fillColor: defaults.fillColor,\n- fillOpacity: defaults.fillOpacity\n- });\n- }\n- if (symbolizer.graphic === true) {\n- OpenLayers.Util.applyDefaults(symbolizer, {\n- pointRadius: this.defaultStyle.pointRadius,\n- externalGraphic: this.defaultStyle.externalGraphic,\n- graphicName: this.defaultStyle.graphicName,\n- graphicOpacity: this.defaultStyle.graphicOpacity,\n- graphicWidth: this.defaultStyle.graphicWidth,\n- graphicHeight: this.defaultStyle.graphicHeight,\n- graphicXOffset: this.defaultStyle.graphicXOffset,\n- graphicYOffset: this.defaultStyle.graphicYOffset\n- });\n- }\n- }\n-\n- // merge the style with the current style\n- return this.createLiterals(\n- OpenLayers.Util.extend(style, symbolizer), feature);\n- },\n-\n- /**\n- * Method: createLiterals\n- * creates literals for all style properties that have an entry in\n- * .\n- * \n- * Parameters:\n- * style - {Object} style to create literals for. Will be modified\n- * inline.\n- * feature - {Object}\n- * \n- * Returns:\n- * {Object} the modified style\n- */\n- createLiterals: function(style, feature) {\n- var context = OpenLayers.Util.extend({}, feature.attributes || feature.data);\n- OpenLayers.Util.extend(context, this.context);\n-\n- for (var i in this.propertyStyles) {\n- style[i] = OpenLayers.Style.createLiteral(style[i], context, feature, i);\n- }\n- return style;\n- },\n-\n- /**\n- * Method: findPropertyStyles\n- * Looks into all rules for this style and the defaultStyle to collect\n- * all the style hash property names containing ${...} strings that have\n- * to be replaced using the createLiteral method before returning them.\n- * \n- * Returns:\n- * {Object} hash of property names that need createLiteral parsing. The\n- * name of the property is the key, and the value is true;\n- */\n- findPropertyStyles: function() {\n- var propertyStyles = {};\n-\n- // check the default style\n- var style = this.defaultStyle;\n- this.addPropertyStyles(propertyStyles, style);\n-\n- // walk through all rules to check for properties in their symbolizer\n- var rules = this.rules;\n- var symbolizer, value;\n- for (var i = 0, len = rules.length; i < len; i++) {\n- symbolizer = rules[i].symbolizer;\n- for (var key in symbolizer) {\n- value = symbolizer[key];\n- if (typeof value == \"object\") {\n- // symbolizer key is \"Point\", \"Line\" or \"Polygon\"\n- this.addPropertyStyles(propertyStyles, value);\n- } else {\n- // symbolizer is a hash of style properties\n- this.addPropertyStyles(propertyStyles, symbolizer);\n- break;\n- }\n- }\n- }\n- return propertyStyles;\n- },\n-\n- /**\n- * Method: addPropertyStyles\n- * \n- * Parameters:\n- * propertyStyles - {Object} hash to add new property styles to. Will be\n- * modified inline\n- * symbolizer - {Object} search this symbolizer for property styles\n- * \n- * Returns:\n- * {Object} propertyStyles hash\n- */\n- addPropertyStyles: function(propertyStyles, symbolizer) {\n- var property;\n- for (var key in symbolizer) {\n- property = symbolizer[key];\n- if (typeof property == \"string\" &&\n- property.match(/\\$\\{\\w+\\}/)) {\n- propertyStyles[key] = true;\n- }\n- }\n- return propertyStyles;\n- },\n-\n- /**\n- * APIMethod: addRules\n- * Adds rules to this style.\n- * \n- * Parameters:\n- * rules - {Array()}\n- */\n- addRules: function(rules) {\n- Array.prototype.push.apply(this.rules, rules);\n- this.propertyStyles = this.findPropertyStyles();\n- },\n-\n- /**\n- * APIMethod: setDefaultStyle\n- * Sets the default style for this style object.\n- * \n- * Parameters:\n- * style - {Object} Hash of style properties\n- */\n- setDefaultStyle: function(style) {\n- this.defaultStyle = style;\n- this.propertyStyles = this.findPropertyStyles();\n- },\n-\n- /**\n- * Method: getSymbolizerPrefix\n- * Returns the correct symbolizer prefix according to the\n- * geometry type of the passed geometry\n- * \n- * Parameters:\n- * geometry - {}\n- * \n- * Returns:\n- * {String} key of the according symbolizer\n- */\n- getSymbolizerPrefix: function(geometry) {\n- var prefixes = OpenLayers.Style.SYMBOLIZER_PREFIXES;\n- for (var i = 0, len = prefixes.length; i < len; i++) {\n- if (geometry.CLASS_NAME.indexOf(prefixes[i]) != -1) {\n- return prefixes[i];\n- }\n- }\n- },\n-\n- /**\n- * APIMethod: clone\n- * Clones this style.\n- * \n- * Returns:\n- * {} Clone of this style.\n- */\n- clone: function() {\n- var options = OpenLayers.Util.extend({}, this);\n- // clone rules\n- if (this.rules) {\n- options.rules = [];\n- for (var i = 0, len = this.rules.length; i < len; ++i) {\n- options.rules.push(this.rules[i].clone());\n- }\n- }\n- // clone context\n- options.context = this.context && OpenLayers.Util.extend({}, this.context);\n- //clone default style\n- var defaultStyle = OpenLayers.Util.extend({}, this.defaultStyle);\n- return new OpenLayers.Style(defaultStyle, options);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Style\"\n-});\n-\n-\n-/**\n- * Function: createLiteral\n- * converts a style value holding a combination of PropertyName and Literal\n- * into a Literal, taking the property values from the passed features.\n- * \n- * Parameters:\n- * value - {String} value to parse. If this string contains a construct like\n- * \"foo ${bar}\", then \"foo \" will be taken as literal, and \"${bar}\"\n- * will be replaced by the value of the \"bar\" attribute of the passed\n- * feature.\n- * context - {Object} context to take attribute values from\n- * feature - {} optional feature to pass to\n- * for evaluating functions in the\n- * context.\n- * property - {String} optional, name of the property for which the literal is\n- * being created for evaluating functions in the context.\n- * \n- * Returns:\n- * {String} the parsed value. In the example of the value parameter above, the\n- * result would be \"foo valueOfBar\", assuming that the passed feature has an\n- * attribute named \"bar\" with the value \"valueOfBar\".\n- */\n-OpenLayers.Style.createLiteral = function(value, context, feature, property) {\n- if (typeof value == \"string\" && value.indexOf(\"${\") != -1) {\n- value = OpenLayers.String.format(value, context, [feature, property]);\n- value = (isNaN(value) || !value) ? value : parseFloat(value);\n- }\n- return value;\n-};\n-\n-/**\n- * Constant: OpenLayers.Style.SYMBOLIZER_PREFIXES\n- * {Array} prefixes of the sld symbolizers. These are the\n- * same as the main geometry types\n- */\n-OpenLayers.Style.SYMBOLIZER_PREFIXES = ['Point', 'Line', 'Polygon', 'Text',\n- 'Raster'\n-];\n-/* ======================================================================\n- OpenLayers/Tile.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n- */\n-\n-/**\n- * Class: OpenLayers.Tile \n- * This is a class designed to designate a single tile, however\n- * it is explicitly designed to do relatively little. Tiles store \n- * information about themselves -- such as the URL that they are related\n- * to, and their size - but do not add themselves to the layer div \n- * automatically, for example. Create a new tile with the \n- * constructor, or a subclass. \n- * \n- * TBD 3.0 - remove reference to url in above paragraph\n- * \n- */\n-OpenLayers.Tile = OpenLayers.Class({\n-\n- /**\n- * APIProperty: events\n- * {} An events object that handles all \n- * events on the tile.\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * tile.events.register(type, obj, listener);\n- * (end)\n- *\n- * Supported event types:\n- * beforedraw - Triggered before the tile is drawn. Used to defer\n- * drawing to an animation queue. To defer drawing, listeners need\n- * to return false, which will abort drawing. The queue handler needs\n- * to call (true) to actually draw the tile.\n- * loadstart - Triggered when tile loading starts.\n- * loadend - Triggered when tile loading ends.\n- * loaderror - Triggered before the loadend event (i.e. when the tile is\n- * still hidden) if the tile could not be loaded.\n- * reload - Triggered when an already loading tile is reloaded.\n- * unload - Triggered before a tile is unloaded.\n- */\n- events: null,\n-\n- /**\n- * APIProperty: eventListeners\n- * {Object} If set as an option at construction, the eventListeners\n- * object will be registered with . Object\n- * structure must be a listeners object as shown in the example for\n- * the events.on method.\n- *\n- * This options can be set in the ``tileOptions`` option from\n- * . For example, to be notified of the\n- * ``loadend`` event of each tiles:\n- * (code)\n- * new OpenLayers.Layer.OSM('osm', 'http://tile.openstreetmap.org/${z}/${x}/${y}.png', {\n- * tileOptions: {\n- * eventListeners: {\n- * 'loadend': function(evt) {\n- * // do something on loadend\n- * }\n- * }\n- * }\n- * });\n- * (end)\n- */\n- eventListeners: null,\n-\n- /**\n- * Property: id \n- * {String} null\n- */\n- id: null,\n-\n- /** \n- * Property: layer \n- * {} layer the tile is attached to \n- */\n- layer: null,\n-\n- /**\n- * Property: url\n- * {String} url of the request.\n- *\n- * TBD 3.0 \n- * Deprecated. The base tile class does not need an url. This should be \n- * handled in subclasses. Does not belong here.\n- */\n- url: null,\n-\n- /** \n- * APIProperty: bounds \n- * {} null\n- */\n- bounds: null,\n-\n- /** \n- * Property: size \n- * {} null\n- */\n- size: null,\n-\n- /** \n- * Property: position \n- * {} Top Left pixel of the tile\n- */\n- position: null,\n-\n- /**\n- * Property: isLoading\n- * {Boolean} Is the tile loading?\n- */\n- isLoading: false,\n-\n- /** TBD 3.0 -- remove 'url' from the list of parameters to the constructor.\n- * there is no need for the base tile class to have a url.\n- */\n-\n- /** \n- * Constructor: OpenLayers.Tile\n- * Constructor for a new instance.\n- * \n- * Parameters:\n- * layer - {} layer that the tile will go in.\n- * position - {}\n- * bounds - {}\n- * url - {}\n- * size - {}\n- * options - {Object}\n- */\n- initialize: function(layer, position, bounds, url, size, options) {\n- this.layer = layer;\n- this.position = position.clone();\n- this.setBounds(bounds);\n- this.url = url;\n- if (size) {\n- this.size = size.clone();\n- }\n-\n- //give the tile a unique id based on its BBOX.\n- this.id = OpenLayers.Util.createUniqueID(\"Tile_\");\n-\n- OpenLayers.Util.extend(this, options);\n-\n- this.events = new OpenLayers.Events(this);\n- if (this.eventListeners instanceof Object) {\n- this.events.on(this.eventListeners);\n- }\n- },\n-\n- /**\n- * Method: unload\n- * Call immediately before destroying if you are listening to tile\n- * events, so that counters are properly handled if tile is still\n- * loading at destroy-time. Will only fire an event if the tile is\n- * still loading.\n- */\n- unload: function() {\n- if (this.isLoading) {\n- this.isLoading = false;\n- this.events.triggerEvent(\"unload\");\n- }\n- },\n-\n- /** \n- * APIMethod: destroy\n- * Nullify references to prevent circular references and memory leaks.\n- */\n- destroy: function() {\n- this.layer = null;\n- this.bounds = null;\n- this.size = null;\n- this.position = null;\n-\n- if (this.eventListeners) {\n- this.events.un(this.eventListeners);\n- }\n- this.events.destroy();\n- this.eventListeners = null;\n- this.events = null;\n- },\n-\n- /**\n- * Method: draw\n- * Clear whatever is currently in the tile, then return whether or not \n- * it should actually be re-drawn. This is an example implementation\n- * that can be overridden by subclasses. The minimum thing to do here\n- * is to call and return the result from .\n- *\n- * Parameters:\n- * force - {Boolean} If true, the tile will not be cleared and no beforedraw\n- * event will be fired. This is used for drawing tiles asynchronously\n- * after drawing has been cancelled by returning false from a beforedraw\n- * listener.\n- * \n- * Returns:\n- * {Boolean} Whether or not the tile should actually be drawn. Returns null\n- * if a beforedraw listener returned false.\n- */\n- draw: function(force) {\n- if (!force) {\n- //clear tile's contents and mark as not drawn\n- this.clear();\n- }\n- var draw = this.shouldDraw();\n- if (draw && !force && this.events.triggerEvent(\"beforedraw\") === false) {\n- draw = null;\n- }\n- return draw;\n- },\n-\n- /**\n- * Method: shouldDraw\n- * Return whether or not the tile should actually be (re-)drawn. The only\n- * case where we *wouldn't* want to draw the tile is if the tile is outside\n- * its layer's maxExtent\n- * \n- * Returns:\n- * {Boolean} Whether or not the tile should actually be drawn.\n- */\n- shouldDraw: function() {\n- var withinMaxExtent = false,\n- maxExtent = this.layer.maxExtent;\n- if (maxExtent) {\n- var map = this.layer.map;\n- var worldBounds = map.baseLayer.wrapDateLine && map.getMaxExtent();\n- if (this.bounds.intersectsBounds(maxExtent, {\n- inclusive: false,\n- worldBounds: worldBounds\n- })) {\n- withinMaxExtent = true;\n- }\n- }\n-\n- return withinMaxExtent || this.layer.displayOutsideMaxExtent;\n- },\n-\n- /**\n- * Method: setBounds\n- * Sets the bounds on this instance\n- *\n- * Parameters:\n- * bounds {}\n- */\n- setBounds: function(bounds) {\n- bounds = bounds.clone();\n- if (this.layer.map.baseLayer.wrapDateLine) {\n- var worldExtent = this.layer.map.getMaxExtent(),\n- tolerance = this.layer.map.getResolution();\n- bounds = bounds.wrapDateLine(worldExtent, {\n- leftTolerance: tolerance,\n- rightTolerance: tolerance\n- });\n- }\n- this.bounds = bounds;\n- },\n-\n- /** \n- * Method: moveTo\n- * Reposition the tile.\n- *\n- * Parameters:\n- * bounds - {}\n- * position - {}\n- * redraw - {Boolean} Call draw method on tile after moving.\n- * Default is true\n- */\n- moveTo: function(bounds, position, redraw) {\n- if (redraw == null) {\n- redraw = true;\n- }\n-\n- this.setBounds(bounds);\n- this.position = position.clone();\n- if (redraw) {\n- this.draw();\n- }\n- },\n-\n- /** \n- * Method: clear\n- * Clear the tile of any bounds/position-related data so that it can \n- * be reused in a new location.\n- */\n- clear: function(draw) {\n- // to be extended by subclasses\n- },\n-\n- CLASS_NAME: \"OpenLayers.Tile\"\n-});\n-/* ======================================================================\n- OpenLayers/Strategy.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- */\n-\n-/**\n- * Class: OpenLayers.Strategy\n- * Abstract vector layer strategy class. Not to be instantiated directly. Use\n- * one of the strategy subclasses instead.\n- */\n-OpenLayers.Strategy = OpenLayers.Class({\n-\n- /**\n- * Property: layer\n- * {} The layer this strategy belongs to.\n- */\n- layer: null,\n-\n- /**\n- * Property: options\n- * {Object} Any options sent to the constructor.\n- */\n- options: null,\n-\n- /** \n- * Property: active \n- * {Boolean} The control is active.\n- */\n- active: null,\n-\n- /**\n- * Property: autoActivate\n- * {Boolean} The creator of the strategy can set autoActivate to false\n- * to fully control when the protocol is activated and deactivated.\n- * Defaults to true.\n- */\n- autoActivate: true,\n-\n- /**\n- * Property: autoDestroy\n- * {Boolean} The creator of the strategy can set autoDestroy to false\n- * to fully control when the strategy is destroyed. Defaults to\n- * true.\n- */\n- autoDestroy: true,\n-\n- /**\n- * Constructor: OpenLayers.Strategy\n- * Abstract class for vector strategies. Create instances of a subclass.\n- *\n- * Parameters:\n- * options - {Object} Optional object whose properties will be set on the\n- * instance.\n- */\n- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n- this.options = options;\n- // set the active property here, so that user cannot override it\n- this.active = false;\n- },\n-\n- /**\n- * APIMethod: destroy\n- * Clean up the strategy.\n- */\n- destroy: function() {\n- this.deactivate();\n- this.layer = null;\n- this.options = null;\n- },\n-\n- /**\n- * Method: setLayer\n- * Called to set the property.\n- *\n- * Parameters:\n- * layer - {}\n- */\n- setLayer: function(layer) {\n- this.layer = layer;\n- },\n-\n- /**\n- * Method: activate\n- * Activate the strategy. Register any listeners, do appropriate setup.\n- *\n- * Returns:\n- * {Boolean} True if the strategy was successfully activated or false if\n- * the strategy was already active.\n- */\n- activate: function() {\n- if (!this.active) {\n- this.active = true;\n- return true;\n- }\n- return false;\n- },\n-\n- /**\n- * Method: deactivate\n- * Deactivate the strategy. Unregister any listeners, do appropriate\n- * tear-down.\n- *\n- * Returns:\n- * {Boolean} True if the strategy was successfully deactivated or false if\n- * the strategy was already inactive.\n- */\n- deactivate: function() {\n- if (this.active) {\n- this.active = false;\n- return true;\n- }\n- return false;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Strategy\"\n-});\n-/* ======================================================================\n- OpenLayers/Handler.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Events.js\n- */\n-\n-/**\n- * Class: OpenLayers.Handler\n- * Base class to construct a higher-level handler for event sequences. All\n- * handlers have activate and deactivate methods. In addition, they have\n- * methods named like browser events. When a handler is activated, any\n- * additional methods named like a browser event is registered as a\n- * listener for the corresponding event. When a handler is deactivated,\n- * those same methods are unregistered as event listeners.\n- *\n- * Handlers also typically have a callbacks object with keys named like\n- * the abstracted events or event sequences that they are in charge of\n- * handling. The controls that wrap handlers define the methods that\n- * correspond to these abstract events - so instead of listening for\n- * individual browser events, they only listen for the abstract events\n- * defined by the handler.\n- * \n- * Handlers are created by controls, which ultimately have the responsibility\n- * of making changes to the the state of the application. Handlers\n- * themselves may make temporary changes, but in general are expected to\n- * return the application in the same state that they found it.\n- */\n-OpenLayers.Handler = OpenLayers.Class({\n-\n- /**\n- * Property: id\n- * {String}\n- */\n- id: null,\n-\n- /**\n- * APIProperty: control\n- * {}. The control that initialized this handler. The\n- * control is assumed to have a valid map property - that map is used\n- * in the handler's own setMap method.\n- */\n- control: null,\n-\n- /**\n- * Property: map\n- * {}\n- */\n- map: null,\n-\n- /**\n- * APIProperty: keyMask\n- * {Integer} Use bitwise operators and one or more of the OpenLayers.Handler\n- * constants to construct a keyMask. The keyMask is used by\n- * . If the keyMask matches the combination of keys\n- * down on an event, checkModifiers returns true.\n- *\n- * Example:\n- * (code)\n- * // handler only responds if the Shift key is down\n- * handler.keyMask = OpenLayers.Handler.MOD_SHIFT;\n- *\n- * // handler only responds if Ctrl-Shift is down\n- * handler.keyMask = OpenLayers.Handler.MOD_SHIFT |\n- * OpenLayers.Handler.MOD_CTRL;\n- * (end)\n- */\n- keyMask: null,\n-\n- /**\n- * Property: active\n- * {Boolean}\n- */\n- active: false,\n-\n- /**\n- * Property: evt\n- * {Event} This property references the last event handled by the handler.\n- * Note that this property is not part of the stable API. Use of the\n- * evt property should be restricted to controls in the library\n- * or other applications that are willing to update with changes to\n- * the OpenLayers code.\n- */\n- evt: null,\n-\n- /**\n- * Property: touch\n- * {Boolean} Indicates the support of touch events. When touch events are \n- * started touch will be true and all mouse related listeners will do \n- * nothing.\n- */\n- touch: false,\n-\n- /**\n- * Constructor: OpenLayers.Handler\n- * Construct a handler.\n- *\n- * Parameters:\n- * control - {} The control that initialized this\n- * handler. The control is assumed to have a valid map property; that\n- * map is used in the handler's own setMap method. If a map property\n- * is present in the options argument it will be used instead.\n- * callbacks - {Object} An object whose properties correspond to abstracted\n- * events or sequences of browser events. The values for these\n- * properties are functions defined by the control that get called by\n- * the handler.\n- * options - {Object} An optional object whose properties will be set on\n- * the handler.\n- */\n- initialize: function(control, callbacks, options) {\n- OpenLayers.Util.extend(this, options);\n- this.control = control;\n- this.callbacks = callbacks;\n-\n- var map = this.map || control.map;\n- if (map) {\n- this.setMap(map);\n- }\n-\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n- },\n-\n- /**\n- * Method: setMap\n- */\n- setMap: function(map) {\n- this.map = map;\n- },\n-\n- /**\n- * Method: checkModifiers\n- * Check the keyMask on the handler. If no is set, this always\n- * returns true. If a is set and it matches the combination\n- * of keys down on an event, this returns true.\n- *\n- * Returns:\n- * {Boolean} The keyMask matches the keys down on an event.\n- */\n- checkModifiers: function(evt) {\n- if (this.keyMask == null) {\n- return true;\n- }\n- /* calculate the keyboard modifier mask for this event */\n- var keyModifiers =\n- (evt.shiftKey ? OpenLayers.Handler.MOD_SHIFT : 0) |\n- (evt.ctrlKey ? OpenLayers.Handler.MOD_CTRL : 0) |\n- (evt.altKey ? OpenLayers.Handler.MOD_ALT : 0) |\n- (evt.metaKey ? OpenLayers.Handler.MOD_META : 0);\n-\n- /* if it differs from the handler object's key mask,\n- bail out of the event handler */\n- return (keyModifiers == this.keyMask);\n- },\n-\n- /**\n- * APIMethod: activate\n- * Turn on the handler. Returns false if the handler was already active.\n- * \n- * Returns: \n- * {Boolean} The handler was activated.\n- */\n- activate: function() {\n- if (this.active) {\n- return false;\n- }\n- // register for event handlers defined on this class.\n- var events = OpenLayers.Events.prototype.BROWSER_EVENTS;\n- for (var i = 0, len = events.length; i < len; i++) {\n- if (this[events[i]]) {\n- this.register(events[i], this[events[i]]);\n- }\n- }\n- this.active = true;\n- return true;\n- },\n-\n- /**\n- * APIMethod: deactivate\n- * Turn off the handler. Returns false if the handler was already inactive.\n- * \n- * Returns:\n- * {Boolean} The handler was deactivated.\n- */\n- deactivate: function() {\n- if (!this.active) {\n- return false;\n- }\n- // unregister event handlers defined on this class.\n- var events = OpenLayers.Events.prototype.BROWSER_EVENTS;\n- for (var i = 0, len = events.length; i < len; i++) {\n- if (this[events[i]]) {\n- this.unregister(events[i], this[events[i]]);\n- }\n- }\n- this.touch = false;\n- this.active = false;\n- return true;\n- },\n-\n- /**\n- * Method: startTouch\n- * Start touch events, this method must be called by subclasses in \n- * \"touchstart\" method. When touch events are started will be\n- * true and all mouse related listeners will do nothing.\n- */\n- startTouch: function() {\n- if (!this.touch) {\n- this.touch = true;\n- var events = [\n- \"mousedown\", \"mouseup\", \"mousemove\", \"click\", \"dblclick\",\n- \"mouseout\"\n- ];\n- for (var i = 0, len = events.length; i < len; i++) {\n- if (this[events[i]]) {\n- this.unregister(events[i], this[events[i]]);\n- }\n- }\n- }\n- },\n-\n- /**\n- * Method: callback\n- * Trigger the control's named callback with the given arguments\n- *\n- * Parameters:\n- * name - {String} The key for the callback that is one of the properties\n- * of the handler's callbacks object.\n- * args - {Array(*)} An array of arguments (any type) with which to call \n- * the callback (defined by the control).\n- */\n- callback: function(name, args) {\n- if (name && this.callbacks[name]) {\n- this.callbacks[name].apply(this.control, args);\n- }\n- },\n-\n- /**\n- * Method: register\n- * register an event on the map\n- */\n- register: function(name, method) {\n- // TODO: deal with registerPriority in 3.0\n- this.map.events.registerPriority(name, this, method);\n- this.map.events.registerPriority(name, this, this.setEvent);\n- },\n-\n- /**\n- * Method: unregister\n- * unregister an event from the map\n- */\n- unregister: function(name, method) {\n- this.map.events.unregister(name, this, method);\n- this.map.events.unregister(name, this, this.setEvent);\n- },\n-\n- /**\n- * Method: setEvent\n- * With each registered browser event, the handler sets its own evt\n- * property. This property can be accessed by controls if needed\n- * to get more information about the event that the handler is\n- * processing.\n- *\n- * This allows modifier keys on the event to be checked (alt, shift, ctrl,\n- * and meta cannot be checked with the keyboard handler). For a\n- * control to determine which modifier keys are associated with the\n- * event that a handler is currently processing, it should access\n- * (code)handler.evt.altKey || handler.evt.shiftKey ||\n- * handler.evt.ctrlKey || handler.evt.metaKey(end).\n- *\n- * Parameters:\n- * evt - {Event} The browser event.\n- */\n- setEvent: function(evt) {\n- this.evt = evt;\n- return true;\n- },\n-\n- /**\n- * Method: destroy\n- * Deconstruct the handler.\n- */\n- destroy: function() {\n- // unregister event listeners\n- this.deactivate();\n- // eliminate circular references\n- this.control = this.map = null;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Handler\"\n-});\n-\n-/**\n- * Constant: OpenLayers.Handler.MOD_NONE\n- * If set as the , returns false if any key is down.\n- */\n-OpenLayers.Handler.MOD_NONE = 0;\n-\n-/**\n- * Constant: OpenLayers.Handler.MOD_SHIFT\n- * If set as the , returns false if Shift is down.\n- */\n-OpenLayers.Handler.MOD_SHIFT = 1;\n-\n-/**\n- * Constant: OpenLayers.Handler.MOD_CTRL\n- * If set as the , returns false if Ctrl is down.\n- */\n-OpenLayers.Handler.MOD_CTRL = 2;\n-\n-/**\n- * Constant: OpenLayers.Handler.MOD_ALT\n- * If set as the , returns false if Alt is down.\n- */\n-OpenLayers.Handler.MOD_ALT = 4;\n-\n-/**\n- * Constant: OpenLayers.Handler.MOD_META\n- * If set as the , returns false if Cmd is down.\n- */\n-OpenLayers.Handler.MOD_META = 8;\n-\n-\n-/* ======================================================================\n- OpenLayers/Protocol.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- */\n-\n-/**\n- * Class: OpenLayers.Protocol\n- * Abstract vector layer protocol class. Not to be instantiated directly. Use\n- * one of the protocol subclasses instead.\n- */\n-OpenLayers.Protocol = OpenLayers.Class({\n-\n- /**\n- * Property: format\n- * {} The format used by this protocol.\n- */\n- format: null,\n-\n- /**\n- * Property: options\n- * {Object} Any options sent to the constructor.\n- */\n- options: null,\n-\n- /**\n- * Property: autoDestroy\n- * {Boolean} The creator of the protocol can set autoDestroy to false\n- * to fully control when the protocol is destroyed. Defaults to\n- * true.\n- */\n- autoDestroy: true,\n-\n- /**\n- * Property: defaultFilter\n- * {} Optional default filter to read requests\n- */\n- defaultFilter: null,\n-\n- /**\n- * Constructor: OpenLayers.Protocol\n- * Abstract class for vector protocols. Create instances of a subclass.\n- *\n- * Parameters:\n- * options - {Object} Optional object whose properties will be set on the\n- * instance.\n- */\n- initialize: function(options) {\n- options = options || {};\n- OpenLayers.Util.extend(this, options);\n- this.options = options;\n- },\n-\n- /**\n- * Method: mergeWithDefaultFilter\n- * Merge filter passed to the read method with the default one\n- *\n- * Parameters:\n- * filter - {}\n- */\n- mergeWithDefaultFilter: function(filter) {\n- var merged;\n- if (filter && this.defaultFilter) {\n- merged = new OpenLayers.Filter.Logical({\n- type: OpenLayers.Filter.Logical.AND,\n- filters: [this.defaultFilter, filter]\n- });\n- } else {\n- merged = filter || this.defaultFilter || undefined;\n- }\n- return merged;\n- },\n-\n- /**\n- * APIMethod: destroy\n- * Clean up the protocol.\n- */\n- destroy: function() {\n- this.options = null;\n- this.format = null;\n- },\n-\n- /**\n- * APIMethod: read\n- * Construct a request for reading new features.\n- *\n- * Parameters:\n- * options - {Object} Optional object for configuring the request.\n- *\n- * Returns:\n- * {} An \n- * object, the same object will be passed to the callback function passed\n- * if one exists in the options object.\n- */\n- read: function(options) {\n- options = options || {};\n- options.filter = this.mergeWithDefaultFilter(options.filter);\n- },\n-\n-\n- /**\n- * APIMethod: create\n- * Construct a request for writing newly created features.\n- *\n- * Parameters:\n- * features - {Array({})} or\n- * {}\n- * options - {Object} Optional object for configuring the request.\n- *\n- * Returns:\n- * {} An \n- * object, the same object will be passed to the callback function passed\n- * if one exists in the options object.\n- */\n- create: function() {},\n-\n- /**\n- * APIMethod: update\n- * Construct a request updating modified features.\n- *\n- * Parameters:\n- * features - {Array({})} or\n- * {}\n- * options - {Object} Optional object for configuring the request.\n- *\n- * Returns:\n- * {} An \n- * object, the same object will be passed to the callback function passed\n- * if one exists in the options object.\n- */\n- update: function() {},\n-\n- /**\n- * APIMethod: delete\n- * Construct a request deleting a removed feature.\n- *\n- * Parameters:\n- * feature - {}\n- * options - {Object} Optional object for configuring the request.\n- *\n- * Returns:\n- * {} An \n- * object, the same object will be passed to the callback function passed\n- * if one exists in the options object.\n- */\n- \"delete\": function() {},\n-\n- /**\n- * APIMethod: commit\n- * Go over the features and for each take action\n- * based on the feature state. Possible actions are create,\n- * update and delete.\n- *\n- * Parameters:\n- * features - {Array({})}\n- * options - {Object} Object whose possible keys are \"create\", \"update\",\n- * \"delete\", \"callback\" and \"scope\", the values referenced by the\n- * first three are objects as passed to the \"create\", \"update\", and\n- * \"delete\" methods, the value referenced by the \"callback\" key is\n- * a function which is called when the commit operation is complete\n- * using the scope referenced by the \"scope\" key.\n- *\n- * Returns:\n- * {Array({})} An array of\n- * objects.\n- */\n- commit: function() {},\n-\n- /**\n- * Method: abort\n- * Abort an ongoing request.\n- *\n- * Parameters:\n- * response - {}\n- */\n- abort: function(response) {},\n-\n- /**\n- * Method: createCallback\n- * Returns a function that applies the given public method with resp and\n- * options arguments.\n- *\n- * Parameters:\n- * method - {Function} The method to be applied by the callback.\n- * response - {} The protocol response object.\n- * options - {Object} Options sent to the protocol method\n- */\n- createCallback: function(method, response, options) {\n- return OpenLayers.Function.bind(function() {\n- method.apply(this, [response, options]);\n- }, this);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Protocol\"\n-});\n-\n-/**\n- * Class: OpenLayers.Protocol.Response\n- * Protocols return Response objects to their users.\n- */\n-OpenLayers.Protocol.Response = OpenLayers.Class({\n- /**\n- * Property: code\n- * {Number} - OpenLayers.Protocol.Response.SUCCESS or\n- * OpenLayers.Protocol.Response.FAILURE\n- */\n- code: null,\n-\n- /**\n- * Property: requestType\n- * {String} The type of request this response corresponds to. Either\n- * \"create\", \"read\", \"update\" or \"delete\".\n- */\n- requestType: null,\n-\n- /**\n- * Property: last\n- * {Boolean} - true if this is the last response expected in a commit,\n- * false otherwise, defaults to true.\n- */\n- last: true,\n-\n- /**\n- * Property: features\n- * {Array({})} or {}\n- * The features returned in the response by the server. Depending on the \n- * protocol's read payload, either features or data will be populated.\n- */\n- features: null,\n-\n- /**\n- * Property: data\n- * {Object}\n- * The data returned in the response by the server. Depending on the \n- * protocol's read payload, either features or data will be populated.\n- */\n- data: null,\n-\n- /**\n- * Property: reqFeatures\n- * {Array({})} or {}\n- * The features provided by the user and placed in the request by the\n- * protocol.\n- */\n- reqFeatures: null,\n-\n- /**\n- * Property: priv\n- */\n- priv: null,\n-\n- /**\n- * Property: error\n- * {Object} The error object in case a service exception was encountered.\n- */\n- error: null,\n-\n- /**\n- * Constructor: OpenLayers.Protocol.Response\n- *\n- * Parameters:\n- * options - {Object} Optional object whose properties will be set on the\n- * instance.\n- */\n- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n- },\n-\n- /**\n- * Method: success\n- *\n- * Returns:\n- * {Boolean} - true on success, false otherwise\n- */\n- success: function() {\n- return this.code > 0;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Protocol.Response\"\n-});\n-\n-OpenLayers.Protocol.Response.SUCCESS = 1;\n-OpenLayers.Protocol.Response.FAILURE = 0;\n-/* ======================================================================\n- OpenLayers/StyleMap.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Style.js\n- * @requires OpenLayers/Feature/Vector.js\n- */\n-\n-/**\n- * Class: OpenLayers.StyleMap\n- */\n-OpenLayers.StyleMap = OpenLayers.Class({\n-\n- /**\n- * Property: styles\n- * {Object} Hash of {}, keyed by names of well known\n- * rendering intents (e.g. \"default\", \"temporary\", \"select\", \"delete\").\n- */\n- styles: null,\n-\n- /**\n- * Property: extendDefault\n- * {Boolean} if true, every render intent will extend the symbolizers\n- * specified for the \"default\" intent at rendering time. Otherwise, every\n- * rendering intent will be treated as a completely independent style.\n- */\n- extendDefault: true,\n-\n- /**\n- * Constructor: OpenLayers.StyleMap\n- * \n- * Parameters:\n- * style - {Object} Optional. Either a style hash, or a style object, or\n- * a hash of style objects (style hashes) keyed by rendering\n- * intent. If just one style hash or style object is passed,\n- * this will be used for all known render intents (default,\n- * select, temporary)\n- * options - {Object} optional hash of additional options for this\n- * instance\n- */\n- initialize: function(style, options) {\n- this.styles = {\n- \"default\": new OpenLayers.Style(\n- OpenLayers.Feature.Vector.style[\"default\"]),\n- \"select\": new OpenLayers.Style(\n- OpenLayers.Feature.Vector.style[\"select\"]),\n- \"temporary\": new OpenLayers.Style(\n- OpenLayers.Feature.Vector.style[\"temporary\"]),\n- \"delete\": new OpenLayers.Style(\n- OpenLayers.Feature.Vector.style[\"delete\"])\n- };\n-\n- // take whatever the user passed as style parameter and convert it\n- // into parts of stylemap.\n- if (style instanceof OpenLayers.Style) {\n- // user passed a style object\n- this.styles[\"default\"] = style;\n- this.styles[\"select\"] = style;\n- this.styles[\"temporary\"] = style;\n- this.styles[\"delete\"] = style;\n- } else if (typeof style == \"object\") {\n- for (var key in style) {\n- if (style[key] instanceof OpenLayers.Style) {\n- // user passed a hash of style objects\n- this.styles[key] = style[key];\n- } else if (typeof style[key] == \"object\") {\n- // user passsed a hash of style hashes\n- this.styles[key] = new OpenLayers.Style(style[key]);\n- } else {\n- // user passed a style hash (i.e. symbolizer)\n- this.styles[\"default\"] = new OpenLayers.Style(style);\n- this.styles[\"select\"] = new OpenLayers.Style(style);\n- this.styles[\"temporary\"] = new OpenLayers.Style(style);\n- this.styles[\"delete\"] = new OpenLayers.Style(style);\n- break;\n- }\n- }\n- }\n- OpenLayers.Util.extend(this, options);\n- },\n-\n- /**\n- * Method: destroy\n- */\n- destroy: function() {\n- for (var key in this.styles) {\n- this.styles[key].destroy();\n- }\n- this.styles = null;\n- },\n-\n- /**\n- * Method: createSymbolizer\n- * Creates the symbolizer for a feature for a render intent.\n- * \n- * Parameters:\n- * feature - {} The feature to evaluate the rules\n- * of the intended style against.\n- * intent - {String} The intent determines the symbolizer that will be\n- * used to draw the feature. Well known intents are \"default\"\n- * (for just drawing the features), \"select\" (for selected\n- * features) and \"temporary\" (for drawing features).\n- * \n- * Returns:\n- * {Object} symbolizer hash\n- */\n- createSymbolizer: function(feature, intent) {\n- if (!feature) {\n- feature = new OpenLayers.Feature.Vector();\n- }\n- if (!this.styles[intent]) {\n- intent = \"default\";\n- }\n- feature.renderIntent = intent;\n- var defaultSymbolizer = {};\n- if (this.extendDefault && intent != \"default\") {\n- defaultSymbolizer = this.styles[\"default\"].createSymbolizer(feature);\n- }\n- return OpenLayers.Util.extend(defaultSymbolizer,\n- this.styles[intent].createSymbolizer(feature));\n- },\n-\n- /**\n- * Method: addUniqueValueRules\n- * Convenience method to create comparison rules for unique values of a\n- * property. The rules will be added to the style object for a specified\n- * rendering intent. This method is a shortcut for creating something like\n- * the \"unique value legends\" familiar from well known desktop GIS systems\n- * \n- * Parameters:\n- * renderIntent - {String} rendering intent to add the rules to\n- * property - {String} values of feature attributes to create the\n- * rules for\n- * symbolizers - {Object} Hash of symbolizers, keyed by the desired\n- * property values \n- * context - {Object} An optional object with properties that\n- * symbolizers' property values should be evaluated\n- * against. If no context is specified, feature.attributes\n- * will be used\n- */\n- addUniqueValueRules: function(renderIntent, property, symbolizers, context) {\n- var rules = [];\n- for (var value in symbolizers) {\n- rules.push(new OpenLayers.Rule({\n- symbolizer: symbolizers[value],\n- context: context,\n- filter: new OpenLayers.Filter.Comparison({\n- type: OpenLayers.Filter.Comparison.EQUAL_TO,\n- property: property,\n- value: value\n- })\n- }));\n- }\n- this.styles[renderIntent].addRules(rules);\n- },\n-\n- CLASS_NAME: \"OpenLayers.StyleMap\"\n-});\n-/* ======================================================================\n- OpenLayers/Spherical.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/SingleFile.js\n- */\n-\n-/**\n- * Namespace: Spherical\n- * The OpenLayers.Spherical namespace includes utility functions for\n- * calculations on the basis of a spherical earth (ignoring ellipsoidal\n- * effects), which is accurate enough for most purposes.\n- *\n- * Relevant links:\n- * * http://www.movable-type.co.uk/scripts/latlong.html\n- * * http://code.google.com/apis/maps/documentation/javascript/reference.html#spherical\n- */\n-\n-OpenLayers.Spherical = OpenLayers.Spherical || {};\n-\n-OpenLayers.Spherical.DEFAULT_RADIUS = 6378137;\n-\n-/**\n- * APIFunction: computeDistanceBetween\n- * Computes the distance between two LonLats.\n- *\n- * Parameters:\n- * from - {} or {Object} Starting point. A LonLat or\n- * a JavaScript literal with lon lat properties.\n- * to - {} or {Object} Ending point. A LonLat or a\n- * JavaScript literal with lon lat properties.\n- * radius - {Float} The radius. Optional. Defaults to 6378137 meters.\n- *\n- * Returns:\n- * {Float} The distance in meters.\n- */\n-OpenLayers.Spherical.computeDistanceBetween = function(from, to, radius) {\n- var R = radius || OpenLayers.Spherical.DEFAULT_RADIUS;\n- var sinHalfDeltaLon = Math.sin(Math.PI * (to.lon - from.lon) / 360);\n- var sinHalfDeltaLat = Math.sin(Math.PI * (to.lat - from.lat) / 360);\n- var a = sinHalfDeltaLat * sinHalfDeltaLat +\n- sinHalfDeltaLon * sinHalfDeltaLon * Math.cos(Math.PI * from.lat / 180) * Math.cos(Math.PI * to.lat / 180);\n- return 2 * R * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n-};\n-\n-\n-/**\n- * APIFunction: computeHeading\n- * Computes the heading from one LonLat to another LonLat.\n- *\n- * Parameters:\n- * from - {} or {Object} Starting point. A LonLat or\n- * a JavaScript literal with lon lat properties.\n- * to - {} or {Object} Ending point. A LonLat or a\n- * JavaScript literal with lon lat properties.\n- *\n- * Returns:\n- * {Float} The heading in degrees.\n- */\n-OpenLayers.Spherical.computeHeading = function(from, to) {\n- var y = Math.sin(Math.PI * (from.lon - to.lon) / 180) * Math.cos(Math.PI * to.lat / 180);\n- var x = Math.cos(Math.PI * from.lat / 180) * Math.sin(Math.PI * to.lat / 180) -\n- Math.sin(Math.PI * from.lat / 180) * Math.cos(Math.PI * to.lat / 180) * Math.cos(Math.PI * (from.lon - to.lon) / 180);\n- return 180 * Math.atan2(y, x) / Math.PI;\n-};\n-/* ======================================================================\n- OpenLayers/Filter.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n- * @requires OpenLayers/Style.js\n- */\n-\n-/**\n- * Class: OpenLayers.Filter\n- * This class represents an OGC Filter.\n- */\n-OpenLayers.Filter = OpenLayers.Class({\n-\n- /** \n- * Constructor: OpenLayers.Filter\n- * This class represents a generic filter.\n- *\n- * Parameters:\n- * options - {Object} Optional object whose properties will be set on the\n- * instance.\n- * \n- * Returns:\n- * {}\n- */\n- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n- },\n-\n- /** \n- * APIMethod: destroy\n- * Remove reference to anything added.\n- */\n- destroy: function() {},\n-\n- /**\n- * APIMethod: evaluate\n- * Evaluates this filter in a specific context. Instances or subclasses\n- * are supposed to override this method.\n- * \n- * Parameters:\n- * context - {Object} Context to use in evaluating the filter. If a vector\n- * feature is provided, the feature.attributes will be used as context.\n- * \n- * Returns:\n- * {Boolean} The filter applies.\n- */\n- evaluate: function(context) {\n- return true;\n- },\n-\n- /**\n- * APIMethod: clone\n- * Clones this filter. Should be implemented by subclasses.\n- * \n- * Returns:\n- * {} Clone of this filter.\n- */\n- clone: function() {\n- return null;\n- },\n-\n- /**\n- * APIMethod: toString\n- *\n- * Returns:\n- * {String} Include in your build to get a CQL\n- * representation of the filter returned. Otherwise \"[Object object]\"\n- * will be returned.\n- */\n- toString: function() {\n- var string;\n- if (OpenLayers.Format && OpenLayers.Format.CQL) {\n- string = OpenLayers.Format.CQL.prototype.write(this);\n- } else {\n- string = Object.prototype.toString.call(this);\n- }\n- return string;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Filter\"\n-});\n-/* ======================================================================\n- OpenLayers/Util/vendorPrefix.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/SingleFile.js\n- */\n-\n-OpenLayers.Util = OpenLayers.Util || {};\n-/**\n- * Namespace: OpenLayers.Util.vendorPrefix\n- * A collection of utility functions to detect vendor prefixed features\n- */\n-OpenLayers.Util.vendorPrefix = (function() {\n- \"use strict\";\n-\n- var VENDOR_PREFIXES = [\"\", \"O\", \"ms\", \"Moz\", \"Webkit\"],\n- divStyle = document.createElement(\"div\").style,\n- cssCache = {},\n- jsCache = {};\n-\n-\n- /**\n- * Function: domToCss\n- * Converts a upper camel case DOM style property name to a CSS property\n- * i.e. transformOrigin -> transform-origin\n- * or WebkitTransformOrigin -> -webkit-transform-origin\n- *\n- * Parameters:\n- * prefixedDom - {String} The property to convert\n- *\n- * Returns:\n- * {String} The CSS property\n- */\n- function domToCss(prefixedDom) {\n- if (!prefixedDom) {\n- return null;\n- }\n- return prefixedDom.\n- replace(/([A-Z])/g, function(c) {\n- return \"-\" + c.toLowerCase();\n- }).\n- replace(/^ms-/, \"-ms-\");\n- }\n-\n- /**\n- * APIMethod: css\n- * Detect which property is used for a CSS property\n- *\n- * Parameters:\n- * property - {String} The standard (unprefixed) CSS property name\n- *\n- * Returns:\n- * {String} The standard CSS property, prefixed property or null if not\n- * supported\n- */\n- function css(property) {\n- if (cssCache[property] === undefined) {\n- var domProperty = property.\n- replace(/(-[\\s\\S])/g, function(c) {\n- return c.charAt(1).toUpperCase();\n- });\n- var prefixedDom = style(domProperty);\n- cssCache[property] = domToCss(prefixedDom);\n- }\n- return cssCache[property];\n- }\n-\n- /**\n- * APIMethod: js\n- * Detect which property is used for a JS property/method\n- *\n- * Parameters:\n- * obj - {Object} The object to test on\n- * property - {String} The standard (unprefixed) JS property name\n- *\n- * Returns:\n- * {String} The standard JS property, prefixed property or null if not\n- * supported\n- */\n- function js(obj, property) {\n- if (jsCache[property] === undefined) {\n- var tmpProp,\n- i = 0,\n- l = VENDOR_PREFIXES.length,\n- prefix,\n- isStyleObj = (typeof obj.cssText !== \"undefined\");\n-\n- jsCache[property] = null;\n- for (; i < l; i++) {\n- prefix = VENDOR_PREFIXES[i];\n- if (prefix) {\n- if (!isStyleObj) {\n- // js prefix should be lower-case, while style\n- // properties have upper case on first character\n- prefix = prefix.toLowerCase();\n- }\n- tmpProp = prefix + property.charAt(0).toUpperCase() + property.slice(1);\n- } else {\n- tmpProp = property;\n- }\n-\n- if (obj[tmpProp] !== undefined) {\n- jsCache[property] = tmpProp;\n- break;\n- }\n- }\n- }\n- return jsCache[property];\n- }\n-\n- /**\n- * APIMethod: style\n- * Detect which property is used for a DOM style property\n- *\n- * Parameters:\n- * property - {String} The standard (unprefixed) style property name\n- *\n- * Returns:\n- * {String} The standard style property, prefixed property or null if not\n- * supported\n- */\n- function style(property) {\n- return js(divStyle, property);\n- }\n-\n- return {\n- css: css,\n- js: js,\n- style: style,\n-\n- // used for testing\n- cssCache: cssCache,\n- jsCache: jsCache\n- };\n-}());\n-/* ======================================================================\n- OpenLayers/Animation.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/SingleFile.js\n- * @requires OpenLayers/Util/vendorPrefix.js\n- */\n-\n-/**\n- * Namespace: OpenLayers.Animation\n- * A collection of utility functions for executing methods that repaint a \n- * portion of the browser window. These methods take advantage of the\n- * browser's scheduled repaints where requestAnimationFrame is available.\n- */\n-OpenLayers.Animation = (function(window) {\n-\n- /**\n- * Property: isNative\n- * {Boolean} true if a native requestAnimationFrame function is available\n- */\n- var requestAnimationFrame = OpenLayers.Util.vendorPrefix.js(window, \"requestAnimationFrame\");\n- var isNative = !!(requestAnimationFrame);\n-\n- /**\n- * Function: requestFrame\n- * Schedule a function to be called at the next available animation frame.\n- * Uses the native method where available. Where requestAnimationFrame is\n- * not available, setTimeout will be called with a 16ms delay.\n- *\n- * Parameters:\n- * callback - {Function} The function to be called at the next animation frame.\n- * element - {DOMElement} Optional element that visually bounds the animation.\n- */\n- var requestFrame = (function() {\n- var request = window[requestAnimationFrame] ||\n- function(callback, element) {\n- window.setTimeout(callback, 16);\n- };\n- // bind to window to avoid illegal invocation of native function\n- return function(callback, element) {\n- request.apply(window, [callback, element]);\n- };\n- })();\n-\n- // private variables for animation loops\n- var counter = 0;\n- var loops = {};\n-\n- /**\n- * Function: start\n- * Executes a method with in series for some \n- * duration.\n- *\n- * Parameters:\n- * callback - {Function} The function to be called at the next animation frame.\n- * duration - {Number} Optional duration for the loop. If not provided, the\n- * animation loop will execute indefinitely.\n- * element - {DOMElement} Optional element that visually bounds the animation.\n- *\n- * Returns:\n- * {Number} Identifier for the animation loop. Used to stop animations with\n- * .\n- */\n- function start(callback, duration, element) {\n- duration = duration > 0 ? duration : Number.POSITIVE_INFINITY;\n- var id = ++counter;\n- var start = +new Date;\n- loops[id] = function() {\n- if (loops[id] && +new Date - start <= duration) {\n- callback();\n- if (loops[id]) {\n- requestFrame(loops[id], element);\n- }\n- } else {\n- delete loops[id];\n- }\n- };\n- requestFrame(loops[id], element);\n- return id;\n- }\n-\n- /**\n- * Function: stop\n- * Terminates an animation loop started with .\n- *\n- * Parameters:\n- * id - {Number} Identifier returned from .\n- */\n- function stop(id) {\n- delete loops[id];\n- }\n-\n- return {\n- isNative: isNative,\n- requestFrame: requestFrame,\n- start: start,\n- stop: stop\n- };\n-\n-})(window);\n-/* ======================================================================\n- OpenLayers/Tween.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Animation.js\n- */\n-\n-/**\n- * Namespace: OpenLayers.Tween\n- */\n-OpenLayers.Tween = OpenLayers.Class({\n-\n- /**\n- * APIProperty: easing\n- * {(Function)} Easing equation used for the animation\n- * Defaultly set to OpenLayers.Easing.Expo.easeOut\n- */\n- easing: null,\n-\n- /**\n- * APIProperty: begin\n- * {Object} Values to start the animation with\n- */\n- begin: null,\n-\n- /**\n- * APIProperty: finish\n- * {Object} Values to finish the animation with\n- */\n- finish: null,\n-\n- /**\n- * APIProperty: duration\n- * {int} duration of the tween (number of steps)\n- */\n- duration: null,\n-\n- /**\n- * APIProperty: callbacks\n- * {Object} An object with start, eachStep and done properties whose values\n- * are functions to be call during the animation. They are passed the\n- * current computed value as argument.\n- */\n- callbacks: null,\n-\n- /**\n- * Property: time\n- * {int} Step counter\n- */\n- time: null,\n-\n- /**\n- * APIProperty: minFrameRate\n- * {Number} The minimum framerate for animations in frames per second. After\n- * each step, the time spent in the animation is compared to the calculated\n- * time at this frame rate. If the animation runs longer than the calculated\n- * time, the next step is skipped. Default is 30.\n- */\n- minFrameRate: null,\n-\n- /**\n- * Property: startTime\n- * {Number} The timestamp of the first execution step. Used for skipping\n- * frames\n- */\n- startTime: null,\n-\n- /**\n- * Property: animationId\n- * {int} Loop id returned by OpenLayers.Animation.start\n- */\n- animationId: null,\n-\n- /**\n- * Property: playing\n- * {Boolean} Tells if the easing is currently playing\n- */\n- playing: false,\n-\n- /** \n- * Constructor: OpenLayers.Tween\n- * Creates a Tween.\n- *\n- * Parameters:\n- * easing - {(Function)} easing function method to use\n- */\n- initialize: function(easing) {\n- this.easing = (easing) ? easing : OpenLayers.Easing.Expo.easeOut;\n- },\n-\n- /**\n- * APIMethod: start\n- * Plays the Tween, and calls the callback method on each step\n- * \n- * Parameters:\n- * begin - {Object} values to start the animation with\n- * finish - {Object} values to finish the animation with\n- * duration - {int} duration of the tween (number of steps)\n- * options - {Object} hash of options (callbacks (start, eachStep, done),\n- * minFrameRate)\n- */\n- start: function(begin, finish, duration, options) {\n- this.playing = true;\n- this.begin = begin;\n- this.finish = finish;\n- this.duration = duration;\n- this.callbacks = options.callbacks;\n- this.minFrameRate = options.minFrameRate || 30;\n- this.time = 0;\n- this.startTime = new Date().getTime();\n- OpenLayers.Animation.stop(this.animationId);\n- this.animationId = null;\n- if (this.callbacks && this.callbacks.start) {\n- this.callbacks.start.call(this, this.begin);\n- }\n- this.animationId = OpenLayers.Animation.start(\n- OpenLayers.Function.bind(this.play, this)\n- );\n- },\n-\n- /**\n- * APIMethod: stop\n- * Stops the Tween, and calls the done callback\n- * Doesn't do anything if animation is already finished\n- */\n- stop: function() {\n- if (!this.playing) {\n- return;\n- }\n-\n- if (this.callbacks && this.callbacks.done) {\n- this.callbacks.done.call(this, this.finish);\n- }\n- OpenLayers.Animation.stop(this.animationId);\n- this.animationId = null;\n- this.playing = false;\n- },\n-\n- /**\n- * Method: play\n- * Calls the appropriate easing method\n- */\n- play: function() {\n- var value = {};\n- for (var i in this.begin) {\n- var b = this.begin[i];\n- var f = this.finish[i];\n- if (b == null || f == null || isNaN(b) || isNaN(f)) {\n- throw new TypeError('invalid value for Tween');\n- }\n-\n- var c = f - b;\n- value[i] = this.easing.apply(this, [this.time, b, c, this.duration]);\n- }\n- this.time++;\n-\n- if (this.callbacks && this.callbacks.eachStep) {\n- // skip frames if frame rate drops below threshold\n- if ((new Date().getTime() - this.startTime) / this.time <= 1000 / this.minFrameRate) {\n- this.callbacks.eachStep.call(this, value);\n- }\n- }\n-\n- if (this.time > this.duration) {\n- this.stop();\n- }\n- },\n-\n- /**\n- * Create empty functions for all easing methods.\n- */\n- CLASS_NAME: \"OpenLayers.Tween\"\n-});\n-\n-/**\n- * Namespace: OpenLayers.Easing\n- * \n- * Credits:\n- * Easing Equations by Robert Penner, \n- */\n-OpenLayers.Easing = {\n- /**\n- * Create empty functions for all easing methods.\n- */\n- CLASS_NAME: \"OpenLayers.Easing\"\n-};\n-\n-/**\n- * Namespace: OpenLayers.Easing.Linear\n- */\n-OpenLayers.Easing.Linear = {\n-\n- /**\n- * Function: easeIn\n- * \n- * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n- * Returns:\n- * {Float}\n- */\n- easeIn: function(t, b, c, d) {\n- return c * t / d + b;\n- },\n-\n- /**\n- * Function: easeOut\n- * \n- * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n- * Returns:\n- * {Float}\n- */\n- easeOut: function(t, b, c, d) {\n- return c * t / d + b;\n- },\n-\n- /**\n- * Function: easeInOut\n- * \n- * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n- * Returns:\n- * {Float}\n- */\n- easeInOut: function(t, b, c, d) {\n- return c * t / d + b;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Easing.Linear\"\n-};\n-\n-/**\n- * Namespace: OpenLayers.Easing.Expo\n- */\n-OpenLayers.Easing.Expo = {\n-\n- /**\n- * Function: easeIn\n- * \n- * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n- * Returns:\n- * {Float}\n- */\n- easeIn: function(t, b, c, d) {\n- return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;\n- },\n-\n- /**\n- * Function: easeOut\n- * \n- * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n- * Returns:\n- * {Float}\n- */\n- easeOut: function(t, b, c, d) {\n- return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;\n- },\n-\n- /**\n- * Function: easeInOut\n- * \n- * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n- * Returns:\n- * {Float}\n- */\n- easeInOut: function(t, b, c, d) {\n- if (t == 0) return b;\n- if (t == d) return b + c;\n- if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;\n- return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Easing.Expo\"\n-};\n-\n-/**\n- * Namespace: OpenLayers.Easing.Quad\n- */\n-OpenLayers.Easing.Quad = {\n-\n- /**\n- * Function: easeIn\n- * \n- * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n- * Returns:\n- * {Float}\n- */\n- easeIn: function(t, b, c, d) {\n- return c * (t /= d) * t + b;\n- },\n-\n- /**\n- * Function: easeOut\n- * \n- * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n- * Returns:\n- * {Float}\n- */\n- easeOut: function(t, b, c, d) {\n- return -c * (t /= d) * (t - 2) + b;\n- },\n-\n- /**\n- * Function: easeInOut\n- * \n- * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n- * Returns:\n- * {Float}\n- */\n- easeInOut: function(t, b, c, d) {\n- if ((t /= d / 2) < 1) return c / 2 * t * t + b;\n- return -c / 2 * ((--t) * (t - 2) - 1) + b;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Easing.Quad\"\n-};\n-/* ======================================================================\n- OpenLayers/Projection.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n- */\n-\n-/**\n- * Namespace: OpenLayers.Projection\n- * Methods for coordinate transforms between coordinate systems. By default,\n- * OpenLayers ships with the ability to transform coordinates between\n- * geographic (EPSG:4326) and web or spherical mercator (EPSG:900913 et al.)\n- * coordinate reference systems. See the method for details\n- * on usage.\n- *\n- * Additional transforms may be added by using the \n- * library. If the proj4js library is included, the method \n- * will work between any two coordinate reference systems with proj4js \n- * definitions.\n- *\n- * If the proj4js library is not included, or if you wish to allow transforms\n- * between arbitrary coordinate reference systems, use the \n- * method to register a custom transform method.\n- */\n-OpenLayers.Projection = OpenLayers.Class({\n-\n- /**\n- * Property: proj\n- * {Object} Proj4js.Proj instance.\n- */\n- proj: null,\n-\n- /**\n- * Property: projCode\n- * {String}\n- */\n- projCode: null,\n-\n- /**\n- * Property: titleRegEx\n- * {RegExp} regular expression to strip the title from a proj4js definition\n- */\n- titleRegEx: /\\+title=[^\\+]*/,\n-\n- /**\n- * Constructor: OpenLayers.Projection\n- * This class offers several methods for interacting with a wrapped \n- * pro4js projection object. \n- *\n- * Parameters:\n- * projCode - {String} A string identifying the Well Known Identifier for\n- * the projection.\n- * options - {Object} An optional object to set additional properties\n- * on the projection.\n- *\n- * Returns:\n- * {} A projection object.\n- */\n- initialize: function(projCode, options) {\n- OpenLayers.Util.extend(this, options);\n- this.projCode = projCode;\n- if (typeof Proj4js == \"object\") {\n- this.proj = new Proj4js.Proj(projCode);\n- }\n- },\n-\n- /**\n- * APIMethod: getCode\n- * Get the string SRS code.\n- *\n- * Returns:\n- * {String} The SRS code.\n- */\n- getCode: function() {\n- return this.proj ? this.proj.srsCode : this.projCode;\n- },\n-\n- /**\n- * APIMethod: getUnits\n- * Get the units string for the projection -- returns null if \n- * proj4js is not available.\n- *\n- * Returns:\n- * {String} The units abbreviation.\n- */\n- getUnits: function() {\n- return this.proj ? this.proj.units : null;\n- },\n-\n- /**\n- * Method: toString\n- * Convert projection to string (getCode wrapper).\n- *\n- * Returns:\n- * {String} The projection code.\n- */\n- toString: function() {\n- return this.getCode();\n- },\n-\n- /**\n- * Method: equals\n- * Test equality of two projection instances. Determines equality based\n- * soley on the projection code.\n- *\n- * Returns:\n- * {Boolean} The two projections are equivalent.\n- */\n- equals: function(projection) {\n- var p = projection,\n- equals = false;\n- if (p) {\n- if (!(p instanceof OpenLayers.Projection)) {\n- p = new OpenLayers.Projection(p);\n- }\n- if ((typeof Proj4js == \"object\") && this.proj.defData && p.proj.defData) {\n- equals = this.proj.defData.replace(this.titleRegEx, \"\") ==\n- p.proj.defData.replace(this.titleRegEx, \"\");\n- } else if (p.getCode) {\n- var source = this.getCode(),\n- target = p.getCode();\n- equals = source == target ||\n- !!OpenLayers.Projection.transforms[source] &&\n- OpenLayers.Projection.transforms[source][target] ===\n- OpenLayers.Projection.nullTransform;\n- }\n- }\n- return equals;\n- },\n-\n- /* Method: destroy\n- * Destroy projection object.\n- */\n- destroy: function() {\n- delete this.proj;\n- delete this.projCode;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Projection\"\n-});\n-\n-/**\n- * Property: transforms\n- * {Object} Transforms is an object, with from properties, each of which may\n- * have a to property. This allows you to define projections without \n- * requiring support for proj4js to be included.\n- *\n- * This object has keys which correspond to a 'source' projection object. The\n- * keys should be strings, corresponding to the projection.getCode() value.\n- * Each source projection object should have a set of destination projection\n- * keys included in the object. \n- * \n- * Each value in the destination object should be a transformation function,\n- * where the function is expected to be passed an object with a .x and a .y\n- * property. The function should return the object, with the .x and .y\n- * transformed according to the transformation function.\n- *\n- * Note - Properties on this object should not be set directly. To add a\n- * transform method to this object, use the method. For an\n- * example of usage, see the OpenLayers.Layer.SphericalMercator file.\n- */\n-OpenLayers.Projection.transforms = {};\n-\n-/**\n- * APIProperty: defaults\n- * {Object} Defaults for the SRS codes known to OpenLayers (currently\n- * EPSG:4326, CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, EPSG:900913, EPSG:3857,\n- * EPSG:102113 and EPSG:102100). Keys are the SRS code, values are units,\n- * maxExtent (the validity extent for the SRS) and yx (true if this SRS is\n- * known to have a reverse axis order).\n- */\n-OpenLayers.Projection.defaults = {\n- \"EPSG:4326\": {\n- units: \"degrees\",\n- maxExtent: [-180, -90, 180, 90],\n- yx: true\n- },\n- \"CRS:84\": {\n- units: \"degrees\",\n- maxExtent: [-180, -90, 180, 90]\n- },\n- \"EPSG:900913\": {\n- units: \"m\",\n- maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34]\n- }\n-};\n-\n-/**\n- * APIMethod: addTransform\n- * Set a custom transform method between two projections. Use this method in\n- * cases where the proj4js lib is not available or where custom projections\n- * need to be handled.\n- *\n- * Parameters:\n- * from - {String} The code for the source projection\n- * to - {String} the code for the destination projection\n- * method - {Function} A function that takes a point as an argument and\n- * transforms that point from the source to the destination projection\n- * in place. The original point should be modified.\n- */\n-OpenLayers.Projection.addTransform = function(from, to, method) {\n- if (method === OpenLayers.Projection.nullTransform) {\n- var defaults = OpenLayers.Projection.defaults[from];\n- if (defaults && !OpenLayers.Projection.defaults[to]) {\n- OpenLayers.Projection.defaults[to] = defaults;\n- }\n- }\n- if (!OpenLayers.Projection.transforms[from]) {\n- OpenLayers.Projection.transforms[from] = {};\n- }\n- OpenLayers.Projection.transforms[from][to] = method;\n-};\n-\n-/**\n- * APIMethod: transform\n- * Transform a point coordinate from one projection to another. Note that\n- * the input point is transformed in place.\n- * \n- * Parameters:\n- * point - { | Object} An object with x and y\n- * properties representing coordinates in those dimensions.\n- * source - {OpenLayers.Projection} Source map coordinate system\n- * dest - {OpenLayers.Projection} Destination map coordinate system\n- *\n- * Returns:\n- * point - {object} A transformed coordinate. The original point is modified.\n- */\n-OpenLayers.Projection.transform = function(point, source, dest) {\n- if (source && dest) {\n- if (!(source instanceof OpenLayers.Projection)) {\n- source = new OpenLayers.Projection(source);\n- }\n- if (!(dest instanceof OpenLayers.Projection)) {\n- dest = new OpenLayers.Projection(dest);\n- }\n- if (source.proj && dest.proj) {\n- point = Proj4js.transform(source.proj, dest.proj, point);\n- } else {\n- var sourceCode = source.getCode();\n- var destCode = dest.getCode();\n- var transforms = OpenLayers.Projection.transforms;\n- if (transforms[sourceCode] && transforms[sourceCode][destCode]) {\n- transforms[sourceCode][destCode](point);\n- }\n- }\n- }\n- return point;\n-};\n-\n-/**\n- * APIFunction: nullTransform\n- * A null transformation - useful for defining projection aliases when\n- * proj4js is not available:\n- *\n- * (code)\n- * OpenLayers.Projection.addTransform(\"EPSG:3857\", \"EPSG:900913\",\n- * OpenLayers.Projection.nullTransform);\n- * OpenLayers.Projection.addTransform(\"EPSG:900913\", \"EPSG:3857\",\n- * OpenLayers.Projection.nullTransform);\n- * (end)\n- */\n-OpenLayers.Projection.nullTransform = function(point) {\n- return point;\n-};\n-\n-/**\n- * Note: Transforms for web mercator <-> geographic\n- * OpenLayers recognizes EPSG:3857, EPSG:900913, EPSG:102113 and EPSG:102100.\n- * OpenLayers originally started referring to EPSG:900913 as web mercator.\n- * The EPSG has declared EPSG:3857 to be web mercator.\n- * ArcGIS 10 recognizes the EPSG:3857, EPSG:102113, and EPSG:102100 as\n- * 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.\n- * For geographic, OpenLayers recognizes EPSG:4326, CRS:84 and\n- * urn:ogc:def:crs:EPSG:6.6:4326. OpenLayers also knows about the reverse axis\n- * order for EPSG:4326. \n- */\n-(function() {\n-\n- var pole = 20037508.34;\n-\n- function inverseMercator(xy) {\n- xy.x = 180 * xy.x / pole;\n- xy.y = 180 / Math.PI * (2 * Math.atan(Math.exp((xy.y / pole) * Math.PI)) - Math.PI / 2);\n- return xy;\n- }\n-\n- function forwardMercator(xy) {\n- xy.x = xy.x * pole / 180;\n- var y = Math.log(Math.tan((90 + xy.y) * Math.PI / 360)) / Math.PI * pole;\n- xy.y = Math.max(-20037508.34, Math.min(y, 20037508.34));\n- return xy;\n- }\n-\n- function map(base, codes) {\n- var add = OpenLayers.Projection.addTransform;\n- var same = OpenLayers.Projection.nullTransform;\n- var i, len, code, other, j;\n- for (i = 0, len = codes.length; i < len; ++i) {\n- code = codes[i];\n- add(base, code, forwardMercator);\n- add(code, base, inverseMercator);\n- for (j = i + 1; j < len; ++j) {\n- other = codes[j];\n- add(code, other, same);\n- add(other, code, same);\n- }\n- }\n- }\n-\n- // list of equivalent codes for web mercator\n- var mercator = [\"EPSG:900913\", \"EPSG:3857\", \"EPSG:102113\", \"EPSG:102100\"],\n- geographic = [\"CRS:84\", \"urn:ogc:def:crs:EPSG:6.6:4326\", \"EPSG:4326\"],\n- i;\n- for (i = mercator.length - 1; i >= 0; --i) {\n- map(mercator[i], geographic);\n- }\n- for (i = geographic.length - 1; i >= 0; --i) {\n- map(geographic[i], mercator);\n- }\n-\n-})();\n-/* ======================================================================\n- OpenLayers/Map.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n- * @requires OpenLayers/Util/vendorPrefix.js\n- * @requires OpenLayers/Events.js\n- * @requires OpenLayers/Tween.js\n- * @requires OpenLayers/Projection.js\n- */\n-\n-/**\n- * Class: OpenLayers.Map\n- * Instances of OpenLayers.Map are interactive maps embedded in a web page.\n- * Create a new map with the constructor.\n- * \n- * On their own maps do not provide much functionality. To extend a map\n- * it's necessary to add controls () and \n- * layers () to the map. \n- */\n-OpenLayers.Map = OpenLayers.Class({\n-\n- /**\n- * Constant: Z_INDEX_BASE\n- * {Object} Base z-indexes for different classes of thing \n- */\n- Z_INDEX_BASE: {\n- BaseLayer: 100,\n- Overlay: 325,\n- Feature: 725,\n- Popup: 750,\n- Control: 1000\n- },\n-\n- /**\n- * APIProperty: events\n- * {}\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * map.events.register(type, obj, listener);\n- * (end)\n- *\n- * Listeners will be called with a reference to an event object. The\n- * properties of this event depends on exactly what happened.\n- *\n- * All event objects have at least the following properties:\n- * object - {Object} A reference to map.events.object.\n- * element - {DOMElement} A reference to map.events.element.\n- *\n- * Browser events have the following additional properties:\n- * xy - {} The pixel location of the event (relative\n- * to the the map viewport).\n- *\n- * Supported map event types:\n- * preaddlayer - triggered before a layer has been added. The event\n- * object will include a *layer* property that references the layer \n- * to be added. When a listener returns \"false\" the adding will be \n- * aborted.\n- * addlayer - triggered after a layer has been added. The event object\n- * will include a *layer* property that references the added layer.\n- * preremovelayer - triggered before a layer has been removed. The event\n- * object will include a *layer* property that references the layer \n- * to be removed. When a listener returns \"false\" the removal will be \n- * aborted.\n- * removelayer - triggered after a layer has been removed. The event\n- * object will include a *layer* property that references the removed\n- * layer.\n- * changelayer - triggered after a layer name change, order change,\n- * opacity change, params change, visibility change (actual visibility,\n- * not the layer's visibility property) or attribution change (due to\n- * extent change). Listeners will receive an event object with *layer*\n- * and *property* properties. The *layer* property will be a reference\n- * to the changed layer. The *property* property will be a key to the\n- * changed property (name, order, opacity, params, visibility or\n- * attribution).\n- * movestart - triggered after the start of a drag, pan, or zoom. The event\n- * object may include a *zoomChanged* property that tells whether the\n- * zoom has changed.\n- * move - triggered after each drag, pan, or zoom\n- * moveend - triggered after a drag, pan, or zoom completes\n- * zoomend - triggered after a zoom completes\n- * mouseover - triggered after mouseover the map\n- * mouseout - triggered after mouseout the map\n- * mousemove - triggered after mousemove the map\n- * changebaselayer - triggered after the base layer changes\n- * updatesize - triggered after the method was executed\n- */\n-\n- /**\n- * Property: id\n- * {String} Unique identifier for the map\n- */\n- id: null,\n-\n- /**\n- * Property: fractionalZoom\n- * {Boolean} For a base layer that supports it, allow the map resolution\n- * to be set to a value between one of the values in the resolutions\n- * array. Default is false.\n- *\n- * When fractionalZoom is set to true, it is possible to zoom to\n- * an arbitrary extent. This requires a base layer from a source\n- * that supports requests for arbitrary extents (i.e. not cached\n- * tiles on a regular lattice). This means that fractionalZoom\n- * will not work with commercial layers (Google, Yahoo, VE), layers\n- * using TileCache, or any other pre-cached data sources.\n- *\n- * If you are using fractionalZoom, then you should also use\n- * instead of layer.resolutions[zoom] as the\n- * former works for non-integer zoom levels.\n- */\n- fractionalZoom: false,\n-\n- /**\n- * APIProperty: events\n- * {} An events object that handles all \n- * events on the map\n- */\n- events: null,\n-\n- /**\n- * APIProperty: allOverlays\n- * {Boolean} Allow the map to function with \"overlays\" only. Defaults to\n- * false. If true, the lowest layer in the draw order will act as\n- * the base layer. In addition, if set to true, all layers will\n- * have isBaseLayer set to false when they are added to the map.\n- *\n- * Note:\n- * If you set map.allOverlays to true, then you *cannot* use\n- * map.setBaseLayer or layer.setIsBaseLayer. With allOverlays true,\n- * the lowest layer in the draw layer is the base layer. So, to change\n- * the base layer, use or to set the layer\n- * index to 0.\n- */\n- allOverlays: false,\n-\n- /**\n- * APIProperty: div\n- * {DOMElement|String} The element that contains the map (or an id for\n- * that element). If the constructor is called\n- * with two arguments, this should be provided as the first argument.\n- * Alternatively, the map constructor can be called with the options\n- * object as the only argument. In this case (one argument), a\n- * div property may or may not be provided. If the div property\n- * is not provided, the map can be rendered to a container later\n- * using the method.\n- * \n- * Note:\n- * If you are calling after map construction, do not use\n- * auto. Instead, divide your by your\n- * maximum expected dimension.\n- */\n- div: null,\n-\n- /**\n- * Property: dragging\n- * {Boolean} The map is currently being dragged.\n- */\n- dragging: false,\n-\n- /**\n- * Property: size\n- * {} Size of the main div (this.div)\n- */\n- size: null,\n-\n- /**\n- * Property: viewPortDiv\n- * {HTMLDivElement} The element that represents the map viewport\n- */\n- viewPortDiv: null,\n-\n- /**\n- * Property: layerContainerOrigin\n- * {} The lonlat at which the later container was\n- * re-initialized (on-zoom)\n+ * Property: layerContainerOrigin\n+ * {} The lonlat at which the later container was\n+ * re-initialized (on-zoom)\n */\n layerContainerOrigin: null,\n \n /**\n * Property: layerContainerDiv\n * {HTMLDivElement} The element that contains the layers.\n */\n@@ -13602,24625 +9882,24161 @@\n OpenLayers.Map.TILE_WIDTH = 256;\n /**\n * Constant: TILE_HEIGHT\n * {Integer} 256 Default tile height (unless otherwise specified)\n */\n OpenLayers.Map.TILE_HEIGHT = 256;\n /* ======================================================================\n- OpenLayers/Icon.js\n+ OpenLayers/Layer.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Map.js\n+ * @requires OpenLayers/Projection.js\n */\n \n /**\n- * Class: OpenLayers.Icon\n- * \n- * The icon represents a graphical icon on the screen. Typically used in\n- * conjunction with a to represent markers on a screen.\n- *\n- * An icon has a url, size and position. It also contains an offset which \n- * allows the center point to be represented correctly. This can be\n- * provided either as a fixed offset or a function provided to calculate\n- * the desired offset. \n- * \n+ * Class: OpenLayers.Layer\n */\n-OpenLayers.Icon = OpenLayers.Class({\n+OpenLayers.Layer = OpenLayers.Class({\n \n- /** \n- * Property: url \n- * {String} image url\n+ /**\n+ * APIProperty: id\n+ * {String}\n */\n- url: null,\n+ id: null,\n \n /** \n- * Property: size \n- * {|Object} An OpenLayers.Size or\n- * an object with a 'w' and 'h' properties.\n+ * APIProperty: name\n+ * {String}\n */\n- size: null,\n+ name: null,\n \n /** \n- * Property: offset \n- * {|Object} distance in pixels to offset the\n- * image when being rendered. An OpenLayers.Pixel or an object\n- * with a 'x' and 'y' properties.\n+ * APIProperty: div\n+ * {DOMElement}\n */\n- offset: null,\n+ div: null,\n \n- /** \n- * Property: calculateOffset \n- * {Function} Function to calculate the offset (based on the size)\n+ /**\n+ * APIProperty: opacity\n+ * {Float} The layer's opacity. Float number between 0.0 and 1.0. Default\n+ * is 1.\n */\n- calculateOffset: null,\n+ opacity: 1,\n \n- /** \n- * Property: imageDiv \n- * {DOMElement} \n+ /**\n+ * APIProperty: alwaysInRange\n+ * {Boolean} If a layer's display should not be scale-based, this should \n+ * be set to true. This will cause the layer, as an overlay, to always \n+ * be 'active', by always returning true from the calculateInRange() \n+ * function. \n+ * \n+ * If not explicitly specified for a layer, its value will be \n+ * determined on startup in initResolutions() based on whether or not \n+ * any scale-specific properties have been set as options on the \n+ * layer. If no scale-specific options have been set on the layer, we \n+ * assume that it should always be in range.\n+ * \n+ * See #987 for more info.\n */\n- imageDiv: null,\n+ alwaysInRange: null,\n \n- /** \n- * Property: px \n- * {|Object} An OpenLayers.Pixel or an object\n- * with a 'x' and 'y' properties.\n+ /**\n+ * Constant: RESOLUTION_PROPERTIES\n+ * {Array} The properties that are used for calculating resolutions\n+ * information.\n */\n- px: null,\n+ RESOLUTION_PROPERTIES: [\n+ 'scales', 'resolutions',\n+ 'maxScale', 'minScale',\n+ 'maxResolution', 'minResolution',\n+ 'numZoomLevels', 'maxZoomLevel'\n+ ],\n \n- /** \n- * Constructor: OpenLayers.Icon\n- * Creates an icon, which is an image tag in a div. \n+ /**\n+ * APIProperty: events\n+ * {}\n *\n- * url - {String} \n- * size - {|Object} An OpenLayers.Size or an\n- * object with a 'w' and 'h'\n- * properties.\n- * offset - {|Object} An OpenLayers.Pixel or an\n- * object with a 'x' and 'y'\n- * properties.\n- * calculateOffset - {Function} \n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * layer.events.register(type, obj, listener);\n+ * (end)\n+ *\n+ * Listeners will be called with a reference to an event object. The\n+ * properties of this event depends on exactly what happened.\n+ *\n+ * All event objects have at least the following properties:\n+ * object - {Object} A reference to layer.events.object.\n+ * element - {DOMElement} A reference to layer.events.element.\n+ *\n+ * Supported map event types:\n+ * loadstart - Triggered when layer loading starts. When using a Vector \n+ * layer with a Fixed or BBOX strategy, the event object includes \n+ * a *filter* property holding the OpenLayers.Filter used when \n+ * calling read on the protocol.\n+ * loadend - Triggered when layer loading ends. When using a Vector layer\n+ * with a Fixed or BBOX strategy, the event object includes a \n+ * *response* property holding an OpenLayers.Protocol.Response object.\n+ * visibilitychanged - Triggered when the layer's visibility property is\n+ * changed, e.g. by turning the layer on or off in the layer switcher.\n+ * Note that the actual visibility of the layer can also change if it\n+ * gets out of range (see ). If you also want to catch\n+ * these cases, register for the map's 'changelayer' event instead.\n+ * move - Triggered when layer moves (triggered with every mousemove\n+ * during a drag).\n+ * moveend - Triggered when layer is done moving, object passed as\n+ * argument has a zoomChanged boolean property which tells that the\n+ * zoom has changed.\n+ * added - Triggered after the layer is added to a map. Listeners will\n+ * receive an object with a *map* property referencing the map and a\n+ * *layer* property referencing the layer.\n+ * removed - Triggered after the layer is removed from the map. Listeners\n+ * will receive an object with a *map* property referencing the map and\n+ * a *layer* property referencing the layer.\n */\n- initialize: function(url, size, offset, calculateOffset) {\n- this.url = url;\n- this.size = size || {\n- w: 20,\n- h: 20\n- };\n- this.offset = offset || {\n- x: -(this.size.w / 2),\n- y: -(this.size.h / 2)\n- };\n- this.calculateOffset = calculateOffset;\n+ events: null,\n \n- var id = OpenLayers.Util.createUniqueID(\"OL_Icon_\");\n- this.imageDiv = OpenLayers.Util.createAlphaImageDiv(id);\n- },\n+ /**\n+ * APIProperty: map\n+ * {} This variable is set when the layer is added to \n+ * the map, via the accessor function setMap().\n+ */\n+ map: null,\n \n- /** \n- * Method: destroy\n- * Nullify references and remove event listeners to prevent circular \n- * references and memory leaks\n+ /**\n+ * APIProperty: isBaseLayer\n+ * {Boolean} Whether or not the layer is a base layer. This should be set \n+ * individually by all subclasses. Default is false\n */\n- destroy: function() {\n- // erase any drawn elements\n- this.erase();\n+ isBaseLayer: false,\n \n- OpenLayers.Event.stopObservingElement(this.imageDiv.firstChild);\n- this.imageDiv.innerHTML = \"\";\n- this.imageDiv = null;\n- },\n+ /**\n+ * Property: alpha\n+ * {Boolean} The layer's images have an alpha channel. Default is false.\n+ */\n+ alpha: false,\n \n /** \n- * Method: clone\n- * \n- * Returns:\n- * {} A fresh copy of the icon.\n+ * APIProperty: displayInLayerSwitcher\n+ * {Boolean} Display the layer's name in the layer switcher. Default is\n+ * true.\n */\n- clone: function() {\n- return new OpenLayers.Icon(this.url,\n- this.size,\n- this.offset,\n- this.calculateOffset);\n- },\n+ displayInLayerSwitcher: true,\n \n /**\n- * Method: setSize\n- * \n- * Parameters:\n- * size - {|Object} An OpenLayers.Size or\n- * an object with a 'w' and 'h' properties.\n+ * APIProperty: visibility\n+ * {Boolean} The layer should be displayed in the map. Default is true.\n */\n- setSize: function(size) {\n- if (size != null) {\n- this.size = size;\n- }\n- this.draw();\n- },\n+ visibility: true,\n \n /**\n- * Method: setUrl\n- * \n- * Parameters:\n- * url - {String} \n+ * APIProperty: attribution\n+ * {String} Attribution string, displayed when an \n+ * has been added to the map.\n */\n- setUrl: function(url) {\n- if (url != null) {\n- this.url = url;\n- }\n- this.draw();\n- },\n+ attribution: null,\n \n /** \n- * Method: draw\n- * Move the div to the given pixel.\n- * \n- * Parameters:\n- * px - {|Object} An OpenLayers.Pixel or an\n- * object with a 'x' and 'y' properties.\n- * \n- * Returns:\n- * {DOMElement} A new DOM Image of this icon set at the location passed-in\n+ * Property: inRange\n+ * {Boolean} The current map resolution is within the layer's min/max \n+ * range. This is set in whenever the zoom \n+ * changes.\n */\n- draw: function(px) {\n- OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,\n- null,\n- null,\n- this.size,\n- this.url,\n- \"absolute\");\n- this.moveTo(px);\n- return this.imageDiv;\n- },\n+ inRange: false,\n \n- /** \n- * Method: erase\n- * Erase the underlying image element.\n+ /**\n+ * Propery: imageSize\n+ * {} For layers with a gutter, the image is larger than \n+ * the tile by twice the gutter in each dimension.\n */\n- erase: function() {\n- if (this.imageDiv != null && this.imageDiv.parentNode != null) {\n- OpenLayers.Element.remove(this.imageDiv);\n- }\n- },\n+ imageSize: null,\n+\n+ // OPTIONS\n \n /** \n- * Method: setOpacity\n- * Change the icon's opacity\n- *\n- * Parameters:\n- * opacity - {float} \n+ * Property: options\n+ * {Object} An optional object whose properties will be set on the layer.\n+ * Any of the layer properties can be set as a property of the options\n+ * object and sent to the constructor when the layer is created.\n */\n- setOpacity: function(opacity) {\n- OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, null, null,\n- null, null, null, null, opacity);\n+ options: null,\n \n- },\n+ /**\n+ * APIProperty: eventListeners\n+ * {Object} If set as an option at construction, the eventListeners\n+ * object will be registered with . Object\n+ * structure must be a listeners object as shown in the example for\n+ * the events.on method.\n+ */\n+ eventListeners: null,\n \n /**\n- * Method: moveTo\n- * move icon to passed in px.\n- *\n- * Parameters:\n- * px - {|Object} the pixel position to move to.\n- * An OpenLayers.Pixel or an object with a 'x' and 'y' properties.\n+ * APIProperty: gutter\n+ * {Integer} Determines the width (in pixels) of the gutter around image\n+ * tiles to ignore. By setting this property to a non-zero value,\n+ * images will be requested that are wider and taller than the tile\n+ * size by a value of 2 x gutter. This allows artifacts of rendering\n+ * at tile edges to be ignored. Set a gutter value that is equal to\n+ * half the size of the widest symbol that needs to be displayed.\n+ * Defaults to zero. Non-tiled layers always have zero gutter.\n */\n- moveTo: function(px) {\n- //if no px passed in, use stored location\n- if (px != null) {\n- this.px = px;\n- }\n+ gutter: 0,\n \n- if (this.imageDiv != null) {\n- if (this.px == null) {\n- this.display(false);\n- } else {\n- if (this.calculateOffset) {\n- this.offset = this.calculateOffset(this.size);\n- }\n- OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, {\n- x: this.px.x + this.offset.x,\n- y: this.px.y + this.offset.y\n- });\n- }\n- }\n- },\n+ /**\n+ * APIProperty: projection\n+ * {} or {} Specifies the projection of the layer.\n+ * Can be set in the layer options. If not specified in the layer options,\n+ * it is set to the default projection specified in the map,\n+ * when the layer is added to the map.\n+ * Projection along with default maxExtent and resolutions\n+ * are set automatically with commercial baselayers in EPSG:3857,\n+ * such as Google, Bing and OpenStreetMap, and do not need to be specified.\n+ * Otherwise, if specifying projection, also set maxExtent,\n+ * maxResolution or resolutions as appropriate.\n+ * When using vector layers with strategies, layer projection should be set\n+ * to the projection of the source data if that is different from the map default.\n+ * \n+ * Can be either a string or an object;\n+ * if a string is passed, will be converted to an object when\n+ * the layer is added to the map.\n+ * \n+ */\n+ projection: null,\n \n- /** \n- * Method: display\n- * Hide or show the icon\n- *\n- * Parameters:\n- * display - {Boolean} \n+ /**\n+ * APIProperty: units\n+ * {String} The layer map units. Defaults to null. Possible values\n+ * are 'degrees' (or 'dd'), 'm', 'ft', 'km', 'mi', 'inches'.\n+ * Normally taken from the projection.\n+ * Only required if both map and layers do not define a projection,\n+ * or if they define a projection which does not define units.\n */\n- display: function(display) {\n- this.imageDiv.style.display = (display) ? \"\" : \"none\";\n- },\n+ units: null,\n \n+ /**\n+ * APIProperty: scales\n+ * {Array} An array of map scales in descending order. The values in the\n+ * array correspond to the map scale denominator. Note that these\n+ * values only make sense if the display (monitor) resolution of the\n+ * client is correctly guessed by whomever is configuring the\n+ * application. In addition, the units property must also be set.\n+ * Use instead wherever possible.\n+ */\n+ scales: null,\n \n /**\n- * APIMethod: isDrawn\n- * \n- * Returns:\n- * {Boolean} Whether or not the icon is drawn.\n+ * APIProperty: resolutions\n+ * {Array} A list of map resolutions (map units per pixel) in descending\n+ * order. If this is not set in the layer constructor, it will be set\n+ * based on other resolution related properties (maxExtent,\n+ * maxResolution, maxScale, etc.).\n */\n- isDrawn: function() {\n- // nodeType 11 for ie, whose nodes *always* have a parentNode\n- // (of type document fragment)\n- var isDrawn = (this.imageDiv && this.imageDiv.parentNode &&\n- (this.imageDiv.parentNode.nodeType != 11));\n+ resolutions: null,\n \n- return isDrawn;\n- },\n+ /**\n+ * APIProperty: maxExtent\n+ * {|Array} If provided as an array, the array\n+ * should consist of four values (left, bottom, right, top).\n+ * The maximum extent for the layer. Defaults to null.\n+ * \n+ * The center of these bounds will not stray outside\n+ * of the viewport extent during panning. In addition, if\n+ * is set to false, data will not be\n+ * requested that falls completely outside of these bounds.\n+ */\n+ maxExtent: null,\n \n- CLASS_NAME: \"OpenLayers.Icon\"\n-});\n-/* ======================================================================\n- OpenLayers/Marker.js\n- ====================================================================== */\n+ /**\n+ * APIProperty: minExtent\n+ * {|Array} If provided as an array, the array\n+ * should consist of four values (left, bottom, right, top).\n+ * The minimum extent for the layer. Defaults to null.\n+ */\n+ minExtent: null,\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ /**\n+ * APIProperty: maxResolution\n+ * {Float} Default max is 360 deg / 256 px, which corresponds to\n+ * zoom level 0 on gmaps. Specify a different value in the layer \n+ * options if you are not using the default \n+ * and displaying the whole world.\n+ */\n+ maxResolution: null,\n \n+ /**\n+ * APIProperty: minResolution\n+ * {Float}\n+ */\n+ minResolution: null,\n \n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Events.js\n- * @requires OpenLayers/Icon.js\n- */\n+ /**\n+ * APIProperty: numZoomLevels\n+ * {Integer}\n+ */\n+ numZoomLevels: null,\n \n-/**\n- * Class: OpenLayers.Marker\n- * Instances of OpenLayers.Marker are a combination of a \n- * and an . \n- *\n- * Markers are generally added to a special layer called\n- * .\n- *\n- * Example:\n- * (code)\n- * var markers = new OpenLayers.Layer.Markers( \"Markers\" );\n- * map.addLayer(markers);\n- *\n- * var size = new OpenLayers.Size(21,25);\n- * var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);\n- * var icon = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png', size, offset);\n- * markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon));\n- * markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon.clone()));\n- *\n- * (end)\n- *\n- * Note that if you pass an icon into the Marker constructor, it will take\n- * that icon and use it. This means that you should not share icons between\n- * markers -- you use them once, but you should clone() for any additional\n- * markers using that same icon.\n- */\n-OpenLayers.Marker = OpenLayers.Class({\n+ /**\n+ * APIProperty: minScale\n+ * {Float}\n+ */\n+ minScale: null,\n \n- /** \n- * Property: icon \n- * {} The icon used by this marker.\n+ /**\n+ * APIProperty: maxScale\n+ * {Float}\n */\n- icon: null,\n+ maxScale: null,\n \n- /** \n- * Property: lonlat \n- * {} location of object\n+ /**\n+ * APIProperty: displayOutsideMaxExtent\n+ * {Boolean} Request map tiles that are completely outside of the max \n+ * extent for this layer. Defaults to false.\n */\n- lonlat: null,\n+ displayOutsideMaxExtent: false,\n \n- /** \n- * Property: events \n- * {} the event handler.\n+ /**\n+ * APIProperty: wrapDateLine\n+ * {Boolean} Wraps the world at the international dateline, so the map can\n+ * be panned infinitely in longitudinal direction. Only use this on the\n+ * base layer, and only if the layer's maxExtent equals the world bounds.\n+ * #487 for more info. \n */\n- events: null,\n+ wrapDateLine: false,\n \n- /** \n- * Property: map \n- * {} the map this marker is attached to\n+ /**\n+ * Property: metadata\n+ * {Object} This object can be used to store additional information on a\n+ * layer object.\n */\n- map: null,\n+ metadata: null,\n \n- /** \n- * Constructor: OpenLayers.Marker\n+ /**\n+ * Constructor: OpenLayers.Layer\n *\n * Parameters:\n- * lonlat - {} the position of this marker\n- * icon - {} the icon for this marker\n+ * name - {String} The layer name\n+ * options - {Object} Hashtable of extra options to tag onto the layer\n */\n- initialize: function(lonlat, icon) {\n- this.lonlat = lonlat;\n+ initialize: function(name, options) {\n \n- var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon();\n- if (this.icon == null) {\n- this.icon = newIcon;\n- } else {\n- this.icon.url = newIcon.url;\n- this.icon.size = newIcon.size;\n- this.icon.offset = newIcon.offset;\n- this.icon.calculateOffset = newIcon.calculateOffset;\n+ this.metadata = {};\n+\n+ options = OpenLayers.Util.extend({}, options);\n+ // make sure we respect alwaysInRange if set on the prototype\n+ if (this.alwaysInRange != null) {\n+ options.alwaysInRange = this.alwaysInRange;\n }\n- this.events = new OpenLayers.Events(this, this.icon.imageDiv);\n- },\n+ this.addOptions(options);\n \n- /**\n- * APIMethod: destroy\n- * Destroy the marker. You must first remove the marker from any \n- * layer which it has been added to, or you will get buggy behavior.\n- * (This can not be done within the marker since the marker does not\n- * know which layer it is attached to.)\n- */\n- destroy: function() {\n- // erase any drawn features\n- this.erase();\n+ this.name = name;\n \n- this.map = null;\n+ if (this.id == null) {\n \n- this.events.destroy();\n- this.events = null;\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n \n- if (this.icon != null) {\n- this.icon.destroy();\n- this.icon = null;\n- }\n- },\n+ this.div = OpenLayers.Util.createDiv(this.id);\n+ this.div.style.width = \"100%\";\n+ this.div.style.height = \"100%\";\n+ this.div.dir = \"ltr\";\n \n- /** \n- * Method: draw\n- * Calls draw on the icon, and returns that output.\n- * \n- * Parameters:\n- * px - {}\n- * \n- * Returns:\n- * {DOMElement} A new DOM Image with this marker's icon set at the \n- * location passed-in\n- */\n- draw: function(px) {\n- return this.icon.draw(px);\n- },\n+ this.events = new OpenLayers.Events(this, this.div);\n+ if (this.eventListeners instanceof Object) {\n+ this.events.on(this.eventListeners);\n+ }\n \n- /** \n- * Method: erase\n- * Erases any drawn elements for this marker.\n- */\n- erase: function() {\n- if (this.icon != null) {\n- this.icon.erase();\n }\n },\n \n /**\n- * Method: moveTo\n- * Move the marker to the new location.\n+ * Method: destroy\n+ * Destroy is a destructor: this is to alleviate cyclic references which\n+ * the Javascript garbage cleaner can not take care of on its own.\n *\n * Parameters:\n- * px - {|Object} the pixel position to move to.\n- * An OpenLayers.Pixel or an object with a 'x' and 'y' properties.\n+ * setNewBaseLayer - {Boolean} Set a new base layer when this layer has\n+ * been destroyed. Default is true.\n */\n- moveTo: function(px) {\n- if ((px != null) && (this.icon != null)) {\n- this.icon.moveTo(px);\n+ destroy: function(setNewBaseLayer) {\n+ if (setNewBaseLayer == null) {\n+ setNewBaseLayer = true;\n }\n- this.lonlat = this.map.getLonLatFromLayerPx(px);\n- },\n+ if (this.map != null) {\n+ this.map.removeLayer(this, setNewBaseLayer);\n+ }\n+ this.projection = null;\n+ this.map = null;\n+ this.name = null;\n+ this.div = null;\n+ this.options = null;\n \n- /**\n- * APIMethod: isDrawn\n- * \n- * Returns:\n- * {Boolean} Whether or not the marker is drawn.\n- */\n- isDrawn: function() {\n- var isDrawn = (this.icon && this.icon.isDrawn());\n- return isDrawn;\n+ if (this.events) {\n+ if (this.eventListeners) {\n+ this.events.un(this.eventListeners);\n+ }\n+ this.events.destroy();\n+ }\n+ this.eventListeners = null;\n+ this.events = null;\n },\n \n /**\n- * Method: onScreen\n+ * Method: clone\n+ *\n+ * Parameters:\n+ * obj - {} The layer to be cloned\n *\n * Returns:\n- * {Boolean} Whether or not the marker is currently visible on screen.\n+ * {} An exact clone of this \n */\n- onScreen: function() {\n+ clone: function(obj) {\n \n- var onScreen = false;\n- if (this.map) {\n- var screenBounds = this.map.getExtent();\n- onScreen = screenBounds.containsLonLat(this.lonlat);\n+ if (obj == null) {\n+ obj = new OpenLayers.Layer(this.name, this.getOptions());\n }\n- return onScreen;\n+\n+ // catch any randomly tagged-on properties\n+ OpenLayers.Util.applyDefaults(obj, this);\n+\n+ // a cloned layer should never have its map property set\n+ // because it has not been added to a map yet. \n+ obj.map = null;\n+\n+ return obj;\n },\n \n /**\n- * Method: inflate\n- * Englarges the markers icon by the specified ratio.\n- *\n- * Parameters:\n- * inflate - {float} the ratio to enlarge the marker by (passing 2\n- * will double the size).\n+ * Method: getOptions\n+ * Extracts an object from the layer with the properties that were set as\n+ * options, but updates them with the values currently set on the\n+ * instance.\n+ * \n+ * Returns:\n+ * {Object} the of the layer, representing the current state.\n */\n- inflate: function(inflate) {\n- if (this.icon) {\n- this.icon.setSize({\n- w: this.icon.size.w * inflate,\n- h: this.icon.size.h * inflate\n- });\n+ getOptions: function() {\n+ var options = {};\n+ for (var o in this.options) {\n+ options[o] = this[o];\n }\n+ return options;\n },\n \n /** \n- * Method: setOpacity\n- * Change the opacity of the marker by changin the opacity of \n- * its icon\n- * \n+ * APIMethod: setName\n+ * Sets the new layer name for this layer. Can trigger a changelayer event\n+ * on the map.\n+ *\n * Parameters:\n- * opacity - {float} Specified as fraction (0.4, etc)\n+ * newName - {String} The new name.\n */\n- setOpacity: function(opacity) {\n- this.icon.setOpacity(opacity);\n+ setName: function(newName) {\n+ if (newName != this.name) {\n+ this.name = newName;\n+ if (this.map != null) {\n+ this.map.events.triggerEvent(\"changelayer\", {\n+ layer: this,\n+ property: \"name\"\n+ });\n+ }\n+ }\n },\n \n /**\n- * Method: setUrl\n- * Change URL of the Icon Image.\n- * \n- * url - {String} \n- */\n- setUrl: function(url) {\n- this.icon.setUrl(url);\n- },\n-\n- /** \n- * Method: display\n- * Hide or show the icon\n+ * APIMethod: addOptions\n * \n- * display - {Boolean} \n+ * Parameters:\n+ * newOptions - {Object}\n+ * reinitialize - {Boolean} If set to true, and if resolution options of the\n+ * current baseLayer were changed, the map will be recentered to make\n+ * sure that it is displayed with a valid resolution, and a\n+ * changebaselayer event will be triggered.\n */\n- display: function(display) {\n- this.icon.display(display);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Marker\"\n-});\n-\n-\n-/**\n- * Function: defaultIcon\n- * Creates a default .\n- * \n- * Returns:\n- * {} A default OpenLayers.Icon to use for a marker\n- */\n-OpenLayers.Marker.defaultIcon = function() {\n- return new OpenLayers.Icon(OpenLayers.Util.getImageLocation(\"marker.png\"), {\n- w: 21,\n- h: 25\n- }, {\n- x: -10.5,\n- y: -25\n- });\n-};\n-\n-\n-/* ======================================================================\n- OpenLayers/Geometry.js\n- ====================================================================== */\n+ addOptions: function(newOptions, reinitialize) {\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ if (this.options == null) {\n+ this.options = {};\n+ }\n \n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- */\n+ if (newOptions) {\n+ // make sure this.projection references a projection object\n+ if (typeof newOptions.projection == \"string\") {\n+ newOptions.projection = new OpenLayers.Projection(newOptions.projection);\n+ }\n+ if (newOptions.projection) {\n+ // get maxResolution, units and maxExtent from projection defaults if\n+ // they are not defined already\n+ OpenLayers.Util.applyDefaults(newOptions,\n+ OpenLayers.Projection.defaults[newOptions.projection.getCode()]);\n+ }\n+ // allow array for extents\n+ if (newOptions.maxExtent && !(newOptions.maxExtent instanceof OpenLayers.Bounds)) {\n+ newOptions.maxExtent = new OpenLayers.Bounds(newOptions.maxExtent);\n+ }\n+ if (newOptions.minExtent && !(newOptions.minExtent instanceof OpenLayers.Bounds)) {\n+ newOptions.minExtent = new OpenLayers.Bounds(newOptions.minExtent);\n+ }\n+ }\n \n-/**\n- * Class: OpenLayers.Geometry\n- * A Geometry is a description of a geographic object. Create an instance of\n- * this class with the constructor. This is a base class,\n- * typical geometry types are described by subclasses of this class.\n- *\n- * Note that if you use the method, you must\n- * explicitly include the OpenLayers.Format.WKT in your build.\n- */\n-OpenLayers.Geometry = OpenLayers.Class({\n+ // update our copy for clone\n+ OpenLayers.Util.extend(this.options, newOptions);\n \n- /**\n- * Property: id\n- * {String} A unique identifier for this geometry.\n- */\n- id: null,\n+ // add new options to this\n+ OpenLayers.Util.extend(this, newOptions);\n \n- /**\n- * Property: parent\n- * {}This is set when a Geometry is added as component\n- * of another geometry\n- */\n- parent: null,\n+ // get the units from the projection, if we have a projection\n+ // and it it has units\n+ if (this.projection && this.projection.getUnits()) {\n+ this.units = this.projection.getUnits();\n+ }\n \n- /**\n- * Property: bounds \n- * {} The bounds of this geometry\n- */\n- bounds: null,\n+ // re-initialize resolutions if necessary, i.e. if any of the\n+ // properties of the \"properties\" array defined below is set\n+ // in the new options\n+ if (this.map) {\n+ // store current resolution so we can try to restore it later\n+ var resolution = this.map.getResolution();\n+ var properties = this.RESOLUTION_PROPERTIES.concat(\n+ [\"projection\", \"units\", \"minExtent\", \"maxExtent\"]\n+ );\n+ for (var o in newOptions) {\n+ if (newOptions.hasOwnProperty(o) &&\n+ OpenLayers.Util.indexOf(properties, o) >= 0) {\n \n- /**\n- * Constructor: OpenLayers.Geometry\n- * Creates a geometry object. \n- */\n- initialize: function() {\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+ this.initResolutions();\n+ if (reinitialize && this.map.baseLayer === this) {\n+ // update map position, and restore previous resolution\n+ this.map.setCenter(this.map.getCenter(),\n+ this.map.getZoomForResolution(resolution),\n+ false, true\n+ );\n+ // trigger a changebaselayer event to make sure that\n+ // all controls (especially\n+ // OpenLayers.Control.PanZoomBar) get notified of the\n+ // new options\n+ this.map.events.triggerEvent(\"changebaselayer\", {\n+ layer: this\n+ });\n+ }\n+ break;\n+ }\n+ }\n+ }\n },\n \n /**\n- * Method: destroy\n- * Destroy this geometry.\n+ * APIMethod: onMapResize\n+ * This function can be implemented by subclasses\n */\n- destroy: function() {\n- this.id = null;\n- this.bounds = null;\n+ onMapResize: function() {\n+ //this function can be implemented by subclasses \n },\n \n /**\n- * APIMethod: clone\n- * Create a clone of this geometry. Does not set any non-standard\n- * properties of the cloned geometry.\n- * \n+ * APIMethod: redraw\n+ * Redraws the layer. Returns true if the layer was redrawn, false if not.\n+ *\n * Returns:\n- * {} An exact clone of this geometry.\n+ * {Boolean} The layer was redrawn.\n */\n- clone: function() {\n- return new OpenLayers.Geometry();\n+ redraw: function() {\n+ var redrawn = false;\n+ if (this.map) {\n+\n+ // min/max Range may have changed\n+ this.inRange = this.calculateInRange();\n+\n+ // map's center might not yet be set\n+ var extent = this.getExtent();\n+\n+ if (extent && this.inRange && this.visibility) {\n+ var zoomChanged = true;\n+ this.moveTo(extent, zoomChanged, false);\n+ this.events.triggerEvent(\"moveend\", {\n+ \"zoomChanged\": zoomChanged\n+ });\n+ redrawn = true;\n+ }\n+ }\n+ return redrawn;\n },\n \n /**\n- * Method: setBounds\n- * Set the bounds for this Geometry.\n+ * Method: moveTo\n * \n * Parameters:\n- * bounds - {} \n+ * bounds - {}\n+ * zoomChanged - {Boolean} Tells when zoom has changed, as layers have to\n+ * do some init work in that case.\n+ * dragging - {Boolean}\n */\n- setBounds: function(bounds) {\n- if (bounds) {\n- this.bounds = bounds.clone();\n+ moveTo: function(bounds, zoomChanged, dragging) {\n+ var display = this.visibility;\n+ if (!this.isBaseLayer) {\n+ display = display && this.inRange;\n }\n+ this.display(display);\n },\n \n /**\n- * Method: clearBounds\n- * Nullify this components bounds and that of its parent as well.\n+ * Method: moveByPx\n+ * Move the layer based on pixel vector. To be implemented by subclasses.\n+ *\n+ * Parameters:\n+ * dx - {Number} The x coord of the displacement vector.\n+ * dy - {Number} The y coord of the displacement vector.\n */\n- clearBounds: function() {\n- this.bounds = null;\n- if (this.parent) {\n- this.parent.clearBounds();\n- }\n- },\n+ moveByPx: function(dx, dy) {},\n \n /**\n- * Method: extendBounds\n- * Extend the existing bounds to include the new bounds. \n- * If geometry's bounds is not yet set, then set a new Bounds.\n- * \n- * Parameters:\n- * newBounds - {} \n+ * Method: setMap\n+ * Set the map property for the layer. This is done through an accessor\n+ * so that subclasses can override this and take special action once \n+ * they have their map variable set. \n+ * \n+ * Here we take care to bring over any of the necessary default \n+ * properties from the map. \n+ * \n+ * Parameters:\n+ * map - {}\n */\n- extendBounds: function(newBounds) {\n- var bounds = this.getBounds();\n- if (!bounds) {\n- this.setBounds(newBounds);\n- } else {\n- this.bounds.extend(newBounds);\n+ setMap: function(map) {\n+ if (this.map == null) {\n+\n+ this.map = map;\n+\n+ // grab some essential layer data from the map if it hasn't already\n+ // been set\n+ this.maxExtent = this.maxExtent || this.map.maxExtent;\n+ this.minExtent = this.minExtent || this.map.minExtent;\n+\n+ this.projection = this.projection || this.map.projection;\n+ if (typeof this.projection == \"string\") {\n+ this.projection = new OpenLayers.Projection(this.projection);\n+ }\n+\n+ // Check the projection to see if we can get units -- if not, refer\n+ // to properties.\n+ this.units = this.projection.getUnits() ||\n+ this.units || this.map.units;\n+\n+ this.initResolutions();\n+\n+ if (!this.isBaseLayer) {\n+ this.inRange = this.calculateInRange();\n+ var show = ((this.visibility) && (this.inRange));\n+ this.div.style.display = show ? \"\" : \"none\";\n+ }\n+\n+ // deal with gutters\n+ this.setTileSize();\n }\n },\n \n /**\n- * APIMethod: getBounds\n- * Get the bounds for this Geometry. If bounds is not set, it \n- * is calculated again, this makes queries faster.\n+ * Method: afterAdd\n+ * Called at the end of the map.addLayer sequence. At this point, the map\n+ * will have a base layer. To be overridden by subclasses.\n+ */\n+ afterAdd: function() {},\n+\n+ /**\n+ * APIMethod: removeMap\n+ * Just as setMap() allows each layer the possibility to take a \n+ * personalized action on being added to the map, removeMap() allows\n+ * each layer to take a personalized action on being removed from it. \n+ * For now, this will be mostly unused, except for the EventPane layer,\n+ * which needs this hook so that it can remove the special invisible\n+ * pane. \n+ * \n+ * Parameters:\n+ * map - {}\n+ */\n+ removeMap: function(map) {\n+ //to be overridden by subclasses\n+ },\n+\n+ /**\n+ * APIMethod: getImageSize\n+ *\n+ * Parameters:\n+ * bounds - {} optional tile bounds, can be used\n+ * by subclasses that have to deal with different tile sizes at the\n+ * layer extent edges (e.g. Zoomify)\n * \n * Returns:\n- * {}\n+ * {} The size that the image should be, taking into \n+ * account gutters.\n */\n- getBounds: function() {\n- if (this.bounds == null) {\n- this.calculateBounds();\n+ getImageSize: function(bounds) {\n+ return (this.imageSize || this.tileSize);\n+ },\n+\n+ /**\n+ * APIMethod: setTileSize\n+ * Set the tile size based on the map size. This also sets layer.imageSize\n+ * or use by Tile.Image.\n+ * \n+ * Parameters:\n+ * size - {}\n+ */\n+ setTileSize: function(size) {\n+ var tileSize = (size) ? size :\n+ ((this.tileSize) ? this.tileSize :\n+ this.map.getTileSize());\n+ this.tileSize = tileSize;\n+ if (this.gutter) {\n+ // layers with gutters need non-null tile sizes\n+ //if(tileSize == null) {\n+ // OpenLayers.console.error(\"Error in layer.setMap() for \" +\n+ // this.name + \": layers with \" +\n+ // \"gutters need non-null tile sizes\");\n+ //}\n+ this.imageSize = new OpenLayers.Size(tileSize.w + (2 * this.gutter),\n+ tileSize.h + (2 * this.gutter));\n }\n- return this.bounds;\n+ },\n+\n+ /**\n+ * APIMethod: getVisibility\n+ * \n+ * Returns:\n+ * {Boolean} The layer should be displayed (if in range).\n+ */\n+ getVisibility: function() {\n+ return this.visibility;\n },\n \n /** \n- * APIMethod: calculateBounds\n- * Recalculate the bounds for the geometry. \n+ * APIMethod: setVisibility\n+ * Set the visibility flag for the layer and hide/show & redraw \n+ * accordingly. Fire event unless otherwise specified\n+ * \n+ * Note that visibility is no longer simply whether or not the layer's\n+ * style.display is set to \"block\". Now we store a 'visibility' state \n+ * property on the layer class, this allows us to remember whether or \n+ * not we *desire* for a layer to be visible. In the case where the \n+ * map's resolution is out of the layer's range, this desire may be \n+ * subverted.\n+ * \n+ * Parameters:\n+ * visibility - {Boolean} Whether or not to display the layer (if in range)\n */\n- calculateBounds: function() {\n- //\n- // This should be overridden by subclasses.\n- //\n+ setVisibility: function(visibility) {\n+ if (visibility != this.visibility) {\n+ this.visibility = visibility;\n+ this.display(visibility);\n+ this.redraw();\n+ if (this.map != null) {\n+ this.map.events.triggerEvent(\"changelayer\", {\n+ layer: this,\n+ property: \"visibility\"\n+ });\n+ }\n+ this.events.triggerEvent(\"visibilitychanged\");\n+ }\n },\n \n- /**\n- * APIMethod: distanceTo\n- * Calculate the closest distance between two geometries (on the x-y plane).\n- *\n+ /** \n+ * APIMethod: display\n+ * Hide or show the Layer. This is designed to be used internally, and \n+ * is not generally the way to enable or disable the layer. For that,\n+ * use the setVisibility function instead..\n+ * \n * Parameters:\n- * geometry - {} The target geometry.\n- * options - {Object} Optional properties for configuring the distance\n- * calculation.\n- *\n- * Valid options depend on the specific geometry type.\n+ * display - {Boolean}\n+ */\n+ display: function(display) {\n+ if (display != (this.div.style.display != \"none\")) {\n+ this.div.style.display = (display && this.calculateInRange()) ? \"block\" : \"none\";\n+ }\n+ },\n+\n+ /**\n+ * APIMethod: calculateInRange\n * \n * Returns:\n- * {Number | Object} The distance between this geometry and the target.\n- * If details is true, the return will be an object with distance,\n- * x0, y0, x1, and x2 properties. The x0 and y0 properties represent\n- * the coordinates of the closest point on this geometry. The x1 and y1\n- * properties represent the coordinates of the closest point on the\n- * target geometry.\n+ * {Boolean} The layer is displayable at the current map's current\n+ * resolution. Note that if 'alwaysInRange' is true for the layer, \n+ * this function will always return true.\n */\n- distanceTo: function(geometry, options) {},\n+ calculateInRange: function() {\n+ var inRange = false;\n+\n+ if (this.alwaysInRange) {\n+ inRange = true;\n+ } else {\n+ if (this.map) {\n+ var resolution = this.map.getResolution();\n+ inRange = ((resolution >= this.minResolution) &&\n+ (resolution <= this.maxResolution));\n+ }\n+ }\n+ return inRange;\n+ },\n+\n+ /** \n+ * APIMethod: setIsBaseLayer\n+ * \n+ * Parameters:\n+ * isBaseLayer - {Boolean}\n+ */\n+ setIsBaseLayer: function(isBaseLayer) {\n+ if (isBaseLayer != this.isBaseLayer) {\n+ this.isBaseLayer = isBaseLayer;\n+ if (this.map != null) {\n+ this.map.events.triggerEvent(\"changebaselayer\", {\n+ layer: this\n+ });\n+ }\n+ }\n+ },\n+\n+ /********************************************************/\n+ /* */\n+ /* Baselayer Functions */\n+ /* */\n+ /********************************************************/\n+\n+ /** \n+ * Method: initResolutions\n+ * This method's responsibility is to set up the 'resolutions' array \n+ * for the layer -- this array is what the layer will use to interface\n+ * between the zoom levels of the map and the resolution display \n+ * of the layer.\n+ * \n+ * The user has several options that determine how the array is set up.\n+ * \n+ * For a detailed explanation, see the following wiki from the \n+ * openlayers.org homepage:\n+ * http://trac.openlayers.org/wiki/SettingZoomLevels\n+ */\n+ initResolutions: function() {\n+\n+ // ok we want resolutions, here's our strategy:\n+ //\n+ // 1. if resolutions are defined in the layer config, use them\n+ // 2. else, if scales are defined in the layer config then derive\n+ // resolutions from these scales\n+ // 3. else, attempt to calculate resolutions from maxResolution,\n+ // minResolution, numZoomLevels, maxZoomLevel set in the\n+ // layer config\n+ // 4. if we still don't have resolutions, and if resolutions\n+ // are defined in the same, use them\n+ // 5. else, if scales are defined in the map then derive\n+ // resolutions from these scales\n+ // 6. else, attempt to calculate resolutions from maxResolution,\n+ // minResolution, numZoomLevels, maxZoomLevel set in the\n+ // map\n+ // 7. hope for the best!\n+\n+ var i, len, p;\n+ var props = {},\n+ alwaysInRange = true;\n+\n+ // get resolution data from layer config\n+ // (we also set alwaysInRange in the layer as appropriate)\n+ for (i = 0, len = this.RESOLUTION_PROPERTIES.length; i < len; i++) {\n+ p = this.RESOLUTION_PROPERTIES[i];\n+ props[p] = this.options[p];\n+ if (alwaysInRange && this.options[p]) {\n+ alwaysInRange = false;\n+ }\n+ }\n+ if (this.options.alwaysInRange == null) {\n+ this.alwaysInRange = alwaysInRange;\n+ }\n+\n+ // if we don't have resolutions then attempt to derive them from scales\n+ if (props.resolutions == null) {\n+ props.resolutions = this.resolutionsFromScales(props.scales);\n+ }\n+\n+ // if we still don't have resolutions then attempt to calculate them\n+ if (props.resolutions == null) {\n+ props.resolutions = this.calculateResolutions(props);\n+ }\n+\n+ // if we couldn't calculate resolutions then we look at we have\n+ // in the map\n+ if (props.resolutions == null) {\n+ for (i = 0, len = this.RESOLUTION_PROPERTIES.length; i < len; i++) {\n+ p = this.RESOLUTION_PROPERTIES[i];\n+ props[p] = this.options[p] != null ?\n+ this.options[p] : this.map[p];\n+ }\n+ if (props.resolutions == null) {\n+ props.resolutions = this.resolutionsFromScales(props.scales);\n+ }\n+ if (props.resolutions == null) {\n+ props.resolutions = this.calculateResolutions(props);\n+ }\n+ }\n+\n+ // ok, we new need to set properties in the instance\n+\n+ // get maxResolution from the config if it's defined there\n+ var maxResolution;\n+ if (this.options.maxResolution &&\n+ this.options.maxResolution !== \"auto\") {\n+ maxResolution = this.options.maxResolution;\n+ }\n+ if (this.options.minScale) {\n+ maxResolution = OpenLayers.Util.getResolutionFromScale(\n+ this.options.minScale, this.units);\n+ }\n+\n+ // get minResolution from the config if it's defined there\n+ var minResolution;\n+ if (this.options.minResolution &&\n+ this.options.minResolution !== \"auto\") {\n+ minResolution = this.options.minResolution;\n+ }\n+ if (this.options.maxScale) {\n+ minResolution = OpenLayers.Util.getResolutionFromScale(\n+ this.options.maxScale, this.units);\n+ }\n+\n+ if (props.resolutions) {\n+\n+ //sort resolutions array descendingly\n+ props.resolutions.sort(function(a, b) {\n+ return (b - a);\n+ });\n+\n+ // if we still don't have a maxResolution get it from the\n+ // resolutions array\n+ if (!maxResolution) {\n+ maxResolution = props.resolutions[0];\n+ }\n+\n+ // if we still don't have a minResolution get it from the\n+ // resolutions array\n+ if (!minResolution) {\n+ var lastIdx = props.resolutions.length - 1;\n+ minResolution = props.resolutions[lastIdx];\n+ }\n+ }\n+\n+ this.resolutions = props.resolutions;\n+ if (this.resolutions) {\n+ len = this.resolutions.length;\n+ this.scales = new Array(len);\n+ for (i = 0; i < len; i++) {\n+ this.scales[i] = OpenLayers.Util.getScaleFromResolution(\n+ this.resolutions[i], this.units);\n+ }\n+ this.numZoomLevels = len;\n+ }\n+ this.minResolution = minResolution;\n+ if (minResolution) {\n+ this.maxScale = OpenLayers.Util.getScaleFromResolution(\n+ minResolution, this.units);\n+ }\n+ this.maxResolution = maxResolution;\n+ if (maxResolution) {\n+ this.minScale = OpenLayers.Util.getScaleFromResolution(\n+ maxResolution, this.units);\n+ }\n+ },\n \n /**\n- * APIMethod: getVertices\n- * Return a list of all points in this geometry.\n+ * Method: resolutionsFromScales\n+ * Derive resolutions from scales.\n *\n * Parameters:\n- * nodes - {Boolean} For lines, only return vertices that are\n- * endpoints. If false, for lines, only vertices that are not\n- * endpoints will be returned. If not provided, all vertices will\n- * be returned.\n+ * scales - {Array(Number)} Scales\n *\n- * Returns:\n- * {Array} A list of all vertices in the geometry.\n+ * Returns\n+ * {Array(Number)} Resolutions\n */\n- getVertices: function(nodes) {},\n+ resolutionsFromScales: function(scales) {\n+ if (scales == null) {\n+ return;\n+ }\n+ var resolutions, i, len;\n+ len = scales.length;\n+ resolutions = new Array(len);\n+ for (i = 0; i < len; i++) {\n+ resolutions[i] = OpenLayers.Util.getResolutionFromScale(\n+ scales[i], this.units);\n+ }\n+ return resolutions;\n+ },\n \n /**\n- * Method: atPoint\n- * Note - This is only an approximation based on the bounds of the \n- * geometry.\n- * \n+ * Method: calculateResolutions\n+ * Calculate resolutions based on the provided properties.\n+ *\n * Parameters:\n- * lonlat - {|Object} OpenLayers.LonLat or an\n- * object with a 'lon' and 'lat' properties.\n- * toleranceLon - {float} Optional tolerance in Geometric Coords\n- * toleranceLat - {float} Optional tolerance in Geographic Coords\n- * \n+ * props - {Object} Properties\n+ *\n * Returns:\n- * {Boolean} Whether or not the geometry is at the specified location\n+ * {Array({Number})} Array of resolutions.\n */\n- atPoint: function(lonlat, toleranceLon, toleranceLat) {\n- var atPoint = false;\n- var bounds = this.getBounds();\n- if ((bounds != null) && (lonlat != null)) {\n+ calculateResolutions: function(props) {\n \n- var dX = (toleranceLon != null) ? toleranceLon : 0;\n- var dY = (toleranceLat != null) ? toleranceLat : 0;\n+ var viewSize, wRes, hRes;\n \n- var toleranceBounds =\n- new OpenLayers.Bounds(this.bounds.left - dX,\n- this.bounds.bottom - dY,\n- this.bounds.right + dX,\n- this.bounds.top + dY);\n+ // determine maxResolution\n+ var maxResolution = props.maxResolution;\n+ if (props.minScale != null) {\n+ maxResolution =\n+ OpenLayers.Util.getResolutionFromScale(props.minScale,\n+ this.units);\n+ } else if (maxResolution == \"auto\" && this.maxExtent != null) {\n+ viewSize = this.map.getSize();\n+ wRes = this.maxExtent.getWidth() / viewSize.w;\n+ hRes = this.maxExtent.getHeight() / viewSize.h;\n+ maxResolution = Math.max(wRes, hRes);\n+ }\n \n- atPoint = toleranceBounds.containsLonLat(lonlat);\n+ // determine minResolution\n+ var minResolution = props.minResolution;\n+ if (props.maxScale != null) {\n+ minResolution =\n+ OpenLayers.Util.getResolutionFromScale(props.maxScale,\n+ this.units);\n+ } else if (props.minResolution == \"auto\" && this.minExtent != null) {\n+ viewSize = this.map.getSize();\n+ wRes = this.minExtent.getWidth() / viewSize.w;\n+ hRes = this.minExtent.getHeight() / viewSize.h;\n+ minResolution = Math.max(wRes, hRes);\n }\n- return atPoint;\n+\n+ if (typeof maxResolution !== \"number\" &&\n+ typeof minResolution !== \"number\" &&\n+ this.maxExtent != null) {\n+ // maxResolution for default grid sets assumes that at zoom\n+ // level zero, the whole world fits on one tile.\n+ var tileSize = this.map.getTileSize();\n+ maxResolution = Math.max(\n+ this.maxExtent.getWidth() / tileSize.w,\n+ this.maxExtent.getHeight() / tileSize.h\n+ );\n+ }\n+\n+ // determine numZoomLevels\n+ var maxZoomLevel = props.maxZoomLevel;\n+ var numZoomLevels = props.numZoomLevels;\n+ if (typeof minResolution === \"number\" &&\n+ typeof maxResolution === \"number\" && numZoomLevels === undefined) {\n+ var ratio = maxResolution / minResolution;\n+ numZoomLevels = Math.floor(Math.log(ratio) / Math.log(2)) + 1;\n+ } else if (numZoomLevels === undefined && maxZoomLevel != null) {\n+ numZoomLevels = maxZoomLevel + 1;\n+ }\n+\n+ // are we able to calculate resolutions?\n+ if (typeof numZoomLevels !== \"number\" || numZoomLevels <= 0 ||\n+ (typeof maxResolution !== \"number\" &&\n+ typeof minResolution !== \"number\")) {\n+ return;\n+ }\n+\n+ // now we have numZoomLevels and at least one of maxResolution\n+ // or minResolution, we can populate the resolutions array\n+\n+ var resolutions = new Array(numZoomLevels);\n+ var base = 2;\n+ if (typeof minResolution == \"number\" &&\n+ typeof maxResolution == \"number\") {\n+ // if maxResolution and minResolution are set, we calculate\n+ // the base for exponential scaling that starts at\n+ // maxResolution and ends at minResolution in numZoomLevels\n+ // steps.\n+ base = Math.pow(\n+ (maxResolution / minResolution),\n+ (1 / (numZoomLevels - 1))\n+ );\n+ }\n+\n+ var i;\n+ if (typeof maxResolution === \"number\") {\n+ for (i = 0; i < numZoomLevels; i++) {\n+ resolutions[i] = maxResolution / Math.pow(base, i);\n+ }\n+ } else {\n+ for (i = 0; i < numZoomLevels; i++) {\n+ resolutions[numZoomLevels - 1 - i] =\n+ minResolution * Math.pow(base, i);\n+ }\n+ }\n+\n+ return resolutions;\n },\n \n /**\n- * Method: getLength\n- * Calculate the length of this geometry. This method is defined in\n- * subclasses.\n+ * APIMethod: getResolution\n * \n * Returns:\n- * {Float} The length of the collection by summing its parts\n+ * {Float} The currently selected resolution of the map, taken from the\n+ * resolutions array, indexed by current zoom level.\n */\n- getLength: function() {\n- //to be overridden by geometries that actually have a length\n- //\n- return 0.0;\n+ getResolution: function() {\n+ var zoom = this.map.getZoom();\n+ return this.getResolutionForZoom(zoom);\n },\n \n- /**\n- * Method: getArea\n- * Calculate the area of this geometry. This method is defined in subclasses.\n+ /** \n+ * APIMethod: getExtent\n * \n * Returns:\n- * {Float} The area of the collection by summing its parts\n+ * {} A Bounds object which represents the lon/lat \n+ * bounds of the current viewPort.\n */\n- getArea: function() {\n- //to be overridden by geometries that actually have an area\n+ getExtent: function() {\n+ // just use stock map calculateBounds function -- passing no arguments\n+ // means it will user map's current center & resolution\n //\n- return 0.0;\n+ return this.map.calculateBounds();\n },\n \n /**\n- * APIMethod: getCentroid\n- * Calculate the centroid of this geometry. This method is defined in subclasses.\n+ * APIMethod: getZoomForExtent\n+ * \n+ * Parameters:\n+ * extent - {}\n+ * closest - {Boolean} Find the zoom level that most closely fits the \n+ * specified bounds. Note that this may result in a zoom that does \n+ * not exactly contain the entire extent.\n+ * Default is false.\n *\n * Returns:\n- * {} The centroid of the collection\n+ * {Integer} The index of the zoomLevel (entry in the resolutions array) \n+ * for the passed-in extent. We do this by calculating the ideal \n+ * resolution for the given extent (based on the map size) and then \n+ * calling getZoomForResolution(), passing along the 'closest'\n+ * parameter.\n */\n- getCentroid: function() {\n- return null;\n+ getZoomForExtent: function(extent, closest) {\n+ var viewSize = this.map.getSize();\n+ var idealResolution = Math.max(extent.getWidth() / viewSize.w,\n+ extent.getHeight() / viewSize.h);\n+\n+ return this.getZoomForResolution(idealResolution, closest);\n+ },\n+\n+ /** \n+ * Method: getDataExtent\n+ * Calculates the max extent which includes all of the data for the layer.\n+ * This function is to be implemented by subclasses.\n+ * \n+ * Returns:\n+ * {}\n+ */\n+ getDataExtent: function() {\n+ //to be implemented by subclasses\n },\n \n /**\n- * Method: toString\n- * Returns a text representation of the geometry. If the WKT format is\n- * included in a build, this will be the Well-Known Text \n- * representation.\n- *\n+ * APIMethod: getResolutionForZoom\n+ * \n+ * Parameters:\n+ * zoom - {Float}\n+ * \n * Returns:\n- * {String} String representation of this geometry.\n+ * {Float} A suitable resolution for the specified zoom.\n */\n- toString: function() {\n- var string;\n- if (OpenLayers.Format && OpenLayers.Format.WKT) {\n- string = OpenLayers.Format.WKT.prototype.write(\n- new OpenLayers.Feature.Vector(this)\n- );\n+ getResolutionForZoom: function(zoom) {\n+ zoom = Math.max(0, Math.min(zoom, this.resolutions.length - 1));\n+ var resolution;\n+ if (this.map.fractionalZoom) {\n+ var low = Math.floor(zoom);\n+ var high = Math.ceil(zoom);\n+ resolution = this.resolutions[low] -\n+ ((zoom - low) * (this.resolutions[low] - this.resolutions[high]));\n } else {\n- string = Object.prototype.toString.call(this);\n+ resolution = this.resolutions[Math.round(zoom)];\n }\n- return string;\n+ return resolution;\n },\n \n- CLASS_NAME: \"OpenLayers.Geometry\"\n-});\n-\n-/**\n- * Function: OpenLayers.Geometry.fromWKT\n- * Generate a geometry given a Well-Known Text string. For this method to\n- * work, you must include the OpenLayers.Format.WKT in your build \n- * explicitly.\n- *\n- * Parameters:\n- * wkt - {String} A string representing the geometry in Well-Known Text.\n- *\n- * Returns:\n- * {} A geometry of the appropriate class.\n- */\n-OpenLayers.Geometry.fromWKT = function(wkt) {\n- var geom;\n- if (OpenLayers.Format && OpenLayers.Format.WKT) {\n- var format = OpenLayers.Geometry.fromWKT.format;\n- if (!format) {\n- format = new OpenLayers.Format.WKT();\n- OpenLayers.Geometry.fromWKT.format = format;\n- }\n- var result = format.read(wkt);\n- if (result instanceof OpenLayers.Feature.Vector) {\n- geom = result.geometry;\n- } else if (OpenLayers.Util.isArray(result)) {\n- var len = result.length;\n- var components = new Array(len);\n- for (var i = 0; i < len; ++i) {\n- components[i] = result[i].geometry;\n+ /**\n+ * APIMethod: getZoomForResolution\n+ * \n+ * Parameters:\n+ * resolution - {Float}\n+ * closest - {Boolean} Find the zoom level that corresponds to the absolute \n+ * closest resolution, which may result in a zoom whose corresponding\n+ * resolution is actually smaller than we would have desired (if this\n+ * is being called from a getZoomForExtent() call, then this means that\n+ * the returned zoom index might not actually contain the entire \n+ * extent specified... but it'll be close).\n+ * Default is false.\n+ * \n+ * Returns:\n+ * {Integer} The index of the zoomLevel (entry in the resolutions array) \n+ * that corresponds to the best fit resolution given the passed in \n+ * value and the 'closest' specification.\n+ */\n+ getZoomForResolution: function(resolution, closest) {\n+ var zoom, i, len;\n+ if (this.map.fractionalZoom) {\n+ var lowZoom = 0;\n+ var highZoom = this.resolutions.length - 1;\n+ var highRes = this.resolutions[lowZoom];\n+ var lowRes = this.resolutions[highZoom];\n+ var res;\n+ for (i = 0, len = this.resolutions.length; i < len; ++i) {\n+ res = this.resolutions[i];\n+ if (res >= resolution) {\n+ highRes = res;\n+ lowZoom = i;\n+ }\n+ if (res <= resolution) {\n+ lowRes = res;\n+ highZoom = i;\n+ break;\n+ }\n }\n- geom = new OpenLayers.Geometry.Collection(components);\n- }\n- }\n- return geom;\n-};\n-\n-/**\n- * Method: OpenLayers.Geometry.segmentsIntersect\n- * Determine whether two line segments intersect. Optionally calculates\n- * and returns the intersection point. This function is optimized for\n- * cases where seg1.x2 >= seg2.x1 || seg2.x2 >= seg1.x1. In those\n- * obvious cases where there is no intersection, the function should\n- * not be called.\n- *\n- * Parameters:\n- * seg1 - {Object} Object representing a segment with properties x1, y1, x2,\n- * and y2. The start point is represented by x1 and y1. The end point\n- * is represented by x2 and y2. Start and end are ordered so that x1 < x2.\n- * seg2 - {Object} Object representing a segment with properties x1, y1, x2,\n- * and y2. The start point is represented by x1 and y1. The end point\n- * is represented by x2 and y2. Start and end are ordered so that x1 < x2.\n- * options - {Object} Optional properties for calculating the intersection.\n- *\n- * Valid options:\n- * point - {Boolean} Return the intersection point. If false, the actual\n- * intersection point will not be calculated. If true and the segments\n- * intersect, the intersection point will be returned. If true and\n- * the segments do not intersect, false will be returned. If true and\n- * the segments are coincident, true will be returned.\n- * tolerance - {Number} If a non-null value is provided, if the segments are\n- * within the tolerance distance, this will be considered an intersection.\n- * In addition, if the point option is true and the calculated intersection\n- * is within the tolerance distance of an end point, the endpoint will be\n- * returned instead of the calculated intersection. Further, if the\n- * intersection is within the tolerance of endpoints on both segments, or\n- * if two segment endpoints are within the tolerance distance of eachother\n- * (but no intersection is otherwise calculated), an endpoint on the\n- * first segment provided will be returned.\n- *\n- * Returns:\n- * {Boolean | } The two segments intersect.\n- * If the point argument is true, the return will be the intersection\n- * point or false if none exists. If point is true and the segments\n- * are coincident, return will be true (and the instersection is equal\n- * to the shorter segment).\n- */\n-OpenLayers.Geometry.segmentsIntersect = function(seg1, seg2, options) {\n- var point = options && options.point;\n- var tolerance = options && options.tolerance;\n- var intersection = false;\n- var x11_21 = seg1.x1 - seg2.x1;\n- var y11_21 = seg1.y1 - seg2.y1;\n- var x12_11 = seg1.x2 - seg1.x1;\n- var y12_11 = seg1.y2 - seg1.y1;\n- var y22_21 = seg2.y2 - seg2.y1;\n- var x22_21 = seg2.x2 - seg2.x1;\n- var d = (y22_21 * x12_11) - (x22_21 * y12_11);\n- var n1 = (x22_21 * y11_21) - (y22_21 * x11_21);\n- var n2 = (x12_11 * y11_21) - (y12_11 * x11_21);\n- if (d == 0) {\n- // parallel\n- if (n1 == 0 && n2 == 0) {\n- // coincident\n- intersection = true;\n- }\n- } else {\n- var along1 = n1 / d;\n- var along2 = n2 / d;\n- if (along1 >= 0 && along1 <= 1 && along2 >= 0 && along2 <= 1) {\n- // intersect\n- if (!point) {\n- intersection = true;\n+ var dRes = highRes - lowRes;\n+ if (dRes > 0) {\n+ zoom = lowZoom + ((highRes - resolution) / dRes);\n } else {\n- // calculate the intersection point\n- var x = seg1.x1 + (along1 * x12_11);\n- var y = seg1.y1 + (along1 * y12_11);\n- intersection = new OpenLayers.Geometry.Point(x, y);\n+ zoom = lowZoom;\n }\n- }\n- }\n- if (tolerance) {\n- var dist;\n- if (intersection) {\n- if (point) {\n- var segs = [seg1, seg2];\n- var seg, x, y;\n- // check segment endpoints for proximity to intersection\n- // set intersection to first endpoint within the tolerance\n- outer: for (var i = 0; i < 2; ++i) {\n- seg = segs[i];\n- for (var j = 1; j < 3; ++j) {\n- x = seg[\"x\" + j];\n- y = seg[\"y\" + j];\n- dist = Math.sqrt(\n- Math.pow(x - intersection.x, 2) +\n- Math.pow(y - intersection.y, 2)\n- );\n- if (dist < tolerance) {\n- intersection.x = x;\n- intersection.y = y;\n- break outer;\n- }\n+ } else {\n+ var diff;\n+ var minDiff = Number.POSITIVE_INFINITY;\n+ for (i = 0, len = this.resolutions.length; i < len; i++) {\n+ if (closest) {\n+ diff = Math.abs(this.resolutions[i] - resolution);\n+ if (diff > minDiff) {\n+ break;\n+ }\n+ minDiff = diff;\n+ } else {\n+ if (this.resolutions[i] < resolution) {\n+ break;\n }\n }\n+ }\n+ zoom = Math.max(0, i - 1);\n+ }\n+ return zoom;\n+ },\n+\n+ /**\n+ * APIMethod: getLonLatFromViewPortPx\n+ * \n+ * Parameters:\n+ * viewPortPx - {|Object} An OpenLayers.Pixel or\n+ * an object with a 'x'\n+ * and 'y' properties.\n+ *\n+ * Returns:\n+ * {} An OpenLayers.LonLat which is the passed-in \n+ * view port , translated into lon/lat by the layer.\n+ */\n+ getLonLatFromViewPortPx: function(viewPortPx) {\n+ var lonlat = null;\n+ var map = this.map;\n+ if (viewPortPx != null && map.minPx) {\n+ var res = map.getResolution();\n+ var maxExtent = map.getMaxExtent({\n+ restricted: true\n+ });\n+ var lon = (viewPortPx.x - map.minPx.x) * res + maxExtent.left;\n+ var lat = (map.minPx.y - viewPortPx.y) * res + maxExtent.top;\n+ lonlat = new OpenLayers.LonLat(lon, lat);\n \n+ if (this.wrapDateLine) {\n+ lonlat = lonlat.wrapDateLine(this.maxExtent);\n }\n- } else {\n- // no calculated intersection, but segments could be within\n- // the tolerance of one another\n- var segs = [seg1, seg2];\n- var source, target, x, y, p, result;\n- // check segment endpoints for proximity to intersection\n- // set intersection to first endpoint within the tolerance\n- outer: for (var i = 0; i < 2; ++i) {\n- source = segs[i];\n- target = segs[(i + 1) % 2];\n- for (var j = 1; j < 3; ++j) {\n- p = {\n- x: source[\"x\" + j],\n- y: source[\"y\" + j]\n- };\n- result = OpenLayers.Geometry.distanceToSegment(p, target);\n- if (result.distance < tolerance) {\n- if (point) {\n- intersection = new OpenLayers.Geometry.Point(p.x, p.y);\n- } else {\n- intersection = true;\n- }\n- break outer;\n- }\n+ }\n+ return lonlat;\n+ },\n+\n+ /**\n+ * APIMethod: getViewPortPxFromLonLat\n+ * Returns a pixel location given a map location. This method will return\n+ * fractional pixel values.\n+ * \n+ * Parameters:\n+ * lonlat - {|Object} An OpenLayers.LonLat or\n+ * an object with a 'lon'\n+ * and 'lat' properties.\n+ *\n+ * Returns: \n+ * {} An which is the passed-in \n+ * lonlat translated into view port pixels.\n+ */\n+ getViewPortPxFromLonLat: function(lonlat, resolution) {\n+ var px = null;\n+ if (lonlat != null) {\n+ resolution = resolution || this.map.getResolution();\n+ var extent = this.map.calculateBounds(null, resolution);\n+ px = new OpenLayers.Pixel(\n+ (1 / resolution * (lonlat.lon - extent.left)),\n+ (1 / resolution * (extent.top - lonlat.lat))\n+ );\n+ }\n+ return px;\n+ },\n+\n+ /**\n+ * APIMethod: setOpacity\n+ * Sets the opacity for the entire layer (all images)\n+ * \n+ * Parameters:\n+ * opacity - {Float}\n+ */\n+ setOpacity: function(opacity) {\n+ if (opacity != this.opacity) {\n+ this.opacity = opacity;\n+ var childNodes = this.div.childNodes;\n+ for (var i = 0, len = childNodes.length; i < len; ++i) {\n+ var element = childNodes[i].firstChild || childNodes[i];\n+ var lastChild = childNodes[i].lastChild;\n+ //TODO de-uglify this\n+ if (lastChild && lastChild.nodeName.toLowerCase() === \"iframe\") {\n+ element = lastChild.parentNode;\n }\n+ OpenLayers.Util.modifyDOMElement(element, null, null, null,\n+ null, null, null, opacity);\n+ }\n+ if (this.map != null) {\n+ this.map.events.triggerEvent(\"changelayer\", {\n+ layer: this,\n+ property: \"opacity\"\n+ });\n }\n }\n- }\n- return intersection;\n-};\n+ },\n \n-/**\n- * Function: OpenLayers.Geometry.distanceToSegment\n- *\n- * Parameters:\n- * point - {Object} An object with x and y properties representing the\n- * point coordinates.\n- * segment - {Object} An object with x1, y1, x2, and y2 properties\n- * representing endpoint coordinates.\n- *\n- * Returns:\n- * {Object} An object with distance, along, x, and y properties. The distance\n- * will be the shortest distance between the input point and segment.\n- * The x and y properties represent the coordinates along the segment\n- * where the shortest distance meets the segment. The along attribute\n- * describes how far between the two segment points the given point is.\n- */\n-OpenLayers.Geometry.distanceToSegment = function(point, segment) {\n- var result = OpenLayers.Geometry.distanceSquaredToSegment(point, segment);\n- result.distance = Math.sqrt(result.distance);\n- return result;\n-};\n+ /**\n+ * Method: getZIndex\n+ * \n+ * Returns: \n+ * {Integer} the z-index of this layer\n+ */\n+ getZIndex: function() {\n+ return this.div.style.zIndex;\n+ },\n \n-/**\n- * Function: OpenLayers.Geometry.distanceSquaredToSegment\n- *\n- * Usually the distanceToSegment function should be used. This variant however\n- * can be used for comparisons where the exact distance is not important.\n- *\n- * Parameters:\n- * point - {Object} An object with x and y properties representing the\n- * point coordinates.\n- * segment - {Object} An object with x1, y1, x2, and y2 properties\n- * representing endpoint coordinates.\n- *\n- * Returns:\n- * {Object} An object with squared distance, along, x, and y properties.\n- * The distance will be the shortest distance between the input point and\n- * segment. The x and y properties represent the coordinates along the\n- * segment where the shortest distance meets the segment. The along\n- * attribute describes how far between the two segment points the given\n- * point is.\n- */\n-OpenLayers.Geometry.distanceSquaredToSegment = function(point, segment) {\n- var x0 = point.x;\n- var y0 = point.y;\n- var x1 = segment.x1;\n- var y1 = segment.y1;\n- var x2 = segment.x2;\n- var y2 = segment.y2;\n- var dx = x2 - x1;\n- var dy = y2 - y1;\n- var along = ((dx * (x0 - x1)) + (dy * (y0 - y1))) /\n- (Math.pow(dx, 2) + Math.pow(dy, 2));\n- var x, y;\n- if (along <= 0.0) {\n- x = x1;\n- y = y1;\n- } else if (along >= 1.0) {\n- x = x2;\n- y = y2;\n- } else {\n- x = x1 + along * dx;\n- y = y1 + along * dy;\n- }\n- return {\n- distance: Math.pow(x - x0, 2) + Math.pow(y - y0, 2),\n- x: x,\n- y: y,\n- along: along\n- };\n-};\n+ /**\n+ * Method: setZIndex\n+ * \n+ * Parameters: \n+ * zIndex - {Integer}\n+ */\n+ setZIndex: function(zIndex) {\n+ this.div.style.zIndex = zIndex;\n+ },\n+\n+ /**\n+ * Method: adjustBounds\n+ * This function will take a bounds, and if wrapDateLine option is set\n+ * on the layer, it will return a bounds which is wrapped around the \n+ * world. We do not wrap for bounds which *cross* the \n+ * maxExtent.left/right, only bounds which are entirely to the left \n+ * or entirely to the right.\n+ * \n+ * Parameters:\n+ * bounds - {}\n+ */\n+ adjustBounds: function(bounds) {\n+\n+ if (this.gutter) {\n+ // Adjust the extent of a bounds in map units by the \n+ // layer's gutter in pixels.\n+ var mapGutter = this.gutter * this.map.getResolution();\n+ bounds = new OpenLayers.Bounds(bounds.left - mapGutter,\n+ bounds.bottom - mapGutter,\n+ bounds.right + mapGutter,\n+ bounds.top + mapGutter);\n+ }\n+\n+ if (this.wrapDateLine) {\n+ // wrap around the date line, within the limits of rounding error\n+ var wrappingOptions = {\n+ 'rightTolerance': this.getResolution(),\n+ 'leftTolerance': this.getResolution()\n+ };\n+ bounds = bounds.wrapDateLine(this.maxExtent, wrappingOptions);\n+\n+ }\n+ return bounds;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Layer\"\n+});\n /* ======================================================================\n- OpenLayers/Format.js\n+ OpenLayers/Strategy.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n */\n \n /**\n- * Class: OpenLayers.Format\n- * Base class for format reading/writing a variety of formats. Subclasses\n- * of OpenLayers.Format are expected to have read and write methods.\n+ * Class: OpenLayers.Strategy\n+ * Abstract vector layer strategy class. Not to be instantiated directly. Use\n+ * one of the strategy subclasses instead.\n */\n-OpenLayers.Format = OpenLayers.Class({\n+OpenLayers.Strategy = OpenLayers.Class({\n \n /**\n- * Property: options\n- * {Object} A reference to options passed to the constructor.\n+ * Property: layer\n+ * {} The layer this strategy belongs to.\n */\n- options: null,\n+ layer: null,\n \n /**\n- * APIProperty: externalProjection\n- * {} When passed a externalProjection and\n- * internalProjection, the format will reproject the geometries it\n- * reads or writes. The externalProjection is the projection used by\n- * the content which is passed into read or which comes out of write.\n- * In order to reproject, a projection transformation function for the\n- * specified projections must be available. This support may be \n- * provided via proj4js or via a custom transformation function. See\n- * {} for more information on\n- * custom transformations.\n+ * Property: options\n+ * {Object} Any options sent to the constructor.\n */\n- externalProjection: null,\n+ options: null,\n \n- /**\n- * APIProperty: internalProjection\n- * {} When passed a externalProjection and\n- * internalProjection, the format will reproject the geometries it\n- * reads or writes. The internalProjection is the projection used by\n- * the geometries which are returned by read or which are passed into\n- * write. In order to reproject, a projection transformation function\n- * for the specified projections must be available. This support may be\n- * provided via proj4js or via a custom transformation function. See\n- * {} for more information on\n- * custom transformations.\n+ /** \n+ * Property: active \n+ * {Boolean} The control is active.\n */\n- internalProjection: null,\n+ active: null,\n \n /**\n- * APIProperty: data\n- * {Object} When is true, this is the parsed string sent to\n- * .\n+ * Property: autoActivate\n+ * {Boolean} The creator of the strategy can set autoActivate to false\n+ * to fully control when the protocol is activated and deactivated.\n+ * Defaults to true.\n */\n- data: null,\n+ autoActivate: true,\n \n /**\n- * APIProperty: keepData\n- * {Object} Maintain a reference () to the most recently read data.\n- * Default is false.\n+ * Property: autoDestroy\n+ * {Boolean} The creator of the strategy can set autoDestroy to false\n+ * to fully control when the strategy is destroyed. Defaults to\n+ * true.\n */\n- keepData: false,\n+ autoDestroy: true,\n \n /**\n- * Constructor: OpenLayers.Format\n- * Instances of this class are not useful. See one of the subclasses.\n+ * Constructor: OpenLayers.Strategy\n+ * Abstract class for vector strategies. Create instances of a subclass.\n *\n * Parameters:\n- * options - {Object} An optional object with properties to set on the\n- * format\n- *\n- * Valid options:\n- * keepData - {Boolean} If true, upon , the data property will be\n- * set to the parsed object (e.g. the json or xml object).\n- *\n- * Returns:\n- * An instance of OpenLayers.Format\n+ * options - {Object} Optional object whose properties will be set on the\n+ * instance.\n */\n initialize: function(options) {\n OpenLayers.Util.extend(this, options);\n this.options = options;\n+ // set the active property here, so that user cannot override it\n+ this.active = false;\n },\n \n /**\n * APIMethod: destroy\n- * Clean up.\n+ * Clean up the strategy.\n */\n- destroy: function() {},\n+ destroy: function() {\n+ this.deactivate();\n+ this.layer = null;\n+ this.options = null;\n+ },\n \n /**\n- * Method: read\n- * Read data from a string, and return an object whose type depends on the\n- * subclass. \n- * \n+ * Method: setLayer\n+ * Called to set the property.\n+ *\n * Parameters:\n- * data - {string} Data to read/parse.\n+ * layer - {}\n+ */\n+ setLayer: function(layer) {\n+ this.layer = layer;\n+ },\n+\n+ /**\n+ * Method: activate\n+ * Activate the strategy. Register any listeners, do appropriate setup.\n *\n * Returns:\n- * Depends on the subclass\n+ * {Boolean} True if the strategy was successfully activated or false if\n+ * the strategy was already active.\n */\n- read: function(data) {\n- throw new Error('Read not implemented.');\n+ activate: function() {\n+ if (!this.active) {\n+ this.active = true;\n+ return true;\n+ }\n+ return false;\n },\n \n /**\n- * Method: write\n- * Accept an object, and return a string. \n- *\n- * Parameters:\n- * object - {Object} Object to be serialized\n+ * Method: deactivate\n+ * Deactivate the strategy. Unregister any listeners, do appropriate\n+ * tear-down.\n *\n * Returns:\n- * {String} A string representation of the object.\n+ * {Boolean} True if the strategy was successfully deactivated or false if\n+ * the strategy was already inactive.\n */\n- write: function(object) {\n- throw new Error('Write not implemented.');\n+ deactivate: function() {\n+ if (this.active) {\n+ this.active = false;\n+ return true;\n+ }\n+ return false;\n },\n \n- CLASS_NAME: \"OpenLayers.Format\"\n+ CLASS_NAME: \"OpenLayers.Strategy\"\n });\n /* ======================================================================\n- OpenLayers/Geometry/Point.js\n+ OpenLayers/Popup.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Geometry.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n */\n \n+\n /**\n- * Class: OpenLayers.Geometry.Point\n- * Point geometry class. \n- * \n- * Inherits from:\n- * - \n+ * Class: OpenLayers.Popup\n+ * A popup is a small div that can opened and closed on the map.\n+ * Typically opened in response to clicking on a marker. \n+ * See . Popup's don't require their own\n+ * layer and are added the the map using the \n+ * method.\n+ *\n+ * Example:\n+ * (code)\n+ * popup = new OpenLayers.Popup(\"chicken\", \n+ * new OpenLayers.LonLat(5,40),\n+ * new OpenLayers.Size(200,200),\n+ * \"example popup\",\n+ * true);\n+ * \n+ * map.addPopup(popup);\n+ * (end)\n */\n-OpenLayers.Geometry.Point = OpenLayers.Class(OpenLayers.Geometry, {\n+OpenLayers.Popup = OpenLayers.Class({\n \n /** \n- * APIProperty: x \n- * {float} \n+ * Property: events \n+ * {} custom event manager \n */\n- x: null,\n+ events: null,\n+\n+ /** Property: id\n+ * {String} the unique identifier assigned to this popup.\n+ */\n+ id: \"\",\n \n /** \n- * APIProperty: y \n- * {float} \n+ * Property: lonlat \n+ * {} the position of this popup on the map\n */\n- y: null,\n+ lonlat: null,\n \n- /**\n- * Constructor: OpenLayers.Geometry.Point\n- * Construct a point geometry.\n- *\n- * Parameters:\n- * x - {float} \n- * y - {float}\n- * \n+ /** \n+ * Property: div \n+ * {DOMElement} the div that contains this popup.\n */\n- initialize: function(x, y) {\n- OpenLayers.Geometry.prototype.initialize.apply(this, arguments);\n+ div: null,\n \n- this.x = parseFloat(x);\n- this.y = parseFloat(y);\n- },\n+ /** \n+ * Property: contentSize \n+ * {} the width and height of the content.\n+ */\n+ contentSize: null,\n \n- /**\n- * APIMethod: clone\n- * \n- * Returns:\n- * {} An exact clone of this OpenLayers.Geometry.Point\n+ /** \n+ * Property: size \n+ * {} the width and height of the popup.\n */\n- clone: function(obj) {\n- if (obj == null) {\n- obj = new OpenLayers.Geometry.Point(this.x, this.y);\n- }\n+ size: null,\n \n- // catch any randomly tagged-on properties\n- OpenLayers.Util.applyDefaults(obj, this);\n+ /** \n+ * Property: contentHTML \n+ * {String} An HTML string for this popup to display.\n+ */\n+ contentHTML: null,\n \n- return obj;\n- },\n+ /** \n+ * Property: backgroundColor \n+ * {String} the background color used by the popup.\n+ */\n+ backgroundColor: \"\",\n \n /** \n- * Method: calculateBounds\n- * Create a new Bounds based on the lon/lat\n+ * Property: opacity \n+ * {float} the opacity of this popup (between 0.0 and 1.0)\n */\n- calculateBounds: function() {\n- this.bounds = new OpenLayers.Bounds(this.x, this.y,\n- this.x, this.y);\n- },\n+ opacity: \"\",\n \n- /**\n- * APIMethod: distanceTo\n- * Calculate the closest distance between two geometries (on the x-y plane).\n- *\n- * Parameters:\n- * geometry - {} The target geometry.\n- * options - {Object} Optional properties for configuring the distance\n- * calculation.\n- *\n- * Valid options:\n- * details - {Boolean} Return details from the distance calculation.\n+ /** \n+ * Property: border \n+ * {String} the border size of the popup. (eg 2px)\n+ */\n+ border: \"\",\n+\n+ /** \n+ * Property: contentDiv \n+ * {DOMElement} a reference to the element that holds the content of\n+ * the div.\n+ */\n+ contentDiv: null,\n+\n+ /** \n+ * Property: groupDiv \n+ * {DOMElement} First and only child of 'div'. The group Div contains the\n+ * 'contentDiv' and the 'closeDiv'.\n+ */\n+ groupDiv: null,\n+\n+ /** \n+ * Property: closeDiv\n+ * {DOMElement} the optional closer image\n+ */\n+ closeDiv: null,\n+\n+ /** \n+ * APIProperty: autoSize\n+ * {Boolean} Resize the popup to auto-fit the contents.\n * Default is false.\n- * edge - {Boolean} Calculate the distance from this geometry to the\n- * nearest edge of the target geometry. Default is true. If true,\n- * calling distanceTo from a geometry that is wholly contained within\n- * the target will result in a non-zero distance. If false, whenever\n- * geometries intersect, calling distanceTo will return 0. If false,\n- * details cannot be returned.\n- *\n- * Returns:\n- * {Number | Object} The distance between this geometry and the target.\n- * If details is true, the return will be an object with distance,\n- * x0, y0, x1, and x2 properties. The x0 and y0 properties represent\n- * the coordinates of the closest point on this geometry. The x1 and y1\n- * properties represent the coordinates of the closest point on the\n- * target geometry.\n */\n- distanceTo: function(geometry, options) {\n- var edge = !(options && options.edge === false);\n- var details = edge && options && options.details;\n- var distance, x0, y0, x1, y1, result;\n- if (geometry instanceof OpenLayers.Geometry.Point) {\n- x0 = this.x;\n- y0 = this.y;\n- x1 = geometry.x;\n- y1 = geometry.y;\n- distance = Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));\n- result = !details ?\n- distance : {\n- x0: x0,\n- y0: y0,\n- x1: x1,\n- y1: y1,\n- distance: distance\n- };\n- } else {\n- result = geometry.distanceTo(this, options);\n- if (details) {\n- // switch coord order since this geom is target\n- result = {\n- x0: result.x1,\n- y0: result.y1,\n- x1: result.x0,\n- y1: result.y0,\n- distance: result.distance\n- };\n- }\n- }\n- return result;\n- },\n+ autoSize: false,\n+\n+ /**\n+ * APIProperty: minSize\n+ * {} Minimum size allowed for the popup's contents.\n+ */\n+ minSize: null,\n+\n+ /**\n+ * APIProperty: maxSize\n+ * {} Maximum size allowed for the popup's contents.\n+ */\n+ maxSize: null,\n \n /** \n- * APIMethod: equals\n- * Determine whether another geometry is equivalent to this one. Geometries\n- * are considered equivalent if all components have the same coordinates.\n+ * Property: displayClass\n+ * {String} The CSS class of the popup.\n+ */\n+ displayClass: \"olPopup\",\n+\n+ /** \n+ * Property: contentDisplayClass\n+ * {String} The CSS class of the popup content div.\n+ */\n+ contentDisplayClass: \"olPopupContent\",\n+\n+ /** \n+ * Property: padding \n+ * {int or } An extra opportunity to specify internal \n+ * padding of the content div inside the popup. This was originally\n+ * confused with the css padding as specified in style.css's \n+ * 'olPopupContent' class. We would like to get rid of this altogether,\n+ * except that it does come in handy for the framed and anchoredbubble\n+ * popups, who need to maintain yet another barrier between their \n+ * content and the outer border of the popup itself. \n * \n- * Parameters:\n- * geom - {} The geometry to test. \n- *\n- * Returns:\n- * {Boolean} The supplied geometry is equivalent to this geometry.\n+ * Note that in order to not break API, we must continue to support \n+ * this property being set as an integer. Really, though, we'd like to \n+ * have this specified as a Bounds object so that user can specify\n+ * distinct left, top, right, bottom paddings. With the 3.0 release\n+ * we can make this only a bounds.\n */\n- equals: function(geom) {\n- var equals = false;\n- if (geom != null) {\n- equals = ((this.x == geom.x && this.y == geom.y) ||\n- (isNaN(this.x) && isNaN(this.y) && isNaN(geom.x) && isNaN(geom.y)));\n+ padding: 0,\n+\n+ /** \n+ * Property: disableFirefoxOverflowHack\n+ * {Boolean} The hack for overflow in Firefox causes all elements \n+ * to be re-drawn, which causes Flash elements to be \n+ * re-initialized, which is troublesome.\n+ * With this property the hack can be disabled.\n+ */\n+ disableFirefoxOverflowHack: false,\n+\n+ /**\n+ * Method: fixPadding\n+ * To be removed in 3.0, this function merely helps us to deal with the \n+ * case where the user may have set an integer value for padding, \n+ * instead of an object.\n+ */\n+ fixPadding: function() {\n+ if (typeof this.padding == \"number\") {\n+ this.padding = new OpenLayers.Bounds(\n+ this.padding, this.padding, this.padding, this.padding\n+ );\n }\n- return equals;\n },\n \n /**\n- * Method: toShortString\n- *\n- * Returns:\n- * {String} Shortened String representation of Point object. \n- * (ex. \"5, 42\")\n+ * APIProperty: panMapIfOutOfView\n+ * {Boolean} When drawn, pan map such that the entire popup is visible in\n+ * the current viewport (if necessary).\n+ * Default is false.\n */\n- toShortString: function() {\n- return (this.x + \", \" + this.y);\n- },\n+ panMapIfOutOfView: false,\n \n /**\n- * APIMethod: move\n- * Moves a geometry by the given displacement along positive x and y axes.\n- * This modifies the position of the geometry and clears the cached\n- * bounds.\n- *\n- * Parameters:\n- * x - {Float} Distance to move geometry in positive x direction. \n- * y - {Float} Distance to move geometry in positive y direction.\n+ * APIProperty: keepInMap \n+ * {Boolean} If panMapIfOutOfView is false, and this property is true, \n+ * contrain the popup such that it always fits in the available map\n+ * space. By default, this is not set on the base class. If you are\n+ * creating popups that are near map edges and not allowing pannning,\n+ * and especially if you have a popup which has a\n+ * fixedRelativePosition, setting this to false may be a smart thing to\n+ * do. Subclasses may want to override this setting.\n+ * \n+ * Default is false.\n */\n- move: function(x, y) {\n- this.x = this.x + x;\n- this.y = this.y + y;\n- this.clearBounds();\n- },\n+ keepInMap: false,\n \n /**\n- * APIMethod: rotate\n- * Rotate a point around another.\n- *\n- * Parameters:\n- * angle - {Float} Rotation angle in degrees (measured counterclockwise\n- * from the positive x-axis)\n- * origin - {} Center point for the rotation\n+ * APIProperty: closeOnMove\n+ * {Boolean} When map pans, close the popup.\n+ * Default is false.\n */\n- rotate: function(angle, origin) {\n- angle *= Math.PI / 180;\n- var radius = this.distanceTo(origin);\n- var theta = angle + Math.atan2(this.y - origin.y, this.x - origin.x);\n- this.x = origin.x + (radius * Math.cos(theta));\n- this.y = origin.y + (radius * Math.sin(theta));\n- this.clearBounds();\n+ closeOnMove: false,\n+\n+ /** \n+ * Property: map \n+ * {} this gets set in Map.js when the popup is added to the map\n+ */\n+ map: null,\n+\n+ /** \n+ * Constructor: OpenLayers.Popup\n+ * Create a popup.\n+ * \n+ * Parameters: \n+ * id - {String} a unqiue identifier for this popup. If null is passed\n+ * an identifier will be automatically generated. \n+ * lonlat - {} The position on the map the popup will\n+ * be shown.\n+ * contentSize - {} The size of the content.\n+ * contentHTML - {String} An HTML string to display inside the \n+ * popup.\n+ * closeBox - {Boolean} Whether to display a close box inside\n+ * the popup.\n+ * closeBoxCallback - {Function} Function to be called on closeBox click.\n+ */\n+ initialize: function(id, lonlat, contentSize, contentHTML, closeBox, closeBoxCallback) {\n+ if (id == null) {\n+ id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+ }\n+\n+ this.id = id;\n+ this.lonlat = lonlat;\n+\n+ this.contentSize = (contentSize != null) ? contentSize :\n+ new OpenLayers.Size(\n+ OpenLayers.Popup.WIDTH,\n+ OpenLayers.Popup.HEIGHT);\n+ if (contentHTML != null) {\n+ this.contentHTML = contentHTML;\n+ }\n+ this.backgroundColor = OpenLayers.Popup.COLOR;\n+ this.opacity = OpenLayers.Popup.OPACITY;\n+ this.border = OpenLayers.Popup.BORDER;\n+\n+ this.div = OpenLayers.Util.createDiv(this.id, null, null,\n+ null, null, null, \"hidden\");\n+ this.div.className = this.displayClass;\n+\n+ var groupDivId = this.id + \"_GroupDiv\";\n+ this.groupDiv = OpenLayers.Util.createDiv(groupDivId, null, null,\n+ null, \"relative\", null,\n+ \"hidden\");\n+\n+ var id = this.div.id + \"_contentDiv\";\n+ this.contentDiv = OpenLayers.Util.createDiv(id, null, this.contentSize.clone(),\n+ null, \"relative\");\n+ this.contentDiv.className = this.contentDisplayClass;\n+ this.groupDiv.appendChild(this.contentDiv);\n+ this.div.appendChild(this.groupDiv);\n+\n+ if (closeBox) {\n+ this.addCloseBox(closeBoxCallback);\n+ }\n+\n+ this.registerEvents();\n },\n \n- /**\n- * APIMethod: getCentroid\n- *\n- * Returns:\n- * {} The centroid of the collection\n+ /** \n+ * Method: destroy\n+ * nullify references to prevent circular references and memory leaks\n */\n- getCentroid: function() {\n- return new OpenLayers.Geometry.Point(this.x, this.y);\n+ destroy: function() {\n+\n+ this.id = null;\n+ this.lonlat = null;\n+ this.size = null;\n+ this.contentHTML = null;\n+\n+ this.backgroundColor = null;\n+ this.opacity = null;\n+ this.border = null;\n+\n+ if (this.closeOnMove && this.map) {\n+ this.map.events.unregister(\"movestart\", this, this.hide);\n+ }\n+\n+ this.events.destroy();\n+ this.events = null;\n+\n+ if (this.closeDiv) {\n+ OpenLayers.Event.stopObservingElement(this.closeDiv);\n+ this.groupDiv.removeChild(this.closeDiv);\n+ }\n+ this.closeDiv = null;\n+\n+ this.div.removeChild(this.groupDiv);\n+ this.groupDiv = null;\n+\n+ if (this.map != null) {\n+ this.map.removePopup(this);\n+ }\n+ this.map = null;\n+ this.div = null;\n+\n+ this.autoSize = null;\n+ this.minSize = null;\n+ this.maxSize = null;\n+ this.padding = null;\n+ this.panMapIfOutOfView = null;\n },\n \n- /**\n- * APIMethod: resize\n- * Resize a point relative to some origin. For points, this has the effect\n- * of scaling a vector (from the origin to the point). This method is\n- * more useful on geometry collection subclasses.\n+ /** \n+ * Method: draw\n+ * Constructs the elements that make up the popup.\n *\n * Parameters:\n- * scale - {Float} Ratio of the new distance from the origin to the old\n- * distance from the origin. A scale of 2 doubles the\n- * distance between the point and origin.\n- * origin - {} Point of origin for resizing\n- * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.\n+ * px - {} the position the popup in pixels.\n * \n * Returns:\n- * {} - The current geometry. \n+ * {DOMElement} Reference to a div that contains the drawn popup\n */\n- resize: function(scale, origin, ratio) {\n- ratio = (ratio == undefined) ? 1 : ratio;\n- this.x = origin.x + (scale * ratio * (this.x - origin.x));\n- this.y = origin.y + (scale * (this.y - origin.y));\n- this.clearBounds();\n- return this;\n+ draw: function(px) {\n+ if (px == null) {\n+ if ((this.lonlat != null) && (this.map != null)) {\n+ px = this.map.getLayerPxFromLonLat(this.lonlat);\n+ }\n+ }\n+\n+ // this assumes that this.map already exists, which is okay because \n+ // this.draw is only called once the popup has been added to the map.\n+ if (this.closeOnMove) {\n+ this.map.events.register(\"movestart\", this, this.hide);\n+ }\n+\n+ //listen to movestart, moveend to disable overflow (FF bug)\n+ if (!this.disableFirefoxOverflowHack && OpenLayers.BROWSER_NAME == 'firefox') {\n+ this.map.events.register(\"movestart\", this, function() {\n+ var style = document.defaultView.getComputedStyle(\n+ this.contentDiv, null\n+ );\n+ var currentOverflow = style.getPropertyValue(\"overflow\");\n+ if (currentOverflow != \"hidden\") {\n+ this.contentDiv._oldOverflow = currentOverflow;\n+ this.contentDiv.style.overflow = \"hidden\";\n+ }\n+ });\n+ this.map.events.register(\"moveend\", this, function() {\n+ var oldOverflow = this.contentDiv._oldOverflow;\n+ if (oldOverflow) {\n+ this.contentDiv.style.overflow = oldOverflow;\n+ this.contentDiv._oldOverflow = null;\n+ }\n+ });\n+ }\n+\n+ this.moveTo(px);\n+ if (!this.autoSize && !this.size) {\n+ this.setSize(this.contentSize);\n+ }\n+ this.setBackgroundColor();\n+ this.setOpacity();\n+ this.setBorder();\n+ this.setContentHTML();\n+\n+ if (this.panMapIfOutOfView) {\n+ this.panIntoView();\n+ }\n+\n+ return this.div;\n },\n \n- /**\n- * APIMethod: intersects\n- * Determine if the input geometry intersects this one.\n- *\n- * Parameters:\n- * geometry - {} Any type of geometry.\n- *\n- * Returns:\n- * {Boolean} The input geometry intersects this one.\n+ /** \n+ * Method: updatePosition\n+ * if the popup has a lonlat and its map members set, \n+ * then have it move itself to its proper position\n */\n- intersects: function(geometry) {\n- var intersect = false;\n- if (geometry.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n- intersect = this.equals(geometry);\n- } else {\n- intersect = geometry.intersects(this);\n+ updatePosition: function() {\n+ if ((this.lonlat) && (this.map)) {\n+ var px = this.map.getLayerPxFromLonLat(this.lonlat);\n+ if (px) {\n+ this.moveTo(px);\n+ }\n }\n- return intersect;\n },\n \n /**\n- * APIMethod: transform\n- * Translate the x,y properties of the point from source to dest.\n+ * Method: moveTo\n * \n * Parameters:\n- * source - {} \n- * dest - {}\n- * \n- * Returns:\n- * {} \n+ * px - {} the top and left position of the popup div. \n */\n- transform: function(source, dest) {\n- if ((source && dest)) {\n- OpenLayers.Projection.transform(\n- this, source, dest);\n- this.bounds = null;\n+ moveTo: function(px) {\n+ if ((px != null) && (this.div != null)) {\n+ this.div.style.left = px.x + \"px\";\n+ this.div.style.top = px.y + \"px\";\n }\n- return this;\n },\n \n /**\n- * APIMethod: getVertices\n- * Return a list of all points in this geometry.\n- *\n- * Parameters:\n- * nodes - {Boolean} For lines, only return vertices that are\n- * endpoints. If false, for lines, only vertices that are not\n- * endpoints will be returned. If not provided, all vertices will\n- * be returned.\n+ * Method: visible\n *\n- * Returns:\n- * {Array} A list of all vertices in the geometry.\n+ * Returns: \n+ * {Boolean} Boolean indicating whether or not the popup is visible\n */\n- getVertices: function(nodes) {\n- return [this];\n+ visible: function() {\n+ return OpenLayers.Element.visible(this.div);\n },\n \n- CLASS_NAME: \"OpenLayers.Geometry.Point\"\n-});\n-/* ======================================================================\n- OpenLayers/Geometry/Collection.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Geometry.js\n- */\n-\n-/**\n- * Class: OpenLayers.Geometry.Collection\n- * A Collection is exactly what it sounds like: A collection of different \n- * Geometries. These are stored in the local parameter (which\n- * can be passed as a parameter to the constructor). \n- * \n- * As new geometries are added to the collection, they are NOT cloned. \n- * When removing geometries, they need to be specified by reference (ie you \n- * have to pass in the *exact* geometry to be removed).\n- * \n- * The and functions here merely iterate through\n- * the components, summing their respective areas and lengths.\n- *\n- * Create a new instance with the constructor.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {\n-\n /**\n- * APIProperty: components\n- * {Array()} The component parts of this geometry\n+ * Method: toggle\n+ * Toggles visibility of the popup.\n */\n- components: null,\n+ toggle: function() {\n+ if (this.visible()) {\n+ this.hide();\n+ } else {\n+ this.show();\n+ }\n+ },\n \n /**\n- * Property: componentTypes\n- * {Array(String)} An array of class names representing the types of\n- * components that the collection can include. A null value means the\n- * component types are not restricted.\n+ * Method: show\n+ * Makes the popup visible.\n */\n- componentTypes: null,\n+ show: function() {\n+ this.div.style.display = '';\n \n- /**\n- * Constructor: OpenLayers.Geometry.Collection\n- * Creates a Geometry Collection -- a list of geoms.\n- *\n- * Parameters: \n- * components - {Array()} Optional array of geometries\n- *\n- */\n- initialize: function(components) {\n- OpenLayers.Geometry.prototype.initialize.apply(this, arguments);\n- this.components = [];\n- if (components != null) {\n- this.addComponents(components);\n+ if (this.panMapIfOutOfView) {\n+ this.panIntoView();\n }\n },\n \n /**\n- * APIMethod: destroy\n- * Destroy this geometry.\n+ * Method: hide\n+ * Makes the popup invisible.\n */\n- destroy: function() {\n- this.components.length = 0;\n- this.components = null;\n- OpenLayers.Geometry.prototype.destroy.apply(this, arguments);\n+ hide: function() {\n+ this.div.style.display = 'none';\n },\n \n /**\n- * APIMethod: clone\n- * Clone this geometry.\n+ * Method: setSize\n+ * Used to adjust the size of the popup. \n *\n- * Returns:\n- * {} An exact clone of this collection\n+ * Parameters:\n+ * contentSize - {} the new size for the popup's \n+ * contents div (in pixels).\n */\n- clone: function() {\n- var geometry = eval(\"new \" + this.CLASS_NAME + \"()\");\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- geometry.addComponent(this.components[i].clone());\n+ setSize: function(contentSize) {\n+ this.size = contentSize.clone();\n+\n+ // if our contentDiv has a css 'padding' set on it by a stylesheet, we \n+ // must add that to the desired \"size\". \n+ var contentDivPadding = this.getContentDivPadding();\n+ var wPadding = contentDivPadding.left + contentDivPadding.right;\n+ var hPadding = contentDivPadding.top + contentDivPadding.bottom;\n+\n+ // take into account the popup's 'padding' property\n+ this.fixPadding();\n+ wPadding += this.padding.left + this.padding.right;\n+ hPadding += this.padding.top + this.padding.bottom;\n+\n+ // make extra space for the close div\n+ if (this.closeDiv) {\n+ var closeDivWidth = parseInt(this.closeDiv.style.width);\n+ wPadding += closeDivWidth + contentDivPadding.right;\n }\n \n- // catch any randomly tagged-on properties\n- OpenLayers.Util.applyDefaults(geometry, this);\n+ //increase size of the main popup div to take into account the \n+ // users's desired padding and close div. \n+ this.size.w += wPadding;\n+ this.size.h += hPadding;\n \n- return geometry;\n- },\n+ //now if our browser is IE, we need to actually make the contents \n+ // div itself bigger to take its own padding into effect. this makes \n+ // me want to shoot someone, but so it goes.\n+ if (OpenLayers.BROWSER_NAME == \"msie\") {\n+ this.contentSize.w +=\n+ contentDivPadding.left + contentDivPadding.right;\n+ this.contentSize.h +=\n+ contentDivPadding.bottom + contentDivPadding.top;\n+ }\n \n- /**\n- * Method: getComponentsString\n- * Get a string representing the components for this collection\n- * \n- * Returns:\n- * {String} A string representation of the components of this geometry\n- */\n- getComponentsString: function() {\n- var strings = [];\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- strings.push(this.components[i].toShortString());\n+ if (this.div != null) {\n+ this.div.style.width = this.size.w + \"px\";\n+ this.div.style.height = this.size.h + \"px\";\n+ }\n+ if (this.contentDiv != null) {\n+ this.contentDiv.style.width = contentSize.w + \"px\";\n+ this.contentDiv.style.height = contentSize.h + \"px\";\n }\n- return strings.join(\",\");\n },\n \n /**\n- * APIMethod: calculateBounds\n- * Recalculate the bounds by iterating through the components and \n- * calling calling extendBounds() on each item.\n+ * APIMethod: updateSize\n+ * Auto size the popup so that it precisely fits its contents (as \n+ * determined by this.contentDiv.innerHTML). Popup size will, of\n+ * course, be limited by the available space on the current map\n */\n- calculateBounds: function() {\n- this.bounds = null;\n- var bounds = new OpenLayers.Bounds();\n- var components = this.components;\n- if (components) {\n- for (var i = 0, len = components.length; i < len; i++) {\n- bounds.extend(components[i].getBounds());\n+ updateSize: function() {\n+\n+ // determine actual render dimensions of the contents by putting its\n+ // contents into a fake contentDiv (for the CSS) and then measuring it\n+ var preparedHTML = \"
\" +\n+ this.contentDiv.innerHTML +\n+ \"
\";\n+\n+ var containerElement = (this.map) ? this.map.div : document.body;\n+ var realSize = OpenLayers.Util.getRenderedDimensions(\n+ preparedHTML, null, {\n+ displayClass: this.displayClass,\n+ containerElement: containerElement\n+ }\n+ );\n+\n+ // is the \"real\" size of the div is safe to display in our map?\n+ var safeSize = this.getSafeContentSize(realSize);\n+\n+ var newSize = null;\n+ if (safeSize.equals(realSize)) {\n+ //real size of content is small enough to fit on the map, \n+ // so we use real size.\n+ newSize = realSize;\n+\n+ } else {\n+\n+ // make a new 'size' object with the clipped dimensions \n+ // set or null if not clipped.\n+ var fixedSize = {\n+ w: (safeSize.w < realSize.w) ? safeSize.w : null,\n+ h: (safeSize.h < realSize.h) ? safeSize.h : null\n+ };\n+\n+ if (fixedSize.w && fixedSize.h) {\n+ //content is too big in both directions, so we will use \n+ // max popup size (safeSize), knowing well that it will \n+ // overflow both ways. \n+ newSize = safeSize;\n+ } else {\n+ //content is clipped in only one direction, so we need to \n+ // run getRenderedDimensions() again with a fixed dimension\n+ var clippedSize = OpenLayers.Util.getRenderedDimensions(\n+ preparedHTML, fixedSize, {\n+ displayClass: this.contentDisplayClass,\n+ containerElement: containerElement\n+ }\n+ );\n+\n+ //if the clipped size is still the same as the safeSize, \n+ // that means that our content must be fixed in the \n+ // offending direction. If overflow is 'auto', this means \n+ // we are going to have a scrollbar for sure, so we must \n+ // adjust for that.\n+ //\n+ var currentOverflow = OpenLayers.Element.getStyle(\n+ this.contentDiv, \"overflow\"\n+ );\n+ if ((currentOverflow != \"hidden\") &&\n+ (clippedSize.equals(safeSize))) {\n+ var scrollBar = OpenLayers.Util.getScrollbarWidth();\n+ if (fixedSize.w) {\n+ clippedSize.h += scrollBar;\n+ } else {\n+ clippedSize.w += scrollBar;\n+ }\n+ }\n+\n+ newSize = this.getSafeContentSize(clippedSize);\n }\n }\n- // to preserve old behavior, we only set bounds if non-null\n- // in the future, we could add bounds.isEmpty()\n- if (bounds.left != null && bounds.bottom != null &&\n- bounds.right != null && bounds.top != null) {\n- this.setBounds(bounds);\n- }\n+ this.setSize(newSize);\n },\n \n /**\n- * APIMethod: addComponents\n- * Add components to this geometry.\n+ * Method: setBackgroundColor\n+ * Sets the background color of the popup.\n *\n * Parameters:\n- * components - {Array()} An array of geometries to add\n+ * color - {String} the background color. eg \"#FFBBBB\"\n */\n- addComponents: function(components) {\n- if (!(OpenLayers.Util.isArray(components))) {\n- components = [components];\n+ setBackgroundColor: function(color) {\n+ if (color != undefined) {\n+ this.backgroundColor = color;\n }\n- for (var i = 0, len = components.length; i < len; i++) {\n- this.addComponent(components[i]);\n+\n+ if (this.div != null) {\n+ this.div.style.backgroundColor = this.backgroundColor;\n }\n },\n \n /**\n- * Method: addComponent\n- * Add a new component (geometry) to the collection. If this.componentTypes\n- * is set, then the component class name must be in the componentTypes array.\n- *\n- * The bounds cache is reset.\n+ * Method: setOpacity\n+ * Sets the opacity of the popup.\n * \n * Parameters:\n- * component - {} A geometry to add\n- * index - {int} Optional index into the array to insert the component\n- *\n- * Returns:\n- * {Boolean} The component geometry was successfully added\n+ * opacity - {float} A value between 0.0 (transparent) and 1.0 (solid). \n */\n- addComponent: function(component, index) {\n- var added = false;\n- if (component) {\n- if (this.componentTypes == null ||\n- (OpenLayers.Util.indexOf(this.componentTypes,\n- component.CLASS_NAME) > -1)) {\n+ setOpacity: function(opacity) {\n+ if (opacity != undefined) {\n+ this.opacity = opacity;\n+ }\n \n- if (index != null && (index < this.components.length)) {\n- var components1 = this.components.slice(0, index);\n- var components2 = this.components.slice(index,\n- this.components.length);\n- components1.push(component);\n- this.components = components1.concat(components2);\n- } else {\n- this.components.push(component);\n- }\n- component.parent = this;\n- this.clearBounds();\n- added = true;\n- }\n+ if (this.div != null) {\n+ // for Mozilla and Safari\n+ this.div.style.opacity = this.opacity;\n+\n+ // for IE\n+ this.div.style.filter = 'alpha(opacity=' + this.opacity * 100 + ')';\n }\n- return added;\n },\n \n /**\n- * APIMethod: removeComponents\n- * Remove components from this geometry.\n+ * Method: setBorder\n+ * Sets the border style of the popup.\n *\n * Parameters:\n- * components - {Array()} The components to be removed\n- *\n- * Returns: \n- * {Boolean} A component was removed.\n+ * border - {String} The border style value. eg 2px \n */\n- removeComponents: function(components) {\n- var removed = false;\n-\n- if (!(OpenLayers.Util.isArray(components))) {\n- components = [components];\n+ setBorder: function(border) {\n+ if (border != undefined) {\n+ this.border = border;\n }\n- for (var i = components.length - 1; i >= 0; --i) {\n- removed = this.removeComponent(components[i]) || removed;\n+\n+ if (this.div != null) {\n+ this.div.style.border = this.border;\n }\n- return removed;\n },\n \n /**\n- * Method: removeComponent\n- * Remove a component from this geometry.\n+ * Method: setContentHTML\n+ * Allows the user to set the HTML content of the popup.\n *\n * Parameters:\n- * component - {} \n- *\n- * Returns: \n- * {Boolean} The component was removed.\n+ * contentHTML - {String} HTML for the div.\n */\n- removeComponent: function(component) {\n+ setContentHTML: function(contentHTML) {\n \n- OpenLayers.Util.removeItem(this.components, component);\n+ if (contentHTML != null) {\n+ this.contentHTML = contentHTML;\n+ }\n \n- // clearBounds() so that it gets recalculated on the next call\n- // to this.getBounds();\n- this.clearBounds();\n- return true;\n- },\n+ if ((this.contentDiv != null) &&\n+ (this.contentHTML != null) &&\n+ (this.contentHTML != this.contentDiv.innerHTML)) {\n \n- /**\n- * APIMethod: getLength\n- * Calculate the length of this geometry\n- *\n- * Returns:\n- * {Float} The length of the geometry\n- */\n- getLength: function() {\n- var length = 0.0;\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- length += this.components[i].getLength();\n+ this.contentDiv.innerHTML = this.contentHTML;\n+\n+ if (this.autoSize) {\n+\n+ //if popup has images, listen for when they finish\n+ // loading and resize accordingly\n+ this.registerImageListeners();\n+\n+ //auto size the popup to its current contents\n+ this.updateSize();\n+ }\n }\n- return length;\n+\n },\n \n /**\n- * APIMethod: getArea\n- * Calculate the area of this geometry. Note how this function is overridden\n- * in .\n- *\n- * Returns:\n- * {Float} The area of the collection by summing its parts\n+ * Method: registerImageListeners\n+ * Called when an image contained by the popup loaded. this function\n+ * updates the popup size, then unregisters the image load listener.\n */\n- getArea: function() {\n- var area = 0.0;\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- area += this.components[i].getArea();\n- }\n- return area;\n- },\n+ registerImageListeners: function() {\n \n- /** \n- * APIMethod: getGeodesicArea\n- * Calculate the approximate area of the polygon were it projected onto\n- * the earth.\n- *\n- * Parameters:\n- * projection - {} The spatial reference system\n- * for the geometry coordinates. If not provided, Geographic/WGS84 is\n- * assumed.\n- * \n- * Reference:\n- * Robert. G. Chamberlain and William H. Duquette, \"Some Algorithms for\n- * Polygons on a Sphere\", JPL Publication 07-03, Jet Propulsion\n- * Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409\n- *\n- * Returns:\n- * {float} The approximate geodesic area of the geometry in square meters.\n- */\n- getGeodesicArea: function(projection) {\n- var area = 0.0;\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- area += this.components[i].getGeodesicArea(projection);\n+ // As the images load, this function will call updateSize() to \n+ // resize the popup to fit the content div (which presumably is now\n+ // bigger than when the image was not loaded).\n+ // \n+ // If the 'panMapIfOutOfView' property is set, we will pan the newly\n+ // resized popup back into view.\n+ // \n+ // Note that this function, when called, will have 'popup' and \n+ // 'img' properties in the context.\n+ //\n+ var onImgLoad = function() {\n+ if (this.popup.id === null) { // this.popup has been destroyed!\n+ return;\n+ }\n+ this.popup.updateSize();\n+\n+ if (this.popup.visible() && this.popup.panMapIfOutOfView) {\n+ this.popup.panIntoView();\n+ }\n+\n+ OpenLayers.Event.stopObserving(\n+ this.img, \"load\", this.img._onImgLoad\n+ );\n+\n+ };\n+\n+ //cycle through the images and if their size is 0x0, that means that \n+ // they haven't been loaded yet, so we attach the listener, which \n+ // will fire when the images finish loading and will resize the \n+ // popup accordingly to its new size.\n+ var images = this.contentDiv.getElementsByTagName(\"img\");\n+ for (var i = 0, len = images.length; i < len; i++) {\n+ var img = images[i];\n+ if (img.width == 0 || img.height == 0) {\n+\n+ var context = {\n+ 'popup': this,\n+ 'img': img\n+ };\n+\n+ //expando this function to the image itself before registering\n+ // it. This way we can easily and properly unregister it.\n+ img._onImgLoad = OpenLayers.Function.bind(onImgLoad, context);\n+\n+ OpenLayers.Event.observe(img, 'load', img._onImgLoad);\n+ }\n }\n- return area;\n },\n \n /**\n- * APIMethod: getCentroid\n- *\n- * Compute the centroid for this geometry collection.\n- *\n+ * APIMethod: getSafeContentSize\n+ * \n * Parameters:\n- * weighted - {Boolean} Perform the getCentroid computation recursively,\n- * returning an area weighted average of all geometries in this collection.\n- *\n+ * size - {} Desired size to make the popup.\n+ * \n * Returns:\n- * {} The centroid of the collection\n+ * {} A size to make the popup which is neither smaller\n+ * than the specified minimum size, nor bigger than the maximum \n+ * size (which is calculated relative to the size of the viewport).\n */\n- getCentroid: function(weighted) {\n- if (!weighted) {\n- return this.components.length && this.components[0].getCentroid();\n+ getSafeContentSize: function(size) {\n+\n+ var safeContentSize = size.clone();\n+\n+ // if our contentDiv has a css 'padding' set on it by a stylesheet, we \n+ // must add that to the desired \"size\". \n+ var contentDivPadding = this.getContentDivPadding();\n+ var wPadding = contentDivPadding.left + contentDivPadding.right;\n+ var hPadding = contentDivPadding.top + contentDivPadding.bottom;\n+\n+ // take into account the popup's 'padding' property\n+ this.fixPadding();\n+ wPadding += this.padding.left + this.padding.right;\n+ hPadding += this.padding.top + this.padding.bottom;\n+\n+ if (this.closeDiv) {\n+ var closeDivWidth = parseInt(this.closeDiv.style.width);\n+ wPadding += closeDivWidth + contentDivPadding.right;\n }\n- var len = this.components.length;\n- if (!len) {\n- return false;\n+\n+ // prevent the popup from being smaller than a specified minimal size\n+ if (this.minSize) {\n+ safeContentSize.w = Math.max(safeContentSize.w,\n+ (this.minSize.w - wPadding));\n+ safeContentSize.h = Math.max(safeContentSize.h,\n+ (this.minSize.h - hPadding));\n }\n \n- var areas = [];\n- var centroids = [];\n- var areaSum = 0;\n- var minArea = Number.MAX_VALUE;\n- var component;\n- for (var i = 0; i < len; ++i) {\n- component = this.components[i];\n- var area = component.getArea();\n- var centroid = component.getCentroid(true);\n- if (isNaN(area) || isNaN(centroid.x) || isNaN(centroid.y)) {\n- continue;\n- }\n- areas.push(area);\n- areaSum += area;\n- minArea = (area < minArea && area > 0) ? area : minArea;\n- centroids.push(centroid);\n+ // prevent the popup from being bigger than a specified maximum size\n+ if (this.maxSize) {\n+ safeContentSize.w = Math.min(safeContentSize.w,\n+ (this.maxSize.w - wPadding));\n+ safeContentSize.h = Math.min(safeContentSize.h,\n+ (this.maxSize.h - hPadding));\n }\n- len = areas.length;\n- if (areaSum === 0) {\n- // all the components in this collection have 0 area\n- // probably a collection of points -- weight all the points the same\n- for (var i = 0; i < len; ++i) {\n- areas[i] = 1;\n- }\n- areaSum = areas.length;\n- } else {\n- // normalize all the areas where the smallest area will get\n- // a value of 1\n- for (var i = 0; i < len; ++i) {\n- areas[i] /= minArea;\n+\n+ //make sure the desired size to set doesn't result in a popup that \n+ // is bigger than the map's viewport.\n+ //\n+ if (this.map && this.map.size) {\n+\n+ var extraX = 0,\n+ extraY = 0;\n+ if (this.keepInMap && !this.panMapIfOutOfView) {\n+ var px = this.map.getPixelFromLonLat(this.lonlat);\n+ switch (this.relativePosition) {\n+ case \"tr\":\n+ extraX = px.x;\n+ extraY = this.map.size.h - px.y;\n+ break;\n+ case \"tl\":\n+ extraX = this.map.size.w - px.x;\n+ extraY = this.map.size.h - px.y;\n+ break;\n+ case \"bl\":\n+ extraX = this.map.size.w - px.x;\n+ extraY = px.y;\n+ break;\n+ case \"br\":\n+ extraX = px.x;\n+ extraY = px.y;\n+ break;\n+ default:\n+ extraX = px.x;\n+ extraY = this.map.size.h - px.y;\n+ break;\n+ }\n }\n- areaSum /= minArea;\n- }\n \n- var xSum = 0,\n- ySum = 0,\n- centroid, area;\n- for (var i = 0; i < len; ++i) {\n- centroid = centroids[i];\n- area = areas[i];\n- xSum += centroid.x * area;\n- ySum += centroid.y * area;\n+ var maxY = this.map.size.h -\n+ this.map.paddingForPopups.top -\n+ this.map.paddingForPopups.bottom -\n+ hPadding - extraY;\n+\n+ var maxX = this.map.size.w -\n+ this.map.paddingForPopups.left -\n+ this.map.paddingForPopups.right -\n+ wPadding - extraX;\n+\n+ safeContentSize.w = Math.min(safeContentSize.w, maxX);\n+ safeContentSize.h = Math.min(safeContentSize.h, maxY);\n }\n \n- return new OpenLayers.Geometry.Point(xSum / areaSum, ySum / areaSum);\n+ return safeContentSize;\n },\n \n /**\n- * APIMethod: getGeodesicLength\n- * Calculate the approximate length of the geometry were it projected onto\n- * the earth.\n+ * Method: getContentDivPadding\n+ * Glorious, oh glorious hack in order to determine the css 'padding' of \n+ * the contentDiv. IE/Opera return null here unless we actually add the \n+ * popup's main 'div' element (which contains contentDiv) to the DOM. \n+ * So we make it invisible and then add it to the document temporarily. \n+ *\n+ * Once we've taken the padding readings we need, we then remove it \n+ * from the DOM (it will actually get added to the DOM in \n+ * Map.js's addPopup)\n *\n- * projection - {} The spatial reference system\n- * for the geometry coordinates. If not provided, Geographic/WGS84 is\n- * assumed.\n- * \n * Returns:\n- * {Float} The appoximate geodesic length of the geometry in meters.\n+ * {}\n */\n- getGeodesicLength: function(projection) {\n- var length = 0.0;\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- length += this.components[i].getGeodesicLength(projection);\n+ getContentDivPadding: function() {\n+\n+ //use cached value if we have it\n+ var contentDivPadding = this._contentDivPadding;\n+ if (!contentDivPadding) {\n+\n+ if (this.div.parentNode == null) {\n+ //make the div invisible and add it to the page \n+ this.div.style.display = \"none\";\n+ document.body.appendChild(this.div);\n+ }\n+\n+ //read the padding settings from css, put them in an OL.Bounds \n+ contentDivPadding = new OpenLayers.Bounds(\n+ OpenLayers.Element.getStyle(this.contentDiv, \"padding-left\"),\n+ OpenLayers.Element.getStyle(this.contentDiv, \"padding-bottom\"),\n+ OpenLayers.Element.getStyle(this.contentDiv, \"padding-right\"),\n+ OpenLayers.Element.getStyle(this.contentDiv, \"padding-top\")\n+ );\n+\n+ //cache the value\n+ this._contentDivPadding = contentDivPadding;\n+\n+ if (this.div.parentNode == document.body) {\n+ //remove the div from the page and make it visible again\n+ document.body.removeChild(this.div);\n+ this.div.style.display = \"\";\n+ }\n }\n- return length;\n+ return contentDivPadding;\n },\n \n /**\n- * APIMethod: move\n- * Moves a geometry by the given displacement along positive x and y axes.\n- * This modifies the position of the geometry and clears the cached\n- * bounds.\n- *\n+ * Method: addCloseBox\n+ * \n * Parameters:\n- * x - {Float} Distance to move geometry in positive x direction. \n- * y - {Float} Distance to move geometry in positive y direction.\n+ * callback - {Function} The callback to be called when the close button\n+ * is clicked.\n */\n- move: function(x, y) {\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- this.components[i].move(x, y);\n- }\n+ addCloseBox: function(callback) {\n+\n+ this.closeDiv = OpenLayers.Util.createDiv(\n+ this.id + \"_close\", null, {\n+ w: 17,\n+ h: 17\n+ }\n+ );\n+ this.closeDiv.className = \"olPopupCloseBox\";\n+\n+ // use the content div's css padding to determine if we should\n+ // padd the close div\n+ var contentDivPadding = this.getContentDivPadding();\n+\n+ this.closeDiv.style.right = contentDivPadding.right + \"px\";\n+ this.closeDiv.style.top = contentDivPadding.top + \"px\";\n+ this.groupDiv.appendChild(this.closeDiv);\n+\n+ var closePopup = callback || function(e) {\n+ this.hide();\n+ OpenLayers.Event.stop(e);\n+ };\n+ OpenLayers.Event.observe(this.closeDiv, \"touchend\",\n+ OpenLayers.Function.bindAsEventListener(closePopup, this));\n+ OpenLayers.Event.observe(this.closeDiv, \"click\",\n+ OpenLayers.Function.bindAsEventListener(closePopup, this));\n },\n \n /**\n- * APIMethod: rotate\n- * Rotate a geometry around some origin\n- *\n- * Parameters:\n- * angle - {Float} Rotation angle in degrees (measured counterclockwise\n- * from the positive x-axis)\n- * origin - {} Center point for the rotation\n+ * Method: panIntoView\n+ * Pans the map such that the popup is totaly viewable (if necessary)\n */\n- rotate: function(angle, origin) {\n- for (var i = 0, len = this.components.length; i < len; ++i) {\n- this.components[i].rotate(angle, origin);\n+ panIntoView: function() {\n+\n+ var mapSize = this.map.getSize();\n+\n+ //start with the top left corner of the popup, in px, \n+ // relative to the viewport\n+ var origTL = this.map.getViewPortPxFromLayerPx(new OpenLayers.Pixel(\n+ parseInt(this.div.style.left),\n+ parseInt(this.div.style.top)\n+ ));\n+ var newTL = origTL.clone();\n+\n+ //new left (compare to margins, using this.size to calculate right)\n+ if (origTL.x < this.map.paddingForPopups.left) {\n+ newTL.x = this.map.paddingForPopups.left;\n+ } else\n+ if ((origTL.x + this.size.w) > (mapSize.w - this.map.paddingForPopups.right)) {\n+ newTL.x = mapSize.w - this.map.paddingForPopups.right - this.size.w;\n+ }\n+\n+ //new top (compare to margins, using this.size to calculate bottom)\n+ if (origTL.y < this.map.paddingForPopups.top) {\n+ newTL.y = this.map.paddingForPopups.top;\n+ } else\n+ if ((origTL.y + this.size.h) > (mapSize.h - this.map.paddingForPopups.bottom)) {\n+ newTL.y = mapSize.h - this.map.paddingForPopups.bottom - this.size.h;\n }\n+\n+ var dx = origTL.x - newTL.x;\n+ var dy = origTL.y - newTL.y;\n+\n+ this.map.pan(dx, dy);\n },\n \n- /**\n- * APIMethod: resize\n- * Resize a geometry relative to some origin. Use this method to apply\n- * a uniform scaling to a geometry.\n+ /** \n+ * Method: registerEvents\n+ * Registers events on the popup.\n *\n- * Parameters:\n- * scale - {Float} Factor by which to scale the geometry. A scale of 2\n- * doubles the size of the geometry in each dimension\n- * (lines, for example, will be twice as long, and polygons\n- * will have four times the area).\n- * origin - {} Point of origin for resizing\n- * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.\n+ * Do this in a separate function so that subclasses can \n+ * choose to override it if they wish to deal differently\n+ * with mouse events\n * \n- * Returns:\n- * {} - The current geometry. \n+ * Note in the following handler functions that some special\n+ * care is needed to deal correctly with mousing and popups. \n+ * \n+ * Because the user might select the zoom-rectangle option and\n+ * then drag it over a popup, we need a safe way to allow the\n+ * mousemove and mouseup events to pass through the popup when\n+ * they are initiated from outside. The same procedure is needed for\n+ * touchmove and touchend events.\n+ * \n+ * Otherwise, we want to essentially kill the event propagation\n+ * for all other events, though we have to do so carefully, \n+ * without disabling basic html functionality, like clicking on \n+ * hyperlinks or drag-selecting text.\n */\n- resize: function(scale, origin, ratio) {\n- for (var i = 0; i < this.components.length; ++i) {\n- this.components[i].resize(scale, origin, ratio);\n+ registerEvents: function() {\n+ this.events = new OpenLayers.Events(this, this.div, null, true);\n+\n+ function onTouchstart(evt) {\n+ OpenLayers.Event.stop(evt, true);\n }\n- return this;\n+ this.events.on({\n+ \"mousedown\": this.onmousedown,\n+ \"mousemove\": this.onmousemove,\n+ \"mouseup\": this.onmouseup,\n+ \"click\": this.onclick,\n+ \"mouseout\": this.onmouseout,\n+ \"dblclick\": this.ondblclick,\n+ \"touchstart\": onTouchstart,\n+ scope: this\n+ });\n+\n },\n \n- /**\n- * APIMethod: distanceTo\n- * Calculate the closest distance between two geometries (on the x-y plane).\n- *\n+ /** \n+ * Method: onmousedown \n+ * When mouse goes down within the popup, make a note of\n+ * it locally, and then do not propagate the mousedown \n+ * (but do so safely so that user can select text inside)\n+ * \n * Parameters:\n- * geometry - {} The target geometry.\n- * options - {Object} Optional properties for configuring the distance\n- * calculation.\n- *\n- * Valid options:\n- * details - {Boolean} Return details from the distance calculation.\n- * Default is false.\n- * edge - {Boolean} Calculate the distance from this geometry to the\n- * nearest edge of the target geometry. Default is true. If true,\n- * calling distanceTo from a geometry that is wholly contained within\n- * the target will result in a non-zero distance. If false, whenever\n- * geometries intersect, calling distanceTo will return 0. If false,\n- * details cannot be returned.\n- *\n- * Returns:\n- * {Number | Object} The distance between this geometry and the target.\n- * If details is true, the return will be an object with distance,\n- * x0, y0, x1, and y1 properties. The x0 and y0 properties represent\n- * the coordinates of the closest point on this geometry. The x1 and y1\n- * properties represent the coordinates of the closest point on the\n- * target geometry.\n+ * evt - {Event} \n */\n- distanceTo: function(geometry, options) {\n- var edge = !(options && options.edge === false);\n- var details = edge && options && options.details;\n- var result, best, distance;\n- var min = Number.POSITIVE_INFINITY;\n- for (var i = 0, len = this.components.length; i < len; ++i) {\n- result = this.components[i].distanceTo(geometry, options);\n- distance = details ? result.distance : result;\n- if (distance < min) {\n- min = distance;\n- best = result;\n- if (min == 0) {\n- break;\n- }\n- }\n- }\n- return best;\n+ onmousedown: function(evt) {\n+ this.mousedown = true;\n+ OpenLayers.Event.stop(evt, true);\n },\n \n /** \n- * APIMethod: equals\n- * Determine whether another geometry is equivalent to this one. Geometries\n- * are considered equivalent if all components have the same coordinates.\n+ * Method: onmousemove\n+ * If the drag was started within the popup, then \n+ * do not propagate the mousemove (but do so safely\n+ * so that user can select text inside)\n * \n * Parameters:\n- * geometry - {} The geometry to test. \n- *\n- * Returns:\n- * {Boolean} The supplied geometry is equivalent to this geometry.\n+ * evt - {Event} \n */\n- equals: function(geometry) {\n- var equivalent = true;\n- if (!geometry || !geometry.CLASS_NAME ||\n- (this.CLASS_NAME != geometry.CLASS_NAME)) {\n- equivalent = false;\n- } else if (!(OpenLayers.Util.isArray(geometry.components)) ||\n- (geometry.components.length != this.components.length)) {\n- equivalent = false;\n- } else {\n- for (var i = 0, len = this.components.length; i < len; ++i) {\n- if (!this.components[i].equals(geometry.components[i])) {\n- equivalent = false;\n- break;\n- }\n- }\n+ onmousemove: function(evt) {\n+ if (this.mousedown) {\n+ OpenLayers.Event.stop(evt, true);\n }\n- return equivalent;\n },\n \n- /**\n- * APIMethod: transform\n- * Reproject the components geometry from source to dest.\n+ /** \n+ * Method: onmouseup\n+ * When mouse comes up within the popup, after going down \n+ * in it, reset the flag, and then (once again) do not \n+ * propagate the event, but do so safely so that user can \n+ * select text inside\n * \n * Parameters:\n- * source - {} \n- * dest - {}\n- * \n- * Returns:\n- * {} \n+ * evt - {Event} \n */\n- transform: function(source, dest) {\n- if (source && dest) {\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- var component = this.components[i];\n- component.transform(source, dest);\n- }\n- this.bounds = null;\n+ onmouseup: function(evt) {\n+ if (this.mousedown) {\n+ this.mousedown = false;\n+ OpenLayers.Event.stop(evt, true);\n }\n- return this;\n },\n \n /**\n- * APIMethod: intersects\n- * Determine if the input geometry intersects this one.\n- *\n+ * Method: onclick\n+ * Ignore clicks, but allowing default browser handling\n+ * \n * Parameters:\n- * geometry - {} Any type of geometry.\n- *\n- * Returns:\n- * {Boolean} The input geometry intersects this one.\n+ * evt - {Event} \n */\n- intersects: function(geometry) {\n- var intersect = false;\n- for (var i = 0, len = this.components.length; i < len; ++i) {\n- intersect = geometry.intersects(this.components[i]);\n- if (intersect) {\n- break;\n- }\n- }\n- return intersect;\n+ onclick: function(evt) {\n+ OpenLayers.Event.stop(evt, true);\n },\n \n- /**\n- * APIMethod: getVertices\n- * Return a list of all points in this geometry.\n- *\n+ /** \n+ * Method: onmouseout\n+ * When mouse goes out of the popup set the flag to false so that\n+ * if they let go and then drag back in, we won't be confused.\n+ * \n * Parameters:\n- * nodes - {Boolean} For lines, only return vertices that are\n- * endpoints. If false, for lines, only vertices that are not\n- * endpoints will be returned. If not provided, all vertices will\n- * be returned.\n- *\n- * Returns:\n- * {Array} A list of all vertices in the geometry.\n+ * evt - {Event} \n */\n- getVertices: function(nodes) {\n- var vertices = [];\n- for (var i = 0, len = this.components.length; i < len; ++i) {\n- Array.prototype.push.apply(\n- vertices, this.components[i].getVertices(nodes)\n- );\n- }\n- return vertices;\n+ onmouseout: function(evt) {\n+ this.mousedown = false;\n },\n \n+ /** \n+ * Method: ondblclick\n+ * Ignore double-clicks, but allowing default browser handling\n+ * \n+ * Parameters:\n+ * evt - {Event} \n+ */\n+ ondblclick: function(evt) {\n+ OpenLayers.Event.stop(evt, true);\n+ },\n \n- CLASS_NAME: \"OpenLayers.Geometry.Collection\"\n+ CLASS_NAME: \"OpenLayers.Popup\"\n });\n+\n+OpenLayers.Popup.WIDTH = 200;\n+OpenLayers.Popup.HEIGHT = 200;\n+OpenLayers.Popup.COLOR = \"white\";\n+OpenLayers.Popup.OPACITY = 1;\n+OpenLayers.Popup.BORDER = \"0px\";\n /* ======================================================================\n- OpenLayers/Geometry/MultiPoint.js\n+ OpenLayers/Feature.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Geometry/Collection.js\n- * @requires OpenLayers/Geometry/Point.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Util.js\n */\n \n /**\n- * Class: OpenLayers.Geometry.MultiPoint\n- * MultiPoint is a collection of Points. Create a new instance with the\n- * constructor.\n- *\n- * Inherits from:\n- * - \n- * - \n+ * Class: OpenLayers.Feature\n+ * Features are combinations of geography and attributes. The OpenLayers.Feature\n+ * class specifically combines a marker and a lonlat.\n */\n-OpenLayers.Geometry.MultiPoint = OpenLayers.Class(\n- OpenLayers.Geometry.Collection, {\n+OpenLayers.Feature = OpenLayers.Class({\n \n- /**\n- * Property: componentTypes\n- * {Array(String)} An array of class names representing the types of\n- * components that the collection can include. A null value means the\n- * component types are not restricted.\n- */\n- componentTypes: [\"OpenLayers.Geometry.Point\"],\n+ /** \n+ * Property: layer \n+ * {} \n+ */\n+ layer: null,\n \n- /**\n- * Constructor: OpenLayers.Geometry.MultiPoint\n- * Create a new MultiPoint Geometry\n- *\n- * Parameters:\n- * components - {Array()} \n- *\n- * Returns:\n- * {}\n- */\n+ /** \n+ * Property: id \n+ * {String} \n+ */\n+ id: null,\n \n- /**\n- * APIMethod: addPoint\n- * Wrapper for \n- *\n- * Parameters:\n- * point - {} Point to be added\n- * index - {Integer} Optional index\n- */\n- addPoint: function(point, index) {\n- this.addComponent(point, index);\n- },\n+ /** \n+ * Property: lonlat \n+ * {} \n+ */\n+ lonlat: null,\n \n- /**\n- * APIMethod: removePoint\n- * Wrapper for \n- *\n- * Parameters:\n- * point - {} Point to be removed\n- */\n- removePoint: function(point) {\n- this.removeComponent(point);\n- },\n+ /** \n+ * Property: data \n+ * {Object} \n+ */\n+ data: null,\n \n- CLASS_NAME: \"OpenLayers.Geometry.MultiPoint\"\n- });\n-/* ======================================================================\n- OpenLayers/Geometry/Curve.js\n- ====================================================================== */\n+ /** \n+ * Property: marker \n+ * {} \n+ */\n+ marker: null,\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ /**\n+ * APIProperty: popupClass\n+ * {} The class which will be used to instantiate\n+ * a new Popup. Default is .\n+ */\n+ popupClass: null,\n \n-/**\n- * @requires OpenLayers/Geometry/MultiPoint.js\n- */\n+ /** \n+ * Property: popup \n+ * {} \n+ */\n+ popup: null,\n \n-/**\n- * Class: OpenLayers.Geometry.Curve\n- * A Curve is a MultiPoint, whose points are assumed to be connected. To \n- * this end, we provide a \"getLength()\" function, which iterates through \n- * the points, summing the distances between them. \n- * \n- * Inherits: \n- * - \n- */\n-OpenLayers.Geometry.Curve = OpenLayers.Class(OpenLayers.Geometry.MultiPoint, {\n+ /** \n+ * Constructor: OpenLayers.Feature\n+ * Constructor for features.\n+ *\n+ * Parameters:\n+ * layer - {} \n+ * lonlat - {} \n+ * data - {Object} \n+ * \n+ * Returns:\n+ * {}\n+ */\n+ initialize: function(layer, lonlat, data) {\n+ this.layer = layer;\n+ this.lonlat = lonlat;\n+ this.data = (data != null) ? data : {};\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+ },\n \n- /**\n- * Property: componentTypes\n- * {Array(String)} An array of class names representing the types of \n- * components that the collection can include. A null \n- * value means the component types are not restricted.\n+ /** \n+ * Method: destroy\n+ * nullify references to prevent circular references and memory leaks\n */\n- componentTypes: [\"OpenLayers.Geometry.Point\"],\n+ destroy: function() {\n+\n+ //remove the popup from the map\n+ if ((this.layer != null) && (this.layer.map != null)) {\n+ if (this.popup != null) {\n+ this.layer.map.removePopup(this.popup);\n+ }\n+ }\n+ // remove the marker from the layer\n+ if (this.layer != null && this.marker != null) {\n+ this.layer.removeMarker(this.marker);\n+ }\n+\n+ this.layer = null;\n+ this.id = null;\n+ this.lonlat = null;\n+ this.data = null;\n+ if (this.marker != null) {\n+ this.destroyMarker(this.marker);\n+ this.marker = null;\n+ }\n+ if (this.popup != null) {\n+ this.destroyPopup(this.popup);\n+ this.popup = null;\n+ }\n+ },\n \n /**\n- * Constructor: OpenLayers.Geometry.Curve\n+ * Method: onScreen\n * \n- * Parameters:\n- * point - {Array()}\n+ * Returns:\n+ * {Boolean} Whether or not the feature is currently visible on screen\n+ * (based on its 'lonlat' property)\n */\n+ onScreen: function() {\n+\n+ var onScreen = false;\n+ if ((this.layer != null) && (this.layer.map != null)) {\n+ var screenBounds = this.layer.map.getExtent();\n+ onScreen = screenBounds.containsLonLat(this.lonlat);\n+ }\n+ return onScreen;\n+ },\n+\n \n /**\n- * APIMethod: getLength\n+ * Method: createMarker\n+ * Based on the data associated with the Feature, create and return a marker object.\n+ *\n+ * Returns: \n+ * {} A Marker Object created from the 'lonlat' and 'icon' properties\n+ * set in this.data. If no 'lonlat' is set, returns null. If no\n+ * 'icon' is set, OpenLayers.Marker() will load the default image.\n+ * \n+ * Note - this.marker is set to return value\n * \n- * Returns:\n- * {Float} The length of the curve\n */\n- getLength: function() {\n- var length = 0.0;\n- if (this.components && (this.components.length > 1)) {\n- for (var i = 1, len = this.components.length; i < len; i++) {\n- length += this.components[i - 1].distanceTo(this.components[i]);\n- }\n+ createMarker: function() {\n+\n+ if (this.lonlat != null) {\n+ this.marker = new OpenLayers.Marker(this.lonlat, this.data.icon);\n }\n- return length;\n+ return this.marker;\n },\n \n /**\n- * APIMethod: getGeodesicLength\n- * Calculate the approximate length of the geometry were it projected onto\n- * the earth.\n+ * Method: destroyMarker\n+ * Destroys marker.\n+ * If user overrides the createMarker() function, s/he should be able\n+ * to also specify an alternative function for destroying it\n+ */\n+ destroyMarker: function() {\n+ this.marker.destroy();\n+ },\n+\n+ /**\n+ * Method: createPopup\n+ * Creates a popup object created from the 'lonlat', 'popupSize',\n+ * and 'popupContentHTML' properties set in this.data. It uses\n+ * this.marker.icon as default anchor. \n+ * \n+ * If no 'lonlat' is set, returns null. \n+ * If no this.marker has been created, no anchor is sent.\n *\n- * projection - {} The spatial reference system\n- * for the geometry coordinates. If not provided, Geographic/WGS84 is\n- * assumed.\n+ * Note - the returned popup object is 'owned' by the feature, so you\n+ * cannot use the popup's destroy method to discard the popup.\n+ * Instead, you must use the feature's destroyPopup\n+ * \n+ * Note - this.popup is set to return value\n+ * \n+ * Parameters: \n+ * closeBox - {Boolean} create popup with closebox or not\n * \n * Returns:\n- * {Float} The appoximate geodesic length of the geometry in meters.\n+ * {} Returns the created popup, which is also set\n+ * as 'popup' property of this feature. Will be of whatever type\n+ * specified by this feature's 'popupClass' property, but must be\n+ * of type .\n+ * \n */\n- getGeodesicLength: function(projection) {\n- var geom = this; // so we can work with a clone if needed\n- if (projection) {\n- var gg = new OpenLayers.Projection(\"EPSG:4326\");\n- if (!gg.equals(projection)) {\n- geom = this.clone().transform(projection, gg);\n+ createPopup: function(closeBox) {\n+\n+ if (this.lonlat != null) {\n+ if (!this.popup) {\n+ var anchor = (this.marker) ? this.marker.icon : null;\n+ var popupClass = this.popupClass ?\n+ this.popupClass : OpenLayers.Popup.Anchored;\n+ this.popup = new popupClass(this.id + \"_popup\",\n+ this.lonlat,\n+ this.data.popupSize,\n+ this.data.popupContentHTML,\n+ anchor,\n+ closeBox);\n }\n- }\n- var length = 0.0;\n- if (geom.components && (geom.components.length > 1)) {\n- var p1, p2;\n- for (var i = 1, len = geom.components.length; i < len; i++) {\n- p1 = geom.components[i - 1];\n- p2 = geom.components[i];\n- // this returns km and requires lon/lat properties\n- length += OpenLayers.Util.distVincenty({\n- lon: p1.x,\n- lat: p1.y\n- }, {\n- lon: p2.x,\n- lat: p2.y\n- });\n+ if (this.data.overflow != null) {\n+ this.popup.contentDiv.style.overflow = this.data.overflow;\n }\n+\n+ this.popup.feature = this;\n }\n- // convert to m\n- return length * 1000;\n+ return this.popup;\n },\n \n- CLASS_NAME: \"OpenLayers.Geometry.Curve\"\n+\n+ /**\n+ * Method: destroyPopup\n+ * Destroys the popup created via createPopup.\n+ *\n+ * As with the marker, if user overrides the createPopup() function, s/he \n+ * should also be able to override the destruction\n+ */\n+ destroyPopup: function() {\n+ if (this.popup) {\n+ this.popup.feature = null;\n+ this.popup.destroy();\n+ this.popup = null;\n+ }\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Feature\"\n });\n /* ======================================================================\n- OpenLayers/Geometry/LineString.js\n+ OpenLayers/Feature/Vector.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+// TRASH THIS\n+OpenLayers.State = {\n+ /** states */\n+ UNKNOWN: 'Unknown',\n+ INSERT: 'Insert',\n+ UPDATE: 'Update',\n+ DELETE: 'Delete'\n+};\n+\n /**\n- * @requires OpenLayers/Geometry/Curve.js\n+ * @requires OpenLayers/Feature.js\n+ * @requires OpenLayers/Util.js\n */\n \n /**\n- * Class: OpenLayers.Geometry.LineString\n- * A LineString is a Curve which, once two points have been added to it, can \n- * never be less than two points long.\n+ * Class: OpenLayers.Feature.Vector\n+ * Vector features use the OpenLayers.Geometry classes as geometry description.\n+ * They have an 'attributes' property, which is the data object, and a 'style'\n+ * property, the default values of which are defined in the \n+ * objects.\n * \n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Geometry.LineString = OpenLayers.Class(OpenLayers.Geometry.Curve, {\n+OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {\n+\n+ /** \n+ * Property: fid \n+ * {String} \n+ */\n+ fid: null,\n+\n+ /** \n+ * APIProperty: geometry \n+ * {} \n+ */\n+ geometry: null,\n+\n+ /** \n+ * APIProperty: attributes \n+ * {Object} This object holds arbitrary, serializable properties that\n+ * describe the feature.\n+ */\n+ attributes: null,\n \n /**\n- * Constructor: OpenLayers.Geometry.LineString\n- * Create a new LineString geometry\n- *\n- * Parameters:\n- * points - {Array()} An array of points used to\n- * generate the linestring\n- *\n+ * Property: bounds\n+ * {} The box bounding that feature's geometry, that\n+ * property can be set by an object when\n+ * deserializing the feature, so in most cases it represents an\n+ * information set by the server. \n+ */\n+ bounds: null,\n+\n+ /** \n+ * Property: state \n+ * {String} \n+ */\n+ state: null,\n+\n+ /** \n+ * APIProperty: style \n+ * {Object} \n */\n+ style: null,\n \n /**\n- * APIMethod: removeComponent\n- * Only allows removal of a point if there are three or more points in \n- * the linestring. (otherwise the result would be just a single point)\n+ * APIProperty: url\n+ * {String} If this property is set it will be taken into account by\n+ * {} when upadting or deleting the feature.\n+ */\n+ url: null,\n+\n+ /**\n+ * Property: renderIntent\n+ * {String} rendering intent currently being used\n+ */\n+ renderIntent: \"default\",\n+\n+ /**\n+ * APIProperty: modified\n+ * {Object} An object with the originals of the geometry and attributes of\n+ * the feature, if they were changed. Currently this property is only read\n+ * by , and written by\n+ * , which sets the geometry property.\n+ * Applications can set the originals of modified attributes in the\n+ * attributes property. Note that applications have to check if this\n+ * object and the attributes property is already created before using it.\n+ * After a change made with ModifyFeature, this object could look like\n *\n- * Parameters: \n- * point - {} The point to be removed\n+ * (code)\n+ * {\n+ * geometry: >Object\n+ * }\n+ * (end)\n *\n- * Returns: \n- * {Boolean} The component was removed.\n+ * When an application has made changes to feature attributes, it could\n+ * have set the attributes to something like this:\n+ *\n+ * (code)\n+ * {\n+ * attributes: {\n+ * myAttribute: \"original\"\n+ * }\n+ * }\n+ * (end)\n+ *\n+ * Note that only checks for truthy values in\n+ * *modified.geometry* and the attribute names in *modified.attributes*,\n+ * but it is recommended to set the original values (and not just true) as\n+ * attribute value, so applications could use this information to undo\n+ * changes.\n */\n- removeComponent: function(point) {\n- var removed = this.components && (this.components.length > 2);\n- if (removed) {\n- OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,\n- arguments);\n+ modified: null,\n+\n+ /** \n+ * Constructor: OpenLayers.Feature.Vector\n+ * Create a vector feature. \n+ * \n+ * Parameters:\n+ * geometry - {} The geometry that this feature\n+ * represents.\n+ * attributes - {Object} An optional object that will be mapped to the\n+ * property. \n+ * style - {Object} An optional style object.\n+ */\n+ initialize: function(geometry, attributes, style) {\n+ OpenLayers.Feature.prototype.initialize.apply(this,\n+ [null, null, attributes]);\n+ this.lonlat = null;\n+ this.geometry = geometry ? geometry : null;\n+ this.state = null;\n+ this.attributes = {};\n+ if (attributes) {\n+ this.attributes = OpenLayers.Util.extend(this.attributes,\n+ attributes);\n }\n- return removed;\n+ this.style = style ? style : null;\n },\n \n- /**\n- * APIMethod: intersects\n- * Test for instersection between two geometries. This is a cheapo\n- * implementation of the Bently-Ottmann algorigithm. It doesn't\n- * really keep track of a sweep line data structure. It is closer\n- * to the brute force method, except that segments are sorted and\n- * potential intersections are only calculated when bounding boxes\n- * intersect.\n- *\n- * Parameters:\n- * geometry - {}\n- *\n- * Returns:\n- * {Boolean} The input geometry intersects this geometry.\n+ /** \n+ * Method: destroy\n+ * nullify references to prevent circular references and memory leaks\n */\n- intersects: function(geometry) {\n- var intersect = false;\n- var type = geometry.CLASS_NAME;\n- if (type == \"OpenLayers.Geometry.LineString\" ||\n- type == \"OpenLayers.Geometry.LinearRing\" ||\n- type == \"OpenLayers.Geometry.Point\") {\n- var segs1 = this.getSortedSegments();\n- var segs2;\n- if (type == \"OpenLayers.Geometry.Point\") {\n- segs2 = [{\n- x1: geometry.x,\n- y1: geometry.y,\n- x2: geometry.x,\n- y2: geometry.y\n- }];\n- } else {\n- segs2 = geometry.getSortedSegments();\n- }\n- var seg1, seg1x1, seg1x2, seg1y1, seg1y2,\n- seg2, seg2y1, seg2y2;\n- // sweep right\n- outer: for (var i = 0, len = segs1.length; i < len; ++i) {\n- seg1 = segs1[i];\n- seg1x1 = seg1.x1;\n- seg1x2 = seg1.x2;\n- seg1y1 = seg1.y1;\n- seg1y2 = seg1.y2;\n- inner: for (var j = 0, jlen = segs2.length; j < jlen; ++j) {\n- seg2 = segs2[j];\n- if (seg2.x1 > seg1x2) {\n- // seg1 still left of seg2\n- break;\n- }\n- if (seg2.x2 < seg1x1) {\n- // seg2 still left of seg1\n- continue;\n- }\n- seg2y1 = seg2.y1;\n- seg2y2 = seg2.y2;\n- if (Math.min(seg2y1, seg2y2) > Math.max(seg1y1, seg1y2)) {\n- // seg2 above seg1\n- continue;\n- }\n- if (Math.max(seg2y1, seg2y2) < Math.min(seg1y1, seg1y2)) {\n- // seg2 below seg1\n- continue;\n- }\n- if (OpenLayers.Geometry.segmentsIntersect(seg1, seg2)) {\n- intersect = true;\n- break outer;\n- }\n- }\n- }\n- } else {\n- intersect = geometry.intersects(this);\n+ destroy: function() {\n+ if (this.layer) {\n+ this.layer.removeFeatures(this);\n+ this.layer = null;\n }\n- return intersect;\n+\n+ this.geometry = null;\n+ this.modified = null;\n+ OpenLayers.Feature.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * Method: getSortedSegments\n+ * Method: clone\n+ * Create a clone of this vector feature. Does not set any non-standard\n+ * properties.\n *\n * Returns:\n- * {Array} An array of segment objects. Segment objects have properties\n- * x1, y1, x2, and y2. The start point is represented by x1 and y1.\n- * The end point is represented by x2 and y2. Start and end are\n- * ordered so that x1 < x2.\n+ * {} An exact clone of this vector feature.\n */\n- getSortedSegments: function() {\n- var numSeg = this.components.length - 1;\n- var segments = new Array(numSeg),\n- point1, point2;\n- for (var i = 0; i < numSeg; ++i) {\n- point1 = this.components[i];\n- point2 = this.components[i + 1];\n- if (point1.x < point2.x) {\n- segments[i] = {\n- x1: point1.x,\n- y1: point1.y,\n- x2: point2.x,\n- y2: point2.y\n- };\n- } else {\n- segments[i] = {\n- x1: point2.x,\n- y1: point2.y,\n- x2: point1.x,\n- y2: point1.y\n- };\n- }\n- }\n- // more efficient to define this somewhere static\n- function byX1(seg1, seg2) {\n- return seg1.x1 - seg2.x1;\n- }\n- return segments.sort(byX1);\n+ clone: function() {\n+ return new OpenLayers.Feature.Vector(\n+ this.geometry ? this.geometry.clone() : null,\n+ this.attributes,\n+ this.style);\n },\n \n /**\n- * Method: splitWithSegment\n- * Split this geometry with the given segment.\n+ * Method: onScreen\n+ * Determine whether the feature is within the map viewport. This method\n+ * tests for an intersection between the geometry and the viewport\n+ * bounds. If a more effecient but less precise geometry bounds\n+ * intersection is desired, call the method with the boundsOnly\n+ * parameter true.\n *\n * Parameters:\n- * seg - {Object} An object with x1, y1, x2, and y2 properties referencing\n- * segment endpoint coordinates.\n- * options - {Object} Properties of this object will be used to determine\n- * how the split is conducted.\n- *\n- * Valid options:\n- * edge - {Boolean} Allow splitting when only edges intersect. Default is\n- * true. If false, a vertex on the source segment must be within the\n- * tolerance distance of the intersection to be considered a split.\n- * tolerance - {Number} If a non-null value is provided, intersections\n- * within the tolerance distance of one of the source segment's\n- * endpoints will be assumed to occur at the endpoint.\n- *\n+ * boundsOnly - {Boolean} Only test whether a feature's bounds intersects\n+ * the viewport bounds. Default is false. If false, the feature's\n+ * geometry must intersect the viewport for onScreen to return true.\n+ * \n * Returns:\n- * {Object} An object with *lines* and *points* properties. If the given\n- * segment intersects this linestring, the lines array will reference\n- * geometries that result from the split. The points array will contain\n- * all intersection points. Intersection points are sorted along the\n- * segment (in order from x1,y1 to x2,y2).\n+ * {Boolean} The feature is currently visible on screen (optionally\n+ * based on its bounds if boundsOnly is true).\n */\n- splitWithSegment: function(seg, options) {\n- var edge = !(options && options.edge === false);\n- var tolerance = options && options.tolerance;\n- var lines = [];\n- var verts = this.getVertices();\n- var points = [];\n- var intersections = [];\n- var split = false;\n- var vert1, vert2, point;\n- var node, vertex, target;\n- var interOptions = {\n- point: true,\n- tolerance: tolerance\n- };\n- var result = null;\n- for (var i = 0, stop = verts.length - 2; i <= stop; ++i) {\n- vert1 = verts[i];\n- points.push(vert1.clone());\n- vert2 = verts[i + 1];\n- target = {\n- x1: vert1.x,\n- y1: vert1.y,\n- x2: vert2.x,\n- y2: vert2.y\n- };\n- point = OpenLayers.Geometry.segmentsIntersect(\n- seg, target, interOptions\n- );\n- if (point instanceof OpenLayers.Geometry.Point) {\n- if ((point.x === seg.x1 && point.y === seg.y1) ||\n- (point.x === seg.x2 && point.y === seg.y2) ||\n- point.equals(vert1) || point.equals(vert2)) {\n- vertex = true;\n- } else {\n- vertex = false;\n- }\n- if (vertex || edge) {\n- // push intersections different than the previous\n- if (!point.equals(intersections[intersections.length - 1])) {\n- intersections.push(point.clone());\n- }\n- if (i === 0) {\n- if (point.equals(vert1)) {\n- continue;\n- }\n- }\n- if (point.equals(vert2)) {\n- continue;\n- }\n- split = true;\n- if (!point.equals(vert1)) {\n- points.push(point);\n- }\n- lines.push(new OpenLayers.Geometry.LineString(points));\n- points = [point.clone()];\n- }\n+ onScreen: function(boundsOnly) {\n+ var onScreen = false;\n+ if (this.layer && this.layer.map) {\n+ var screenBounds = this.layer.map.getExtent();\n+ if (boundsOnly) {\n+ var featureBounds = this.geometry.getBounds();\n+ onScreen = screenBounds.intersectsBounds(featureBounds);\n+ } else {\n+ var screenPoly = screenBounds.toGeometry();\n+ onScreen = screenPoly.intersects(this.geometry);\n }\n }\n- if (split) {\n- points.push(vert2.clone());\n- lines.push(new OpenLayers.Geometry.LineString(points));\n- }\n- if (intersections.length > 0) {\n- // sort intersections along segment\n- var xDir = seg.x1 < seg.x2 ? 1 : -1;\n- var yDir = seg.y1 < seg.y2 ? 1 : -1;\n- result = {\n- lines: lines,\n- points: intersections.sort(function(p1, p2) {\n- return (xDir * p1.x - xDir * p2.x) || (yDir * p1.y - yDir * p2.y);\n- })\n- };\n- }\n- return result;\n+ return onScreen;\n },\n \n /**\n- * Method: split\n- * Use this geometry (the source) to attempt to split a target geometry.\n- * \n- * Parameters:\n- * target - {} The target geometry.\n- * options - {Object} Properties of this object will be used to determine\n- * how the split is conducted.\n- *\n- * Valid options:\n- * mutual - {Boolean} Split the source geometry in addition to the target\n- * geometry. Default is false.\n- * edge - {Boolean} Allow splitting when only edges intersect. Default is\n- * true. If false, a vertex on the source must be within the tolerance\n- * distance of the intersection to be considered a split.\n- * tolerance - {Number} If a non-null value is provided, intersections\n- * within the tolerance distance of an existing vertex on the source\n- * will be assumed to occur at the vertex.\n+ * Method: getVisibility\n+ * Determine whether the feature is displayed or not. It may not displayed\n+ * because:\n+ * - its style display property is set to 'none',\n+ * - it doesn't belong to any layer,\n+ * - the styleMap creates a symbolizer with display property set to 'none'\n+ * for it,\n+ * - the layer which it belongs to is not visible.\n * \n * Returns:\n- * {Array} A list of geometries (of this same type as the target) that\n- * result from splitting the target with the source geometry. The\n- * source and target geometry will remain unmodified. If no split\n- * results, null will be returned. If mutual is true and a split\n- * results, return will be an array of two arrays - the first will be\n- * all geometries that result from splitting the source geometry and\n- * the second will be all geometries that result from splitting the\n- * target geometry.\n+ * {Boolean} The feature is currently displayed.\n */\n- split: function(target, options) {\n- var results = null;\n- var mutual = options && options.mutual;\n- var sourceSplit, targetSplit, sourceParts, targetParts;\n- if (target instanceof OpenLayers.Geometry.LineString) {\n- var verts = this.getVertices();\n- var vert1, vert2, seg, splits, lines, point;\n- var points = [];\n- sourceParts = [];\n- for (var i = 0, stop = verts.length - 2; i <= stop; ++i) {\n- vert1 = verts[i];\n- vert2 = verts[i + 1];\n- seg = {\n- x1: vert1.x,\n- y1: vert1.y,\n- x2: vert2.x,\n- y2: vert2.y\n- };\n- targetParts = targetParts || [target];\n- if (mutual) {\n- points.push(vert1.clone());\n- }\n- for (var j = 0; j < targetParts.length; ++j) {\n- splits = targetParts[j].splitWithSegment(seg, options);\n- if (splits) {\n- // splice in new features\n- lines = splits.lines;\n- if (lines.length > 0) {\n- lines.unshift(j, 1);\n- Array.prototype.splice.apply(targetParts, lines);\n- j += lines.length - 2;\n- }\n- if (mutual) {\n- for (var k = 0, len = splits.points.length; k < len; ++k) {\n- point = splits.points[k];\n- if (!point.equals(vert1)) {\n- points.push(point);\n- sourceParts.push(new OpenLayers.Geometry.LineString(points));\n- if (point.equals(vert2)) {\n- points = [];\n- } else {\n- points = [point.clone()];\n- }\n- }\n- }\n- }\n- }\n- }\n- }\n- if (mutual && sourceParts.length > 0 && points.length > 0) {\n- points.push(vert2.clone());\n- sourceParts.push(new OpenLayers.Geometry.LineString(points));\n- }\n- } else {\n- results = target.splitWith(this, options);\n- }\n- if (targetParts && targetParts.length > 1) {\n- targetSplit = true;\n- } else {\n- targetParts = [];\n- }\n- if (sourceParts && sourceParts.length > 1) {\n- sourceSplit = true;\n- } else {\n- sourceParts = [];\n- }\n- if (targetSplit || sourceSplit) {\n- if (mutual) {\n- results = [sourceParts, targetParts];\n- } else {\n- results = targetParts;\n- }\n- }\n- return results;\n+ getVisibility: function() {\n+ return !(this.style && this.style.display == 'none' ||\n+ !this.layer ||\n+ this.layer && this.layer.styleMap &&\n+ this.layer.styleMap.createSymbolizer(this, this.renderIntent).display == 'none' ||\n+ this.layer && !this.layer.getVisibility());\n },\n \n /**\n- * Method: splitWith\n- * Split this geometry (the target) with the given geometry (the source).\n- *\n- * Parameters:\n- * geometry - {} A geometry used to split this\n- * geometry (the source).\n- * options - {Object} Properties of this object will be used to determine\n- * how the split is conducted.\n- *\n- * Valid options:\n- * mutual - {Boolean} Split the source geometry in addition to the target\n- * geometry. Default is false.\n- * edge - {Boolean} Allow splitting when only edges intersect. Default is\n- * true. If false, a vertex on the source must be within the tolerance\n- * distance of the intersection to be considered a split.\n- * tolerance - {Number} If a non-null value is provided, intersections\n- * within the tolerance distance of an existing vertex on the source\n- * will be assumed to occur at the vertex.\n+ * Method: createMarker\n+ * HACK - we need to decide if all vector features should be able to\n+ * create markers\n * \n * Returns:\n- * {Array} A list of geometries (of this same type as the target) that\n- * result from splitting the target with the source geometry. The\n- * source and target geometry will remain unmodified. If no split\n- * results, null will be returned. If mutual is true and a split\n- * results, return will be an array of two arrays - the first will be\n- * all geometries that result from splitting the source geometry and\n- * the second will be all geometries that result from splitting the\n- * target geometry.\n+ * {} For now just returns null\n */\n- splitWith: function(geometry, options) {\n- return geometry.split(this, options);\n+ createMarker: function() {\n+ return null;\n+ },\n \n+ /**\n+ * Method: destroyMarker\n+ * HACK - we need to decide if all vector features should be able to\n+ * delete markers\n+ * \n+ * If user overrides the createMarker() function, s/he should be able\n+ * to also specify an alternative function for destroying it\n+ */\n+ destroyMarker: function() {\n+ // pass\n },\n \n /**\n- * APIMethod: getVertices\n- * Return a list of all points in this geometry.\n- *\n- * Parameters:\n- * nodes - {Boolean} For lines, only return vertices that are\n- * endpoints. If false, for lines, only vertices that are not\n- * endpoints will be returned. If not provided, all vertices will\n- * be returned.\n- *\n+ * Method: createPopup\n+ * HACK - we need to decide if all vector features should be able to\n+ * create popups\n+ * \n * Returns:\n- * {Array} A list of all vertices in the geometry.\n+ * {} For now just returns null\n */\n- getVertices: function(nodes) {\n- var vertices;\n- if (nodes === true) {\n- vertices = [\n- this.components[0],\n- this.components[this.components.length - 1]\n- ];\n- } else if (nodes === false) {\n- vertices = this.components.slice(1, this.components.length - 1);\n- } else {\n- vertices = this.components.slice();\n- }\n- return vertices;\n+ createPopup: function() {\n+ return null;\n },\n \n /**\n- * APIMethod: distanceTo\n- * Calculate the closest distance between two geometries (on the x-y plane).\n- *\n- * Parameters:\n- * geometry - {} The target geometry.\n- * options - {Object} Optional properties for configuring the distance\n- * calculation.\n- *\n- * Valid options:\n- * details - {Boolean} Return details from the distance calculation.\n- * Default is false.\n- * edge - {Boolean} Calculate the distance from this geometry to the\n- * nearest edge of the target geometry. Default is true. If true,\n- * calling distanceTo from a geometry that is wholly contained within\n- * the target will result in a non-zero distance. If false, whenever\n- * geometries intersect, calling distanceTo will return 0. If false,\n- * details cannot be returned.\n- *\n+ * Method: atPoint\n+ * Determins whether the feature intersects with the specified location.\n+ * \n+ * Parameters: \n+ * lonlat - {|Object} OpenLayers.LonLat or an\n+ * object with a 'lon' and 'lat' properties.\n+ * toleranceLon - {float} Optional tolerance in Geometric Coords\n+ * toleranceLat - {float} Optional tolerance in Geographic Coords\n+ * \n * Returns:\n- * {Number | Object} The distance between this geometry and the target.\n- * If details is true, the return will be an object with distance,\n- * x0, y0, x1, and x2 properties. The x0 and y0 properties represent\n- * the coordinates of the closest point on this geometry. The x1 and y1\n- * properties represent the coordinates of the closest point on the\n- * target geometry.\n+ * {Boolean} Whether or not the feature is at the specified location\n */\n- distanceTo: function(geometry, options) {\n- var edge = !(options && options.edge === false);\n- var details = edge && options && options.details;\n- var result, best = {};\n- var min = Number.POSITIVE_INFINITY;\n- if (geometry instanceof OpenLayers.Geometry.Point) {\n- var segs = this.getSortedSegments();\n- var x = geometry.x;\n- var y = geometry.y;\n- var seg;\n- for (var i = 0, len = segs.length; i < len; ++i) {\n- seg = segs[i];\n- result = OpenLayers.Geometry.distanceToSegment(geometry, seg);\n- if (result.distance < min) {\n- min = result.distance;\n- best = result;\n- if (min === 0) {\n- break;\n- }\n- } else {\n- // if distance increases and we cross y0 to the right of x0, no need to keep looking.\n- if (seg.x2 > x && ((y > seg.y1 && y < seg.y2) || (y < seg.y1 && y > seg.y2))) {\n- break;\n- }\n- }\n- }\n- if (details) {\n- best = {\n- distance: best.distance,\n- x0: best.x,\n- y0: best.y,\n- x1: x,\n- y1: y\n- };\n- } else {\n- best = best.distance;\n- }\n- } else if (geometry instanceof OpenLayers.Geometry.LineString) {\n- var segs0 = this.getSortedSegments();\n- var segs1 = geometry.getSortedSegments();\n- var seg0, seg1, intersection, x0, y0;\n- var len1 = segs1.length;\n- var interOptions = {\n- point: true\n- };\n- outer: for (var i = 0, len = segs0.length; i < len; ++i) {\n- seg0 = segs0[i];\n- x0 = seg0.x1;\n- y0 = seg0.y1;\n- for (var j = 0; j < len1; ++j) {\n- seg1 = segs1[j];\n- intersection = OpenLayers.Geometry.segmentsIntersect(seg0, seg1, interOptions);\n- if (intersection) {\n- min = 0;\n- best = {\n- distance: 0,\n- x0: intersection.x,\n- y0: intersection.y,\n- x1: intersection.x,\n- y1: intersection.y\n- };\n- break outer;\n- } else {\n- result = OpenLayers.Geometry.distanceToSegment({\n- x: x0,\n- y: y0\n- }, seg1);\n- if (result.distance < min) {\n- min = result.distance;\n- best = {\n- distance: min,\n- x0: x0,\n- y0: y0,\n- x1: result.x,\n- y1: result.y\n- };\n- }\n- }\n- }\n- }\n- if (!details) {\n- best = best.distance;\n- }\n- if (min !== 0) {\n- // check the final vertex in this line's sorted segments\n- if (seg0) {\n- result = geometry.distanceTo(\n- new OpenLayers.Geometry.Point(seg0.x2, seg0.y2),\n- options\n- );\n- var dist = details ? result.distance : result;\n- if (dist < min) {\n- if (details) {\n- best = {\n- distance: min,\n- x0: result.x1,\n- y0: result.y1,\n- x1: result.x0,\n- y1: result.y0\n- };\n- } else {\n- best = dist;\n- }\n- }\n- }\n- }\n- } else {\n- best = geometry.distanceTo(this, options);\n- // swap since target comes from this line\n- if (details) {\n- best = {\n- distance: best.distance,\n- x0: best.x1,\n- y0: best.y1,\n- x1: best.x0,\n- y1: best.y0\n- };\n- }\n+ atPoint: function(lonlat, toleranceLon, toleranceLat) {\n+ var atPoint = false;\n+ if (this.geometry) {\n+ atPoint = this.geometry.atPoint(lonlat, toleranceLon,\n+ toleranceLat);\n }\n- return best;\n+ return atPoint;\n },\n \n /**\n- * APIMethod: simplify\n- * This function will return a simplified LineString.\n- * Simplification is based on the Douglas-Peucker algorithm.\n- *\n+ * Method: destroyPopup\n+ * HACK - we need to decide if all vector features should be able to\n+ * delete popups\n+ */\n+ destroyPopup: function() {\n+ // pass\n+ },\n+\n+ /**\n+ * Method: move\n+ * Moves the feature and redraws it at its new location\n *\n * Parameters:\n- * tolerance - {number} threshhold for simplification in map units\n- *\n- * Returns:\n- * {OpenLayers.Geometry.LineString} the simplified LineString\n+ * location - { or } the\n+ * location to which to move the feature.\n */\n- simplify: function(tolerance) {\n- if (this && this !== null) {\n- var points = this.getVertices();\n- if (points.length < 3) {\n- return this;\n- }\n-\n- var compareNumbers = function(a, b) {\n- return (a - b);\n- };\n-\n- /**\n- * Private function doing the Douglas-Peucker reduction\n- */\n- var douglasPeuckerReduction = function(points, firstPoint, lastPoint, tolerance) {\n- var maxDistance = 0;\n- var indexFarthest = 0;\n-\n- for (var index = firstPoint, distance; index < lastPoint; index++) {\n- distance = perpendicularDistance(points[firstPoint], points[lastPoint], points[index]);\n- if (distance > maxDistance) {\n- maxDistance = distance;\n- indexFarthest = index;\n- }\n- }\n-\n- if (maxDistance > tolerance && indexFarthest != firstPoint) {\n- //Add the largest point that exceeds the tolerance\n- pointIndexsToKeep.push(indexFarthest);\n- douglasPeuckerReduction(points, firstPoint, indexFarthest, tolerance);\n- douglasPeuckerReduction(points, indexFarthest, lastPoint, tolerance);\n- }\n- };\n-\n- /**\n- * Private function calculating the perpendicular distance\n- * TODO: check whether OpenLayers.Geometry.LineString::distanceTo() is faster or slower\n- */\n- var perpendicularDistance = function(point1, point2, point) {\n- //Area = |(1/2)(x1y2 + x2y3 + x3y1 - x2y1 - x3y2 - x1y3)| *Area of triangle\n- //Base = v((x1-x2)\u00b2+(x1-x2)\u00b2) *Base of Triangle*\n- //Area = .5*Base*H *Solve for height\n- //Height = Area/.5/Base\n-\n- var area = Math.abs(0.5 * (point1.x * point2.y + point2.x * point.y + point.x * point1.y - point2.x * point1.y - point.x * point2.y - point1.x * point.y));\n- var bottom = Math.sqrt(Math.pow(point1.x - point2.x, 2) + Math.pow(point1.y - point2.y, 2));\n- var height = area / bottom * 2;\n+ move: function(location) {\n \n- return height;\n- };\n+ if (!this.layer || !this.geometry.move) {\n+ //do nothing if no layer or immoveable geometry\n+ return undefined;\n+ }\n \n- var firstPoint = 0;\n- var lastPoint = points.length - 1;\n- var pointIndexsToKeep = [];\n+ var pixel;\n+ if (location.CLASS_NAME == \"OpenLayers.LonLat\") {\n+ pixel = this.layer.getViewPortPxFromLonLat(location);\n+ } else {\n+ pixel = location;\n+ }\n \n- //Add the first and last index to the keepers\n- pointIndexsToKeep.push(firstPoint);\n- pointIndexsToKeep.push(lastPoint);\n+ var lastPixel = this.layer.getViewPortPxFromLonLat(this.geometry.getBounds().getCenterLonLat());\n+ var res = this.layer.map.getResolution();\n+ this.geometry.move(res * (pixel.x - lastPixel.x),\n+ res * (lastPixel.y - pixel.y));\n+ this.layer.drawFeature(this);\n+ return lastPixel;\n+ },\n \n- //The first and the last point cannot be the same\n- while (points[firstPoint].equals(points[lastPoint])) {\n- lastPoint--;\n- //Addition: the first point not equal to first point in the LineString is kept as well\n- pointIndexsToKeep.push(lastPoint);\n+ /**\n+ * Method: toState\n+ * Sets the new state\n+ *\n+ * Parameters:\n+ * state - {String} \n+ */\n+ toState: function(state) {\n+ if (state == OpenLayers.State.UPDATE) {\n+ switch (this.state) {\n+ case OpenLayers.State.UNKNOWN:\n+ case OpenLayers.State.DELETE:\n+ this.state = state;\n+ break;\n+ case OpenLayers.State.UPDATE:\n+ case OpenLayers.State.INSERT:\n+ break;\n }\n-\n- douglasPeuckerReduction(points, firstPoint, lastPoint, tolerance);\n- var returnPoints = [];\n- pointIndexsToKeep.sort(compareNumbers);\n- for (var index = 0; index < pointIndexsToKeep.length; index++) {\n- returnPoints.push(points[pointIndexsToKeep[index]]);\n+ } else if (state == OpenLayers.State.INSERT) {\n+ switch (this.state) {\n+ case OpenLayers.State.UNKNOWN:\n+ break;\n+ default:\n+ this.state = state;\n+ break;\n }\n- return new OpenLayers.Geometry.LineString(returnPoints);\n-\n- } else {\n- return this;\n+ } else if (state == OpenLayers.State.DELETE) {\n+ switch (this.state) {\n+ case OpenLayers.State.INSERT:\n+ // the feature should be destroyed\n+ break;\n+ case OpenLayers.State.DELETE:\n+ break;\n+ case OpenLayers.State.UNKNOWN:\n+ case OpenLayers.State.UPDATE:\n+ this.state = state;\n+ break;\n+ }\n+ } else if (state == OpenLayers.State.UNKNOWN) {\n+ this.state = state;\n }\n },\n \n- CLASS_NAME: \"OpenLayers.Geometry.LineString\"\n+ CLASS_NAME: \"OpenLayers.Feature.Vector\"\n });\n+\n+\n+/**\n+ * Constant: OpenLayers.Feature.Vector.style\n+ * OpenLayers features can have a number of style attributes. The 'default' \n+ * style will typically be used if no other style is specified. These\n+ * styles correspond for the most part, to the styling properties defined\n+ * by the SVG standard. \n+ * Information on fill properties: http://www.w3.org/TR/SVG/painting.html#FillProperties\n+ * Information on stroke properties: http://www.w3.org/TR/SVG/painting.html#StrokeProperties\n+ *\n+ * Symbolizer properties:\n+ * fill - {Boolean} Set to false if no fill is desired.\n+ * fillColor - {String} Hex fill color. Default is \"#ee9900\".\n+ * fillOpacity - {Number} Fill opacity (0-1). Default is 0.4 \n+ * stroke - {Boolean} Set to false if no stroke is desired.\n+ * strokeColor - {String} Hex stroke color. Default is \"#ee9900\".\n+ * strokeOpacity - {Number} Stroke opacity (0-1). Default is 1.\n+ * strokeWidth - {Number} Pixel stroke width. Default is 1.\n+ * strokeLinecap - {String} Stroke cap type. Default is \"round\". [butt | round | square]\n+ * strokeDashstyle - {String} Stroke dash style. Default is \"solid\". [dot | dash | dashdot | longdash | longdashdot | solid]\n+ * graphic - {Boolean} Set to false if no graphic is desired.\n+ * pointRadius - {Number} Pixel point radius. Default is 6.\n+ * pointerEvents - {String} Default is \"visiblePainted\".\n+ * cursor - {String} Default is \"\".\n+ * externalGraphic - {String} Url to an external graphic that will be used for rendering points.\n+ * graphicWidth - {Number} Pixel width for sizing an external graphic.\n+ * graphicHeight - {Number} Pixel height for sizing an external graphic.\n+ * graphicOpacity - {Number} Opacity (0-1) for an external graphic.\n+ * graphicXOffset - {Number} Pixel offset along the positive x axis for displacing an external graphic.\n+ * graphicYOffset - {Number} Pixel offset along the positive y axis for displacing an external graphic.\n+ * rotation - {Number} For point symbolizers, this is the rotation of a graphic in the clockwise direction about its center point (or any point off center as specified by graphicXOffset and graphicYOffset).\n+ * graphicZIndex - {Number} The integer z-index value to use in rendering.\n+ * graphicName - {String} Named graphic to use when rendering points. Supported values include \"circle\" (default),\n+ * \"square\", \"star\", \"x\", \"cross\", \"triangle\".\n+ * graphicTitle - {String} Tooltip when hovering over a feature. *deprecated*, use title instead\n+ * title - {String} Tooltip when hovering over a feature. Not supported by the canvas renderer.\n+ * backgroundGraphic - {String} Url to a graphic to be used as the background under an externalGraphic.\n+ * backgroundGraphicZIndex - {Number} The integer z-index value to use in rendering the background graphic.\n+ * backgroundXOffset - {Number} The x offset (in pixels) for the background graphic.\n+ * backgroundYOffset - {Number} The y offset (in pixels) for the background graphic.\n+ * backgroundHeight - {Number} The height of the background graphic. If not provided, the graphicHeight will be used.\n+ * backgroundWidth - {Number} The width of the background width. If not provided, the graphicWidth will be used.\n+ * label - {String} The text for an optional label. For browsers that use the canvas renderer, this requires either\n+ * fillText or mozDrawText to be available.\n+ * labelAlign - {String} Label alignment. This specifies the insertion point relative to the text. It is a string\n+ * composed of two characters. The first character is for the horizontal alignment, the second for the vertical\n+ * alignment. Valid values for horizontal alignment: \"l\"=left, \"c\"=center, \"r\"=right. Valid values for vertical\n+ * alignment: \"t\"=top, \"m\"=middle, \"b\"=bottom. Example values: \"lt\", \"cm\", \"rb\". Default is \"cm\".\n+ * labelXOffset - {Number} Pixel offset along the positive x axis for displacing the label. Not supported by the canvas renderer.\n+ * labelYOffset - {Number} Pixel offset along the positive y axis for displacing the label. Not supported by the canvas renderer.\n+ * labelSelect - {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls.\n+ * Default is false.\n+ * labelOutlineColor - {String} The color of the label outline. Default is 'white'. Only supported by the canvas & SVG renderers.\n+ * labelOutlineWidth - {Number} The width of the label outline. Default is 3, set to 0 or null to disable. Only supported by the SVG renderers.\n+ * labelOutlineOpacity - {Number} The opacity (0-1) of the label outline. Default is fontOpacity. Only supported by the canvas & SVG renderers.\n+ * fontColor - {String} The font color for the label, to be provided like CSS.\n+ * fontOpacity - {Number} Opacity (0-1) for the label\n+ * fontFamily - {String} The font family for the label, to be provided like in CSS.\n+ * fontSize - {String} The font size for the label, to be provided like in CSS.\n+ * fontStyle - {String} The font style for the label, to be provided like in CSS.\n+ * fontWeight - {String} The font weight for the label, to be provided like in CSS.\n+ * display - {String} Symbolizers will have no effect if display is set to \"none\". All other values have no effect.\n+ */\n+OpenLayers.Feature.Vector.style = {\n+ 'default': {\n+ fillColor: \"#ee9900\",\n+ fillOpacity: 0.4,\n+ hoverFillColor: \"white\",\n+ hoverFillOpacity: 0.8,\n+ strokeColor: \"#ee9900\",\n+ strokeOpacity: 1,\n+ strokeWidth: 1,\n+ strokeLinecap: \"round\",\n+ strokeDashstyle: \"solid\",\n+ hoverStrokeColor: \"red\",\n+ hoverStrokeOpacity: 1,\n+ hoverStrokeWidth: 0.2,\n+ pointRadius: 6,\n+ hoverPointRadius: 1,\n+ hoverPointUnit: \"%\",\n+ pointerEvents: \"visiblePainted\",\n+ cursor: \"inherit\",\n+ fontColor: \"#000000\",\n+ labelAlign: \"cm\",\n+ labelOutlineColor: \"white\",\n+ labelOutlineWidth: 3\n+ },\n+ 'select': {\n+ fillColor: \"blue\",\n+ fillOpacity: 0.4,\n+ hoverFillColor: \"white\",\n+ hoverFillOpacity: 0.8,\n+ strokeColor: \"blue\",\n+ strokeOpacity: 1,\n+ strokeWidth: 2,\n+ strokeLinecap: \"round\",\n+ strokeDashstyle: \"solid\",\n+ hoverStrokeColor: \"red\",\n+ hoverStrokeOpacity: 1,\n+ hoverStrokeWidth: 0.2,\n+ pointRadius: 6,\n+ hoverPointRadius: 1,\n+ hoverPointUnit: \"%\",\n+ pointerEvents: \"visiblePainted\",\n+ cursor: \"pointer\",\n+ fontColor: \"#000000\",\n+ labelAlign: \"cm\",\n+ labelOutlineColor: \"white\",\n+ labelOutlineWidth: 3\n+\n+ },\n+ 'temporary': {\n+ fillColor: \"#66cccc\",\n+ fillOpacity: 0.2,\n+ hoverFillColor: \"white\",\n+ hoverFillOpacity: 0.8,\n+ strokeColor: \"#66cccc\",\n+ strokeOpacity: 1,\n+ strokeLinecap: \"round\",\n+ strokeWidth: 2,\n+ strokeDashstyle: \"solid\",\n+ hoverStrokeColor: \"red\",\n+ hoverStrokeOpacity: 1,\n+ hoverStrokeWidth: 0.2,\n+ pointRadius: 6,\n+ hoverPointRadius: 1,\n+ hoverPointUnit: \"%\",\n+ pointerEvents: \"visiblePainted\",\n+ cursor: \"inherit\",\n+ fontColor: \"#000000\",\n+ labelAlign: \"cm\",\n+ labelOutlineColor: \"white\",\n+ labelOutlineWidth: 3\n+\n+ },\n+ 'delete': {\n+ display: \"none\"\n+ }\n+};\n /* ======================================================================\n- OpenLayers/Geometry/MultiLineString.js\n+ OpenLayers/Style.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Geometry/Collection.js\n- * @requires OpenLayers/Geometry/LineString.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Util.js\n+ * @requires OpenLayers/Feature/Vector.js\n */\n \n /**\n- * Class: OpenLayers.Geometry.MultiLineString\n- * A MultiLineString is a geometry with multiple \n- * components.\n- * \n- * Inherits from:\n- * - \n- * - \n+ * Class: OpenLayers.Style\n+ * This class represents a UserStyle obtained\n+ * from a SLD, containing styling rules.\n */\n-OpenLayers.Geometry.MultiLineString = OpenLayers.Class(\n- OpenLayers.Geometry.Collection, {\n+OpenLayers.Style = OpenLayers.Class({\n \n- /**\n- * Property: componentTypes\n- * {Array(String)} An array of class names representing the types of\n- * components that the collection can include. A null value means the\n- * component types are not restricted.\n- */\n- componentTypes: [\"OpenLayers.Geometry.LineString\"],\n+ /**\n+ * Property: id\n+ * {String} A unique id for this session.\n+ */\n+ id: null,\n \n- /**\n- * Constructor: OpenLayers.Geometry.MultiLineString\n- * Constructor for a MultiLineString Geometry.\n- *\n- * Parameters: \n- * components - {Array()} \n- *\n- */\n+ /**\n+ * APIProperty: name\n+ * {String}\n+ */\n+ name: null,\n \n- /**\n- * Method: split\n- * Use this geometry (the source) to attempt to split a target geometry.\n- * \n- * Parameters:\n- * geometry - {} The target geometry.\n- * options - {Object} Properties of this object will be used to determine\n- * how the split is conducted.\n- *\n- * Valid options:\n- * mutual - {Boolean} Split the source geometry in addition to the target\n- * geometry. Default is false.\n- * edge - {Boolean} Allow splitting when only edges intersect. Default is\n- * true. If false, a vertex on the source must be within the tolerance\n- * distance of the intersection to be considered a split.\n- * tolerance - {Number} If a non-null value is provided, intersections\n- * within the tolerance distance of an existing vertex on the source\n- * will be assumed to occur at the vertex.\n- * \n- * Returns:\n- * {Array} A list of geometries (of this same type as the target) that\n- * result from splitting the target with the source geometry. The\n- * source and target geometry will remain unmodified. If no split\n- * results, null will be returned. If mutual is true and a split\n- * results, return will be an array of two arrays - the first will be\n- * all geometries that result from splitting the source geometry and\n- * the second will be all geometries that result from splitting the\n- * target geometry.\n- */\n- split: function(geometry, options) {\n- var results = null;\n- var mutual = options && options.mutual;\n- var splits, sourceLine, sourceLines, sourceSplit, targetSplit;\n- var sourceParts = [];\n- var targetParts = [geometry];\n- for (var i = 0, len = this.components.length; i < len; ++i) {\n- sourceLine = this.components[i];\n- sourceSplit = false;\n- for (var j = 0; j < targetParts.length; ++j) {\n- splits = sourceLine.split(targetParts[j], options);\n- if (splits) {\n- if (mutual) {\n- sourceLines = splits[0];\n- for (var k = 0, klen = sourceLines.length; k < klen; ++k) {\n- if (k === 0 && sourceParts.length) {\n- sourceParts[sourceParts.length - 1].addComponent(\n- sourceLines[k]\n- );\n- } else {\n- sourceParts.push(\n- new OpenLayers.Geometry.MultiLineString([\n- sourceLines[k]\n- ])\n- );\n- }\n- }\n- sourceSplit = true;\n- splits = splits[1];\n- }\n- if (splits.length) {\n- // splice in new target parts\n- splits.unshift(j, 1);\n- Array.prototype.splice.apply(targetParts, splits);\n- break;\n- }\n- }\n- }\n- if (!sourceSplit) {\n- // source line was not hit\n- if (sourceParts.length) {\n- // add line to existing multi\n- sourceParts[sourceParts.length - 1].addComponent(\n- sourceLine.clone()\n- );\n- } else {\n- // create a fresh multi\n- sourceParts = [\n- new OpenLayers.Geometry.MultiLineString(\n- sourceLine.clone()\n- )\n- ];\n- }\n- }\n- }\n- if (sourceParts && sourceParts.length > 1) {\n- sourceSplit = true;\n- } else {\n- sourceParts = [];\n- }\n- if (targetParts && targetParts.length > 1) {\n- targetSplit = true;\n- } else {\n- targetParts = [];\n- }\n- if (sourceSplit || targetSplit) {\n- if (mutual) {\n- results = [sourceParts, targetParts];\n- } else {\n- results = targetParts;\n- }\n- }\n- return results;\n- },\n-\n- /**\n- * Method: splitWith\n- * Split this geometry (the target) with the given geometry (the source).\n- *\n- * Parameters:\n- * geometry - {} A geometry used to split this\n- * geometry (the source).\n- * options - {Object} Properties of this object will be used to determine\n- * how the split is conducted.\n- *\n- * Valid options:\n- * mutual - {Boolean} Split the source geometry in addition to the target\n- * geometry. Default is false.\n- * edge - {Boolean} Allow splitting when only edges intersect. Default is\n- * true. If false, a vertex on the source must be within the tolerance\n- * distance of the intersection to be considered a split.\n- * tolerance - {Number} If a non-null value is provided, intersections\n- * within the tolerance distance of an existing vertex on the source\n- * will be assumed to occur at the vertex.\n- * \n- * Returns:\n- * {Array} A list of geometries (of this same type as the target) that\n- * result from splitting the target with the source geometry. The\n- * source and target geometry will remain unmodified. If no split\n- * results, null will be returned. If mutual is true and a split\n- * results, return will be an array of two arrays - the first will be\n- * all geometries that result from splitting the source geometry and\n- * the second will be all geometries that result from splitting the\n- * target geometry.\n- */\n- splitWith: function(geometry, options) {\n- var results = null;\n- var mutual = options && options.mutual;\n- var splits, targetLine, sourceLines, sourceSplit, targetSplit, sourceParts, targetParts;\n- if (geometry instanceof OpenLayers.Geometry.LineString) {\n- targetParts = [];\n- sourceParts = [geometry];\n- for (var i = 0, len = this.components.length; i < len; ++i) {\n- targetSplit = false;\n- targetLine = this.components[i];\n- for (var j = 0; j < sourceParts.length; ++j) {\n- splits = sourceParts[j].split(targetLine, options);\n- if (splits) {\n- if (mutual) {\n- sourceLines = splits[0];\n- if (sourceLines.length) {\n- // splice in new source parts\n- sourceLines.unshift(j, 1);\n- Array.prototype.splice.apply(sourceParts, sourceLines);\n- j += sourceLines.length - 2;\n- }\n- splits = splits[1];\n- if (splits.length === 0) {\n- splits = [targetLine.clone()];\n- }\n- }\n- for (var k = 0, klen = splits.length; k < klen; ++k) {\n- if (k === 0 && targetParts.length) {\n- targetParts[targetParts.length - 1].addComponent(\n- splits[k]\n- );\n- } else {\n- targetParts.push(\n- new OpenLayers.Geometry.MultiLineString([\n- splits[k]\n- ])\n- );\n- }\n- }\n- targetSplit = true;\n- }\n- }\n- if (!targetSplit) {\n- // target component was not hit\n- if (targetParts.length) {\n- // add it to any existing multi-line\n- targetParts[targetParts.length - 1].addComponent(\n- targetLine.clone()\n- );\n- } else {\n- // or start with a fresh multi-line\n- targetParts = [\n- new OpenLayers.Geometry.MultiLineString([\n- targetLine.clone()\n- ])\n- ];\n- }\n-\n- }\n- }\n- } else {\n- results = geometry.split(this);\n- }\n- if (sourceParts && sourceParts.length > 1) {\n- sourceSplit = true;\n- } else {\n- sourceParts = [];\n- }\n- if (targetParts && targetParts.length > 1) {\n- targetSplit = true;\n- } else {\n- targetParts = [];\n- }\n- if (sourceSplit || targetSplit) {\n- if (mutual) {\n- results = [sourceParts, targetParts];\n- } else {\n- results = targetParts;\n- }\n- }\n- return results;\n- },\n+ /**\n+ * Property: title\n+ * {String} Title of this style (set if included in SLD)\n+ */\n+ title: null,\n \n- CLASS_NAME: \"OpenLayers.Geometry.MultiLineString\"\n- });\n-/* ======================================================================\n- OpenLayers/Geometry/LinearRing.js\n- ====================================================================== */\n+ /**\n+ * Property: description\n+ * {String} Description of this style (set if abstract is included in SLD)\n+ */\n+ description: null,\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ /**\n+ * APIProperty: layerName\n+ * {} name of the layer that this style belongs to, usually\n+ * according to the NamedLayer attribute of an SLD document.\n+ */\n+ layerName: null,\n \n-/**\n- * @requires OpenLayers/Geometry/LineString.js\n- */\n+ /**\n+ * APIProperty: isDefault\n+ * {Boolean}\n+ */\n+ isDefault: false,\n \n-/**\n- * Class: OpenLayers.Geometry.LinearRing\n- * \n- * A Linear Ring is a special LineString which is closed. It closes itself \n- * automatically on every addPoint/removePoint by adding a copy of the first\n- * point as the last point. \n- * \n- * Also, as it is the first in the line family to close itself, a getArea()\n- * function is defined to calculate the enclosed area of the linearRing\n- * \n- * Inherits:\n- * - \n- */\n-OpenLayers.Geometry.LinearRing = OpenLayers.Class(\n- OpenLayers.Geometry.LineString, {\n+ /** \n+ * Property: rules \n+ * {Array()}\n+ */\n+ rules: null,\n \n- /**\n- * Property: componentTypes\n- * {Array(String)} An array of class names representing the types of \n- * components that the collection can include. A null \n- * value means the component types are not restricted.\n- */\n- componentTypes: [\"OpenLayers.Geometry.Point\"],\n+ /**\n+ * APIProperty: context\n+ * {Object} An optional object with properties that symbolizers' property\n+ * values should be evaluated against. If no context is specified,\n+ * feature.attributes will be used\n+ */\n+ context: null,\n \n- /**\n- * Constructor: OpenLayers.Geometry.LinearRing\n- * Linear rings are constructed with an array of points. This array\n- * can represent a closed or open ring. If the ring is open (the last\n- * point does not equal the first point), the constructor will close\n- * the ring. If the ring is already closed (the last point does equal\n- * the first point), it will be left closed.\n- * \n- * Parameters:\n- * points - {Array()} points\n- */\n+ /**\n+ * Property: defaultStyle\n+ * {Object} hash of style properties to use as default for merging\n+ * rule-based style symbolizers onto. If no rules are defined,\n+ * createSymbolizer will return this style. If is set to\n+ * true, the defaultStyle will only be taken into account if there are\n+ * rules defined.\n+ */\n+ defaultStyle: null,\n \n- /**\n- * APIMethod: addComponent\n- * Adds a point to geometry components. If the point is to be added to\n- * the end of the components array and it is the same as the last point\n- * already in that array, the duplicate point is not added. This has \n- * the effect of closing the ring if it is not already closed, and \n- * doing the right thing if it is already closed. This behavior can \n- * be overridden by calling the method with a non-null index as the \n- * second argument.\n- *\n- * Parameters:\n- * point - {}\n- * index - {Integer} Index into the array to insert the component\n- * \n- * Returns:\n- * {Boolean} Was the Point successfully added?\n- */\n- addComponent: function(point, index) {\n- var added = false;\n+ /**\n+ * Property: defaultsPerSymbolizer\n+ * {Boolean} If set to true, the will extend the symbolizer\n+ * of every rule. Properties of the will also be used to set\n+ * missing symbolizer properties if the symbolizer has stroke, fill or\n+ * graphic set to true. Default is false.\n+ */\n+ defaultsPerSymbolizer: false,\n \n- //remove last point\n- var lastPoint = this.components.pop();\n+ /**\n+ * Property: propertyStyles\n+ * {Hash of Boolean} cache of style properties that need to be parsed for\n+ * propertyNames. Property names are keys, values won't be used.\n+ */\n+ propertyStyles: null,\n \n- // given an index, add the point\n- // without an index only add non-duplicate points\n- if (index != null || !point.equals(lastPoint)) {\n- added = OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,\n- arguments);\n- }\n \n- //append copy of first point\n- var firstPoint = this.components[0];\n- OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,\n- [firstPoint]);\n+ /** \n+ * Constructor: OpenLayers.Style\n+ * Creates a UserStyle.\n+ *\n+ * Parameters:\n+ * style - {Object} Optional hash of style properties that will be\n+ * used as default style for this style object. This style\n+ * applies if no rules are specified. Symbolizers defined in\n+ * rules will extend this default style.\n+ * options - {Object} An optional object with properties to set on the\n+ * style.\n+ *\n+ * Valid options:\n+ * rules - {Array()} List of rules to be added to the\n+ * style.\n+ * \n+ * Returns:\n+ * {}\n+ */\n+ initialize: function(style, options) {\n \n- return added;\n- },\n+ OpenLayers.Util.extend(this, options);\n+ this.rules = [];\n+ if (options && options.rules) {\n+ this.addRules(options.rules);\n+ }\n \n- /**\n- * APIMethod: removeComponent\n- * Removes a point from geometry components.\n- *\n- * Parameters:\n- * point - {}\n- *\n- * Returns: \n- * {Boolean} The component was removed.\n- */\n- removeComponent: function(point) {\n- var removed = this.components && (this.components.length > 3);\n- if (removed) {\n- //remove last point\n- this.components.pop();\n+ // use the default style from OpenLayers.Feature.Vector if no style\n+ // was given in the constructor\n+ this.setDefaultStyle(style ||\n+ OpenLayers.Feature.Vector.style[\"default\"]);\n \n- //remove our point\n- OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,\n- arguments);\n- //append copy of first point\n- var firstPoint = this.components[0];\n- OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,\n- [firstPoint]);\n- }\n- return removed;\n- },\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+ },\n \n- /**\n- * APIMethod: move\n- * Moves a geometry by the given displacement along positive x and y axes.\n- * This modifies the position of the geometry and clears the cached\n- * bounds.\n- *\n- * Parameters:\n- * x - {Float} Distance to move geometry in positive x direction. \n- * y - {Float} Distance to move geometry in positive y direction.\n- */\n- move: function(x, y) {\n- for (var i = 0, len = this.components.length; i < len - 1; i++) {\n- this.components[i].move(x, y);\n- }\n- },\n+ /** \n+ * APIMethod: destroy\n+ * nullify references to prevent circular references and memory leaks\n+ */\n+ destroy: function() {\n+ for (var i = 0, len = this.rules.length; i < len; i++) {\n+ this.rules[i].destroy();\n+ this.rules[i] = null;\n+ }\n+ this.rules = null;\n+ this.defaultStyle = null;\n+ },\n \n- /**\n- * APIMethod: rotate\n- * Rotate a geometry around some origin\n- *\n- * Parameters:\n- * angle - {Float} Rotation angle in degrees (measured counterclockwise\n- * from the positive x-axis)\n- * origin - {} Center point for the rotation\n- */\n- rotate: function(angle, origin) {\n- for (var i = 0, len = this.components.length; i < len - 1; ++i) {\n- this.components[i].rotate(angle, origin);\n- }\n- },\n+ /**\n+ * Method: createSymbolizer\n+ * creates a style by applying all feature-dependent rules to the base\n+ * style.\n+ * \n+ * Parameters:\n+ * feature - {} feature to evaluate rules for\n+ * \n+ * Returns:\n+ * {Object} symbolizer hash\n+ */\n+ createSymbolizer: function(feature) {\n+ var style = this.defaultsPerSymbolizer ? {} : this.createLiterals(\n+ OpenLayers.Util.extend({}, this.defaultStyle), feature);\n \n- /**\n- * APIMethod: resize\n- * Resize a geometry relative to some origin. Use this method to apply\n- * a uniform scaling to a geometry.\n- *\n- * Parameters:\n- * scale - {Float} Factor by which to scale the geometry. A scale of 2\n- * doubles the size of the geometry in each dimension\n- * (lines, for example, will be twice as long, and polygons\n- * will have four times the area).\n- * origin - {} Point of origin for resizing\n- * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.\n- * \n- * Returns:\n- * {} - The current geometry. \n- */\n- resize: function(scale, origin, ratio) {\n- for (var i = 0, len = this.components.length; i < len - 1; ++i) {\n- this.components[i].resize(scale, origin, ratio);\n- }\n- return this;\n- },\n+ var rules = this.rules;\n \n- /**\n- * APIMethod: transform\n- * Reproject the components geometry from source to dest.\n- *\n- * Parameters:\n- * source - {}\n- * dest - {}\n- * \n- * Returns:\n- * {} \n- */\n- transform: function(source, dest) {\n- if (source && dest) {\n- for (var i = 0, len = this.components.length; i < len - 1; i++) {\n- var component = this.components[i];\n- component.transform(source, dest);\n- }\n- this.bounds = null;\n- }\n- return this;\n- },\n+ var rule, context;\n+ var elseRules = [];\n+ var appliedRules = false;\n+ for (var i = 0, len = rules.length; i < len; i++) {\n+ rule = rules[i];\n+ // does the rule apply?\n+ var applies = rule.evaluate(feature);\n \n- /**\n- * APIMethod: getCentroid\n- *\n- * Returns:\n- * {} The centroid of the collection\n- */\n- getCentroid: function() {\n- if (this.components) {\n- var len = this.components.length;\n- if (len > 0 && len <= 2) {\n- return this.components[0].clone();\n- } else if (len > 2) {\n- var sumX = 0.0;\n- var sumY = 0.0;\n- var x0 = this.components[0].x;\n- var y0 = this.components[0].y;\n- var area = -1 * this.getArea();\n- if (area != 0) {\n- for (var i = 0; i < len - 1; i++) {\n- var b = this.components[i];\n- var c = this.components[i + 1];\n- sumX += (b.x + c.x - 2 * x0) * ((b.x - x0) * (c.y - y0) - (c.x - x0) * (b.y - y0));\n- sumY += (b.y + c.y - 2 * y0) * ((b.x - x0) * (c.y - y0) - (c.x - x0) * (b.y - y0));\n- }\n- var x = x0 + sumX / (6 * area);\n- var y = y0 + sumY / (6 * area);\n- } else {\n- for (var i = 0; i < len - 1; i++) {\n- sumX += this.components[i].x;\n- sumY += this.components[i].y;\n- }\n- var x = sumX / (len - 1);\n- var y = sumY / (len - 1);\n- }\n- return new OpenLayers.Geometry.Point(x, y);\n+ if (applies) {\n+ if (rule instanceof OpenLayers.Rule && rule.elseFilter) {\n+ elseRules.push(rule);\n } else {\n- return null;\n+ appliedRules = true;\n+ this.applySymbolizer(rule, style, feature);\n }\n }\n- },\n+ }\n \n- /**\n- * APIMethod: getArea\n- * Note - The area is positive if the ring is oriented CW, otherwise\n- * it will be negative.\n- * \n- * Returns:\n- * {Float} The signed area for a ring.\n- */\n- getArea: function() {\n- var area = 0.0;\n- if (this.components && (this.components.length > 2)) {\n- var sum = 0.0;\n- for (var i = 0, len = this.components.length; i < len - 1; i++) {\n- var b = this.components[i];\n- var c = this.components[i + 1];\n- sum += (b.x + c.x) * (c.y - b.y);\n- }\n- area = -sum / 2.0;\n+ // if no other rules apply, apply the rules with else filters\n+ if (appliedRules == false && elseRules.length > 0) {\n+ appliedRules = true;\n+ for (var i = 0, len = elseRules.length; i < len; i++) {\n+ this.applySymbolizer(elseRules[i], style, feature);\n }\n- return area;\n- },\n+ }\n \n- /**\n- * APIMethod: getGeodesicArea\n- * Calculate the approximate area of the polygon were it projected onto\n- * the earth. Note that this area will be positive if ring is oriented\n- * clockwise, otherwise it will be negative.\n- *\n- * Parameters:\n- * projection - {} The spatial reference system\n- * for the geometry coordinates. If not provided, Geographic/WGS84 is\n- * assumed.\n- * \n- * Reference:\n- * Robert. G. Chamberlain and William H. Duquette, \"Some Algorithms for\n- * Polygons on a Sphere\", JPL Publication 07-03, Jet Propulsion\n- * Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409\n- *\n- * Returns:\n- * {float} The approximate signed geodesic area of the polygon in square\n- * meters.\n- */\n- getGeodesicArea: function(projection) {\n- var ring = this; // so we can work with a clone if needed\n- if (projection) {\n- var gg = new OpenLayers.Projection(\"EPSG:4326\");\n- if (!gg.equals(projection)) {\n- ring = this.clone().transform(projection, gg);\n- }\n- }\n- var area = 0.0;\n- var len = ring.components && ring.components.length;\n- if (len > 2) {\n- var p1, p2;\n- for (var i = 0; i < len - 1; i++) {\n- p1 = ring.components[i];\n- p2 = ring.components[i + 1];\n- area += OpenLayers.Util.rad(p2.x - p1.x) *\n- (2 + Math.sin(OpenLayers.Util.rad(p1.y)) +\n- Math.sin(OpenLayers.Util.rad(p2.y)));\n- }\n- area = area * 6378137.0 * 6378137.0 / 2.0;\n- }\n- return area;\n- },\n+ // don't display if there were rules but none applied\n+ if (rules.length > 0 && appliedRules == false) {\n+ style.display = \"none\";\n+ }\n \n- /**\n- * Method: containsPoint\n- * Test if a point is inside a linear ring. For the case where a point\n- * is coincident with a linear ring edge, returns 1. Otherwise,\n- * returns boolean.\n- *\n- * Parameters:\n- * point - {}\n- *\n- * Returns:\n- * {Boolean | Number} The point is inside the linear ring. Returns 1 if\n- * the point is coincident with an edge. Returns boolean otherwise.\n- */\n- containsPoint: function(point) {\n- var approx = OpenLayers.Number.limitSigDigs;\n- var digs = 14;\n- var px = approx(point.x, digs);\n- var py = approx(point.y, digs);\n+ if (style.label != null && typeof style.label !== \"string\") {\n+ style.label = String(style.label);\n+ }\n \n- function getX(y, x1, y1, x2, y2) {\n- return (y - y2) * ((x2 - x1) / (y2 - y1)) + x2;\n- }\n- var numSeg = this.components.length - 1;\n- var start, end, x1, y1, x2, y2, cx, cy;\n- var crosses = 0;\n- for (var i = 0; i < numSeg; ++i) {\n- start = this.components[i];\n- x1 = approx(start.x, digs);\n- y1 = approx(start.y, digs);\n- end = this.components[i + 1];\n- x2 = approx(end.x, digs);\n- y2 = approx(end.y, digs);\n+ return style;\n+ },\n \n- /**\n- * The following conditions enforce five edge-crossing rules:\n- * 1. points coincident with edges are considered contained;\n- * 2. an upward edge includes its starting endpoint, and\n- * excludes its final endpoint;\n- * 3. a downward edge excludes its starting endpoint, and\n- * includes its final endpoint;\n- * 4. horizontal edges are excluded; and\n- * 5. the edge-ray intersection point must be strictly right\n- * of the point P.\n- */\n- if (y1 == y2) {\n- // horizontal edge\n- if (py == y1) {\n- // point on horizontal line\n- if (x1 <= x2 && (px >= x1 && px <= x2) || // right or vert\n- x1 >= x2 && (px <= x1 && px >= x2)) { // left or vert\n- // point on edge\n- crosses = -1;\n- break;\n- }\n- }\n- // ignore other horizontal edges\n- continue;\n- }\n- cx = approx(getX(py, x1, y1, x2, y2), digs);\n- if (cx == px) {\n- // point on line\n- if (y1 < y2 && (py >= y1 && py <= y2) || // upward\n- y1 > y2 && (py <= y1 && py >= y2)) { // downward\n- // point on edge\n- crosses = -1;\n- break;\n- }\n- }\n- if (cx <= px) {\n- // no crossing to the right\n- continue;\n- }\n- if (x1 != x2 && (cx < Math.min(x1, x2) || cx > Math.max(x1, x2))) {\n- // no crossing\n- continue;\n- }\n- if (y1 < y2 && (py >= y1 && py < y2) || // upward\n- y1 > y2 && (py < y1 && py >= y2)) { // downward\n- ++crosses;\n- }\n- }\n- var contained = (crosses == -1) ?\n- // on edge\n- 1 :\n- // even (out) or odd (in)\n- !!(crosses & 1);\n+ /**\n+ * Method: applySymbolizer\n+ *\n+ * Parameters:\n+ * rule - {}\n+ * style - {Object}\n+ * feature - {}\n+ *\n+ * Returns:\n+ * {Object} A style with new symbolizer applied.\n+ */\n+ applySymbolizer: function(rule, style, feature) {\n+ var symbolizerPrefix = feature.geometry ?\n+ this.getSymbolizerPrefix(feature.geometry) :\n+ OpenLayers.Style.SYMBOLIZER_PREFIXES[0];\n \n- return contained;\n- },\n+ var symbolizer = rule.symbolizer[symbolizerPrefix] || rule.symbolizer;\n \n- /**\n- * APIMethod: intersects\n- * Determine if the input geometry intersects this one.\n- *\n- * Parameters:\n- * geometry - {} Any type of geometry.\n- *\n- * Returns:\n- * {Boolean} The input geometry intersects this one.\n- */\n- intersects: function(geometry) {\n- var intersect = false;\n- if (geometry.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n- intersect = this.containsPoint(geometry);\n- } else if (geometry.CLASS_NAME == \"OpenLayers.Geometry.LineString\") {\n- intersect = geometry.intersects(this);\n- } else if (geometry.CLASS_NAME == \"OpenLayers.Geometry.LinearRing\") {\n- intersect = OpenLayers.Geometry.LineString.prototype.intersects.apply(\n- this, [geometry]\n- );\n- } else {\n- // check for component intersections\n- for (var i = 0, len = geometry.components.length; i < len; ++i) {\n- intersect = geometry.components[i].intersects(this);\n- if (intersect) {\n- break;\n- }\n- }\n+ if (this.defaultsPerSymbolizer === true) {\n+ var defaults = this.defaultStyle;\n+ OpenLayers.Util.applyDefaults(symbolizer, {\n+ pointRadius: defaults.pointRadius\n+ });\n+ if (symbolizer.stroke === true || symbolizer.graphic === true) {\n+ OpenLayers.Util.applyDefaults(symbolizer, {\n+ strokeWidth: defaults.strokeWidth,\n+ strokeColor: defaults.strokeColor,\n+ strokeOpacity: defaults.strokeOpacity,\n+ strokeDashstyle: defaults.strokeDashstyle,\n+ strokeLinecap: defaults.strokeLinecap\n+ });\n }\n- return intersect;\n- },\n-\n- /**\n- * APIMethod: getVertices\n- * Return a list of all points in this geometry.\n- *\n- * Parameters:\n- * nodes - {Boolean} For lines, only return vertices that are\n- * endpoints. If false, for lines, only vertices that are not\n- * endpoints will be returned. If not provided, all vertices will\n- * be returned.\n- *\n- * Returns:\n- * {Array} A list of all vertices in the geometry.\n- */\n- getVertices: function(nodes) {\n- return (nodes === true) ? [] : this.components.slice(0, this.components.length - 1);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Geometry.LinearRing\"\n- });\n-/* ======================================================================\n- OpenLayers/Geometry/Polygon.js\n- ====================================================================== */\n+ if (symbolizer.fill === true || symbolizer.graphic === true) {\n+ OpenLayers.Util.applyDefaults(symbolizer, {\n+ fillColor: defaults.fillColor,\n+ fillOpacity: defaults.fillOpacity\n+ });\n+ }\n+ if (symbolizer.graphic === true) {\n+ OpenLayers.Util.applyDefaults(symbolizer, {\n+ pointRadius: this.defaultStyle.pointRadius,\n+ externalGraphic: this.defaultStyle.externalGraphic,\n+ graphicName: this.defaultStyle.graphicName,\n+ graphicOpacity: this.defaultStyle.graphicOpacity,\n+ graphicWidth: this.defaultStyle.graphicWidth,\n+ graphicHeight: this.defaultStyle.graphicHeight,\n+ graphicXOffset: this.defaultStyle.graphicXOffset,\n+ graphicYOffset: this.defaultStyle.graphicYOffset\n+ });\n+ }\n+ }\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ // merge the style with the current style\n+ return this.createLiterals(\n+ OpenLayers.Util.extend(style, symbolizer), feature);\n+ },\n \n-/**\n- * @requires OpenLayers/Geometry/Collection.js\n- * @requires OpenLayers/Geometry/LinearRing.js\n- */\n+ /**\n+ * Method: createLiterals\n+ * creates literals for all style properties that have an entry in\n+ * .\n+ * \n+ * Parameters:\n+ * style - {Object} style to create literals for. Will be modified\n+ * inline.\n+ * feature - {Object}\n+ * \n+ * Returns:\n+ * {Object} the modified style\n+ */\n+ createLiterals: function(style, feature) {\n+ var context = OpenLayers.Util.extend({}, feature.attributes || feature.data);\n+ OpenLayers.Util.extend(context, this.context);\n \n-/**\n- * Class: OpenLayers.Geometry.Polygon \n- * Polygon is a collection of Geometry.LinearRings. \n- * \n- * Inherits from:\n- * - \n- * - \n- */\n-OpenLayers.Geometry.Polygon = OpenLayers.Class(\n- OpenLayers.Geometry.Collection, {\n+ for (var i in this.propertyStyles) {\n+ style[i] = OpenLayers.Style.createLiteral(style[i], context, feature, i);\n+ }\n+ return style;\n+ },\n \n- /**\n- * Property: componentTypes\n- * {Array(String)} An array of class names representing the types of\n- * components that the collection can include. A null value means the\n- * component types are not restricted.\n- */\n- componentTypes: [\"OpenLayers.Geometry.LinearRing\"],\n+ /**\n+ * Method: findPropertyStyles\n+ * Looks into all rules for this style and the defaultStyle to collect\n+ * all the style hash property names containing ${...} strings that have\n+ * to be replaced using the createLiteral method before returning them.\n+ * \n+ * Returns:\n+ * {Object} hash of property names that need createLiteral parsing. The\n+ * name of the property is the key, and the value is true;\n+ */\n+ findPropertyStyles: function() {\n+ var propertyStyles = {};\n \n- /**\n- * Constructor: OpenLayers.Geometry.Polygon\n- * Constructor for a Polygon geometry. \n- * The first ring (this.component[0])is the outer bounds of the polygon and \n- * all subsequent rings (this.component[1-n]) are internal holes.\n- *\n- *\n- * Parameters:\n- * components - {Array()} \n- */\n+ // check the default style\n+ var style = this.defaultStyle;\n+ this.addPropertyStyles(propertyStyles, style);\n \n- /** \n- * APIMethod: getArea\n- * Calculated by subtracting the areas of the internal holes from the \n- * area of the outer hole.\n- * \n- * Returns:\n- * {float} The area of the geometry\n- */\n- getArea: function() {\n- var area = 0.0;\n- if (this.components && (this.components.length > 0)) {\n- area += Math.abs(this.components[0].getArea());\n- for (var i = 1, len = this.components.length; i < len; i++) {\n- area -= Math.abs(this.components[i].getArea());\n+ // walk through all rules to check for properties in their symbolizer\n+ var rules = this.rules;\n+ var symbolizer, value;\n+ for (var i = 0, len = rules.length; i < len; i++) {\n+ symbolizer = rules[i].symbolizer;\n+ for (var key in symbolizer) {\n+ value = symbolizer[key];\n+ if (typeof value == \"object\") {\n+ // symbolizer key is \"Point\", \"Line\" or \"Polygon\"\n+ this.addPropertyStyles(propertyStyles, value);\n+ } else {\n+ // symbolizer is a hash of style properties\n+ this.addPropertyStyles(propertyStyles, symbolizer);\n+ break;\n }\n }\n- return area;\n- },\n+ }\n+ return propertyStyles;\n+ },\n \n- /** \n- * APIMethod: getGeodesicArea\n- * Calculate the approximate area of the polygon were it projected onto\n- * the earth.\n- *\n- * Parameters:\n- * projection - {} The spatial reference system\n- * for the geometry coordinates. If not provided, Geographic/WGS84 is\n- * assumed.\n- * \n- * Reference:\n- * Robert. G. Chamberlain and William H. Duquette, \"Some Algorithms for\n- * Polygons on a Sphere\", JPL Publication 07-03, Jet Propulsion\n- * Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409\n- *\n- * Returns:\n- * {float} The approximate geodesic area of the polygon in square meters.\n- */\n- getGeodesicArea: function(projection) {\n- var area = 0.0;\n- if (this.components && (this.components.length > 0)) {\n- area += Math.abs(this.components[0].getGeodesicArea(projection));\n- for (var i = 1, len = this.components.length; i < len; i++) {\n- area -= Math.abs(this.components[i].getGeodesicArea(projection));\n- }\n+ /**\n+ * Method: addPropertyStyles\n+ * \n+ * Parameters:\n+ * propertyStyles - {Object} hash to add new property styles to. Will be\n+ * modified inline\n+ * symbolizer - {Object} search this symbolizer for property styles\n+ * \n+ * Returns:\n+ * {Object} propertyStyles hash\n+ */\n+ addPropertyStyles: function(propertyStyles, symbolizer) {\n+ var property;\n+ for (var key in symbolizer) {\n+ property = symbolizer[key];\n+ if (typeof property == \"string\" &&\n+ property.match(/\\$\\{\\w+\\}/)) {\n+ propertyStyles[key] = true;\n }\n- return area;\n- },\n+ }\n+ return propertyStyles;\n+ },\n \n- /**\n- * Method: containsPoint\n- * Test if a point is inside a polygon. Points on a polygon edge are\n- * considered inside.\n- *\n- * Parameters:\n- * point - {}\n- *\n- * Returns:\n- * {Boolean | Number} The point is inside the polygon. Returns 1 if the\n- * point is on an edge. Returns boolean otherwise.\n- */\n- containsPoint: function(point) {\n- var numRings = this.components.length;\n- var contained = false;\n- if (numRings > 0) {\n- // check exterior ring - 1 means on edge, boolean otherwise\n- contained = this.components[0].containsPoint(point);\n- if (contained !== 1) {\n- if (contained && numRings > 1) {\n- // check interior rings\n- var hole;\n- for (var i = 1; i < numRings; ++i) {\n- hole = this.components[i].containsPoint(point);\n- if (hole) {\n- if (hole === 1) {\n- // on edge\n- contained = 1;\n- } else {\n- // in hole\n- contained = false;\n- }\n- break;\n- }\n- }\n- }\n- }\n- }\n- return contained;\n- },\n+ /**\n+ * APIMethod: addRules\n+ * Adds rules to this style.\n+ * \n+ * Parameters:\n+ * rules - {Array()}\n+ */\n+ addRules: function(rules) {\n+ Array.prototype.push.apply(this.rules, rules);\n+ this.propertyStyles = this.findPropertyStyles();\n+ },\n \n- /**\n- * APIMethod: intersects\n- * Determine if the input geometry intersects this one.\n- *\n- * Parameters:\n- * geometry - {} Any type of geometry.\n- *\n- * Returns:\n- * {Boolean} The input geometry intersects this one.\n- */\n- intersects: function(geometry) {\n- var intersect = false;\n- var i, len;\n- if (geometry.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n- intersect = this.containsPoint(geometry);\n- } else if (geometry.CLASS_NAME == \"OpenLayers.Geometry.LineString\" ||\n- geometry.CLASS_NAME == \"OpenLayers.Geometry.LinearRing\") {\n- // check if rings/linestrings intersect\n- for (i = 0, len = this.components.length; i < len; ++i) {\n- intersect = geometry.intersects(this.components[i]);\n- if (intersect) {\n- break;\n- }\n- }\n- if (!intersect) {\n- // check if this poly contains points of the ring/linestring\n- for (i = 0, len = geometry.components.length; i < len; ++i) {\n- intersect = this.containsPoint(geometry.components[i]);\n- if (intersect) {\n- break;\n- }\n- }\n- }\n- } else {\n- for (i = 0, len = geometry.components.length; i < len; ++i) {\n- intersect = this.intersects(geometry.components[i]);\n- if (intersect) {\n- break;\n- }\n- }\n- }\n- // check case where this poly is wholly contained by another\n- if (!intersect && geometry.CLASS_NAME == \"OpenLayers.Geometry.Polygon\") {\n- // exterior ring points will be contained in the other geometry\n- var ring = this.components[0];\n- for (i = 0, len = ring.components.length; i < len; ++i) {\n- intersect = geometry.containsPoint(ring.components[i]);\n- if (intersect) {\n- break;\n- }\n- }\n+ /**\n+ * APIMethod: setDefaultStyle\n+ * Sets the default style for this style object.\n+ * \n+ * Parameters:\n+ * style - {Object} Hash of style properties\n+ */\n+ setDefaultStyle: function(style) {\n+ this.defaultStyle = style;\n+ this.propertyStyles = this.findPropertyStyles();\n+ },\n+\n+ /**\n+ * Method: getSymbolizerPrefix\n+ * Returns the correct symbolizer prefix according to the\n+ * geometry type of the passed geometry\n+ * \n+ * Parameters:\n+ * geometry - {}\n+ * \n+ * Returns:\n+ * {String} key of the according symbolizer\n+ */\n+ getSymbolizerPrefix: function(geometry) {\n+ var prefixes = OpenLayers.Style.SYMBOLIZER_PREFIXES;\n+ for (var i = 0, len = prefixes.length; i < len; i++) {\n+ if (geometry.CLASS_NAME.indexOf(prefixes[i]) != -1) {\n+ return prefixes[i];\n }\n- return intersect;\n- },\n+ }\n+ },\n \n- /**\n- * APIMethod: distanceTo\n- * Calculate the closest distance between two geometries (on the x-y plane).\n- *\n- * Parameters:\n- * geometry - {} The target geometry.\n- * options - {Object} Optional properties for configuring the distance\n- * calculation.\n- *\n- * Valid options:\n- * details - {Boolean} Return details from the distance calculation.\n- * Default is false.\n- * edge - {Boolean} Calculate the distance from this geometry to the\n- * nearest edge of the target geometry. Default is true. If true,\n- * calling distanceTo from a geometry that is wholly contained within\n- * the target will result in a non-zero distance. If false, whenever\n- * geometries intersect, calling distanceTo will return 0. If false,\n- * details cannot be returned.\n- *\n- * Returns:\n- * {Number | Object} The distance between this geometry and the target.\n- * If details is true, the return will be an object with distance,\n- * x0, y0, x1, and y1 properties. The x0 and y0 properties represent\n- * the coordinates of the closest point on this geometry. The x1 and y1\n- * properties represent the coordinates of the closest point on the\n- * target geometry.\n- */\n- distanceTo: function(geometry, options) {\n- var edge = !(options && options.edge === false);\n- var result;\n- // this is the case where we might not be looking for distance to edge\n- if (!edge && this.intersects(geometry)) {\n- result = 0;\n- } else {\n- result = OpenLayers.Geometry.Collection.prototype.distanceTo.apply(\n- this, [geometry, options]\n- );\n+ /**\n+ * APIMethod: clone\n+ * Clones this style.\n+ * \n+ * Returns:\n+ * {} Clone of this style.\n+ */\n+ clone: function() {\n+ var options = OpenLayers.Util.extend({}, this);\n+ // clone rules\n+ if (this.rules) {\n+ options.rules = [];\n+ for (var i = 0, len = this.rules.length; i < len; ++i) {\n+ options.rules.push(this.rules[i].clone());\n }\n- return result;\n- },\n+ }\n+ // clone context\n+ options.context = this.context && OpenLayers.Util.extend({}, this.context);\n+ //clone default style\n+ var defaultStyle = OpenLayers.Util.extend({}, this.defaultStyle);\n+ return new OpenLayers.Style(defaultStyle, options);\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Style\"\n+});\n \n- CLASS_NAME: \"OpenLayers.Geometry.Polygon\"\n- });\n \n /**\n- * APIMethod: createRegularPolygon\n- * Create a regular polygon around a radius. Useful for creating circles \n- * and the like.\n- *\n+ * Function: createLiteral\n+ * converts a style value holding a combination of PropertyName and Literal\n+ * into a Literal, taking the property values from the passed features.\n+ * \n * Parameters:\n- * origin - {} center of polygon.\n- * radius - {Float} distance to vertex, in map units.\n- * sides - {Integer} Number of sides. 20 approximates a circle.\n- * rotation - {Float} original angle of rotation, in degrees.\n+ * value - {String} value to parse. If this string contains a construct like\n+ * \"foo ${bar}\", then \"foo \" will be taken as literal, and \"${bar}\"\n+ * will be replaced by the value of the \"bar\" attribute of the passed\n+ * feature.\n+ * context - {Object} context to take attribute values from\n+ * feature - {} optional feature to pass to\n+ * for evaluating functions in the\n+ * context.\n+ * property - {String} optional, name of the property for which the literal is\n+ * being created for evaluating functions in the context.\n+ * \n+ * Returns:\n+ * {String} the parsed value. In the example of the value parameter above, the\n+ * result would be \"foo valueOfBar\", assuming that the passed feature has an\n+ * attribute named \"bar\" with the value \"valueOfBar\".\n */\n-OpenLayers.Geometry.Polygon.createRegularPolygon = function(origin, radius, sides, rotation) {\n- var angle = Math.PI * ((1 / sides) - (1 / 2));\n- if (rotation) {\n- angle += (rotation / 180) * Math.PI;\n- }\n- var rotatedAngle, x, y;\n- var points = [];\n- for (var i = 0; i < sides; ++i) {\n- rotatedAngle = angle + (i * 2 * Math.PI / sides);\n- x = origin.x + (radius * Math.cos(rotatedAngle));\n- y = origin.y + (radius * Math.sin(rotatedAngle));\n- points.push(new OpenLayers.Geometry.Point(x, y));\n+OpenLayers.Style.createLiteral = function(value, context, feature, property) {\n+ if (typeof value == \"string\" && value.indexOf(\"${\") != -1) {\n+ value = OpenLayers.String.format(value, context, [feature, property]);\n+ value = (isNaN(value) || !value) ? value : parseFloat(value);\n }\n- var ring = new OpenLayers.Geometry.LinearRing(points);\n- return new OpenLayers.Geometry.Polygon([ring]);\n+ return value;\n };\n+\n+/**\n+ * Constant: OpenLayers.Style.SYMBOLIZER_PREFIXES\n+ * {Array} prefixes of the sld symbolizers. These are the\n+ * same as the main geometry types\n+ */\n+OpenLayers.Style.SYMBOLIZER_PREFIXES = ['Point', 'Line', 'Polygon', 'Text',\n+ 'Raster'\n+];\n /* ======================================================================\n- OpenLayers/Geometry/MultiPolygon.js\n+ OpenLayers/Spherical.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Geometry/Collection.js\n- * @requires OpenLayers/Geometry/Polygon.js\n+ * @requires OpenLayers/SingleFile.js\n */\n \n /**\n- * Class: OpenLayers.Geometry.MultiPolygon\n- * MultiPolygon is a geometry with multiple \n- * components. Create a new instance with the \n- * constructor.\n- * \n- * Inherits from:\n- * - \n+ * Namespace: Spherical\n+ * The OpenLayers.Spherical namespace includes utility functions for\n+ * calculations on the basis of a spherical earth (ignoring ellipsoidal\n+ * effects), which is accurate enough for most purposes.\n+ *\n+ * Relevant links:\n+ * * http://www.movable-type.co.uk/scripts/latlong.html\n+ * * http://code.google.com/apis/maps/documentation/javascript/reference.html#spherical\n */\n-OpenLayers.Geometry.MultiPolygon = OpenLayers.Class(\n- OpenLayers.Geometry.Collection, {\n \n- /**\n- * Property: componentTypes\n- * {Array(String)} An array of class names representing the types of\n- * components that the collection can include. A null value means the\n- * component types are not restricted.\n- */\n- componentTypes: [\"OpenLayers.Geometry.Polygon\"],\n+OpenLayers.Spherical = OpenLayers.Spherical || {};\n \n- /**\n- * Constructor: OpenLayers.Geometry.MultiPolygon\n- * Create a new MultiPolygon geometry\n- *\n- * Parameters:\n- * components - {Array()} An array of polygons\n- * used to generate the MultiPolygon\n- *\n- */\n+OpenLayers.Spherical.DEFAULT_RADIUS = 6378137;\n \n- CLASS_NAME: \"OpenLayers.Geometry.MultiPolygon\"\n- });\n+/**\n+ * APIFunction: computeDistanceBetween\n+ * Computes the distance between two LonLats.\n+ *\n+ * Parameters:\n+ * from - {} or {Object} Starting point. A LonLat or\n+ * a JavaScript literal with lon lat properties.\n+ * to - {} or {Object} Ending point. A LonLat or a\n+ * JavaScript literal with lon lat properties.\n+ * radius - {Float} The radius. Optional. Defaults to 6378137 meters.\n+ *\n+ * Returns:\n+ * {Float} The distance in meters.\n+ */\n+OpenLayers.Spherical.computeDistanceBetween = function(from, to, radius) {\n+ var R = radius || OpenLayers.Spherical.DEFAULT_RADIUS;\n+ var sinHalfDeltaLon = Math.sin(Math.PI * (to.lon - from.lon) / 360);\n+ var sinHalfDeltaLat = Math.sin(Math.PI * (to.lat - from.lat) / 360);\n+ var a = sinHalfDeltaLat * sinHalfDeltaLat +\n+ sinHalfDeltaLon * sinHalfDeltaLon * Math.cos(Math.PI * from.lat / 180) * Math.cos(Math.PI * to.lat / 180);\n+ return 2 * R * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n+};\n+\n+\n+/**\n+ * APIFunction: computeHeading\n+ * Computes the heading from one LonLat to another LonLat.\n+ *\n+ * Parameters:\n+ * from - {} or {Object} Starting point. A LonLat or\n+ * a JavaScript literal with lon lat properties.\n+ * to - {} or {Object} Ending point. A LonLat or a\n+ * JavaScript literal with lon lat properties.\n+ *\n+ * Returns:\n+ * {Float} The heading in degrees.\n+ */\n+OpenLayers.Spherical.computeHeading = function(from, to) {\n+ var y = Math.sin(Math.PI * (from.lon - to.lon) / 180) * Math.cos(Math.PI * to.lat / 180);\n+ var x = Math.cos(Math.PI * from.lat / 180) * Math.sin(Math.PI * to.lat / 180) -\n+ Math.sin(Math.PI * from.lat / 180) * Math.cos(Math.PI * to.lat / 180) * Math.cos(Math.PI * (from.lon - to.lon) / 180);\n+ return 180 * Math.atan2(y, x) / Math.PI;\n+};\n /* ======================================================================\n- OpenLayers/Format/WKT.js\n+ OpenLayers/Rule.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Format.js\n- * @requires OpenLayers/Feature/Vector.js\n- * @requires OpenLayers/Geometry/Point.js\n- * @requires OpenLayers/Geometry/MultiPoint.js\n- * @requires OpenLayers/Geometry/LineString.js\n- * @requires OpenLayers/Geometry/MultiLineString.js\n- * @requires OpenLayers/Geometry/Polygon.js\n- * @requires OpenLayers/Geometry/MultiPolygon.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Util.js\n+ * @requires OpenLayers/Style.js\n */\n \n /**\n- * Class: OpenLayers.Format.WKT\n- * Class for reading and writing Well-Known Text. Create a new instance\n- * with the constructor.\n- * \n- * Inherits from:\n- * - \n+ * Class: OpenLayers.Rule\n+ * This class represents an SLD Rule, as being used for rule-based SLD styling.\n */\n-OpenLayers.Format.WKT = OpenLayers.Class(OpenLayers.Format, {\n+OpenLayers.Rule = OpenLayers.Class({\n \n /**\n- * Constructor: OpenLayers.Format.WKT\n- * Create a new parser for WKT\n+ * Property: id\n+ * {String} A unique id for this session.\n+ */\n+ id: null,\n+\n+ /**\n+ * APIProperty: name\n+ * {String} name of this rule\n+ */\n+ name: null,\n+\n+ /**\n+ * Property: title\n+ * {String} Title of this rule (set if included in SLD)\n+ */\n+ title: null,\n+\n+ /**\n+ * Property: description\n+ * {String} Description of this rule (set if abstract is included in SLD)\n+ */\n+ description: null,\n+\n+ /**\n+ * Property: context\n+ * {Object} An optional object with properties that the rule should be\n+ * evaluated against. If no context is specified, feature.attributes will\n+ * be used.\n+ */\n+ context: null,\n+\n+ /**\n+ * Property: filter\n+ * {} Optional filter for the rule.\n+ */\n+ filter: null,\n+\n+ /**\n+ * Property: elseFilter\n+ * {Boolean} Determines whether this rule is only to be applied only if\n+ * no other rules match (ElseFilter according to the SLD specification). \n+ * Default is false. For instances of OpenLayers.Rule, if elseFilter is\n+ * false, the rule will always apply. For subclasses, the else property is \n+ * ignored.\n+ */\n+ elseFilter: false,\n+\n+ /**\n+ * Property: symbolizer\n+ * {Object} Symbolizer or hash of symbolizers for this rule. If hash of\n+ * symbolizers, keys are one or more of [\"Point\", \"Line\", \"Polygon\"]. The\n+ * latter if useful if it is required to style e.g. vertices of a line\n+ * with a point symbolizer. Note, however, that this is not implemented\n+ * yet in OpenLayers, but it is the way how symbolizers are defined in\n+ * SLD.\n+ */\n+ symbolizer: null,\n+\n+ /**\n+ * Property: symbolizers\n+ * {Array} Collection of symbolizers associated with this rule. If \n+ * provided at construction, the symbolizers array has precedence\n+ * over the deprecated symbolizer property. Note that multiple \n+ * symbolizers are not currently supported by the vector renderers.\n+ * Rules with multiple symbolizers are currently only useful for\n+ * maintaining elements in an SLD document.\n+ */\n+ symbolizers: null,\n+\n+ /**\n+ * APIProperty: minScaleDenominator\n+ * {Number} or {String} minimum scale at which to draw the feature.\n+ * In the case of a String, this can be a combination of text and\n+ * propertyNames in the form \"literal ${propertyName}\"\n+ */\n+ minScaleDenominator: null,\n+\n+ /**\n+ * APIProperty: maxScaleDenominator\n+ * {Number} or {String} maximum scale at which to draw the feature.\n+ * In the case of a String, this can be a combination of text and\n+ * propertyNames in the form \"literal ${propertyName}\"\n+ */\n+ maxScaleDenominator: null,\n+\n+ /** \n+ * Constructor: OpenLayers.Rule\n+ * Creates a Rule.\n *\n * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance\n- *\n+ * options - {Object} An optional object with properties to set on the\n+ * rule\n+ * \n * Returns:\n- * {} A new WKT parser.\n+ * {}\n */\n initialize: function(options) {\n- this.regExes = {\n- 'typeStr': /^\\s*(\\w+)\\s*\\(\\s*(.*)\\s*\\)\\s*$/,\n- 'spaces': /\\s+/,\n- 'parenComma': /\\)\\s*,\\s*\\(/,\n- 'doubleParenComma': /\\)\\s*\\)\\s*,\\s*\\(\\s*\\(/, // can't use {2} here\n- 'trimParens': /^\\s*\\(?(.*?)\\)?\\s*$/\n- };\n- OpenLayers.Format.prototype.initialize.apply(this, [options]);\n+ this.symbolizer = {};\n+ OpenLayers.Util.extend(this, options);\n+ if (this.symbolizers) {\n+ delete this.symbolizer;\n+ }\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n },\n \n- /**\n- * APIMethod: read\n- * Deserialize a WKT string and return a vector feature or an\n- * array of vector features. Supports WKT for POINT, MULTIPOINT,\n- * LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON, and\n- * GEOMETRYCOLLECTION.\n- *\n- * Parameters:\n- * wkt - {String} A WKT string\n- *\n- * Returns:\n- * {|Array} A feature or array of features for\n- * GEOMETRYCOLLECTION WKT.\n+ /** \n+ * APIMethod: destroy\n+ * nullify references to prevent circular references and memory leaks\n */\n- read: function(wkt) {\n- var features, type, str;\n- wkt = wkt.replace(/[\\n\\r]/g, \" \");\n- var matches = this.regExes.typeStr.exec(wkt);\n- if (matches) {\n- type = matches[1].toLowerCase();\n- str = matches[2];\n- if (this.parse[type]) {\n- features = this.parse[type].apply(this, [str]);\n- }\n- if (this.internalProjection && this.externalProjection) {\n- if (features &&\n- features.CLASS_NAME == \"OpenLayers.Feature.Vector\") {\n- features.geometry.transform(this.externalProjection,\n- this.internalProjection);\n- } else if (features &&\n- type != \"geometrycollection\" &&\n- typeof features == \"object\") {\n- for (var i = 0, len = features.length; i < len; i++) {\n- var component = features[i];\n- component.geometry.transform(this.externalProjection,\n- this.internalProjection);\n- }\n- }\n- }\n+ destroy: function() {\n+ for (var i in this.symbolizer) {\n+ this.symbolizer[i] = null;\n }\n- return features;\n+ this.symbolizer = null;\n+ delete this.symbolizers;\n },\n \n /**\n- * APIMethod: write\n- * Serialize a feature or array of features into a WKT string.\n- *\n+ * APIMethod: evaluate\n+ * evaluates this rule for a specific feature\n+ * \n * Parameters:\n- * features - {|Array} A feature or array of\n- * features\n- *\n+ * feature - {} feature to apply the rule to.\n+ * \n * Returns:\n- * {String} The WKT string representation of the input geometries\n+ * {Boolean} true if the rule applies, false if it does not.\n+ * This rule is the default rule and always returns true.\n */\n- write: function(features) {\n- var collection, geometry, isCollection;\n- if (features.constructor == Array) {\n- collection = features;\n- isCollection = true;\n- } else {\n- collection = [features];\n- isCollection = false;\n+ evaluate: function(feature) {\n+ var context = this.getContext(feature);\n+ var applies = true;\n+\n+ if (this.minScaleDenominator || this.maxScaleDenominator) {\n+ var scale = feature.layer.map.getScale();\n }\n- var pieces = [];\n- if (isCollection) {\n- pieces.push('GEOMETRYCOLLECTION(');\n+\n+ // check if within minScale/maxScale bounds\n+ if (this.minScaleDenominator) {\n+ applies = scale >= OpenLayers.Style.createLiteral(\n+ this.minScaleDenominator, context);\n }\n- for (var i = 0, len = collection.length; i < len; ++i) {\n- if (isCollection && i > 0) {\n- pieces.push(',');\n- }\n- geometry = collection[i].geometry;\n- pieces.push(this.extractGeometry(geometry));\n+ if (applies && this.maxScaleDenominator) {\n+ applies = scale < OpenLayers.Style.createLiteral(\n+ this.maxScaleDenominator, context);\n }\n- if (isCollection) {\n- pieces.push(')');\n+\n+ // check if optional filter applies\n+ if (applies && this.filter) {\n+ // feature id filters get the feature, others get the context\n+ if (this.filter.CLASS_NAME == \"OpenLayers.Filter.FeatureId\") {\n+ applies = this.filter.evaluate(feature);\n+ } else {\n+ applies = this.filter.evaluate(context);\n+ }\n }\n- return pieces.join('');\n+\n+ return applies;\n },\n \n /**\n- * Method: extractGeometry\n- * Entry point to construct the WKT for a single Geometry object.\n- *\n- * Parameters:\n- * geometry - {}\n- *\n- * Returns:\n- * {String} A WKT string of representing the geometry\n+ * Method: getContext\n+ * Gets the context for evaluating this rule\n+ * \n+ * Paramters:\n+ * feature - {} feature to take the context from if\n+ * none is specified.\n */\n- extractGeometry: function(geometry) {\n- var type = geometry.CLASS_NAME.split('.')[2].toLowerCase();\n- if (!this.extract[type]) {\n- return null;\n+ getContext: function(feature) {\n+ var context = this.context;\n+ if (!context) {\n+ context = feature.attributes || feature.data;\n }\n- if (this.internalProjection && this.externalProjection) {\n- geometry = geometry.clone();\n- geometry.transform(this.internalProjection, this.externalProjection);\n+ if (typeof this.context == \"function\") {\n+ context = this.context(feature);\n }\n- var wktType = type == 'collection' ? 'GEOMETRYCOLLECTION' : type.toUpperCase();\n- var data = wktType + '(' + this.extract[type].apply(this, [geometry]) + ')';\n- return data;\n+ return context;\n },\n \n /**\n- * Object with properties corresponding to the geometry types.\n- * Property values are functions that do the actual data extraction.\n+ * APIMethod: clone\n+ * Clones this rule.\n+ * \n+ * Returns:\n+ * {} Clone of this rule.\n */\n- extract: {\n- /**\n- * Return a space delimited string of point coordinates.\n- * @param {OpenLayers.Geometry.Point} point\n- * @returns {String} A string of coordinates representing the point\n- */\n- 'point': function(point) {\n- return point.x + ' ' + point.y;\n- },\n-\n- /**\n- * Return a comma delimited string of point coordinates from a multipoint.\n- * @param {OpenLayers.Geometry.MultiPoint} multipoint\n- * @returns {String} A string of point coordinate strings representing\n- * the multipoint\n- */\n- 'multipoint': function(multipoint) {\n- var array = [];\n- for (var i = 0, len = multipoint.components.length; i < len; ++i) {\n- array.push('(' +\n- this.extract.point.apply(this, [multipoint.components[i]]) +\n- ')');\n- }\n- return array.join(',');\n- },\n-\n- /**\n- * Return a comma delimited string of point coordinates from a line.\n- * @param {OpenLayers.Geometry.LineString} linestring\n- * @returns {String} A string of point coordinate strings representing\n- * the linestring\n- */\n- 'linestring': function(linestring) {\n- var array = [];\n- for (var i = 0, len = linestring.components.length; i < len; ++i) {\n- array.push(this.extract.point.apply(this, [linestring.components[i]]));\n+ clone: function() {\n+ var options = OpenLayers.Util.extend({}, this);\n+ if (this.symbolizers) {\n+ // clone symbolizers\n+ var len = this.symbolizers.length;\n+ options.symbolizers = new Array(len);\n+ for (var i = 0; i < len; ++i) {\n+ options.symbolizers[i] = this.symbolizers[i].clone();\n }\n- return array.join(',');\n- },\n-\n- /**\n- * Return a comma delimited string of linestring strings from a multilinestring.\n- * @param {OpenLayers.Geometry.MultiLineString} multilinestring\n- * @returns {String} A string of of linestring strings representing\n- * the multilinestring\n- */\n- 'multilinestring': function(multilinestring) {\n- var array = [];\n- for (var i = 0, len = multilinestring.components.length; i < len; ++i) {\n- array.push('(' +\n- this.extract.linestring.apply(this, [multilinestring.components[i]]) +\n- ')');\n+ } else {\n+ // clone symbolizer\n+ options.symbolizer = {};\n+ var value, type;\n+ for (var key in this.symbolizer) {\n+ value = this.symbolizer[key];\n+ type = typeof value;\n+ if (type === \"object\") {\n+ options.symbolizer[key] = OpenLayers.Util.extend({}, value);\n+ } else if (type === \"string\") {\n+ options.symbolizer[key] = value;\n+ }\n }\n- return array.join(',');\n- },\n+ }\n+ // clone filter\n+ options.filter = this.filter && this.filter.clone();\n+ // clone context\n+ options.context = this.context && OpenLayers.Util.extend({}, this.context);\n+ return new OpenLayers.Rule(options);\n+ },\n \n- /**\n- * Return a comma delimited string of linear ring arrays from a polygon.\n- * @param {OpenLayers.Geometry.Polygon} polygon\n- * @returns {String} An array of linear ring arrays representing the polygon\n- */\n- 'polygon': function(polygon) {\n- var array = [];\n- for (var i = 0, len = polygon.components.length; i < len; ++i) {\n- array.push('(' +\n- this.extract.linestring.apply(this, [polygon.components[i]]) +\n- ')');\n- }\n- return array.join(',');\n- },\n+ CLASS_NAME: \"OpenLayers.Rule\"\n+});\n+/* ======================================================================\n+ OpenLayers/StyleMap.js\n+ ====================================================================== */\n \n- /**\n- * Return an array of polygon arrays from a multipolygon.\n- * @param {OpenLayers.Geometry.MultiPolygon} multipolygon\n- * @returns {String} An array of polygon arrays representing\n- * the multipolygon\n- */\n- 'multipolygon': function(multipolygon) {\n- var array = [];\n- for (var i = 0, len = multipolygon.components.length; i < len; ++i) {\n- array.push('(' +\n- this.extract.polygon.apply(this, [multipolygon.components[i]]) +\n- ')');\n- }\n- return array.join(',');\n- },\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- /**\n- * Return the WKT portion between 'GEOMETRYCOLLECTION(' and ')' for an \n- * @param {OpenLayers.Geometry.Collection} collection\n- * @returns {String} internal WKT representation of the collection\n- */\n- 'collection': function(collection) {\n- var array = [];\n- for (var i = 0, len = collection.components.length; i < len; ++i) {\n- array.push(this.extractGeometry.apply(this, [collection.components[i]]));\n- }\n- return array.join(',');\n- }\n+/**\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Style.js\n+ * @requires OpenLayers/Feature/Vector.js\n+ */\n \n- },\n+/**\n+ * Class: OpenLayers.StyleMap\n+ */\n+OpenLayers.StyleMap = OpenLayers.Class({\n \n /**\n- * Object with properties corresponding to the geometry types.\n- * Property values are functions that do the actual parsing.\n+ * Property: styles\n+ * {Object} Hash of {}, keyed by names of well known\n+ * rendering intents (e.g. \"default\", \"temporary\", \"select\", \"delete\").\n */\n- parse: {\n- /**\n- * Return point feature given a point WKT fragment.\n- * @param {String} str A WKT fragment representing the point\n- * @returns {OpenLayers.Feature.Vector} A point feature\n- * @private\n- */\n- 'point': function(str) {\n- var coords = OpenLayers.String.trim(str).split(this.regExes.spaces);\n- return new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.Point(coords[0], coords[1])\n- );\n- },\n-\n- /**\n- * Return a multipoint feature given a multipoint WKT fragment.\n- * @param {String} str A WKT fragment representing the multipoint\n- * @returns {OpenLayers.Feature.Vector} A multipoint feature\n- * @private\n- */\n- 'multipoint': function(str) {\n- var point;\n- var points = OpenLayers.String.trim(str).split(',');\n- var components = [];\n- for (var i = 0, len = points.length; i < len; ++i) {\n- point = points[i].replace(this.regExes.trimParens, '$1');\n- components.push(this.parse.point.apply(this, [point]).geometry);\n- }\n- return new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.MultiPoint(components)\n- );\n- },\n+ styles: null,\n \n- /**\n- * Return a linestring feature given a linestring WKT fragment.\n- * @param {String} str A WKT fragment representing the linestring\n- * @returns {OpenLayers.Feature.Vector} A linestring feature\n- * @private\n- */\n- 'linestring': function(str) {\n- var points = OpenLayers.String.trim(str).split(',');\n- var components = [];\n- for (var i = 0, len = points.length; i < len; ++i) {\n- components.push(this.parse.point.apply(this, [points[i]]).geometry);\n- }\n- return new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.LineString(components)\n- );\n- },\n+ /**\n+ * Property: extendDefault\n+ * {Boolean} if true, every render intent will extend the symbolizers\n+ * specified for the \"default\" intent at rendering time. Otherwise, every\n+ * rendering intent will be treated as a completely independent style.\n+ */\n+ extendDefault: true,\n \n- /**\n- * Return a multilinestring feature given a multilinestring WKT fragment.\n- * @param {String} str A WKT fragment representing the multilinestring\n- * @returns {OpenLayers.Feature.Vector} A multilinestring feature\n- * @private\n- */\n- 'multilinestring': function(str) {\n- var line;\n- var lines = OpenLayers.String.trim(str).split(this.regExes.parenComma);\n- var components = [];\n- for (var i = 0, len = lines.length; i < len; ++i) {\n- line = lines[i].replace(this.regExes.trimParens, '$1');\n- components.push(this.parse.linestring.apply(this, [line]).geometry);\n- }\n- return new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.MultiLineString(components)\n- );\n- },\n+ /**\n+ * Constructor: OpenLayers.StyleMap\n+ * \n+ * Parameters:\n+ * style - {Object} Optional. Either a style hash, or a style object, or\n+ * a hash of style objects (style hashes) keyed by rendering\n+ * intent. If just one style hash or style object is passed,\n+ * this will be used for all known render intents (default,\n+ * select, temporary)\n+ * options - {Object} optional hash of additional options for this\n+ * instance\n+ */\n+ initialize: function(style, options) {\n+ this.styles = {\n+ \"default\": new OpenLayers.Style(\n+ OpenLayers.Feature.Vector.style[\"default\"]),\n+ \"select\": new OpenLayers.Style(\n+ OpenLayers.Feature.Vector.style[\"select\"]),\n+ \"temporary\": new OpenLayers.Style(\n+ OpenLayers.Feature.Vector.style[\"temporary\"]),\n+ \"delete\": new OpenLayers.Style(\n+ OpenLayers.Feature.Vector.style[\"delete\"])\n+ };\n \n- /**\n- * Return a polygon feature given a polygon WKT fragment.\n- * @param {String} str A WKT fragment representing the polygon\n- * @returns {OpenLayers.Feature.Vector} A polygon feature\n- * @private\n- */\n- 'polygon': function(str) {\n- var ring, linestring, linearring;\n- var rings = OpenLayers.String.trim(str).split(this.regExes.parenComma);\n- var components = [];\n- for (var i = 0, len = rings.length; i < len; ++i) {\n- ring = rings[i].replace(this.regExes.trimParens, '$1');\n- linestring = this.parse.linestring.apply(this, [ring]).geometry;\n- linearring = new OpenLayers.Geometry.LinearRing(linestring.components);\n- components.push(linearring);\n+ // take whatever the user passed as style parameter and convert it\n+ // into parts of stylemap.\n+ if (style instanceof OpenLayers.Style) {\n+ // user passed a style object\n+ this.styles[\"default\"] = style;\n+ this.styles[\"select\"] = style;\n+ this.styles[\"temporary\"] = style;\n+ this.styles[\"delete\"] = style;\n+ } else if (typeof style == \"object\") {\n+ for (var key in style) {\n+ if (style[key] instanceof OpenLayers.Style) {\n+ // user passed a hash of style objects\n+ this.styles[key] = style[key];\n+ } else if (typeof style[key] == \"object\") {\n+ // user passsed a hash of style hashes\n+ this.styles[key] = new OpenLayers.Style(style[key]);\n+ } else {\n+ // user passed a style hash (i.e. symbolizer)\n+ this.styles[\"default\"] = new OpenLayers.Style(style);\n+ this.styles[\"select\"] = new OpenLayers.Style(style);\n+ this.styles[\"temporary\"] = new OpenLayers.Style(style);\n+ this.styles[\"delete\"] = new OpenLayers.Style(style);\n+ break;\n+ }\n }\n- return new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.Polygon(components)\n- );\n- },\n+ }\n+ OpenLayers.Util.extend(this, options);\n+ },\n \n- /**\n- * Return a multipolygon feature given a multipolygon WKT fragment.\n- * @param {String} str A WKT fragment representing the multipolygon\n- * @returns {OpenLayers.Feature.Vector} A multipolygon feature\n- * @private\n- */\n- 'multipolygon': function(str) {\n- var polygon;\n- var polygons = OpenLayers.String.trim(str).split(this.regExes.doubleParenComma);\n- var components = [];\n- for (var i = 0, len = polygons.length; i < len; ++i) {\n- polygon = polygons[i].replace(this.regExes.trimParens, '$1');\n- components.push(this.parse.polygon.apply(this, [polygon]).geometry);\n- }\n- return new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.MultiPolygon(components)\n- );\n- },\n+ /**\n+ * Method: destroy\n+ */\n+ destroy: function() {\n+ for (var key in this.styles) {\n+ this.styles[key].destroy();\n+ }\n+ this.styles = null;\n+ },\n \n- /**\n- * Return an array of features given a geometrycollection WKT fragment.\n- * @param {String} str A WKT fragment representing the geometrycollection\n- * @returns {Array} An array of OpenLayers.Feature.Vector\n- * @private\n- */\n- 'geometrycollection': function(str) {\n- // separate components of the collection with |\n- str = str.replace(/,\\s*([A-Za-z])/g, '|$1');\n- var wktArray = OpenLayers.String.trim(str).split('|');\n- var components = [];\n- for (var i = 0, len = wktArray.length; i < len; ++i) {\n- components.push(OpenLayers.Format.WKT.prototype.read.apply(this, [wktArray[i]]));\n- }\n- return components;\n+ /**\n+ * Method: createSymbolizer\n+ * Creates the symbolizer for a feature for a render intent.\n+ * \n+ * Parameters:\n+ * feature - {} The feature to evaluate the rules\n+ * of the intended style against.\n+ * intent - {String} The intent determines the symbolizer that will be\n+ * used to draw the feature. Well known intents are \"default\"\n+ * (for just drawing the features), \"select\" (for selected\n+ * features) and \"temporary\" (for drawing features).\n+ * \n+ * Returns:\n+ * {Object} symbolizer hash\n+ */\n+ createSymbolizer: function(feature, intent) {\n+ if (!feature) {\n+ feature = new OpenLayers.Feature.Vector();\n+ }\n+ if (!this.styles[intent]) {\n+ intent = \"default\";\n+ }\n+ feature.renderIntent = intent;\n+ var defaultSymbolizer = {};\n+ if (this.extendDefault && intent != \"default\") {\n+ defaultSymbolizer = this.styles[\"default\"].createSymbolizer(feature);\n }\n+ return OpenLayers.Util.extend(defaultSymbolizer,\n+ this.styles[intent].createSymbolizer(feature));\n+ },\n \n+ /**\n+ * Method: addUniqueValueRules\n+ * Convenience method to create comparison rules for unique values of a\n+ * property. The rules will be added to the style object for a specified\n+ * rendering intent. This method is a shortcut for creating something like\n+ * the \"unique value legends\" familiar from well known desktop GIS systems\n+ * \n+ * Parameters:\n+ * renderIntent - {String} rendering intent to add the rules to\n+ * property - {String} values of feature attributes to create the\n+ * rules for\n+ * symbolizers - {Object} Hash of symbolizers, keyed by the desired\n+ * property values \n+ * context - {Object} An optional object with properties that\n+ * symbolizers' property values should be evaluated\n+ * against. If no context is specified, feature.attributes\n+ * will be used\n+ */\n+ addUniqueValueRules: function(renderIntent, property, symbolizers, context) {\n+ var rules = [];\n+ for (var value in symbolizers) {\n+ rules.push(new OpenLayers.Rule({\n+ symbolizer: symbolizers[value],\n+ context: context,\n+ filter: new OpenLayers.Filter.Comparison({\n+ type: OpenLayers.Filter.Comparison.EQUAL_TO,\n+ property: property,\n+ value: value\n+ })\n+ }));\n+ }\n+ this.styles[renderIntent].addRules(rules);\n },\n \n- CLASS_NAME: \"OpenLayers.Format.WKT\"\n+ CLASS_NAME: \"OpenLayers.StyleMap\"\n });\n /* ======================================================================\n- OpenLayers/Format/JSON.js\n+ OpenLayers/Control.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * Note:\n- * This work draws heavily from the public domain JSON serializer/deserializer\n- * at http://www.json.org/json.js. Rewritten so that it doesn't modify\n- * basic data prototypes.\n- */\n-\n-/**\n- * @requires OpenLayers/Format.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n */\n \n /**\n- * Class: OpenLayers.Format.JSON\n- * A parser to read/write JSON safely. Create a new instance with the\n- * constructor.\n+ * Class: OpenLayers.Control\n+ * Controls affect the display or behavior of the map. They allow everything\n+ * from panning and zooming to displaying a scale indicator. Controls by \n+ * default are added to the map they are contained within however it is\n+ * possible to add a control to an external div by passing the div in the\n+ * options parameter.\n+ * \n+ * Example:\n+ * The following example shows how to add many of the common controls\n+ * to a map.\n+ * \n+ * > var map = new OpenLayers.Map('map', { controls: [] });\n+ * >\n+ * > map.addControl(new OpenLayers.Control.PanZoomBar());\n+ * > map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false}));\n+ * > map.addControl(new OpenLayers.Control.Permalink());\n+ * > map.addControl(new OpenLayers.Control.Permalink('permalink'));\n+ * > map.addControl(new OpenLayers.Control.MousePosition());\n+ * > map.addControl(new OpenLayers.Control.OverviewMap());\n+ * > map.addControl(new OpenLayers.Control.KeyboardDefaults());\n *\n- * Inherits from:\n- * - \n+ * The next code fragment is a quick example of how to intercept \n+ * shift-mouse click to display the extent of the bounding box\n+ * dragged out by the user. Usually controls are not created\n+ * in exactly this manner. See the source for a more complete \n+ * example:\n+ *\n+ * > var control = new OpenLayers.Control();\n+ * > OpenLayers.Util.extend(control, {\n+ * > draw: function () {\n+ * > // this Handler.Box will intercept the shift-mousedown\n+ * > // before Control.MouseDefault gets to see it\n+ * > this.box = new OpenLayers.Handler.Box( control, \n+ * > {\"done\": this.notice},\n+ * > {keyMask: OpenLayers.Handler.MOD_SHIFT});\n+ * > this.box.activate();\n+ * > },\n+ * >\n+ * > notice: function (bounds) {\n+ * > OpenLayers.Console.userError(bounds);\n+ * > }\n+ * > }); \n+ * > map.addControl(control);\n+ * \n */\n-OpenLayers.Format.JSON = OpenLayers.Class(OpenLayers.Format, {\n+OpenLayers.Control = OpenLayers.Class({\n \n- /**\n- * APIProperty: indent\n- * {String} For \"pretty\" printing, the indent string will be used once for\n- * each indentation level.\n+ /** \n+ * Property: id \n+ * {String} \n */\n- indent: \" \",\n+ id: null,\n \n- /**\n- * APIProperty: space\n- * {String} For \"pretty\" printing, the space string will be used after\n- * the \":\" separating a name/value pair.\n+ /** \n+ * Property: map \n+ * {} this gets set in the addControl() function in\n+ * OpenLayers.Map \n */\n- space: \" \",\n+ map: null,\n \n- /**\n- * APIProperty: newline\n- * {String} For \"pretty\" printing, the newline string will be used at the\n- * end of each name/value pair or array item.\n+ /** \n+ * APIProperty: div \n+ * {DOMElement} The element that contains the control, if not present the \n+ * control is placed inside the map.\n */\n- newline: \"\\n\",\n+ div: null,\n+\n+ /** \n+ * APIProperty: type \n+ * {Number} Controls can have a 'type'. The type determines the type of\n+ * interactions which are possible with them when they are placed in an\n+ * . \n+ */\n+ type: null,\n+\n+ /** \n+ * Property: allowSelection\n+ * {Boolean} By default, controls do not allow selection, because\n+ * it may interfere with map dragging. If this is true, OpenLayers\n+ * will not prevent selection of the control.\n+ * Default is false.\n+ */\n+ allowSelection: false,\n+\n+ /** \n+ * Property: displayClass \n+ * {string} This property is used for CSS related to the drawing of the\n+ * Control. \n+ */\n+ displayClass: \"\",\n \n /**\n- * Property: level\n- * {Integer} For \"pretty\" printing, this is incremented/decremented during\n- * serialization.\n+ * APIProperty: title \n+ * {string} This property is used for showing a tooltip over the \n+ * Control. \n */\n- level: 0,\n+ title: \"\",\n \n /**\n- * Property: pretty\n- * {Boolean} Serialize with extra whitespace for structure. This is set\n- * by the method.\n+ * APIProperty: autoActivate\n+ * {Boolean} Activate the control when it is added to a map. Default is\n+ * false.\n */\n- pretty: false,\n+ autoActivate: false,\n+\n+ /** \n+ * APIProperty: active \n+ * {Boolean} The control is active (read-only). Use and \n+ * to change control state.\n+ */\n+ active: null,\n \n /**\n- * Property: nativeJSON\n- * {Boolean} Does the browser support native json?\n+ * Property: handlerOptions\n+ * {Object} Used to set non-default properties on the control's handler\n */\n- nativeJSON: (function() {\n- return !!(window.JSON && typeof JSON.parse == \"function\" && typeof JSON.stringify == \"function\");\n- })(),\n+ handlerOptions: null,\n+\n+ /** \n+ * Property: handler \n+ * {} null\n+ */\n+ handler: null,\n \n /**\n- * Constructor: OpenLayers.Format.JSON\n- * Create a new parser for JSON.\n+ * APIProperty: eventListeners\n+ * {Object} If set as an option at construction, the eventListeners\n+ * object will be registered with . Object\n+ * structure must be a listeners object as shown in the example for\n+ * the events.on method.\n+ */\n+ eventListeners: null,\n+\n+ /** \n+ * APIProperty: events\n+ * {} Events instance for listeners and triggering\n+ * control specific events.\n *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * control.events.register(type, obj, listener);\n+ * (end)\n+ *\n+ * Listeners will be called with a reference to an event object. The\n+ * properties of this event depends on exactly what happened.\n+ *\n+ * All event objects have at least the following properties:\n+ * object - {Object} A reference to control.events.object (a reference\n+ * to the control).\n+ * element - {DOMElement} A reference to control.events.element (which\n+ * will be null unless documented otherwise).\n+ *\n+ * Supported map event types:\n+ * activate - Triggered when activated.\n+ * deactivate - Triggered when deactivated.\n */\n+ events: null,\n \n /**\n- * APIMethod: read\n- * Deserialize a json string.\n+ * Constructor: OpenLayers.Control\n+ * Create an OpenLayers Control. The options passed as a parameter\n+ * directly extend the control. For example passing the following:\n+ * \n+ * > var control = new OpenLayers.Control({div: myDiv});\n *\n+ * Overrides the default div attribute value of null.\n+ * \n * Parameters:\n- * json - {String} A JSON string\n- * filter - {Function} A function which will be called for every key and\n- * value at every level of the final result. Each value will be\n- * replaced by the result of the filter function. This can be used to\n- * reform generic objects into instances of classes, or to transform\n- * date strings into Date objects.\n- * \n- * Returns:\n- * {Object} An object, array, string, or number .\n+ * options - {Object} \n */\n- read: function(json, filter) {\n- var object;\n- if (this.nativeJSON) {\n- object = JSON.parse(json, filter);\n- } else try {\n- /**\n- * Parsing happens in three stages. In the first stage, we run the\n- * text against a regular expression which looks for non-JSON\n- * characters. We are especially concerned with '()' and 'new'\n- * because they can cause invocation, and '=' because it can\n- * cause mutation. But just to be safe, we will reject all\n- * unexpected characters.\n- */\n- if (/^[\\],:{}\\s]*$/.test(json.replace(/\\\\[\"\\\\\\/bfnrtu]/g, '@').replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']').replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n+ initialize: function(options) {\n+ // We do this before the extend so that instances can override\n+ // className in options.\n+ this.displayClass =\n+ this.CLASS_NAME.replace(\"OpenLayers.\", \"ol\").replace(/\\./g, \"\");\n \n- /**\n- * In the second stage we use the eval function to compile the\n- * text into a JavaScript structure. The '{' operator is\n- * subject to a syntactic ambiguity in JavaScript - it can\n- * begin a block or an object literal. We wrap the text in\n- * parens to eliminate the ambiguity.\n- */\n- object = eval('(' + json + ')');\n+ OpenLayers.Util.extend(this, options);\n \n- /**\n- * In the optional third stage, we recursively walk the new\n- * structure, passing each name/value pair to a filter\n- * function for possible transformation.\n- */\n- if (typeof filter === 'function') {\n- function walk(k, v) {\n- if (v && typeof v === 'object') {\n- for (var i in v) {\n- if (v.hasOwnProperty(i)) {\n- v[i] = walk(i, v[i]);\n- }\n- }\n- }\n- return filter(k, v);\n- }\n- object = walk('', object);\n- }\n- }\n- } catch (e) {\n- // Fall through if the regexp test fails.\n+ this.events = new OpenLayers.Events(this);\n+ if (this.eventListeners instanceof Object) {\n+ this.events.on(this.eventListeners);\n+ }\n+ if (this.id == null) {\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n }\n+ },\n \n- if (this.keepData) {\n- this.data = object;\n+ /**\n+ * Method: destroy\n+ * The destroy method is used to perform any clean up before the control\n+ * is dereferenced. Typically this is where event listeners are removed\n+ * to prevent memory leaks.\n+ */\n+ destroy: function() {\n+ if (this.events) {\n+ if (this.eventListeners) {\n+ this.events.un(this.eventListeners);\n+ }\n+ this.events.destroy();\n+ this.events = null;\n }\n+ this.eventListeners = null;\n \n- return object;\n+ // eliminate circular references\n+ if (this.handler) {\n+ this.handler.destroy();\n+ this.handler = null;\n+ }\n+ if (this.handlers) {\n+ for (var key in this.handlers) {\n+ if (this.handlers.hasOwnProperty(key) &&\n+ typeof this.handlers[key].destroy == \"function\") {\n+ this.handlers[key].destroy();\n+ }\n+ }\n+ this.handlers = null;\n+ }\n+ if (this.map) {\n+ this.map.removeControl(this);\n+ this.map = null;\n+ }\n+ this.div = null;\n },\n \n- /**\n- * APIMethod: write\n- * Serialize an object into a JSON string.\n+ /** \n+ * Method: setMap\n+ * Set the map property for the control. This is done through an accessor\n+ * so that subclasses can override this and take special action once \n+ * they have their map variable set. \n *\n * Parameters:\n- * value - {String} The object, array, string, number, boolean or date\n- * to be serialized.\n- * pretty - {Boolean} Structure the output with newlines and indentation.\n- * Default is false.\n- *\n- * Returns:\n- * {String} The JSON string representation of the input value.\n+ * map - {} \n */\n- write: function(value, pretty) {\n- this.pretty = !!pretty;\n- var json = null;\n- var type = typeof value;\n- if (this.serialize[type]) {\n- try {\n- json = (!this.pretty && this.nativeJSON) ?\n- JSON.stringify(value) :\n- this.serialize[type].apply(this, [value]);\n- } catch (err) {\n- OpenLayers.Console.error(\"Trouble serializing: \" + err);\n- }\n+ setMap: function(map) {\n+ this.map = map;\n+ if (this.handler) {\n+ this.handler.setMap(map);\n }\n- return json;\n },\n \n /**\n- * Method: writeIndent\n- * Output an indentation string depending on the indentation level.\n+ * Method: draw\n+ * The draw method is called when the control is ready to be displayed\n+ * on the page. If a div has not been created one is created. Controls\n+ * with a visual component will almost always want to override this method \n+ * to customize the look of control. \n+ *\n+ * Parameters:\n+ * px - {} The top-left pixel position of the control\n+ * or null.\n *\n * Returns:\n- * {String} An appropriate indentation string.\n+ * {DOMElement} A reference to the DIV DOMElement containing the control\n */\n- writeIndent: function() {\n- var pieces = [];\n- if (this.pretty) {\n- for (var i = 0; i < this.level; ++i) {\n- pieces.push(this.indent);\n+ draw: function(px) {\n+ if (this.div == null) {\n+ this.div = OpenLayers.Util.createDiv(this.id);\n+ this.div.className = this.displayClass;\n+ if (!this.allowSelection) {\n+ this.div.className += \" olControlNoSelect\";\n+ this.div.setAttribute(\"unselectable\", \"on\", 0);\n+ this.div.onselectstart = OpenLayers.Function.False;\n+ }\n+ if (this.title != \"\") {\n+ this.div.title = this.title;\n }\n }\n- return pieces.join('');\n+ if (px != null) {\n+ this.position = px.clone();\n+ }\n+ this.moveTo(this.position);\n+ return this.div;\n },\n \n /**\n- * Method: writeNewline\n- * Output a string representing a newline if in pretty printing mode.\n+ * Method: moveTo\n+ * Sets the left and top style attributes to the passed in pixel \n+ * coordinates.\n *\n- * Returns:\n- * {String} A string representing a new line.\n+ * Parameters:\n+ * px - {}\n */\n- writeNewline: function() {\n- return (this.pretty) ? this.newline : '';\n+ moveTo: function(px) {\n+ if ((px != null) && (this.div != null)) {\n+ this.div.style.left = px.x + \"px\";\n+ this.div.style.top = px.y + \"px\";\n+ }\n },\n \n /**\n- * Method: writeSpace\n- * Output a string representing a space if in pretty printing mode.\n- *\n+ * APIMethod: activate\n+ * Explicitly activates a control and it's associated\n+ * handler if one has been set. Controls can be\n+ * deactivated by calling the deactivate() method.\n+ * \n * Returns:\n- * {String} A space.\n+ * {Boolean} True if the control was successfully activated or\n+ * false if the control was already active.\n */\n- writeSpace: function() {\n- return (this.pretty) ? this.space : '';\n+ activate: function() {\n+ if (this.active) {\n+ return false;\n+ }\n+ if (this.handler) {\n+ this.handler.activate();\n+ }\n+ this.active = true;\n+ if (this.map) {\n+ OpenLayers.Element.addClass(\n+ this.map.viewPortDiv,\n+ this.displayClass.replace(/ /g, \"\") + \"Active\"\n+ );\n+ }\n+ this.events.triggerEvent(\"activate\");\n+ return true;\n },\n \n /**\n- * Property: serialize\n- * Object with properties corresponding to the serializable data types.\n- * Property values are functions that do the actual serializing.\n+ * APIMethod: deactivate\n+ * Deactivates a control and it's associated handler if any. The exact\n+ * effect of this depends on the control itself.\n+ * \n+ * Returns:\n+ * {Boolean} True if the control was effectively deactivated or false\n+ * if the control was already inactive.\n */\n- serialize: {\n- /**\n- * Method: serialize.object\n- * Transform an object into a JSON string.\n- *\n- * Parameters:\n- * object - {Object} The object to be serialized.\n- * \n- * Returns:\n- * {String} A JSON string representing the object.\n- */\n- 'object': function(object) {\n- // three special objects that we want to treat differently\n- if (object == null) {\n- return \"null\";\n- }\n- if (object.constructor == Date) {\n- return this.serialize.date.apply(this, [object]);\n- }\n- if (object.constructor == Array) {\n- return this.serialize.array.apply(this, [object]);\n- }\n- var pieces = ['{'];\n- this.level += 1;\n- var key, keyJSON, valueJSON;\n-\n- var addComma = false;\n- for (key in object) {\n- if (object.hasOwnProperty(key)) {\n- // recursive calls need to allow for sub-classing\n- keyJSON = OpenLayers.Format.JSON.prototype.write.apply(this,\n- [key, this.pretty]);\n- valueJSON = OpenLayers.Format.JSON.prototype.write.apply(this,\n- [object[key], this.pretty]);\n- if (keyJSON != null && valueJSON != null) {\n- if (addComma) {\n- pieces.push(',');\n- }\n- pieces.push(this.writeNewline(), this.writeIndent(),\n- keyJSON, ':', this.writeSpace(), valueJSON);\n- addComma = true;\n- }\n- }\n- }\n-\n- this.level -= 1;\n- pieces.push(this.writeNewline(), this.writeIndent(), '}');\n- return pieces.join('');\n- },\n-\n- /**\n- * Method: serialize.array\n- * Transform an array into a JSON string.\n- *\n- * Parameters:\n- * array - {Array} The array to be serialized\n- * \n- * Returns:\n- * {String} A JSON string representing the array.\n- */\n- 'array': function(array) {\n- var json;\n- var pieces = ['['];\n- this.level += 1;\n-\n- for (var i = 0, len = array.length; i < len; ++i) {\n- // recursive calls need to allow for sub-classing\n- json = OpenLayers.Format.JSON.prototype.write.apply(this,\n- [array[i], this.pretty]);\n- if (json != null) {\n- if (i > 0) {\n- pieces.push(',');\n- }\n- pieces.push(this.writeNewline(), this.writeIndent(), json);\n- }\n- }\n-\n- this.level -= 1;\n- pieces.push(this.writeNewline(), this.writeIndent(), ']');\n- return pieces.join('');\n- },\n-\n- /**\n- * Method: serialize.string\n- * Transform a string into a JSON string.\n- *\n- * Parameters:\n- * string - {String} The string to be serialized\n- * \n- * Returns:\n- * {String} A JSON string representing the string.\n- */\n- 'string': function(string) {\n- // If the string contains no control characters, no quote characters, and no\n- // backslash characters, then we can simply slap some quotes around it.\n- // Otherwise we must also replace the offending characters with safe\n- // sequences. \n- var m = {\n- '\\b': '\\\\b',\n- '\\t': '\\\\t',\n- '\\n': '\\\\n',\n- '\\f': '\\\\f',\n- '\\r': '\\\\r',\n- '\"': '\\\\\"',\n- '\\\\': '\\\\\\\\'\n- };\n- if (/[\"\\\\\\x00-\\x1f]/.test(string)) {\n- return '\"' + string.replace(/([\\x00-\\x1f\\\\\"])/g, function(a, b) {\n- var c = m[b];\n- if (c) {\n- return c;\n- }\n- c = b.charCodeAt();\n- return '\\\\u00' +\n- Math.floor(c / 16).toString(16) +\n- (c % 16).toString(16);\n- }) + '\"';\n+ deactivate: function() {\n+ if (this.active) {\n+ if (this.handler) {\n+ this.handler.deactivate();\n }\n- return '\"' + string + '\"';\n- },\n-\n- /**\n- * Method: serialize.number\n- * Transform a number into a JSON string.\n- *\n- * Parameters:\n- * number - {Number} The number to be serialized.\n- *\n- * Returns:\n- * {String} A JSON string representing the number.\n- */\n- 'number': function(number) {\n- return isFinite(number) ? String(number) : \"null\";\n- },\n-\n- /**\n- * Method: serialize.boolean\n- * Transform a boolean into a JSON string.\n- *\n- * Parameters:\n- * bool - {Boolean} The boolean to be serialized.\n- * \n- * Returns:\n- * {String} A JSON string representing the boolean.\n- */\n- 'boolean': function(bool) {\n- return String(bool);\n- },\n-\n- /**\n- * Method: serialize.object\n- * Transform a date into a JSON string.\n- *\n- * Parameters:\n- * date - {Date} The date to be serialized.\n- * \n- * Returns:\n- * {String} A JSON string representing the date.\n- */\n- 'date': function(date) {\n- function format(number) {\n- // Format integers to have at least two digits.\n- return (number < 10) ? '0' + number : number;\n+ this.active = false;\n+ if (this.map) {\n+ OpenLayers.Element.removeClass(\n+ this.map.viewPortDiv,\n+ this.displayClass.replace(/ /g, \"\") + \"Active\"\n+ );\n }\n- return '\"' + date.getFullYear() + '-' +\n- format(date.getMonth() + 1) + '-' +\n- format(date.getDate()) + 'T' +\n- format(date.getHours()) + ':' +\n- format(date.getMinutes()) + ':' +\n- format(date.getSeconds()) + '\"';\n+ this.events.triggerEvent(\"deactivate\");\n+ return true;\n }\n+ return false;\n },\n \n- CLASS_NAME: \"OpenLayers.Format.JSON\"\n-\n+ CLASS_NAME: \"OpenLayers.Control\"\n });\n+\n+/**\n+ * Constant: OpenLayers.Control.TYPE_BUTTON\n+ */\n+OpenLayers.Control.TYPE_BUTTON = 1;\n+\n+/**\n+ * Constant: OpenLayers.Control.TYPE_TOGGLE\n+ */\n+OpenLayers.Control.TYPE_TOGGLE = 2;\n+\n+/**\n+ * Constant: OpenLayers.Control.TYPE_TOOL\n+ */\n+OpenLayers.Control.TYPE_TOOL = 3;\n /* ======================================================================\n- OpenLayers/Format/GeoJSON.js\n+ OpenLayers/Icon.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format/JSON.js\n- * @requires OpenLayers/Feature/Vector.js\n- * @requires OpenLayers/Geometry/Point.js\n- * @requires OpenLayers/Geometry/MultiPoint.js\n- * @requires OpenLayers/Geometry/LineString.js\n- * @requires OpenLayers/Geometry/MultiLineString.js\n- * @requires OpenLayers/Geometry/Polygon.js\n- * @requires OpenLayers/Geometry/MultiPolygon.js\n- * @requires OpenLayers/Console.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n */\n \n /**\n- * Class: OpenLayers.Format.GeoJSON\n- * Read and write GeoJSON. Create a new parser with the\n- * constructor.\n+ * Class: OpenLayers.Icon\n+ * \n+ * The icon represents a graphical icon on the screen. Typically used in\n+ * conjunction with a to represent markers on a screen.\n *\n- * Inherits from:\n- * - \n+ * An icon has a url, size and position. It also contains an offset which \n+ * allows the center point to be represented correctly. This can be\n+ * provided either as a fixed offset or a function provided to calculate\n+ * the desired offset. \n+ * \n */\n-OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {\n+OpenLayers.Icon = OpenLayers.Class({\n \n- /**\n- * APIProperty: ignoreExtraDims\n- * {Boolean} Ignore dimensions higher than 2 when reading geometry\n- * coordinates.\n+ /** \n+ * Property: url \n+ * {String} image url\n */\n- ignoreExtraDims: false,\n+ url: null,\n \n- /**\n- * Constructor: OpenLayers.Format.GeoJSON\n- * Create a new parser for GeoJSON.\n- *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ /** \n+ * Property: size \n+ * {|Object} An OpenLayers.Size or\n+ * an object with a 'w' and 'h' properties.\n */\n+ size: null,\n \n- /**\n- * APIMethod: read\n- * Deserialize a GeoJSON string.\n- *\n- * Parameters:\n- * json - {String} A GeoJSON string\n- * type - {String} Optional string that determines the structure of\n- * the output. Supported values are \"Geometry\", \"Feature\", and\n- * \"FeatureCollection\". If absent or null, a default of\n- * \"FeatureCollection\" is assumed.\n- * filter - {Function} A function which will be called for every key and\n- * value at every level of the final result. Each value will be\n- * replaced by the result of the filter function. This can be used to\n- * reform generic objects into instances of classes, or to transform\n- * date strings into Date objects.\n+ /** \n+ * Property: offset \n+ * {|Object} distance in pixels to offset the\n+ * image when being rendered. An OpenLayers.Pixel or an object\n+ * with a 'x' and 'y' properties.\n+ */\n+ offset: null,\n+\n+ /** \n+ * Property: calculateOffset \n+ * {Function} Function to calculate the offset (based on the size)\n+ */\n+ calculateOffset: null,\n+\n+ /** \n+ * Property: imageDiv \n+ * {DOMElement} \n+ */\n+ imageDiv: null,\n+\n+ /** \n+ * Property: px \n+ * {|Object} An OpenLayers.Pixel or an object\n+ * with a 'x' and 'y' properties.\n+ */\n+ px: null,\n+\n+ /** \n+ * Constructor: OpenLayers.Icon\n+ * Creates an icon, which is an image tag in a div. \n *\n- * Returns: \n- * {Object} The return depends on the value of the type argument. If type\n- * is \"FeatureCollection\" (the default), the return will be an array\n- * of . If type is \"Geometry\", the input json\n- * must represent a single geometry, and the return will be an\n- * . If type is \"Feature\", the input json must\n- * represent a single feature, and the return will be an\n- * .\n+ * url - {String} \n+ * size - {|Object} An OpenLayers.Size or an\n+ * object with a 'w' and 'h'\n+ * properties.\n+ * offset - {|Object} An OpenLayers.Pixel or an\n+ * object with a 'x' and 'y'\n+ * properties.\n+ * calculateOffset - {Function} \n */\n- read: function(json, type, filter) {\n- type = (type) ? type : \"FeatureCollection\";\n- var results = null;\n- var obj = null;\n- if (typeof json == \"string\") {\n- obj = OpenLayers.Format.JSON.prototype.read.apply(this,\n- [json, filter]);\n- } else {\n- obj = json;\n- }\n- if (!obj) {\n- OpenLayers.Console.error(\"Bad JSON: \" + json);\n- } else if (typeof(obj.type) != \"string\") {\n- OpenLayers.Console.error(\"Bad GeoJSON - no type: \" + json);\n- } else if (this.isValidType(obj, type)) {\n- switch (type) {\n- case \"Geometry\":\n- try {\n- results = this.parseGeometry(obj);\n- } catch (err) {\n- OpenLayers.Console.error(err);\n- }\n- break;\n- case \"Feature\":\n- try {\n- results = this.parseFeature(obj);\n- results.type = \"Feature\";\n- } catch (err) {\n- OpenLayers.Console.error(err);\n- }\n- break;\n- case \"FeatureCollection\":\n- // for type FeatureCollection, we allow input to be any type\n- results = [];\n- switch (obj.type) {\n- case \"Feature\":\n- try {\n- results.push(this.parseFeature(obj));\n- } catch (err) {\n- results = null;\n- OpenLayers.Console.error(err);\n- }\n- break;\n- case \"FeatureCollection\":\n- for (var i = 0, len = obj.features.length; i < len; ++i) {\n- try {\n- results.push(this.parseFeature(obj.features[i]));\n- } catch (err) {\n- results = null;\n- OpenLayers.Console.error(err);\n- }\n- }\n- break;\n- default:\n- try {\n- var geom = this.parseGeometry(obj);\n- results.push(new OpenLayers.Feature.Vector(geom));\n- } catch (err) {\n- results = null;\n- OpenLayers.Console.error(err);\n- }\n- }\n- break;\n- }\n- }\n- return results;\n+ initialize: function(url, size, offset, calculateOffset) {\n+ this.url = url;\n+ this.size = size || {\n+ w: 20,\n+ h: 20\n+ };\n+ this.offset = offset || {\n+ x: -(this.size.w / 2),\n+ y: -(this.size.h / 2)\n+ };\n+ this.calculateOffset = calculateOffset;\n+\n+ var id = OpenLayers.Util.createUniqueID(\"OL_Icon_\");\n+ this.imageDiv = OpenLayers.Util.createAlphaImageDiv(id);\n },\n \n- /**\n- * Method: isValidType\n- * Check if a GeoJSON object is a valid representative of the given type.\n- *\n+ /** \n+ * Method: destroy\n+ * Nullify references and remove event listeners to prevent circular \n+ * references and memory leaks\n+ */\n+ destroy: function() {\n+ // erase any drawn elements\n+ this.erase();\n+\n+ OpenLayers.Event.stopObservingElement(this.imageDiv.firstChild);\n+ this.imageDiv.innerHTML = \"\";\n+ this.imageDiv = null;\n+ },\n+\n+ /** \n+ * Method: clone\n+ * \n * Returns:\n- * {Boolean} The object is valid GeoJSON object of the given type.\n+ * {} A fresh copy of the icon.\n */\n- isValidType: function(obj, type) {\n- var valid = false;\n- switch (type) {\n- case \"Geometry\":\n- if (OpenLayers.Util.indexOf(\n- [\"Point\", \"MultiPoint\", \"LineString\", \"MultiLineString\",\n- \"Polygon\", \"MultiPolygon\", \"Box\", \"GeometryCollection\"\n- ],\n- obj.type) == -1) {\n- // unsupported geometry type\n- OpenLayers.Console.error(\"Unsupported geometry type: \" +\n- obj.type);\n- } else {\n- valid = true;\n- }\n- break;\n- case \"FeatureCollection\":\n- // allow for any type to be converted to a feature collection\n- valid = true;\n- break;\n- default:\n- // for Feature types must match\n- if (obj.type == type) {\n- valid = true;\n- } else {\n- OpenLayers.Console.error(\"Cannot convert types from \" +\n- obj.type + \" to \" + type);\n- }\n- }\n- return valid;\n+ clone: function() {\n+ return new OpenLayers.Icon(this.url,\n+ this.size,\n+ this.offset,\n+ this.calculateOffset);\n },\n \n /**\n- * Method: parseFeature\n- * Convert a feature object from GeoJSON into an\n- * .\n- *\n+ * Method: setSize\n+ * \n * Parameters:\n- * obj - {Object} An object created from a GeoJSON object\n- *\n- * Returns:\n- * {} A feature.\n+ * size - {|Object} An OpenLayers.Size or\n+ * an object with a 'w' and 'h' properties.\n */\n- parseFeature: function(obj) {\n- var feature, geometry, attributes, bbox;\n- attributes = (obj.properties) ? obj.properties : {};\n- bbox = (obj.geometry && obj.geometry.bbox) || obj.bbox;\n- try {\n- geometry = this.parseGeometry(obj.geometry);\n- } catch (err) {\n- // deal with bad geometries\n- throw err;\n- }\n- feature = new OpenLayers.Feature.Vector(geometry, attributes);\n- if (bbox) {\n- feature.bounds = OpenLayers.Bounds.fromArray(bbox);\n- }\n- if (obj.id) {\n- feature.fid = obj.id;\n+ setSize: function(size) {\n+ if (size != null) {\n+ this.size = size;\n }\n- return feature;\n+ this.draw();\n },\n \n /**\n- * Method: parseGeometry\n- * Convert a geometry object from GeoJSON into an .\n- *\n+ * Method: setUrl\n+ * \n * Parameters:\n- * obj - {Object} An object created from a GeoJSON object\n- *\n- * Returns: \n- * {} A geometry.\n+ * url - {String} \n */\n- parseGeometry: function(obj) {\n- if (obj == null) {\n- return null;\n- }\n- var geometry, collection = false;\n- if (obj.type == \"GeometryCollection\") {\n- if (!(OpenLayers.Util.isArray(obj.geometries))) {\n- throw \"GeometryCollection must have geometries array: \" + obj;\n- }\n- var numGeom = obj.geometries.length;\n- var components = new Array(numGeom);\n- for (var i = 0; i < numGeom; ++i) {\n- components[i] = this.parseGeometry.apply(\n- this, [obj.geometries[i]]\n- );\n- }\n- geometry = new OpenLayers.Geometry.Collection(components);\n- collection = true;\n- } else {\n- if (!(OpenLayers.Util.isArray(obj.coordinates))) {\n- throw \"Geometry must have coordinates array: \" + obj;\n- }\n- if (!this.parseCoords[obj.type.toLowerCase()]) {\n- throw \"Unsupported geometry type: \" + obj.type;\n- }\n- try {\n- geometry = this.parseCoords[obj.type.toLowerCase()].apply(\n- this, [obj.coordinates]\n- );\n- } catch (err) {\n- // deal with bad coordinates\n- throw err;\n- }\n- }\n- // We don't reproject collections because the children are reprojected\n- // for us when they are created.\n- if (this.internalProjection && this.externalProjection && !collection) {\n- geometry.transform(this.externalProjection,\n- this.internalProjection);\n+ setUrl: function(url) {\n+ if (url != null) {\n+ this.url = url;\n }\n- return geometry;\n+ this.draw();\n },\n \n- /**\n- * Property: parseCoords\n- * Object with properties corresponding to the GeoJSON geometry types.\n- * Property values are functions that do the actual parsing.\n+ /** \n+ * Method: draw\n+ * Move the div to the given pixel.\n+ * \n+ * Parameters:\n+ * px - {|Object} An OpenLayers.Pixel or an\n+ * object with a 'x' and 'y' properties.\n+ * \n+ * Returns:\n+ * {DOMElement} A new DOM Image of this icon set at the location passed-in\n */\n- parseCoords: {\n- /**\n- * Method: parseCoords.point\n- * Convert a coordinate array from GeoJSON into an\n- * .\n- *\n- * Parameters:\n- * array - {Object} The coordinates array from the GeoJSON fragment.\n- *\n- * Returns:\n- * {} A geometry.\n- */\n- \"point\": function(array) {\n- if (this.ignoreExtraDims == false &&\n- array.length != 2) {\n- throw \"Only 2D points are supported: \" + array;\n- }\n- return new OpenLayers.Geometry.Point(array[0], array[1]);\n- },\n-\n- /**\n- * Method: parseCoords.multipoint\n- * Convert a coordinate array from GeoJSON into an\n- * .\n- *\n- * Parameters:\n- * array - {Object} The coordinates array from the GeoJSON fragment.\n- *\n- * Returns:\n- * {} A geometry.\n- */\n- \"multipoint\": function(array) {\n- var points = [];\n- var p = null;\n- for (var i = 0, len = array.length; i < len; ++i) {\n- try {\n- p = this.parseCoords[\"point\"].apply(this, [array[i]]);\n- } catch (err) {\n- throw err;\n- }\n- points.push(p);\n- }\n- return new OpenLayers.Geometry.MultiPoint(points);\n- },\n-\n- /**\n- * Method: parseCoords.linestring\n- * Convert a coordinate array from GeoJSON into an\n- * .\n- *\n- * Parameters:\n- * array - {Object} The coordinates array from the GeoJSON fragment.\n- *\n- * Returns:\n- * {} A geometry.\n- */\n- \"linestring\": function(array) {\n- var points = [];\n- var p = null;\n- for (var i = 0, len = array.length; i < len; ++i) {\n- try {\n- p = this.parseCoords[\"point\"].apply(this, [array[i]]);\n- } catch (err) {\n- throw err;\n- }\n- points.push(p);\n- }\n- return new OpenLayers.Geometry.LineString(points);\n- },\n-\n- /**\n- * Method: parseCoords.multilinestring\n- * Convert a coordinate array from GeoJSON into an\n- * .\n- *\n- * Parameters:\n- * array - {Object} The coordinates array from the GeoJSON fragment.\n- *\n- * Returns:\n- * {} A geometry.\n- */\n- \"multilinestring\": function(array) {\n- var lines = [];\n- var l = null;\n- for (var i = 0, len = array.length; i < len; ++i) {\n- try {\n- l = this.parseCoords[\"linestring\"].apply(this, [array[i]]);\n- } catch (err) {\n- throw err;\n- }\n- lines.push(l);\n- }\n- return new OpenLayers.Geometry.MultiLineString(lines);\n- },\n-\n- /**\n- * Method: parseCoords.polygon\n- * Convert a coordinate array from GeoJSON into an\n- * .\n- *\n- * Returns:\n- * {} A geometry.\n- */\n- \"polygon\": function(array) {\n- var rings = [];\n- var r, l;\n- for (var i = 0, len = array.length; i < len; ++i) {\n- try {\n- l = this.parseCoords[\"linestring\"].apply(this, [array[i]]);\n- } catch (err) {\n- throw err;\n- }\n- r = new OpenLayers.Geometry.LinearRing(l.components);\n- rings.push(r);\n- }\n- return new OpenLayers.Geometry.Polygon(rings);\n- },\n-\n- /**\n- * Method: parseCoords.multipolygon\n- * Convert a coordinate array from GeoJSON into an\n- * .\n- *\n- * Parameters:\n- * array - {Object} The coordinates array from the GeoJSON fragment.\n- *\n- * Returns:\n- * {} A geometry.\n- */\n- \"multipolygon\": function(array) {\n- var polys = [];\n- var p = null;\n- for (var i = 0, len = array.length; i < len; ++i) {\n- try {\n- p = this.parseCoords[\"polygon\"].apply(this, [array[i]]);\n- } catch (err) {\n- throw err;\n- }\n- polys.push(p);\n- }\n- return new OpenLayers.Geometry.MultiPolygon(polys);\n- },\n+ draw: function(px) {\n+ OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,\n+ null,\n+ null,\n+ this.size,\n+ this.url,\n+ \"absolute\");\n+ this.moveTo(px);\n+ return this.imageDiv;\n+ },\n \n- /**\n- * Method: parseCoords.box\n- * Convert a coordinate array from GeoJSON into an\n- * .\n- *\n- * Parameters:\n- * array - {Object} The coordinates array from the GeoJSON fragment.\n- *\n- * Returns:\n- * {} A geometry.\n- */\n- \"box\": function(array) {\n- if (array.length != 2) {\n- throw \"GeoJSON box coordinates must have 2 elements\";\n- }\n- return new OpenLayers.Geometry.Polygon([\n- new OpenLayers.Geometry.LinearRing([\n- new OpenLayers.Geometry.Point(array[0][0], array[0][1]),\n- new OpenLayers.Geometry.Point(array[1][0], array[0][1]),\n- new OpenLayers.Geometry.Point(array[1][0], array[1][1]),\n- new OpenLayers.Geometry.Point(array[0][0], array[1][1]),\n- new OpenLayers.Geometry.Point(array[0][0], array[0][1])\n- ])\n- ]);\n+ /** \n+ * Method: erase\n+ * Erase the underlying image element.\n+ */\n+ erase: function() {\n+ if (this.imageDiv != null && this.imageDiv.parentNode != null) {\n+ OpenLayers.Element.remove(this.imageDiv);\n }\n-\n },\n \n- /**\n- * APIMethod: write\n- * Serialize a feature, geometry, array of features into a GeoJSON string.\n+ /** \n+ * Method: setOpacity\n+ * Change the icon's opacity\n *\n * Parameters:\n- * obj - {Object} An , ,\n- * or an array of features.\n- * pretty - {Boolean} Structure the output with newlines and indentation.\n- * Default is false.\n- *\n- * Returns:\n- * {String} The GeoJSON string representation of the input geometry,\n- * features, or array of features.\n+ * opacity - {float} \n */\n- write: function(obj, pretty) {\n- var geojson = {\n- \"type\": null\n- };\n- if (OpenLayers.Util.isArray(obj)) {\n- geojson.type = \"FeatureCollection\";\n- var numFeatures = obj.length;\n- geojson.features = new Array(numFeatures);\n- for (var i = 0; i < numFeatures; ++i) {\n- var element = obj[i];\n- if (!element instanceof OpenLayers.Feature.Vector) {\n- var msg = \"FeatureCollection only supports collections \" +\n- \"of features: \" + element;\n- throw msg;\n- }\n- geojson.features[i] = this.extract.feature.apply(\n- this, [element]\n- );\n- }\n- } else if (obj.CLASS_NAME.indexOf(\"OpenLayers.Geometry\") == 0) {\n- geojson = this.extract.geometry.apply(this, [obj]);\n- } else if (obj instanceof OpenLayers.Feature.Vector) {\n- geojson = this.extract.feature.apply(this, [obj]);\n- if (obj.layer && obj.layer.projection) {\n- geojson.crs = this.createCRSObject(obj);\n- }\n- }\n- return OpenLayers.Format.JSON.prototype.write.apply(this,\n- [geojson, pretty]);\n+ setOpacity: function(opacity) {\n+ OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, null, null,\n+ null, null, null, null, opacity);\n+\n },\n \n /**\n- * Method: createCRSObject\n- * Create the CRS object for an object.\n+ * Method: moveTo\n+ * move icon to passed in px.\n *\n * Parameters:\n- * object - {} \n- *\n- * Returns:\n- * {Object} An object which can be assigned to the crs property\n- * of a GeoJSON object.\n+ * px - {|Object} the pixel position to move to.\n+ * An OpenLayers.Pixel or an object with a 'x' and 'y' properties.\n */\n- createCRSObject: function(object) {\n- var proj = object.layer.projection.toString();\n- var crs = {};\n- if (proj.match(/epsg:/i)) {\n- var code = parseInt(proj.substring(proj.indexOf(\":\") + 1));\n- if (code == 4326) {\n- crs = {\n- \"type\": \"name\",\n- \"properties\": {\n- \"name\": \"urn:ogc:def:crs:OGC:1.3:CRS84\"\n- }\n- };\n+ moveTo: function(px) {\n+ //if no px passed in, use stored location\n+ if (px != null) {\n+ this.px = px;\n+ }\n+\n+ if (this.imageDiv != null) {\n+ if (this.px == null) {\n+ this.display(false);\n } else {\n- crs = {\n- \"type\": \"name\",\n- \"properties\": {\n- \"name\": \"EPSG:\" + code\n- }\n- };\n+ if (this.calculateOffset) {\n+ this.offset = this.calculateOffset(this.size);\n+ }\n+ OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, {\n+ x: this.px.x + this.offset.x,\n+ y: this.px.y + this.offset.y\n+ });\n }\n }\n- return crs;\n },\n \n- /**\n- * Property: extract\n- * Object with properties corresponding to the GeoJSON types.\n- * Property values are functions that do the actual value extraction.\n+ /** \n+ * Method: display\n+ * Hide or show the icon\n+ *\n+ * Parameters:\n+ * display - {Boolean} \n */\n- extract: {\n- /**\n- * Method: extract.feature\n- * Return a partial GeoJSON object representing a single feature.\n- *\n- * Parameters:\n- * feature - {}\n- *\n- * Returns:\n- * {Object} An object representing the point.\n- */\n- 'feature': function(feature) {\n- var geom = this.extract.geometry.apply(this, [feature.geometry]);\n- var json = {\n- \"type\": \"Feature\",\n- \"properties\": feature.attributes,\n- \"geometry\": geom\n- };\n- if (feature.fid != null) {\n- json.id = feature.fid;\n- }\n- return json;\n- },\n-\n- /**\n- * Method: extract.geometry\n- * Return a GeoJSON object representing a single geometry.\n- *\n- * Parameters:\n- * geometry - {}\n- *\n- * Returns:\n- * {Object} An object representing the geometry.\n- */\n- 'geometry': function(geometry) {\n- if (geometry == null) {\n- return null;\n- }\n- if (this.internalProjection && this.externalProjection) {\n- geometry = geometry.clone();\n- geometry.transform(this.internalProjection,\n- this.externalProjection);\n- }\n- var geometryType = geometry.CLASS_NAME.split('.')[2];\n- var data = this.extract[geometryType.toLowerCase()].apply(this, [geometry]);\n- var json;\n- if (geometryType == \"Collection\") {\n- json = {\n- \"type\": \"GeometryCollection\",\n- \"geometries\": data\n- };\n- } else {\n- json = {\n- \"type\": geometryType,\n- \"coordinates\": data\n- };\n- }\n-\n- return json;\n- },\n-\n- /**\n- * Method: extract.point\n- * Return an array of coordinates from a point.\n- *\n- * Parameters:\n- * point - {}\n- *\n- * Returns: \n- * {Array} An array of coordinates representing the point.\n- */\n- 'point': function(point) {\n- return [point.x, point.y];\n- },\n-\n- /**\n- * Method: extract.multipoint\n- * Return an array of point coordinates from a multipoint.\n- *\n- * Parameters:\n- * multipoint - {}\n- *\n- * Returns:\n- * {Array} An array of point coordinate arrays representing\n- * the multipoint.\n- */\n- 'multipoint': function(multipoint) {\n- var array = [];\n- for (var i = 0, len = multipoint.components.length; i < len; ++i) {\n- array.push(this.extract.point.apply(this, [multipoint.components[i]]));\n- }\n- return array;\n- },\n-\n- /**\n- * Method: extract.linestring\n- * Return an array of coordinate arrays from a linestring.\n- *\n- * Parameters:\n- * linestring - {}\n- *\n- * Returns:\n- * {Array} An array of coordinate arrays representing\n- * the linestring.\n- */\n- 'linestring': function(linestring) {\n- var array = [];\n- for (var i = 0, len = linestring.components.length; i < len; ++i) {\n- array.push(this.extract.point.apply(this, [linestring.components[i]]));\n- }\n- return array;\n- },\n-\n- /**\n- * Method: extract.multilinestring\n- * Return an array of linestring arrays from a linestring.\n- * \n- * Parameters:\n- * multilinestring - {}\n- * \n- * Returns:\n- * {Array} An array of linestring arrays representing\n- * the multilinestring.\n- */\n- 'multilinestring': function(multilinestring) {\n- var array = [];\n- for (var i = 0, len = multilinestring.components.length; i < len; ++i) {\n- array.push(this.extract.linestring.apply(this, [multilinestring.components[i]]));\n- }\n- return array;\n- },\n-\n- /**\n- * Method: extract.polygon\n- * Return an array of linear ring arrays from a polygon.\n- *\n- * Parameters:\n- * polygon - {}\n- * \n- * Returns:\n- * {Array} An array of linear ring arrays representing the polygon.\n- */\n- 'polygon': function(polygon) {\n- var array = [];\n- for (var i = 0, len = polygon.components.length; i < len; ++i) {\n- array.push(this.extract.linestring.apply(this, [polygon.components[i]]));\n- }\n- return array;\n- },\n-\n- /**\n- * Method: extract.multipolygon\n- * Return an array of polygon arrays from a multipolygon.\n- * \n- * Parameters:\n- * multipolygon - {}\n- * \n- * Returns:\n- * {Array} An array of polygon arrays representing\n- * the multipolygon\n- */\n- 'multipolygon': function(multipolygon) {\n- var array = [];\n- for (var i = 0, len = multipolygon.components.length; i < len; ++i) {\n- array.push(this.extract.polygon.apply(this, [multipolygon.components[i]]));\n- }\n- return array;\n- },\n+ display: function(display) {\n+ this.imageDiv.style.display = (display) ? \"\" : \"none\";\n+ },\n \n- /**\n- * Method: extract.collection\n- * Return an array of geometries from a geometry collection.\n- * \n- * Parameters:\n- * collection - {}\n- * \n- * Returns:\n- * {Array} An array of geometry objects representing the geometry\n- * collection.\n- */\n- 'collection': function(collection) {\n- var len = collection.components.length;\n- var array = new Array(len);\n- for (var i = 0; i < len; ++i) {\n- array[i] = this.extract.geometry.apply(\n- this, [collection.components[i]]\n- );\n- }\n- return array;\n- }\n \n+ /**\n+ * APIMethod: isDrawn\n+ * \n+ * Returns:\n+ * {Boolean} Whether or not the icon is drawn.\n+ */\n+ isDrawn: function() {\n+ // nodeType 11 for ie, whose nodes *always* have a parentNode\n+ // (of type document fragment)\n+ var isDrawn = (this.imageDiv && this.imageDiv.parentNode &&\n+ (this.imageDiv.parentNode.nodeType != 11));\n \n+ return isDrawn;\n },\n \n- CLASS_NAME: \"OpenLayers.Format.GeoJSON\"\n-\n+ CLASS_NAME: \"OpenLayers.Icon\"\n });\n /* ======================================================================\n- OpenLayers/Format/XML.js\n+ OpenLayers/Marker.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Format.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Events.js\n+ * @requires OpenLayers/Icon.js\n */\n \n /**\n- * Class: OpenLayers.Format.XML\n- * Read and write XML. For cross-browser XML generation, use methods on an\n- * instance of the XML format class instead of on document.\n- * The DOM creation and traversing methods exposed here all mimic the\n- * W3C XML DOM methods. Create a new parser with the\n- * constructor.\n+ * Class: OpenLayers.Marker\n+ * Instances of OpenLayers.Marker are a combination of a \n+ * and an . \n *\n- * Inherits from:\n- * - \n+ * Markers are generally added to a special layer called\n+ * .\n+ *\n+ * Example:\n+ * (code)\n+ * var markers = new OpenLayers.Layer.Markers( \"Markers\" );\n+ * map.addLayer(markers);\n+ *\n+ * var size = new OpenLayers.Size(21,25);\n+ * var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);\n+ * var icon = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png', size, offset);\n+ * markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon));\n+ * markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon.clone()));\n+ *\n+ * (end)\n+ *\n+ * Note that if you pass an icon into the Marker constructor, it will take\n+ * that icon and use it. This means that you should not share icons between\n+ * markers -- you use them once, but you should clone() for any additional\n+ * markers using that same icon.\n */\n-OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {\n-\n- /**\n- * Property: namespaces\n- * {Object} Mapping of namespace aliases to namespace URIs. Properties\n- * of this object should not be set individually. Read-only. All\n- * XML subclasses should have their own namespaces object. Use\n- * to add or set a namespace alias after construction.\n- */\n- namespaces: null,\n-\n- /**\n- * Property: namespaceAlias\n- * {Object} Mapping of namespace URI to namespace alias. This object\n- * is read-only. Use to add or set a namespace alias.\n- */\n- namespaceAlias: null,\n+OpenLayers.Marker = OpenLayers.Class({\n \n- /**\n- * Property: defaultPrefix\n- * {String} The default namespace alias for creating element nodes.\n+ /** \n+ * Property: icon \n+ * {} The icon used by this marker.\n */\n- defaultPrefix: null,\n+ icon: null,\n \n- /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n+ /** \n+ * Property: lonlat \n+ * {} location of object\n */\n- readers: {},\n+ lonlat: null,\n \n- /**\n- * Property: writers\n- * As a compliment to the property, this structure contains public\n- * writing functions grouped by namespace alias and named like the\n- * node names they produce.\n+ /** \n+ * Property: events \n+ * {} the event handler.\n */\n- writers: {},\n+ events: null,\n \n- /**\n- * Property: xmldom\n- * {XMLDom} If this browser uses ActiveX, this will be set to a XMLDOM\n- * object. It is not intended to be a browser sniffing property.\n- * Instead, the xmldom property is used instead of document\n- * where namespaced node creation methods are not supported. In all\n- * other browsers, this remains null.\n+ /** \n+ * Property: map \n+ * {} the map this marker is attached to\n */\n- xmldom: null,\n+ map: null,\n \n- /**\n- * Constructor: OpenLayers.Format.XML\n- * Construct an XML parser. The parser is used to read and write XML.\n- * Reading XML from a string returns a DOM element. Writing XML from\n- * a DOM element returns a string.\n+ /** \n+ * Constructor: OpenLayers.Marker\n *\n * Parameters:\n- * options - {Object} Optional object whose properties will be set on\n- * the object.\n+ * lonlat - {} the position of this marker\n+ * icon - {} the icon for this marker\n */\n- initialize: function(options) {\n- if (window.ActiveXObject) {\n- this.xmldom = new ActiveXObject(\"Microsoft.XMLDOM\");\n- }\n- OpenLayers.Format.prototype.initialize.apply(this, [options]);\n- // clone the namespace object and set all namespace aliases\n- this.namespaces = OpenLayers.Util.extend({}, this.namespaces);\n- this.namespaceAlias = {};\n- for (var alias in this.namespaces) {\n- this.namespaceAlias[this.namespaces[alias]] = alias;\n+ initialize: function(lonlat, icon) {\n+ this.lonlat = lonlat;\n+\n+ var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon();\n+ if (this.icon == null) {\n+ this.icon = newIcon;\n+ } else {\n+ this.icon.url = newIcon.url;\n+ this.icon.size = newIcon.size;\n+ this.icon.offset = newIcon.offset;\n+ this.icon.calculateOffset = newIcon.calculateOffset;\n }\n+ this.events = new OpenLayers.Events(this, this.icon.imageDiv);\n },\n \n /**\n * APIMethod: destroy\n- * Clean up.\n+ * Destroy the marker. You must first remove the marker from any \n+ * layer which it has been added to, or you will get buggy behavior.\n+ * (This can not be done within the marker since the marker does not\n+ * know which layer it is attached to.)\n */\n destroy: function() {\n- this.xmldom = null;\n- OpenLayers.Format.prototype.destroy.apply(this, arguments);\n- },\n+ // erase any drawn features\n+ this.erase();\n \n- /**\n- * Method: setNamespace\n- * Set a namespace alias and URI for the format.\n- *\n- * Parameters:\n- * alias - {String} The namespace alias (prefix).\n- * uri - {String} The namespace URI.\n- */\n- setNamespace: function(alias, uri) {\n- this.namespaces[alias] = uri;\n- this.namespaceAlias[uri] = alias;\n+ this.map = null;\n+\n+ this.events.destroy();\n+ this.events = null;\n+\n+ if (this.icon != null) {\n+ this.icon.destroy();\n+ this.icon = null;\n+ }\n },\n \n- /**\n- * APIMethod: read\n- * Deserialize a XML string and return a DOM node.\n- *\n+ /** \n+ * Method: draw\n+ * Calls draw on the icon, and returns that output.\n+ * \n * Parameters:\n- * text - {String} A XML string\n- \n+ * px - {}\n+ * \n * Returns:\n- * {DOMElement} A DOM node\n+ * {DOMElement} A new DOM Image with this marker's icon set at the \n+ * location passed-in\n */\n- read: function(text) {\n- var index = text.indexOf('<');\n- if (index > 0) {\n- text = text.substring(index);\n- }\n- var node = OpenLayers.Util.Try(\n- OpenLayers.Function.bind((\n- function() {\n- var xmldom;\n- /**\n- * Since we want to be able to call this method on the prototype\n- * itself, this.xmldom may not exist even if in IE.\n- */\n- if (window.ActiveXObject && !this.xmldom) {\n- xmldom = new ActiveXObject(\"Microsoft.XMLDOM\");\n- } else {\n- xmldom = this.xmldom;\n-\n- }\n- xmldom.loadXML(text);\n- return xmldom;\n- }\n- ), this),\n- function() {\n- return new DOMParser().parseFromString(text, 'text/xml');\n- },\n- function() {\n- var req = new XMLHttpRequest();\n- req.open(\"GET\", \"data:\" + \"text/xml\" +\n- \";charset=utf-8,\" + encodeURIComponent(text), false);\n- if (req.overrideMimeType) {\n- req.overrideMimeType(\"text/xml\");\n- }\n- req.send(null);\n- return req.responseXML;\n- }\n- );\n+ draw: function(px) {\n+ return this.icon.draw(px);\n+ },\n \n- if (this.keepData) {\n- this.data = node;\n+ /** \n+ * Method: erase\n+ * Erases any drawn elements for this marker.\n+ */\n+ erase: function() {\n+ if (this.icon != null) {\n+ this.icon.erase();\n }\n-\n- return node;\n },\n \n /**\n- * APIMethod: write\n- * Serialize a DOM node into a XML string.\n- * \n- * Parameters:\n- * node - {DOMElement} A DOM node.\n+ * Method: moveTo\n+ * Move the marker to the new location.\n *\n- * Returns:\n- * {String} The XML string representation of the input node.\n+ * Parameters:\n+ * px - {|Object} the pixel position to move to.\n+ * An OpenLayers.Pixel or an object with a 'x' and 'y' properties.\n */\n- write: function(node) {\n- var data;\n- if (this.xmldom) {\n- data = node.xml;\n- } else {\n- var serializer = new XMLSerializer();\n- if (node.nodeType == 1) {\n- // Add nodes to a document before serializing. Everything else\n- // is serialized as is. This may need more work. See #1218 .\n- var doc = document.implementation.createDocument(\"\", \"\", null);\n- if (doc.importNode) {\n- node = doc.importNode(node, true);\n- }\n- doc.appendChild(node);\n- data = serializer.serializeToString(doc);\n- } else {\n- data = serializer.serializeToString(node);\n- }\n+ moveTo: function(px) {\n+ if ((px != null) && (this.icon != null)) {\n+ this.icon.moveTo(px);\n }\n- return data;\n+ this.lonlat = this.map.getLonLatFromLayerPx(px);\n },\n \n /**\n- * APIMethod: createElementNS\n- * Create a new element with namespace. This node can be appended to\n- * another node with the standard node.appendChild method. For\n- * cross-browser support, this method must be used instead of\n- * document.createElementNS.\n- *\n- * Parameters:\n- * uri - {String} Namespace URI for the element.\n- * name - {String} The qualified name of the element (prefix:localname).\n+ * APIMethod: isDrawn\n * \n * Returns:\n- * {Element} A DOM element with namespace.\n+ * {Boolean} Whether or not the marker is drawn.\n */\n- createElementNS: function(uri, name) {\n- var element;\n- if (this.xmldom) {\n- if (typeof uri == \"string\") {\n- element = this.xmldom.createNode(1, name, uri);\n- } else {\n- element = this.xmldom.createNode(1, name, \"\");\n- }\n- } else {\n- element = document.createElementNS(uri, name);\n- }\n- return element;\n+ isDrawn: function() {\n+ var isDrawn = (this.icon && this.icon.isDrawn());\n+ return isDrawn;\n },\n \n /**\n- * APIMethod: createDocumentFragment\n- * Create a document fragment node that can be appended to another node\n- * created by createElementNS. This will call \n- * document.createDocumentFragment outside of IE. In IE, the ActiveX\n- * object's createDocumentFragment method is used.\n+ * Method: onScreen\n *\n * Returns:\n- * {Element} A document fragment.\n+ * {Boolean} Whether or not the marker is currently visible on screen.\n */\n- createDocumentFragment: function() {\n- var element;\n- if (this.xmldom) {\n- element = this.xmldom.createDocumentFragment();\n- } else {\n- element = document.createDocumentFragment();\n+ onScreen: function() {\n+\n+ var onScreen = false;\n+ if (this.map) {\n+ var screenBounds = this.map.getExtent();\n+ onScreen = screenBounds.containsLonLat(this.lonlat);\n }\n- return element;\n+ return onScreen;\n },\n \n /**\n- * APIMethod: createTextNode\n- * Create a text node. This node can be appended to another node with\n- * the standard node.appendChild method. For cross-browser support,\n- * this method must be used instead of document.createTextNode.\n- * \n+ * Method: inflate\n+ * Englarges the markers icon by the specified ratio.\n+ *\n * Parameters:\n- * text - {String} The text of the node.\n- * \n- * Returns: \n- * {DOMElement} A DOM text node.\n+ * inflate - {float} the ratio to enlarge the marker by (passing 2\n+ * will double the size).\n */\n- createTextNode: function(text) {\n- var node;\n- if (typeof text !== \"string\") {\n- text = String(text);\n- }\n- if (this.xmldom) {\n- node = this.xmldom.createTextNode(text);\n- } else {\n- node = document.createTextNode(text);\n+ inflate: function(inflate) {\n+ if (this.icon) {\n+ this.icon.setSize({\n+ w: this.icon.size.w * inflate,\n+ h: this.icon.size.h * inflate\n+ });\n }\n- return node;\n },\n \n- /**\n- * APIMethod: getElementsByTagNameNS\n- * Get a list of elements on a node given the namespace URI and local name.\n- * To return all nodes in a given namespace, use '*' for the name\n- * argument. To return all nodes of a given (local) name, regardless\n- * of namespace, use '*' for the uri argument.\n+ /** \n+ * Method: setOpacity\n+ * Change the opacity of the marker by changin the opacity of \n+ * its icon\n * \n * Parameters:\n- * node - {Element} Node on which to search for other nodes.\n- * uri - {String} Namespace URI.\n- * name - {String} Local name of the tag (without the prefix).\n- * \n- * Returns:\n- * {NodeList} A node list or array of elements.\n+ * opacity - {float} Specified as fraction (0.4, etc)\n */\n- getElementsByTagNameNS: function(node, uri, name) {\n- var elements = [];\n- if (node.getElementsByTagNameNS) {\n- elements = node.getElementsByTagNameNS(uri, name);\n- } else {\n- // brute force method\n- var allNodes = node.getElementsByTagName(\"*\");\n- var potentialNode, fullName;\n- for (var i = 0, len = allNodes.length; i < len; ++i) {\n- potentialNode = allNodes[i];\n- fullName = (potentialNode.prefix) ?\n- (potentialNode.prefix + \":\" + name) : name;\n- if ((name == \"*\") || (fullName == potentialNode.nodeName)) {\n- if ((uri == \"*\") || (uri == potentialNode.namespaceURI)) {\n- elements.push(potentialNode);\n- }\n- }\n- }\n- }\n- return elements;\n+ setOpacity: function(opacity) {\n+ this.icon.setOpacity(opacity);\n },\n \n /**\n- * APIMethod: getAttributeNodeNS\n- * Get an attribute node given the namespace URI and local name.\n- * \n- * Parameters:\n- * node - {Element} Node on which to search for attribute nodes.\n- * uri - {String} Namespace URI.\n- * name - {String} Local name of the attribute (without the prefix).\n+ * Method: setUrl\n+ * Change URL of the Icon Image.\n * \n- * Returns:\n- * {DOMElement} An attribute node or null if none found.\n+ * url - {String} \n */\n- getAttributeNodeNS: function(node, uri, name) {\n- var attributeNode = null;\n- if (node.getAttributeNodeNS) {\n- attributeNode = node.getAttributeNodeNS(uri, name);\n- } else {\n- var attributes = node.attributes;\n- var potentialNode, fullName;\n- for (var i = 0, len = attributes.length; i < len; ++i) {\n- potentialNode = attributes[i];\n- if (potentialNode.namespaceURI == uri) {\n- fullName = (potentialNode.prefix) ?\n- (potentialNode.prefix + \":\" + name) : name;\n- if (fullName == potentialNode.nodeName) {\n- attributeNode = potentialNode;\n- break;\n- }\n- }\n- }\n- }\n- return attributeNode;\n+ setUrl: function(url) {\n+ this.icon.setUrl(url);\n },\n \n- /**\n- * APIMethod: getAttributeNS\n- * Get an attribute value given the namespace URI and local name.\n- * \n- * Parameters:\n- * node - {Element} Node on which to search for an attribute.\n- * uri - {String} Namespace URI.\n- * name - {String} Local name of the attribute (without the prefix).\n+ /** \n+ * Method: display\n+ * Hide or show the icon\n * \n- * Returns:\n- * {String} An attribute value or and empty string if none found.\n+ * display - {Boolean} \n */\n- getAttributeNS: function(node, uri, name) {\n- var attributeValue = \"\";\n- if (node.getAttributeNS) {\n- attributeValue = node.getAttributeNS(uri, name) || \"\";\n- } else {\n- var attributeNode = this.getAttributeNodeNS(node, uri, name);\n- if (attributeNode) {\n- attributeValue = attributeNode.nodeValue;\n- }\n- }\n- return attributeValue;\n+ display: function(display) {\n+ this.icon.display(display);\n },\n \n+ CLASS_NAME: \"OpenLayers.Marker\"\n+});\n+\n+\n+/**\n+ * Function: defaultIcon\n+ * Creates a default .\n+ * \n+ * Returns:\n+ * {} A default OpenLayers.Icon to use for a marker\n+ */\n+OpenLayers.Marker.defaultIcon = function() {\n+ return new OpenLayers.Icon(OpenLayers.Util.getImageLocation(\"marker.png\"), {\n+ w: 21,\n+ h: 25\n+ }, {\n+ x: -10.5,\n+ y: -25\n+ });\n+};\n+\n+\n+/* ======================================================================\n+ OpenLayers/Symbolizer.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Symbolizer\n+ * Base class representing a symbolizer used for feature rendering.\n+ */\n+OpenLayers.Symbolizer = OpenLayers.Class({\n+\n+\n /**\n- * APIMethod: getChildValue\n- * Get the textual value of the node if it exists, or return an\n- * optional default string. Returns an empty string if no first child\n- * exists and no default value is supplied.\n- *\n- * Parameters:\n- * node - {DOMElement} The element used to look for a first child value.\n- * def - {String} Optional string to return in the event that no\n- * first child value exists.\n- *\n- * Returns:\n- * {String} The value of the first child of the given node.\n+ * APIProperty: zIndex\n+ * {Number} The zIndex determines the rendering order for a symbolizer.\n+ * Symbolizers with larger zIndex values are rendered over symbolizers\n+ * with smaller zIndex values. Default is 0.\n */\n- getChildValue: function(node, def) {\n- var value = def || \"\";\n- if (node) {\n- for (var child = node.firstChild; child; child = child.nextSibling) {\n- switch (child.nodeType) {\n- case 3: // text node\n- case 4: // cdata section\n- value += child.nodeValue;\n- }\n- }\n- }\n- return value;\n- },\n+ zIndex: 0,\n \n /**\n- * APIMethod: isSimpleContent\n- * Test if the given node has only simple content (i.e. no child element\n- * nodes).\n+ * Constructor: OpenLayers.Symbolizer\n+ * Instances of this class are not useful. See one of the subclasses.\n *\n * Parameters:\n- * node - {DOMElement} An element node.\n+ * config - {Object} An object containing properties to be set on the \n+ * symbolizer. Any documented symbolizer property can be set at \n+ * construction.\n *\n * Returns:\n- * {Boolean} The node has no child element nodes (nodes of type 1). \n+ * A new symbolizer.\n */\n- isSimpleContent: function(node) {\n- var simple = true;\n- for (var child = node.firstChild; child; child = child.nextSibling) {\n- if (child.nodeType === 1) {\n- simple = false;\n- break;\n- }\n- }\n- return simple;\n+ initialize: function(config) {\n+ OpenLayers.Util.extend(this, config);\n },\n \n- /**\n- * APIMethod: contentType\n- * Determine the content type for a given node.\n- *\n- * Parameters:\n- * node - {DOMElement}\n+ /** \n+ * APIMethod: clone\n+ * Create a copy of this symbolizer.\n *\n- * Returns:\n- * {Integer} One of OpenLayers.Format.XML.CONTENT_TYPE.{EMPTY,SIMPLE,COMPLEX,MIXED}\n- * if the node has no, simple, complex, or mixed content.\n+ * Returns a symbolizer of the same type with the same properties.\n */\n- contentType: function(node) {\n- var simple = false,\n- complex = false;\n+ clone: function() {\n+ var Type = eval(this.CLASS_NAME);\n+ return new Type(OpenLayers.Util.extend({}, this));\n+ },\n \n- var type = OpenLayers.Format.XML.CONTENT_TYPE.EMPTY;\n+ CLASS_NAME: \"OpenLayers.Symbolizer\"\n \n- for (var child = node.firstChild; child; child = child.nextSibling) {\n- switch (child.nodeType) {\n- case 1: // element\n- complex = true;\n- break;\n- case 8: // comment\n- break;\n- default:\n- simple = true;\n- }\n- if (complex && simple) {\n- break;\n- }\n- }\n+});\n \n- if (complex && simple) {\n- type = OpenLayers.Format.XML.CONTENT_TYPE.MIXED;\n- } else if (complex) {\n- return OpenLayers.Format.XML.CONTENT_TYPE.COMPLEX;\n- } else if (simple) {\n- return OpenLayers.Format.XML.CONTENT_TYPE.SIMPLE;\n- }\n- return type;\n- },\n+/* ======================================================================\n+ OpenLayers/Symbolizer/Point.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Symbolizer.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Symbolizer.Point\n+ * A symbolizer used to render point features.\n+ */\n+OpenLayers.Symbolizer.Point = OpenLayers.Class(OpenLayers.Symbolizer, {\n \n /**\n- * APIMethod: hasAttributeNS\n- * Determine whether a node has a particular attribute matching the given\n- * name and namespace.\n- * \n- * Parameters:\n- * node - {Element} Node on which to search for an attribute.\n- * uri - {String} Namespace URI.\n- * name - {String} Local name of the attribute (without the prefix).\n+ * APIProperty: strokeColor\n+ * {String} Color for line stroke. This is a RGB hex value (e.g. \"#ff0000\"\n+ * for red).\n * \n- * Returns:\n- * {Boolean} The node has an attribute matching the name and namespace.\n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- hasAttributeNS: function(node, uri, name) {\n- var found = false;\n- if (node.hasAttributeNS) {\n- found = node.hasAttributeNS(uri, name);\n- } else {\n- found = !!this.getAttributeNodeNS(node, uri, name);\n- }\n- return found;\n- },\n \n /**\n- * APIMethod: setAttributeNS\n- * Adds a new attribute or changes the value of an attribute with the given\n- * namespace and name.\n- *\n- * Parameters:\n- * node - {Element} Element node on which to set the attribute.\n- * uri - {String} Namespace URI for the attribute.\n- * name - {String} Qualified name (prefix:localname) for the attribute.\n- * value - {String} Attribute value.\n+ * APIProperty: strokeOpacity\n+ * {Number} Stroke opacity (0-1).\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- setAttributeNS: function(node, uri, name, value) {\n- if (node.setAttributeNS) {\n- node.setAttributeNS(uri, name, value);\n- } else {\n- if (this.xmldom) {\n- if (uri) {\n- var attribute = node.ownerDocument.createNode(\n- 2, name, uri\n- );\n- attribute.nodeValue = value;\n- node.setAttributeNode(attribute);\n- } else {\n- node.setAttribute(name, value);\n- }\n- } else {\n- throw \"setAttributeNS not implemented\";\n- }\n- }\n- },\n \n /**\n- * Method: createElementNSPlus\n- * Shorthand for creating namespaced elements with optional attributes and\n- * child text nodes.\n- *\n- * Parameters:\n- * name - {String} The qualified node name.\n- * options - {Object} Optional object for node configuration.\n- *\n- * Valid options:\n- * uri - {String} Optional namespace uri for the element - supply a prefix\n- * instead if the namespace uri is a property of the format's namespace\n- * object.\n- * attributes - {Object} Optional attributes to be set using the\n- * method.\n- * value - {String} Optional text to be appended as a text node.\n- *\n- * Returns:\n- * {Element} An element node.\n+ * APIProperty: strokeWidth\n+ * {Number} Pixel stroke width.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- createElementNSPlus: function(name, options) {\n- options = options || {};\n- // order of prefix preference\n- // 1. in the uri option\n- // 2. in the prefix option\n- // 3. in the qualified name\n- // 4. from the defaultPrefix\n- var uri = options.uri || this.namespaces[options.prefix];\n- if (!uri) {\n- var loc = name.indexOf(\":\");\n- uri = this.namespaces[name.substring(0, loc)];\n- }\n- if (!uri) {\n- uri = this.namespaces[this.defaultPrefix];\n- }\n- var node = this.createElementNS(uri, name);\n- if (options.attributes) {\n- this.setAttributes(node, options.attributes);\n- }\n- var value = options.value;\n- if (value != null) {\n- node.appendChild(this.createTextNode(value));\n- }\n- return node;\n- },\n \n /**\n- * Method: setAttributes\n- * Set multiple attributes given key value pairs from an object.\n- *\n- * Parameters:\n- * node - {Element} An element node.\n- * obj - {Object || Array} An object whose properties represent attribute\n- * names and values represent attribute values. If an attribute name\n- * is a qualified name (\"prefix:local\"), the prefix will be looked up\n- * in the parsers {namespaces} object. If the prefix is found,\n- * setAttributeNS will be used instead of setAttribute.\n+ * APIProperty: strokeLinecap\n+ * {String} Stroke cap type (\"butt\", \"round\", or \"square\").\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- setAttributes: function(node, obj) {\n- var value, uri;\n- for (var name in obj) {\n- if (obj[name] != null && obj[name].toString) {\n- value = obj[name].toString();\n- // check for qualified attribute name (\"prefix:local\")\n- uri = this.namespaces[name.substring(0, name.indexOf(\":\"))] || null;\n- this.setAttributeNS(node, uri, name, value);\n- }\n- }\n- },\n \n /**\n- * Method: readNode\n- * Shorthand for applying one of the named readers given the node\n- * namespace and local name. Readers take two args (node, obj) and\n- * generally extend or modify the second.\n- *\n- * Parameters:\n- * node - {DOMElement} The node to be read (required).\n- * obj - {Object} The object to be modified (optional).\n- *\n- * Returns:\n- * {Object} The input object, modified (or a new one if none was provided).\n+ * Property: strokeDashstyle\n+ * {String} Stroke dash style according to the SLD spec. Note that the\n+ * OpenLayers values for strokeDashstyle (\"dot\", \"dash\", \"dashdot\",\n+ * \"longdash\", \"longdashdot\", or \"solid\") will not work in SLD, but\n+ * most SLD patterns will render correctly in OpenLayers.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- readNode: function(node, obj) {\n- if (!obj) {\n- obj = {};\n- }\n- var group = this.readers[node.namespaceURI ? this.namespaceAlias[node.namespaceURI] : this.defaultPrefix];\n- if (group) {\n- var local = node.localName || node.nodeName.split(\":\").pop();\n- var reader = group[local] || group[\"*\"];\n- if (reader) {\n- reader.apply(this, [node, obj]);\n- }\n- }\n- return obj;\n- },\n \n /**\n- * Method: readChildNodes\n- * Shorthand for applying the named readers to all children of a node.\n- * For each child of type 1 (element), is called.\n- *\n- * Parameters:\n- * node - {DOMElement} The node to be read (required).\n- * obj - {Object} The object to be modified (optional).\n- *\n- * Returns:\n- * {Object} The input object, modified.\n+ * APIProperty: fillColor\n+ * {String} RGB hex fill color (e.g. \"#ff0000\" for red).\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- readChildNodes: function(node, obj) {\n- if (!obj) {\n- obj = {};\n- }\n- var children = node.childNodes;\n- var child;\n- for (var i = 0, len = children.length; i < len; ++i) {\n- child = children[i];\n- if (child.nodeType == 1) {\n- this.readNode(child, obj);\n- }\n- }\n- return obj;\n- },\n \n /**\n- * Method: writeNode\n- * Shorthand for applying one of the named writers and appending the\n- * results to a node. If a qualified name is not provided for the\n- * second argument (and a local name is used instead), the namespace\n- * of the parent node will be assumed.\n- *\n- * Parameters:\n- * name - {String} The name of a node to generate. If a qualified name\n- * (e.g. \"pre:Name\") is used, the namespace prefix is assumed to be\n- * in the group. If a local name is used (e.g. \"Name\") then\n- * the namespace of the parent is assumed. If a local name is used\n- * and no parent is supplied, then the default namespace is assumed.\n- * obj - {Object} Structure containing data for the writer.\n- * parent - {DOMElement} Result will be appended to this node. If no parent\n- * is supplied, the node will not be appended to anything.\n- *\n- * Returns:\n- * {DOMElement} The child node.\n+ * APIProperty: fillOpacity\n+ * {Number} Fill opacity (0-1).\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- writeNode: function(name, obj, parent) {\n- var prefix, local;\n- var split = name.indexOf(\":\");\n- if (split > 0) {\n- prefix = name.substring(0, split);\n- local = name.substring(split + 1);\n- } else {\n- if (parent) {\n- prefix = this.namespaceAlias[parent.namespaceURI];\n- } else {\n- prefix = this.defaultPrefix;\n- }\n- local = name;\n- }\n- var child = this.writers[prefix][local].apply(this, [obj]);\n- if (parent) {\n- parent.appendChild(child);\n- }\n- return child;\n- },\n \n /**\n- * APIMethod: getChildEl\n- * Get the first child element. Optionally only return the first child\n- * if it matches the given name and namespace URI.\n- *\n- * Parameters:\n- * node - {DOMElement} The parent node.\n- * name - {String} Optional node name (local) to search for.\n- * uri - {String} Optional namespace URI to search for.\n- *\n- * Returns:\n- * {DOMElement} The first child. Returns null if no element is found, if\n- * something significant besides an element is found, or if the element\n- * found does not match the optional name and uri.\n+ * APIProperty: pointRadius\n+ * {Number} Pixel point radius.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- getChildEl: function(node, name, uri) {\n- return node && this.getThisOrNextEl(node.firstChild, name, uri);\n- },\n \n /**\n- * APIMethod: getNextEl\n- * Get the next sibling element. Optionally get the first sibling only\n- * if it matches the given local name and namespace URI.\n- *\n- * Parameters:\n- * node - {DOMElement} The node.\n- * name - {String} Optional local name of the sibling to search for.\n- * uri - {String} Optional namespace URI of the sibling to search for.\n- *\n- * Returns:\n- * {DOMElement} The next sibling element. Returns null if no element is\n- * found, something significant besides an element is found, or the\n- * found element does not match the optional name and uri.\n+ * APIProperty: externalGraphic\n+ * {String} Url to an external graphic that will be used for rendering \n+ * points.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- getNextEl: function(node, name, uri) {\n- return node && this.getThisOrNextEl(node.nextSibling, name, uri);\n- },\n \n /**\n- * Method: getThisOrNextEl\n- * Return this node or the next element node. Optionally get the first\n- * sibling with the given local name or namespace URI.\n- *\n- * Parameters:\n- * node - {DOMElement} The node.\n- * name - {String} Optional local name of the sibling to search for.\n- * uri - {String} Optional namespace URI of the sibling to search for.\n- *\n- * Returns:\n- * {DOMElement} The next sibling element. Returns null if no element is\n- * found, something significant besides an element is found, or the\n- * found element does not match the query.\n+ * APIProperty: graphicWidth\n+ * {Number} Pixel width for sizing an external graphic.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- getThisOrNextEl: function(node, name, uri) {\n- outer: for (var sibling = node; sibling; sibling = sibling.nextSibling) {\n- switch (sibling.nodeType) {\n- case 1: // Element\n- if ((!name || name === (sibling.localName || sibling.nodeName.split(\":\").pop())) &&\n- (!uri || uri === sibling.namespaceURI)) {\n- // matches\n- break outer;\n- }\n- sibling = null;\n- break outer;\n- case 3: // Text\n- if (/^\\s*$/.test(sibling.nodeValue)) {\n- break;\n- }\n- case 4: // CDATA\n- case 6: // ENTITY_NODE\n- case 12: // NOTATION_NODE\n- case 10: // DOCUMENT_TYPE_NODE\n- case 11: // DOCUMENT_FRAGMENT_NODE\n- sibling = null;\n- break outer;\n- } // ignore comments and processing instructions\n- }\n- return sibling || null;\n- },\n \n /**\n- * APIMethod: lookupNamespaceURI\n- * Takes a prefix and returns the namespace URI associated with it on the given\n- * node if found (and null if not). Supplying null for the prefix will\n- * return the default namespace.\n- *\n- * For browsers that support it, this calls the native lookupNamesapceURI\n- * function. In other browsers, this is an implementation of\n- * http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespaceURI.\n- *\n- * For browsers that don't support the attribute.ownerElement property, this\n- * method cannot be called on attribute nodes.\n- * \n- * Parameters:\n- * node - {DOMElement} The node from which to start looking.\n- * prefix - {String} The prefix to lookup or null to lookup the default namespace.\n+ * APIProperty: graphicHeight\n+ * {Number} Pixel height for sizing an external graphic.\n * \n- * Returns:\n- * {String} The namespace URI for the given prefix. Returns null if the prefix\n- * cannot be found or the node is the wrong type.\n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- lookupNamespaceURI: function(node, prefix) {\n- var uri = null;\n- if (node) {\n- if (node.lookupNamespaceURI) {\n- uri = node.lookupNamespaceURI(prefix);\n- } else {\n- outer: switch (node.nodeType) {\n- case 1: // ELEMENT_NODE\n- if (node.namespaceURI !== null && node.prefix === prefix) {\n- uri = node.namespaceURI;\n- break outer;\n- }\n- var len = node.attributes.length;\n- if (len) {\n- var attr;\n- for (var i = 0; i < len; ++i) {\n- attr = node.attributes[i];\n- if (attr.prefix === \"xmlns\" && attr.name === \"xmlns:\" + prefix) {\n- uri = attr.value || null;\n- break outer;\n- } else if (attr.name === \"xmlns\" && prefix === null) {\n- uri = attr.value || null;\n- break outer;\n- }\n- }\n- }\n- uri = this.lookupNamespaceURI(node.parentNode, prefix);\n- break outer;\n- case 2: // ATTRIBUTE_NODE\n- uri = this.lookupNamespaceURI(node.ownerElement, prefix);\n- break outer;\n- case 9: // DOCUMENT_NODE\n- uri = this.lookupNamespaceURI(node.documentElement, prefix);\n- break outer;\n- case 6: // ENTITY_NODE\n- case 12: // NOTATION_NODE\n- case 10: // DOCUMENT_TYPE_NODE\n- case 11: // DOCUMENT_FRAGMENT_NODE\n- break outer;\n- default:\n- // TEXT_NODE (3), CDATA_SECTION_NODE (4), ENTITY_REFERENCE_NODE (5),\n- // PROCESSING_INSTRUCTION_NODE (7), COMMENT_NODE (8)\n- uri = this.lookupNamespaceURI(node.parentNode, prefix);\n- break outer;\n- }\n- }\n- }\n- return uri;\n- },\n \n /**\n- * Method: getXMLDoc\n- * Get an XML document for nodes that are not supported in HTML (e.g.\n- * createCDATASection). On IE, this will either return an existing or\n- * create a new on the instance. On other browsers, this will\n- * either return an existing or create a new shared document (see\n- * ).\n- *\n- * Returns:\n- * {XMLDocument}\n+ * APIProperty: graphicOpacity\n+ * {Number} Opacity (0-1) for an external graphic.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- getXMLDoc: function() {\n- if (!OpenLayers.Format.XML.document && !this.xmldom) {\n- if (document.implementation && document.implementation.createDocument) {\n- OpenLayers.Format.XML.document =\n- document.implementation.createDocument(\"\", \"\", null);\n- } else if (!this.xmldom && window.ActiveXObject) {\n- this.xmldom = new ActiveXObject(\"Microsoft.XMLDOM\");\n- }\n- }\n- return OpenLayers.Format.XML.document || this.xmldom;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Format.XML\"\n-\n-});\n-\n-OpenLayers.Format.XML.CONTENT_TYPE = {\n- EMPTY: 0,\n- SIMPLE: 1,\n- COMPLEX: 2,\n- MIXED: 3\n-};\n-\n-/**\n- * APIFunction: OpenLayers.Format.XML.lookupNamespaceURI\n- * Takes a prefix and returns the namespace URI associated with it on the given\n- * node if found (and null if not). Supplying null for the prefix will\n- * return the default namespace.\n- *\n- * For browsers that support it, this calls the native lookupNamesapceURI\n- * function. In other browsers, this is an implementation of\n- * http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespaceURI.\n- *\n- * For browsers that don't support the attribute.ownerElement property, this\n- * method cannot be called on attribute nodes.\n- * \n- * Parameters:\n- * node - {DOMElement} The node from which to start looking.\n- * prefix - {String} The prefix to lookup or null to lookup the default namespace.\n- * \n- * Returns:\n- * {String} The namespace URI for the given prefix. Returns null if the prefix\n- * cannot be found or the node is the wrong type.\n- */\n-OpenLayers.Format.XML.lookupNamespaceURI = OpenLayers.Function.bind(\n- OpenLayers.Format.XML.prototype.lookupNamespaceURI,\n- OpenLayers.Format.XML.prototype\n-);\n-\n-/**\n- * Property: OpenLayers.Format.XML.document\n- * {XMLDocument} XML document to reuse for creating non-HTML compliant nodes,\n- * like document.createCDATASection.\n- */\n-OpenLayers.Format.XML.document = null;\n-/* ======================================================================\n- OpenLayers/Format/OGCExceptionReport.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Format/XML.js\n- */\n-\n-/**\n- * Class: OpenLayers.Format.OGCExceptionReport\n- * Class to read exception reports for various OGC services and versions.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Format.OGCExceptionReport = OpenLayers.Class(OpenLayers.Format.XML, {\n \n /**\n- * Property: namespaces\n- * {Object} Mapping of namespace aliases to namespace URIs.\n+ * APIProperty: graphicXOffset\n+ * {Number} Pixel offset along the positive x axis for displacing an \n+ * external graphic.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- namespaces: {\n- ogc: \"http://www.opengis.net/ogc\"\n- },\n \n /**\n- * Property: regExes\n- * Compiled regular expressions for manipulating strings.\n+ * APIProperty: graphicYOffset\n+ * {Number} Pixel offset along the positive y axis for displacing an \n+ * external graphic.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- regExes: {\n- trimSpace: (/^\\s*|\\s*$/g),\n- removeSpace: (/\\s*/g),\n- splitSpace: (/\\s+/),\n- trimComma: (/\\s*,\\s*/g)\n- },\n \n /**\n- * Property: defaultPrefix\n+ * APIProperty: rotation\n+ * {Number} The rotation of a graphic in the clockwise direction about its \n+ * center point (or any point off center as specified by \n+ * and ).\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- defaultPrefix: \"ogc\",\n \n /**\n- * Constructor: OpenLayers.Format.OGCExceptionReport\n- * Create a new parser for OGC exception reports.\n- *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ * APIProperty: graphicName\n+ * {String} Named graphic to use when rendering points. Supported values \n+ * include \"circle\", \"square\", \"star\", \"x\", \"cross\", and \"triangle\".\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n \n /**\n- * APIMethod: read\n- * Read OGC exception report data from a string, and return an object with\n- * information about the exceptions.\n+ * Constructor: OpenLayers.Symbolizer.Point\n+ * Create a symbolizer for rendering points.\n *\n * Parameters:\n- * data - {String} or {DOMElement} data to read/parse.\n+ * config - {Object} An object containing properties to be set on the \n+ * symbolizer. Any documented symbolizer property can be set at \n+ * construction.\n *\n * Returns:\n- * {Object} Information about the exceptions that occurred.\n- */\n- read: function(data) {\n- var result;\n- if (typeof data == \"string\") {\n- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n- }\n- var root = data.documentElement;\n- var exceptionInfo = {\n- exceptionReport: null\n- };\n- if (root) {\n- this.readChildNodes(data, exceptionInfo);\n- if (exceptionInfo.exceptionReport === null) {\n- // fall-back to OWSCommon since this is a common output format for exceptions\n- // we cannot easily use the ows readers directly since they differ for 1.0 and 1.1\n- exceptionInfo = new OpenLayers.Format.OWSCommon().read(data);\n- }\n- }\n- return exceptionInfo;\n- },\n-\n- /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n+ * A new point symbolizer.\n */\n- readers: {\n- \"ogc\": {\n- \"ServiceExceptionReport\": function(node, obj) {\n- obj.exceptionReport = {\n- exceptions: []\n- };\n- this.readChildNodes(node, obj.exceptionReport);\n- },\n- \"ServiceException\": function(node, exceptionReport) {\n- var exception = {\n- code: node.getAttribute(\"code\"),\n- locator: node.getAttribute(\"locator\"),\n- text: this.getChildValue(node)\n- };\n- exceptionReport.exceptions.push(exception);\n- }\n- }\n+ initialize: function(config) {\n+ OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);\n },\n \n- CLASS_NAME: \"OpenLayers.Format.OGCExceptionReport\"\n+ CLASS_NAME: \"OpenLayers.Symbolizer.Point\"\n \n });\n+\n /* ======================================================================\n- OpenLayers/Format/XML/VersionedOGC.js\n+ OpenLayers/Symbolizer/Line.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format/XML.js\n- * @requires OpenLayers/Format/OGCExceptionReport.js\n+ * @requires OpenLayers/Symbolizer.js\n */\n \n /**\n- * Class: OpenLayers.Format.XML.VersionedOGC\n- * Base class for versioned formats, i.e. a format which supports multiple\n- * versions.\n- *\n- * To enable checking if parsing succeeded, you will need to define a property\n- * called errorProperty on the parser you want to check. The parser will then\n- * check the returned object to see if that property is present. If it is, it\n- * assumes the parsing was successful. If it is not present (or is null), it will\n- * pass the document through an OGCExceptionReport parser.\n- * \n- * If errorProperty is undefined for the parser, this error checking mechanism\n- * will be disabled.\n- *\n- *\n- * \n- * Inherits from:\n- * - \n+ * Class: OpenLayers.Symbolizer.Line\n+ * A symbolizer used to render line features.\n */\n-OpenLayers.Format.XML.VersionedOGC = OpenLayers.Class(OpenLayers.Format.XML, {\n-\n- /**\n- * APIProperty: defaultVersion\n- * {String} Version number to assume if none found.\n- */\n- defaultVersion: null,\n-\n- /**\n- * APIProperty: version\n- * {String} Specify a version string if one is known.\n- */\n- version: null,\n-\n- /**\n- * APIProperty: profile\n- * {String} If provided, use a custom profile.\n- */\n- profile: null,\n-\n- /**\n- * APIProperty: allowFallback\n- * {Boolean} If a profiled parser cannot be found for the returned version,\n- * use a non-profiled parser as the fallback. Application code using this\n- * should take into account that the return object structure might be\n- * missing the specifics of the profile. Defaults to false.\n- */\n- allowFallback: false,\n-\n- /**\n- * Property: name\n- * {String} The name of this parser, this is the part of the CLASS_NAME\n- * except for \"OpenLayers.Format.\"\n- */\n- name: null,\n+OpenLayers.Symbolizer.Line = OpenLayers.Class(OpenLayers.Symbolizer, {\n \n /**\n- * APIProperty: stringifyOutput\n- * {Boolean} If true, write will return a string otherwise a DOMElement.\n- * Default is false.\n+ * APIProperty: strokeColor\n+ * {String} Color for line stroke. This is a RGB hex value (e.g. \"#ff0000\"\n+ * for red). \n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- stringifyOutput: false,\n \n /**\n- * Property: parser\n- * {Object} Instance of the versioned parser. Cached for multiple read and\n- * write calls of the same version.\n+ * APIProperty: strokeOpacity\n+ * {Number} Stroke opacity (0-1).\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- parser: null,\n \n /**\n- * Constructor: OpenLayers.Format.XML.VersionedOGC.\n- * Constructor.\n- *\n- * Parameters:\n- * options - {Object} Optional object whose properties will be set on\n- * the object.\n+ * APIProperty: strokeWidth\n+ * {Number} Pixel stroke width.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- initialize: function(options) {\n- OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);\n- var className = this.CLASS_NAME;\n- this.name = className.substring(className.lastIndexOf(\".\") + 1);\n- },\n \n /**\n- * Method: getVersion\n- * Returns the version to use. Subclasses can override this function\n- * if a different version detection is needed.\n- *\n- * Parameters:\n- * root - {DOMElement}\n- * options - {Object} Optional configuration object.\n- *\n- * Returns:\n- * {String} The version to use.\n+ * APIProperty: strokeLinecap\n+ * {String} Stroke cap type (\"butt\", \"round\", or \"square\").\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- getVersion: function(root, options) {\n- var version;\n- // read\n- if (root) {\n- version = this.version;\n- if (!version) {\n- version = root.getAttribute(\"version\");\n- if (!version) {\n- version = this.defaultVersion;\n- }\n- }\n- } else { // write\n- version = (options && options.version) ||\n- this.version || this.defaultVersion;\n- }\n- return version;\n- },\n \n /**\n- * Method: getParser\n- * Get an instance of the cached parser if available, otherwise create one.\n- *\n- * Parameters:\n- * version - {String}\n- *\n- * Returns:\n- * {}\n+ * Property: strokeDashstyle\n+ * {String} Stroke dash style according to the SLD spec. Note that the\n+ * OpenLayers values for strokeDashstyle (\"dot\", \"dash\", \"dashdot\",\n+ * \"longdash\", \"longdashdot\", or \"solid\") will not work in SLD, but\n+ * most SLD patterns will render correctly in OpenLayers.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- getParser: function(version) {\n- version = version || this.defaultVersion;\n- var profile = this.profile ? \"_\" + this.profile : \"\";\n- if (!this.parser || this.parser.VERSION != version) {\n- var format = OpenLayers.Format[this.name][\n- \"v\" + version.replace(/\\./g, \"_\") + profile\n- ];\n- if (!format) {\n- if (profile !== \"\" && this.allowFallback) {\n- // fallback to the non-profiled version of the parser\n- profile = \"\";\n- format = OpenLayers.Format[this.name][\n- \"v\" + version.replace(/\\./g, \"_\")\n- ];\n- }\n- if (!format) {\n- throw \"Can't find a \" + this.name + \" parser for version \" +\n- version + profile;\n- }\n- }\n- this.parser = new format(this.options);\n- }\n- return this.parser;\n- },\n \n /**\n- * APIMethod: write\n- * Write a document.\n+ * Constructor: OpenLayers.Symbolizer.Line\n+ * Create a symbolizer for rendering lines.\n *\n * Parameters:\n- * obj - {Object} An object representing the document.\n- * options - {Object} Optional configuration object.\n+ * config - {Object} An object containing properties to be set on the \n+ * symbolizer. Any documented symbolizer property can be set at \n+ * construction.\n *\n * Returns:\n- * {String} The document as a string\n+ * A new line symbolizer.\n */\n- write: function(obj, options) {\n- var version = this.getVersion(null, options);\n- this.parser = this.getParser(version);\n- var root = this.parser.write(obj, options);\n- if (this.stringifyOutput === false) {\n- return root;\n- } else {\n- return OpenLayers.Format.XML.prototype.write.apply(this, [root]);\n- }\n+ initialize: function(config) {\n+ OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);\n },\n \n- /**\n- * APIMethod: read\n- * Read a doc and return an object representing the document.\n- *\n- * Parameters:\n- * data - {String | DOMElement} Data to read.\n- * options - {Object} Options for the reader.\n- *\n- * Returns:\n- * {Object} An object representing the document.\n- */\n- read: function(data, options) {\n- if (typeof data == \"string\") {\n- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n- }\n- var root = data.documentElement;\n- var version = this.getVersion(root);\n- this.parser = this.getParser(version); // Select the parser\n- var obj = this.parser.read(data, options); // Parse the data\n-\n- var errorProperty = this.parser.errorProperty || null;\n- if (errorProperty !== null && obj[errorProperty] === undefined) {\n- // an error must have happened, so parse it and report back\n- var format = new OpenLayers.Format.OGCExceptionReport();\n- obj.error = format.read(data);\n- }\n- obj.version = version;\n- return obj;\n- },\n+ CLASS_NAME: \"OpenLayers.Symbolizer.Line\"\n \n- CLASS_NAME: \"OpenLayers.Format.XML.VersionedOGC\"\n });\n+\n /* ======================================================================\n- OpenLayers/Format/OWSCommon.js\n+ OpenLayers/Symbolizer/Polygon.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format/XML/VersionedOGC.js\n+ * @requires OpenLayers/Symbolizer.js\n */\n \n /**\n- * Class: OpenLayers.Format.OWSCommon\n- * Read OWSCommon. Create a new instance with the \n- * constructor.\n- * \n- * Inherits from:\n- * - \n+ * Class: OpenLayers.Symbolizer.Polygon\n+ * A symbolizer used to render line features.\n */\n-OpenLayers.Format.OWSCommon = OpenLayers.Class(OpenLayers.Format.XML.VersionedOGC, {\n+OpenLayers.Symbolizer.Polygon = OpenLayers.Class(OpenLayers.Symbolizer, {\n \n /**\n- * APIProperty: defaultVersion\n- * {String} Version number to assume if none found. Default is \"1.0.0\".\n+ * APIProperty: strokeColor\n+ * {String} Color for line stroke. This is a RGB hex value (e.g. \"#ff0000\"\n+ * for red).\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- defaultVersion: \"1.0.0\",\n \n /**\n- * Constructor: OpenLayers.Format.OWSCommon\n- * Create a new parser for OWSCommon.\n- *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ * APIProperty: strokeOpacity\n+ * {Number} Stroke opacity (0-1).\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n \n /**\n- * Method: getVersion\n- * Returns the version to use. Subclasses can override this function\n- * if a different version detection is needed.\n- *\n- * Parameters:\n- * root - {DOMElement}\n- * options - {Object} Optional configuration object.\n- *\n- * Returns:\n- * {String} The version to use.\n+ * APIProperty: strokeWidth\n+ * {Number} Pixel stroke width.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- getVersion: function(root, options) {\n- var version = this.version;\n- if (!version) {\n- // remember version does not correspond to the OWS version\n- // it corresponds to the WMS/WFS/WCS etc. request version\n- var uri = root.getAttribute(\"xmlns:ows\");\n- // the above will fail if the namespace prefix is different than\n- // ows and if the namespace is declared on a different element\n- if (uri && uri.substring(uri.lastIndexOf(\"/\") + 1) === \"1.1\") {\n- version = \"1.1.0\";\n- }\n- if (!version) {\n- version = this.defaultVersion;\n- }\n- }\n- return version;\n- },\n \n /**\n- * APIMethod: read\n- * Read an OWSCommon document and return an object.\n- *\n- * Parameters:\n- * data - {String | DOMElement} Data to read.\n- * options - {Object} Options for the reader.\n- *\n- * Returns:\n- * {Object} An object representing the structure of the document.\n+ * APIProperty: strokeLinecap\n+ * {String} Stroke cap type (\"butt\", \"round\", or \"square\").\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n \n- CLASS_NAME: \"OpenLayers.Format.OWSCommon\"\n-});\n-/* ======================================================================\n- OpenLayers/Format/OWSCommon/v1.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Format/OWSCommon.js\n- */\n-\n-/**\n- * Class: OpenLayers.Format.OWSCommon.v1\n- * Common readers and writers for OWSCommon v1.X formats\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Format.OWSCommon.v1 = OpenLayers.Class(OpenLayers.Format.XML, {\n-\n /**\n- * Property: regExes\n- * Compiled regular expressions for manipulating strings.\n+ * Property: strokeDashstyle\n+ * {String} Stroke dash style according to the SLD spec. Note that the\n+ * OpenLayers values for strokeDashstyle (\"dot\", \"dash\", \"dashdot\",\n+ * \"longdash\", \"longdashdot\", or \"solid\") will not work in SLD, but\n+ * most SLD patterns will render correctly in OpenLayers.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- regExes: {\n- trimSpace: (/^\\s*|\\s*$/g),\n- removeSpace: (/\\s*/g),\n- splitSpace: (/\\s+/),\n- trimComma: (/\\s*,\\s*/g)\n- },\n \n /**\n- * Method: read\n- *\n- * Parameters:\n- * data - {DOMElement} An OWSCommon document element.\n- * options - {Object} Options for the reader.\n- *\n- * Returns:\n- * {Object} An object representing the OWSCommon document.\n+ * APIProperty: fillColor\n+ * {String} RGB hex fill color (e.g. \"#ff0000\" for red).\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- read: function(data, options) {\n- options = OpenLayers.Util.applyDefaults(options, this.options);\n- var ows = {};\n- this.readChildNodes(data, ows);\n- return ows;\n- },\n \n /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n+ * APIProperty: fillOpacity\n+ * {Number} Fill opacity (0-1).\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- readers: {\n- \"ows\": {\n- \"Exception\": function(node, exceptionReport) {\n- var exception = {\n- code: node.getAttribute('exceptionCode'),\n- locator: node.getAttribute('locator'),\n- texts: []\n- };\n- exceptionReport.exceptions.push(exception);\n- this.readChildNodes(node, exception);\n- },\n- \"ExceptionText\": function(node, exception) {\n- var text = this.getChildValue(node);\n- exception.texts.push(text);\n- },\n- \"ServiceIdentification\": function(node, obj) {\n- obj.serviceIdentification = {};\n- this.readChildNodes(node, obj.serviceIdentification);\n- },\n- \"Title\": function(node, obj) {\n- obj.title = this.getChildValue(node);\n- },\n- \"Abstract\": function(node, serviceIdentification) {\n- serviceIdentification[\"abstract\"] = this.getChildValue(node);\n- },\n- \"Keywords\": function(node, serviceIdentification) {\n- serviceIdentification.keywords = {};\n- this.readChildNodes(node, serviceIdentification.keywords);\n- },\n- \"Keyword\": function(node, keywords) {\n- keywords[this.getChildValue(node)] = true;\n- },\n- \"ServiceType\": function(node, serviceIdentification) {\n- serviceIdentification.serviceType = {\n- codeSpace: node.getAttribute('codeSpace'),\n- value: this.getChildValue(node)\n- };\n- },\n- \"ServiceTypeVersion\": function(node, serviceIdentification) {\n- serviceIdentification.serviceTypeVersion = this.getChildValue(node);\n- },\n- \"Fees\": function(node, serviceIdentification) {\n- serviceIdentification.fees = this.getChildValue(node);\n- },\n- \"AccessConstraints\": function(node, serviceIdentification) {\n- serviceIdentification.accessConstraints =\n- this.getChildValue(node);\n- },\n- \"ServiceProvider\": function(node, obj) {\n- obj.serviceProvider = {};\n- this.readChildNodes(node, obj.serviceProvider);\n- },\n- \"ProviderName\": function(node, serviceProvider) {\n- serviceProvider.providerName = this.getChildValue(node);\n- },\n- \"ProviderSite\": function(node, serviceProvider) {\n- serviceProvider.providerSite = this.getAttributeNS(node,\n- this.namespaces.xlink, \"href\");\n- },\n- \"ServiceContact\": function(node, serviceProvider) {\n- serviceProvider.serviceContact = {};\n- this.readChildNodes(node, serviceProvider.serviceContact);\n- },\n- \"IndividualName\": function(node, serviceContact) {\n- serviceContact.individualName = this.getChildValue(node);\n- },\n- \"PositionName\": function(node, serviceContact) {\n- serviceContact.positionName = this.getChildValue(node);\n- },\n- \"ContactInfo\": function(node, serviceContact) {\n- serviceContact.contactInfo = {};\n- this.readChildNodes(node, serviceContact.contactInfo);\n- },\n- \"Phone\": function(node, contactInfo) {\n- contactInfo.phone = {};\n- this.readChildNodes(node, contactInfo.phone);\n- },\n- \"Voice\": function(node, phone) {\n- phone.voice = this.getChildValue(node);\n- },\n- \"Address\": function(node, contactInfo) {\n- contactInfo.address = {};\n- this.readChildNodes(node, contactInfo.address);\n- },\n- \"DeliveryPoint\": function(node, address) {\n- address.deliveryPoint = this.getChildValue(node);\n- },\n- \"City\": function(node, address) {\n- address.city = this.getChildValue(node);\n- },\n- \"AdministrativeArea\": function(node, address) {\n- address.administrativeArea = this.getChildValue(node);\n- },\n- \"PostalCode\": function(node, address) {\n- address.postalCode = this.getChildValue(node);\n- },\n- \"Country\": function(node, address) {\n- address.country = this.getChildValue(node);\n- },\n- \"ElectronicMailAddress\": function(node, address) {\n- address.electronicMailAddress = this.getChildValue(node);\n- },\n- \"Role\": function(node, serviceContact) {\n- serviceContact.role = this.getChildValue(node);\n- },\n- \"OperationsMetadata\": function(node, obj) {\n- obj.operationsMetadata = {};\n- this.readChildNodes(node, obj.operationsMetadata);\n- },\n- \"Operation\": function(node, operationsMetadata) {\n- var name = node.getAttribute(\"name\");\n- operationsMetadata[name] = {};\n- this.readChildNodes(node, operationsMetadata[name]);\n- },\n- \"DCP\": function(node, operation) {\n- operation.dcp = {};\n- this.readChildNodes(node, operation.dcp);\n- },\n- \"HTTP\": function(node, dcp) {\n- dcp.http = {};\n- this.readChildNodes(node, dcp.http);\n- },\n- \"Get\": function(node, http) {\n- if (!http.get) {\n- http.get = [];\n- }\n- var obj = {\n- url: this.getAttributeNS(node, this.namespaces.xlink, \"href\")\n- };\n- this.readChildNodes(node, obj);\n- http.get.push(obj);\n- },\n- \"Post\": function(node, http) {\n- if (!http.post) {\n- http.post = [];\n- }\n- var obj = {\n- url: this.getAttributeNS(node, this.namespaces.xlink, \"href\")\n- };\n- this.readChildNodes(node, obj);\n- http.post.push(obj);\n- },\n- \"Parameter\": function(node, operation) {\n- if (!operation.parameters) {\n- operation.parameters = {};\n- }\n- var name = node.getAttribute(\"name\");\n- operation.parameters[name] = {};\n- this.readChildNodes(node, operation.parameters[name]);\n- },\n- \"Constraint\": function(node, obj) {\n- if (!obj.constraints) {\n- obj.constraints = {};\n- }\n- var name = node.getAttribute(\"name\");\n- obj.constraints[name] = {};\n- this.readChildNodes(node, obj.constraints[name]);\n- },\n- \"Value\": function(node, allowedValues) {\n- allowedValues[this.getChildValue(node)] = true;\n- },\n- \"OutputFormat\": function(node, obj) {\n- obj.formats.push({\n- value: this.getChildValue(node)\n- });\n- this.readChildNodes(node, obj);\n- },\n- \"WGS84BoundingBox\": function(node, obj) {\n- var boundingBox = {};\n- boundingBox.crs = node.getAttribute(\"crs\");\n- if (obj.BoundingBox) {\n- obj.BoundingBox.push(boundingBox);\n- } else {\n- obj.projection = boundingBox.crs;\n- boundingBox = obj;\n- }\n- this.readChildNodes(node, boundingBox);\n- },\n- \"BoundingBox\": function(node, obj) {\n- // FIXME: We consider that BoundingBox is the same as WGS84BoundingBox\n- // LowerCorner = \"min_x min_y\"\n- // UpperCorner = \"max_x max_y\"\n- // It should normally depend on the projection\n- this.readers['ows']['WGS84BoundingBox'].apply(this, [node, obj]);\n- },\n- \"LowerCorner\": function(node, obj) {\n- var str = this.getChildValue(node).replace(\n- this.regExes.trimSpace, \"\");\n- str = str.replace(this.regExes.trimComma, \",\");\n- var pointList = str.split(this.regExes.splitSpace);\n- obj.left = pointList[0];\n- obj.bottom = pointList[1];\n- },\n- \"UpperCorner\": function(node, obj) {\n- var str = this.getChildValue(node).replace(\n- this.regExes.trimSpace, \"\");\n- str = str.replace(this.regExes.trimComma, \",\");\n- var pointList = str.split(this.regExes.splitSpace);\n- obj.right = pointList[0];\n- obj.top = pointList[1];\n- obj.bounds = new OpenLayers.Bounds(obj.left, obj.bottom,\n- obj.right, obj.top);\n- delete obj.left;\n- delete obj.bottom;\n- delete obj.right;\n- delete obj.top;\n- },\n- \"Language\": function(node, obj) {\n- obj.language = this.getChildValue(node);\n- }\n- }\n- },\n \n /**\n- * Property: writers\n- * As a compliment to the readers property, this structure contains public\n- * writing functions grouped by namespace alias and named like the\n- * node names they produce.\n+ * Constructor: OpenLayers.Symbolizer.Polygon\n+ * Create a symbolizer for rendering polygons.\n+ *\n+ * Parameters:\n+ * config - {Object} An object containing properties to be set on the \n+ * symbolizer. Any documented symbolizer property can be set at \n+ * construction.\n+ *\n+ * Returns:\n+ * A new polygon symbolizer.\n */\n- writers: {\n- \"ows\": {\n- \"BoundingBox\": function(options, nodeName) {\n- var node = this.createElementNSPlus(nodeName || \"ows:BoundingBox\", {\n- attributes: {\n- crs: options.projection\n- }\n- });\n- this.writeNode(\"ows:LowerCorner\", options, node);\n- this.writeNode(\"ows:UpperCorner\", options, node);\n- return node;\n- },\n- \"LowerCorner\": function(options) {\n- var node = this.createElementNSPlus(\"ows:LowerCorner\", {\n- value: options.bounds.left + \" \" + options.bounds.bottom\n- });\n- return node;\n- },\n- \"UpperCorner\": function(options) {\n- var node = this.createElementNSPlus(\"ows:UpperCorner\", {\n- value: options.bounds.right + \" \" + options.bounds.top\n- });\n- return node;\n- },\n- \"Identifier\": function(identifier) {\n- var node = this.createElementNSPlus(\"ows:Identifier\", {\n- value: identifier\n- });\n- return node;\n- },\n- \"Title\": function(title) {\n- var node = this.createElementNSPlus(\"ows:Title\", {\n- value: title\n- });\n- return node;\n- },\n- \"Abstract\": function(abstractValue) {\n- var node = this.createElementNSPlus(\"ows:Abstract\", {\n- value: abstractValue\n- });\n- return node;\n- },\n- \"OutputFormat\": function(format) {\n- var node = this.createElementNSPlus(\"ows:OutputFormat\", {\n- value: format\n- });\n- return node;\n- }\n- }\n+ initialize: function(config) {\n+ OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);\n },\n \n- CLASS_NAME: \"OpenLayers.Format.OWSCommon.v1\"\n+ CLASS_NAME: \"OpenLayers.Symbolizer.Polygon\"\n \n });\n-/* ======================================================================\n- OpenLayers/Format/OWSCommon/v1_1_0.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Format/OWSCommon/v1.js\n- */\n-\n-/**\n- * Class: OpenLayers.Format.OWSCommon.v1_1_0\n- * Parser for OWS Common version 1.1.0.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Format.OWSCommon.v1_1_0 = OpenLayers.Class(OpenLayers.Format.OWSCommon.v1, {\n-\n- /**\n- * Property: namespaces\n- * {Object} Mapping of namespace aliases to namespace URIs.\n- */\n- namespaces: {\n- ows: \"http://www.opengis.net/ows/1.1\",\n- xlink: \"http://www.w3.org/1999/xlink\"\n- },\n-\n- /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n- */\n- readers: {\n- \"ows\": OpenLayers.Util.applyDefaults({\n- \"ExceptionReport\": function(node, obj) {\n- obj.exceptionReport = {\n- version: node.getAttribute('version'),\n- language: node.getAttribute('xml:lang'),\n- exceptions: []\n- };\n- this.readChildNodes(node, obj.exceptionReport);\n- },\n- \"AllowedValues\": function(node, parameter) {\n- parameter.allowedValues = {};\n- this.readChildNodes(node, parameter.allowedValues);\n- },\n- \"AnyValue\": function(node, parameter) {\n- parameter.anyValue = true;\n- },\n- \"DataType\": function(node, parameter) {\n- parameter.dataType = this.getChildValue(node);\n- },\n- \"Range\": function(node, allowedValues) {\n- allowedValues.range = {};\n- this.readChildNodes(node, allowedValues.range);\n- },\n- \"MinimumValue\": function(node, range) {\n- range.minValue = this.getChildValue(node);\n- },\n- \"MaximumValue\": function(node, range) {\n- range.maxValue = this.getChildValue(node);\n- },\n- \"Identifier\": function(node, obj) {\n- obj.identifier = this.getChildValue(node);\n- },\n- \"SupportedCRS\": function(node, obj) {\n- obj.supportedCRS = this.getChildValue(node);\n- }\n- }, OpenLayers.Format.OWSCommon.v1.prototype.readers[\"ows\"])\n- },\n-\n- /**\n- * Property: writers\n- * As a compliment to the readers property, this structure contains public\n- * writing functions grouped by namespace alias and named like the\n- * node names they produce.\n- */\n- writers: {\n- \"ows\": OpenLayers.Util.applyDefaults({\n- \"Range\": function(range) {\n- var node = this.createElementNSPlus(\"ows:Range\", {\n- attributes: {\n- 'ows:rangeClosure': range.closure\n- }\n- });\n- this.writeNode(\"ows:MinimumValue\", range.minValue, node);\n- this.writeNode(\"ows:MaximumValue\", range.maxValue, node);\n- return node;\n- },\n- \"MinimumValue\": function(minValue) {\n- var node = this.createElementNSPlus(\"ows:MinimumValue\", {\n- value: minValue\n- });\n- return node;\n- },\n- \"MaximumValue\": function(maxValue) {\n- var node = this.createElementNSPlus(\"ows:MaximumValue\", {\n- value: maxValue\n- });\n- return node;\n- },\n- \"Value\": function(value) {\n- var node = this.createElementNSPlus(\"ows:Value\", {\n- value: value\n- });\n- return node;\n- }\n- }, OpenLayers.Format.OWSCommon.v1.prototype.writers[\"ows\"])\n- },\n \n- CLASS_NAME: \"OpenLayers.Format.OWSCommon.v1_1_0\"\n-\n-});\n /* ======================================================================\n- OpenLayers/Format/WCSGetCoverage.js\n+ OpenLayers/Symbolizer/Text.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format/XML.js\n- * @requires OpenLayers/Format/OWSCommon/v1_1_0.js\n+ * @requires OpenLayers/Symbolizer.js\n */\n \n /**\n- * Class: OpenLayers.Format.WCSGetCoverage version 1.1.0\n- *\n- * Inherits from:\n- * - \n+ * Class: OpenLayers.Symbolizer.Text\n+ * A symbolizer used to render text labels for features.\n */\n-OpenLayers.Format.WCSGetCoverage = OpenLayers.Class(OpenLayers.Format.XML, {\n+OpenLayers.Symbolizer.Text = OpenLayers.Class(OpenLayers.Symbolizer, {\n \n- /**\n- * Property: namespaces\n- * {Object} Mapping of namespace aliases to namespace URIs.\n+ /** \n+ * APIProperty: label\n+ * {String} The text for the label.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- namespaces: {\n- ows: \"http://www.opengis.net/ows/1.1\",\n- wcs: \"http://www.opengis.net/wcs/1.1\",\n- xlink: \"http://www.w3.org/1999/xlink\",\n- xsi: \"http://www.w3.org/2001/XMLSchema-instance\"\n- },\n \n- /**\n- * Property: regExes\n- * Compiled regular expressions for manipulating strings.\n+ /** \n+ * APIProperty: fontFamily\n+ * {String} The font family for the label.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- regExes: {\n- trimSpace: (/^\\s*|\\s*$/g),\n- removeSpace: (/\\s*/g),\n- splitSpace: (/\\s+/),\n- trimComma: (/\\s*,\\s*/g)\n- },\n \n- /**\n- * Constant: VERSION\n- * {String} 1.1.2\n+ /** \n+ * APIProperty: fontSize\n+ * {String} The font size for the label.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- VERSION: \"1.1.2\",\n \n- /**\n- * Property: schemaLocation\n- * {String} Schema location\n+ /** \n+ * APIProperty: fontWeight\n+ * {String} The font weight for the label.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n- schemaLocation: \"http://www.opengis.net/wcs/1.1 http://schemas.opengis.net/wcs/1.1/wcsGetCoverage.xsd\",\n \n /**\n- * Constructor: OpenLayers.Format.WCSGetCoverage\n- *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ * Property: fontStyle\n+ * {String} The font style for the label.\n+ * \n+ * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n */\n \n /**\n- * Method: write\n+ * Constructor: OpenLayers.Symbolizer.Text\n+ * Create a symbolizer for rendering text labels.\n *\n * Parameters:\n- * options - {Object} Optional object.\n+ * config - {Object} An object containing properties to be set on the \n+ * symbolizer. Any documented symbolizer property can be set at \n+ * construction.\n *\n * Returns:\n- * {String} A WCS GetCoverage request XML string.\n- */\n- write: function(options) {\n- var node = this.writeNode(\"wcs:GetCoverage\", options);\n- this.setAttributeNS(\n- node, this.namespaces.xsi,\n- \"xsi:schemaLocation\", this.schemaLocation\n- );\n- return OpenLayers.Format.XML.prototype.write.apply(this, [node]);\n- },\n-\n- /**\n- * Property: writers\n- * As a compliment to the readers property, this structure contains public\n- * writing functions grouped by namespace alias and named like the\n- * node names they produce.\n+ * A new text symbolizer.\n */\n- writers: {\n- \"wcs\": {\n- \"GetCoverage\": function(options) {\n- var node = this.createElementNSPlus(\"wcs:GetCoverage\", {\n- attributes: {\n- version: options.version || this.VERSION,\n- service: 'WCS'\n- }\n- });\n- this.writeNode(\"ows:Identifier\", options.identifier, node);\n- this.writeNode(\"wcs:DomainSubset\", options.domainSubset, node);\n- this.writeNode(\"wcs:Output\", options.output, node);\n- return node;\n- },\n- \"DomainSubset\": function(domainSubset) {\n- var node = this.createElementNSPlus(\"wcs:DomainSubset\", {});\n- this.writeNode(\"ows:BoundingBox\", domainSubset.boundingBox, node);\n- if (domainSubset.temporalSubset) {\n- this.writeNode(\"wcs:TemporalSubset\", domainSubset.temporalSubset, node);\n- }\n- return node;\n- },\n- \"TemporalSubset\": function(temporalSubset) {\n- var node = this.createElementNSPlus(\"wcs:TemporalSubset\", {});\n- for (var i = 0, len = temporalSubset.timePeriods.length; i < len; ++i) {\n- this.writeNode(\"wcs:TimePeriod\", temporalSubset.timePeriods[i], node);\n- }\n- return node;\n- },\n- \"TimePeriod\": function(timePeriod) {\n- var node = this.createElementNSPlus(\"wcs:TimePeriod\", {});\n- this.writeNode(\"wcs:BeginPosition\", timePeriod.begin, node);\n- this.writeNode(\"wcs:EndPosition\", timePeriod.end, node);\n- if (timePeriod.resolution) {\n- this.writeNode(\"wcs:TimeResolution\", timePeriod.resolution, node);\n- }\n- return node;\n- },\n- \"BeginPosition\": function(begin) {\n- var node = this.createElementNSPlus(\"wcs:BeginPosition\", {\n- value: begin\n- });\n- return node;\n- },\n- \"EndPosition\": function(end) {\n- var node = this.createElementNSPlus(\"wcs:EndPosition\", {\n- value: end\n- });\n- return node;\n- },\n- \"TimeResolution\": function(resolution) {\n- var node = this.createElementNSPlus(\"wcs:TimeResolution\", {\n- value: resolution\n- });\n- return node;\n- },\n- \"Output\": function(output) {\n- var node = this.createElementNSPlus(\"wcs:Output\", {\n- attributes: {\n- format: output.format,\n- store: output.store\n- }\n- });\n- if (output.gridCRS) {\n- this.writeNode(\"wcs:GridCRS\", output.gridCRS, node);\n- }\n- return node;\n- },\n- \"GridCRS\": function(gridCRS) {\n- var node = this.createElementNSPlus(\"wcs:GridCRS\", {});\n- this.writeNode(\"wcs:GridBaseCRS\", gridCRS.baseCRS, node);\n- if (gridCRS.type) {\n- this.writeNode(\"wcs:GridType\", gridCRS.type, node);\n- }\n- if (gridCRS.origin) {\n- this.writeNode(\"wcs:GridOrigin\", gridCRS.origin, node);\n- }\n- this.writeNode(\"wcs:GridOffsets\", gridCRS.offsets, node);\n- if (gridCRS.CS) {\n- this.writeNode(\"wcs:GridCS\", gridCRS.CS, node);\n- }\n- return node;\n- },\n- \"GridBaseCRS\": function(baseCRS) {\n- return this.createElementNSPlus(\"wcs:GridBaseCRS\", {\n- value: baseCRS\n- });\n- },\n- \"GridOrigin\": function(origin) {\n- return this.createElementNSPlus(\"wcs:GridOrigin\", {\n- value: origin\n- });\n- },\n- \"GridType\": function(type) {\n- return this.createElementNSPlus(\"wcs:GridType\", {\n- value: type\n- });\n- },\n- \"GridOffsets\": function(offsets) {\n- return this.createElementNSPlus(\"wcs:GridOffsets\", {\n- value: offsets\n- });\n- },\n- \"GridCS\": function(CS) {\n- return this.createElementNSPlus(\"wcs:GridCS\", {\n- value: CS\n- });\n- }\n- },\n- \"ows\": OpenLayers.Format.OWSCommon.v1_1_0.prototype.writers.ows\n+ initialize: function(config) {\n+ OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);\n },\n \n- CLASS_NAME: \"OpenLayers.Format.WCSGetCoverage\"\n+ CLASS_NAME: \"OpenLayers.Symbolizer.Text\"\n \n });\n+\n /* ======================================================================\n- OpenLayers/Format/WFST.js\n+ OpenLayers/Symbolizer/Raster.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format.js\n+ * @requires OpenLayers/Symbolizer.js\n */\n \n /**\n- * Function: OpenLayers.Format.WFST\n- * Used to create a versioned WFS protocol. Default version is 1.0.0.\n- *\n- * Returns:\n- * {} A WFST format of the given version.\n+ * Class: OpenLayers.Symbolizer.Raster\n+ * A symbolizer used to render raster images.\n */\n-OpenLayers.Format.WFST = function(options) {\n- options = OpenLayers.Util.applyDefaults(\n- options, OpenLayers.Format.WFST.DEFAULTS\n- );\n- var cls = OpenLayers.Format.WFST[\"v\" + options.version.replace(/\\./g, \"_\")];\n- if (!cls) {\n- throw \"Unsupported WFST version: \" + options.version;\n- }\n- return new cls(options);\n-};\n+OpenLayers.Symbolizer.Raster = OpenLayers.Class(OpenLayers.Symbolizer, {\n \n-/**\n- * Constant: OpenLayers.Format.WFST.DEFAULTS\n- * {Object} Default properties for the WFST format.\n- */\n-OpenLayers.Format.WFST.DEFAULTS = {\n- \"version\": \"1.0.0\"\n-};\n+ /**\n+ * Constructor: OpenLayers.Symbolizer.Raster\n+ * Create a symbolizer for rendering rasters.\n+ *\n+ * Parameters:\n+ * config - {Object} An object containing properties to be set on the \n+ * symbolizer. Any documented symbolizer property can be set at \n+ * construction.\n+ *\n+ * Returns:\n+ * A new raster symbolizer.\n+ */\n+ initialize: function(config) {\n+ OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Symbolizer.Raster\"\n+\n+});\n /* ======================================================================\n- OpenLayers/Filter/Spatial.js\n+ OpenLayers/Style2.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Filter.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Rule.js\n+ * @requires OpenLayers/Symbolizer/Point.js\n+ * @requires OpenLayers/Symbolizer/Line.js\n+ * @requires OpenLayers/Symbolizer/Polygon.js\n+ * @requires OpenLayers/Symbolizer/Text.js\n+ * @requires OpenLayers/Symbolizer/Raster.js\n */\n \n /**\n- * Class: OpenLayers.Filter.Spatial\n- * This class represents a spatial filter.\n- * Currently implemented: BBOX, DWithin and Intersects\n- * \n- * Inherits from:\n- * - \n+ * Class: OpenLayers.Style2\n+ * This class represents a collection of rules for rendering features.\n */\n-OpenLayers.Filter.Spatial = OpenLayers.Class(OpenLayers.Filter, {\n+OpenLayers.Style2 = OpenLayers.Class({\n \n /**\n- * APIProperty: type\n- * {String} Type of spatial filter.\n- *\n- * The type should be one of:\n- * - OpenLayers.Filter.Spatial.BBOX\n- * - OpenLayers.Filter.Spatial.INTERSECTS\n- * - OpenLayers.Filter.Spatial.DWITHIN\n- * - OpenLayers.Filter.Spatial.WITHIN\n- * - OpenLayers.Filter.Spatial.CONTAINS\n+ * Property: id\n+ * {String} A unique id for this session.\n */\n- type: null,\n+ id: null,\n \n /**\n- * APIProperty: property\n- * {String} Name of the context property to compare.\n+ * APIProperty: name\n+ * {String} Style identifier.\n */\n- property: null,\n+ name: null,\n \n /**\n- * APIProperty: value\n- * { || } The bounds or geometry\n- * to be used by the filter. Use bounds for BBOX filters and geometry\n- * for INTERSECTS or DWITHIN filters.\n+ * APIProperty: title\n+ * {String} Title of this style.\n */\n- value: null,\n+ title: null,\n \n /**\n- * APIProperty: distance\n- * {Number} The distance to use in a DWithin spatial filter.\n+ * APIProperty: description\n+ * {String} Description of this style.\n */\n- distance: null,\n+ description: null,\n \n /**\n- * APIProperty: distanceUnits\n- * {String} The units to use for the distance, e.g. 'm'.\n+ * APIProperty: layerName\n+ * {} Name of the layer that this style belongs to, usually\n+ * according to the NamedLayer attribute of an SLD document.\n */\n- distanceUnits: null,\n+ layerName: null,\n+\n+ /**\n+ * APIProperty: isDefault\n+ * {Boolean}\n+ */\n+ isDefault: false,\n \n /** \n- * Constructor: OpenLayers.Filter.Spatial\n- * Creates a spatial filter.\n+ * APIProperty: rules \n+ * {Array()} Collection of rendering rules.\n+ */\n+ rules: null,\n+\n+ /** \n+ * Constructor: OpenLayers.Style2\n+ * Creates a style representing a collection of rendering rules.\n *\n * Parameters:\n- * options - {Object} An optional object with properties to set on the\n- * filter.\n- * \n+ * config - {Object} An object containing properties to be set on the \n+ * style. Any documented properties may be set at construction.\n+ *\n * Returns:\n- * {}\n+ * {} A new style object.\n */\n+ initialize: function(config) {\n+ OpenLayers.Util.extend(this, config);\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+ },\n \n- /**\n- * Method: evaluate\n- * Evaluates this filter for a specific feature.\n- * \n- * Parameters:\n- * feature - {} feature to apply the filter to.\n- * \n- * Returns:\n- * {Boolean} The feature meets filter criteria.\n+ /** \n+ * APIMethod: destroy\n+ * nullify references to prevent circular references and memory leaks\n */\n- evaluate: function(feature) {\n- var intersect = false;\n- switch (this.type) {\n- case OpenLayers.Filter.Spatial.BBOX:\n- case OpenLayers.Filter.Spatial.INTERSECTS:\n- if (feature.geometry) {\n- var geom = this.value;\n- if (this.value.CLASS_NAME == \"OpenLayers.Bounds\") {\n- geom = this.value.toGeometry();\n- }\n- if (feature.geometry.intersects(geom)) {\n- intersect = true;\n- }\n- }\n- break;\n- default:\n- throw new Error('evaluate is not implemented for this filter type.');\n+ destroy: function() {\n+ for (var i = 0, len = this.rules.length; i < len; i++) {\n+ this.rules[i].destroy();\n }\n- return intersect;\n+ delete this.rules;\n },\n \n /**\n * APIMethod: clone\n- * Clones this filter.\n+ * Clones this style.\n * \n * Returns:\n- * {} Clone of this filter.\n+ * {} Clone of this style.\n */\n clone: function() {\n- var options = OpenLayers.Util.applyDefaults({\n- value: this.value && this.value.clone && this.value.clone()\n- }, this);\n- return new OpenLayers.Filter.Spatial(options);\n+ var config = OpenLayers.Util.extend({}, this);\n+ // clone rules\n+ if (this.rules) {\n+ config.rules = [];\n+ for (var i = 0, len = this.rules.length; i < len; ++i) {\n+ config.rules.push(this.rules[i].clone());\n+ }\n+ }\n+ return new OpenLayers.Style2(config);\n },\n- CLASS_NAME: \"OpenLayers.Filter.Spatial\"\n-});\n \n-OpenLayers.Filter.Spatial.BBOX = \"BBOX\";\n-OpenLayers.Filter.Spatial.INTERSECTS = \"INTERSECTS\";\n-OpenLayers.Filter.Spatial.DWITHIN = \"DWITHIN\";\n-OpenLayers.Filter.Spatial.WITHIN = \"WITHIN\";\n-OpenLayers.Filter.Spatial.CONTAINS = \"CONTAINS\";\n+ CLASS_NAME: \"OpenLayers.Style2\"\n+});\n /* ======================================================================\n- OpenLayers/Filter/FeatureId.js\n+ OpenLayers/Filter.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n \n /**\n- * @requires OpenLayers/Filter.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Util.js\n+ * @requires OpenLayers/Style.js\n */\n \n /**\n- * Class: OpenLayers.Filter.FeatureId\n- * This class represents a ogc:FeatureId Filter, as being used for rule-based SLD\n- * styling\n- * \n- * Inherits from:\n- * - \n+ * Class: OpenLayers.Filter\n+ * This class represents an OGC Filter.\n */\n-OpenLayers.Filter.FeatureId = OpenLayers.Class(OpenLayers.Filter, {\n-\n- /** \n- * APIProperty: fids\n- * {Array(String)} Feature Ids to evaluate this rule against. \n- * To be passed inside the params object.\n- */\n- fids: null,\n-\n- /** \n- * Property: type\n- * {String} Type to identify this filter.\n- */\n- type: \"FID\",\n+OpenLayers.Filter = OpenLayers.Class({\n \n /** \n- * Constructor: OpenLayers.Filter.FeatureId\n- * Creates an ogc:FeatureId rule.\n+ * Constructor: OpenLayers.Filter\n+ * This class represents a generic filter.\n *\n * Parameters:\n- * options - {Object} An optional object with properties to set on the\n- * rule\n+ * options - {Object} Optional object whose properties will be set on the\n+ * instance.\n * \n * Returns:\n- * {}\n+ * {}\n */\n initialize: function(options) {\n- this.fids = [];\n- OpenLayers.Filter.prototype.initialize.apply(this, [options]);\n+ OpenLayers.Util.extend(this, options);\n },\n \n+ /** \n+ * APIMethod: destroy\n+ * Remove reference to anything added.\n+ */\n+ destroy: function() {},\n+\n /**\n * APIMethod: evaluate\n- * evaluates this rule for a specific feature\n+ * Evaluates this filter in a specific context. Instances or subclasses\n+ * are supposed to override this method.\n * \n * Parameters:\n- * feature - {} feature to apply the rule to.\n- * For vector features, the check is run against the fid,\n- * for plain features against the id.\n+ * context - {Object} Context to use in evaluating the filter. If a vector\n+ * feature is provided, the feature.attributes will be used as context.\n * \n * Returns:\n- * {Boolean} true if the rule applies, false if it does not\n+ * {Boolean} The filter applies.\n */\n- evaluate: function(feature) {\n- for (var i = 0, len = this.fids.length; i < len; i++) {\n- var fid = feature.fid || feature.id;\n- if (fid == this.fids[i]) {\n- return true;\n- }\n- }\n- return false;\n+ evaluate: function(context) {\n+ return true;\n },\n \n /**\n * APIMethod: clone\n- * Clones this filter.\n+ * Clones this filter. Should be implemented by subclasses.\n * \n * Returns:\n- * {} Clone of this filter.\n+ * {} Clone of this filter.\n */\n clone: function() {\n- var filter = new OpenLayers.Filter.FeatureId();\n- OpenLayers.Util.extend(filter, this);\n- filter.fids = this.fids.slice();\n- return filter;\n+ return null;\n },\n \n- CLASS_NAME: \"OpenLayers.Filter.FeatureId\"\n+ /**\n+ * APIMethod: toString\n+ *\n+ * Returns:\n+ * {String} Include in your build to get a CQL\n+ * representation of the filter returned. Otherwise \"[Object object]\"\n+ * will be returned.\n+ */\n+ toString: function() {\n+ var string;\n+ if (OpenLayers.Format && OpenLayers.Format.CQL) {\n+ string = OpenLayers.Format.CQL.prototype.write(this);\n+ } else {\n+ string = Object.prototype.toString.call(this);\n+ }\n+ return string;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Filter\"\n });\n /* ======================================================================\n- OpenLayers/Format/WFST/v1.js\n+ OpenLayers/Handler.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format/XML.js\n- * @requires OpenLayers/Format/WFST.js\n- * @requires OpenLayers/Filter/Spatial.js\n- * @requires OpenLayers/Filter/FeatureId.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Events.js\n */\n \n /**\n- * Class: OpenLayers.Format.WFST.v1\n- * Superclass for WFST parsers.\n+ * Class: OpenLayers.Handler\n+ * Base class to construct a higher-level handler for event sequences. All\n+ * handlers have activate and deactivate methods. In addition, they have\n+ * methods named like browser events. When a handler is activated, any\n+ * additional methods named like a browser event is registered as a\n+ * listener for the corresponding event. When a handler is deactivated,\n+ * those same methods are unregistered as event listeners.\n *\n- * Inherits from:\n- * - \n+ * Handlers also typically have a callbacks object with keys named like\n+ * the abstracted events or event sequences that they are in charge of\n+ * handling. The controls that wrap handlers define the methods that\n+ * correspond to these abstract events - so instead of listening for\n+ * individual browser events, they only listen for the abstract events\n+ * defined by the handler.\n+ * \n+ * Handlers are created by controls, which ultimately have the responsibility\n+ * of making changes to the the state of the application. Handlers\n+ * themselves may make temporary changes, but in general are expected to\n+ * return the application in the same state that they found it.\n */\n-OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {\n-\n- /**\n- * Property: namespaces\n- * {Object} Mapping of namespace aliases to namespace URIs.\n- */\n- namespaces: {\n- xlink: \"http://www.w3.org/1999/xlink\",\n- xsi: \"http://www.w3.org/2001/XMLSchema-instance\",\n- wfs: \"http://www.opengis.net/wfs\",\n- gml: \"http://www.opengis.net/gml\",\n- ogc: \"http://www.opengis.net/ogc\",\n- ows: \"http://www.opengis.net/ows\"\n- },\n+OpenLayers.Handler = OpenLayers.Class({\n \n /**\n- * Property: defaultPrefix\n+ * Property: id\n+ * {String}\n */\n- defaultPrefix: \"wfs\",\n+ id: null,\n \n /**\n- * Property: version\n- * {String} WFS version number.\n+ * APIProperty: control\n+ * {}. The control that initialized this handler. The\n+ * control is assumed to have a valid map property - that map is used\n+ * in the handler's own setMap method.\n */\n- version: null,\n+ control: null,\n \n /**\n- * Property: schemaLocation\n- * {String} Schema location for a particular minor version.\n+ * Property: map\n+ * {}\n */\n- schemaLocations: null,\n+ map: null,\n \n /**\n- * APIProperty: srsName\n- * {String} URI for spatial reference system.\n+ * APIProperty: keyMask\n+ * {Integer} Use bitwise operators and one or more of the OpenLayers.Handler\n+ * constants to construct a keyMask. The keyMask is used by\n+ * . If the keyMask matches the combination of keys\n+ * down on an event, checkModifiers returns true.\n+ *\n+ * Example:\n+ * (code)\n+ * // handler only responds if the Shift key is down\n+ * handler.keyMask = OpenLayers.Handler.MOD_SHIFT;\n+ *\n+ * // handler only responds if Ctrl-Shift is down\n+ * handler.keyMask = OpenLayers.Handler.MOD_SHIFT |\n+ * OpenLayers.Handler.MOD_CTRL;\n+ * (end)\n */\n- srsName: null,\n+ keyMask: null,\n \n /**\n- * APIProperty: extractAttributes\n- * {Boolean} Extract attributes from GML. Default is true.\n+ * Property: active\n+ * {Boolean}\n */\n- extractAttributes: true,\n+ active: false,\n \n /**\n- * APIProperty: xy\n- * {Boolean} Order of the GML coordinate true:(x,y) or false:(y,x)\n- * Changing is not recommended, a new Format should be instantiated.\n+ * Property: evt\n+ * {Event} This property references the last event handled by the handler.\n+ * Note that this property is not part of the stable API. Use of the\n+ * evt property should be restricted to controls in the library\n+ * or other applications that are willing to update with changes to\n+ * the OpenLayers code.\n */\n- xy: true,\n+ evt: null,\n \n /**\n- * Property: stateName\n- * {Object} Maps feature states to node names.\n+ * Property: touch\n+ * {Boolean} Indicates the support of touch events. When touch events are \n+ * started touch will be true and all mouse related listeners will do \n+ * nothing.\n */\n- stateName: null,\n+ touch: false,\n \n /**\n- * Constructor: OpenLayers.Format.WFST.v1\n- * Instances of this class are not created directly. Use the\n- * or \n- * constructor instead.\n+ * Constructor: OpenLayers.Handler\n+ * Construct a handler.\n *\n * Parameters:\n+ * control - {} The control that initialized this\n+ * handler. The control is assumed to have a valid map property; that\n+ * map is used in the handler's own setMap method. If a map property\n+ * is present in the options argument it will be used instead.\n+ * callbacks - {Object} An object whose properties correspond to abstracted\n+ * events or sequences of browser events. The values for these\n+ * properties are functions defined by the control that get called by\n+ * the handler.\n * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ * the handler.\n */\n- initialize: function(options) {\n- // set state name mapping\n- this.stateName = {};\n- this.stateName[OpenLayers.State.INSERT] = \"wfs:Insert\";\n- this.stateName[OpenLayers.State.UPDATE] = \"wfs:Update\";\n- this.stateName[OpenLayers.State.DELETE] = \"wfs:Delete\";\n- OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);\n+ initialize: function(control, callbacks, options) {\n+ OpenLayers.Util.extend(this, options);\n+ this.control = control;\n+ this.callbacks = callbacks;\n+\n+ var map = this.map || control.map;\n+ if (map) {\n+ this.setMap(map);\n+ }\n+\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n },\n \n /**\n- * Method: getSrsName\n+ * Method: setMap\n */\n- getSrsName: function(feature, options) {\n- var srsName = options && options.srsName;\n- if (!srsName) {\n- if (feature && feature.layer) {\n- srsName = feature.layer.projection.getCode();\n- } else {\n- srsName = this.srsName;\n- }\n- }\n- return srsName;\n+ setMap: function(map) {\n+ this.map = map;\n },\n \n /**\n- * APIMethod: read\n- * Parse the response from a transaction. Because WFS is split into\n- * Transaction requests (create, update, and delete) and GetFeature\n- * requests (read), this method handles parsing of both types of\n- * responses.\n- *\n- * Parameters:\n- * data - {String | Document} The WFST document to read\n- * options - {Object} Options for the reader\n- *\n- * Valid options properties:\n- * output - {String} either \"features\" or \"object\". The default is\n- * \"features\", which means that the method will return an array of\n- * features. If set to \"object\", an object with a \"features\" property\n- * and other properties read by the parser will be returned.\n+ * Method: checkModifiers\n+ * Check the keyMask on the handler. If no is set, this always\n+ * returns true. If a is set and it matches the combination\n+ * of keys down on an event, this returns true.\n *\n * Returns:\n- * {Array | Object} Output depending on the output option.\n+ * {Boolean} The keyMask matches the keys down on an event.\n */\n- read: function(data, options) {\n- options = options || {};\n- OpenLayers.Util.applyDefaults(options, {\n- output: \"features\"\n- });\n-\n- if (typeof data == \"string\") {\n- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n- }\n- if (data && data.nodeType == 9) {\n- data = data.documentElement;\n- }\n- var obj = {};\n- if (data) {\n- this.readNode(data, obj, true);\n- }\n- if (obj.features && options.output === \"features\") {\n- obj = obj.features;\n+ checkModifiers: function(evt) {\n+ if (this.keyMask == null) {\n+ return true;\n }\n- return obj;\n+ /* calculate the keyboard modifier mask for this event */\n+ var keyModifiers =\n+ (evt.shiftKey ? OpenLayers.Handler.MOD_SHIFT : 0) |\n+ (evt.ctrlKey ? OpenLayers.Handler.MOD_CTRL : 0) |\n+ (evt.altKey ? OpenLayers.Handler.MOD_ALT : 0) |\n+ (evt.metaKey ? OpenLayers.Handler.MOD_META : 0);\n+\n+ /* if it differs from the handler object's key mask,\n+ bail out of the event handler */\n+ return (keyModifiers == this.keyMask);\n },\n \n /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n+ * APIMethod: activate\n+ * Turn on the handler. Returns false if the handler was already active.\n+ * \n+ * Returns: \n+ * {Boolean} The handler was activated.\n */\n- readers: {\n- \"wfs\": {\n- \"FeatureCollection\": function(node, obj) {\n- obj.features = [];\n- this.readChildNodes(node, obj);\n+ activate: function() {\n+ if (this.active) {\n+ return false;\n+ }\n+ // register for event handlers defined on this class.\n+ var events = OpenLayers.Events.prototype.BROWSER_EVENTS;\n+ for (var i = 0, len = events.length; i < len; i++) {\n+ if (this[events[i]]) {\n+ this.register(events[i], this[events[i]]);\n }\n }\n+ this.active = true;\n+ return true;\n },\n \n /**\n- * Method: write\n- * Given an array of features, write a WFS transaction. This assumes\n- * the features have a state property that determines the operation\n- * type - insert, update, or delete.\n- *\n- * Parameters:\n- * features - {Array()} A list of features. See\n- * below for a more detailed description of the influence of the\n- * feature's *modified* property.\n- * options - {Object}\n- *\n- * feature.modified rules:\n- * If a feature has a modified property set, the following checks will be\n- * made before a feature's geometry or attribute is included in an Update\n- * transaction:\n- * - *modified* is not set at all: The geometry and all attributes will be\n- * included.\n- * - *modified.geometry* is set (null or a geometry): The geometry will be\n- * included. If *modified.attributes* is not set, all attributes will\n- * be included.\n- * - *modified.attributes* is set: Only the attributes set (i.e. to null or\n- * a value) in *modified.attributes* will be included. \n- * If *modified.geometry* is not set, the geometry will not be included.\n- *\n- * Valid options include:\n- * - *multi* {Boolean} If set to true, geometries will be casted to\n- * Multi geometries before writing.\n- *\n+ * APIMethod: deactivate\n+ * Turn off the handler. Returns false if the handler was already inactive.\n+ * \n * Returns:\n- * {String} A serialized WFS transaction.\n+ * {Boolean} The handler was deactivated.\n */\n- write: function(features, options) {\n- var node = this.writeNode(\"wfs:Transaction\", {\n- features: features,\n- options: options\n- });\n- var value = this.schemaLocationAttr();\n- if (value) {\n- this.setAttributeNS(\n- node, this.namespaces[\"xsi\"], \"xsi:schemaLocation\", value\n- );\n+ deactivate: function() {\n+ if (!this.active) {\n+ return false;\n }\n- return OpenLayers.Format.XML.prototype.write.apply(this, [node]);\n- },\n-\n- /**\n- * Property: writers\n- * As a compliment to the readers property, this structure contains public\n- * writing functions grouped by namespace alias and named like the\n- * node names they produce.\n- */\n- writers: {\n- \"wfs\": {\n- \"GetFeature\": function(options) {\n- var node = this.createElementNSPlus(\"wfs:GetFeature\", {\n- attributes: {\n- service: \"WFS\",\n- version: this.version,\n- handle: options && options.handle,\n- outputFormat: options && options.outputFormat,\n- maxFeatures: options && options.maxFeatures,\n- \"xsi:schemaLocation\": this.schemaLocationAttr(options)\n- }\n- });\n- if (typeof this.featureType == \"string\") {\n- this.writeNode(\"Query\", options, node);\n- } else {\n- for (var i = 0, len = this.featureType.length; i < len; i++) {\n- options.featureType = this.featureType[i];\n- this.writeNode(\"Query\", options, node);\n- }\n- }\n- return node;\n- },\n- \"Transaction\": function(obj) {\n- obj = obj || {};\n- var options = obj.options || {};\n- var node = this.createElementNSPlus(\"wfs:Transaction\", {\n- attributes: {\n- service: \"WFS\",\n- version: this.version,\n- handle: options.handle\n- }\n- });\n- var i, len;\n- var features = obj.features;\n- if (features) {\n- // temporarily re-assigning geometry types\n- if (options.multi === true) {\n- OpenLayers.Util.extend(this.geometryTypes, {\n- \"OpenLayers.Geometry.Point\": \"MultiPoint\",\n- \"OpenLayers.Geometry.LineString\": (this.multiCurve === true) ? \"MultiCurve\" : \"MultiLineString\",\n- \"OpenLayers.Geometry.Polygon\": (this.multiSurface === true) ? \"MultiSurface\" : \"MultiPolygon\"\n- });\n- }\n- var name, feature;\n- for (i = 0, len = features.length; i < len; ++i) {\n- feature = features[i];\n- name = this.stateName[feature.state];\n- if (name) {\n- this.writeNode(name, {\n- feature: feature,\n- options: options\n- }, node);\n- }\n- }\n- // switch back to original geometry types assignment\n- if (options.multi === true) {\n- this.setGeometryTypes();\n- }\n- }\n- if (options.nativeElements) {\n- for (i = 0, len = options.nativeElements.length; i < len; ++i) {\n- this.writeNode(\"wfs:Native\",\n- options.nativeElements[i], node);\n- }\n- }\n- return node;\n- },\n- \"Native\": function(nativeElement) {\n- var node = this.createElementNSPlus(\"wfs:Native\", {\n- attributes: {\n- vendorId: nativeElement.vendorId,\n- safeToIgnore: nativeElement.safeToIgnore\n- },\n- value: nativeElement.value\n- });\n- return node;\n- },\n- \"Insert\": function(obj) {\n- var feature = obj.feature;\n- var options = obj.options;\n- var node = this.createElementNSPlus(\"wfs:Insert\", {\n- attributes: {\n- handle: options && options.handle\n- }\n- });\n- this.srsName = this.getSrsName(feature);\n- this.writeNode(\"feature:_typeName\", feature, node);\n- return node;\n- },\n- \"Update\": function(obj) {\n- var feature = obj.feature;\n- var options = obj.options;\n- var node = this.createElementNSPlus(\"wfs:Update\", {\n- attributes: {\n- handle: options && options.handle,\n- typeName: (this.featureNS ? this.featurePrefix + \":\" : \"\") +\n- this.featureType\n- }\n- });\n- if (this.featureNS) {\n- node.setAttribute(\"xmlns:\" + this.featurePrefix, this.featureNS);\n- }\n-\n- // add in geometry\n- var modified = feature.modified;\n- if (this.geometryName !== null && (!modified || modified.geometry !== undefined)) {\n- this.srsName = this.getSrsName(feature);\n- this.writeNode(\n- \"Property\", {\n- name: this.geometryName,\n- value: feature.geometry\n- }, node\n- );\n- }\n-\n- // add in attributes\n- for (var key in feature.attributes) {\n- if (feature.attributes[key] !== undefined &&\n- (!modified || !modified.attributes ||\n- (modified.attributes && modified.attributes[key] !== undefined))) {\n- this.writeNode(\n- \"Property\", {\n- name: key,\n- value: feature.attributes[key]\n- }, node\n- );\n- }\n- }\n-\n- // add feature id filter\n- this.writeNode(\"ogc:Filter\", new OpenLayers.Filter.FeatureId({\n- fids: [feature.fid]\n- }), node);\n-\n- return node;\n- },\n- \"Property\": function(obj) {\n- var node = this.createElementNSPlus(\"wfs:Property\");\n- this.writeNode(\"Name\", obj.name, node);\n- if (obj.value !== null) {\n- this.writeNode(\"Value\", obj.value, node);\n- }\n- return node;\n- },\n- \"Name\": function(name) {\n- return this.createElementNSPlus(\"wfs:Name\", {\n- value: name\n- });\n- },\n- \"Value\": function(obj) {\n- var node;\n- if (obj instanceof OpenLayers.Geometry) {\n- node = this.createElementNSPlus(\"wfs:Value\");\n- var geom = this.writeNode(\"feature:_geometry\", obj).firstChild;\n- node.appendChild(geom);\n- } else {\n- node = this.createElementNSPlus(\"wfs:Value\", {\n- value: obj\n- });\n- }\n- return node;\n- },\n- \"Delete\": function(obj) {\n- var feature = obj.feature;\n- var options = obj.options;\n- var node = this.createElementNSPlus(\"wfs:Delete\", {\n- attributes: {\n- handle: options && options.handle,\n- typeName: (this.featureNS ? this.featurePrefix + \":\" : \"\") +\n- this.featureType\n- }\n- });\n- if (this.featureNS) {\n- node.setAttribute(\"xmlns:\" + this.featurePrefix, this.featureNS);\n- }\n- this.writeNode(\"ogc:Filter\", new OpenLayers.Filter.FeatureId({\n- fids: [feature.fid]\n- }), node);\n- return node;\n+ // unregister event handlers defined on this class.\n+ var events = OpenLayers.Events.prototype.BROWSER_EVENTS;\n+ for (var i = 0, len = events.length; i < len; i++) {\n+ if (this[events[i]]) {\n+ this.unregister(events[i], this[events[i]]);\n }\n }\n+ this.touch = false;\n+ this.active = false;\n+ return true;\n },\n \n /**\n- * Method: schemaLocationAttr\n- * Generate the xsi:schemaLocation attribute value.\n- *\n- * Returns:\n- * {String} The xsi:schemaLocation attribute or undefined if none.\n+ * Method: startTouch\n+ * Start touch events, this method must be called by subclasses in \n+ * \"touchstart\" method. When touch events are started will be\n+ * true and all mouse related listeners will do nothing.\n */\n- schemaLocationAttr: function(options) {\n- options = OpenLayers.Util.extend({\n- featurePrefix: this.featurePrefix,\n- schema: this.schema\n- }, options);\n- var schemaLocations = OpenLayers.Util.extend({}, this.schemaLocations);\n- if (options.schema) {\n- schemaLocations[options.featurePrefix] = options.schema;\n- }\n- var parts = [];\n- var uri;\n- for (var key in schemaLocations) {\n- uri = this.namespaces[key];\n- if (uri) {\n- parts.push(uri + \" \" + schemaLocations[key]);\n+ startTouch: function() {\n+ if (!this.touch) {\n+ this.touch = true;\n+ var events = [\n+ \"mousedown\", \"mouseup\", \"mousemove\", \"click\", \"dblclick\",\n+ \"mouseout\"\n+ ];\n+ for (var i = 0, len = events.length; i < len; i++) {\n+ if (this[events[i]]) {\n+ this.unregister(events[i], this[events[i]]);\n+ }\n }\n }\n- var value = parts.join(\" \") || undefined;\n- return value;\n },\n \n /**\n- * Method: setFilterProperty\n- * Set the property of each spatial filter.\n+ * Method: callback\n+ * Trigger the control's named callback with the given arguments\n *\n * Parameters:\n- * filter - {}\n+ * name - {String} The key for the callback that is one of the properties\n+ * of the handler's callbacks object.\n+ * args - {Array(*)} An array of arguments (any type) with which to call \n+ * the callback (defined by the control).\n */\n- setFilterProperty: function(filter) {\n- if (filter.filters) {\n- for (var i = 0, len = filter.filters.length; i < len; ++i) {\n- OpenLayers.Format.WFST.v1.prototype.setFilterProperty.call(this, filter.filters[i]);\n- }\n- } else {\n- if (filter instanceof OpenLayers.Filter.Spatial && !filter.property) {\n- // got a spatial filter without property, so set it\n- filter.property = this.geometryName;\n- }\n+ callback: function(name, args) {\n+ if (name && this.callbacks[name]) {\n+ this.callbacks[name].apply(this.control, args);\n }\n },\n \n- CLASS_NAME: \"OpenLayers.Format.WFST.v1\"\n-\n-});\n-/* ======================================================================\n- OpenLayers/Filter/Logical.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/Filter.js\n- */\n-\n-/**\n- * Class: OpenLayers.Filter.Logical\n- * This class represents ogc:And, ogc:Or and ogc:Not rules.\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Filter.Logical = OpenLayers.Class(OpenLayers.Filter, {\n-\n /**\n- * APIProperty: filters\n- * {Array()} Child filters for this filter.\n+ * Method: register\n+ * register an event on the map\n */\n- filters: null,\n+ register: function(name, method) {\n+ // TODO: deal with registerPriority in 3.0\n+ this.map.events.registerPriority(name, this, method);\n+ this.map.events.registerPriority(name, this, this.setEvent);\n+ },\n \n /**\n- * APIProperty: type\n- * {String} type of logical operator. Available types are:\n- * - OpenLayers.Filter.Logical.AND = \"&&\";\n- * - OpenLayers.Filter.Logical.OR = \"||\";\n- * - OpenLayers.Filter.Logical.NOT = \"!\";\n+ * Method: unregister\n+ * unregister an event from the map\n */\n- type: null,\n+ unregister: function(name, method) {\n+ this.map.events.unregister(name, this, method);\n+ this.map.events.unregister(name, this, this.setEvent);\n+ },\n \n- /** \n- * Constructor: OpenLayers.Filter.Logical\n- * Creates a logical filter (And, Or, Not).\n+ /**\n+ * Method: setEvent\n+ * With each registered browser event, the handler sets its own evt\n+ * property. This property can be accessed by controls if needed\n+ * to get more information about the event that the handler is\n+ * processing.\n+ *\n+ * This allows modifier keys on the event to be checked (alt, shift, ctrl,\n+ * and meta cannot be checked with the keyboard handler). For a\n+ * control to determine which modifier keys are associated with the\n+ * event that a handler is currently processing, it should access\n+ * (code)handler.evt.altKey || handler.evt.shiftKey ||\n+ * handler.evt.ctrlKey || handler.evt.metaKey(end).\n *\n * Parameters:\n- * options - {Object} An optional object with properties to set on the\n- * filter.\n- * \n- * Returns:\n- * {}\n+ * evt - {Event} The browser event.\n */\n- initialize: function(options) {\n- this.filters = [];\n- OpenLayers.Filter.prototype.initialize.apply(this, [options]);\n+ setEvent: function(evt) {\n+ this.evt = evt;\n+ return true;\n },\n \n- /** \n- * APIMethod: destroy\n- * Remove reference to child filters.\n+ /**\n+ * Method: destroy\n+ * Deconstruct the handler.\n */\n destroy: function() {\n- this.filters = null;\n- OpenLayers.Filter.prototype.destroy.apply(this);\n+ // unregister event listeners\n+ this.deactivate();\n+ // eliminate circular references\n+ this.control = this.map = null;\n },\n \n- /**\n- * APIMethod: evaluate\n- * Evaluates this filter in a specific context.\n- * \n- * Parameters:\n- * context - {Object} Context to use in evaluating the filter. A vector\n- * feature may also be provided to evaluate feature attributes in \n- * comparison filters or geometries in spatial filters.\n- * \n- * Returns:\n- * {Boolean} The filter applies.\n- */\n- evaluate: function(context) {\n- var i, len;\n- switch (this.type) {\n- case OpenLayers.Filter.Logical.AND:\n- for (i = 0, len = this.filters.length; i < len; i++) {\n- if (this.filters[i].evaluate(context) == false) {\n- return false;\n- }\n- }\n- return true;\n+ CLASS_NAME: \"OpenLayers.Handler\"\n+});\n \n- case OpenLayers.Filter.Logical.OR:\n- for (i = 0, len = this.filters.length; i < len; i++) {\n- if (this.filters[i].evaluate(context) == true) {\n- return true;\n- }\n- }\n- return false;\n+/**\n+ * Constant: OpenLayers.Handler.MOD_NONE\n+ * If set as the , returns false if any key is down.\n+ */\n+OpenLayers.Handler.MOD_NONE = 0;\n \n- case OpenLayers.Filter.Logical.NOT:\n- return (!this.filters[0].evaluate(context));\n- }\n- return undefined;\n- },\n+/**\n+ * Constant: OpenLayers.Handler.MOD_SHIFT\n+ * If set as the , returns false if Shift is down.\n+ */\n+OpenLayers.Handler.MOD_SHIFT = 1;\n \n- /**\n- * APIMethod: clone\n- * Clones this filter.\n- * \n- * Returns:\n- * {} Clone of this filter.\n- */\n- clone: function() {\n- var filters = [];\n- for (var i = 0, len = this.filters.length; i < len; ++i) {\n- filters.push(this.filters[i].clone());\n- }\n- return new OpenLayers.Filter.Logical({\n- type: this.type,\n- filters: filters\n- });\n- },\n+/**\n+ * Constant: OpenLayers.Handler.MOD_CTRL\n+ * If set as the , returns false if Ctrl is down.\n+ */\n+OpenLayers.Handler.MOD_CTRL = 2;\n \n- CLASS_NAME: \"OpenLayers.Filter.Logical\"\n-});\n+/**\n+ * Constant: OpenLayers.Handler.MOD_ALT\n+ * If set as the , returns false if Alt is down.\n+ */\n+OpenLayers.Handler.MOD_ALT = 4;\n+\n+/**\n+ * Constant: OpenLayers.Handler.MOD_META\n+ * If set as the , returns false if Cmd is down.\n+ */\n+OpenLayers.Handler.MOD_META = 8;\n \n \n-OpenLayers.Filter.Logical.AND = \"&&\";\n-OpenLayers.Filter.Logical.OR = \"||\";\n-OpenLayers.Filter.Logical.NOT = \"!\";\n /* ======================================================================\n- OpenLayers/Filter/Comparison.js\n+ OpenLayers/Geometry.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Filter.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n */\n \n /**\n- * Class: OpenLayers.Filter.Comparison\n- * This class represents a comparison filter.\n- * \n- * Inherits from:\n- * - \n+ * Class: OpenLayers.Geometry\n+ * A Geometry is a description of a geographic object. Create an instance of\n+ * this class with the constructor. This is a base class,\n+ * typical geometry types are described by subclasses of this class.\n+ *\n+ * Note that if you use the method, you must\n+ * explicitly include the OpenLayers.Format.WKT in your build.\n */\n-OpenLayers.Filter.Comparison = OpenLayers.Class(OpenLayers.Filter, {\n+OpenLayers.Geometry = OpenLayers.Class({\n \n /**\n- * APIProperty: type\n- * {String} type: type of the comparison. This is one of\n- * - OpenLayers.Filter.Comparison.EQUAL_TO = \"==\";\n- * - OpenLayers.Filter.Comparison.NOT_EQUAL_TO = \"!=\";\n- * - OpenLayers.Filter.Comparison.LESS_THAN = \"<\";\n- * - OpenLayers.Filter.Comparison.GREATER_THAN = \">\";\n- * - OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO = \"<=\";\n- * - OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO = \">=\";\n- * - OpenLayers.Filter.Comparison.BETWEEN = \"..\";\n- * - OpenLayers.Filter.Comparison.LIKE = \"~\";\n- * - OpenLayers.Filter.Comparison.IS_NULL = \"NULL\";\n+ * Property: id\n+ * {String} A unique identifier for this geometry.\n */\n- type: null,\n+ id: null,\n \n /**\n- * APIProperty: property\n- * {String}\n- * name of the context property to compare\n+ * Property: parent\n+ * {}This is set when a Geometry is added as component\n+ * of another geometry\n */\n- property: null,\n+ parent: null,\n \n /**\n- * APIProperty: value\n- * {Number} or {String}\n- * comparison value for binary comparisons. In the case of a String, this\n- * can be a combination of text and propertyNames in the form\n- * \"literal ${propertyName}\"\n+ * Property: bounds \n+ * {} The bounds of this geometry\n */\n- value: null,\n+ bounds: null,\n \n /**\n- * Property: matchCase\n- * {Boolean} Force case sensitive searches for EQUAL_TO and NOT_EQUAL_TO\n- * comparisons. The Filter Encoding 1.1 specification added a matchCase\n- * attribute to ogc:PropertyIsEqualTo and ogc:PropertyIsNotEqualTo\n- * elements. This property will be serialized with those elements only\n- * if using the v1.1.0 filter format. However, when evaluating filters\n- * here, the matchCase property will always be respected (for EQUAL_TO\n- * and NOT_EQUAL_TO). Default is true. \n+ * Constructor: OpenLayers.Geometry\n+ * Creates a geometry object. \n */\n- matchCase: true,\n+ initialize: function() {\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+ },\n \n /**\n- * APIProperty: lowerBoundary\n- * {Number} or {String}\n- * lower boundary for between comparisons. In the case of a String, this\n- * can be a combination of text and propertyNames in the form\n- * \"literal ${propertyName}\"\n+ * Method: destroy\n+ * Destroy this geometry.\n */\n- lowerBoundary: null,\n+ destroy: function() {\n+ this.id = null;\n+ this.bounds = null;\n+ },\n \n /**\n- * APIProperty: upperBoundary\n- * {Number} or {String}\n- * upper boundary for between comparisons. In the case of a String, this\n- * can be a combination of text and propertyNames in the form\n- * \"literal ${propertyName}\"\n- */\n- upperBoundary: null,\n-\n- /** \n- * Constructor: OpenLayers.Filter.Comparison\n- * Creates a comparison rule.\n- *\n- * Parameters:\n- * options - {Object} An optional object with properties to set on the\n- * rule\n+ * APIMethod: clone\n+ * Create a clone of this geometry. Does not set any non-standard\n+ * properties of the cloned geometry.\n * \n * Returns:\n- * {}\n+ * {} An exact clone of this geometry.\n */\n- initialize: function(options) {\n- OpenLayers.Filter.prototype.initialize.apply(this, [options]);\n- // since matchCase on PropertyIsLike is not schema compliant, we only\n- // want to use this if explicitly asked for\n- if (this.type === OpenLayers.Filter.Comparison.LIKE &&\n- options.matchCase === undefined) {\n- this.matchCase = null;\n- }\n+ clone: function() {\n+ return new OpenLayers.Geometry();\n },\n \n /**\n- * APIMethod: evaluate\n- * Evaluates this filter in a specific context.\n+ * Method: setBounds\n+ * Set the bounds for this Geometry.\n * \n * Parameters:\n- * context - {Object} Context to use in evaluating the filter. If a vector\n- * feature is provided, the feature.attributes will be used as context.\n- * \n- * Returns:\n- * {Boolean} The filter applies.\n+ * bounds - {} \n */\n- evaluate: function(context) {\n- if (context instanceof OpenLayers.Feature.Vector) {\n- context = context.attributes;\n+ setBounds: function(bounds) {\n+ if (bounds) {\n+ this.bounds = bounds.clone();\n }\n- var result = false;\n- var got = context[this.property];\n- var exp;\n- switch (this.type) {\n- case OpenLayers.Filter.Comparison.EQUAL_TO:\n- exp = this.value;\n- if (!this.matchCase &&\n- typeof got == \"string\" && typeof exp == \"string\") {\n- result = (got.toUpperCase() == exp.toUpperCase());\n- } else {\n- result = (got == exp);\n- }\n- break;\n- case OpenLayers.Filter.Comparison.NOT_EQUAL_TO:\n- exp = this.value;\n- if (!this.matchCase &&\n- typeof got == \"string\" && typeof exp == \"string\") {\n- result = (got.toUpperCase() != exp.toUpperCase());\n- } else {\n- result = (got != exp);\n- }\n- break;\n- case OpenLayers.Filter.Comparison.LESS_THAN:\n- result = got < this.value;\n- break;\n- case OpenLayers.Filter.Comparison.GREATER_THAN:\n- result = got > this.value;\n- break;\n- case OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO:\n- result = got <= this.value;\n- break;\n- case OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO:\n- result = got >= this.value;\n- break;\n- case OpenLayers.Filter.Comparison.BETWEEN:\n- result = (got >= this.lowerBoundary) &&\n- (got <= this.upperBoundary);\n- break;\n- case OpenLayers.Filter.Comparison.LIKE:\n- var regexp = new RegExp(this.value, \"gi\");\n- result = regexp.test(got);\n- break;\n- case OpenLayers.Filter.Comparison.IS_NULL:\n- result = (got === null);\n- break;\n+ },\n+\n+ /**\n+ * Method: clearBounds\n+ * Nullify this components bounds and that of its parent as well.\n+ */\n+ clearBounds: function() {\n+ this.bounds = null;\n+ if (this.parent) {\n+ this.parent.clearBounds();\n }\n- return result;\n },\n \n /**\n- * APIMethod: value2regex\n- * Converts the value of this rule into a regular expression string,\n- * according to the wildcard characters specified. This method has to\n- * be called after instantiation of this class, if the value is not a\n- * regular expression already.\n+ * Method: extendBounds\n+ * Extend the existing bounds to include the new bounds. \n+ * If geometry's bounds is not yet set, then set a new Bounds.\n * \n * Parameters:\n- * wildCard - {Char} wildcard character in the above value, default\n- * is \"*\"\n- * singleChar - {Char} single-character wildcard in the above value\n- * default is \".\"\n- * escapeChar - {Char} escape character in the above value, default is\n- * \"!\"\n+ * newBounds - {} \n+ */\n+ extendBounds: function(newBounds) {\n+ var bounds = this.getBounds();\n+ if (!bounds) {\n+ this.setBounds(newBounds);\n+ } else {\n+ this.bounds.extend(newBounds);\n+ }\n+ },\n+\n+ /**\n+ * APIMethod: getBounds\n+ * Get the bounds for this Geometry. If bounds is not set, it \n+ * is calculated again, this makes queries faster.\n * \n * Returns:\n- * {String} regular expression string\n+ * {}\n */\n- value2regex: function(wildCard, singleChar, escapeChar) {\n- if (wildCard == \".\") {\n- throw new Error(\"'.' is an unsupported wildCard character for \" +\n- \"OpenLayers.Filter.Comparison\");\n+ getBounds: function() {\n+ if (this.bounds == null) {\n+ this.calculateBounds();\n }\n+ return this.bounds;\n+ },\n \n-\n- // set UMN MapServer defaults for unspecified parameters\n- wildCard = wildCard ? wildCard : \"*\";\n- singleChar = singleChar ? singleChar : \".\";\n- escapeChar = escapeChar ? escapeChar : \"!\";\n-\n- this.value = this.value.replace(\n- new RegExp(\"\\\\\" + escapeChar + \"(.|$)\", \"g\"), \"\\\\$1\");\n- this.value = this.value.replace(\n- new RegExp(\"\\\\\" + singleChar, \"g\"), \".\");\n- this.value = this.value.replace(\n- new RegExp(\"\\\\\" + wildCard, \"g\"), \".*\");\n- this.value = this.value.replace(\n- new RegExp(\"\\\\\\\\.\\\\*\", \"g\"), \"\\\\\" + wildCard);\n- this.value = this.value.replace(\n- new RegExp(\"\\\\\\\\\\\\.\", \"g\"), \"\\\\\" + singleChar);\n-\n- return this.value;\n+ /** \n+ * APIMethod: calculateBounds\n+ * Recalculate the bounds for the geometry. \n+ */\n+ calculateBounds: function() {\n+ //\n+ // This should be overridden by subclasses.\n+ //\n },\n \n /**\n- * Method: regex2value\n- * Convert the value of this rule from a regular expression string into an\n- * ogc literal string using a wildCard of *, a singleChar of ., and an\n- * escape of !. Leaves the property unmodified.\n+ * APIMethod: distanceTo\n+ * Calculate the closest distance between two geometries (on the x-y plane).\n+ *\n+ * Parameters:\n+ * geometry - {} The target geometry.\n+ * options - {Object} Optional properties for configuring the distance\n+ * calculation.\n+ *\n+ * Valid options depend on the specific geometry type.\n * \n * Returns:\n- * {String} A string value.\n+ * {Number | Object} The distance between this geometry and the target.\n+ * If details is true, the return will be an object with distance,\n+ * x0, y0, x1, and x2 properties. The x0 and y0 properties represent\n+ * the coordinates of the closest point on this geometry. The x1 and y1\n+ * properties represent the coordinates of the closest point on the\n+ * target geometry.\n */\n- regex2value: function() {\n-\n- var value = this.value;\n-\n- // replace ! with !!\n- value = value.replace(/!/g, \"!!\");\n+ distanceTo: function(geometry, options) {},\n \n- // replace \\. with !. (watching out for \\\\.)\n- value = value.replace(/(\\\\)?\\\\\\./g, function($0, $1) {\n- return $1 ? $0 : \"!.\";\n- });\n+ /**\n+ * APIMethod: getVertices\n+ * Return a list of all points in this geometry.\n+ *\n+ * Parameters:\n+ * nodes - {Boolean} For lines, only return vertices that are\n+ * endpoints. If false, for lines, only vertices that are not\n+ * endpoints will be returned. If not provided, all vertices will\n+ * be returned.\n+ *\n+ * Returns:\n+ * {Array} A list of all vertices in the geometry.\n+ */\n+ getVertices: function(nodes) {},\n \n- // replace \\* with #* (watching out for \\\\*)\n- value = value.replace(/(\\\\)?\\\\\\*/g, function($0, $1) {\n- return $1 ? $0 : \"!*\";\n- });\n+ /**\n+ * Method: atPoint\n+ * Note - This is only an approximation based on the bounds of the \n+ * geometry.\n+ * \n+ * Parameters:\n+ * lonlat - {|Object} OpenLayers.LonLat or an\n+ * object with a 'lon' and 'lat' properties.\n+ * toleranceLon - {float} Optional tolerance in Geometric Coords\n+ * toleranceLat - {float} Optional tolerance in Geographic Coords\n+ * \n+ * Returns:\n+ * {Boolean} Whether or not the geometry is at the specified location\n+ */\n+ atPoint: function(lonlat, toleranceLon, toleranceLat) {\n+ var atPoint = false;\n+ var bounds = this.getBounds();\n+ if ((bounds != null) && (lonlat != null)) {\n \n- // replace \\\\ with \\\n- value = value.replace(/\\\\\\\\/g, \"\\\\\");\n+ var dX = (toleranceLon != null) ? toleranceLon : 0;\n+ var dY = (toleranceLat != null) ? toleranceLat : 0;\n \n- // convert .* to * (the sequence #.* is not allowed)\n- value = value.replace(/\\.\\*/g, \"*\");\n+ var toleranceBounds =\n+ new OpenLayers.Bounds(this.bounds.left - dX,\n+ this.bounds.bottom - dY,\n+ this.bounds.right + dX,\n+ this.bounds.top + dY);\n \n- return value;\n+ atPoint = toleranceBounds.containsLonLat(lonlat);\n+ }\n+ return atPoint;\n },\n \n /**\n- * APIMethod: clone\n- * Clones this filter.\n+ * Method: getLength\n+ * Calculate the length of this geometry. This method is defined in\n+ * subclasses.\n * \n * Returns:\n- * {} Clone of this filter.\n+ * {Float} The length of the collection by summing its parts\n */\n- clone: function() {\n- return OpenLayers.Util.extend(new OpenLayers.Filter.Comparison(), this);\n+ getLength: function() {\n+ //to be overridden by geometries that actually have a length\n+ //\n+ return 0.0;\n },\n \n- CLASS_NAME: \"OpenLayers.Filter.Comparison\"\n-});\n-\n-\n-OpenLayers.Filter.Comparison.EQUAL_TO = \"==\";\n-OpenLayers.Filter.Comparison.NOT_EQUAL_TO = \"!=\";\n-OpenLayers.Filter.Comparison.LESS_THAN = \"<\";\n-OpenLayers.Filter.Comparison.GREATER_THAN = \">\";\n-OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO = \"<=\";\n-OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO = \">=\";\n-OpenLayers.Filter.Comparison.BETWEEN = \"..\";\n-OpenLayers.Filter.Comparison.LIKE = \"~\";\n-OpenLayers.Filter.Comparison.IS_NULL = \"NULL\";\n-/* ======================================================================\n- OpenLayers/Format/Filter.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Format/XML/VersionedOGC.js\n- * @requires OpenLayers/Filter/FeatureId.js\n- * @requires OpenLayers/Filter/Logical.js\n- * @requires OpenLayers/Filter/Comparison.js\n- */\n-\n-/**\n- * Class: OpenLayers.Format.Filter\n- * Read/Write ogc:Filter. Create a new instance with the \n- * constructor.\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Format.Filter = OpenLayers.Class(OpenLayers.Format.XML.VersionedOGC, {\n-\n /**\n- * APIProperty: defaultVersion\n- * {String} Version number to assume if none found. Default is \"1.0.0\".\n+ * Method: getArea\n+ * Calculate the area of this geometry. This method is defined in subclasses.\n+ * \n+ * Returns:\n+ * {Float} The area of the collection by summing its parts\n */\n- defaultVersion: \"1.0.0\",\n+ getArea: function() {\n+ //to be overridden by geometries that actually have an area\n+ //\n+ return 0.0;\n+ },\n \n /**\n- * APIMethod: write\n- * Write an ogc:Filter given a filter object.\n- *\n- * Parameters:\n- * filter - {} An filter.\n- * options - {Object} Optional configuration object.\n+ * APIMethod: getCentroid\n+ * Calculate the centroid of this geometry. This method is defined in subclasses.\n *\n * Returns:\n- * {Elment} An ogc:Filter element node.\n+ * {} The centroid of the collection\n */\n+ getCentroid: function() {\n+ return null;\n+ },\n \n /**\n- * APIMethod: read\n- * Read and Filter doc and return an object representing the Filter.\n- *\n- * Parameters:\n- * data - {String | DOMElement} Data to read.\n+ * Method: toString\n+ * Returns a text representation of the geometry. If the WKT format is\n+ * included in a build, this will be the Well-Known Text \n+ * representation.\n *\n * Returns:\n- * {} A filter object.\n+ * {String} String representation of this geometry.\n */\n+ toString: function() {\n+ var string;\n+ if (OpenLayers.Format && OpenLayers.Format.WKT) {\n+ string = OpenLayers.Format.WKT.prototype.write(\n+ new OpenLayers.Feature.Vector(this)\n+ );\n+ } else {\n+ string = Object.prototype.toString.call(this);\n+ }\n+ return string;\n+ },\n \n- CLASS_NAME: \"OpenLayers.Format.Filter\"\n+ CLASS_NAME: \"OpenLayers.Geometry\"\n });\n+\n+/**\n+ * Function: OpenLayers.Geometry.fromWKT\n+ * Generate a geometry given a Well-Known Text string. For this method to\n+ * work, you must include the OpenLayers.Format.WKT in your build \n+ * explicitly.\n+ *\n+ * Parameters:\n+ * wkt - {String} A string representing the geometry in Well-Known Text.\n+ *\n+ * Returns:\n+ * {} A geometry of the appropriate class.\n+ */\n+OpenLayers.Geometry.fromWKT = function(wkt) {\n+ var geom;\n+ if (OpenLayers.Format && OpenLayers.Format.WKT) {\n+ var format = OpenLayers.Geometry.fromWKT.format;\n+ if (!format) {\n+ format = new OpenLayers.Format.WKT();\n+ OpenLayers.Geometry.fromWKT.format = format;\n+ }\n+ var result = format.read(wkt);\n+ if (result instanceof OpenLayers.Feature.Vector) {\n+ geom = result.geometry;\n+ } else if (OpenLayers.Util.isArray(result)) {\n+ var len = result.length;\n+ var components = new Array(len);\n+ for (var i = 0; i < len; ++i) {\n+ components[i] = result[i].geometry;\n+ }\n+ geom = new OpenLayers.Geometry.Collection(components);\n+ }\n+ }\n+ return geom;\n+};\n+\n+/**\n+ * Method: OpenLayers.Geometry.segmentsIntersect\n+ * Determine whether two line segments intersect. Optionally calculates\n+ * and returns the intersection point. This function is optimized for\n+ * cases where seg1.x2 >= seg2.x1 || seg2.x2 >= seg1.x1. In those\n+ * obvious cases where there is no intersection, the function should\n+ * not be called.\n+ *\n+ * Parameters:\n+ * seg1 - {Object} Object representing a segment with properties x1, y1, x2,\n+ * and y2. The start point is represented by x1 and y1. The end point\n+ * is represented by x2 and y2. Start and end are ordered so that x1 < x2.\n+ * seg2 - {Object} Object representing a segment with properties x1, y1, x2,\n+ * and y2. The start point is represented by x1 and y1. The end point\n+ * is represented by x2 and y2. Start and end are ordered so that x1 < x2.\n+ * options - {Object} Optional properties for calculating the intersection.\n+ *\n+ * Valid options:\n+ * point - {Boolean} Return the intersection point. If false, the actual\n+ * intersection point will not be calculated. If true and the segments\n+ * intersect, the intersection point will be returned. If true and\n+ * the segments do not intersect, false will be returned. If true and\n+ * the segments are coincident, true will be returned.\n+ * tolerance - {Number} If a non-null value is provided, if the segments are\n+ * within the tolerance distance, this will be considered an intersection.\n+ * In addition, if the point option is true and the calculated intersection\n+ * is within the tolerance distance of an end point, the endpoint will be\n+ * returned instead of the calculated intersection. Further, if the\n+ * intersection is within the tolerance of endpoints on both segments, or\n+ * if two segment endpoints are within the tolerance distance of eachother\n+ * (but no intersection is otherwise calculated), an endpoint on the\n+ * first segment provided will be returned.\n+ *\n+ * Returns:\n+ * {Boolean | } The two segments intersect.\n+ * If the point argument is true, the return will be the intersection\n+ * point or false if none exists. If point is true and the segments\n+ * are coincident, return will be true (and the instersection is equal\n+ * to the shorter segment).\n+ */\n+OpenLayers.Geometry.segmentsIntersect = function(seg1, seg2, options) {\n+ var point = options && options.point;\n+ var tolerance = options && options.tolerance;\n+ var intersection = false;\n+ var x11_21 = seg1.x1 - seg2.x1;\n+ var y11_21 = seg1.y1 - seg2.y1;\n+ var x12_11 = seg1.x2 - seg1.x1;\n+ var y12_11 = seg1.y2 - seg1.y1;\n+ var y22_21 = seg2.y2 - seg2.y1;\n+ var x22_21 = seg2.x2 - seg2.x1;\n+ var d = (y22_21 * x12_11) - (x22_21 * y12_11);\n+ var n1 = (x22_21 * y11_21) - (y22_21 * x11_21);\n+ var n2 = (x12_11 * y11_21) - (y12_11 * x11_21);\n+ if (d == 0) {\n+ // parallel\n+ if (n1 == 0 && n2 == 0) {\n+ // coincident\n+ intersection = true;\n+ }\n+ } else {\n+ var along1 = n1 / d;\n+ var along2 = n2 / d;\n+ if (along1 >= 0 && along1 <= 1 && along2 >= 0 && along2 <= 1) {\n+ // intersect\n+ if (!point) {\n+ intersection = true;\n+ } else {\n+ // calculate the intersection point\n+ var x = seg1.x1 + (along1 * x12_11);\n+ var y = seg1.y1 + (along1 * y12_11);\n+ intersection = new OpenLayers.Geometry.Point(x, y);\n+ }\n+ }\n+ }\n+ if (tolerance) {\n+ var dist;\n+ if (intersection) {\n+ if (point) {\n+ var segs = [seg1, seg2];\n+ var seg, x, y;\n+ // check segment endpoints for proximity to intersection\n+ // set intersection to first endpoint within the tolerance\n+ outer: for (var i = 0; i < 2; ++i) {\n+ seg = segs[i];\n+ for (var j = 1; j < 3; ++j) {\n+ x = seg[\"x\" + j];\n+ y = seg[\"y\" + j];\n+ dist = Math.sqrt(\n+ Math.pow(x - intersection.x, 2) +\n+ Math.pow(y - intersection.y, 2)\n+ );\n+ if (dist < tolerance) {\n+ intersection.x = x;\n+ intersection.y = y;\n+ break outer;\n+ }\n+ }\n+ }\n+\n+ }\n+ } else {\n+ // no calculated intersection, but segments could be within\n+ // the tolerance of one another\n+ var segs = [seg1, seg2];\n+ var source, target, x, y, p, result;\n+ // check segment endpoints for proximity to intersection\n+ // set intersection to first endpoint within the tolerance\n+ outer: for (var i = 0; i < 2; ++i) {\n+ source = segs[i];\n+ target = segs[(i + 1) % 2];\n+ for (var j = 1; j < 3; ++j) {\n+ p = {\n+ x: source[\"x\" + j],\n+ y: source[\"y\" + j]\n+ };\n+ result = OpenLayers.Geometry.distanceToSegment(p, target);\n+ if (result.distance < tolerance) {\n+ if (point) {\n+ intersection = new OpenLayers.Geometry.Point(p.x, p.y);\n+ } else {\n+ intersection = true;\n+ }\n+ break outer;\n+ }\n+ }\n+ }\n+ }\n+ }\n+ return intersection;\n+};\n+\n+/**\n+ * Function: OpenLayers.Geometry.distanceToSegment\n+ *\n+ * Parameters:\n+ * point - {Object} An object with x and y properties representing the\n+ * point coordinates.\n+ * segment - {Object} An object with x1, y1, x2, and y2 properties\n+ * representing endpoint coordinates.\n+ *\n+ * Returns:\n+ * {Object} An object with distance, along, x, and y properties. The distance\n+ * will be the shortest distance between the input point and segment.\n+ * The x and y properties represent the coordinates along the segment\n+ * where the shortest distance meets the segment. The along attribute\n+ * describes how far between the two segment points the given point is.\n+ */\n+OpenLayers.Geometry.distanceToSegment = function(point, segment) {\n+ var result = OpenLayers.Geometry.distanceSquaredToSegment(point, segment);\n+ result.distance = Math.sqrt(result.distance);\n+ return result;\n+};\n+\n+/**\n+ * Function: OpenLayers.Geometry.distanceSquaredToSegment\n+ *\n+ * Usually the distanceToSegment function should be used. This variant however\n+ * can be used for comparisons where the exact distance is not important.\n+ *\n+ * Parameters:\n+ * point - {Object} An object with x and y properties representing the\n+ * point coordinates.\n+ * segment - {Object} An object with x1, y1, x2, and y2 properties\n+ * representing endpoint coordinates.\n+ *\n+ * Returns:\n+ * {Object} An object with squared distance, along, x, and y properties.\n+ * The distance will be the shortest distance between the input point and\n+ * segment. The x and y properties represent the coordinates along the\n+ * segment where the shortest distance meets the segment. The along\n+ * attribute describes how far between the two segment points the given\n+ * point is.\n+ */\n+OpenLayers.Geometry.distanceSquaredToSegment = function(point, segment) {\n+ var x0 = point.x;\n+ var y0 = point.y;\n+ var x1 = segment.x1;\n+ var y1 = segment.y1;\n+ var x2 = segment.x2;\n+ var y2 = segment.y2;\n+ var dx = x2 - x1;\n+ var dy = y2 - y1;\n+ var along = ((dx * (x0 - x1)) + (dy * (y0 - y1))) /\n+ (Math.pow(dx, 2) + Math.pow(dy, 2));\n+ var x, y;\n+ if (along <= 0.0) {\n+ x = x1;\n+ y = y1;\n+ } else if (along >= 1.0) {\n+ x = x2;\n+ y = y2;\n+ } else {\n+ x = x1 + along * dx;\n+ y = y1 + along * dy;\n+ }\n+ return {\n+ distance: Math.pow(x - x0, 2) + Math.pow(y - y0, 2),\n+ x: x,\n+ y: y,\n+ along: along\n+ };\n+};\n /* ======================================================================\n- OpenLayers/Filter/Function.js\n+ OpenLayers/Geometry/Point.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Filter.js\n+ * @requires OpenLayers/Geometry.js\n */\n \n /**\n- * Class: OpenLayers.Filter.Function\n- * This class represents a filter function.\n- * We are using this class for creation of complex \n- * filters that can contain filter functions as values.\n- * Nesting function as other functions parameter is supported.\n+ * Class: OpenLayers.Geometry.Point\n+ * Point geometry class. \n * \n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Filter.Function = OpenLayers.Class(OpenLayers.Filter, {\n+OpenLayers.Geometry.Point = OpenLayers.Class(OpenLayers.Geometry, {\n \n- /**\n- * APIProperty: name\n- * {String} Name of the function.\n+ /** \n+ * APIProperty: x \n+ * {float} \n */\n- name: null,\n+ x: null,\n \n- /**\n- * APIProperty: params\n- * {Array( || String || Number)} Function parameters\n- * For now support only other Functions, String or Number\n+ /** \n+ * APIProperty: y \n+ * {float} \n */\n- params: null,\n+ y: null,\n \n- /** \n- * Constructor: OpenLayers.Filter.Function\n- * Creates a filter function.\n+ /**\n+ * Constructor: OpenLayers.Geometry.Point\n+ * Construct a point geometry.\n *\n * Parameters:\n- * options - {Object} An optional object with properties to set on the\n- * function.\n+ * x - {float} \n+ * y - {float}\n * \n- * Returns:\n- * {}\n */\n+ initialize: function(x, y) {\n+ OpenLayers.Geometry.prototype.initialize.apply(this, arguments);\n \n- CLASS_NAME: \"OpenLayers.Filter.Function\"\n-});\n-\n-/* ======================================================================\n- OpenLayers/BaseTypes/Date.js\n- ====================================================================== */\n+ this.x = parseFloat(x);\n+ this.y = parseFloat(y);\n+ },\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ /**\n+ * APIMethod: clone\n+ * \n+ * Returns:\n+ * {} An exact clone of this OpenLayers.Geometry.Point\n+ */\n+ clone: function(obj) {\n+ if (obj == null) {\n+ obj = new OpenLayers.Geometry.Point(this.x, this.y);\n+ }\n \n-/**\n- * @requires OpenLayers/SingleFile.js\n- */\n+ // catch any randomly tagged-on properties\n+ OpenLayers.Util.applyDefaults(obj, this);\n \n-/**\n- * Namespace: OpenLayers.Date\n- * Contains implementations of Date.parse and date.toISOString that match the\n- * ECMAScript 5 specification for parsing RFC 3339 dates.\n- * http://tools.ietf.org/html/rfc3339\n- */\n-OpenLayers.Date = {\n+ return obj;\n+ },\n \n /** \n- * APIProperty: dateRegEx\n- * The regex to be used for validating dates. You can provide your own\n- * regex for instance for adding support for years before BC. Default\n- * value is: /^(?:(\\d{4})(?:-(\\d{2})(?:-(\\d{2}))?)?)?(?:(?:T(\\d{1,2}):(\\d{2}):(\\d{2}(?:\\.\\d+)?)(Z|(?:[+-]\\d{1,2}(?::(\\d{2}))?)))|Z)?$/\n+ * Method: calculateBounds\n+ * Create a new Bounds based on the lon/lat\n */\n- dateRegEx: /^(?:(\\d{4})(?:-(\\d{2})(?:-(\\d{2}))?)?)?(?:(?:T(\\d{1,2}):(\\d{2}):(\\d{2}(?:\\.\\d+)?)(Z|(?:[+-]\\d{1,2}(?::(\\d{2}))?)))|Z)?$/,\n+ calculateBounds: function() {\n+ this.bounds = new OpenLayers.Bounds(this.x, this.y,\n+ this.x, this.y);\n+ },\n \n /**\n- * APIMethod: toISOString\n- * Generates a string representing a date. The format of the string follows\n- * the profile of ISO 8601 for date and time on the Internet (see\n- * http://tools.ietf.org/html/rfc3339). If the toISOString method is\n- * available on the Date prototype, that is used. The toISOString\n- * method for Date instances is defined in ECMA-262.\n+ * APIMethod: distanceTo\n+ * Calculate the closest distance between two geometries (on the x-y plane).\n *\n * Parameters:\n- * date - {Date} A date object.\n+ * geometry - {} The target geometry.\n+ * options - {Object} Optional properties for configuring the distance\n+ * calculation.\n+ *\n+ * Valid options:\n+ * details - {Boolean} Return details from the distance calculation.\n+ * Default is false.\n+ * edge - {Boolean} Calculate the distance from this geometry to the\n+ * nearest edge of the target geometry. Default is true. If true,\n+ * calling distanceTo from a geometry that is wholly contained within\n+ * the target will result in a non-zero distance. If false, whenever\n+ * geometries intersect, calling distanceTo will return 0. If false,\n+ * details cannot be returned.\n *\n * Returns:\n- * {String} A string representing the date (e.g.\n- * \"2010-08-07T16:58:23.123Z\"). If the date does not have a valid time\n- * (i.e. isNaN(date.getTime())) this method returns the string \"Invalid\n- * Date\". The ECMA standard says the toISOString method should throw\n- * RangeError in this case, but Firefox returns a string instead. For\n- * best results, use isNaN(date.getTime()) to determine date validity\n- * before generating date strings.\n+ * {Number | Object} The distance between this geometry and the target.\n+ * If details is true, the return will be an object with distance,\n+ * x0, y0, x1, and x2 properties. The x0 and y0 properties represent\n+ * the coordinates of the closest point on this geometry. The x1 and y1\n+ * properties represent the coordinates of the closest point on the\n+ * target geometry.\n */\n- toISOString: (function() {\n- if (\"toISOString\" in Date.prototype) {\n- return function(date) {\n- return date.toISOString();\n- };\n+ distanceTo: function(geometry, options) {\n+ var edge = !(options && options.edge === false);\n+ var details = edge && options && options.details;\n+ var distance, x0, y0, x1, y1, result;\n+ if (geometry instanceof OpenLayers.Geometry.Point) {\n+ x0 = this.x;\n+ y0 = this.y;\n+ x1 = geometry.x;\n+ y1 = geometry.y;\n+ distance = Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));\n+ result = !details ?\n+ distance : {\n+ x0: x0,\n+ y0: y0,\n+ x1: x1,\n+ y1: y1,\n+ distance: distance\n+ };\n } else {\n- return function(date) {\n- var str;\n- if (isNaN(date.getTime())) {\n- // ECMA-262 says throw RangeError, Firefox returns\n- // \"Invalid Date\"\n- str = \"Invalid Date\";\n- } else {\n- str =\n- date.getUTCFullYear() + \"-\" +\n- OpenLayers.Number.zeroPad(date.getUTCMonth() + 1, 2) + \"-\" +\n- OpenLayers.Number.zeroPad(date.getUTCDate(), 2) + \"T\" +\n- OpenLayers.Number.zeroPad(date.getUTCHours(), 2) + \":\" +\n- OpenLayers.Number.zeroPad(date.getUTCMinutes(), 2) + \":\" +\n- OpenLayers.Number.zeroPad(date.getUTCSeconds(), 2) + \".\" +\n- OpenLayers.Number.zeroPad(date.getUTCMilliseconds(), 3) + \"Z\";\n- }\n- return str;\n- };\n+ result = geometry.distanceTo(this, options);\n+ if (details) {\n+ // switch coord order since this geom is target\n+ result = {\n+ x0: result.x1,\n+ y0: result.y1,\n+ x1: result.x0,\n+ y1: result.y0,\n+ distance: result.distance\n+ };\n+ }\n }\n+ return result;\n+ },\n \n- })(),\n-\n- /**\n- * APIMethod: parse\n- * Generate a date object from a string. The format for the string follows\n- * the profile of ISO 8601 for date and time on the Internet (see\n- * http://tools.ietf.org/html/rfc3339). We don't call the native\n- * Date.parse because of inconsistency between implmentations. In\n- * Chrome, calling Date.parse with a string that doesn't contain any\n- * indication of the timezone (e.g. \"2011\"), the date is interpreted\n- * in local time. On Firefox, the assumption is UTC.\n- *\n+ /** \n+ * APIMethod: equals\n+ * Determine whether another geometry is equivalent to this one. Geometries\n+ * are considered equivalent if all components have the same coordinates.\n+ * \n * Parameters:\n- * str - {String} A string representing the date (e.g.\n- * \"2010\", \"2010-08\", \"2010-08-07\", \"2010-08-07T16:58:23.123Z\",\n- * \"2010-08-07T11:58:23.123-06\").\n+ * geom - {} The geometry to test. \n *\n * Returns:\n- * {Date} A date object. If the string could not be parsed, an invalid\n- * date is returned (i.e. isNaN(date.getTime())).\n+ * {Boolean} The supplied geometry is equivalent to this geometry.\n */\n- parse: function(str) {\n- var date;\n- var match = str.match(this.dateRegEx);\n- if (match && (match[1] || match[7])) { // must have at least year or time\n- var year = parseInt(match[1], 10) || 0;\n- var month = (parseInt(match[2], 10) - 1) || 0;\n- var day = parseInt(match[3], 10) || 1;\n- date = new Date(Date.UTC(year, month, day));\n- // optional time\n- var type = match[7];\n- if (type) {\n- var hours = parseInt(match[4], 10);\n- var minutes = parseInt(match[5], 10);\n- var secFrac = parseFloat(match[6]);\n- var seconds = secFrac | 0;\n- var milliseconds = Math.round(1000 * (secFrac - seconds));\n- date.setUTCHours(hours, minutes, seconds, milliseconds);\n- // check offset\n- if (type !== \"Z\") {\n- var hoursOffset = parseInt(type, 10);\n- var minutesOffset = parseInt(match[8], 10) || 0;\n- var offset = -1000 * (60 * (hoursOffset * 60) + minutesOffset * 60);\n- date = new Date(date.getTime() + offset);\n- }\n- }\n- } else {\n- date = new Date(\"invalid\");\n+ equals: function(geom) {\n+ var equals = false;\n+ if (geom != null) {\n+ equals = ((this.x == geom.x && this.y == geom.y) ||\n+ (isNaN(this.x) && isNaN(this.y) && isNaN(geom.x) && isNaN(geom.y)));\n }\n- return date;\n- }\n-};\n-/* ======================================================================\n- OpenLayers/Format/Filter/v1.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-/**\n- * @requires OpenLayers/Format/Filter.js\n- * @requires OpenLayers/Format/XML.js\n- * @requires OpenLayers/Filter/Function.js\n- * @requires OpenLayers/BaseTypes/Date.js\n- */\n-\n-/**\n- * Class: OpenLayers.Format.Filter.v1\n- * Superclass for Filter version 1 parsers.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Format.Filter.v1 = OpenLayers.Class(OpenLayers.Format.XML, {\n-\n- /**\n- * Property: namespaces\n- * {Object} Mapping of namespace aliases to namespace URIs.\n- */\n- namespaces: {\n- ogc: \"http://www.opengis.net/ogc\",\n- gml: \"http://www.opengis.net/gml\",\n- xlink: \"http://www.w3.org/1999/xlink\",\n- xsi: \"http://www.w3.org/2001/XMLSchema-instance\"\n+ return equals;\n },\n \n /**\n- * Property: defaultPrefix\n- */\n- defaultPrefix: \"ogc\",\n-\n- /**\n- * Property: schemaLocation\n- * {String} Schema location for a particular minor version.\n+ * Method: toShortString\n+ *\n+ * Returns:\n+ * {String} Shortened String representation of Point object. \n+ * (ex. \"5, 42\")\n */\n- schemaLocation: null,\n+ toShortString: function() {\n+ return (this.x + \", \" + this.y);\n+ },\n \n /**\n- * Constructor: OpenLayers.Format.Filter.v1\n- * Instances of this class are not created directly. Use the\n- * constructor instead.\n+ * APIMethod: move\n+ * Moves a geometry by the given displacement along positive x and y axes.\n+ * This modifies the position of the geometry and clears the cached\n+ * bounds.\n *\n * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ * x - {Float} Distance to move geometry in positive x direction. \n+ * y - {Float} Distance to move geometry in positive y direction.\n */\n- initialize: function(options) {\n- OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);\n+ move: function(x, y) {\n+ this.x = this.x + x;\n+ this.y = this.y + y;\n+ this.clearBounds();\n },\n \n /**\n- * Method: read\n+ * APIMethod: rotate\n+ * Rotate a point around another.\n *\n * Parameters:\n- * data - {DOMElement} A Filter document element.\n- *\n- * Returns:\n- * {} A filter object.\n+ * angle - {Float} Rotation angle in degrees (measured counterclockwise\n+ * from the positive x-axis)\n+ * origin - {} Center point for the rotation\n */\n- read: function(data) {\n- var obj = {};\n- this.readers.ogc[\"Filter\"].apply(this, [data, obj]);\n- return obj.filter;\n+ rotate: function(angle, origin) {\n+ angle *= Math.PI / 180;\n+ var radius = this.distanceTo(origin);\n+ var theta = angle + Math.atan2(this.y - origin.y, this.x - origin.x);\n+ this.x = origin.x + (radius * Math.cos(theta));\n+ this.y = origin.y + (radius * Math.sin(theta));\n+ this.clearBounds();\n },\n \n /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n+ * APIMethod: getCentroid\n+ *\n+ * Returns:\n+ * {} The centroid of the collection\n */\n- readers: {\n- \"ogc\": {\n- \"_expression\": function(node) {\n- // only the simplest of ogc:expression handled\n- // \"some text and an attribute\"}\n- var obj, value = \"\";\n- for (var child = node.firstChild; child; child = child.nextSibling) {\n- switch (child.nodeType) {\n- case 1:\n- obj = this.readNode(child);\n- if (obj.property) {\n- value += \"${\" + obj.property + \"}\";\n- } else if (obj.value !== undefined) {\n- value += obj.value;\n- }\n- break;\n- case 3: // text node\n- case 4: // cdata section\n- value += child.nodeValue;\n- }\n- }\n- return value;\n- },\n- \"Filter\": function(node, parent) {\n- // Filters correspond to subclasses of OpenLayers.Filter.\n- // Since they contain information we don't persist, we\n- // create a temporary object and then pass on the filter\n- // (ogc:Filter) to the parent obj.\n- var obj = {\n- fids: [],\n- filters: []\n- };\n- this.readChildNodes(node, obj);\n- if (obj.fids.length > 0) {\n- parent.filter = new OpenLayers.Filter.FeatureId({\n- fids: obj.fids\n- });\n- } else if (obj.filters.length > 0) {\n- parent.filter = obj.filters[0];\n- }\n- },\n- \"FeatureId\": function(node, obj) {\n- var fid = node.getAttribute(\"fid\");\n- if (fid) {\n- obj.fids.push(fid);\n- }\n- },\n- \"And\": function(node, obj) {\n- var filter = new OpenLayers.Filter.Logical({\n- type: OpenLayers.Filter.Logical.AND\n- });\n- this.readChildNodes(node, filter);\n- obj.filters.push(filter);\n- },\n- \"Or\": function(node, obj) {\n- var filter = new OpenLayers.Filter.Logical({\n- type: OpenLayers.Filter.Logical.OR\n- });\n- this.readChildNodes(node, filter);\n- obj.filters.push(filter);\n- },\n- \"Not\": function(node, obj) {\n- var filter = new OpenLayers.Filter.Logical({\n- type: OpenLayers.Filter.Logical.NOT\n- });\n- this.readChildNodes(node, filter);\n- obj.filters.push(filter);\n- },\n- \"PropertyIsLessThan\": function(node, obj) {\n- var filter = new OpenLayers.Filter.Comparison({\n- type: OpenLayers.Filter.Comparison.LESS_THAN\n- });\n- this.readChildNodes(node, filter);\n- obj.filters.push(filter);\n- },\n- \"PropertyIsGreaterThan\": function(node, obj) {\n- var filter = new OpenLayers.Filter.Comparison({\n- type: OpenLayers.Filter.Comparison.GREATER_THAN\n- });\n- this.readChildNodes(node, filter);\n- obj.filters.push(filter);\n- },\n- \"PropertyIsLessThanOrEqualTo\": function(node, obj) {\n- var filter = new OpenLayers.Filter.Comparison({\n- type: OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO\n- });\n- this.readChildNodes(node, filter);\n- obj.filters.push(filter);\n- },\n- \"PropertyIsGreaterThanOrEqualTo\": function(node, obj) {\n- var filter = new OpenLayers.Filter.Comparison({\n- type: OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO\n- });\n- this.readChildNodes(node, filter);\n- obj.filters.push(filter);\n- },\n- \"PropertyIsBetween\": function(node, obj) {\n- var filter = new OpenLayers.Filter.Comparison({\n- type: OpenLayers.Filter.Comparison.BETWEEN\n- });\n- this.readChildNodes(node, filter);\n- obj.filters.push(filter);\n- },\n- \"Literal\": function(node, obj) {\n- obj.value = OpenLayers.String.numericIf(\n- this.getChildValue(node), true);\n- },\n- \"PropertyName\": function(node, filter) {\n- filter.property = this.getChildValue(node);\n- },\n- \"LowerBoundary\": function(node, filter) {\n- filter.lowerBoundary = OpenLayers.String.numericIf(\n- this.readers.ogc._expression.call(this, node), true);\n- },\n- \"UpperBoundary\": function(node, filter) {\n- filter.upperBoundary = OpenLayers.String.numericIf(\n- this.readers.ogc._expression.call(this, node), true);\n- },\n- \"Intersects\": function(node, obj) {\n- this.readSpatial(node, obj, OpenLayers.Filter.Spatial.INTERSECTS);\n- },\n- \"Within\": function(node, obj) {\n- this.readSpatial(node, obj, OpenLayers.Filter.Spatial.WITHIN);\n- },\n- \"Contains\": function(node, obj) {\n- this.readSpatial(node, obj, OpenLayers.Filter.Spatial.CONTAINS);\n- },\n- \"DWithin\": function(node, obj) {\n- this.readSpatial(node, obj, OpenLayers.Filter.Spatial.DWITHIN);\n- },\n- \"Distance\": function(node, obj) {\n- obj.distance = parseInt(this.getChildValue(node));\n- obj.distanceUnits = node.getAttribute(\"units\");\n- },\n- \"Function\": function(node, obj) {\n- //TODO write decoder for it\n- return;\n- },\n- \"PropertyIsNull\": function(node, obj) {\n- var filter = new OpenLayers.Filter.Comparison({\n- type: OpenLayers.Filter.Comparison.IS_NULL\n- });\n- this.readChildNodes(node, filter);\n- obj.filters.push(filter);\n- }\n- }\n+ getCentroid: function() {\n+ return new OpenLayers.Geometry.Point(this.x, this.y);\n },\n \n /**\n- * Method: readSpatial\n+ * APIMethod: resize\n+ * Resize a point relative to some origin. For points, this has the effect\n+ * of scaling a vector (from the origin to the point). This method is\n+ * more useful on geometry collection subclasses.\n *\n- * Read a {} filter.\n- * \n * Parameters:\n- * node - {DOMElement} A DOM element that contains an ogc:expression.\n- * obj - {Object} The target object.\n- * type - {String} One of the OpenLayers.Filter.Spatial.* constants.\n- *\n+ * scale - {Float} Ratio of the new distance from the origin to the old\n+ * distance from the origin. A scale of 2 doubles the\n+ * distance between the point and origin.\n+ * origin - {} Point of origin for resizing\n+ * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.\n+ * \n * Returns:\n- * {} The created filter.\n+ * {} - The current geometry. \n */\n- readSpatial: function(node, obj, type) {\n- var filter = new OpenLayers.Filter.Spatial({\n- type: type\n- });\n- this.readChildNodes(node, filter);\n- filter.value = filter.components[0];\n- delete filter.components;\n- obj.filters.push(filter);\n+ resize: function(scale, origin, ratio) {\n+ ratio = (ratio == undefined) ? 1 : ratio;\n+ this.x = origin.x + (scale * ratio * (this.x - origin.x));\n+ this.y = origin.y + (scale * (this.y - origin.y));\n+ this.clearBounds();\n+ return this;\n },\n \n /**\n- * APIMethod: encodeLiteral\n- * Generates the string representation of a value for use in \n- * elements. The default encoder writes Date values as ISO 8601 \n- * strings.\n+ * APIMethod: intersects\n+ * Determine if the input geometry intersects this one.\n *\n * Parameters:\n- * value - {Object} Literal value to encode\n+ * geometry - {} Any type of geometry.\n *\n * Returns:\n- * {String} String representation of the provided value.\n+ * {Boolean} The input geometry intersects this one.\n */\n- encodeLiteral: function(value) {\n- if (value instanceof Date) {\n- value = OpenLayers.Date.toISOString(value);\n+ intersects: function(geometry) {\n+ var intersect = false;\n+ if (geometry.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n+ intersect = this.equals(geometry);\n+ } else {\n+ intersect = geometry.intersects(this);\n }\n- return value;\n+ return intersect;\n },\n \n /**\n- * Method: writeOgcExpression\n- * Limited support for writing OGC expressions. Currently it supports\n- * ( || String || Number)\n- *\n+ * APIMethod: transform\n+ * Translate the x,y properties of the point from source to dest.\n+ * \n * Parameters:\n- * value - ( || String || Number)\n- * node - {DOMElement} A parent DOM element \n- *\n+ * source - {} \n+ * dest - {}\n+ * \n * Returns:\n- * {DOMElement} Updated node element.\n+ * {} \n */\n- writeOgcExpression: function(value, node) {\n- if (value instanceof OpenLayers.Filter.Function) {\n- this.writeNode(\"Function\", value, node);\n- } else {\n- this.writeNode(\"Literal\", value, node);\n+ transform: function(source, dest) {\n+ if ((source && dest)) {\n+ OpenLayers.Projection.transform(\n+ this, source, dest);\n+ this.bounds = null;\n }\n- return node;\n+ return this;\n },\n \n /**\n- * Method: write\n+ * APIMethod: getVertices\n+ * Return a list of all points in this geometry.\n *\n * Parameters:\n- * filter - {} A filter object.\n+ * nodes - {Boolean} For lines, only return vertices that are\n+ * endpoints. If false, for lines, only vertices that are not\n+ * endpoints will be returned. If not provided, all vertices will\n+ * be returned.\n *\n * Returns:\n- * {DOMElement} An ogc:Filter element.\n- */\n- write: function(filter) {\n- return this.writers.ogc[\"Filter\"].apply(this, [filter]);\n- },\n-\n- /**\n- * Property: writers\n- * As a compliment to the readers property, this structure contains public\n- * writing functions grouped by namespace alias and named like the\n- * node names they produce.\n- */\n- writers: {\n- \"ogc\": {\n- \"Filter\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:Filter\");\n- this.writeNode(this.getFilterType(filter), filter, node);\n- return node;\n- },\n- \"_featureIds\": function(filter) {\n- var node = this.createDocumentFragment();\n- for (var i = 0, ii = filter.fids.length; i < ii; ++i) {\n- this.writeNode(\"ogc:FeatureId\", filter.fids[i], node);\n- }\n- return node;\n- },\n- \"FeatureId\": function(fid) {\n- return this.createElementNSPlus(\"ogc:FeatureId\", {\n- attributes: {\n- fid: fid\n- }\n- });\n- },\n- \"And\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:And\");\n- var childFilter;\n- for (var i = 0, ii = filter.filters.length; i < ii; ++i) {\n- childFilter = filter.filters[i];\n- this.writeNode(\n- this.getFilterType(childFilter), childFilter, node\n- );\n- }\n- return node;\n- },\n- \"Or\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:Or\");\n- var childFilter;\n- for (var i = 0, ii = filter.filters.length; i < ii; ++i) {\n- childFilter = filter.filters[i];\n- this.writeNode(\n- this.getFilterType(childFilter), childFilter, node\n- );\n- }\n- return node;\n- },\n- \"Not\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:Not\");\n- var childFilter = filter.filters[0];\n- this.writeNode(\n- this.getFilterType(childFilter), childFilter, node\n- );\n- return node;\n- },\n- \"PropertyIsLessThan\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:PropertyIsLessThan\");\n- // no ogc:expression handling for PropertyName for now\n- this.writeNode(\"PropertyName\", filter, node);\n- // handle Literals or Functions for now\n- this.writeOgcExpression(filter.value, node);\n- return node;\n- },\n- \"PropertyIsGreaterThan\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:PropertyIsGreaterThan\");\n- // no ogc:expression handling for PropertyName for now\n- this.writeNode(\"PropertyName\", filter, node);\n- // handle Literals or Functions for now\n- this.writeOgcExpression(filter.value, node);\n- return node;\n- },\n- \"PropertyIsLessThanOrEqualTo\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:PropertyIsLessThanOrEqualTo\");\n- // no ogc:expression handling for PropertyName for now\n- this.writeNode(\"PropertyName\", filter, node);\n- // handle Literals or Functions for now\n- this.writeOgcExpression(filter.value, node);\n- return node;\n- },\n- \"PropertyIsGreaterThanOrEqualTo\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:PropertyIsGreaterThanOrEqualTo\");\n- // no ogc:expression handling for PropertyName for now\n- this.writeNode(\"PropertyName\", filter, node);\n- // handle Literals or Functions for now\n- this.writeOgcExpression(filter.value, node);\n- return node;\n- },\n- \"PropertyIsBetween\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:PropertyIsBetween\");\n- // no ogc:expression handling for PropertyName for now\n- this.writeNode(\"PropertyName\", filter, node);\n- this.writeNode(\"LowerBoundary\", filter, node);\n- this.writeNode(\"UpperBoundary\", filter, node);\n- return node;\n- },\n- \"PropertyName\": function(filter) {\n- // no ogc:expression handling for now\n- return this.createElementNSPlus(\"ogc:PropertyName\", {\n- value: filter.property\n- });\n- },\n- \"Literal\": function(value) {\n- var encode = this.encodeLiteral ||\n- OpenLayers.Format.Filter.v1.prototype.encodeLiteral;\n- return this.createElementNSPlus(\"ogc:Literal\", {\n- value: encode(value)\n- });\n- },\n- \"LowerBoundary\": function(filter) {\n- // handle Literals or Functions for now\n- var node = this.createElementNSPlus(\"ogc:LowerBoundary\");\n- this.writeOgcExpression(filter.lowerBoundary, node);\n- return node;\n- },\n- \"UpperBoundary\": function(filter) {\n- // handle Literals or Functions for now\n- var node = this.createElementNSPlus(\"ogc:UpperBoundary\");\n- this.writeNode(\"Literal\", filter.upperBoundary, node);\n- return node;\n- },\n- \"INTERSECTS\": function(filter) {\n- return this.writeSpatial(filter, \"Intersects\");\n- },\n- \"WITHIN\": function(filter) {\n- return this.writeSpatial(filter, \"Within\");\n- },\n- \"CONTAINS\": function(filter) {\n- return this.writeSpatial(filter, \"Contains\");\n- },\n- \"DWITHIN\": function(filter) {\n- var node = this.writeSpatial(filter, \"DWithin\");\n- this.writeNode(\"Distance\", filter, node);\n- return node;\n- },\n- \"Distance\": function(filter) {\n- return this.createElementNSPlus(\"ogc:Distance\", {\n- attributes: {\n- units: filter.distanceUnits\n- },\n- value: filter.distance\n- });\n- },\n- \"Function\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:Function\", {\n- attributes: {\n- name: filter.name\n- }\n- });\n- var params = filter.params;\n- for (var i = 0, len = params.length; i < len; i++) {\n- this.writeOgcExpression(params[i], node);\n- }\n- return node;\n- },\n- \"PropertyIsNull\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:PropertyIsNull\");\n- this.writeNode(\"PropertyName\", filter, node);\n- return node;\n- }\n- }\n- },\n-\n- /**\n- * Method: getFilterType\n- */\n- getFilterType: function(filter) {\n- var filterType = this.filterMap[filter.type];\n- if (!filterType) {\n- throw \"Filter writing not supported for rule type: \" + filter.type;\n- }\n- return filterType;\n- },\n-\n- /**\n- * Property: filterMap\n- * {Object} Contains a member for each filter type. Values are node names\n- * for corresponding OGC Filter child elements.\n+ * {Array} A list of all vertices in the geometry.\n */\n- filterMap: {\n- \"&&\": \"And\",\n- \"||\": \"Or\",\n- \"!\": \"Not\",\n- \"==\": \"PropertyIsEqualTo\",\n- \"!=\": \"PropertyIsNotEqualTo\",\n- \"<\": \"PropertyIsLessThan\",\n- \">\": \"PropertyIsGreaterThan\",\n- \"<=\": \"PropertyIsLessThanOrEqualTo\",\n- \">=\": \"PropertyIsGreaterThanOrEqualTo\",\n- \"..\": \"PropertyIsBetween\",\n- \"~\": \"PropertyIsLike\",\n- \"NULL\": \"PropertyIsNull\",\n- \"BBOX\": \"BBOX\",\n- \"DWITHIN\": \"DWITHIN\",\n- \"WITHIN\": \"WITHIN\",\n- \"CONTAINS\": \"CONTAINS\",\n- \"INTERSECTS\": \"INTERSECTS\",\n- \"FID\": \"_featureIds\"\n+ getVertices: function(nodes) {\n+ return [this];\n },\n \n- CLASS_NAME: \"OpenLayers.Format.Filter.v1\"\n-\n+ CLASS_NAME: \"OpenLayers.Geometry.Point\"\n });\n /* ======================================================================\n- OpenLayers/Format/GML.js\n+ OpenLayers/Geometry/Collection.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format/XML.js\n- * @requires OpenLayers/Feature/Vector.js\n- * @requires OpenLayers/Geometry/Point.js\n- * @requires OpenLayers/Geometry/MultiPoint.js\n- * @requires OpenLayers/Geometry/LineString.js\n- * @requires OpenLayers/Geometry/MultiLineString.js\n- * @requires OpenLayers/Geometry/Polygon.js\n- * @requires OpenLayers/Geometry/MultiPolygon.js\n+ * @requires OpenLayers/Geometry.js\n */\n \n /**\n- * Class: OpenLayers.Format.GML\n- * Read/Write GML. Create a new instance with the \n- * constructor. Supports the GML simple features profile.\n+ * Class: OpenLayers.Geometry.Collection\n+ * A Collection is exactly what it sounds like: A collection of different \n+ * Geometries. These are stored in the local parameter (which\n+ * can be passed as a parameter to the constructor). \n * \n+ * As new geometries are added to the collection, they are NOT cloned. \n+ * When removing geometries, they need to be specified by reference (ie you \n+ * have to pass in the *exact* geometry to be removed).\n+ * \n+ * The and functions here merely iterate through\n+ * the components, summing their respective areas and lengths.\n+ *\n+ * Create a new instance with the constructor.\n+ *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Format.GML = OpenLayers.Class(OpenLayers.Format.XML, {\n+OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {\n \n /**\n- * APIProperty: featureNS\n- * {String} Namespace used for feature attributes. Default is\n- * \"http://mapserver.gis.umn.edu/mapserver\".\n+ * APIProperty: components\n+ * {Array()} The component parts of this geometry\n */\n- featureNS: \"http://mapserver.gis.umn.edu/mapserver\",\n+ components: null,\n \n /**\n- * APIProperty: featurePrefix\n- * {String} Namespace alias (or prefix) for feature nodes. Default is\n- * \"feature\".\n+ * Property: componentTypes\n+ * {Array(String)} An array of class names representing the types of\n+ * components that the collection can include. A null value means the\n+ * component types are not restricted.\n */\n- featurePrefix: \"feature\",\n+ componentTypes: null,\n \n /**\n- * APIProperty: featureName\n- * {String} Element name for features. Default is \"featureMember\".\n+ * Constructor: OpenLayers.Geometry.Collection\n+ * Creates a Geometry Collection -- a list of geoms.\n+ *\n+ * Parameters: \n+ * components - {Array()} Optional array of geometries\n+ *\n */\n- featureName: \"featureMember\",\n+ initialize: function(components) {\n+ OpenLayers.Geometry.prototype.initialize.apply(this, arguments);\n+ this.components = [];\n+ if (components != null) {\n+ this.addComponents(components);\n+ }\n+ },\n \n /**\n- * APIProperty: layerName\n- * {String} Name of data layer. Default is \"features\".\n+ * APIMethod: destroy\n+ * Destroy this geometry.\n */\n- layerName: \"features\",\n+ destroy: function() {\n+ this.components.length = 0;\n+ this.components = null;\n+ OpenLayers.Geometry.prototype.destroy.apply(this, arguments);\n+ },\n \n /**\n- * APIProperty: geometryName\n- * {String} Name of geometry element. Defaults to \"geometry\".\n+ * APIMethod: clone\n+ * Clone this geometry.\n+ *\n+ * Returns:\n+ * {} An exact clone of this collection\n */\n- geometryName: \"geometry\",\n+ clone: function() {\n+ var geometry = eval(\"new \" + this.CLASS_NAME + \"()\");\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ geometry.addComponent(this.components[i].clone());\n+ }\n \n- /** \n- * APIProperty: collectionName\n- * {String} Name of featureCollection element.\n- */\n- collectionName: \"FeatureCollection\",\n+ // catch any randomly tagged-on properties\n+ OpenLayers.Util.applyDefaults(geometry, this);\n \n- /**\n- * APIProperty: gmlns\n- * {String} GML Namespace.\n- */\n- gmlns: \"http://www.opengis.net/gml\",\n+ return geometry;\n+ },\n \n /**\n- * APIProperty: extractAttributes\n- * {Boolean} Extract attributes from GML.\n+ * Method: getComponentsString\n+ * Get a string representing the components for this collection\n+ * \n+ * Returns:\n+ * {String} A string representation of the components of this geometry\n */\n- extractAttributes: true,\n+ getComponentsString: function() {\n+ var strings = [];\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ strings.push(this.components[i].toShortString());\n+ }\n+ return strings.join(\",\");\n+ },\n \n /**\n- * APIProperty: xy\n- * {Boolean} Order of the GML coordinate true:(x,y) or false:(y,x)\n- * Changing is not recommended, a new Format should be instantiated.\n+ * APIMethod: calculateBounds\n+ * Recalculate the bounds by iterating through the components and \n+ * calling calling extendBounds() on each item.\n */\n- xy: true,\n+ calculateBounds: function() {\n+ this.bounds = null;\n+ var bounds = new OpenLayers.Bounds();\n+ var components = this.components;\n+ if (components) {\n+ for (var i = 0, len = components.length; i < len; i++) {\n+ bounds.extend(components[i].getBounds());\n+ }\n+ }\n+ // to preserve old behavior, we only set bounds if non-null\n+ // in the future, we could add bounds.isEmpty()\n+ if (bounds.left != null && bounds.bottom != null &&\n+ bounds.right != null && bounds.top != null) {\n+ this.setBounds(bounds);\n+ }\n+ },\n \n /**\n- * Constructor: OpenLayers.Format.GML\n- * Create a new parser for GML.\n+ * APIMethod: addComponents\n+ * Add components to this geometry.\n *\n * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ * components - {Array()} An array of geometries to add\n */\n- initialize: function(options) {\n- // compile regular expressions once instead of every time they are used\n- this.regExes = {\n- trimSpace: (/^\\s*|\\s*$/g),\n- removeSpace: (/\\s*/g),\n- splitSpace: (/\\s+/),\n- trimComma: (/\\s*,\\s*/g)\n- };\n- OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);\n+ addComponents: function(components) {\n+ if (!(OpenLayers.Util.isArray(components))) {\n+ components = [components];\n+ }\n+ for (var i = 0, len = components.length; i < len; i++) {\n+ this.addComponent(components[i]);\n+ }\n },\n \n /**\n- * APIMethod: read\n- * Read data from a string, and return a list of features. \n+ * Method: addComponent\n+ * Add a new component (geometry) to the collection. If this.componentTypes\n+ * is set, then the component class name must be in the componentTypes array.\n+ *\n+ * The bounds cache is reset.\n * \n * Parameters:\n- * data - {String} or {DOMElement} data to read/parse.\n+ * component - {} A geometry to add\n+ * index - {int} Optional index into the array to insert the component\n *\n * Returns:\n- * {Array()} An array of features.\n+ * {Boolean} The component geometry was successfully added\n */\n- read: function(data) {\n- if (typeof data == \"string\") {\n- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n- }\n- var featureNodes = this.getElementsByTagNameNS(data.documentElement,\n- this.gmlns,\n- this.featureName);\n- var features = [];\n- for (var i = 0; i < featureNodes.length; i++) {\n- var feature = this.parseFeature(featureNodes[i]);\n- if (feature) {\n- features.push(feature);\n+ addComponent: function(component, index) {\n+ var added = false;\n+ if (component) {\n+ if (this.componentTypes == null ||\n+ (OpenLayers.Util.indexOf(this.componentTypes,\n+ component.CLASS_NAME) > -1)) {\n+\n+ if (index != null && (index < this.components.length)) {\n+ var components1 = this.components.slice(0, index);\n+ var components2 = this.components.slice(index,\n+ this.components.length);\n+ components1.push(component);\n+ this.components = components1.concat(components2);\n+ } else {\n+ this.components.push(component);\n+ }\n+ component.parent = this;\n+ this.clearBounds();\n+ added = true;\n }\n }\n- return features;\n+ return added;\n },\n \n /**\n- * Method: parseFeature\n- * This function is the core of the GML parsing code in OpenLayers.\n- * It creates the geometries that are then attached to the returned\n- * feature, and calls parseAttributes() to get attribute data out.\n- * \n+ * APIMethod: removeComponents\n+ * Remove components from this geometry.\n+ *\n * Parameters:\n- * node - {DOMElement} A GML feature node. \n+ * components - {Array()} The components to be removed\n+ *\n+ * Returns: \n+ * {Boolean} A component was removed.\n */\n- parseFeature: function(node) {\n- // only accept one geometry per feature - look for highest \"order\"\n- var order = [\"MultiPolygon\", \"Polygon\",\n- \"MultiLineString\", \"LineString\",\n- \"MultiPoint\", \"Point\", \"Envelope\"\n- ];\n- // FIXME: In case we parse a feature with no geometry, but boundedBy an Envelope,\n- // this code creates a geometry derived from the Envelope. This is not correct.\n- var type, nodeList, geometry, parser;\n- for (var i = 0; i < order.length; ++i) {\n- type = order[i];\n- nodeList = this.getElementsByTagNameNS(node, this.gmlns, type);\n- if (nodeList.length > 0) {\n- // only deal with first geometry of this type\n- parser = this.parseGeometry[type.toLowerCase()];\n- if (parser) {\n- geometry = parser.apply(this, [nodeList[0]]);\n- if (this.internalProjection && this.externalProjection) {\n- geometry.transform(this.externalProjection,\n- this.internalProjection);\n- }\n- } else {\n- throw new TypeError(\"Unsupported geometry type: \" + type);\n- }\n- // stop looking for different geometry types\n- break;\n- }\n- }\n-\n- var bounds;\n- var boxNodes = this.getElementsByTagNameNS(node, this.gmlns, \"Box\");\n- for (i = 0; i < boxNodes.length; ++i) {\n- var boxNode = boxNodes[i];\n- var box = this.parseGeometry[\"box\"].apply(this, [boxNode]);\n- var parentNode = boxNode.parentNode;\n- var parentName = parentNode.localName ||\n- parentNode.nodeName.split(\":\").pop();\n- if (parentName === \"boundedBy\") {\n- bounds = box;\n- } else {\n- geometry = box.toGeometry();\n- }\n- }\n+ removeComponents: function(components) {\n+ var removed = false;\n \n- // construct feature (optionally with attributes)\n- var attributes;\n- if (this.extractAttributes) {\n- attributes = this.parseAttributes(node);\n+ if (!(OpenLayers.Util.isArray(components))) {\n+ components = [components];\n }\n- var feature = new OpenLayers.Feature.Vector(geometry, attributes);\n- feature.bounds = bounds;\n-\n- feature.gml = {\n- featureType: node.firstChild.nodeName.split(\":\")[1],\n- featureNS: node.firstChild.namespaceURI,\n- featureNSPrefix: node.firstChild.prefix\n- };\n-\n- // assign fid - this can come from a \"fid\" or \"id\" attribute\n- var childNode = node.firstChild;\n- var fid;\n- while (childNode) {\n- if (childNode.nodeType == 1) {\n- fid = childNode.getAttribute(\"fid\") ||\n- childNode.getAttribute(\"id\");\n- if (fid) {\n- break;\n- }\n- }\n- childNode = childNode.nextSibling;\n+ for (var i = components.length - 1; i >= 0; --i) {\n+ removed = this.removeComponent(components[i]) || removed;\n }\n- feature.fid = fid;\n- return feature;\n+ return removed;\n },\n \n /**\n- * Property: parseGeometry\n- * Properties of this object are the functions that parse geometries based\n- * on their type.\n+ * Method: removeComponent\n+ * Remove a component from this geometry.\n+ *\n+ * Parameters:\n+ * component - {} \n+ *\n+ * Returns: \n+ * {Boolean} The component was removed.\n */\n- parseGeometry: {\n-\n- /**\n- * Method: parseGeometry.point\n- * Given a GML node representing a point geometry, create an OpenLayers\n- * point geometry.\n- *\n- * Parameters:\n- * node - {DOMElement} A GML node.\n- *\n- * Returns:\n- * {} A point geometry.\n- */\n- point: function(node) {\n- /**\n- * Three coordinate variations to consider:\n- * 1) x y z\n- * 2) x, y, z\n- * 3) xy\n- */\n- var nodeList, coordString;\n- var coords = [];\n-\n- // look for \n- var nodeList = this.getElementsByTagNameNS(node, this.gmlns, \"pos\");\n- if (nodeList.length > 0) {\n- coordString = nodeList[0].firstChild.nodeValue;\n- coordString = coordString.replace(this.regExes.trimSpace, \"\");\n- coords = coordString.split(this.regExes.splitSpace);\n- }\n-\n- // look for \n- if (coords.length == 0) {\n- nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n- \"coordinates\");\n- if (nodeList.length > 0) {\n- coordString = nodeList[0].firstChild.nodeValue;\n- coordString = coordString.replace(this.regExes.removeSpace,\n- \"\");\n- coords = coordString.split(\",\");\n- }\n- }\n-\n- // look for \n- if (coords.length == 0) {\n- nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n- \"coord\");\n- if (nodeList.length > 0) {\n- var xList = this.getElementsByTagNameNS(nodeList[0],\n- this.gmlns, \"X\");\n- var yList = this.getElementsByTagNameNS(nodeList[0],\n- this.gmlns, \"Y\");\n- if (xList.length > 0 && yList.length > 0) {\n- coords = [xList[0].firstChild.nodeValue,\n- yList[0].firstChild.nodeValue\n- ];\n- }\n- }\n- }\n-\n- // preserve third dimension\n- if (coords.length == 2) {\n- coords[2] = null;\n- }\n-\n- if (this.xy) {\n- return new OpenLayers.Geometry.Point(coords[0], coords[1],\n- coords[2]);\n- } else {\n- return new OpenLayers.Geometry.Point(coords[1], coords[0],\n- coords[2]);\n- }\n- },\n+ removeComponent: function(component) {\n \n- /**\n- * Method: parseGeometry.multipoint\n- * Given a GML node representing a multipoint geometry, create an\n- * OpenLayers multipoint geometry.\n- *\n- * Parameters:\n- * node - {DOMElement} A GML node.\n- *\n- * Returns:\n- * {} A multipoint geometry.\n- */\n- multipoint: function(node) {\n- var nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n- \"Point\");\n- var components = [];\n- if (nodeList.length > 0) {\n- var point;\n- for (var i = 0; i < nodeList.length; ++i) {\n- point = this.parseGeometry.point.apply(this, [nodeList[i]]);\n- if (point) {\n- components.push(point);\n- }\n- }\n- }\n- return new OpenLayers.Geometry.MultiPoint(components);\n- },\n+ OpenLayers.Util.removeItem(this.components, component);\n \n- /**\n- * Method: parseGeometry.linestring\n- * Given a GML node representing a linestring geometry, create an\n- * OpenLayers linestring geometry.\n- *\n- * Parameters:\n- * node - {DOMElement} A GML node.\n- *\n- * Returns:\n- * {} A linestring geometry.\n- */\n- linestring: function(node, ring) {\n- /**\n- * Two coordinate variations to consider:\n- * 1) x0 y0 z0 x1 y1 z1\n- * 2) x0, y0, z0 x1, y1, z1\n- */\n- var nodeList, coordString;\n- var coords = [];\n- var points = [];\n+ // clearBounds() so that it gets recalculated on the next call\n+ // to this.getBounds();\n+ this.clearBounds();\n+ return true;\n+ },\n \n- // look for \n- nodeList = this.getElementsByTagNameNS(node, this.gmlns, \"posList\");\n- if (nodeList.length > 0) {\n- coordString = this.getChildValue(nodeList[0]);\n- coordString = coordString.replace(this.regExes.trimSpace, \"\");\n- coords = coordString.split(this.regExes.splitSpace);\n- var dim = parseInt(nodeList[0].getAttribute(\"dimension\"));\n- var j, x, y, z;\n- for (var i = 0; i < coords.length / dim; ++i) {\n- j = i * dim;\n- x = coords[j];\n- y = coords[j + 1];\n- z = (dim == 2) ? null : coords[j + 2];\n- if (this.xy) {\n- points.push(new OpenLayers.Geometry.Point(x, y, z));\n- } else {\n- points.push(new OpenLayers.Geometry.Point(y, x, z));\n- }\n- }\n- }\n+ /**\n+ * APIMethod: getLength\n+ * Calculate the length of this geometry\n+ *\n+ * Returns:\n+ * {Float} The length of the geometry\n+ */\n+ getLength: function() {\n+ var length = 0.0;\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ length += this.components[i].getLength();\n+ }\n+ return length;\n+ },\n \n- // look for \n- if (coords.length == 0) {\n- nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n- \"coordinates\");\n- if (nodeList.length > 0) {\n- coordString = this.getChildValue(nodeList[0]);\n- coordString = coordString.replace(this.regExes.trimSpace,\n- \"\");\n- coordString = coordString.replace(this.regExes.trimComma,\n- \",\");\n- var pointList = coordString.split(this.regExes.splitSpace);\n- for (var i = 0; i < pointList.length; ++i) {\n- coords = pointList[i].split(\",\");\n- if (coords.length == 2) {\n- coords[2] = null;\n- }\n- if (this.xy) {\n- points.push(new OpenLayers.Geometry.Point(coords[0],\n- coords[1],\n- coords[2]));\n- } else {\n- points.push(new OpenLayers.Geometry.Point(coords[1],\n- coords[0],\n- coords[2]));\n- }\n- }\n- }\n- }\n+ /**\n+ * APIMethod: getArea\n+ * Calculate the area of this geometry. Note how this function is overridden\n+ * in .\n+ *\n+ * Returns:\n+ * {Float} The area of the collection by summing its parts\n+ */\n+ getArea: function() {\n+ var area = 0.0;\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ area += this.components[i].getArea();\n+ }\n+ return area;\n+ },\n \n- var line = null;\n- if (points.length != 0) {\n- if (ring) {\n- line = new OpenLayers.Geometry.LinearRing(points);\n- } else {\n- line = new OpenLayers.Geometry.LineString(points);\n- }\n- }\n- return line;\n- },\n+ /** \n+ * APIMethod: getGeodesicArea\n+ * Calculate the approximate area of the polygon were it projected onto\n+ * the earth.\n+ *\n+ * Parameters:\n+ * projection - {} The spatial reference system\n+ * for the geometry coordinates. If not provided, Geographic/WGS84 is\n+ * assumed.\n+ * \n+ * Reference:\n+ * Robert. G. Chamberlain and William H. Duquette, \"Some Algorithms for\n+ * Polygons on a Sphere\", JPL Publication 07-03, Jet Propulsion\n+ * Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409\n+ *\n+ * Returns:\n+ * {float} The approximate geodesic area of the geometry in square meters.\n+ */\n+ getGeodesicArea: function(projection) {\n+ var area = 0.0;\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ area += this.components[i].getGeodesicArea(projection);\n+ }\n+ return area;\n+ },\n \n- /**\n- * Method: parseGeometry.multilinestring\n- * Given a GML node representing a multilinestring geometry, create an\n- * OpenLayers multilinestring geometry.\n- *\n- * Parameters:\n- * node - {DOMElement} A GML node.\n- *\n- * Returns:\n- * {} A multilinestring geometry.\n- */\n- multilinestring: function(node) {\n- var nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n- \"LineString\");\n- var components = [];\n- if (nodeList.length > 0) {\n- var line;\n- for (var i = 0; i < nodeList.length; ++i) {\n- line = this.parseGeometry.linestring.apply(this,\n- [nodeList[i]]);\n- if (line) {\n- components.push(line);\n- }\n- }\n- }\n- return new OpenLayers.Geometry.MultiLineString(components);\n- },\n+ /**\n+ * APIMethod: getCentroid\n+ *\n+ * Compute the centroid for this geometry collection.\n+ *\n+ * Parameters:\n+ * weighted - {Boolean} Perform the getCentroid computation recursively,\n+ * returning an area weighted average of all geometries in this collection.\n+ *\n+ * Returns:\n+ * {} The centroid of the collection\n+ */\n+ getCentroid: function(weighted) {\n+ if (!weighted) {\n+ return this.components.length && this.components[0].getCentroid();\n+ }\n+ var len = this.components.length;\n+ if (!len) {\n+ return false;\n+ }\n \n- /**\n- * Method: parseGeometry.polygon\n- * Given a GML node representing a polygon geometry, create an\n- * OpenLayers polygon geometry.\n- *\n- * Parameters:\n- * node - {DOMElement} A GML node.\n- *\n- * Returns:\n- * {} A polygon geometry.\n- */\n- polygon: function(node) {\n- var nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n- \"LinearRing\");\n- var components = [];\n- if (nodeList.length > 0) {\n- // this assumes exterior ring first, inner rings after\n- var ring;\n- for (var i = 0; i < nodeList.length; ++i) {\n- ring = this.parseGeometry.linestring.apply(this,\n- [nodeList[i], true]);\n- if (ring) {\n- components.push(ring);\n- }\n- }\n+ var areas = [];\n+ var centroids = [];\n+ var areaSum = 0;\n+ var minArea = Number.MAX_VALUE;\n+ var component;\n+ for (var i = 0; i < len; ++i) {\n+ component = this.components[i];\n+ var area = component.getArea();\n+ var centroid = component.getCentroid(true);\n+ if (isNaN(area) || isNaN(centroid.x) || isNaN(centroid.y)) {\n+ continue;\n }\n- return new OpenLayers.Geometry.Polygon(components);\n- },\n-\n- /**\n- * Method: parseGeometry.multipolygon\n- * Given a GML node representing a multipolygon geometry, create an\n- * OpenLayers multipolygon geometry.\n- *\n- * Parameters:\n- * node - {DOMElement} A GML node.\n- *\n- * Returns:\n- * {} A multipolygon geometry.\n- */\n- multipolygon: function(node) {\n- var nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n- \"Polygon\");\n- var components = [];\n- if (nodeList.length > 0) {\n- var polygon;\n- for (var i = 0; i < nodeList.length; ++i) {\n- polygon = this.parseGeometry.polygon.apply(this,\n- [nodeList[i]]);\n- if (polygon) {\n- components.push(polygon);\n- }\n- }\n+ areas.push(area);\n+ areaSum += area;\n+ minArea = (area < minArea && area > 0) ? area : minArea;\n+ centroids.push(centroid);\n+ }\n+ len = areas.length;\n+ if (areaSum === 0) {\n+ // all the components in this collection have 0 area\n+ // probably a collection of points -- weight all the points the same\n+ for (var i = 0; i < len; ++i) {\n+ areas[i] = 1;\n }\n- return new OpenLayers.Geometry.MultiPolygon(components);\n- },\n-\n- envelope: function(node) {\n- var components = [];\n- var coordString;\n- var envelope;\n-\n- var lpoint = this.getElementsByTagNameNS(node, this.gmlns, \"lowerCorner\");\n- if (lpoint.length > 0) {\n- var coords = [];\n-\n- if (lpoint.length > 0) {\n- coordString = lpoint[0].firstChild.nodeValue;\n- coordString = coordString.replace(this.regExes.trimSpace, \"\");\n- coords = coordString.split(this.regExes.splitSpace);\n- }\n-\n- if (coords.length == 2) {\n- coords[2] = null;\n- }\n- if (this.xy) {\n- var lowerPoint = new OpenLayers.Geometry.Point(coords[0], coords[1], coords[2]);\n- } else {\n- var lowerPoint = new OpenLayers.Geometry.Point(coords[1], coords[0], coords[2]);\n- }\n+ areaSum = areas.length;\n+ } else {\n+ // normalize all the areas where the smallest area will get\n+ // a value of 1\n+ for (var i = 0; i < len; ++i) {\n+ areas[i] /= minArea;\n }\n+ areaSum /= minArea;\n+ }\n \n- var upoint = this.getElementsByTagNameNS(node, this.gmlns, \"upperCorner\");\n- if (upoint.length > 0) {\n- var coords = [];\n-\n- if (upoint.length > 0) {\n- coordString = upoint[0].firstChild.nodeValue;\n- coordString = coordString.replace(this.regExes.trimSpace, \"\");\n- coords = coordString.split(this.regExes.splitSpace);\n- }\n+ var xSum = 0,\n+ ySum = 0,\n+ centroid, area;\n+ for (var i = 0; i < len; ++i) {\n+ centroid = centroids[i];\n+ area = areas[i];\n+ xSum += centroid.x * area;\n+ ySum += centroid.y * area;\n+ }\n \n- if (coords.length == 2) {\n- coords[2] = null;\n- }\n- if (this.xy) {\n- var upperPoint = new OpenLayers.Geometry.Point(coords[0], coords[1], coords[2]);\n- } else {\n- var upperPoint = new OpenLayers.Geometry.Point(coords[1], coords[0], coords[2]);\n- }\n- }\n+ return new OpenLayers.Geometry.Point(xSum / areaSum, ySum / areaSum);\n+ },\n \n- if (lowerPoint && upperPoint) {\n- components.push(new OpenLayers.Geometry.Point(lowerPoint.x, lowerPoint.y));\n- components.push(new OpenLayers.Geometry.Point(upperPoint.x, lowerPoint.y));\n- components.push(new OpenLayers.Geometry.Point(upperPoint.x, upperPoint.y));\n- components.push(new OpenLayers.Geometry.Point(lowerPoint.x, upperPoint.y));\n- components.push(new OpenLayers.Geometry.Point(lowerPoint.x, lowerPoint.y));\n+ /**\n+ * APIMethod: getGeodesicLength\n+ * Calculate the approximate length of the geometry were it projected onto\n+ * the earth.\n+ *\n+ * projection - {} The spatial reference system\n+ * for the geometry coordinates. If not provided, Geographic/WGS84 is\n+ * assumed.\n+ * \n+ * Returns:\n+ * {Float} The appoximate geodesic length of the geometry in meters.\n+ */\n+ getGeodesicLength: function(projection) {\n+ var length = 0.0;\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ length += this.components[i].getGeodesicLength(projection);\n+ }\n+ return length;\n+ },\n \n- var ring = new OpenLayers.Geometry.LinearRing(components);\n- envelope = new OpenLayers.Geometry.Polygon([ring]);\n- }\n- return envelope;\n- },\n+ /**\n+ * APIMethod: move\n+ * Moves a geometry by the given displacement along positive x and y axes.\n+ * This modifies the position of the geometry and clears the cached\n+ * bounds.\n+ *\n+ * Parameters:\n+ * x - {Float} Distance to move geometry in positive x direction. \n+ * y - {Float} Distance to move geometry in positive y direction.\n+ */\n+ move: function(x, y) {\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ this.components[i].move(x, y);\n+ }\n+ },\n \n- /**\n- * Method: parseGeometry.box\n- * Given a GML node representing a box geometry, create an\n- * OpenLayers.Bounds.\n- *\n- * Parameters:\n- * node - {DOMElement} A GML node.\n- *\n- * Returns:\n- * {} A bounds representing the box.\n- */\n- box: function(node) {\n- var nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n- \"coordinates\");\n- var coordString;\n- var coords, beginPoint = null,\n- endPoint = null;\n- if (nodeList.length > 0) {\n- coordString = nodeList[0].firstChild.nodeValue;\n- coords = coordString.split(\" \");\n- if (coords.length == 2) {\n- beginPoint = coords[0].split(\",\");\n- endPoint = coords[1].split(\",\");\n- }\n- }\n- if (beginPoint !== null && endPoint !== null) {\n- return new OpenLayers.Bounds(parseFloat(beginPoint[0]),\n- parseFloat(beginPoint[1]),\n- parseFloat(endPoint[0]),\n- parseFloat(endPoint[1]));\n- }\n+ /**\n+ * APIMethod: rotate\n+ * Rotate a geometry around some origin\n+ *\n+ * Parameters:\n+ * angle - {Float} Rotation angle in degrees (measured counterclockwise\n+ * from the positive x-axis)\n+ * origin - {} Center point for the rotation\n+ */\n+ rotate: function(angle, origin) {\n+ for (var i = 0, len = this.components.length; i < len; ++i) {\n+ this.components[i].rotate(angle, origin);\n }\n+ },\n \n+ /**\n+ * APIMethod: resize\n+ * Resize a geometry relative to some origin. Use this method to apply\n+ * a uniform scaling to a geometry.\n+ *\n+ * Parameters:\n+ * scale - {Float} Factor by which to scale the geometry. A scale of 2\n+ * doubles the size of the geometry in each dimension\n+ * (lines, for example, will be twice as long, and polygons\n+ * will have four times the area).\n+ * origin - {} Point of origin for resizing\n+ * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.\n+ * \n+ * Returns:\n+ * {} - The current geometry. \n+ */\n+ resize: function(scale, origin, ratio) {\n+ for (var i = 0; i < this.components.length; ++i) {\n+ this.components[i].resize(scale, origin, ratio);\n+ }\n+ return this;\n },\n \n /**\n- * Method: parseAttributes\n+ * APIMethod: distanceTo\n+ * Calculate the closest distance between two geometries (on the x-y plane).\n *\n * Parameters:\n- * node - {DOMElement}\n+ * geometry - {} The target geometry.\n+ * options - {Object} Optional properties for configuring the distance\n+ * calculation.\n+ *\n+ * Valid options:\n+ * details - {Boolean} Return details from the distance calculation.\n+ * Default is false.\n+ * edge - {Boolean} Calculate the distance from this geometry to the\n+ * nearest edge of the target geometry. Default is true. If true,\n+ * calling distanceTo from a geometry that is wholly contained within\n+ * the target will result in a non-zero distance. If false, whenever\n+ * geometries intersect, calling distanceTo will return 0. If false,\n+ * details cannot be returned.\n *\n * Returns:\n- * {Object} An attributes object.\n+ * {Number | Object} The distance between this geometry and the target.\n+ * If details is true, the return will be an object with distance,\n+ * x0, y0, x1, and y1 properties. The x0 and y0 properties represent\n+ * the coordinates of the closest point on this geometry. The x1 and y1\n+ * properties represent the coordinates of the closest point on the\n+ * target geometry.\n */\n- parseAttributes: function(node) {\n- var attributes = {};\n- // assume attributes are children of the first type 1 child\n- var childNode = node.firstChild;\n- var children, i, child, grandchildren, grandchild, name, value;\n- while (childNode) {\n- if (childNode.nodeType == 1) {\n- // attributes are type 1 children with one type 3 child\n- children = childNode.childNodes;\n- for (i = 0; i < children.length; ++i) {\n- child = children[i];\n- if (child.nodeType == 1) {\n- grandchildren = child.childNodes;\n- if (grandchildren.length == 1) {\n- grandchild = grandchildren[0];\n- if (grandchild.nodeType == 3 ||\n- grandchild.nodeType == 4) {\n- name = (child.prefix) ?\n- child.nodeName.split(\":\")[1] :\n- child.nodeName;\n- value = grandchild.nodeValue.replace(\n- this.regExes.trimSpace, \"\");\n- attributes[name] = value;\n- }\n- } else {\n- // If child has no childNodes (grandchildren),\n- // set an attribute with null value.\n- // e.g. becomes\n- // {fieldname: null}\n- attributes[child.nodeName.split(\":\").pop()] = null;\n- }\n- }\n+ distanceTo: function(geometry, options) {\n+ var edge = !(options && options.edge === false);\n+ var details = edge && options && options.details;\n+ var result, best, distance;\n+ var min = Number.POSITIVE_INFINITY;\n+ for (var i = 0, len = this.components.length; i < len; ++i) {\n+ result = this.components[i].distanceTo(geometry, options);\n+ distance = details ? result.distance : result;\n+ if (distance < min) {\n+ min = distance;\n+ best = result;\n+ if (min == 0) {\n+ break;\n }\n- break;\n }\n- childNode = childNode.nextSibling;\n }\n- return attributes;\n+ return best;\n },\n \n- /**\n- * APIMethod: write\n- * Generate a GML document string given a list of features. \n+ /** \n+ * APIMethod: equals\n+ * Determine whether another geometry is equivalent to this one. Geometries\n+ * are considered equivalent if all components have the same coordinates.\n * \n * Parameters:\n- * features - {Array()} List of features to\n- * serialize into a string.\n+ * geometry - {} The geometry to test. \n *\n * Returns:\n- * {String} A string representing the GML document.\n+ * {Boolean} The supplied geometry is equivalent to this geometry.\n */\n- write: function(features) {\n- if (!(OpenLayers.Util.isArray(features))) {\n- features = [features];\n+ equals: function(geometry) {\n+ var equivalent = true;\n+ if (!geometry || !geometry.CLASS_NAME ||\n+ (this.CLASS_NAME != geometry.CLASS_NAME)) {\n+ equivalent = false;\n+ } else if (!(OpenLayers.Util.isArray(geometry.components)) ||\n+ (geometry.components.length != this.components.length)) {\n+ equivalent = false;\n+ } else {\n+ for (var i = 0, len = this.components.length; i < len; ++i) {\n+ if (!this.components[i].equals(geometry.components[i])) {\n+ equivalent = false;\n+ break;\n+ }\n+ }\n }\n- var gml = this.createElementNS(\"http://www.opengis.net/wfs\",\n- \"wfs:\" + this.collectionName);\n- for (var i = 0; i < features.length; i++) {\n- gml.appendChild(this.createFeatureXML(features[i]));\n+ return equivalent;\n+ },\n+\n+ /**\n+ * APIMethod: transform\n+ * Reproject the components geometry from source to dest.\n+ * \n+ * Parameters:\n+ * source - {} \n+ * dest - {}\n+ * \n+ * Returns:\n+ * {} \n+ */\n+ transform: function(source, dest) {\n+ if (source && dest) {\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ var component = this.components[i];\n+ component.transform(source, dest);\n+ }\n+ this.bounds = null;\n }\n- return OpenLayers.Format.XML.prototype.write.apply(this, [gml]);\n+ return this;\n },\n \n- /** \n- * Method: createFeatureXML\n- * Accept an OpenLayers.Feature.Vector, and build a GML node for it.\n+ /**\n+ * APIMethod: intersects\n+ * Determine if the input geometry intersects this one.\n *\n * Parameters:\n- * feature - {} The feature to be built as GML.\n+ * geometry - {} Any type of geometry.\n *\n * Returns:\n- * {DOMElement} A node reprensting the feature in GML.\n+ * {Boolean} The input geometry intersects this one.\n */\n- createFeatureXML: function(feature) {\n- var geometry = feature.geometry;\n- var geometryNode = this.buildGeometryNode(geometry);\n- var geomContainer = this.createElementNS(this.featureNS,\n- this.featurePrefix + \":\" +\n- this.geometryName);\n- geomContainer.appendChild(geometryNode);\n- var featureNode = this.createElementNS(this.gmlns,\n- \"gml:\" + this.featureName);\n- var featureContainer = this.createElementNS(this.featureNS,\n- this.featurePrefix + \":\" +\n- this.layerName);\n- var fid = feature.fid || feature.id;\n- featureContainer.setAttribute(\"fid\", fid);\n- featureContainer.appendChild(geomContainer);\n- for (var attr in feature.attributes) {\n- var attrText = this.createTextNode(feature.attributes[attr]);\n- var nodename = attr.substring(attr.lastIndexOf(\":\") + 1);\n- var attrContainer = this.createElementNS(this.featureNS,\n- this.featurePrefix + \":\" +\n- nodename);\n- attrContainer.appendChild(attrText);\n- featureContainer.appendChild(attrContainer);\n+ intersects: function(geometry) {\n+ var intersect = false;\n+ for (var i = 0, len = this.components.length; i < len; ++i) {\n+ intersect = geometry.intersects(this.components[i]);\n+ if (intersect) {\n+ break;\n+ }\n }\n- featureNode.appendChild(featureContainer);\n- return featureNode;\n+ return intersect;\n },\n \n /**\n- * APIMethod: buildGeometryNode\n+ * APIMethod: getVertices\n+ * Return a list of all points in this geometry.\n+ *\n+ * Parameters:\n+ * nodes - {Boolean} For lines, only return vertices that are\n+ * endpoints. If false, for lines, only vertices that are not\n+ * endpoints will be returned. If not provided, all vertices will\n+ * be returned.\n+ *\n+ * Returns:\n+ * {Array} A list of all vertices in the geometry.\n */\n- buildGeometryNode: function(geometry) {\n- if (this.externalProjection && this.internalProjection) {\n- geometry = geometry.clone();\n- geometry.transform(this.internalProjection,\n- this.externalProjection);\n+ getVertices: function(nodes) {\n+ var vertices = [];\n+ for (var i = 0, len = this.components.length; i < len; ++i) {\n+ Array.prototype.push.apply(\n+ vertices, this.components[i].getVertices(nodes)\n+ );\n }\n- var className = geometry.CLASS_NAME;\n- var type = className.substring(className.lastIndexOf(\".\") + 1);\n- var builder = this.buildGeometry[type.toLowerCase()];\n- return builder.apply(this, [geometry]);\n+ return vertices;\n },\n \n- /**\n- * Property: buildGeometry\n- * Object containing methods to do the actual geometry node building\n- * based on geometry type.\n- */\n- buildGeometry: {\n- // TBD retrieve the srs from layer\n- // srsName is non-standard, so not including it until it's right.\n- // gml.setAttribute(\"srsName\",\n- // \"http://www.opengis.net/gml/srs/epsg.xml#4326\");\n \n- /**\n- * Method: buildGeometry.point\n- * Given an OpenLayers point geometry, create a GML point.\n- *\n- * Parameters:\n- * geometry - {} A point geometry.\n- *\n- * Returns:\n- * {DOMElement} A GML point node.\n- */\n- point: function(geometry) {\n- var gml = this.createElementNS(this.gmlns, \"gml:Point\");\n- gml.appendChild(this.buildCoordinatesNode(geometry));\n- return gml;\n- },\n+ CLASS_NAME: \"OpenLayers.Geometry.Collection\"\n+});\n+/* ======================================================================\n+ OpenLayers/Geometry/MultiPoint.js\n+ ====================================================================== */\n \n- /**\n- * Method: buildGeometry.multipoint\n- * Given an OpenLayers multipoint geometry, create a GML multipoint.\n- *\n- * Parameters:\n- * geometry - {} A multipoint geometry.\n- *\n- * Returns:\n- * {DOMElement} A GML multipoint node.\n- */\n- multipoint: function(geometry) {\n- var gml = this.createElementNS(this.gmlns, \"gml:MultiPoint\");\n- var points = geometry.components;\n- var pointMember, pointGeom;\n- for (var i = 0; i < points.length; i++) {\n- pointMember = this.createElementNS(this.gmlns,\n- \"gml:pointMember\");\n- pointGeom = this.buildGeometry.point.apply(this,\n- [points[i]]);\n- pointMember.appendChild(pointGeom);\n- gml.appendChild(pointMember);\n- }\n- return gml;\n- },\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- /**\n- * Method: buildGeometry.linestring\n- * Given an OpenLayers linestring geometry, create a GML linestring.\n- *\n- * Parameters:\n- * geometry - {} A linestring geometry.\n- *\n- * Returns:\n- * {DOMElement} A GML linestring node.\n- */\n- linestring: function(geometry) {\n- var gml = this.createElementNS(this.gmlns, \"gml:LineString\");\n- gml.appendChild(this.buildCoordinatesNode(geometry));\n- return gml;\n- },\n+/**\n+ * @requires OpenLayers/Geometry/Collection.js\n+ * @requires OpenLayers/Geometry/Point.js\n+ */\n \n- /**\n- * Method: buildGeometry.multilinestring\n- * Given an OpenLayers multilinestring geometry, create a GML\n- * multilinestring.\n- *\n- * Parameters:\n- * geometry - {} A multilinestring\n- * geometry.\n- *\n- * Returns:\n- * {DOMElement} A GML multilinestring node.\n- */\n- multilinestring: function(geometry) {\n- var gml = this.createElementNS(this.gmlns, \"gml:MultiLineString\");\n- var lines = geometry.components;\n- var lineMember, lineGeom;\n- for (var i = 0; i < lines.length; ++i) {\n- lineMember = this.createElementNS(this.gmlns,\n- \"gml:lineStringMember\");\n- lineGeom = this.buildGeometry.linestring.apply(this,\n- [lines[i]]);\n- lineMember.appendChild(lineGeom);\n- gml.appendChild(lineMember);\n- }\n- return gml;\n- },\n+/**\n+ * Class: OpenLayers.Geometry.MultiPoint\n+ * MultiPoint is a collection of Points. Create a new instance with the\n+ * constructor.\n+ *\n+ * Inherits from:\n+ * - \n+ * - \n+ */\n+OpenLayers.Geometry.MultiPoint = OpenLayers.Class(\n+ OpenLayers.Geometry.Collection, {\n \n /**\n- * Method: buildGeometry.linearring\n- * Given an OpenLayers linearring geometry, create a GML linearring.\n- *\n- * Parameters:\n- * geometry - {} A linearring geometry.\n- *\n- * Returns:\n- * {DOMElement} A GML linearring node.\n+ * Property: componentTypes\n+ * {Array(String)} An array of class names representing the types of\n+ * components that the collection can include. A null value means the\n+ * component types are not restricted.\n */\n- linearring: function(geometry) {\n- var gml = this.createElementNS(this.gmlns, \"gml:LinearRing\");\n- gml.appendChild(this.buildCoordinatesNode(geometry));\n- return gml;\n- },\n+ componentTypes: [\"OpenLayers.Geometry.Point\"],\n \n /**\n- * Method: buildGeometry.polygon\n- * Given an OpenLayers polygon geometry, create a GML polygon.\n+ * Constructor: OpenLayers.Geometry.MultiPoint\n+ * Create a new MultiPoint Geometry\n *\n * Parameters:\n- * geometry - {} A polygon geometry.\n+ * components - {Array()} \n *\n * Returns:\n- * {DOMElement} A GML polygon node.\n+ * {}\n */\n- polygon: function(geometry) {\n- var gml = this.createElementNS(this.gmlns, \"gml:Polygon\");\n- var rings = geometry.components;\n- var ringMember, ringGeom, type;\n- for (var i = 0; i < rings.length; ++i) {\n- type = (i == 0) ? \"outerBoundaryIs\" : \"innerBoundaryIs\";\n- ringMember = this.createElementNS(this.gmlns,\n- \"gml:\" + type);\n- ringGeom = this.buildGeometry.linearring.apply(this,\n- [rings[i]]);\n- ringMember.appendChild(ringGeom);\n- gml.appendChild(ringMember);\n- }\n- return gml;\n- },\n \n /**\n- * Method: buildGeometry.multipolygon\n- * Given an OpenLayers multipolygon geometry, create a GML multipolygon.\n+ * APIMethod: addPoint\n+ * Wrapper for \n *\n * Parameters:\n- * geometry - {} A multipolygon\n- * geometry.\n- *\n- * Returns:\n- * {DOMElement} A GML multipolygon node.\n+ * point - {} Point to be added\n+ * index - {Integer} Optional index\n */\n- multipolygon: function(geometry) {\n- var gml = this.createElementNS(this.gmlns, \"gml:MultiPolygon\");\n- var polys = geometry.components;\n- var polyMember, polyGeom;\n- for (var i = 0; i < polys.length; ++i) {\n- polyMember = this.createElementNS(this.gmlns,\n- \"gml:polygonMember\");\n- polyGeom = this.buildGeometry.polygon.apply(this,\n- [polys[i]]);\n- polyMember.appendChild(polyGeom);\n- gml.appendChild(polyMember);\n- }\n- return gml;\n-\n+ addPoint: function(point, index) {\n+ this.addComponent(point, index);\n },\n \n /**\n- * Method: buildGeometry.bounds\n- * Given an OpenLayers bounds, create a GML box.\n+ * APIMethod: removePoint\n+ * Wrapper for \n *\n * Parameters:\n- * bounds - {} A bounds object.\n- *\n- * Returns:\n- * {DOMElement} A GML box node.\n+ * point - {} Point to be removed\n */\n- bounds: function(bounds) {\n- var gml = this.createElementNS(this.gmlns, \"gml:Box\");\n- gml.appendChild(this.buildCoordinatesNode(bounds));\n- return gml;\n- }\n- },\n-\n- /**\n- * Method: buildCoordinates\n- * builds the coordinates XmlNode\n- * (code)\n- * ...\n- * (end)\n- *\n- * Parameters: \n- * geometry - {} \n- *\n- * Returns:\n- * {XmlNode} created xmlNode\n- */\n- buildCoordinatesNode: function(geometry) {\n- var coordinatesNode = this.createElementNS(this.gmlns,\n- \"gml:coordinates\");\n- coordinatesNode.setAttribute(\"decimal\", \".\");\n- coordinatesNode.setAttribute(\"cs\", \",\");\n- coordinatesNode.setAttribute(\"ts\", \" \");\n-\n- var parts = [];\n-\n- if (geometry instanceof OpenLayers.Bounds) {\n- parts.push(geometry.left + \",\" + geometry.bottom);\n- parts.push(geometry.right + \",\" + geometry.top);\n- } else {\n- var points = (geometry.components) ? geometry.components : [geometry];\n- for (var i = 0; i < points.length; i++) {\n- parts.push(points[i].x + \",\" + points[i].y);\n- }\n- }\n-\n- var txtNode = this.createTextNode(parts.join(\" \"));\n- coordinatesNode.appendChild(txtNode);\n-\n- return coordinatesNode;\n- },\n+ removePoint: function(point) {\n+ this.removeComponent(point);\n+ },\n \n- CLASS_NAME: \"OpenLayers.Format.GML\"\n-});\n+ CLASS_NAME: \"OpenLayers.Geometry.MultiPoint\"\n+ });\n /* ======================================================================\n- OpenLayers/Format/GML/Base.js\n+ OpenLayers/Geometry/Curve.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format/XML.js\n- * @requires OpenLayers/Format/GML.js\n- */\n-\n-/**\n- * Though required in the full build, if the GML format is excluded, we set\n- * the namespace here.\n+ * @requires OpenLayers/Geometry/MultiPoint.js\n */\n-if (!OpenLayers.Format.GML) {\n- OpenLayers.Format.GML = {};\n-}\n \n /**\n- * Class: OpenLayers.Format.GML.Base\n- * Superclass for GML parsers.\n- *\n- * Inherits from:\n- * - \n+ * Class: OpenLayers.Geometry.Curve\n+ * A Curve is a MultiPoint, whose points are assumed to be connected. To \n+ * this end, we provide a \"getLength()\" function, which iterates through \n+ * the points, summing the distances between them. \n+ * \n+ * Inherits: \n+ * - \n */\n-OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {\n-\n- /**\n- * Property: namespaces\n- * {Object} Mapping of namespace aliases to namespace URIs.\n- */\n- namespaces: {\n- gml: \"http://www.opengis.net/gml\",\n- xlink: \"http://www.w3.org/1999/xlink\",\n- xsi: \"http://www.w3.org/2001/XMLSchema-instance\",\n- wfs: \"http://www.opengis.net/wfs\" // this is a convenience for reading wfs:FeatureCollection\n- },\n-\n- /**\n- * Property: defaultPrefix\n- */\n- defaultPrefix: \"gml\",\n-\n- /**\n- * Property: schemaLocation\n- * {String} Schema location for a particular minor version.\n- */\n- schemaLocation: null,\n-\n- /**\n- * APIProperty: featureType\n- * {Array(String) or String} The local (without prefix) feature typeName(s).\n- */\n- featureType: null,\n+OpenLayers.Geometry.Curve = OpenLayers.Class(OpenLayers.Geometry.MultiPoint, {\n \n /**\n- * APIProperty: featureNS\n- * {String} The feature namespace. Must be set in the options at\n- * construction.\n+ * Property: componentTypes\n+ * {Array(String)} An array of class names representing the types of \n+ * components that the collection can include. A null \n+ * value means the component types are not restricted.\n */\n- featureNS: null,\n+ componentTypes: [\"OpenLayers.Geometry.Point\"],\n \n /**\n- * APIProperty: geometry\n- * {String} Name of geometry element. Defaults to \"geometry\". If null, it\n- * will be set on when the first geometry is parsed.\n+ * Constructor: OpenLayers.Geometry.Curve\n+ * \n+ * Parameters:\n+ * point - {Array()}\n */\n- geometryName: \"geometry\",\n \n /**\n- * APIProperty: extractAttributes\n- * {Boolean} Extract attributes from GML. Default is true.\n+ * APIMethod: getLength\n+ * \n+ * Returns:\n+ * {Float} The length of the curve\n */\n- extractAttributes: true,\n+ getLength: function() {\n+ var length = 0.0;\n+ if (this.components && (this.components.length > 1)) {\n+ for (var i = 1, len = this.components.length; i < len; i++) {\n+ length += this.components[i - 1].distanceTo(this.components[i]);\n+ }\n+ }\n+ return length;\n+ },\n \n /**\n- * APIProperty: srsName\n- * {String} URI for spatial reference system. This is optional for\n- * single part geometries and mandatory for collections and multis.\n- * If set, the srsName attribute will be written for all geometries.\n- * Default is null.\n+ * APIMethod: getGeodesicLength\n+ * Calculate the approximate length of the geometry were it projected onto\n+ * the earth.\n+ *\n+ * projection - {} The spatial reference system\n+ * for the geometry coordinates. If not provided, Geographic/WGS84 is\n+ * assumed.\n+ * \n+ * Returns:\n+ * {Float} The appoximate geodesic length of the geometry in meters.\n */\n- srsName: null,\n+ getGeodesicLength: function(projection) {\n+ var geom = this; // so we can work with a clone if needed\n+ if (projection) {\n+ var gg = new OpenLayers.Projection(\"EPSG:4326\");\n+ if (!gg.equals(projection)) {\n+ geom = this.clone().transform(projection, gg);\n+ }\n+ }\n+ var length = 0.0;\n+ if (geom.components && (geom.components.length > 1)) {\n+ var p1, p2;\n+ for (var i = 1, len = geom.components.length; i < len; i++) {\n+ p1 = geom.components[i - 1];\n+ p2 = geom.components[i];\n+ // this returns km and requires lon/lat properties\n+ length += OpenLayers.Util.distVincenty({\n+ lon: p1.x,\n+ lat: p1.y\n+ }, {\n+ lon: p2.x,\n+ lat: p2.y\n+ });\n+ }\n+ }\n+ // convert to m\n+ return length * 1000;\n+ },\n \n- /**\n- * APIProperty: xy\n- * {Boolean} Order of the GML coordinate true:(x,y) or false:(y,x)\n- * Changing is not recommended, a new Format should be instantiated.\n- */\n- xy: true,\n+ CLASS_NAME: \"OpenLayers.Geometry.Curve\"\n+});\n+/* ======================================================================\n+ OpenLayers/Geometry/LineString.js\n+ ====================================================================== */\n \n- /**\n- * Property: geometryTypes\n- * {Object} Maps OpenLayers geometry class names to GML element names.\n- * Use before accessing this property.\n- */\n- geometryTypes: null,\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- /**\n- * Property: singleFeatureType\n- * {Boolean} True if there is only 1 featureType, and not an array\n- * of featuretypes.\n- */\n- singleFeatureType: null,\n+/**\n+ * @requires OpenLayers/Geometry/Curve.js\n+ */\n \n- /**\n- * Property: autoConfig\n- * {Boolean} Indicates if the format was configured without a ,\n- * but auto-configured and during read.\n- * Subclasses making use of auto-configuration should make\n- * the first call to the method (usually in the read method)\n- * with true as 3rd argument, so the auto-configured featureType can be\n- * reset and the format can be reused for subsequent reads with data from\n- * different featureTypes. Set to false after read if you want to keep the\n- * auto-configured values.\n- */\n+/**\n+ * Class: OpenLayers.Geometry.LineString\n+ * A LineString is a Curve which, once two points have been added to it, can \n+ * never be less than two points long.\n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Geometry.LineString = OpenLayers.Class(OpenLayers.Geometry.Curve, {\n \n /**\n- * Property: regExes\n- * Compiled regular expressions for manipulating strings.\n+ * Constructor: OpenLayers.Geometry.LineString\n+ * Create a new LineString geometry\n+ *\n+ * Parameters:\n+ * points - {Array()} An array of points used to\n+ * generate the linestring\n+ *\n */\n- regExes: {\n- trimSpace: (/^\\s*|\\s*$/g),\n- removeSpace: (/\\s*/g),\n- splitSpace: (/\\s+/),\n- trimComma: (/\\s*,\\s*/g),\n- featureMember: (/^(.*:)?featureMembers?$/)\n- },\n \n /**\n- * Constructor: OpenLayers.Format.GML.Base\n- * Instances of this class are not created directly. Use the\n- * or constructor\n- * instead.\n+ * APIMethod: removeComponent\n+ * Only allows removal of a point if there are three or more points in \n+ * the linestring. (otherwise the result would be just a single point)\n *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ * Parameters: \n+ * point - {} The point to be removed\n *\n- * Valid options properties:\n- * featureType - {Array(String) or String} Local (without prefix) feature \n- * typeName(s) (required for write).\n- * featureNS - {String} Feature namespace (required for write).\n- * geometryName - {String} Geometry element name (required for write).\n+ * Returns: \n+ * {Boolean} The component was removed.\n */\n- initialize: function(options) {\n- OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);\n- this.setGeometryTypes();\n- if (options && options.featureNS) {\n- this.setNamespace(\"feature\", options.featureNS);\n+ removeComponent: function(point) {\n+ var removed = this.components && (this.components.length > 2);\n+ if (removed) {\n+ OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,\n+ arguments);\n }\n- this.singleFeatureType = !options || (typeof options.featureType === \"string\");\n+ return removed;\n },\n \n /**\n- * Method: read\n+ * APIMethod: intersects\n+ * Test for instersection between two geometries. This is a cheapo\n+ * implementation of the Bently-Ottmann algorigithm. It doesn't\n+ * really keep track of a sweep line data structure. It is closer\n+ * to the brute force method, except that segments are sorted and\n+ * potential intersections are only calculated when bounding boxes\n+ * intersect.\n *\n * Parameters:\n- * data - {DOMElement} A gml:featureMember element, a gml:featureMembers\n- * element, or an element containing either of the above at any level.\n+ * geometry - {}\n *\n * Returns:\n- * {Array()} An array of features.\n+ * {Boolean} The input geometry intersects this geometry.\n */\n- read: function(data) {\n- if (typeof data == \"string\") {\n- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n- }\n- if (data && data.nodeType == 9) {\n- data = data.documentElement;\n- }\n- var features = [];\n- this.readNode(data, {\n- features: features\n- }, true);\n- if (features.length == 0) {\n- // look for gml:featureMember elements\n- var elements = this.getElementsByTagNameNS(\n- data, this.namespaces.gml, \"featureMember\"\n- );\n- if (elements.length) {\n- for (var i = 0, len = elements.length; i < len; ++i) {\n- this.readNode(elements[i], {\n- features: features\n- }, true);\n- }\n+ intersects: function(geometry) {\n+ var intersect = false;\n+ var type = geometry.CLASS_NAME;\n+ if (type == \"OpenLayers.Geometry.LineString\" ||\n+ type == \"OpenLayers.Geometry.LinearRing\" ||\n+ type == \"OpenLayers.Geometry.Point\") {\n+ var segs1 = this.getSortedSegments();\n+ var segs2;\n+ if (type == \"OpenLayers.Geometry.Point\") {\n+ segs2 = [{\n+ x1: geometry.x,\n+ y1: geometry.y,\n+ x2: geometry.x,\n+ y2: geometry.y\n+ }];\n } else {\n- // look for gml:featureMembers elements (this is v3, but does no harm here)\n- var elements = this.getElementsByTagNameNS(\n- data, this.namespaces.gml, \"featureMembers\"\n- );\n- if (elements.length) {\n- // there can be only one\n- this.readNode(elements[0], {\n- features: features\n- }, true);\n+ segs2 = geometry.getSortedSegments();\n+ }\n+ var seg1, seg1x1, seg1x2, seg1y1, seg1y2,\n+ seg2, seg2y1, seg2y2;\n+ // sweep right\n+ outer: for (var i = 0, len = segs1.length; i < len; ++i) {\n+ seg1 = segs1[i];\n+ seg1x1 = seg1.x1;\n+ seg1x2 = seg1.x2;\n+ seg1y1 = seg1.y1;\n+ seg1y2 = seg1.y2;\n+ inner: for (var j = 0, jlen = segs2.length; j < jlen; ++j) {\n+ seg2 = segs2[j];\n+ if (seg2.x1 > seg1x2) {\n+ // seg1 still left of seg2\n+ break;\n+ }\n+ if (seg2.x2 < seg1x1) {\n+ // seg2 still left of seg1\n+ continue;\n+ }\n+ seg2y1 = seg2.y1;\n+ seg2y2 = seg2.y2;\n+ if (Math.min(seg2y1, seg2y2) > Math.max(seg1y1, seg1y2)) {\n+ // seg2 above seg1\n+ continue;\n+ }\n+ if (Math.max(seg2y1, seg2y2) < Math.min(seg1y1, seg1y2)) {\n+ // seg2 below seg1\n+ continue;\n+ }\n+ if (OpenLayers.Geometry.segmentsIntersect(seg1, seg2)) {\n+ intersect = true;\n+ break outer;\n+ }\n }\n }\n+ } else {\n+ intersect = geometry.intersects(this);\n }\n- return features;\n+ return intersect;\n },\n \n /**\n- * Method: readNode\n- * Shorthand for applying one of the named readers given the node\n- * namespace and local name. Readers take two args (node, obj) and\n- * generally extend or modify the second.\n- *\n- * Parameters:\n- * node - {DOMElement} The node to be read (required).\n- * obj - {Object} The object to be modified (optional).\n- * first - {Boolean} Should be set to true for the first node read. This\n- * is usually the readNode call in the read method. Without this being\n- * set, auto-configured properties will stick on subsequent reads.\n+ * Method: getSortedSegments\n *\n * Returns:\n- * {Object} The input object, modified (or a new one if none was provided).\n+ * {Array} An array of segment objects. Segment objects have properties\n+ * x1, y1, x2, and y2. The start point is represented by x1 and y1.\n+ * The end point is represented by x2 and y2. Start and end are\n+ * ordered so that x1 < x2.\n */\n- readNode: function(node, obj, first) {\n- // on subsequent calls of format.read(), we want to reset auto-\n- // configured properties and auto-configure again.\n- if (first === true && this.autoConfig === true) {\n- this.featureType = null;\n- delete this.namespaceAlias[this.featureNS];\n- delete this.namespaces[\"feature\"];\n- this.featureNS = null;\n+ getSortedSegments: function() {\n+ var numSeg = this.components.length - 1;\n+ var segments = new Array(numSeg),\n+ point1, point2;\n+ for (var i = 0; i < numSeg; ++i) {\n+ point1 = this.components[i];\n+ point2 = this.components[i + 1];\n+ if (point1.x < point2.x) {\n+ segments[i] = {\n+ x1: point1.x,\n+ y1: point1.y,\n+ x2: point2.x,\n+ y2: point2.y\n+ };\n+ } else {\n+ segments[i] = {\n+ x1: point2.x,\n+ y1: point2.y,\n+ x2: point1.x,\n+ y2: point1.y\n+ };\n+ }\n }\n- // featureType auto-configuration\n- if (!this.featureNS && (!(node.prefix in this.namespaces) &&\n- node.parentNode.namespaceURI == this.namespaces[\"gml\"] &&\n- this.regExes.featureMember.test(node.parentNode.nodeName))) {\n- this.featureType = node.nodeName.split(\":\").pop();\n- this.setNamespace(\"feature\", node.namespaceURI);\n- this.featureNS = node.namespaceURI;\n- this.autoConfig = true;\n+ // more efficient to define this somewhere static\n+ function byX1(seg1, seg2) {\n+ return seg1.x1 - seg2.x1;\n }\n- return OpenLayers.Format.XML.prototype.readNode.apply(this, [node, obj]);\n+ return segments.sort(byX1);\n },\n \n /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n+ * Method: splitWithSegment\n+ * Split this geometry with the given segment.\n+ *\n+ * Parameters:\n+ * seg - {Object} An object with x1, y1, x2, and y2 properties referencing\n+ * segment endpoint coordinates.\n+ * options - {Object} Properties of this object will be used to determine\n+ * how the split is conducted.\n+ *\n+ * Valid options:\n+ * edge - {Boolean} Allow splitting when only edges intersect. Default is\n+ * true. If false, a vertex on the source segment must be within the\n+ * tolerance distance of the intersection to be considered a split.\n+ * tolerance - {Number} If a non-null value is provided, intersections\n+ * within the tolerance distance of one of the source segment's\n+ * endpoints will be assumed to occur at the endpoint.\n+ *\n+ * Returns:\n+ * {Object} An object with *lines* and *points* properties. If the given\n+ * segment intersects this linestring, the lines array will reference\n+ * geometries that result from the split. The points array will contain\n+ * all intersection points. Intersection points are sorted along the\n+ * segment (in order from x1,y1 to x2,y2).\n */\n- readers: {\n- \"gml\": {\n- \"_inherit\": function(node, obj, container) {\n- // To be implemented by version specific parsers\n- },\n- \"featureMember\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"featureMembers\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"name\": function(node, obj) {\n- obj.name = this.getChildValue(node);\n- },\n- \"boundedBy\": function(node, obj) {\n- var container = {};\n- this.readChildNodes(node, container);\n- if (container.components && container.components.length > 0) {\n- obj.bounds = container.components[0];\n- }\n- },\n- \"Point\": function(node, container) {\n- var obj = {\n- points: []\n- };\n- this.readChildNodes(node, obj);\n- if (!container.components) {\n- container.components = [];\n- }\n- container.components.push(obj.points[0]);\n- },\n- \"coordinates\": function(node, obj) {\n- var str = this.getChildValue(node).replace(\n- this.regExes.trimSpace, \"\"\n- );\n- str = str.replace(this.regExes.trimComma, \",\");\n- var pointList = str.split(this.regExes.splitSpace);\n- var coords;\n- var numPoints = pointList.length;\n- var points = new Array(numPoints);\n- for (var i = 0; i < numPoints; ++i) {\n- coords = pointList[i].split(\",\");\n- if (this.xy) {\n- points[i] = new OpenLayers.Geometry.Point(\n- coords[0], coords[1], coords[2]\n- );\n- } else {\n- points[i] = new OpenLayers.Geometry.Point(\n- coords[1], coords[0], coords[2]\n- );\n- }\n- }\n- obj.points = points;\n- },\n- \"coord\": function(node, obj) {\n- var coord = {};\n- this.readChildNodes(node, coord);\n- if (!obj.points) {\n- obj.points = [];\n- }\n- obj.points.push(new OpenLayers.Geometry.Point(\n- coord.x, coord.y, coord.z\n- ));\n- },\n- \"X\": function(node, coord) {\n- coord.x = this.getChildValue(node);\n- },\n- \"Y\": function(node, coord) {\n- coord.y = this.getChildValue(node);\n- },\n- \"Z\": function(node, coord) {\n- coord.z = this.getChildValue(node);\n- },\n- \"MultiPoint\": function(node, container) {\n- var obj = {\n- components: []\n- };\n- this.readers.gml._inherit.apply(this, [node, obj, container]);\n- this.readChildNodes(node, obj);\n- container.components = [\n- new OpenLayers.Geometry.MultiPoint(obj.components)\n- ];\n- },\n- \"pointMember\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"LineString\": function(node, container) {\n- var obj = {};\n- this.readers.gml._inherit.apply(this, [node, obj, container]);\n- this.readChildNodes(node, obj);\n- if (!container.components) {\n- container.components = [];\n- }\n- container.components.push(\n- new OpenLayers.Geometry.LineString(obj.points)\n- );\n- },\n- \"MultiLineString\": function(node, container) {\n- var obj = {\n- components: []\n- };\n- this.readers.gml._inherit.apply(this, [node, obj, container]);\n- this.readChildNodes(node, obj);\n- container.components = [\n- new OpenLayers.Geometry.MultiLineString(obj.components)\n- ];\n- },\n- \"lineStringMember\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"Polygon\": function(node, container) {\n- var obj = {\n- outer: null,\n- inner: []\n- };\n- this.readers.gml._inherit.apply(this, [node, obj, container]);\n- this.readChildNodes(node, obj);\n- obj.inner.unshift(obj.outer);\n- if (!container.components) {\n- container.components = [];\n+ splitWithSegment: function(seg, options) {\n+ var edge = !(options && options.edge === false);\n+ var tolerance = options && options.tolerance;\n+ var lines = [];\n+ var verts = this.getVertices();\n+ var points = [];\n+ var intersections = [];\n+ var split = false;\n+ var vert1, vert2, point;\n+ var node, vertex, target;\n+ var interOptions = {\n+ point: true,\n+ tolerance: tolerance\n+ };\n+ var result = null;\n+ for (var i = 0, stop = verts.length - 2; i <= stop; ++i) {\n+ vert1 = verts[i];\n+ points.push(vert1.clone());\n+ vert2 = verts[i + 1];\n+ target = {\n+ x1: vert1.x,\n+ y1: vert1.y,\n+ x2: vert2.x,\n+ y2: vert2.y\n+ };\n+ point = OpenLayers.Geometry.segmentsIntersect(\n+ seg, target, interOptions\n+ );\n+ if (point instanceof OpenLayers.Geometry.Point) {\n+ if ((point.x === seg.x1 && point.y === seg.y1) ||\n+ (point.x === seg.x2 && point.y === seg.y2) ||\n+ point.equals(vert1) || point.equals(vert2)) {\n+ vertex = true;\n+ } else {\n+ vertex = false;\n }\n- container.components.push(\n- new OpenLayers.Geometry.Polygon(obj.inner)\n- );\n- },\n- \"LinearRing\": function(node, obj) {\n- var container = {};\n- this.readers.gml._inherit.apply(this, [node, container]);\n- this.readChildNodes(node, container);\n- obj.components = [new OpenLayers.Geometry.LinearRing(\n- container.points\n- )];\n- },\n- \"MultiPolygon\": function(node, container) {\n- var obj = {\n- components: []\n- };\n- this.readers.gml._inherit.apply(this, [node, obj, container]);\n- this.readChildNodes(node, obj);\n- container.components = [\n- new OpenLayers.Geometry.MultiPolygon(obj.components)\n- ];\n- },\n- \"polygonMember\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"GeometryCollection\": function(node, container) {\n- var obj = {\n- components: []\n- };\n- this.readers.gml._inherit.apply(this, [node, obj, container]);\n- this.readChildNodes(node, obj);\n- container.components = [\n- new OpenLayers.Geometry.Collection(obj.components)\n- ];\n- },\n- \"geometryMember\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- }\n- },\n- \"feature\": {\n- \"*\": function(node, obj) {\n- // The node can either be named like the featureType, or it\n- // can be a child of the feature:featureType. Children can be\n- // geometry or attributes.\n- var name;\n- var local = node.localName || node.nodeName.split(\":\").pop();\n- // Since an attribute can have the same name as the feature type\n- // we only want to read the node as a feature if the parent\n- // node can have feature nodes as children. In this case, the\n- // obj.features property is set.\n- if (obj.features) {\n- if (!this.singleFeatureType &&\n- (OpenLayers.Util.indexOf(this.featureType, local) !== -1)) {\n- name = \"_typeName\";\n- } else if (local === this.featureType) {\n- name = \"_typeName\";\n+ if (vertex || edge) {\n+ // push intersections different than the previous\n+ if (!point.equals(intersections[intersections.length - 1])) {\n+ intersections.push(point.clone());\n }\n- } else {\n- // Assume attribute elements have one child node and that the child\n- // is a text node. Otherwise assume it is a geometry node.\n- if (node.childNodes.length == 0 ||\n- (node.childNodes.length == 1 && node.firstChild.nodeType == 3)) {\n- if (this.extractAttributes) {\n- name = \"_attribute\";\n+ if (i === 0) {\n+ if (point.equals(vert1)) {\n+ continue;\n }\n- } else {\n- name = \"_geometry\";\n }\n+ if (point.equals(vert2)) {\n+ continue;\n+ }\n+ split = true;\n+ if (!point.equals(vert1)) {\n+ points.push(point);\n+ }\n+ lines.push(new OpenLayers.Geometry.LineString(points));\n+ points = [point.clone()];\n }\n- if (name) {\n- this.readers.feature[name].apply(this, [node, obj]);\n- }\n- },\n- \"_typeName\": function(node, obj) {\n- var container = {\n- components: [],\n- attributes: {}\n- };\n- this.readChildNodes(node, container);\n- // look for common gml namespaced elements\n- if (container.name) {\n- container.attributes.name = container.name;\n- }\n- var feature = new OpenLayers.Feature.Vector(\n- container.components[0], container.attributes\n- );\n- if (!this.singleFeatureType) {\n- feature.type = node.nodeName.split(\":\").pop();\n- feature.namespace = node.namespaceURI;\n- }\n- var fid = node.getAttribute(\"fid\") ||\n- this.getAttributeNS(node, this.namespaces[\"gml\"], \"id\");\n- if (fid) {\n- feature.fid = fid;\n- }\n- if (this.internalProjection && this.externalProjection &&\n- feature.geometry) {\n- feature.geometry.transform(\n- this.externalProjection, this.internalProjection\n- );\n- }\n- if (container.bounds) {\n- feature.bounds = container.bounds;\n- }\n- obj.features.push(feature);\n- },\n- \"_geometry\": function(node, obj) {\n- if (!this.geometryName) {\n- this.geometryName = node.nodeName.split(\":\").pop();\n- }\n- this.readChildNodes(node, obj);\n- },\n- \"_attribute\": function(node, obj) {\n- var local = node.localName || node.nodeName.split(\":\").pop();\n- var value = this.getChildValue(node);\n- obj.attributes[local] = value;\n- }\n- },\n- \"wfs\": {\n- \"FeatureCollection\": function(node, obj) {\n- this.readChildNodes(node, obj);\n }\n }\n+ if (split) {\n+ points.push(vert2.clone());\n+ lines.push(new OpenLayers.Geometry.LineString(points));\n+ }\n+ if (intersections.length > 0) {\n+ // sort intersections along segment\n+ var xDir = seg.x1 < seg.x2 ? 1 : -1;\n+ var yDir = seg.y1 < seg.y2 ? 1 : -1;\n+ result = {\n+ lines: lines,\n+ points: intersections.sort(function(p1, p2) {\n+ return (xDir * p1.x - xDir * p2.x) || (yDir * p1.y - yDir * p2.y);\n+ })\n+ };\n+ }\n+ return result;\n },\n \n /**\n- * Method: write\n- *\n+ * Method: split\n+ * Use this geometry (the source) to attempt to split a target geometry.\n+ * \n * Parameters:\n- * features - {Array() | OpenLayers.Feature.Vector}\n- * An array of features or a single feature.\n+ * target - {} The target geometry.\n+ * options - {Object} Properties of this object will be used to determine\n+ * how the split is conducted.\n *\n+ * Valid options:\n+ * mutual - {Boolean} Split the source geometry in addition to the target\n+ * geometry. Default is false.\n+ * edge - {Boolean} Allow splitting when only edges intersect. Default is\n+ * true. If false, a vertex on the source must be within the tolerance\n+ * distance of the intersection to be considered a split.\n+ * tolerance - {Number} If a non-null value is provided, intersections\n+ * within the tolerance distance of an existing vertex on the source\n+ * will be assumed to occur at the vertex.\n+ * \n * Returns:\n- * {String} Given an array of features, a doc with a gml:featureMembers\n- * element will be returned. Given a single feature, a doc with a\n- * gml:featureMember element will be returned.\n- */\n- write: function(features) {\n- var name;\n- if (OpenLayers.Util.isArray(features)) {\n- name = \"featureMembers\";\n- } else {\n- name = \"featureMember\";\n- }\n- var root = this.writeNode(\"gml:\" + name, features);\n- this.setAttributeNS(\n- root, this.namespaces[\"xsi\"],\n- \"xsi:schemaLocation\", this.schemaLocation\n- );\n-\n- return OpenLayers.Format.XML.prototype.write.apply(this, [root]);\n- },\n-\n- /**\n- * Property: writers\n- * As a compliment to the readers property, this structure contains public\n- * writing functions grouped by namespace alias and named like the\n- * node names they produce.\n+ * {Array} A list of geometries (of this same type as the target) that\n+ * result from splitting the target with the source geometry. The\n+ * source and target geometry will remain unmodified. If no split\n+ * results, null will be returned. If mutual is true and a split\n+ * results, return will be an array of two arrays - the first will be\n+ * all geometries that result from splitting the source geometry and\n+ * the second will be all geometries that result from splitting the\n+ * target geometry.\n */\n- writers: {\n- \"gml\": {\n- \"featureMember\": function(feature) {\n- var node = this.createElementNSPlus(\"gml:featureMember\");\n- this.writeNode(\"feature:_typeName\", feature, node);\n- return node;\n- },\n- \"MultiPoint\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:MultiPoint\");\n- var components = geometry.components || [geometry];\n- for (var i = 0, ii = components.length; i < ii; ++i) {\n- this.writeNode(\"pointMember\", components[i], node);\n- }\n- return node;\n- },\n- \"pointMember\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:pointMember\");\n- this.writeNode(\"Point\", geometry, node);\n- return node;\n- },\n- \"MultiLineString\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:MultiLineString\");\n- var components = geometry.components || [geometry];\n- for (var i = 0, ii = components.length; i < ii; ++i) {\n- this.writeNode(\"lineStringMember\", components[i], node);\n- }\n- return node;\n- },\n- \"lineStringMember\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:lineStringMember\");\n- this.writeNode(\"LineString\", geometry, node);\n- return node;\n- },\n- \"MultiPolygon\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:MultiPolygon\");\n- var components = geometry.components || [geometry];\n- for (var i = 0, ii = components.length; i < ii; ++i) {\n- this.writeNode(\n- \"polygonMember\", components[i], node\n- );\n- }\n- return node;\n- },\n- \"polygonMember\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:polygonMember\");\n- this.writeNode(\"Polygon\", geometry, node);\n- return node;\n- },\n- \"GeometryCollection\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:GeometryCollection\");\n- for (var i = 0, len = geometry.components.length; i < len; ++i) {\n- this.writeNode(\"geometryMember\", geometry.components[i], node);\n- }\n- return node;\n- },\n- \"geometryMember\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:geometryMember\");\n- var child = this.writeNode(\"feature:_geometry\", geometry);\n- node.appendChild(child.firstChild);\n- return node;\n- }\n- },\n- \"feature\": {\n- \"_typeName\": function(feature) {\n- var node = this.createElementNSPlus(\"feature:\" + this.featureType, {\n- attributes: {\n- fid: feature.fid\n- }\n- });\n- if (feature.geometry) {\n- this.writeNode(\"feature:_geometry\", feature.geometry, node);\n+ split: function(target, options) {\n+ var results = null;\n+ var mutual = options && options.mutual;\n+ var sourceSplit, targetSplit, sourceParts, targetParts;\n+ if (target instanceof OpenLayers.Geometry.LineString) {\n+ var verts = this.getVertices();\n+ var vert1, vert2, seg, splits, lines, point;\n+ var points = [];\n+ sourceParts = [];\n+ for (var i = 0, stop = verts.length - 2; i <= stop; ++i) {\n+ vert1 = verts[i];\n+ vert2 = verts[i + 1];\n+ seg = {\n+ x1: vert1.x,\n+ y1: vert1.y,\n+ x2: vert2.x,\n+ y2: vert2.y\n+ };\n+ targetParts = targetParts || [target];\n+ if (mutual) {\n+ points.push(vert1.clone());\n }\n- for (var name in feature.attributes) {\n- var value = feature.attributes[name];\n- if (value != null) {\n- this.writeNode(\n- \"feature:_attribute\", {\n- name: name,\n- value: value\n- }, node\n- );\n+ for (var j = 0; j < targetParts.length; ++j) {\n+ splits = targetParts[j].splitWithSegment(seg, options);\n+ if (splits) {\n+ // splice in new features\n+ lines = splits.lines;\n+ if (lines.length > 0) {\n+ lines.unshift(j, 1);\n+ Array.prototype.splice.apply(targetParts, lines);\n+ j += lines.length - 2;\n+ }\n+ if (mutual) {\n+ for (var k = 0, len = splits.points.length; k < len; ++k) {\n+ point = splits.points[k];\n+ if (!point.equals(vert1)) {\n+ points.push(point);\n+ sourceParts.push(new OpenLayers.Geometry.LineString(points));\n+ if (point.equals(vert2)) {\n+ points = [];\n+ } else {\n+ points = [point.clone()];\n+ }\n+ }\n+ }\n+ }\n }\n }\n- return node;\n- },\n- \"_geometry\": function(geometry) {\n- if (this.externalProjection && this.internalProjection) {\n- geometry = geometry.clone().transform(\n- this.internalProjection, this.externalProjection\n- );\n- }\n- var node = this.createElementNSPlus(\n- \"feature:\" + this.geometryName\n- );\n- var type = this.geometryTypes[geometry.CLASS_NAME];\n- var child = this.writeNode(\"gml:\" + type, geometry, node);\n- if (this.srsName) {\n- child.setAttribute(\"srsName\", this.srsName);\n- }\n- return node;\n- },\n- \"_attribute\": function(obj) {\n- return this.createElementNSPlus(\"feature:\" + obj.name, {\n- value: obj.value\n- });\n }\n- },\n- \"wfs\": {\n- \"FeatureCollection\": function(features) {\n- /**\n- * This is only here because GML2 only describes abstract\n- * feature collections. Typically, you would not be using\n- * the GML format to write wfs elements. This just provides\n- * some way to write out lists of features. GML3 defines the\n- * featureMembers element, so that is used by default instead.\n- */\n- var node = this.createElementNSPlus(\"wfs:FeatureCollection\");\n- for (var i = 0, len = features.length; i < len; ++i) {\n- this.writeNode(\"gml:featureMember\", features[i], node);\n- }\n- return node;\n+ if (mutual && sourceParts.length > 0 && points.length > 0) {\n+ points.push(vert2.clone());\n+ sourceParts.push(new OpenLayers.Geometry.LineString(points));\n }\n+ } else {\n+ results = target.splitWith(this, options);\n }\n+ if (targetParts && targetParts.length > 1) {\n+ targetSplit = true;\n+ } else {\n+ targetParts = [];\n+ }\n+ if (sourceParts && sourceParts.length > 1) {\n+ sourceSplit = true;\n+ } else {\n+ sourceParts = [];\n+ }\n+ if (targetSplit || sourceSplit) {\n+ if (mutual) {\n+ results = [sourceParts, targetParts];\n+ } else {\n+ results = targetParts;\n+ }\n+ }\n+ return results;\n },\n \n /**\n- * Method: setGeometryTypes\n- * Sets the mapping.\n- */\n- setGeometryTypes: function() {\n- this.geometryTypes = {\n- \"OpenLayers.Geometry.Point\": \"Point\",\n- \"OpenLayers.Geometry.MultiPoint\": \"MultiPoint\",\n- \"OpenLayers.Geometry.LineString\": \"LineString\",\n- \"OpenLayers.Geometry.MultiLineString\": \"MultiLineString\",\n- \"OpenLayers.Geometry.Polygon\": \"Polygon\",\n- \"OpenLayers.Geometry.MultiPolygon\": \"MultiPolygon\",\n- \"OpenLayers.Geometry.Collection\": \"GeometryCollection\"\n- };\n- },\n-\n- CLASS_NAME: \"OpenLayers.Format.GML.Base\"\n-\n-});\n-/* ======================================================================\n- OpenLayers/Format/GML/v3.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Format/GML/Base.js\n- */\n-\n-/**\n- * Class: OpenLayers.Format.GML.v3\n- * Parses GML version 3.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Format.GML.v3 = OpenLayers.Class(OpenLayers.Format.GML.Base, {\n-\n- /**\n- * Property: schemaLocation\n- * {String} Schema location for a particular minor version. The writers\n- * conform with the Simple Features Profile for GML.\n- */\n- schemaLocation: \"http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/1.0.0/gmlsf.xsd\",\n-\n- /**\n- * Property: curve\n- * {Boolean} Write gml:Curve instead of gml:LineString elements. This also\n- * affects the elements in multi-part geometries. Default is false.\n- * To write gml:Curve elements instead of gml:LineString, set curve\n- * to true in the options to the contstructor (cannot be changed after\n- * instantiation).\n- */\n- curve: false,\n-\n- /**\n- * Property: multiCurve\n- * {Boolean} Write gml:MultiCurve instead of gml:MultiLineString. Since\n- * the latter is deprecated in GML 3, the default is true. To write\n- * gml:MultiLineString instead of gml:MultiCurve, set multiCurve to\n- * false in the options to the constructor (cannot be changed after\n- * instantiation).\n- */\n- multiCurve: true,\n-\n- /**\n- * Property: surface\n- * {Boolean} Write gml:Surface instead of gml:Polygon elements. This also\n- * affects the elements in multi-part geometries. Default is false.\n- * To write gml:Surface elements instead of gml:Polygon, set surface\n- * to true in the options to the contstructor (cannot be changed after\n- * instantiation).\n+ * Method: splitWith\n+ * Split this geometry (the target) with the given geometry (the source).\n+ *\n+ * Parameters:\n+ * geometry - {} A geometry used to split this\n+ * geometry (the source).\n+ * options - {Object} Properties of this object will be used to determine\n+ * how the split is conducted.\n+ *\n+ * Valid options:\n+ * mutual - {Boolean} Split the source geometry in addition to the target\n+ * geometry. Default is false.\n+ * edge - {Boolean} Allow splitting when only edges intersect. Default is\n+ * true. If false, a vertex on the source must be within the tolerance\n+ * distance of the intersection to be considered a split.\n+ * tolerance - {Number} If a non-null value is provided, intersections\n+ * within the tolerance distance of an existing vertex on the source\n+ * will be assumed to occur at the vertex.\n+ * \n+ * Returns:\n+ * {Array} A list of geometries (of this same type as the target) that\n+ * result from splitting the target with the source geometry. The\n+ * source and target geometry will remain unmodified. If no split\n+ * results, null will be returned. If mutual is true and a split\n+ * results, return will be an array of two arrays - the first will be\n+ * all geometries that result from splitting the source geometry and\n+ * the second will be all geometries that result from splitting the\n+ * target geometry.\n */\n- surface: false,\n+ splitWith: function(geometry, options) {\n+ return geometry.split(this, options);\n \n- /**\n- * Property: multiSurface\n- * {Boolean} Write gml:multiSurface instead of gml:MultiPolygon. Since\n- * the latter is deprecated in GML 3, the default is true. To write\n- * gml:MultiPolygon instead of gml:multiSurface, set multiSurface to\n- * false in the options to the constructor (cannot be changed after\n- * instantiation).\n- */\n- multiSurface: true,\n+ },\n \n /**\n- * Constructor: OpenLayers.Format.GML.v3\n- * Create a parser for GML v3.\n+ * APIMethod: getVertices\n+ * Return a list of all points in this geometry.\n *\n * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ * nodes - {Boolean} For lines, only return vertices that are\n+ * endpoints. If false, for lines, only vertices that are not\n+ * endpoints will be returned. If not provided, all vertices will\n+ * be returned.\n *\n- * Valid options properties:\n- * featureType - {String} Local (without prefix) feature typeName (required).\n- * featureNS - {String} Feature namespace (required).\n- * geometryName - {String} Geometry element name.\n+ * Returns:\n+ * {Array} A list of all vertices in the geometry.\n */\n- initialize: function(options) {\n- OpenLayers.Format.GML.Base.prototype.initialize.apply(this, [options]);\n+ getVertices: function(nodes) {\n+ var vertices;\n+ if (nodes === true) {\n+ vertices = [\n+ this.components[0],\n+ this.components[this.components.length - 1]\n+ ];\n+ } else if (nodes === false) {\n+ vertices = this.components.slice(1, this.components.length - 1);\n+ } else {\n+ vertices = this.components.slice();\n+ }\n+ return vertices;\n },\n \n /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n+ * APIMethod: distanceTo\n+ * Calculate the closest distance between two geometries (on the x-y plane).\n+ *\n+ * Parameters:\n+ * geometry - {} The target geometry.\n+ * options - {Object} Optional properties for configuring the distance\n+ * calculation.\n+ *\n+ * Valid options:\n+ * details - {Boolean} Return details from the distance calculation.\n+ * Default is false.\n+ * edge - {Boolean} Calculate the distance from this geometry to the\n+ * nearest edge of the target geometry. Default is true. If true,\n+ * calling distanceTo from a geometry that is wholly contained within\n+ * the target will result in a non-zero distance. If false, whenever\n+ * geometries intersect, calling distanceTo will return 0. If false,\n+ * details cannot be returned.\n+ *\n+ * Returns:\n+ * {Number | Object} The distance between this geometry and the target.\n+ * If details is true, the return will be an object with distance,\n+ * x0, y0, x1, and x2 properties. The x0 and y0 properties represent\n+ * the coordinates of the closest point on this geometry. The x1 and y1\n+ * properties represent the coordinates of the closest point on the\n+ * target geometry.\n */\n- readers: {\n- \"gml\": OpenLayers.Util.applyDefaults({\n- \"_inherit\": function(node, obj, container) {\n- // SRSReferenceGroup attributes\n- var dim = parseInt(node.getAttribute(\"srsDimension\"), 10) ||\n- (container && container.srsDimension);\n- if (dim) {\n- obj.srsDimension = dim;\n- }\n- },\n- \"featureMembers\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"Curve\": function(node, container) {\n- var obj = {\n- points: []\n- };\n- this.readers.gml._inherit.apply(this, [node, obj, container]);\n- this.readChildNodes(node, obj);\n- if (!container.components) {\n- container.components = [];\n- }\n- container.components.push(\n- new OpenLayers.Geometry.LineString(obj.points)\n- );\n- },\n- \"segments\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"LineStringSegment\": function(node, container) {\n- var obj = {};\n- this.readChildNodes(node, obj);\n- if (obj.points) {\n- Array.prototype.push.apply(container.points, obj.points);\n- }\n- },\n- \"pos\": function(node, obj) {\n- var str = this.getChildValue(node).replace(\n- this.regExes.trimSpace, \"\"\n- );\n- var coords = str.split(this.regExes.splitSpace);\n- var point;\n- if (this.xy) {\n- point = new OpenLayers.Geometry.Point(\n- coords[0], coords[1], coords[2]\n- );\n+ distanceTo: function(geometry, options) {\n+ var edge = !(options && options.edge === false);\n+ var details = edge && options && options.details;\n+ var result, best = {};\n+ var min = Number.POSITIVE_INFINITY;\n+ if (geometry instanceof OpenLayers.Geometry.Point) {\n+ var segs = this.getSortedSegments();\n+ var x = geometry.x;\n+ var y = geometry.y;\n+ var seg;\n+ for (var i = 0, len = segs.length; i < len; ++i) {\n+ seg = segs[i];\n+ result = OpenLayers.Geometry.distanceToSegment(geometry, seg);\n+ if (result.distance < min) {\n+ min = result.distance;\n+ best = result;\n+ if (min === 0) {\n+ break;\n+ }\n } else {\n- point = new OpenLayers.Geometry.Point(\n- coords[1], coords[0], coords[2]\n- );\n- }\n- obj.points = [point];\n- },\n- \"posList\": function(node, obj) {\n- var str = this.getChildValue(node).replace(\n- this.regExes.trimSpace, \"\"\n- );\n- var coords = str.split(this.regExes.splitSpace);\n- // The \"dimension\" attribute is from the GML 3.0.1 spec.\n- var dim = obj.srsDimension ||\n- parseInt(node.getAttribute(\"srsDimension\") || node.getAttribute(\"dimension\"), 10) || 2;\n- var j, x, y, z;\n- var numPoints = coords.length / dim;\n- var points = new Array(numPoints);\n- for (var i = 0, len = coords.length; i < len; i += dim) {\n- x = coords[i];\n- y = coords[i + 1];\n- z = (dim == 2) ? undefined : coords[i + 2];\n- if (this.xy) {\n- points[i / dim] = new OpenLayers.Geometry.Point(x, y, z);\n- } else {\n- points[i / dim] = new OpenLayers.Geometry.Point(y, x, z);\n+ // if distance increases and we cross y0 to the right of x0, no need to keep looking.\n+ if (seg.x2 > x && ((y > seg.y1 && y < seg.y2) || (y < seg.y1 && y > seg.y2))) {\n+ break;\n }\n }\n- obj.points = points;\n- },\n- \"Surface\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"patches\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"PolygonPatch\": function(node, obj) {\n- this.readers.gml.Polygon.apply(this, [node, obj]);\n- },\n- \"exterior\": function(node, container) {\n- var obj = {};\n- this.readChildNodes(node, obj);\n- container.outer = obj.components[0];\n- },\n- \"interior\": function(node, container) {\n- var obj = {};\n- this.readChildNodes(node, obj);\n- container.inner.push(obj.components[0]);\n- },\n- \"MultiCurve\": function(node, container) {\n- var obj = {\n- components: []\n+ }\n+ if (details) {\n+ best = {\n+ distance: best.distance,\n+ x0: best.x,\n+ y0: best.y,\n+ x1: x,\n+ y1: y\n };\n- this.readers.gml._inherit.apply(this, [node, obj, container]);\n- this.readChildNodes(node, obj);\n- if (obj.components.length > 0) {\n- container.components = [\n- new OpenLayers.Geometry.MultiLineString(obj.components)\n- ];\n+ } else {\n+ best = best.distance;\n+ }\n+ } else if (geometry instanceof OpenLayers.Geometry.LineString) {\n+ var segs0 = this.getSortedSegments();\n+ var segs1 = geometry.getSortedSegments();\n+ var seg0, seg1, intersection, x0, y0;\n+ var len1 = segs1.length;\n+ var interOptions = {\n+ point: true\n+ };\n+ outer: for (var i = 0, len = segs0.length; i < len; ++i) {\n+ seg0 = segs0[i];\n+ x0 = seg0.x1;\n+ y0 = seg0.y1;\n+ for (var j = 0; j < len1; ++j) {\n+ seg1 = segs1[j];\n+ intersection = OpenLayers.Geometry.segmentsIntersect(seg0, seg1, interOptions);\n+ if (intersection) {\n+ min = 0;\n+ best = {\n+ distance: 0,\n+ x0: intersection.x,\n+ y0: intersection.y,\n+ x1: intersection.x,\n+ y1: intersection.y\n+ };\n+ break outer;\n+ } else {\n+ result = OpenLayers.Geometry.distanceToSegment({\n+ x: x0,\n+ y: y0\n+ }, seg1);\n+ if (result.distance < min) {\n+ min = result.distance;\n+ best = {\n+ distance: min,\n+ x0: x0,\n+ y0: y0,\n+ x1: result.x,\n+ y1: result.y\n+ };\n+ }\n+ }\n }\n- },\n- \"curveMember\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"MultiSurface\": function(node, container) {\n- var obj = {\n- components: []\n- };\n- this.readers.gml._inherit.apply(this, [node, obj, container]);\n- this.readChildNodes(node, obj);\n- if (obj.components.length > 0) {\n- container.components = [\n- new OpenLayers.Geometry.MultiPolygon(obj.components)\n- ];\n+ }\n+ if (!details) {\n+ best = best.distance;\n+ }\n+ if (min !== 0) {\n+ // check the final vertex in this line's sorted segments\n+ if (seg0) {\n+ result = geometry.distanceTo(\n+ new OpenLayers.Geometry.Point(seg0.x2, seg0.y2),\n+ options\n+ );\n+ var dist = details ? result.distance : result;\n+ if (dist < min) {\n+ if (details) {\n+ best = {\n+ distance: min,\n+ x0: result.x1,\n+ y0: result.y1,\n+ x1: result.x0,\n+ y1: result.y0\n+ };\n+ } else {\n+ best = dist;\n+ }\n+ }\n }\n- },\n- \"surfaceMember\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"surfaceMembers\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"pointMembers\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"lineStringMembers\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"polygonMembers\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"geometryMembers\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"Envelope\": function(node, container) {\n- var obj = {\n- points: new Array(2)\n+ }\n+ } else {\n+ best = geometry.distanceTo(this, options);\n+ // swap since target comes from this line\n+ if (details) {\n+ best = {\n+ distance: best.distance,\n+ x0: best.x1,\n+ y0: best.y1,\n+ x1: best.x0,\n+ y1: best.y0\n };\n- this.readChildNodes(node, obj);\n- if (!container.components) {\n- container.components = [];\n- }\n- var min = obj.points[0];\n- var max = obj.points[1];\n- container.components.push(\n- new OpenLayers.Bounds(min.x, min.y, max.x, max.y)\n- );\n- },\n- \"lowerCorner\": function(node, container) {\n- var obj = {};\n- this.readers.gml.pos.apply(this, [node, obj]);\n- container.points[0] = obj.points[0];\n- },\n- \"upperCorner\": function(node, container) {\n- var obj = {};\n- this.readers.gml.pos.apply(this, [node, obj]);\n- container.points[1] = obj.points[0];\n }\n- }, OpenLayers.Format.GML.Base.prototype.readers[\"gml\"]),\n- \"feature\": OpenLayers.Format.GML.Base.prototype.readers[\"feature\"],\n- \"wfs\": OpenLayers.Format.GML.Base.prototype.readers[\"wfs\"]\n+ }\n+ return best;\n },\n \n /**\n- * Method: write\n+ * APIMethod: simplify\n+ * This function will return a simplified LineString.\n+ * Simplification is based on the Douglas-Peucker algorithm.\n+ *\n *\n * Parameters:\n- * features - {Array() | OpenLayers.Feature.Vector}\n- * An array of features or a single feature.\n+ * tolerance - {number} threshhold for simplification in map units\n *\n * Returns:\n- * {String} Given an array of features, a doc with a gml:featureMembers\n- * element will be returned. Given a single feature, a doc with a\n- * gml:featureMember element will be returned.\n+ * {OpenLayers.Geometry.LineString} the simplified LineString\n */\n- write: function(features) {\n- var name;\n- if (OpenLayers.Util.isArray(features)) {\n- name = \"featureMembers\";\n- } else {\n- name = \"featureMember\";\n- }\n- var root = this.writeNode(\"gml:\" + name, features);\n- this.setAttributeNS(\n- root, this.namespaces[\"xsi\"],\n- \"xsi:schemaLocation\", this.schemaLocation\n- );\n+ simplify: function(tolerance) {\n+ if (this && this !== null) {\n+ var points = this.getVertices();\n+ if (points.length < 3) {\n+ return this;\n+ }\n \n- return OpenLayers.Format.XML.prototype.write.apply(this, [root]);\n- },\n+ var compareNumbers = function(a, b) {\n+ return (a - b);\n+ };\n \n- /**\n- * Property: writers\n- * As a compliment to the readers property, this structure contains public\n- * writing functions grouped by namespace alias and named like the\n- * node names they produce.\n- */\n- writers: {\n- \"gml\": OpenLayers.Util.applyDefaults({\n- \"featureMembers\": function(features) {\n- var node = this.createElementNSPlus(\"gml:featureMembers\");\n- for (var i = 0, len = features.length; i < len; ++i) {\n- this.writeNode(\"feature:_typeName\", features[i], node);\n- }\n- return node;\n- },\n- \"Point\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:Point\");\n- this.writeNode(\"pos\", geometry, node);\n- return node;\n- },\n- \"pos\": function(point) {\n- // only 2d for simple features profile\n- var pos = (this.xy) ?\n- (point.x + \" \" + point.y) : (point.y + \" \" + point.x);\n- return this.createElementNSPlus(\"gml:pos\", {\n- value: pos\n- });\n- },\n- \"LineString\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:LineString\");\n- this.writeNode(\"posList\", geometry.components, node);\n- return node;\n- },\n- \"Curve\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:Curve\");\n- this.writeNode(\"segments\", geometry, node);\n- return node;\n- },\n- \"segments\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:segments\");\n- this.writeNode(\"LineStringSegment\", geometry, node);\n- return node;\n- },\n- \"LineStringSegment\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:LineStringSegment\");\n- this.writeNode(\"posList\", geometry.components, node);\n- return node;\n- },\n- \"posList\": function(points) {\n- // only 2d for simple features profile\n- var len = points.length;\n- var parts = new Array(len);\n- var point;\n- for (var i = 0; i < len; ++i) {\n- point = points[i];\n- if (this.xy) {\n- parts[i] = point.x + \" \" + point.y;\n- } else {\n- parts[i] = point.y + \" \" + point.x;\n- }\n- }\n- return this.createElementNSPlus(\"gml:posList\", {\n- value: parts.join(\" \")\n- });\n- },\n- \"Surface\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:Surface\");\n- this.writeNode(\"patches\", geometry, node);\n- return node;\n- },\n- \"patches\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:patches\");\n- this.writeNode(\"PolygonPatch\", geometry, node);\n- return node;\n- },\n- \"PolygonPatch\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:PolygonPatch\", {\n- attributes: {\n- interpolation: \"planar\"\n+ /**\n+ * Private function doing the Douglas-Peucker reduction\n+ */\n+ var douglasPeuckerReduction = function(points, firstPoint, lastPoint, tolerance) {\n+ var maxDistance = 0;\n+ var indexFarthest = 0;\n+\n+ for (var index = firstPoint, distance; index < lastPoint; index++) {\n+ distance = perpendicularDistance(points[firstPoint], points[lastPoint], points[index]);\n+ if (distance > maxDistance) {\n+ maxDistance = distance;\n+ indexFarthest = index;\n }\n- });\n- this.writeNode(\"exterior\", geometry.components[0], node);\n- for (var i = 1, len = geometry.components.length; i < len; ++i) {\n- this.writeNode(\n- \"interior\", geometry.components[i], node\n- );\n- }\n- return node;\n- },\n- \"Polygon\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:Polygon\");\n- this.writeNode(\"exterior\", geometry.components[0], node);\n- for (var i = 1, len = geometry.components.length; i < len; ++i) {\n- this.writeNode(\n- \"interior\", geometry.components[i], node\n- );\n- }\n- return node;\n- },\n- \"exterior\": function(ring) {\n- var node = this.createElementNSPlus(\"gml:exterior\");\n- this.writeNode(\"LinearRing\", ring, node);\n- return node;\n- },\n- \"interior\": function(ring) {\n- var node = this.createElementNSPlus(\"gml:interior\");\n- this.writeNode(\"LinearRing\", ring, node);\n- return node;\n- },\n- \"LinearRing\": function(ring) {\n- var node = this.createElementNSPlus(\"gml:LinearRing\");\n- this.writeNode(\"posList\", ring.components, node);\n- return node;\n- },\n- \"MultiCurve\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:MultiCurve\");\n- var components = geometry.components || [geometry];\n- for (var i = 0, len = components.length; i < len; ++i) {\n- this.writeNode(\"curveMember\", components[i], node);\n- }\n- return node;\n- },\n- \"curveMember\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:curveMember\");\n- if (this.curve) {\n- this.writeNode(\"Curve\", geometry, node);\n- } else {\n- this.writeNode(\"LineString\", geometry, node);\n- }\n- return node;\n- },\n- \"MultiSurface\": function(geometry) {\n- var node = this.createElementNSPlus(\"gml:MultiSurface\");\n- var components = geometry.components || [geometry];\n- for (var i = 0, len = components.length; i < len; ++i) {\n- this.writeNode(\"surfaceMember\", components[i], node);\n- }\n- return node;\n- },\n- \"surfaceMember\": function(polygon) {\n- var node = this.createElementNSPlus(\"gml:surfaceMember\");\n- if (this.surface) {\n- this.writeNode(\"Surface\", polygon, node);\n- } else {\n- this.writeNode(\"Polygon\", polygon, node);\n }\n- return node;\n- },\n- \"Envelope\": function(bounds) {\n- var node = this.createElementNSPlus(\"gml:Envelope\");\n- this.writeNode(\"lowerCorner\", bounds, node);\n- this.writeNode(\"upperCorner\", bounds, node);\n- // srsName attribute is required for gml:Envelope\n- if (this.srsName) {\n- node.setAttribute(\"srsName\", this.srsName);\n+\n+ if (maxDistance > tolerance && indexFarthest != firstPoint) {\n+ //Add the largest point that exceeds the tolerance\n+ pointIndexsToKeep.push(indexFarthest);\n+ douglasPeuckerReduction(points, firstPoint, indexFarthest, tolerance);\n+ douglasPeuckerReduction(points, indexFarthest, lastPoint, tolerance);\n }\n- return node;\n- },\n- \"lowerCorner\": function(bounds) {\n- // only 2d for simple features profile\n- var pos = (this.xy) ?\n- (bounds.left + \" \" + bounds.bottom) :\n- (bounds.bottom + \" \" + bounds.left);\n- return this.createElementNSPlus(\"gml:lowerCorner\", {\n- value: pos\n- });\n- },\n- \"upperCorner\": function(bounds) {\n- // only 2d for simple features profile\n- var pos = (this.xy) ?\n- (bounds.right + \" \" + bounds.top) :\n- (bounds.top + \" \" + bounds.right);\n- return this.createElementNSPlus(\"gml:upperCorner\", {\n- value: pos\n- });\n+ };\n+\n+ /**\n+ * Private function calculating the perpendicular distance\n+ * TODO: check whether OpenLayers.Geometry.LineString::distanceTo() is faster or slower\n+ */\n+ var perpendicularDistance = function(point1, point2, point) {\n+ //Area = |(1/2)(x1y2 + x2y3 + x3y1 - x2y1 - x3y2 - x1y3)| *Area of triangle\n+ //Base = v((x1-x2)\u00b2+(x1-x2)\u00b2) *Base of Triangle*\n+ //Area = .5*Base*H *Solve for height\n+ //Height = Area/.5/Base\n+\n+ var area = Math.abs(0.5 * (point1.x * point2.y + point2.x * point.y + point.x * point1.y - point2.x * point1.y - point.x * point2.y - point1.x * point.y));\n+ var bottom = Math.sqrt(Math.pow(point1.x - point2.x, 2) + Math.pow(point1.y - point2.y, 2));\n+ var height = area / bottom * 2;\n+\n+ return height;\n+ };\n+\n+ var firstPoint = 0;\n+ var lastPoint = points.length - 1;\n+ var pointIndexsToKeep = [];\n+\n+ //Add the first and last index to the keepers\n+ pointIndexsToKeep.push(firstPoint);\n+ pointIndexsToKeep.push(lastPoint);\n+\n+ //The first and the last point cannot be the same\n+ while (points[firstPoint].equals(points[lastPoint])) {\n+ lastPoint--;\n+ //Addition: the first point not equal to first point in the LineString is kept as well\n+ pointIndexsToKeep.push(lastPoint);\n }\n- }, OpenLayers.Format.GML.Base.prototype.writers[\"gml\"]),\n- \"feature\": OpenLayers.Format.GML.Base.prototype.writers[\"feature\"],\n- \"wfs\": OpenLayers.Format.GML.Base.prototype.writers[\"wfs\"]\n- },\n \n- /**\n- * Method: setGeometryTypes\n- * Sets the mapping.\n- */\n- setGeometryTypes: function() {\n- this.geometryTypes = {\n- \"OpenLayers.Geometry.Point\": \"Point\",\n- \"OpenLayers.Geometry.MultiPoint\": \"MultiPoint\",\n- \"OpenLayers.Geometry.LineString\": (this.curve === true) ? \"Curve\" : \"LineString\",\n- \"OpenLayers.Geometry.MultiLineString\": (this.multiCurve === false) ? \"MultiLineString\" : \"MultiCurve\",\n- \"OpenLayers.Geometry.Polygon\": (this.surface === true) ? \"Surface\" : \"Polygon\",\n- \"OpenLayers.Geometry.MultiPolygon\": (this.multiSurface === false) ? \"MultiPolygon\" : \"MultiSurface\",\n- \"OpenLayers.Geometry.Collection\": \"GeometryCollection\"\n- };\n- },\n+ douglasPeuckerReduction(points, firstPoint, lastPoint, tolerance);\n+ var returnPoints = [];\n+ pointIndexsToKeep.sort(compareNumbers);\n+ for (var index = 0; index < pointIndexsToKeep.length; index++) {\n+ returnPoints.push(points[pointIndexsToKeep[index]]);\n+ }\n+ return new OpenLayers.Geometry.LineString(returnPoints);\n \n- CLASS_NAME: \"OpenLayers.Format.GML.v3\"\n+ } else {\n+ return this;\n+ }\n+ },\n \n+ CLASS_NAME: \"OpenLayers.Geometry.LineString\"\n });\n /* ======================================================================\n- OpenLayers/Format/Filter/v1_1_0.js\n+ OpenLayers/Geometry/MultiLineString.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format/Filter/v1.js\n- * @requires OpenLayers/Format/GML/v3.js\n+ * @requires OpenLayers/Geometry/Collection.js\n+ * @requires OpenLayers/Geometry/LineString.js\n */\n \n /**\n- * Class: OpenLayers.Format.Filter.v1_1_0\n- * Write ogc:Filter version 1.1.0.\n- *\n- * Differences from the v1.0.0 parser:\n- * - uses GML v3 instead of GML v2\n- * - reads matchCase attribute on ogc:PropertyIsEqual and\n- * ogc:PropertyIsNotEqual elements.\n- * - writes matchCase attribute from comparison filters of type EQUAL_TO,\n- * NOT_EQUAL_TO and LIKE.\n+ * Class: OpenLayers.Geometry.MultiLineString\n+ * A MultiLineString is a geometry with multiple \n+ * components.\n * \n- * Inherits from: \n- * - \n- * - \n+ * Inherits from:\n+ * - \n+ * - \n */\n-OpenLayers.Format.Filter.v1_1_0 = OpenLayers.Class(\n- OpenLayers.Format.GML.v3, OpenLayers.Format.Filter.v1, {\n-\n- /**\n- * Constant: VERSION\n- * {String} 1.1.0\n- */\n- VERSION: \"1.1.0\",\n+OpenLayers.Geometry.MultiLineString = OpenLayers.Class(\n+ OpenLayers.Geometry.Collection, {\n \n /**\n- * Property: schemaLocation\n- * {String} http://www.opengis.net/ogc/filter/1.1.0/filter.xsd\n+ * Property: componentTypes\n+ * {Array(String)} An array of class names representing the types of\n+ * components that the collection can include. A null value means the\n+ * component types are not restricted.\n */\n- schemaLocation: \"http://www.opengis.net/ogc/filter/1.1.0/filter.xsd\",\n+ componentTypes: [\"OpenLayers.Geometry.LineString\"],\n \n /**\n- * Constructor: OpenLayers.Format.Filter.v1_1_0\n- * Instances of this class are not created directly. Use the\n- * constructor instead.\n+ * Constructor: OpenLayers.Geometry.MultiLineString\n+ * Constructor for a MultiLineString Geometry.\n+ *\n+ * Parameters: \n+ * components - {Array()} \n *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n- */\n- initialize: function(options) {\n- OpenLayers.Format.GML.v3.prototype.initialize.apply(\n- this, [options]\n- );\n- },\n-\n- /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n */\n- readers: {\n- \"ogc\": OpenLayers.Util.applyDefaults({\n- \"PropertyIsEqualTo\": function(node, obj) {\n- var matchCase = node.getAttribute(\"matchCase\");\n- var filter = new OpenLayers.Filter.Comparison({\n- type: OpenLayers.Filter.Comparison.EQUAL_TO,\n- matchCase: !(matchCase === \"false\" || matchCase === \"0\")\n- });\n- this.readChildNodes(node, filter);\n- obj.filters.push(filter);\n- },\n- \"PropertyIsNotEqualTo\": function(node, obj) {\n- var matchCase = node.getAttribute(\"matchCase\");\n- var filter = new OpenLayers.Filter.Comparison({\n- type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO,\n- matchCase: !(matchCase === \"false\" || matchCase === \"0\")\n- });\n- this.readChildNodes(node, filter);\n- obj.filters.push(filter);\n- },\n- \"PropertyIsLike\": function(node, obj) {\n- var filter = new OpenLayers.Filter.Comparison({\n- type: OpenLayers.Filter.Comparison.LIKE\n- });\n- this.readChildNodes(node, filter);\n- var wildCard = node.getAttribute(\"wildCard\");\n- var singleChar = node.getAttribute(\"singleChar\");\n- var esc = node.getAttribute(\"escapeChar\");\n- filter.value2regex(wildCard, singleChar, esc);\n- obj.filters.push(filter);\n- }\n- }, OpenLayers.Format.Filter.v1.prototype.readers[\"ogc\"]),\n- \"gml\": OpenLayers.Format.GML.v3.prototype.readers[\"gml\"],\n- \"feature\": OpenLayers.Format.GML.v3.prototype.readers[\"feature\"]\n- },\n \n /**\n- * Property: writers\n- * As a compliment to the readers property, this structure contains public\n- * writing functions grouped by namespace alias and named like the\n- * node names they produce.\n+ * Method: split\n+ * Use this geometry (the source) to attempt to split a target geometry.\n+ * \n+ * Parameters:\n+ * geometry - {} The target geometry.\n+ * options - {Object} Properties of this object will be used to determine\n+ * how the split is conducted.\n+ *\n+ * Valid options:\n+ * mutual - {Boolean} Split the source geometry in addition to the target\n+ * geometry. Default is false.\n+ * edge - {Boolean} Allow splitting when only edges intersect. Default is\n+ * true. If false, a vertex on the source must be within the tolerance\n+ * distance of the intersection to be considered a split.\n+ * tolerance - {Number} If a non-null value is provided, intersections\n+ * within the tolerance distance of an existing vertex on the source\n+ * will be assumed to occur at the vertex.\n+ * \n+ * Returns:\n+ * {Array} A list of geometries (of this same type as the target) that\n+ * result from splitting the target with the source geometry. The\n+ * source and target geometry will remain unmodified. If no split\n+ * results, null will be returned. If mutual is true and a split\n+ * results, return will be an array of two arrays - the first will be\n+ * all geometries that result from splitting the source geometry and\n+ * the second will be all geometries that result from splitting the\n+ * target geometry.\n */\n- writers: {\n- \"ogc\": OpenLayers.Util.applyDefaults({\n- \"PropertyIsEqualTo\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:PropertyIsEqualTo\", {\n- attributes: {\n- matchCase: filter.matchCase\n- }\n- });\n- // no ogc:expression handling for PropertyName for now\n- this.writeNode(\"PropertyName\", filter, node);\n- // handle Literals or Functions for now\n- this.writeOgcExpression(filter.value, node);\n- return node;\n- },\n- \"PropertyIsNotEqualTo\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:PropertyIsNotEqualTo\", {\n- attributes: {\n- matchCase: filter.matchCase\n+ split: function(geometry, options) {\n+ var results = null;\n+ var mutual = options && options.mutual;\n+ var splits, sourceLine, sourceLines, sourceSplit, targetSplit;\n+ var sourceParts = [];\n+ var targetParts = [geometry];\n+ for (var i = 0, len = this.components.length; i < len; ++i) {\n+ sourceLine = this.components[i];\n+ sourceSplit = false;\n+ for (var j = 0; j < targetParts.length; ++j) {\n+ splits = sourceLine.split(targetParts[j], options);\n+ if (splits) {\n+ if (mutual) {\n+ sourceLines = splits[0];\n+ for (var k = 0, klen = sourceLines.length; k < klen; ++k) {\n+ if (k === 0 && sourceParts.length) {\n+ sourceParts[sourceParts.length - 1].addComponent(\n+ sourceLines[k]\n+ );\n+ } else {\n+ sourceParts.push(\n+ new OpenLayers.Geometry.MultiLineString([\n+ sourceLines[k]\n+ ])\n+ );\n+ }\n+ }\n+ sourceSplit = true;\n+ splits = splits[1];\n }\n- });\n- // no ogc:expression handling for PropertyName for now\n- this.writeNode(\"PropertyName\", filter, node);\n- // handle Literals or Functions for now\n- this.writeOgcExpression(filter.value, node);\n- return node;\n- },\n- \"PropertyIsLike\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:PropertyIsLike\", {\n- attributes: {\n- matchCase: filter.matchCase,\n- wildCard: \"*\",\n- singleChar: \".\",\n- escapeChar: \"!\"\n+ if (splits.length) {\n+ // splice in new target parts\n+ splits.unshift(j, 1);\n+ Array.prototype.splice.apply(targetParts, splits);\n+ break;\n }\n- });\n- // no ogc:expression handling for now\n- this.writeNode(\"PropertyName\", filter, node);\n- // convert regex string to ogc string\n- this.writeNode(\"Literal\", filter.regex2value(), node);\n- return node;\n- },\n- \"BBOX\": function(filter) {\n- var node = this.createElementNSPlus(\"ogc:BBOX\");\n- // PropertyName is optional in 1.1.0\n- filter.property && this.writeNode(\"PropertyName\", filter, node);\n- var box = this.writeNode(\"gml:Envelope\", filter.value);\n- if (filter.projection) {\n- box.setAttribute(\"srsName\", filter.projection);\n }\n- node.appendChild(box);\n- return node;\n- },\n- \"SortBy\": function(sortProperties) {\n- var node = this.createElementNSPlus(\"ogc:SortBy\");\n- for (var i = 0, l = sortProperties.length; i < l; i++) {\n- this.writeNode(\n- \"ogc:SortProperty\",\n- sortProperties[i],\n- node\n+ }\n+ if (!sourceSplit) {\n+ // source line was not hit\n+ if (sourceParts.length) {\n+ // add line to existing multi\n+ sourceParts[sourceParts.length - 1].addComponent(\n+ sourceLine.clone()\n );\n+ } else {\n+ // create a fresh multi\n+ sourceParts = [\n+ new OpenLayers.Geometry.MultiLineString(\n+ sourceLine.clone()\n+ )\n+ ];\n }\n- return node;\n- },\n- \"SortProperty\": function(sortProperty) {\n- var node = this.createElementNSPlus(\"ogc:SortProperty\");\n- this.writeNode(\n- \"ogc:PropertyName\",\n- sortProperty,\n- node\n- );\n- this.writeNode(\n- \"ogc:SortOrder\",\n- (sortProperty.order == 'DESC') ? 'DESC' : 'ASC',\n- node\n- );\n- return node;\n- },\n- \"SortOrder\": function(value) {\n- var node = this.createElementNSPlus(\"ogc:SortOrder\", {\n- value: value\n- });\n- return node;\n }\n- }, OpenLayers.Format.Filter.v1.prototype.writers[\"ogc\"]),\n- \"gml\": OpenLayers.Format.GML.v3.prototype.writers[\"gml\"],\n- \"feature\": OpenLayers.Format.GML.v3.prototype.writers[\"feature\"]\n+ }\n+ if (sourceParts && sourceParts.length > 1) {\n+ sourceSplit = true;\n+ } else {\n+ sourceParts = [];\n+ }\n+ if (targetParts && targetParts.length > 1) {\n+ targetSplit = true;\n+ } else {\n+ targetParts = [];\n+ }\n+ if (sourceSplit || targetSplit) {\n+ if (mutual) {\n+ results = [sourceParts, targetParts];\n+ } else {\n+ results = targetParts;\n+ }\n+ }\n+ return results;\n },\n \n /**\n- * Method: writeSpatial\n- *\n- * Read a {} filter and converts it into XML.\n+ * Method: splitWith\n+ * Split this geometry (the target) with the given geometry (the source).\n *\n * Parameters:\n- * filter - {} The filter.\n- * name - {String} Name of the generated XML element.\n+ * geometry - {} A geometry used to split this\n+ * geometry (the source).\n+ * options - {Object} Properties of this object will be used to determine\n+ * how the split is conducted.\n *\n+ * Valid options:\n+ * mutual - {Boolean} Split the source geometry in addition to the target\n+ * geometry. Default is false.\n+ * edge - {Boolean} Allow splitting when only edges intersect. Default is\n+ * true. If false, a vertex on the source must be within the tolerance\n+ * distance of the intersection to be considered a split.\n+ * tolerance - {Number} If a non-null value is provided, intersections\n+ * within the tolerance distance of an existing vertex on the source\n+ * will be assumed to occur at the vertex.\n+ * \n * Returns:\n- * {DOMElement} The created XML element.\n+ * {Array} A list of geometries (of this same type as the target) that\n+ * result from splitting the target with the source geometry. The\n+ * source and target geometry will remain unmodified. If no split\n+ * results, null will be returned. If mutual is true and a split\n+ * results, return will be an array of two arrays - the first will be\n+ * all geometries that result from splitting the source geometry and\n+ * the second will be all geometries that result from splitting the\n+ * target geometry.\n */\n- writeSpatial: function(filter, name) {\n- var node = this.createElementNSPlus(\"ogc:\" + name);\n- this.writeNode(\"PropertyName\", filter, node);\n- if (filter.value instanceof OpenLayers.Filter.Function) {\n- this.writeNode(\"Function\", filter.value, node);\n+ splitWith: function(geometry, options) {\n+ var results = null;\n+ var mutual = options && options.mutual;\n+ var splits, targetLine, sourceLines, sourceSplit, targetSplit, sourceParts, targetParts;\n+ if (geometry instanceof OpenLayers.Geometry.LineString) {\n+ targetParts = [];\n+ sourceParts = [geometry];\n+ for (var i = 0, len = this.components.length; i < len; ++i) {\n+ targetSplit = false;\n+ targetLine = this.components[i];\n+ for (var j = 0; j < sourceParts.length; ++j) {\n+ splits = sourceParts[j].split(targetLine, options);\n+ if (splits) {\n+ if (mutual) {\n+ sourceLines = splits[0];\n+ if (sourceLines.length) {\n+ // splice in new source parts\n+ sourceLines.unshift(j, 1);\n+ Array.prototype.splice.apply(sourceParts, sourceLines);\n+ j += sourceLines.length - 2;\n+ }\n+ splits = splits[1];\n+ if (splits.length === 0) {\n+ splits = [targetLine.clone()];\n+ }\n+ }\n+ for (var k = 0, klen = splits.length; k < klen; ++k) {\n+ if (k === 0 && targetParts.length) {\n+ targetParts[targetParts.length - 1].addComponent(\n+ splits[k]\n+ );\n+ } else {\n+ targetParts.push(\n+ new OpenLayers.Geometry.MultiLineString([\n+ splits[k]\n+ ])\n+ );\n+ }\n+ }\n+ targetSplit = true;\n+ }\n+ }\n+ if (!targetSplit) {\n+ // target component was not hit\n+ if (targetParts.length) {\n+ // add it to any existing multi-line\n+ targetParts[targetParts.length - 1].addComponent(\n+ targetLine.clone()\n+ );\n+ } else {\n+ // or start with a fresh multi-line\n+ targetParts = [\n+ new OpenLayers.Geometry.MultiLineString([\n+ targetLine.clone()\n+ ])\n+ ];\n+ }\n+\n+ }\n+ }\n } else {\n- var child;\n- if (filter.value instanceof OpenLayers.Geometry) {\n- child = this.writeNode(\"feature:_geometry\", filter.value).firstChild;\n+ results = geometry.split(this);\n+ }\n+ if (sourceParts && sourceParts.length > 1) {\n+ sourceSplit = true;\n+ } else {\n+ sourceParts = [];\n+ }\n+ if (targetParts && targetParts.length > 1) {\n+ targetSplit = true;\n+ } else {\n+ targetParts = [];\n+ }\n+ if (sourceSplit || targetSplit) {\n+ if (mutual) {\n+ results = [sourceParts, targetParts];\n } else {\n- child = this.writeNode(\"gml:Envelope\", filter.value);\n- }\n- if (filter.projection) {\n- child.setAttribute(\"srsName\", filter.projection);\n+ results = targetParts;\n }\n- node.appendChild(child);\n }\n- return node;\n+ return results;\n },\n \n- CLASS_NAME: \"OpenLayers.Format.Filter.v1_1_0\"\n-\n+ CLASS_NAME: \"OpenLayers.Geometry.MultiLineString\"\n });\n /* ======================================================================\n- OpenLayers/Format/OWSCommon/v1_0_0.js\n+ OpenLayers/Geometry/LinearRing.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format/OWSCommon/v1.js\n+ * @requires OpenLayers/Geometry/LineString.js\n */\n \n /**\n- * Class: OpenLayers.Format.OWSCommon.v1_0_0\n- * Parser for OWS Common version 1.0.0.\n- *\n- * Inherits from:\n- * - \n+ * Class: OpenLayers.Geometry.LinearRing\n+ * \n+ * A Linear Ring is a special LineString which is closed. It closes itself \n+ * automatically on every addPoint/removePoint by adding a copy of the first\n+ * point as the last point. \n+ * \n+ * Also, as it is the first in the line family to close itself, a getArea()\n+ * function is defined to calculate the enclosed area of the linearRing\n+ * \n+ * Inherits:\n+ * - \n */\n-OpenLayers.Format.OWSCommon.v1_0_0 = OpenLayers.Class(OpenLayers.Format.OWSCommon.v1, {\n-\n- /**\n- * Property: namespaces\n- * {Object} Mapping of namespace aliases to namespace URIs.\n- */\n- namespaces: {\n- ows: \"http://www.opengis.net/ows\",\n- xlink: \"http://www.w3.org/1999/xlink\"\n- },\n+OpenLayers.Geometry.LinearRing = OpenLayers.Class(\n+ OpenLayers.Geometry.LineString, {\n \n- /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n- */\n- readers: {\n- \"ows\": OpenLayers.Util.applyDefaults({\n- \"ExceptionReport\": function(node, obj) {\n- obj.success = false;\n- obj.exceptionReport = {\n- version: node.getAttribute('version'),\n- language: node.getAttribute('language'),\n- exceptions: []\n- };\n- this.readChildNodes(node, obj.exceptionReport);\n- }\n- }, OpenLayers.Format.OWSCommon.v1.prototype.readers.ows)\n- },\n+ /**\n+ * Property: componentTypes\n+ * {Array(String)} An array of class names representing the types of \n+ * components that the collection can include. A null \n+ * value means the component types are not restricted.\n+ */\n+ componentTypes: [\"OpenLayers.Geometry.Point\"],\n \n- /**\n- * Property: writers\n- * As a compliment to the readers property, this structure contains public\n- * writing functions grouped by namespace alias and named like the\n- * node names they produce.\n- */\n- writers: {\n- \"ows\": OpenLayers.Format.OWSCommon.v1.prototype.writers.ows\n- },\n+ /**\n+ * Constructor: OpenLayers.Geometry.LinearRing\n+ * Linear rings are constructed with an array of points. This array\n+ * can represent a closed or open ring. If the ring is open (the last\n+ * point does not equal the first point), the constructor will close\n+ * the ring. If the ring is already closed (the last point does equal\n+ * the first point), it will be left closed.\n+ * \n+ * Parameters:\n+ * points - {Array()} points\n+ */\n \n- CLASS_NAME: \"OpenLayers.Format.OWSCommon.v1_0_0\"\n+ /**\n+ * APIMethod: addComponent\n+ * Adds a point to geometry components. If the point is to be added to\n+ * the end of the components array and it is the same as the last point\n+ * already in that array, the duplicate point is not added. This has \n+ * the effect of closing the ring if it is not already closed, and \n+ * doing the right thing if it is already closed. This behavior can \n+ * be overridden by calling the method with a non-null index as the \n+ * second argument.\n+ *\n+ * Parameters:\n+ * point - {}\n+ * index - {Integer} Index into the array to insert the component\n+ * \n+ * Returns:\n+ * {Boolean} Was the Point successfully added?\n+ */\n+ addComponent: function(point, index) {\n+ var added = false;\n \n-});\n-/* ======================================================================\n- OpenLayers/Format/WFST/v1_1_0.js\n- ====================================================================== */\n+ //remove last point\n+ var lastPoint = this.components.pop();\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ // given an index, add the point\n+ // without an index only add non-duplicate points\n+ if (index != null || !point.equals(lastPoint)) {\n+ added = OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,\n+ arguments);\n+ }\n \n-/**\n- * @requires OpenLayers/Format/WFST/v1.js\n- * @requires OpenLayers/Format/Filter/v1_1_0.js\n- * @requires OpenLayers/Format/OWSCommon/v1_0_0.js\n- */\n+ //append copy of first point\n+ var firstPoint = this.components[0];\n+ OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,\n+ [firstPoint]);\n \n-/**\n- * Class: OpenLayers.Format.WFST.v1_1_0\n- * A format for creating WFS v1.1.0 transactions. Create a new instance with the\n- * constructor.\n- *\n- * Inherits from:\n- * - \n- * - \n- */\n-OpenLayers.Format.WFST.v1_1_0 = OpenLayers.Class(\n- OpenLayers.Format.Filter.v1_1_0, OpenLayers.Format.WFST.v1, {\n+ return added;\n+ },\n \n /**\n- * Property: version\n- * {String} WFS version number.\n+ * APIMethod: removeComponent\n+ * Removes a point from geometry components.\n+ *\n+ * Parameters:\n+ * point - {}\n+ *\n+ * Returns: \n+ * {Boolean} The component was removed.\n */\n- version: \"1.1.0\",\n+ removeComponent: function(point) {\n+ var removed = this.components && (this.components.length > 3);\n+ if (removed) {\n+ //remove last point\n+ this.components.pop();\n+\n+ //remove our point\n+ OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,\n+ arguments);\n+ //append copy of first point\n+ var firstPoint = this.components[0];\n+ OpenLayers.Geometry.Collection.prototype.addComponent.apply(this,\n+ [firstPoint]);\n+ }\n+ return removed;\n+ },\n \n /**\n- * Property: schemaLocations\n- * {Object} Properties are namespace aliases, values are schema locations.\n+ * APIMethod: move\n+ * Moves a geometry by the given displacement along positive x and y axes.\n+ * This modifies the position of the geometry and clears the cached\n+ * bounds.\n+ *\n+ * Parameters:\n+ * x - {Float} Distance to move geometry in positive x direction. \n+ * y - {Float} Distance to move geometry in positive y direction.\n */\n- schemaLocations: {\n- \"wfs\": \"http://schemas.opengis.net/wfs/1.1.0/wfs.xsd\"\n+ move: function(x, y) {\n+ for (var i = 0, len = this.components.length; i < len - 1; i++) {\n+ this.components[i].move(x, y);\n+ }\n },\n \n /**\n- * Constructor: OpenLayers.Format.WFST.v1_1_0\n- * A class for parsing and generating WFS v1.1.0 transactions.\n- *\n- * To read additional information like hit count (numberOfFeatures) from\n- * the FeatureCollection, call the method\n- * with {output: \"object\"} as 2nd argument. Note that it is possible to\n- * just request the hit count from a WFS 1.1.0 server with the\n- * resultType=\"hits\" request parameter.\n+ * APIMethod: rotate\n+ * Rotate a geometry around some origin\n *\n * Parameters:\n- * options - {Object} Optional object whose properties will be set on the\n- * instance.\n+ * angle - {Float} Rotation angle in degrees (measured counterclockwise\n+ * from the positive x-axis)\n+ * origin - {} Center point for the rotation\n+ */\n+ rotate: function(angle, origin) {\n+ for (var i = 0, len = this.components.length; i < len - 1; ++i) {\n+ this.components[i].rotate(angle, origin);\n+ }\n+ },\n+\n+ /**\n+ * APIMethod: resize\n+ * Resize a geometry relative to some origin. Use this method to apply\n+ * a uniform scaling to a geometry.\n *\n- * Valid options properties:\n- * featureType - {String} Local (without prefix) feature typeName (required).\n- * featureNS - {String} Feature namespace (optional).\n- * featurePrefix - {String} Feature namespace alias (optional - only used\n- * if featureNS is provided). Default is 'feature'.\n- * geometryName - {String} Name of geometry attribute. Default is 'the_geom'.\n+ * Parameters:\n+ * scale - {Float} Factor by which to scale the geometry. A scale of 2\n+ * doubles the size of the geometry in each dimension\n+ * (lines, for example, will be twice as long, and polygons\n+ * will have four times the area).\n+ * origin - {} Point of origin for resizing\n+ * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.\n+ * \n+ * Returns:\n+ * {} - The current geometry. \n */\n- initialize: function(options) {\n- OpenLayers.Format.Filter.v1_1_0.prototype.initialize.apply(this, [options]);\n- OpenLayers.Format.WFST.v1.prototype.initialize.apply(this, [options]);\n+ resize: function(scale, origin, ratio) {\n+ for (var i = 0, len = this.components.length; i < len - 1; ++i) {\n+ this.components[i].resize(scale, origin, ratio);\n+ }\n+ return this;\n },\n \n /**\n- * Method: readNode\n- * Shorthand for applying one of the named readers given the node\n- * namespace and local name. Readers take two args (node, obj) and\n- * generally extend or modify the second.\n+ * APIMethod: transform\n+ * Reproject the components geometry from source to dest.\n *\n * Parameters:\n- * node - {DOMElement} The node to be read (required).\n- * obj - {Object} The object to be modified (optional).\n- * first - {Boolean} Should be set to true for the first node read. This\n- * is usually the readNode call in the read method. Without this being\n- * set, auto-configured properties will stick on subsequent reads.\n+ * source - {}\n+ * dest - {}\n+ * \n+ * Returns:\n+ * {} \n+ */\n+ transform: function(source, dest) {\n+ if (source && dest) {\n+ for (var i = 0, len = this.components.length; i < len - 1; i++) {\n+ var component = this.components[i];\n+ component.transform(source, dest);\n+ }\n+ this.bounds = null;\n+ }\n+ return this;\n+ },\n+\n+ /**\n+ * APIMethod: getCentroid\n *\n * Returns:\n- * {Object} The input object, modified (or a new one if none was provided).\n+ * {} The centroid of the collection\n */\n- readNode: function(node, obj, first) {\n- // Not the superclass, only the mixin classes inherit from\n- // Format.GML.v3. We need this because we don't want to get readNode\n- // from the superclass's superclass, which is OpenLayers.Format.XML.\n- return OpenLayers.Format.GML.v3.prototype.readNode.apply(this, arguments);\n+ getCentroid: function() {\n+ if (this.components) {\n+ var len = this.components.length;\n+ if (len > 0 && len <= 2) {\n+ return this.components[0].clone();\n+ } else if (len > 2) {\n+ var sumX = 0.0;\n+ var sumY = 0.0;\n+ var x0 = this.components[0].x;\n+ var y0 = this.components[0].y;\n+ var area = -1 * this.getArea();\n+ if (area != 0) {\n+ for (var i = 0; i < len - 1; i++) {\n+ var b = this.components[i];\n+ var c = this.components[i + 1];\n+ sumX += (b.x + c.x - 2 * x0) * ((b.x - x0) * (c.y - y0) - (c.x - x0) * (b.y - y0));\n+ sumY += (b.y + c.y - 2 * y0) * ((b.x - x0) * (c.y - y0) - (c.x - x0) * (b.y - y0));\n+ }\n+ var x = x0 + sumX / (6 * area);\n+ var y = y0 + sumY / (6 * area);\n+ } else {\n+ for (var i = 0; i < len - 1; i++) {\n+ sumX += this.components[i].x;\n+ sumY += this.components[i].y;\n+ }\n+ var x = sumX / (len - 1);\n+ var y = sumY / (len - 1);\n+ }\n+ return new OpenLayers.Geometry.Point(x, y);\n+ } else {\n+ return null;\n+ }\n+ }\n },\n \n /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n+ * APIMethod: getArea\n+ * Note - The area is positive if the ring is oriented CW, otherwise\n+ * it will be negative.\n+ * \n+ * Returns:\n+ * {Float} The signed area for a ring.\n */\n- readers: {\n- \"wfs\": OpenLayers.Util.applyDefaults({\n- \"FeatureCollection\": function(node, obj) {\n- obj.numberOfFeatures = parseInt(node.getAttribute(\n- \"numberOfFeatures\"));\n- OpenLayers.Format.WFST.v1.prototype.readers[\"wfs\"][\"FeatureCollection\"].apply(\n- this, arguments);\n- },\n- \"TransactionResponse\": function(node, obj) {\n- obj.insertIds = [];\n- obj.success = false;\n- this.readChildNodes(node, obj);\n- },\n- \"TransactionSummary\": function(node, obj) {\n- // this is a limited test of success\n- obj.success = true;\n- },\n- \"InsertResults\": function(node, obj) {\n- this.readChildNodes(node, obj);\n- },\n- \"Feature\": function(node, container) {\n- var obj = {\n- fids: []\n- };\n- this.readChildNodes(node, obj);\n- container.insertIds.push(obj.fids[0]);\n+ getArea: function() {\n+ var area = 0.0;\n+ if (this.components && (this.components.length > 2)) {\n+ var sum = 0.0;\n+ for (var i = 0, len = this.components.length; i < len - 1; i++) {\n+ var b = this.components[i];\n+ var c = this.components[i + 1];\n+ sum += (b.x + c.x) * (c.y - b.y);\n }\n- }, OpenLayers.Format.WFST.v1.prototype.readers[\"wfs\"]),\n- \"gml\": OpenLayers.Format.GML.v3.prototype.readers[\"gml\"],\n- \"feature\": OpenLayers.Format.GML.v3.prototype.readers[\"feature\"],\n- \"ogc\": OpenLayers.Format.Filter.v1_1_0.prototype.readers[\"ogc\"],\n- \"ows\": OpenLayers.Format.OWSCommon.v1_0_0.prototype.readers[\"ows\"]\n+ area = -sum / 2.0;\n+ }\n+ return area;\n },\n \n /**\n- * Property: writers\n- * As a compliment to the readers property, this structure contains public\n- * writing functions grouped by namespace alias and named like the\n- * node names they produce.\n+ * APIMethod: getGeodesicArea\n+ * Calculate the approximate area of the polygon were it projected onto\n+ * the earth. Note that this area will be positive if ring is oriented\n+ * clockwise, otherwise it will be negative.\n+ *\n+ * Parameters:\n+ * projection - {} The spatial reference system\n+ * for the geometry coordinates. If not provided, Geographic/WGS84 is\n+ * assumed.\n+ * \n+ * Reference:\n+ * Robert. G. Chamberlain and William H. Duquette, \"Some Algorithms for\n+ * Polygons on a Sphere\", JPL Publication 07-03, Jet Propulsion\n+ * Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409\n+ *\n+ * Returns:\n+ * {float} The approximate signed geodesic area of the polygon in square\n+ * meters.\n */\n- writers: {\n- \"wfs\": OpenLayers.Util.applyDefaults({\n- \"GetFeature\": function(options) {\n- var node = OpenLayers.Format.WFST.v1.prototype.writers[\"wfs\"][\"GetFeature\"].apply(this, arguments);\n- options && this.setAttributes(node, {\n- resultType: options.resultType,\n- startIndex: options.startIndex,\n- count: options.count\n- });\n- return node;\n- },\n- \"Query\": function(options) {\n- options = OpenLayers.Util.extend({\n- featureNS: this.featureNS,\n- featurePrefix: this.featurePrefix,\n- featureType: this.featureType,\n- srsName: this.srsName\n- }, options);\n- var prefix = options.featurePrefix;\n- var node = this.createElementNSPlus(\"wfs:Query\", {\n- attributes: {\n- typeName: (prefix ? prefix + \":\" : \"\") +\n- options.featureType,\n- srsName: options.srsName\n+ getGeodesicArea: function(projection) {\n+ var ring = this; // so we can work with a clone if needed\n+ if (projection) {\n+ var gg = new OpenLayers.Projection(\"EPSG:4326\");\n+ if (!gg.equals(projection)) {\n+ ring = this.clone().transform(projection, gg);\n+ }\n+ }\n+ var area = 0.0;\n+ var len = ring.components && ring.components.length;\n+ if (len > 2) {\n+ var p1, p2;\n+ for (var i = 0; i < len - 1; i++) {\n+ p1 = ring.components[i];\n+ p2 = ring.components[i + 1];\n+ area += OpenLayers.Util.rad(p2.x - p1.x) *\n+ (2 + Math.sin(OpenLayers.Util.rad(p1.y)) +\n+ Math.sin(OpenLayers.Util.rad(p2.y)));\n+ }\n+ area = area * 6378137.0 * 6378137.0 / 2.0;\n+ }\n+ return area;\n+ },\n+\n+ /**\n+ * Method: containsPoint\n+ * Test if a point is inside a linear ring. For the case where a point\n+ * is coincident with a linear ring edge, returns 1. Otherwise,\n+ * returns boolean.\n+ *\n+ * Parameters:\n+ * point - {}\n+ *\n+ * Returns:\n+ * {Boolean | Number} The point is inside the linear ring. Returns 1 if\n+ * the point is coincident with an edge. Returns boolean otherwise.\n+ */\n+ containsPoint: function(point) {\n+ var approx = OpenLayers.Number.limitSigDigs;\n+ var digs = 14;\n+ var px = approx(point.x, digs);\n+ var py = approx(point.y, digs);\n+\n+ function getX(y, x1, y1, x2, y2) {\n+ return (y - y2) * ((x2 - x1) / (y2 - y1)) + x2;\n+ }\n+ var numSeg = this.components.length - 1;\n+ var start, end, x1, y1, x2, y2, cx, cy;\n+ var crosses = 0;\n+ for (var i = 0; i < numSeg; ++i) {\n+ start = this.components[i];\n+ x1 = approx(start.x, digs);\n+ y1 = approx(start.y, digs);\n+ end = this.components[i + 1];\n+ x2 = approx(end.x, digs);\n+ y2 = approx(end.y, digs);\n+\n+ /**\n+ * The following conditions enforce five edge-crossing rules:\n+ * 1. points coincident with edges are considered contained;\n+ * 2. an upward edge includes its starting endpoint, and\n+ * excludes its final endpoint;\n+ * 3. a downward edge excludes its starting endpoint, and\n+ * includes its final endpoint;\n+ * 4. horizontal edges are excluded; and\n+ * 5. the edge-ray intersection point must be strictly right\n+ * of the point P.\n+ */\n+ if (y1 == y2) {\n+ // horizontal edge\n+ if (py == y1) {\n+ // point on horizontal line\n+ if (x1 <= x2 && (px >= x1 && px <= x2) || // right or vert\n+ x1 >= x2 && (px <= x1 && px >= x2)) { // left or vert\n+ // point on edge\n+ crosses = -1;\n+ break;\n }\n- });\n- if (options.featureNS) {\n- node.setAttribute(\"xmlns:\" + prefix, options.featureNS);\n }\n- if (options.propertyNames) {\n- for (var i = 0, len = options.propertyNames.length; i < len; i++) {\n- this.writeNode(\n- \"wfs:PropertyName\", {\n- property: options.propertyNames[i]\n- },\n- node\n- );\n- }\n+ // ignore other horizontal edges\n+ continue;\n+ }\n+ cx = approx(getX(py, x1, y1, x2, y2), digs);\n+ if (cx == px) {\n+ // point on line\n+ if (y1 < y2 && (py >= y1 && py <= y2) || // upward\n+ y1 > y2 && (py <= y1 && py >= y2)) { // downward\n+ // point on edge\n+ crosses = -1;\n+ break;\n }\n- if (options.filter) {\n- OpenLayers.Format.WFST.v1_1_0.prototype.setFilterProperty.call(this, options.filter);\n- this.writeNode(\"ogc:Filter\", options.filter, node);\n+ }\n+ if (cx <= px) {\n+ // no crossing to the right\n+ continue;\n+ }\n+ if (x1 != x2 && (cx < Math.min(x1, x2) || cx > Math.max(x1, x2))) {\n+ // no crossing\n+ continue;\n+ }\n+ if (y1 < y2 && (py >= y1 && py < y2) || // upward\n+ y1 > y2 && (py < y1 && py >= y2)) { // downward\n+ ++crosses;\n+ }\n+ }\n+ var contained = (crosses == -1) ?\n+ // on edge\n+ 1 :\n+ // even (out) or odd (in)\n+ !!(crosses & 1);\n+\n+ return contained;\n+ },\n+\n+ /**\n+ * APIMethod: intersects\n+ * Determine if the input geometry intersects this one.\n+ *\n+ * Parameters:\n+ * geometry - {} Any type of geometry.\n+ *\n+ * Returns:\n+ * {Boolean} The input geometry intersects this one.\n+ */\n+ intersects: function(geometry) {\n+ var intersect = false;\n+ if (geometry.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n+ intersect = this.containsPoint(geometry);\n+ } else if (geometry.CLASS_NAME == \"OpenLayers.Geometry.LineString\") {\n+ intersect = geometry.intersects(this);\n+ } else if (geometry.CLASS_NAME == \"OpenLayers.Geometry.LinearRing\") {\n+ intersect = OpenLayers.Geometry.LineString.prototype.intersects.apply(\n+ this, [geometry]\n+ );\n+ } else {\n+ // check for component intersections\n+ for (var i = 0, len = geometry.components.length; i < len; ++i) {\n+ intersect = geometry.components[i].intersects(this);\n+ if (intersect) {\n+ break;\n }\n- return node;\n- },\n- \"PropertyName\": function(obj) {\n- return this.createElementNSPlus(\"wfs:PropertyName\", {\n- value: obj.property\n- });\n }\n- }, OpenLayers.Format.WFST.v1.prototype.writers[\"wfs\"]),\n- \"gml\": OpenLayers.Format.GML.v3.prototype.writers[\"gml\"],\n- \"feature\": OpenLayers.Format.GML.v3.prototype.writers[\"feature\"],\n- \"ogc\": OpenLayers.Format.Filter.v1_1_0.prototype.writers[\"ogc\"]\n+ }\n+ return intersect;\n },\n \n- CLASS_NAME: \"OpenLayers.Format.WFST.v1_1_0\"\n+ /**\n+ * APIMethod: getVertices\n+ * Return a list of all points in this geometry.\n+ *\n+ * Parameters:\n+ * nodes - {Boolean} For lines, only return vertices that are\n+ * endpoints. If false, for lines, only vertices that are not\n+ * endpoints will be returned. If not provided, all vertices will\n+ * be returned.\n+ *\n+ * Returns:\n+ * {Array} A list of all vertices in the geometry.\n+ */\n+ getVertices: function(nodes) {\n+ return (nodes === true) ? [] : this.components.slice(0, this.components.length - 1);\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Geometry.LinearRing\"\n });\n /* ======================================================================\n- OpenLayers/Format/WPSExecute.js\n+ OpenLayers/Geometry/Polygon.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format/XML.js\n- * @requires OpenLayers/Format/OWSCommon/v1_1_0.js\n- * @requires OpenLayers/Format/WCSGetCoverage.js\n- * @requires OpenLayers/Format/WFST/v1_1_0.js\n+ * @requires OpenLayers/Geometry/Collection.js\n+ * @requires OpenLayers/Geometry/LinearRing.js\n */\n \n /**\n- * Class: OpenLayers.Format.WPSExecute version 1.0.0\n- *\n+ * Class: OpenLayers.Geometry.Polygon \n+ * Polygon is a collection of Geometry.LinearRings. \n+ * \n * Inherits from:\n- * - \n+ * - \n+ * - \n */\n-OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML,\n- OpenLayers.Format.Filter.v1_1_0, {\n+OpenLayers.Geometry.Polygon = OpenLayers.Class(\n+ OpenLayers.Geometry.Collection, {\n \n /**\n- * Property: namespaces\n- * {Object} Mapping of namespace aliases to namespace URIs.\n+ * Property: componentTypes\n+ * {Array(String)} An array of class names representing the types of\n+ * components that the collection can include. A null value means the\n+ * component types are not restricted.\n */\n- namespaces: {\n- ows: \"http://www.opengis.net/ows/1.1\",\n- gml: \"http://www.opengis.net/gml\",\n- wps: \"http://www.opengis.net/wps/1.0.0\",\n- wfs: \"http://www.opengis.net/wfs\",\n- ogc: \"http://www.opengis.net/ogc\",\n- wcs: \"http://www.opengis.net/wcs\",\n- xlink: \"http://www.w3.org/1999/xlink\",\n- xsi: \"http://www.w3.org/2001/XMLSchema-instance\"\n- },\n+ componentTypes: [\"OpenLayers.Geometry.LinearRing\"],\n \n /**\n- * Property: regExes\n- * Compiled regular expressions for manipulating strings.\n+ * Constructor: OpenLayers.Geometry.Polygon\n+ * Constructor for a Polygon geometry. \n+ * The first ring (this.component[0])is the outer bounds of the polygon and \n+ * all subsequent rings (this.component[1-n]) are internal holes.\n+ *\n+ *\n+ * Parameters:\n+ * components - {Array()} \n */\n- regExes: {\n- trimSpace: (/^\\s*|\\s*$/g),\n- removeSpace: (/\\s*/g),\n- splitSpace: (/\\s+/),\n- trimComma: (/\\s*,\\s*/g)\n- },\n \n- /**\n- * Constant: VERSION\n- * {String} 1.0.0\n+ /** \n+ * APIMethod: getArea\n+ * Calculated by subtracting the areas of the internal holes from the \n+ * area of the outer hole.\n+ * \n+ * Returns:\n+ * {float} The area of the geometry\n */\n- VERSION: \"1.0.0\",\n+ getArea: function() {\n+ var area = 0.0;\n+ if (this.components && (this.components.length > 0)) {\n+ area += Math.abs(this.components[0].getArea());\n+ for (var i = 1, len = this.components.length; i < len; i++) {\n+ area -= Math.abs(this.components[i].getArea());\n+ }\n+ }\n+ return area;\n+ },\n \n- /**\n- * Property: schemaLocation\n- * {String} Schema location\n+ /** \n+ * APIMethod: getGeodesicArea\n+ * Calculate the approximate area of the polygon were it projected onto\n+ * the earth.\n+ *\n+ * Parameters:\n+ * projection - {} The spatial reference system\n+ * for the geometry coordinates. If not provided, Geographic/WGS84 is\n+ * assumed.\n+ * \n+ * Reference:\n+ * Robert. G. Chamberlain and William H. Duquette, \"Some Algorithms for\n+ * Polygons on a Sphere\", JPL Publication 07-03, Jet Propulsion\n+ * Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409\n+ *\n+ * Returns:\n+ * {float} The approximate geodesic area of the polygon in square meters.\n */\n- schemaLocation: \"http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd\",\n-\n- schemaLocationAttr: function(options) {\n- return undefined;\n+ getGeodesicArea: function(projection) {\n+ var area = 0.0;\n+ if (this.components && (this.components.length > 0)) {\n+ area += Math.abs(this.components[0].getGeodesicArea(projection));\n+ for (var i = 1, len = this.components.length; i < len; i++) {\n+ area -= Math.abs(this.components[i].getGeodesicArea(projection));\n+ }\n+ }\n+ return area;\n },\n \n /**\n- * Constructor: OpenLayers.Format.WPSExecute\n+ * Method: containsPoint\n+ * Test if a point is inside a polygon. Points on a polygon edge are\n+ * considered inside.\n *\n * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ * point - {}\n+ *\n+ * Returns:\n+ * {Boolean | Number} The point is inside the polygon. Returns 1 if the\n+ * point is on an edge. Returns boolean otherwise.\n */\n+ containsPoint: function(point) {\n+ var numRings = this.components.length;\n+ var contained = false;\n+ if (numRings > 0) {\n+ // check exterior ring - 1 means on edge, boolean otherwise\n+ contained = this.components[0].containsPoint(point);\n+ if (contained !== 1) {\n+ if (contained && numRings > 1) {\n+ // check interior rings\n+ var hole;\n+ for (var i = 1; i < numRings; ++i) {\n+ hole = this.components[i].containsPoint(point);\n+ if (hole) {\n+ if (hole === 1) {\n+ // on edge\n+ contained = 1;\n+ } else {\n+ // in hole\n+ contained = false;\n+ }\n+ break;\n+ }\n+ }\n+ }\n+ }\n+ }\n+ return contained;\n+ },\n \n /**\n- * Method: write\n+ * APIMethod: intersects\n+ * Determine if the input geometry intersects this one.\n *\n * Parameters:\n- * options - {Object} Optional object.\n+ * geometry - {} Any type of geometry.\n *\n * Returns:\n- * {String} An WPS Execute request XML string.\n+ * {Boolean} The input geometry intersects this one.\n */\n- write: function(options) {\n- var doc;\n- if (window.ActiveXObject) {\n- doc = new ActiveXObject(\"Microsoft.XMLDOM\");\n- this.xmldom = doc;\n+ intersects: function(geometry) {\n+ var intersect = false;\n+ var i, len;\n+ if (geometry.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n+ intersect = this.containsPoint(geometry);\n+ } else if (geometry.CLASS_NAME == \"OpenLayers.Geometry.LineString\" ||\n+ geometry.CLASS_NAME == \"OpenLayers.Geometry.LinearRing\") {\n+ // check if rings/linestrings intersect\n+ for (i = 0, len = this.components.length; i < len; ++i) {\n+ intersect = geometry.intersects(this.components[i]);\n+ if (intersect) {\n+ break;\n+ }\n+ }\n+ if (!intersect) {\n+ // check if this poly contains points of the ring/linestring\n+ for (i = 0, len = geometry.components.length; i < len; ++i) {\n+ intersect = this.containsPoint(geometry.components[i]);\n+ if (intersect) {\n+ break;\n+ }\n+ }\n+ }\n } else {\n- doc = document.implementation.createDocument(\"\", \"\", null);\n+ for (i = 0, len = geometry.components.length; i < len; ++i) {\n+ intersect = this.intersects(geometry.components[i]);\n+ if (intersect) {\n+ break;\n+ }\n+ }\n }\n- var node = this.writeNode(\"wps:Execute\", options, doc);\n- this.setAttributeNS(\n- node, this.namespaces.xsi,\n- \"xsi:schemaLocation\", this.schemaLocation\n- );\n- return OpenLayers.Format.XML.prototype.write.apply(this, [node]);\n+ // check case where this poly is wholly contained by another\n+ if (!intersect && geometry.CLASS_NAME == \"OpenLayers.Geometry.Polygon\") {\n+ // exterior ring points will be contained in the other geometry\n+ var ring = this.components[0];\n+ for (i = 0, len = ring.components.length; i < len; ++i) {\n+ intersect = geometry.containsPoint(ring.components[i]);\n+ if (intersect) {\n+ break;\n+ }\n+ }\n+ }\n+ return intersect;\n },\n \n /**\n- * APIMethod: read\n- * Parse a WPS Execute and return an object with its information.\n- * \n- * Parameters: \n- * data - {String} or {DOMElement} data to read/parse.\n+ * APIMethod: distanceTo\n+ * Calculate the closest distance between two geometries (on the x-y plane).\n+ *\n+ * Parameters:\n+ * geometry - {} The target geometry.\n+ * options - {Object} Optional properties for configuring the distance\n+ * calculation.\n+ *\n+ * Valid options:\n+ * details - {Boolean} Return details from the distance calculation.\n+ * Default is false.\n+ * edge - {Boolean} Calculate the distance from this geometry to the\n+ * nearest edge of the target geometry. Default is true. If true,\n+ * calling distanceTo from a geometry that is wholly contained within\n+ * the target will result in a non-zero distance. If false, whenever\n+ * geometries intersect, calling distanceTo will return 0. If false,\n+ * details cannot be returned.\n *\n * Returns:\n- * {Object}\n+ * {Number | Object} The distance between this geometry and the target.\n+ * If details is true, the return will be an object with distance,\n+ * x0, y0, x1, and y1 properties. The x0 and y0 properties represent\n+ * the coordinates of the closest point on this geometry. The x1 and y1\n+ * properties represent the coordinates of the closest point on the\n+ * target geometry.\n */\n- read: function(data) {\n- if (typeof data == \"string\") {\n- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n- }\n- if (data && data.nodeType == 9) {\n- data = data.documentElement;\n+ distanceTo: function(geometry, options) {\n+ var edge = !(options && options.edge === false);\n+ var result;\n+ // this is the case where we might not be looking for distance to edge\n+ if (!edge && this.intersects(geometry)) {\n+ result = 0;\n+ } else {\n+ result = OpenLayers.Geometry.Collection.prototype.distanceTo.apply(\n+ this, [geometry, options]\n+ );\n }\n- var info = {};\n- this.readNode(data, info);\n- return info;\n+ return result;\n },\n \n- /**\n- * Property: writers\n- * As a compliment to the readers property, this structure contains public\n- * writing functions grouped by namespace alias and named like the\n- * node names they produce.\n- */\n- writers: {\n- \"wps\": {\n- \"Execute\": function(options) {\n- var node = this.createElementNSPlus(\"wps:Execute\", {\n- attributes: {\n- version: this.VERSION,\n- service: 'WPS'\n- }\n- });\n- this.writeNode(\"ows:Identifier\", options.identifier, node);\n- this.writeNode(\"wps:DataInputs\", options.dataInputs, node);\n- this.writeNode(\"wps:ResponseForm\", options.responseForm, node);\n- return node;\n- },\n- \"ResponseForm\": function(responseForm) {\n- var node = this.createElementNSPlus(\"wps:ResponseForm\", {});\n- if (responseForm.rawDataOutput) {\n- this.writeNode(\"wps:RawDataOutput\", responseForm.rawDataOutput, node);\n- }\n- if (responseForm.responseDocument) {\n- this.writeNode(\"wps:ResponseDocument\", responseForm.responseDocument, node);\n- }\n- return node;\n- },\n- \"ResponseDocument\": function(responseDocument) {\n- var node = this.createElementNSPlus(\"wps:ResponseDocument\", {\n- attributes: {\n- storeExecuteResponse: responseDocument.storeExecuteResponse,\n- lineage: responseDocument.lineage,\n- status: responseDocument.status\n- }\n- });\n- if (responseDocument.outputs) {\n- for (var i = 0, len = responseDocument.outputs.length; i < len; i++) {\n- this.writeNode(\"wps:Output\", responseDocument.outputs[i], node);\n- }\n- }\n- return node;\n- },\n- \"Output\": function(output) {\n- var node = this.createElementNSPlus(\"wps:Output\", {\n- attributes: {\n- asReference: output.asReference,\n- mimeType: output.mimeType,\n- encoding: output.encoding,\n- schema: output.schema\n- }\n- });\n- this.writeNode(\"ows:Identifier\", output.identifier, node);\n- this.writeNode(\"ows:Title\", output.title, node);\n- this.writeNode(\"ows:Abstract\", output[\"abstract\"], node);\n- return node;\n- },\n- \"RawDataOutput\": function(rawDataOutput) {\n- var node = this.createElementNSPlus(\"wps:RawDataOutput\", {\n- attributes: {\n- mimeType: rawDataOutput.mimeType,\n- encoding: rawDataOutput.encoding,\n- schema: rawDataOutput.schema\n- }\n- });\n- this.writeNode(\"ows:Identifier\", rawDataOutput.identifier, node);\n- return node;\n- },\n- \"DataInputs\": function(dataInputs) {\n- var node = this.createElementNSPlus(\"wps:DataInputs\", {});\n- for (var i = 0, ii = dataInputs.length; i < ii; ++i) {\n- this.writeNode(\"wps:Input\", dataInputs[i], node);\n- }\n- return node;\n- },\n- \"Input\": function(input) {\n- var node = this.createElementNSPlus(\"wps:Input\", {});\n- this.writeNode(\"ows:Identifier\", input.identifier, node);\n- if (input.title) {\n- this.writeNode(\"ows:Title\", input.title, node);\n- }\n- if (input.data) {\n- this.writeNode(\"wps:Data\", input.data, node);\n- }\n- if (input.reference) {\n- this.writeNode(\"wps:Reference\", input.reference, node);\n- }\n- if (input.boundingBoxData) {\n- this.writeNode(\"wps:BoundingBoxData\", input.boundingBoxData, node);\n- }\n- return node;\n- },\n- \"Data\": function(data) {\n- var node = this.createElementNSPlus(\"wps:Data\", {});\n- if (data.literalData) {\n- this.writeNode(\"wps:LiteralData\", data.literalData, node);\n- } else if (data.complexData) {\n- this.writeNode(\"wps:ComplexData\", data.complexData, node);\n- } else if (data.boundingBoxData) {\n- this.writeNode(\"ows:BoundingBox\", data.boundingBoxData, node);\n- }\n- return node;\n- },\n- \"LiteralData\": function(literalData) {\n- var node = this.createElementNSPlus(\"wps:LiteralData\", {\n- attributes: {\n- uom: literalData.uom\n- },\n- value: literalData.value\n- });\n- return node;\n- },\n- \"ComplexData\": function(complexData) {\n- var node = this.createElementNSPlus(\"wps:ComplexData\", {\n- attributes: {\n- mimeType: complexData.mimeType,\n- encoding: complexData.encoding,\n- schema: complexData.schema\n- }\n- });\n- var data = complexData.value;\n- if (typeof data === \"string\") {\n- node.appendChild(\n- this.getXMLDoc().createCDATASection(complexData.value)\n- );\n- } else {\n- node.appendChild(data);\n- }\n- return node;\n- },\n- \"Reference\": function(reference) {\n- var node = this.createElementNSPlus(\"wps:Reference\", {\n- attributes: {\n- mimeType: reference.mimeType,\n- \"xlink:href\": reference.href,\n- method: reference.method,\n- encoding: reference.encoding,\n- schema: reference.schema\n- }\n- });\n- if (reference.body) {\n- this.writeNode(\"wps:Body\", reference.body, node);\n- }\n- return node;\n- },\n- \"BoundingBoxData\": function(node, obj) {\n- this.writers['ows']['BoundingBox'].apply(this, [node, obj, \"wps:BoundingBoxData\"]);\n- },\n- \"Body\": function(body) {\n- var node = this.createElementNSPlus(\"wps:Body\", {});\n- if (body.wcs) {\n- this.writeNode(\"wcs:GetCoverage\", body.wcs, node);\n- } else if (body.wfs) {\n- // OpenLayers.Format.WFST expects these to be on the \n- // instance and not in the options\n- this.featureType = body.wfs.featureType;\n- this.version = body.wfs.version;\n- this.writeNode(\"wfs:GetFeature\", body.wfs, node);\n- } else {\n- this.writeNode(\"wps:Execute\", body, node);\n- }\n- return node;\n- }\n- },\n- \"wcs\": OpenLayers.Format.WCSGetCoverage.prototype.writers.wcs,\n- \"wfs\": OpenLayers.Format.WFST.v1_1_0.prototype.writers.wfs,\n- \"ogc\": OpenLayers.Format.Filter.v1_1_0.prototype.writers.ogc,\n- \"ows\": OpenLayers.Format.OWSCommon.v1_1_0.prototype.writers.ows\n- },\n+ CLASS_NAME: \"OpenLayers.Geometry.Polygon\"\n+ });\n \n- /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n- */\n- readers: {\n- \"wps\": {\n- \"ExecuteResponse\": function(node, obj) {\n- obj.executeResponse = {\n- lang: node.getAttribute(\"lang\"),\n- statusLocation: node.getAttribute(\"statusLocation\"),\n- serviceInstance: node.getAttribute(\"serviceInstance\"),\n- service: node.getAttribute(\"service\")\n- };\n- this.readChildNodes(node, obj.executeResponse);\n- },\n- \"Process\": function(node, obj) {\n- obj.process = {};\n- this.readChildNodes(node, obj.process);\n- },\n- \"Status\": function(node, obj) {\n- obj.status = {\n- creationTime: node.getAttribute(\"creationTime\")\n- };\n- this.readChildNodes(node, obj.status);\n- },\n- \"ProcessSucceeded\": function(node, obj) {\n- obj.processSucceeded = true;\n- },\n- \"ProcessOutputs\": function(node, processDescription) {\n- processDescription.processOutputs = [];\n- this.readChildNodes(node, processDescription.processOutputs);\n- },\n- \"Output\": function(node, processOutputs) {\n- var output = {};\n- this.readChildNodes(node, output);\n- processOutputs.push(output);\n- },\n- \"Reference\": function(node, output) {\n- output.reference = {\n- href: node.getAttribute(\"href\"),\n- mimeType: node.getAttribute(\"mimeType\"),\n- encoding: node.getAttribute(\"encoding\"),\n- schema: node.getAttribute(\"schema\")\n- };\n- },\n- \"Data\": function(node, output) {\n- output.data = {};\n- this.readChildNodes(node, output);\n- },\n- \"LiteralData\": function(node, output) {\n- output.literalData = {\n- dataType: node.getAttribute(\"dataType\"),\n- uom: node.getAttribute(\"uom\"),\n- value: this.getChildValue(node)\n- };\n- },\n- \"ComplexData\": function(node, output) {\n- output.complexData = {\n- mimeType: node.getAttribute(\"mimeType\"),\n- schema: node.getAttribute(\"schema\"),\n- encoding: node.getAttribute(\"encoding\"),\n- value: \"\"\n- };\n+/**\n+ * APIMethod: createRegularPolygon\n+ * Create a regular polygon around a radius. Useful for creating circles \n+ * and the like.\n+ *\n+ * Parameters:\n+ * origin - {} center of polygon.\n+ * radius - {Float} distance to vertex, in map units.\n+ * sides - {Integer} Number of sides. 20 approximates a circle.\n+ * rotation - {Float} original angle of rotation, in degrees.\n+ */\n+OpenLayers.Geometry.Polygon.createRegularPolygon = function(origin, radius, sides, rotation) {\n+ var angle = Math.PI * ((1 / sides) - (1 / 2));\n+ if (rotation) {\n+ angle += (rotation / 180) * Math.PI;\n+ }\n+ var rotatedAngle, x, y;\n+ var points = [];\n+ for (var i = 0; i < sides; ++i) {\n+ rotatedAngle = angle + (i * 2 * Math.PI / sides);\n+ x = origin.x + (radius * Math.cos(rotatedAngle));\n+ y = origin.y + (radius * Math.sin(rotatedAngle));\n+ points.push(new OpenLayers.Geometry.Point(x, y));\n+ }\n+ var ring = new OpenLayers.Geometry.LinearRing(points);\n+ return new OpenLayers.Geometry.Polygon([ring]);\n+};\n+/* ======================================================================\n+ OpenLayers/Geometry/MultiPolygon.js\n+ ====================================================================== */\n \n- // try to get *some* value, ignore the empty text values\n- if (this.isSimpleContent(node)) {\n- var child;\n- for (child = node.firstChild; child; child = child.nextSibling) {\n- switch (child.nodeType) {\n- case 3: // text node\n- case 4: // cdata section\n- output.complexData.value += child.nodeValue;\n- }\n- }\n- } else {\n- for (child = node.firstChild; child; child = child.nextSibling) {\n- if (child.nodeType == 1) {\n- output.complexData.value = child;\n- }\n- }\n- }\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- },\n- \"BoundingBox\": function(node, output) {\n- output.boundingBoxData = {\n- dimensions: node.getAttribute(\"dimensions\"),\n- crs: node.getAttribute(\"crs\")\n- };\n- this.readChildNodes(node, output.boundingBoxData);\n- }\n- },\n+/**\n+ * @requires OpenLayers/Geometry/Collection.js\n+ * @requires OpenLayers/Geometry/Polygon.js\n+ */\n \n- // TODO: we should add Exception parsing here\n- \"ows\": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers[\"ows\"]\n- },\n+/**\n+ * Class: OpenLayers.Geometry.MultiPolygon\n+ * MultiPolygon is a geometry with multiple \n+ * components. Create a new instance with the \n+ * constructor.\n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Geometry.MultiPolygon = OpenLayers.Class(\n+ OpenLayers.Geometry.Collection, {\n \n- CLASS_NAME: \"OpenLayers.Format.WPSExecute\"\n+ /**\n+ * Property: componentTypes\n+ * {Array(String)} An array of class names representing the types of\n+ * components that the collection can include. A null value means the\n+ * component types are not restricted.\n+ */\n+ componentTypes: [\"OpenLayers.Geometry.Polygon\"],\n+\n+ /**\n+ * Constructor: OpenLayers.Geometry.MultiPolygon\n+ * Create a new MultiPolygon geometry\n+ *\n+ * Parameters:\n+ * components - {Array()} An array of polygons\n+ * used to generate the MultiPolygon\n+ *\n+ */\n \n+ CLASS_NAME: \"OpenLayers.Geometry.MultiPolygon\"\n });\n /* ======================================================================\n- OpenLayers/WPSProcess.js\n+ OpenLayers/Format/WKT.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/SingleFile.js\n- */\n-\n-/**\n- * @requires OpenLayers/Geometry.js\n+ * @requires OpenLayers/Format.js\n * @requires OpenLayers/Feature/Vector.js\n- * @requires OpenLayers/Format/WKT.js\n- * @requires OpenLayers/Format/GeoJSON.js\n- * @requires OpenLayers/Format/WPSExecute.js\n- * @requires OpenLayers/Request.js\n+ * @requires OpenLayers/Geometry/Point.js\n+ * @requires OpenLayers/Geometry/MultiPoint.js\n+ * @requires OpenLayers/Geometry/LineString.js\n+ * @requires OpenLayers/Geometry/MultiLineString.js\n+ * @requires OpenLayers/Geometry/Polygon.js\n+ * @requires OpenLayers/Geometry/MultiPolygon.js\n */\n \n /**\n- * Class: OpenLayers.WPSProcess\n- * Representation of a WPS process. Usually instances of\n- * are created by calling 'getProcess' on an\n- * instance.\n- *\n- * Currently supports processes that have geometries\n- * or features as output, using WKT or GeoJSON as output format. It also\n- * supports chaining of processes by using the method to create a\n- * handle that is used as process input instead of a static value.\n+ * Class: OpenLayers.Format.WKT\n+ * Class for reading and writing Well-Known Text. Create a new instance\n+ * with the constructor.\n+ * \n+ * Inherits from:\n+ * - \n */\n-OpenLayers.WPSProcess = OpenLayers.Class({\n-\n- /**\n- * Property: client\n- * {} The client that manages this process.\n- */\n- client: null,\n-\n- /**\n- * Property: server\n- * {String} Local client identifier for this process's server.\n- */\n- server: null,\n-\n- /**\n- * Property: identifier\n- * {String} Process identifier known to the server.\n- */\n- identifier: null,\n-\n- /**\n- * Property: description\n- * {Object} DescribeProcess response for this process.\n- */\n- description: null,\n-\n- /**\n- * APIProperty: localWPS\n- * {String} Service endpoint for locally chained WPS processes. Default is\n- * 'http://geoserver/wps'.\n- */\n- localWPS: 'http://geoserver/wps',\n-\n- /**\n- * Property: formats\n- * {Object} OpenLayers.Format instances keyed by mimetype.\n- */\n- formats: null,\n-\n- /**\n- * Property: chained\n- * {Integer} Number of chained processes for pending execute requests that\n- * don't have a full configuration yet.\n- */\n- chained: 0,\n-\n- /**\n- * Property: executeCallbacks\n- * {Array} Callbacks waiting to be executed until all chained processes\n- * are configured;\n- */\n- executeCallbacks: null,\n+OpenLayers.Format.WKT = OpenLayers.Class(OpenLayers.Format, {\n \n /**\n- * Constructor: OpenLayers.WPSProcess\n+ * Constructor: OpenLayers.Format.WKT\n+ * Create a new parser for WKT\n *\n * Parameters:\n- * options - {Object} Object whose properties will be set on the instance.\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance\n *\n- * Avaliable options:\n- * client - {} Mandatory. Client that manages this\n- * process.\n- * server - {String} Mandatory. Local client identifier of this process's\n- * server.\n- * identifier - {String} Mandatory. Process identifier known to the server.\n+ * Returns:\n+ * {} A new WKT parser.\n */\n initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n- this.executeCallbacks = [];\n- this.formats = {\n- 'application/wkt': new OpenLayers.Format.WKT(),\n- 'application/json': new OpenLayers.Format.GeoJSON()\n+ this.regExes = {\n+ 'typeStr': /^\\s*(\\w+)\\s*\\(\\s*(.*)\\s*\\)\\s*$/,\n+ 'spaces': /\\s+/,\n+ 'parenComma': /\\)\\s*,\\s*\\(/,\n+ 'doubleParenComma': /\\)\\s*\\)\\s*,\\s*\\(\\s*\\(/, // can't use {2} here\n+ 'trimParens': /^\\s*\\(?(.*?)\\)?\\s*$/\n };\n+ OpenLayers.Format.prototype.initialize.apply(this, [options]);\n },\n \n /**\n- * Method: describe\n- * Makes the client issue a DescribeProcess request asynchronously.\n+ * APIMethod: read\n+ * Deserialize a WKT string and return a vector feature or an\n+ * array of vector features. Supports WKT for POINT, MULTIPOINT,\n+ * LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON, and\n+ * GEOMETRYCOLLECTION.\n *\n * Parameters:\n- * options - {Object} Configuration for the method call\n+ * wkt - {String} A WKT string\n *\n- * Available options:\n- * callback - {Function} Callback to execute when the description is\n- * available. Will be called with the parsed description as argument.\n- * Optional.\n- * scope - {Object} The scope in which the callback will be executed.\n- * Default is the global object.\n+ * Returns:\n+ * {|Array} A feature or array of features for\n+ * GEOMETRYCOLLECTION WKT.\n */\n- describe: function(options) {\n- options = options || {};\n- if (!this.description) {\n- this.client.describeProcess(this.server, this.identifier, function(description) {\n- if (!this.description) {\n- this.parseDescription(description);\n- }\n- if (options.callback) {\n- options.callback.call(options.scope, this.description);\n+ read: function(wkt) {\n+ var features, type, str;\n+ wkt = wkt.replace(/[\\n\\r]/g, \" \");\n+ var matches = this.regExes.typeStr.exec(wkt);\n+ if (matches) {\n+ type = matches[1].toLowerCase();\n+ str = matches[2];\n+ if (this.parse[type]) {\n+ features = this.parse[type].apply(this, [str]);\n+ }\n+ if (this.internalProjection && this.externalProjection) {\n+ if (features &&\n+ features.CLASS_NAME == \"OpenLayers.Feature.Vector\") {\n+ features.geometry.transform(this.externalProjection,\n+ this.internalProjection);\n+ } else if (features &&\n+ type != \"geometrycollection\" &&\n+ typeof features == \"object\") {\n+ for (var i = 0, len = features.length; i < len; i++) {\n+ var component = features[i];\n+ component.geometry.transform(this.externalProjection,\n+ this.internalProjection);\n+ }\n }\n- }, this);\n- } else if (options.callback) {\n- var description = this.description;\n- window.setTimeout(function() {\n- options.callback.call(options.scope, description);\n- }, 0);\n+ }\n }\n+ return features;\n },\n \n /**\n- * APIMethod: configure\n- * Configure the process, but do not execute it. Use this for processes\n- * that are chained as input of a different process by means of the\n- * method.\n+ * APIMethod: write\n+ * Serialize a feature or array of features into a WKT string.\n *\n * Parameters:\n- * options - {Object}\n+ * features - {|Array} A feature or array of\n+ * features\n *\n * Returns:\n- * {} this process.\n- *\n- * Available options:\n- * inputs - {Object} The inputs for the process, keyed by input identifier.\n- * For spatial data inputs, the value of an input is usually an\n- * , an or an array of\n- * geometries or features.\n- * callback - {Function} Callback to call when the configuration is\n- * complete. Optional.\n- * scope - {Object} Optional scope for the callback.\n+ * {String} The WKT string representation of the input geometries\n */\n- configure: function(options) {\n- this.describe({\n- callback: function() {\n- var description = this.description,\n- inputs = options.inputs,\n- input, i, ii;\n- for (i = 0, ii = description.dataInputs.length; i < ii; ++i) {\n- input = description.dataInputs[i];\n- this.setInputData(input, inputs[input.identifier]);\n- }\n- if (options.callback) {\n- options.callback.call(options.scope);\n- }\n- },\n- scope: this\n- });\n- return this;\n+ write: function(features) {\n+ var collection, geometry, isCollection;\n+ if (features.constructor == Array) {\n+ collection = features;\n+ isCollection = true;\n+ } else {\n+ collection = [features];\n+ isCollection = false;\n+ }\n+ var pieces = [];\n+ if (isCollection) {\n+ pieces.push('GEOMETRYCOLLECTION(');\n+ }\n+ for (var i = 0, len = collection.length; i < len; ++i) {\n+ if (isCollection && i > 0) {\n+ pieces.push(',');\n+ }\n+ geometry = collection[i].geometry;\n+ pieces.push(this.extractGeometry(geometry));\n+ }\n+ if (isCollection) {\n+ pieces.push(')');\n+ }\n+ return pieces.join('');\n },\n \n /**\n- * APIMethod: execute\n- * Configures and executes the process\n+ * Method: extractGeometry\n+ * Entry point to construct the WKT for a single Geometry object.\n *\n * Parameters:\n- * options - {Object}\n+ * geometry - {}\n *\n- * Available options:\n- * inputs - {Object} The inputs for the process, keyed by input identifier.\n- * For spatial data inputs, the value of an input is usually an\n- * , an or an array of\n- * geometries or features.\n- * output - {String} The identifier of the output to request and parse.\n- * Optional. If not provided, the first output will be requested.\n- * success - {Function} Callback to call when the process is complete.\n- * This function is called with an outputs object as argument, which\n- * will have a property with the identifier of the requested output\n- * (or 'result' if output was not configured). For processes that\n- * generate spatial output, the value will be an array of\n- * instances.\n- * scope - {Object} Optional scope for the success callback.\n+ * Returns:\n+ * {String} A WKT string of representing the geometry\n */\n- execute: function(options) {\n- this.configure({\n- inputs: options.inputs,\n- callback: function() {\n- var me = this;\n- //TODO For now we only deal with a single output\n- var outputIndex = this.getOutputIndex(\n- me.description.processOutputs, options.output\n- );\n- me.setResponseForm({\n- outputIndex: outputIndex\n- });\n- (function callback() {\n- OpenLayers.Util.removeItem(me.executeCallbacks, callback);\n- if (me.chained !== 0) {\n- // need to wait until chained processes have a\n- // description and configuration - see chainProcess\n- me.executeCallbacks.push(callback);\n- return;\n- }\n- // all chained processes are added as references now, so\n- // let's proceed.\n- OpenLayers.Request.POST({\n- url: me.client.servers[me.server].url,\n- data: new OpenLayers.Format.WPSExecute().write(me.description),\n- success: function(response) {\n- var output = me.description.processOutputs[outputIndex];\n- var mimeType = me.findMimeType(\n- output.complexOutput.supported.formats\n- );\n- //TODO For now we assume a spatial output\n- var features = me.formats[mimeType].read(response.responseText);\n- if (features instanceof OpenLayers.Feature.Vector) {\n- features = [features];\n- }\n- if (options.success) {\n- var outputs = {};\n- outputs[options.output || 'result'] = features;\n- options.success.call(options.scope, outputs);\n- }\n- },\n- scope: me\n- });\n- })();\n- },\n- scope: this\n- });\n+ extractGeometry: function(geometry) {\n+ var type = geometry.CLASS_NAME.split('.')[2].toLowerCase();\n+ if (!this.extract[type]) {\n+ return null;\n+ }\n+ if (this.internalProjection && this.externalProjection) {\n+ geometry = geometry.clone();\n+ geometry.transform(this.internalProjection, this.externalProjection);\n+ }\n+ var wktType = type == 'collection' ? 'GEOMETRYCOLLECTION' : type.toUpperCase();\n+ var data = wktType + '(' + this.extract[type].apply(this, [geometry]) + ')';\n+ return data;\n },\n \n /**\n- * APIMethod: output\n- * Chain an output of a configured process (see ) as input to\n- * another process.\n- *\n- * (code)\n- * intersect = client.getProcess('opengeo', 'JTS:intersection'); \n- * intersect.configure({\n- * // ...\n- * });\n- * buffer = client.getProcess('opengeo', 'JTS:buffer');\n- * buffer.execute({\n- * inputs: {\n- * geom: intersect.output('result'), // <-- here we're chaining\n- * distance: 1\n- * },\n- * // ...\n- * });\n- * (end)\n- *\n- * Parameters:\n- * identifier - {String} Identifier of the output that we're chaining. If\n- * not provided, the first output will be used.\n+ * Object with properties corresponding to the geometry types.\n+ * Property values are functions that do the actual data extraction.\n */\n- output: function(identifier) {\n- return new OpenLayers.WPSProcess.ChainLink({\n- process: this,\n- output: identifier\n- });\n- },\n+ extract: {\n+ /**\n+ * Return a space delimited string of point coordinates.\n+ * @param {OpenLayers.Geometry.Point} point\n+ * @returns {String} A string of coordinates representing the point\n+ */\n+ 'point': function(point) {\n+ return point.x + ' ' + point.y;\n+ },\n \n- /**\n- * Method: parseDescription\n- * Parses the DescribeProcess response\n- *\n- * Parameters:\n- * description - {Object}\n- */\n- parseDescription: function(description) {\n- var server = this.client.servers[this.server];\n- this.description = new OpenLayers.Format.WPSDescribeProcess()\n- .read(server.processDescription[this.identifier])\n- .processDescriptions[this.identifier];\n- },\n+ /**\n+ * Return a comma delimited string of point coordinates from a multipoint.\n+ * @param {OpenLayers.Geometry.MultiPoint} multipoint\n+ * @returns {String} A string of point coordinate strings representing\n+ * the multipoint\n+ */\n+ 'multipoint': function(multipoint) {\n+ var array = [];\n+ for (var i = 0, len = multipoint.components.length; i < len; ++i) {\n+ array.push('(' +\n+ this.extract.point.apply(this, [multipoint.components[i]]) +\n+ ')');\n+ }\n+ return array.join(',');\n+ },\n \n- /**\n- * Method: setInputData\n- * Sets the data for a single input\n- *\n- * Parameters:\n- * input - {Object} An entry from the dataInputs array of the process\n- * description.\n- * data - {Mixed} For spatial data inputs, this is usually an\n- * , an or an array of\n- * geometries or features.\n- */\n- setInputData: function(input, data) {\n- // clear any previous data\n- delete input.data;\n- delete input.reference;\n- if (data instanceof OpenLayers.WPSProcess.ChainLink) {\n- ++this.chained;\n- input.reference = {\n- method: 'POST',\n- href: data.process.server === this.server ?\n- this.localWPS : this.client.servers[data.process.server].url\n- };\n- data.process.describe({\n- callback: function() {\n- --this.chained;\n- this.chainProcess(input, data);\n- },\n- scope: this\n- });\n- } else {\n- input.data = {};\n- var complexData = input.complexData;\n- if (complexData) {\n- var format = this.findMimeType(complexData.supported.formats);\n- input.data.complexData = {\n- mimeType: format,\n- value: this.formats[format].write(this.toFeatures(data))\n- };\n- } else {\n- input.data.literalData = {\n- value: data\n- };\n+ /**\n+ * Return a comma delimited string of point coordinates from a line.\n+ * @param {OpenLayers.Geometry.LineString} linestring\n+ * @returns {String} A string of point coordinate strings representing\n+ * the linestring\n+ */\n+ 'linestring': function(linestring) {\n+ var array = [];\n+ for (var i = 0, len = linestring.components.length; i < len; ++i) {\n+ array.push(this.extract.point.apply(this, [linestring.components[i]]));\n }\n- }\n- },\n+ return array.join(',');\n+ },\n \n- /**\n- * Method: setResponseForm\n- * Sets the responseForm property of the payload.\n- *\n- * Parameters:\n- * options - {Object} See below.\n- *\n- * Available options:\n- * outputIndex - {Integer} The index of the output to use. Optional.\n- * supportedFormats - {Object} Object with supported mime types as key,\n- * and true as value for supported types. Optional.\n- */\n- setResponseForm: function(options) {\n- options = options || {};\n- var output = this.description.processOutputs[options.outputIndex || 0];\n- this.description.responseForm = {\n- rawDataOutput: {\n- identifier: output.identifier,\n- mimeType: this.findMimeType(output.complexOutput.supported.formats, options.supportedFormats)\n+ /**\n+ * Return a comma delimited string of linestring strings from a multilinestring.\n+ * @param {OpenLayers.Geometry.MultiLineString} multilinestring\n+ * @returns {String} A string of of linestring strings representing\n+ * the multilinestring\n+ */\n+ 'multilinestring': function(multilinestring) {\n+ var array = [];\n+ for (var i = 0, len = multilinestring.components.length; i < len; ++i) {\n+ array.push('(' +\n+ this.extract.linestring.apply(this, [multilinestring.components[i]]) +\n+ ')');\n }\n- };\n- },\n+ return array.join(',');\n+ },\n \n- /**\n- * Method: getOutputIndex\n- * Gets the index of a processOutput by its identifier\n- *\n- * Parameters:\n- * outputs - {Array} The processOutputs array to look at\n- * identifier - {String} The identifier of the output\n- *\n- * Returns\n- * {Integer} The index of the processOutput with the provided identifier\n- * in the outputs array.\n- */\n- getOutputIndex: function(outputs, identifier) {\n- var output;\n- if (identifier) {\n- for (var i = outputs.length - 1; i >= 0; --i) {\n- if (outputs[i].identifier === identifier) {\n- output = i;\n- break;\n- }\n+ /**\n+ * Return a comma delimited string of linear ring arrays from a polygon.\n+ * @param {OpenLayers.Geometry.Polygon} polygon\n+ * @returns {String} An array of linear ring arrays representing the polygon\n+ */\n+ 'polygon': function(polygon) {\n+ var array = [];\n+ for (var i = 0, len = polygon.components.length; i < len; ++i) {\n+ array.push('(' +\n+ this.extract.linestring.apply(this, [polygon.components[i]]) +\n+ ')');\n }\n- } else {\n- output = 0;\n- }\n- return output;\n- },\n+ return array.join(',');\n+ },\n \n- /**\n- * Method: chainProcess\n- * Sets a fully configured chained process as input for this process.\n- *\n- * Parameters:\n- * input - {Object} The dataInput that the chained process provides.\n- * chainLink - {} The process to chain.\n- */\n- chainProcess: function(input, chainLink) {\n- var output = this.getOutputIndex(\n- chainLink.process.description.processOutputs, chainLink.output\n- );\n- input.reference.mimeType = this.findMimeType(\n- input.complexData.supported.formats,\n- chainLink.process.description.processOutputs[output].complexOutput.supported.formats\n- );\n- var formats = {};\n- formats[input.reference.mimeType] = true;\n- chainLink.process.setResponseForm({\n- outputIndex: output,\n- supportedFormats: formats\n- });\n- input.reference.body = chainLink.process.description;\n- while (this.executeCallbacks.length > 0) {\n- this.executeCallbacks[0]();\n- }\n- },\n+ /**\n+ * Return an array of polygon arrays from a multipolygon.\n+ * @param {OpenLayers.Geometry.MultiPolygon} multipolygon\n+ * @returns {String} An array of polygon arrays representing\n+ * the multipolygon\n+ */\n+ 'multipolygon': function(multipolygon) {\n+ var array = [];\n+ for (var i = 0, len = multipolygon.components.length; i < len; ++i) {\n+ array.push('(' +\n+ this.extract.polygon.apply(this, [multipolygon.components[i]]) +\n+ ')');\n+ }\n+ return array.join(',');\n+ },\n \n- /**\n- * Method: toFeatures\n- * Converts spatial input into features so it can be processed by\n- * instances.\n- *\n- * Parameters:\n- * source - {Mixed} An , an\n- * , or an array of geometries or features\n- *\n- * Returns:\n- * {Array()}\n- */\n- toFeatures: function(source) {\n- var isArray = OpenLayers.Util.isArray(source);\n- if (!isArray) {\n- source = [source];\n- }\n- var target = new Array(source.length),\n- current;\n- for (var i = 0, ii = source.length; i < ii; ++i) {\n- current = source[i];\n- target[i] = current instanceof OpenLayers.Feature.Vector ?\n- current : new OpenLayers.Feature.Vector(current);\n+ /**\n+ * Return the WKT portion between 'GEOMETRYCOLLECTION(' and ')' for an \n+ * @param {OpenLayers.Geometry.Collection} collection\n+ * @returns {String} internal WKT representation of the collection\n+ */\n+ 'collection': function(collection) {\n+ var array = [];\n+ for (var i = 0, len = collection.components.length; i < len; ++i) {\n+ array.push(this.extractGeometry.apply(this, [collection.components[i]]));\n+ }\n+ return array.join(',');\n }\n- return isArray ? target : target[0];\n+\n },\n \n /**\n- * Method: findMimeType\n- * Finds a supported mime type.\n- *\n- * Parameters:\n- * sourceFormats - {Object} An object literal with mime types as key and\n- * true as value for supported formats.\n- * targetFormats - {Object} Like , but optional to check for\n- * supported mime types on a different target than this process.\n- * Default is to check against this process's supported formats.\n- *\n- * Returns:\n- * {String} A supported mime type.\n+ * Object with properties corresponding to the geometry types.\n+ * Property values are functions that do the actual parsing.\n */\n- findMimeType: function(sourceFormats, targetFormats) {\n- targetFormats = targetFormats || this.formats;\n- for (var f in sourceFormats) {\n- if (f in targetFormats) {\n- return f;\n+ parse: {\n+ /**\n+ * Return point feature given a point WKT fragment.\n+ * @param {String} str A WKT fragment representing the point\n+ * @returns {OpenLayers.Feature.Vector} A point feature\n+ * @private\n+ */\n+ 'point': function(str) {\n+ var coords = OpenLayers.String.trim(str).split(this.regExes.spaces);\n+ return new OpenLayers.Feature.Vector(\n+ new OpenLayers.Geometry.Point(coords[0], coords[1])\n+ );\n+ },\n+\n+ /**\n+ * Return a multipoint feature given a multipoint WKT fragment.\n+ * @param {String} str A WKT fragment representing the multipoint\n+ * @returns {OpenLayers.Feature.Vector} A multipoint feature\n+ * @private\n+ */\n+ 'multipoint': function(str) {\n+ var point;\n+ var points = OpenLayers.String.trim(str).split(',');\n+ var components = [];\n+ for (var i = 0, len = points.length; i < len; ++i) {\n+ point = points[i].replace(this.regExes.trimParens, '$1');\n+ components.push(this.parse.point.apply(this, [point]).geometry);\n }\n- }\n- },\n+ return new OpenLayers.Feature.Vector(\n+ new OpenLayers.Geometry.MultiPoint(components)\n+ );\n+ },\n \n- CLASS_NAME: \"OpenLayers.WPSProcess\"\n+ /**\n+ * Return a linestring feature given a linestring WKT fragment.\n+ * @param {String} str A WKT fragment representing the linestring\n+ * @returns {OpenLayers.Feature.Vector} A linestring feature\n+ * @private\n+ */\n+ 'linestring': function(str) {\n+ var points = OpenLayers.String.trim(str).split(',');\n+ var components = [];\n+ for (var i = 0, len = points.length; i < len; ++i) {\n+ components.push(this.parse.point.apply(this, [points[i]]).geometry);\n+ }\n+ return new OpenLayers.Feature.Vector(\n+ new OpenLayers.Geometry.LineString(components)\n+ );\n+ },\n \n-});\n+ /**\n+ * Return a multilinestring feature given a multilinestring WKT fragment.\n+ * @param {String} str A WKT fragment representing the multilinestring\n+ * @returns {OpenLayers.Feature.Vector} A multilinestring feature\n+ * @private\n+ */\n+ 'multilinestring': function(str) {\n+ var line;\n+ var lines = OpenLayers.String.trim(str).split(this.regExes.parenComma);\n+ var components = [];\n+ for (var i = 0, len = lines.length; i < len; ++i) {\n+ line = lines[i].replace(this.regExes.trimParens, '$1');\n+ components.push(this.parse.linestring.apply(this, [line]).geometry);\n+ }\n+ return new OpenLayers.Feature.Vector(\n+ new OpenLayers.Geometry.MultiLineString(components)\n+ );\n+ },\n \n-/**\n- * Class: OpenLayers.WPSProcess.ChainLink\n- * Type for chaining processes.\n- */\n-OpenLayers.WPSProcess.ChainLink = OpenLayers.Class({\n+ /**\n+ * Return a polygon feature given a polygon WKT fragment.\n+ * @param {String} str A WKT fragment representing the polygon\n+ * @returns {OpenLayers.Feature.Vector} A polygon feature\n+ * @private\n+ */\n+ 'polygon': function(str) {\n+ var ring, linestring, linearring;\n+ var rings = OpenLayers.String.trim(str).split(this.regExes.parenComma);\n+ var components = [];\n+ for (var i = 0, len = rings.length; i < len; ++i) {\n+ ring = rings[i].replace(this.regExes.trimParens, '$1');\n+ linestring = this.parse.linestring.apply(this, [ring]).geometry;\n+ linearring = new OpenLayers.Geometry.LinearRing(linestring.components);\n+ components.push(linearring);\n+ }\n+ return new OpenLayers.Feature.Vector(\n+ new OpenLayers.Geometry.Polygon(components)\n+ );\n+ },\n \n- /**\n- * Property: process\n- * {} The process to chain\n- */\n- process: null,\n+ /**\n+ * Return a multipolygon feature given a multipolygon WKT fragment.\n+ * @param {String} str A WKT fragment representing the multipolygon\n+ * @returns {OpenLayers.Feature.Vector} A multipolygon feature\n+ * @private\n+ */\n+ 'multipolygon': function(str) {\n+ var polygon;\n+ var polygons = OpenLayers.String.trim(str).split(this.regExes.doubleParenComma);\n+ var components = [];\n+ for (var i = 0, len = polygons.length; i < len; ++i) {\n+ polygon = polygons[i].replace(this.regExes.trimParens, '$1');\n+ components.push(this.parse.polygon.apply(this, [polygon]).geometry);\n+ }\n+ return new OpenLayers.Feature.Vector(\n+ new OpenLayers.Geometry.MultiPolygon(components)\n+ );\n+ },\n \n- /**\n- * Property: output\n- * {String} The output identifier of the output we are going to use as\n- * input for another process.\n- */\n- output: null,\n+ /**\n+ * Return an array of features given a geometrycollection WKT fragment.\n+ * @param {String} str A WKT fragment representing the geometrycollection\n+ * @returns {Array} An array of OpenLayers.Feature.Vector\n+ * @private\n+ */\n+ 'geometrycollection': function(str) {\n+ // separate components of the collection with |\n+ str = str.replace(/,\\s*([A-Za-z])/g, '|$1');\n+ var wktArray = OpenLayers.String.trim(str).split('|');\n+ var components = [];\n+ for (var i = 0, len = wktArray.length; i < len; ++i) {\n+ components.push(OpenLayers.Format.WKT.prototype.read.apply(this, [wktArray[i]]));\n+ }\n+ return components;\n+ }\n \n- /**\n- * Constructor: OpenLayers.WPSProcess.ChainLink\n- *\n- * Parameters:\n- * options - {Object} Properties to set on the instance.\n- */\n- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n },\n \n- CLASS_NAME: \"OpenLayers.WPSProcess.ChainLink\"\n-\n+ CLASS_NAME: \"OpenLayers.Format.WKT\"\n });\n /* ======================================================================\n- OpenLayers/Popup.js\n+ OpenLayers/Format/JSON.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/BaseTypes/Class.js\n+ * Note:\n+ * This work draws heavily from the public domain JSON serializer/deserializer\n+ * at http://www.json.org/json.js. Rewritten so that it doesn't modify\n+ * basic data prototypes.\n */\n \n+/**\n+ * @requires OpenLayers/Format.js\n+ */\n \n /**\n- * Class: OpenLayers.Popup\n- * A popup is a small div that can opened and closed on the map.\n- * Typically opened in response to clicking on a marker. \n- * See . Popup's don't require their own\n- * layer and are added the the map using the \n- * method.\n+ * Class: OpenLayers.Format.JSON\n+ * A parser to read/write JSON safely. Create a new instance with the\n+ * constructor.\n *\n- * Example:\n- * (code)\n- * popup = new OpenLayers.Popup(\"chicken\", \n- * new OpenLayers.LonLat(5,40),\n- * new OpenLayers.Size(200,200),\n- * \"example popup\",\n- * true);\n- * \n- * map.addPopup(popup);\n- * (end)\n+ * Inherits from:\n+ * - \n */\n-OpenLayers.Popup = OpenLayers.Class({\n-\n- /** \n- * Property: events \n- * {} custom event manager \n- */\n- events: null,\n-\n- /** Property: id\n- * {String} the unique identifier assigned to this popup.\n- */\n- id: \"\",\n-\n- /** \n- * Property: lonlat \n- * {} the position of this popup on the map\n- */\n- lonlat: null,\n-\n- /** \n- * Property: div \n- * {DOMElement} the div that contains this popup.\n- */\n- div: null,\n-\n- /** \n- * Property: contentSize \n- * {} the width and height of the content.\n- */\n- contentSize: null,\n-\n- /** \n- * Property: size \n- * {} the width and height of the popup.\n- */\n- size: null,\n-\n- /** \n- * Property: contentHTML \n- * {String} An HTML string for this popup to display.\n- */\n- contentHTML: null,\n-\n- /** \n- * Property: backgroundColor \n- * {String} the background color used by the popup.\n- */\n- backgroundColor: \"\",\n-\n- /** \n- * Property: opacity \n- * {float} the opacity of this popup (between 0.0 and 1.0)\n- */\n- opacity: \"\",\n-\n- /** \n- * Property: border \n- * {String} the border size of the popup. (eg 2px)\n- */\n- border: \"\",\n-\n- /** \n- * Property: contentDiv \n- * {DOMElement} a reference to the element that holds the content of\n- * the div.\n- */\n- contentDiv: null,\n-\n- /** \n- * Property: groupDiv \n- * {DOMElement} First and only child of 'div'. The group Div contains the\n- * 'contentDiv' and the 'closeDiv'.\n- */\n- groupDiv: null,\n-\n- /** \n- * Property: closeDiv\n- * {DOMElement} the optional closer image\n- */\n- closeDiv: null,\n-\n- /** \n- * APIProperty: autoSize\n- * {Boolean} Resize the popup to auto-fit the contents.\n- * Default is false.\n- */\n- autoSize: false,\n+OpenLayers.Format.JSON = OpenLayers.Class(OpenLayers.Format, {\n \n /**\n- * APIProperty: minSize\n- * {} Minimum size allowed for the popup's contents.\n+ * APIProperty: indent\n+ * {String} For \"pretty\" printing, the indent string will be used once for\n+ * each indentation level.\n */\n- minSize: null,\n+ indent: \" \",\n \n /**\n- * APIProperty: maxSize\n- * {} Maximum size allowed for the popup's contents.\n- */\n- maxSize: null,\n-\n- /** \n- * Property: displayClass\n- * {String} The CSS class of the popup.\n- */\n- displayClass: \"olPopup\",\n-\n- /** \n- * Property: contentDisplayClass\n- * {String} The CSS class of the popup content div.\n- */\n- contentDisplayClass: \"olPopupContent\",\n-\n- /** \n- * Property: padding \n- * {int or } An extra opportunity to specify internal \n- * padding of the content div inside the popup. This was originally\n- * confused with the css padding as specified in style.css's \n- * 'olPopupContent' class. We would like to get rid of this altogether,\n- * except that it does come in handy for the framed and anchoredbubble\n- * popups, who need to maintain yet another barrier between their \n- * content and the outer border of the popup itself. \n- * \n- * Note that in order to not break API, we must continue to support \n- * this property being set as an integer. Really, though, we'd like to \n- * have this specified as a Bounds object so that user can specify\n- * distinct left, top, right, bottom paddings. With the 3.0 release\n- * we can make this only a bounds.\n- */\n- padding: 0,\n-\n- /** \n- * Property: disableFirefoxOverflowHack\n- * {Boolean} The hack for overflow in Firefox causes all elements \n- * to be re-drawn, which causes Flash elements to be \n- * re-initialized, which is troublesome.\n- * With this property the hack can be disabled.\n+ * APIProperty: space\n+ * {String} For \"pretty\" printing, the space string will be used after\n+ * the \":\" separating a name/value pair.\n */\n- disableFirefoxOverflowHack: false,\n+ space: \" \",\n \n /**\n- * Method: fixPadding\n- * To be removed in 3.0, this function merely helps us to deal with the \n- * case where the user may have set an integer value for padding, \n- * instead of an object.\n+ * APIProperty: newline\n+ * {String} For \"pretty\" printing, the newline string will be used at the\n+ * end of each name/value pair or array item.\n */\n- fixPadding: function() {\n- if (typeof this.padding == \"number\") {\n- this.padding = new OpenLayers.Bounds(\n- this.padding, this.padding, this.padding, this.padding\n- );\n- }\n- },\n+ newline: \"\\n\",\n \n /**\n- * APIProperty: panMapIfOutOfView\n- * {Boolean} When drawn, pan map such that the entire popup is visible in\n- * the current viewport (if necessary).\n- * Default is false.\n+ * Property: level\n+ * {Integer} For \"pretty\" printing, this is incremented/decremented during\n+ * serialization.\n */\n- panMapIfOutOfView: false,\n+ level: 0,\n \n /**\n- * APIProperty: keepInMap \n- * {Boolean} If panMapIfOutOfView is false, and this property is true, \n- * contrain the popup such that it always fits in the available map\n- * space. By default, this is not set on the base class. If you are\n- * creating popups that are near map edges and not allowing pannning,\n- * and especially if you have a popup which has a\n- * fixedRelativePosition, setting this to false may be a smart thing to\n- * do. Subclasses may want to override this setting.\n- * \n- * Default is false.\n+ * Property: pretty\n+ * {Boolean} Serialize with extra whitespace for structure. This is set\n+ * by the method.\n */\n- keepInMap: false,\n+ pretty: false,\n \n /**\n- * APIProperty: closeOnMove\n- * {Boolean} When map pans, close the popup.\n- * Default is false.\n- */\n- closeOnMove: false,\n-\n- /** \n- * Property: map \n- * {} this gets set in Map.js when the popup is added to the map\n- */\n- map: null,\n-\n- /** \n- * Constructor: OpenLayers.Popup\n- * Create a popup.\n- * \n- * Parameters: \n- * id - {String} a unqiue identifier for this popup. If null is passed\n- * an identifier will be automatically generated. \n- * lonlat - {} The position on the map the popup will\n- * be shown.\n- * contentSize - {} The size of the content.\n- * contentHTML - {String} An HTML string to display inside the \n- * popup.\n- * closeBox - {Boolean} Whether to display a close box inside\n- * the popup.\n- * closeBoxCallback - {Function} Function to be called on closeBox click.\n+ * Property: nativeJSON\n+ * {Boolean} Does the browser support native json?\n */\n- initialize: function(id, lonlat, contentSize, contentHTML, closeBox, closeBoxCallback) {\n- if (id == null) {\n- id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n- }\n-\n- this.id = id;\n- this.lonlat = lonlat;\n-\n- this.contentSize = (contentSize != null) ? contentSize :\n- new OpenLayers.Size(\n- OpenLayers.Popup.WIDTH,\n- OpenLayers.Popup.HEIGHT);\n- if (contentHTML != null) {\n- this.contentHTML = contentHTML;\n- }\n- this.backgroundColor = OpenLayers.Popup.COLOR;\n- this.opacity = OpenLayers.Popup.OPACITY;\n- this.border = OpenLayers.Popup.BORDER;\n-\n- this.div = OpenLayers.Util.createDiv(this.id, null, null,\n- null, null, null, \"hidden\");\n- this.div.className = this.displayClass;\n-\n- var groupDivId = this.id + \"_GroupDiv\";\n- this.groupDiv = OpenLayers.Util.createDiv(groupDivId, null, null,\n- null, \"relative\", null,\n- \"hidden\");\n-\n- var id = this.div.id + \"_contentDiv\";\n- this.contentDiv = OpenLayers.Util.createDiv(id, null, this.contentSize.clone(),\n- null, \"relative\");\n- this.contentDiv.className = this.contentDisplayClass;\n- this.groupDiv.appendChild(this.contentDiv);\n- this.div.appendChild(this.groupDiv);\n-\n- if (closeBox) {\n- this.addCloseBox(closeBoxCallback);\n- }\n-\n- this.registerEvents();\n- },\n+ nativeJSON: (function() {\n+ return !!(window.JSON && typeof JSON.parse == \"function\" && typeof JSON.stringify == \"function\");\n+ })(),\n \n- /** \n- * Method: destroy\n- * nullify references to prevent circular references and memory leaks\n+ /**\n+ * Constructor: OpenLayers.Format.JSON\n+ * Create a new parser for JSON.\n+ *\n+ * Parameters:\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n */\n- destroy: function() {\n-\n- this.id = null;\n- this.lonlat = null;\n- this.size = null;\n- this.contentHTML = null;\n-\n- this.backgroundColor = null;\n- this.opacity = null;\n- this.border = null;\n-\n- if (this.closeOnMove && this.map) {\n- this.map.events.unregister(\"movestart\", this, this.hide);\n- }\n-\n- this.events.destroy();\n- this.events = null;\n-\n- if (this.closeDiv) {\n- OpenLayers.Event.stopObservingElement(this.closeDiv);\n- this.groupDiv.removeChild(this.closeDiv);\n- }\n- this.closeDiv = null;\n-\n- this.div.removeChild(this.groupDiv);\n- this.groupDiv = null;\n-\n- if (this.map != null) {\n- this.map.removePopup(this);\n- }\n- this.map = null;\n- this.div = null;\n-\n- this.autoSize = null;\n- this.minSize = null;\n- this.maxSize = null;\n- this.padding = null;\n- this.panMapIfOutOfView = null;\n- },\n \n- /** \n- * Method: draw\n- * Constructs the elements that make up the popup.\n+ /**\n+ * APIMethod: read\n+ * Deserialize a json string.\n *\n * Parameters:\n- * px - {} the position the popup in pixels.\n- * \n+ * json - {String} A JSON string\n+ * filter - {Function} A function which will be called for every key and\n+ * value at every level of the final result. Each value will be\n+ * replaced by the result of the filter function. This can be used to\n+ * reform generic objects into instances of classes, or to transform\n+ * date strings into Date objects.\n+ * \n * Returns:\n- * {DOMElement} Reference to a div that contains the drawn popup\n+ * {Object} An object, array, string, or number .\n */\n- draw: function(px) {\n- if (px == null) {\n- if ((this.lonlat != null) && (this.map != null)) {\n- px = this.map.getLayerPxFromLonLat(this.lonlat);\n- }\n- }\n+ read: function(json, filter) {\n+ var object;\n+ if (this.nativeJSON) {\n+ object = JSON.parse(json, filter);\n+ } else try {\n+ /**\n+ * Parsing happens in three stages. In the first stage, we run the\n+ * text against a regular expression which looks for non-JSON\n+ * characters. We are especially concerned with '()' and 'new'\n+ * because they can cause invocation, and '=' because it can\n+ * cause mutation. But just to be safe, we will reject all\n+ * unexpected characters.\n+ */\n+ if (/^[\\],:{}\\s]*$/.test(json.replace(/\\\\[\"\\\\\\/bfnrtu]/g, '@').replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']').replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n \n- // this assumes that this.map already exists, which is okay because \n- // this.draw is only called once the popup has been added to the map.\n- if (this.closeOnMove) {\n- this.map.events.register(\"movestart\", this, this.hide);\n- }\n+ /**\n+ * In the second stage we use the eval function to compile the\n+ * text into a JavaScript structure. The '{' operator is\n+ * subject to a syntactic ambiguity in JavaScript - it can\n+ * begin a block or an object literal. We wrap the text in\n+ * parens to eliminate the ambiguity.\n+ */\n+ object = eval('(' + json + ')');\n \n- //listen to movestart, moveend to disable overflow (FF bug)\n- if (!this.disableFirefoxOverflowHack && OpenLayers.BROWSER_NAME == 'firefox') {\n- this.map.events.register(\"movestart\", this, function() {\n- var style = document.defaultView.getComputedStyle(\n- this.contentDiv, null\n- );\n- var currentOverflow = style.getPropertyValue(\"overflow\");\n- if (currentOverflow != \"hidden\") {\n- this.contentDiv._oldOverflow = currentOverflow;\n- this.contentDiv.style.overflow = \"hidden\";\n- }\n- });\n- this.map.events.register(\"moveend\", this, function() {\n- var oldOverflow = this.contentDiv._oldOverflow;\n- if (oldOverflow) {\n- this.contentDiv.style.overflow = oldOverflow;\n- this.contentDiv._oldOverflow = null;\n+ /**\n+ * In the optional third stage, we recursively walk the new\n+ * structure, passing each name/value pair to a filter\n+ * function for possible transformation.\n+ */\n+ if (typeof filter === 'function') {\n+ function walk(k, v) {\n+ if (v && typeof v === 'object') {\n+ for (var i in v) {\n+ if (v.hasOwnProperty(i)) {\n+ v[i] = walk(i, v[i]);\n+ }\n+ }\n+ }\n+ return filter(k, v);\n+ }\n+ object = walk('', object);\n }\n- });\n- }\n-\n- this.moveTo(px);\n- if (!this.autoSize && !this.size) {\n- this.setSize(this.contentSize);\n+ }\n+ } catch (e) {\n+ // Fall through if the regexp test fails.\n }\n- this.setBackgroundColor();\n- this.setOpacity();\n- this.setBorder();\n- this.setContentHTML();\n \n- if (this.panMapIfOutOfView) {\n- this.panIntoView();\n+ if (this.keepData) {\n+ this.data = object;\n }\n \n- return this.div;\n- },\n-\n- /** \n- * Method: updatePosition\n- * if the popup has a lonlat and its map members set, \n- * then have it move itself to its proper position\n- */\n- updatePosition: function() {\n- if ((this.lonlat) && (this.map)) {\n- var px = this.map.getLayerPxFromLonLat(this.lonlat);\n- if (px) {\n- this.moveTo(px);\n- }\n- }\n+ return object;\n },\n \n /**\n- * Method: moveTo\n- * \n+ * APIMethod: write\n+ * Serialize an object into a JSON string.\n+ *\n * Parameters:\n- * px - {} the top and left position of the popup div. \n+ * value - {String} The object, array, string, number, boolean or date\n+ * to be serialized.\n+ * pretty - {Boolean} Structure the output with newlines and indentation.\n+ * Default is false.\n+ *\n+ * Returns:\n+ * {String} The JSON string representation of the input value.\n */\n- moveTo: function(px) {\n- if ((px != null) && (this.div != null)) {\n- this.div.style.left = px.x + \"px\";\n- this.div.style.top = px.y + \"px\";\n+ write: function(value, pretty) {\n+ this.pretty = !!pretty;\n+ var json = null;\n+ var type = typeof value;\n+ if (this.serialize[type]) {\n+ try {\n+ json = (!this.pretty && this.nativeJSON) ?\n+ JSON.stringify(value) :\n+ this.serialize[type].apply(this, [value]);\n+ } catch (err) {\n+ OpenLayers.Console.error(\"Trouble serializing: \" + err);\n+ }\n }\n+ return json;\n },\n \n /**\n- * Method: visible\n+ * Method: writeIndent\n+ * Output an indentation string depending on the indentation level.\n *\n- * Returns: \n- * {Boolean} Boolean indicating whether or not the popup is visible\n- */\n- visible: function() {\n- return OpenLayers.Element.visible(this.div);\n- },\n-\n- /**\n- * Method: toggle\n- * Toggles visibility of the popup.\n+ * Returns:\n+ * {String} An appropriate indentation string.\n */\n- toggle: function() {\n- if (this.visible()) {\n- this.hide();\n- } else {\n- this.show();\n+ writeIndent: function() {\n+ var pieces = [];\n+ if (this.pretty) {\n+ for (var i = 0; i < this.level; ++i) {\n+ pieces.push(this.indent);\n+ }\n }\n+ return pieces.join('');\n },\n \n /**\n- * Method: show\n- * Makes the popup visible.\n+ * Method: writeNewline\n+ * Output a string representing a newline if in pretty printing mode.\n+ *\n+ * Returns:\n+ * {String} A string representing a new line.\n */\n- show: function() {\n- this.div.style.display = '';\n-\n- if (this.panMapIfOutOfView) {\n- this.panIntoView();\n- }\n+ writeNewline: function() {\n+ return (this.pretty) ? this.newline : '';\n },\n \n /**\n- * Method: hide\n- * Makes the popup invisible.\n+ * Method: writeSpace\n+ * Output a string representing a space if in pretty printing mode.\n+ *\n+ * Returns:\n+ * {String} A space.\n */\n- hide: function() {\n- this.div.style.display = 'none';\n+ writeSpace: function() {\n+ return (this.pretty) ? this.space : '';\n },\n \n /**\n- * Method: setSize\n- * Used to adjust the size of the popup. \n- *\n- * Parameters:\n- * contentSize - {} the new size for the popup's \n- * contents div (in pixels).\n+ * Property: serialize\n+ * Object with properties corresponding to the serializable data types.\n+ * Property values are functions that do the actual serializing.\n */\n- setSize: function(contentSize) {\n- this.size = contentSize.clone();\n+ serialize: {\n+ /**\n+ * Method: serialize.object\n+ * Transform an object into a JSON string.\n+ *\n+ * Parameters:\n+ * object - {Object} The object to be serialized.\n+ * \n+ * Returns:\n+ * {String} A JSON string representing the object.\n+ */\n+ 'object': function(object) {\n+ // three special objects that we want to treat differently\n+ if (object == null) {\n+ return \"null\";\n+ }\n+ if (object.constructor == Date) {\n+ return this.serialize.date.apply(this, [object]);\n+ }\n+ if (object.constructor == Array) {\n+ return this.serialize.array.apply(this, [object]);\n+ }\n+ var pieces = ['{'];\n+ this.level += 1;\n+ var key, keyJSON, valueJSON;\n \n- // if our contentDiv has a css 'padding' set on it by a stylesheet, we \n- // must add that to the desired \"size\". \n- var contentDivPadding = this.getContentDivPadding();\n- var wPadding = contentDivPadding.left + contentDivPadding.right;\n- var hPadding = contentDivPadding.top + contentDivPadding.bottom;\n+ var addComma = false;\n+ for (key in object) {\n+ if (object.hasOwnProperty(key)) {\n+ // recursive calls need to allow for sub-classing\n+ keyJSON = OpenLayers.Format.JSON.prototype.write.apply(this,\n+ [key, this.pretty]);\n+ valueJSON = OpenLayers.Format.JSON.prototype.write.apply(this,\n+ [object[key], this.pretty]);\n+ if (keyJSON != null && valueJSON != null) {\n+ if (addComma) {\n+ pieces.push(',');\n+ }\n+ pieces.push(this.writeNewline(), this.writeIndent(),\n+ keyJSON, ':', this.writeSpace(), valueJSON);\n+ addComma = true;\n+ }\n+ }\n+ }\n \n- // take into account the popup's 'padding' property\n- this.fixPadding();\n- wPadding += this.padding.left + this.padding.right;\n- hPadding += this.padding.top + this.padding.bottom;\n+ this.level -= 1;\n+ pieces.push(this.writeNewline(), this.writeIndent(), '}');\n+ return pieces.join('');\n+ },\n \n- // make extra space for the close div\n- if (this.closeDiv) {\n- var closeDivWidth = parseInt(this.closeDiv.style.width);\n- wPadding += closeDivWidth + contentDivPadding.right;\n- }\n+ /**\n+ * Method: serialize.array\n+ * Transform an array into a JSON string.\n+ *\n+ * Parameters:\n+ * array - {Array} The array to be serialized\n+ * \n+ * Returns:\n+ * {String} A JSON string representing the array.\n+ */\n+ 'array': function(array) {\n+ var json;\n+ var pieces = ['['];\n+ this.level += 1;\n \n- //increase size of the main popup div to take into account the \n- // users's desired padding and close div. \n- this.size.w += wPadding;\n- this.size.h += hPadding;\n+ for (var i = 0, len = array.length; i < len; ++i) {\n+ // recursive calls need to allow for sub-classing\n+ json = OpenLayers.Format.JSON.prototype.write.apply(this,\n+ [array[i], this.pretty]);\n+ if (json != null) {\n+ if (i > 0) {\n+ pieces.push(',');\n+ }\n+ pieces.push(this.writeNewline(), this.writeIndent(), json);\n+ }\n+ }\n \n- //now if our browser is IE, we need to actually make the contents \n- // div itself bigger to take its own padding into effect. this makes \n- // me want to shoot someone, but so it goes.\n- if (OpenLayers.BROWSER_NAME == \"msie\") {\n- this.contentSize.w +=\n- contentDivPadding.left + contentDivPadding.right;\n- this.contentSize.h +=\n- contentDivPadding.bottom + contentDivPadding.top;\n- }\n+ this.level -= 1;\n+ pieces.push(this.writeNewline(), this.writeIndent(), ']');\n+ return pieces.join('');\n+ },\n \n- if (this.div != null) {\n- this.div.style.width = this.size.w + \"px\";\n- this.div.style.height = this.size.h + \"px\";\n- }\n- if (this.contentDiv != null) {\n- this.contentDiv.style.width = contentSize.w + \"px\";\n- this.contentDiv.style.height = contentSize.h + \"px\";\n- }\n- },\n+ /**\n+ * Method: serialize.string\n+ * Transform a string into a JSON string.\n+ *\n+ * Parameters:\n+ * string - {String} The string to be serialized\n+ * \n+ * Returns:\n+ * {String} A JSON string representing the string.\n+ */\n+ 'string': function(string) {\n+ // If the string contains no control characters, no quote characters, and no\n+ // backslash characters, then we can simply slap some quotes around it.\n+ // Otherwise we must also replace the offending characters with safe\n+ // sequences. \n+ var m = {\n+ '\\b': '\\\\b',\n+ '\\t': '\\\\t',\n+ '\\n': '\\\\n',\n+ '\\f': '\\\\f',\n+ '\\r': '\\\\r',\n+ '\"': '\\\\\"',\n+ '\\\\': '\\\\\\\\'\n+ };\n+ if (/[\"\\\\\\x00-\\x1f]/.test(string)) {\n+ return '\"' + string.replace(/([\\x00-\\x1f\\\\\"])/g, function(a, b) {\n+ var c = m[b];\n+ if (c) {\n+ return c;\n+ }\n+ c = b.charCodeAt();\n+ return '\\\\u00' +\n+ Math.floor(c / 16).toString(16) +\n+ (c % 16).toString(16);\n+ }) + '\"';\n+ }\n+ return '\"' + string + '\"';\n+ },\n \n- /**\n- * APIMethod: updateSize\n- * Auto size the popup so that it precisely fits its contents (as \n- * determined by this.contentDiv.innerHTML). Popup size will, of\n- * course, be limited by the available space on the current map\n- */\n- updateSize: function() {\n+ /**\n+ * Method: serialize.number\n+ * Transform a number into a JSON string.\n+ *\n+ * Parameters:\n+ * number - {Number} The number to be serialized.\n+ *\n+ * Returns:\n+ * {String} A JSON string representing the number.\n+ */\n+ 'number': function(number) {\n+ return isFinite(number) ? String(number) : \"null\";\n+ },\n \n- // determine actual render dimensions of the contents by putting its\n- // contents into a fake contentDiv (for the CSS) and then measuring it\n- var preparedHTML = \"
\" +\n- this.contentDiv.innerHTML +\n- \"
\";\n+ /**\n+ * Method: serialize.boolean\n+ * Transform a boolean into a JSON string.\n+ *\n+ * Parameters:\n+ * bool - {Boolean} The boolean to be serialized.\n+ * \n+ * Returns:\n+ * {String} A JSON string representing the boolean.\n+ */\n+ 'boolean': function(bool) {\n+ return String(bool);\n+ },\n \n- var containerElement = (this.map) ? this.map.div : document.body;\n- var realSize = OpenLayers.Util.getRenderedDimensions(\n- preparedHTML, null, {\n- displayClass: this.displayClass,\n- containerElement: containerElement\n+ /**\n+ * Method: serialize.object\n+ * Transform a date into a JSON string.\n+ *\n+ * Parameters:\n+ * date - {Date} The date to be serialized.\n+ * \n+ * Returns:\n+ * {String} A JSON string representing the date.\n+ */\n+ 'date': function(date) {\n+ function format(number) {\n+ // Format integers to have at least two digits.\n+ return (number < 10) ? '0' + number : number;\n }\n- );\n-\n- // is the \"real\" size of the div is safe to display in our map?\n- var safeSize = this.getSafeContentSize(realSize);\n+ return '\"' + date.getFullYear() + '-' +\n+ format(date.getMonth() + 1) + '-' +\n+ format(date.getDate()) + 'T' +\n+ format(date.getHours()) + ':' +\n+ format(date.getMinutes()) + ':' +\n+ format(date.getSeconds()) + '\"';\n+ }\n+ },\n \n- var newSize = null;\n- if (safeSize.equals(realSize)) {\n- //real size of content is small enough to fit on the map, \n- // so we use real size.\n- newSize = realSize;\n+ CLASS_NAME: \"OpenLayers.Format.JSON\"\n \n- } else {\n+});\n+/* ======================================================================\n+ OpenLayers/Format/GeoJSON.js\n+ ====================================================================== */\n \n- // make a new 'size' object with the clipped dimensions \n- // set or null if not clipped.\n- var fixedSize = {\n- w: (safeSize.w < realSize.w) ? safeSize.w : null,\n- h: (safeSize.h < realSize.h) ? safeSize.h : null\n- };\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- if (fixedSize.w && fixedSize.h) {\n- //content is too big in both directions, so we will use \n- // max popup size (safeSize), knowing well that it will \n- // overflow both ways. \n- newSize = safeSize;\n- } else {\n- //content is clipped in only one direction, so we need to \n- // run getRenderedDimensions() again with a fixed dimension\n- var clippedSize = OpenLayers.Util.getRenderedDimensions(\n- preparedHTML, fixedSize, {\n- displayClass: this.contentDisplayClass,\n- containerElement: containerElement\n- }\n- );\n+/**\n+ * @requires OpenLayers/Format/JSON.js\n+ * @requires OpenLayers/Feature/Vector.js\n+ * @requires OpenLayers/Geometry/Point.js\n+ * @requires OpenLayers/Geometry/MultiPoint.js\n+ * @requires OpenLayers/Geometry/LineString.js\n+ * @requires OpenLayers/Geometry/MultiLineString.js\n+ * @requires OpenLayers/Geometry/Polygon.js\n+ * @requires OpenLayers/Geometry/MultiPolygon.js\n+ * @requires OpenLayers/Console.js\n+ */\n \n- //if the clipped size is still the same as the safeSize, \n- // that means that our content must be fixed in the \n- // offending direction. If overflow is 'auto', this means \n- // we are going to have a scrollbar for sure, so we must \n- // adjust for that.\n- //\n- var currentOverflow = OpenLayers.Element.getStyle(\n- this.contentDiv, \"overflow\"\n- );\n- if ((currentOverflow != \"hidden\") &&\n- (clippedSize.equals(safeSize))) {\n- var scrollBar = OpenLayers.Util.getScrollbarWidth();\n- if (fixedSize.w) {\n- clippedSize.h += scrollBar;\n- } else {\n- clippedSize.w += scrollBar;\n- }\n- }\n+/**\n+ * Class: OpenLayers.Format.GeoJSON\n+ * Read and write GeoJSON. Create a new parser with the\n+ * constructor.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {\n \n- newSize = this.getSafeContentSize(clippedSize);\n- }\n- }\n- this.setSize(newSize);\n- },\n+ /**\n+ * APIProperty: ignoreExtraDims\n+ * {Boolean} Ignore dimensions higher than 2 when reading geometry\n+ * coordinates.\n+ */\n+ ignoreExtraDims: false,\n \n /**\n- * Method: setBackgroundColor\n- * Sets the background color of the popup.\n+ * Constructor: OpenLayers.Format.GeoJSON\n+ * Create a new parser for GeoJSON.\n *\n * Parameters:\n- * color - {String} the background color. eg \"#FFBBBB\"\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n */\n- setBackgroundColor: function(color) {\n- if (color != undefined) {\n- this.backgroundColor = color;\n- }\n-\n- if (this.div != null) {\n- this.div.style.backgroundColor = this.backgroundColor;\n- }\n- },\n \n /**\n- * Method: setOpacity\n- * Sets the opacity of the popup.\n- * \n+ * APIMethod: read\n+ * Deserialize a GeoJSON string.\n+ *\n * Parameters:\n- * opacity - {float} A value between 0.0 (transparent) and 1.0 (solid). \n+ * json - {String} A GeoJSON string\n+ * type - {String} Optional string that determines the structure of\n+ * the output. Supported values are \"Geometry\", \"Feature\", and\n+ * \"FeatureCollection\". If absent or null, a default of\n+ * \"FeatureCollection\" is assumed.\n+ * filter - {Function} A function which will be called for every key and\n+ * value at every level of the final result. Each value will be\n+ * replaced by the result of the filter function. This can be used to\n+ * reform generic objects into instances of classes, or to transform\n+ * date strings into Date objects.\n+ *\n+ * Returns: \n+ * {Object} The return depends on the value of the type argument. If type\n+ * is \"FeatureCollection\" (the default), the return will be an array\n+ * of . If type is \"Geometry\", the input json\n+ * must represent a single geometry, and the return will be an\n+ * . If type is \"Feature\", the input json must\n+ * represent a single feature, and the return will be an\n+ * .\n */\n- setOpacity: function(opacity) {\n- if (opacity != undefined) {\n- this.opacity = opacity;\n+ read: function(json, type, filter) {\n+ type = (type) ? type : \"FeatureCollection\";\n+ var results = null;\n+ var obj = null;\n+ if (typeof json == \"string\") {\n+ obj = OpenLayers.Format.JSON.prototype.read.apply(this,\n+ [json, filter]);\n+ } else {\n+ obj = json;\n }\n-\n- if (this.div != null) {\n- // for Mozilla and Safari\n- this.div.style.opacity = this.opacity;\n-\n- // for IE\n- this.div.style.filter = 'alpha(opacity=' + this.opacity * 100 + ')';\n+ if (!obj) {\n+ OpenLayers.Console.error(\"Bad JSON: \" + json);\n+ } else if (typeof(obj.type) != \"string\") {\n+ OpenLayers.Console.error(\"Bad GeoJSON - no type: \" + json);\n+ } else if (this.isValidType(obj, type)) {\n+ switch (type) {\n+ case \"Geometry\":\n+ try {\n+ results = this.parseGeometry(obj);\n+ } catch (err) {\n+ OpenLayers.Console.error(err);\n+ }\n+ break;\n+ case \"Feature\":\n+ try {\n+ results = this.parseFeature(obj);\n+ results.type = \"Feature\";\n+ } catch (err) {\n+ OpenLayers.Console.error(err);\n+ }\n+ break;\n+ case \"FeatureCollection\":\n+ // for type FeatureCollection, we allow input to be any type\n+ results = [];\n+ switch (obj.type) {\n+ case \"Feature\":\n+ try {\n+ results.push(this.parseFeature(obj));\n+ } catch (err) {\n+ results = null;\n+ OpenLayers.Console.error(err);\n+ }\n+ break;\n+ case \"FeatureCollection\":\n+ for (var i = 0, len = obj.features.length; i < len; ++i) {\n+ try {\n+ results.push(this.parseFeature(obj.features[i]));\n+ } catch (err) {\n+ results = null;\n+ OpenLayers.Console.error(err);\n+ }\n+ }\n+ break;\n+ default:\n+ try {\n+ var geom = this.parseGeometry(obj);\n+ results.push(new OpenLayers.Feature.Vector(geom));\n+ } catch (err) {\n+ results = null;\n+ OpenLayers.Console.error(err);\n+ }\n+ }\n+ break;\n+ }\n }\n+ return results;\n },\n \n /**\n- * Method: setBorder\n- * Sets the border style of the popup.\n+ * Method: isValidType\n+ * Check if a GeoJSON object is a valid representative of the given type.\n *\n- * Parameters:\n- * border - {String} The border style value. eg 2px \n+ * Returns:\n+ * {Boolean} The object is valid GeoJSON object of the given type.\n */\n- setBorder: function(border) {\n- if (border != undefined) {\n- this.border = border;\n- }\n-\n- if (this.div != null) {\n- this.div.style.border = this.border;\n+ isValidType: function(obj, type) {\n+ var valid = false;\n+ switch (type) {\n+ case \"Geometry\":\n+ if (OpenLayers.Util.indexOf(\n+ [\"Point\", \"MultiPoint\", \"LineString\", \"MultiLineString\",\n+ \"Polygon\", \"MultiPolygon\", \"Box\", \"GeometryCollection\"\n+ ],\n+ obj.type) == -1) {\n+ // unsupported geometry type\n+ OpenLayers.Console.error(\"Unsupported geometry type: \" +\n+ obj.type);\n+ } else {\n+ valid = true;\n+ }\n+ break;\n+ case \"FeatureCollection\":\n+ // allow for any type to be converted to a feature collection\n+ valid = true;\n+ break;\n+ default:\n+ // for Feature types must match\n+ if (obj.type == type) {\n+ valid = true;\n+ } else {\n+ OpenLayers.Console.error(\"Cannot convert types from \" +\n+ obj.type + \" to \" + type);\n+ }\n }\n+ return valid;\n },\n \n /**\n- * Method: setContentHTML\n- * Allows the user to set the HTML content of the popup.\n+ * Method: parseFeature\n+ * Convert a feature object from GeoJSON into an\n+ * .\n *\n * Parameters:\n- * contentHTML - {String} HTML for the div.\n+ * obj - {Object} An object created from a GeoJSON object\n+ *\n+ * Returns:\n+ * {} A feature.\n */\n- setContentHTML: function(contentHTML) {\n-\n- if (contentHTML != null) {\n- this.contentHTML = contentHTML;\n+ parseFeature: function(obj) {\n+ var feature, geometry, attributes, bbox;\n+ attributes = (obj.properties) ? obj.properties : {};\n+ bbox = (obj.geometry && obj.geometry.bbox) || obj.bbox;\n+ try {\n+ geometry = this.parseGeometry(obj.geometry);\n+ } catch (err) {\n+ // deal with bad geometries\n+ throw err;\n }\n-\n- if ((this.contentDiv != null) &&\n- (this.contentHTML != null) &&\n- (this.contentHTML != this.contentDiv.innerHTML)) {\n-\n- this.contentDiv.innerHTML = this.contentHTML;\n-\n- if (this.autoSize) {\n-\n- //if popup has images, listen for when they finish\n- // loading and resize accordingly\n- this.registerImageListeners();\n-\n- //auto size the popup to its current contents\n- this.updateSize();\n- }\n+ feature = new OpenLayers.Feature.Vector(geometry, attributes);\n+ if (bbox) {\n+ feature.bounds = OpenLayers.Bounds.fromArray(bbox);\n }\n-\n+ if (obj.id) {\n+ feature.fid = obj.id;\n+ }\n+ return feature;\n },\n \n /**\n- * Method: registerImageListeners\n- * Called when an image contained by the popup loaded. this function\n- * updates the popup size, then unregisters the image load listener.\n+ * Method: parseGeometry\n+ * Convert a geometry object from GeoJSON into an .\n+ *\n+ * Parameters:\n+ * obj - {Object} An object created from a GeoJSON object\n+ *\n+ * Returns: \n+ * {} A geometry.\n */\n- registerImageListeners: function() {\n-\n- // As the images load, this function will call updateSize() to \n- // resize the popup to fit the content div (which presumably is now\n- // bigger than when the image was not loaded).\n- // \n- // If the 'panMapIfOutOfView' property is set, we will pan the newly\n- // resized popup back into view.\n- // \n- // Note that this function, when called, will have 'popup' and \n- // 'img' properties in the context.\n- //\n- var onImgLoad = function() {\n- if (this.popup.id === null) { // this.popup has been destroyed!\n- return;\n+ parseGeometry: function(obj) {\n+ if (obj == null) {\n+ return null;\n+ }\n+ var geometry, collection = false;\n+ if (obj.type == \"GeometryCollection\") {\n+ if (!(OpenLayers.Util.isArray(obj.geometries))) {\n+ throw \"GeometryCollection must have geometries array: \" + obj;\n }\n- this.popup.updateSize();\n-\n- if (this.popup.visible() && this.popup.panMapIfOutOfView) {\n- this.popup.panIntoView();\n+ var numGeom = obj.geometries.length;\n+ var components = new Array(numGeom);\n+ for (var i = 0; i < numGeom; ++i) {\n+ components[i] = this.parseGeometry.apply(\n+ this, [obj.geometries[i]]\n+ );\n }\n-\n- OpenLayers.Event.stopObserving(\n- this.img, \"load\", this.img._onImgLoad\n- );\n-\n- };\n-\n- //cycle through the images and if their size is 0x0, that means that \n- // they haven't been loaded yet, so we attach the listener, which \n- // will fire when the images finish loading and will resize the \n- // popup accordingly to its new size.\n- var images = this.contentDiv.getElementsByTagName(\"img\");\n- for (var i = 0, len = images.length; i < len; i++) {\n- var img = images[i];\n- if (img.width == 0 || img.height == 0) {\n-\n- var context = {\n- 'popup': this,\n- 'img': img\n- };\n-\n- //expando this function to the image itself before registering\n- // it. This way we can easily and properly unregister it.\n- img._onImgLoad = OpenLayers.Function.bind(onImgLoad, context);\n-\n- OpenLayers.Event.observe(img, 'load', img._onImgLoad);\n+ geometry = new OpenLayers.Geometry.Collection(components);\n+ collection = true;\n+ } else {\n+ if (!(OpenLayers.Util.isArray(obj.coordinates))) {\n+ throw \"Geometry must have coordinates array: \" + obj;\n+ }\n+ if (!this.parseCoords[obj.type.toLowerCase()]) {\n+ throw \"Unsupported geometry type: \" + obj.type;\n+ }\n+ try {\n+ geometry = this.parseCoords[obj.type.toLowerCase()].apply(\n+ this, [obj.coordinates]\n+ );\n+ } catch (err) {\n+ // deal with bad coordinates\n+ throw err;\n }\n }\n+ // We don't reproject collections because the children are reprojected\n+ // for us when they are created.\n+ if (this.internalProjection && this.externalProjection && !collection) {\n+ geometry.transform(this.externalProjection,\n+ this.internalProjection);\n+ }\n+ return geometry;\n },\n \n /**\n- * APIMethod: getSafeContentSize\n- * \n- * Parameters:\n- * size - {} Desired size to make the popup.\n- * \n- * Returns:\n- * {} A size to make the popup which is neither smaller\n- * than the specified minimum size, nor bigger than the maximum \n- * size (which is calculated relative to the size of the viewport).\n+ * Property: parseCoords\n+ * Object with properties corresponding to the GeoJSON geometry types.\n+ * Property values are functions that do the actual parsing.\n */\n- getSafeContentSize: function(size) {\n-\n- var safeContentSize = size.clone();\n-\n- // if our contentDiv has a css 'padding' set on it by a stylesheet, we \n- // must add that to the desired \"size\". \n- var contentDivPadding = this.getContentDivPadding();\n- var wPadding = contentDivPadding.left + contentDivPadding.right;\n- var hPadding = contentDivPadding.top + contentDivPadding.bottom;\n-\n- // take into account the popup's 'padding' property\n- this.fixPadding();\n- wPadding += this.padding.left + this.padding.right;\n- hPadding += this.padding.top + this.padding.bottom;\n-\n- if (this.closeDiv) {\n- var closeDivWidth = parseInt(this.closeDiv.style.width);\n- wPadding += closeDivWidth + contentDivPadding.right;\n- }\n-\n- // prevent the popup from being smaller than a specified minimal size\n- if (this.minSize) {\n- safeContentSize.w = Math.max(safeContentSize.w,\n- (this.minSize.w - wPadding));\n- safeContentSize.h = Math.max(safeContentSize.h,\n- (this.minSize.h - hPadding));\n- }\n+ parseCoords: {\n+ /**\n+ * Method: parseCoords.point\n+ * Convert a coordinate array from GeoJSON into an\n+ * .\n+ *\n+ * Parameters:\n+ * array - {Object} The coordinates array from the GeoJSON fragment.\n+ *\n+ * Returns:\n+ * {} A geometry.\n+ */\n+ \"point\": function(array) {\n+ if (this.ignoreExtraDims == false &&\n+ array.length != 2) {\n+ throw \"Only 2D points are supported: \" + array;\n+ }\n+ return new OpenLayers.Geometry.Point(array[0], array[1]);\n+ },\n \n- // prevent the popup from being bigger than a specified maximum size\n- if (this.maxSize) {\n- safeContentSize.w = Math.min(safeContentSize.w,\n- (this.maxSize.w - wPadding));\n- safeContentSize.h = Math.min(safeContentSize.h,\n- (this.maxSize.h - hPadding));\n- }\n+ /**\n+ * Method: parseCoords.multipoint\n+ * Convert a coordinate array from GeoJSON into an\n+ * .\n+ *\n+ * Parameters:\n+ * array - {Object} The coordinates array from the GeoJSON fragment.\n+ *\n+ * Returns:\n+ * {} A geometry.\n+ */\n+ \"multipoint\": function(array) {\n+ var points = [];\n+ var p = null;\n+ for (var i = 0, len = array.length; i < len; ++i) {\n+ try {\n+ p = this.parseCoords[\"point\"].apply(this, [array[i]]);\n+ } catch (err) {\n+ throw err;\n+ }\n+ points.push(p);\n+ }\n+ return new OpenLayers.Geometry.MultiPoint(points);\n+ },\n \n- //make sure the desired size to set doesn't result in a popup that \n- // is bigger than the map's viewport.\n- //\n- if (this.map && this.map.size) {\n+ /**\n+ * Method: parseCoords.linestring\n+ * Convert a coordinate array from GeoJSON into an\n+ * .\n+ *\n+ * Parameters:\n+ * array - {Object} The coordinates array from the GeoJSON fragment.\n+ *\n+ * Returns:\n+ * {} A geometry.\n+ */\n+ \"linestring\": function(array) {\n+ var points = [];\n+ var p = null;\n+ for (var i = 0, len = array.length; i < len; ++i) {\n+ try {\n+ p = this.parseCoords[\"point\"].apply(this, [array[i]]);\n+ } catch (err) {\n+ throw err;\n+ }\n+ points.push(p);\n+ }\n+ return new OpenLayers.Geometry.LineString(points);\n+ },\n \n- var extraX = 0,\n- extraY = 0;\n- if (this.keepInMap && !this.panMapIfOutOfView) {\n- var px = this.map.getPixelFromLonLat(this.lonlat);\n- switch (this.relativePosition) {\n- case \"tr\":\n- extraX = px.x;\n- extraY = this.map.size.h - px.y;\n- break;\n- case \"tl\":\n- extraX = this.map.size.w - px.x;\n- extraY = this.map.size.h - px.y;\n- break;\n- case \"bl\":\n- extraX = this.map.size.w - px.x;\n- extraY = px.y;\n- break;\n- case \"br\":\n- extraX = px.x;\n- extraY = px.y;\n- break;\n- default:\n- extraX = px.x;\n- extraY = this.map.size.h - px.y;\n- break;\n+ /**\n+ * Method: parseCoords.multilinestring\n+ * Convert a coordinate array from GeoJSON into an\n+ * .\n+ *\n+ * Parameters:\n+ * array - {Object} The coordinates array from the GeoJSON fragment.\n+ *\n+ * Returns:\n+ * {} A geometry.\n+ */\n+ \"multilinestring\": function(array) {\n+ var lines = [];\n+ var l = null;\n+ for (var i = 0, len = array.length; i < len; ++i) {\n+ try {\n+ l = this.parseCoords[\"linestring\"].apply(this, [array[i]]);\n+ } catch (err) {\n+ throw err;\n }\n+ lines.push(l);\n }\n+ return new OpenLayers.Geometry.MultiLineString(lines);\n+ },\n \n- var maxY = this.map.size.h -\n- this.map.paddingForPopups.top -\n- this.map.paddingForPopups.bottom -\n- hPadding - extraY;\n+ /**\n+ * Method: parseCoords.polygon\n+ * Convert a coordinate array from GeoJSON into an\n+ * .\n+ *\n+ * Returns:\n+ * {} A geometry.\n+ */\n+ \"polygon\": function(array) {\n+ var rings = [];\n+ var r, l;\n+ for (var i = 0, len = array.length; i < len; ++i) {\n+ try {\n+ l = this.parseCoords[\"linestring\"].apply(this, [array[i]]);\n+ } catch (err) {\n+ throw err;\n+ }\n+ r = new OpenLayers.Geometry.LinearRing(l.components);\n+ rings.push(r);\n+ }\n+ return new OpenLayers.Geometry.Polygon(rings);\n+ },\n \n- var maxX = this.map.size.w -\n- this.map.paddingForPopups.left -\n- this.map.paddingForPopups.right -\n- wPadding - extraX;\n+ /**\n+ * Method: parseCoords.multipolygon\n+ * Convert a coordinate array from GeoJSON into an\n+ * .\n+ *\n+ * Parameters:\n+ * array - {Object} The coordinates array from the GeoJSON fragment.\n+ *\n+ * Returns:\n+ * {} A geometry.\n+ */\n+ \"multipolygon\": function(array) {\n+ var polys = [];\n+ var p = null;\n+ for (var i = 0, len = array.length; i < len; ++i) {\n+ try {\n+ p = this.parseCoords[\"polygon\"].apply(this, [array[i]]);\n+ } catch (err) {\n+ throw err;\n+ }\n+ polys.push(p);\n+ }\n+ return new OpenLayers.Geometry.MultiPolygon(polys);\n+ },\n \n- safeContentSize.w = Math.min(safeContentSize.w, maxX);\n- safeContentSize.h = Math.min(safeContentSize.h, maxY);\n+ /**\n+ * Method: parseCoords.box\n+ * Convert a coordinate array from GeoJSON into an\n+ * .\n+ *\n+ * Parameters:\n+ * array - {Object} The coordinates array from the GeoJSON fragment.\n+ *\n+ * Returns:\n+ * {} A geometry.\n+ */\n+ \"box\": function(array) {\n+ if (array.length != 2) {\n+ throw \"GeoJSON box coordinates must have 2 elements\";\n+ }\n+ return new OpenLayers.Geometry.Polygon([\n+ new OpenLayers.Geometry.LinearRing([\n+ new OpenLayers.Geometry.Point(array[0][0], array[0][1]),\n+ new OpenLayers.Geometry.Point(array[1][0], array[0][1]),\n+ new OpenLayers.Geometry.Point(array[1][0], array[1][1]),\n+ new OpenLayers.Geometry.Point(array[0][0], array[1][1]),\n+ new OpenLayers.Geometry.Point(array[0][0], array[0][1])\n+ ])\n+ ]);\n }\n \n- return safeContentSize;\n },\n \n /**\n- * Method: getContentDivPadding\n- * Glorious, oh glorious hack in order to determine the css 'padding' of \n- * the contentDiv. IE/Opera return null here unless we actually add the \n- * popup's main 'div' element (which contains contentDiv) to the DOM. \n- * So we make it invisible and then add it to the document temporarily. \n+ * APIMethod: write\n+ * Serialize a feature, geometry, array of features into a GeoJSON string.\n *\n- * Once we've taken the padding readings we need, we then remove it \n- * from the DOM (it will actually get added to the DOM in \n- * Map.js's addPopup)\n+ * Parameters:\n+ * obj - {Object} An , ,\n+ * or an array of features.\n+ * pretty - {Boolean} Structure the output with newlines and indentation.\n+ * Default is false.\n *\n * Returns:\n- * {}\n+ * {String} The GeoJSON string representation of the input geometry,\n+ * features, or array of features.\n */\n- getContentDivPadding: function() {\n-\n- //use cached value if we have it\n- var contentDivPadding = this._contentDivPadding;\n- if (!contentDivPadding) {\n-\n- if (this.div.parentNode == null) {\n- //make the div invisible and add it to the page \n- this.div.style.display = \"none\";\n- document.body.appendChild(this.div);\n+ write: function(obj, pretty) {\n+ var geojson = {\n+ \"type\": null\n+ };\n+ if (OpenLayers.Util.isArray(obj)) {\n+ geojson.type = \"FeatureCollection\";\n+ var numFeatures = obj.length;\n+ geojson.features = new Array(numFeatures);\n+ for (var i = 0; i < numFeatures; ++i) {\n+ var element = obj[i];\n+ if (!element instanceof OpenLayers.Feature.Vector) {\n+ var msg = \"FeatureCollection only supports collections \" +\n+ \"of features: \" + element;\n+ throw msg;\n+ }\n+ geojson.features[i] = this.extract.feature.apply(\n+ this, [element]\n+ );\n }\n-\n- //read the padding settings from css, put them in an OL.Bounds \n- contentDivPadding = new OpenLayers.Bounds(\n- OpenLayers.Element.getStyle(this.contentDiv, \"padding-left\"),\n- OpenLayers.Element.getStyle(this.contentDiv, \"padding-bottom\"),\n- OpenLayers.Element.getStyle(this.contentDiv, \"padding-right\"),\n- OpenLayers.Element.getStyle(this.contentDiv, \"padding-top\")\n- );\n-\n- //cache the value\n- this._contentDivPadding = contentDivPadding;\n-\n- if (this.div.parentNode == document.body) {\n- //remove the div from the page and make it visible again\n- document.body.removeChild(this.div);\n- this.div.style.display = \"\";\n+ } else if (obj.CLASS_NAME.indexOf(\"OpenLayers.Geometry\") == 0) {\n+ geojson = this.extract.geometry.apply(this, [obj]);\n+ } else if (obj instanceof OpenLayers.Feature.Vector) {\n+ geojson = this.extract.feature.apply(this, [obj]);\n+ if (obj.layer && obj.layer.projection) {\n+ geojson.crs = this.createCRSObject(obj);\n }\n }\n- return contentDivPadding;\n+ return OpenLayers.Format.JSON.prototype.write.apply(this,\n+ [geojson, pretty]);\n },\n \n /**\n- * Method: addCloseBox\n- * \n+ * Method: createCRSObject\n+ * Create the CRS object for an object.\n+ *\n * Parameters:\n- * callback - {Function} The callback to be called when the close button\n- * is clicked.\n+ * object - {} \n+ *\n+ * Returns:\n+ * {Object} An object which can be assigned to the crs property\n+ * of a GeoJSON object.\n */\n- addCloseBox: function(callback) {\n-\n- this.closeDiv = OpenLayers.Util.createDiv(\n- this.id + \"_close\", null, {\n- w: 17,\n- h: 17\n+ createCRSObject: function(object) {\n+ var proj = object.layer.projection.toString();\n+ var crs = {};\n+ if (proj.match(/epsg:/i)) {\n+ var code = parseInt(proj.substring(proj.indexOf(\":\") + 1));\n+ if (code == 4326) {\n+ crs = {\n+ \"type\": \"name\",\n+ \"properties\": {\n+ \"name\": \"urn:ogc:def:crs:OGC:1.3:CRS84\"\n+ }\n+ };\n+ } else {\n+ crs = {\n+ \"type\": \"name\",\n+ \"properties\": {\n+ \"name\": \"EPSG:\" + code\n+ }\n+ };\n }\n- );\n- this.closeDiv.className = \"olPopupCloseBox\";\n-\n- // use the content div's css padding to determine if we should\n- // padd the close div\n- var contentDivPadding = this.getContentDivPadding();\n-\n- this.closeDiv.style.right = contentDivPadding.right + \"px\";\n- this.closeDiv.style.top = contentDivPadding.top + \"px\";\n- this.groupDiv.appendChild(this.closeDiv);\n-\n- var closePopup = callback || function(e) {\n- this.hide();\n- OpenLayers.Event.stop(e);\n- };\n- OpenLayers.Event.observe(this.closeDiv, \"touchend\",\n- OpenLayers.Function.bindAsEventListener(closePopup, this));\n- OpenLayers.Event.observe(this.closeDiv, \"click\",\n- OpenLayers.Function.bindAsEventListener(closePopup, this));\n+ }\n+ return crs;\n },\n \n /**\n- * Method: panIntoView\n- * Pans the map such that the popup is totaly viewable (if necessary)\n+ * Property: extract\n+ * Object with properties corresponding to the GeoJSON types.\n+ * Property values are functions that do the actual value extraction.\n */\n- panIntoView: function() {\n-\n- var mapSize = this.map.getSize();\n-\n- //start with the top left corner of the popup, in px, \n- // relative to the viewport\n- var origTL = this.map.getViewPortPxFromLayerPx(new OpenLayers.Pixel(\n- parseInt(this.div.style.left),\n- parseInt(this.div.style.top)\n- ));\n- var newTL = origTL.clone();\n-\n- //new left (compare to margins, using this.size to calculate right)\n- if (origTL.x < this.map.paddingForPopups.left) {\n- newTL.x = this.map.paddingForPopups.left;\n- } else\n- if ((origTL.x + this.size.w) > (mapSize.w - this.map.paddingForPopups.right)) {\n- newTL.x = mapSize.w - this.map.paddingForPopups.right - this.size.w;\n- }\n+ extract: {\n+ /**\n+ * Method: extract.feature\n+ * Return a partial GeoJSON object representing a single feature.\n+ *\n+ * Parameters:\n+ * feature - {}\n+ *\n+ * Returns:\n+ * {Object} An object representing the point.\n+ */\n+ 'feature': function(feature) {\n+ var geom = this.extract.geometry.apply(this, [feature.geometry]);\n+ var json = {\n+ \"type\": \"Feature\",\n+ \"properties\": feature.attributes,\n+ \"geometry\": geom\n+ };\n+ if (feature.fid != null) {\n+ json.id = feature.fid;\n+ }\n+ return json;\n+ },\n \n- //new top (compare to margins, using this.size to calculate bottom)\n- if (origTL.y < this.map.paddingForPopups.top) {\n- newTL.y = this.map.paddingForPopups.top;\n- } else\n- if ((origTL.y + this.size.h) > (mapSize.h - this.map.paddingForPopups.bottom)) {\n- newTL.y = mapSize.h - this.map.paddingForPopups.bottom - this.size.h;\n- }\n+ /**\n+ * Method: extract.geometry\n+ * Return a GeoJSON object representing a single geometry.\n+ *\n+ * Parameters:\n+ * geometry - {}\n+ *\n+ * Returns:\n+ * {Object} An object representing the geometry.\n+ */\n+ 'geometry': function(geometry) {\n+ if (geometry == null) {\n+ return null;\n+ }\n+ if (this.internalProjection && this.externalProjection) {\n+ geometry = geometry.clone();\n+ geometry.transform(this.internalProjection,\n+ this.externalProjection);\n+ }\n+ var geometryType = geometry.CLASS_NAME.split('.')[2];\n+ var data = this.extract[geometryType.toLowerCase()].apply(this, [geometry]);\n+ var json;\n+ if (geometryType == \"Collection\") {\n+ json = {\n+ \"type\": \"GeometryCollection\",\n+ \"geometries\": data\n+ };\n+ } else {\n+ json = {\n+ \"type\": geometryType,\n+ \"coordinates\": data\n+ };\n+ }\n \n- var dx = origTL.x - newTL.x;\n- var dy = origTL.y - newTL.y;\n+ return json;\n+ },\n \n- this.map.pan(dx, dy);\n- },\n+ /**\n+ * Method: extract.point\n+ * Return an array of coordinates from a point.\n+ *\n+ * Parameters:\n+ * point - {}\n+ *\n+ * Returns: \n+ * {Array} An array of coordinates representing the point.\n+ */\n+ 'point': function(point) {\n+ return [point.x, point.y];\n+ },\n \n- /** \n- * Method: registerEvents\n- * Registers events on the popup.\n- *\n- * Do this in a separate function so that subclasses can \n- * choose to override it if they wish to deal differently\n- * with mouse events\n- * \n- * Note in the following handler functions that some special\n- * care is needed to deal correctly with mousing and popups. \n- * \n- * Because the user might select the zoom-rectangle option and\n- * then drag it over a popup, we need a safe way to allow the\n- * mousemove and mouseup events to pass through the popup when\n- * they are initiated from outside. The same procedure is needed for\n- * touchmove and touchend events.\n- * \n- * Otherwise, we want to essentially kill the event propagation\n- * for all other events, though we have to do so carefully, \n- * without disabling basic html functionality, like clicking on \n- * hyperlinks or drag-selecting text.\n- */\n- registerEvents: function() {\n- this.events = new OpenLayers.Events(this, this.div, null, true);\n+ /**\n+ * Method: extract.multipoint\n+ * Return an array of point coordinates from a multipoint.\n+ *\n+ * Parameters:\n+ * multipoint - {}\n+ *\n+ * Returns:\n+ * {Array} An array of point coordinate arrays representing\n+ * the multipoint.\n+ */\n+ 'multipoint': function(multipoint) {\n+ var array = [];\n+ for (var i = 0, len = multipoint.components.length; i < len; ++i) {\n+ array.push(this.extract.point.apply(this, [multipoint.components[i]]));\n+ }\n+ return array;\n+ },\n \n- function onTouchstart(evt) {\n- OpenLayers.Event.stop(evt, true);\n- }\n- this.events.on({\n- \"mousedown\": this.onmousedown,\n- \"mousemove\": this.onmousemove,\n- \"mouseup\": this.onmouseup,\n- \"click\": this.onclick,\n- \"mouseout\": this.onmouseout,\n- \"dblclick\": this.ondblclick,\n- \"touchstart\": onTouchstart,\n- scope: this\n- });\n+ /**\n+ * Method: extract.linestring\n+ * Return an array of coordinate arrays from a linestring.\n+ *\n+ * Parameters:\n+ * linestring - {}\n+ *\n+ * Returns:\n+ * {Array} An array of coordinate arrays representing\n+ * the linestring.\n+ */\n+ 'linestring': function(linestring) {\n+ var array = [];\n+ for (var i = 0, len = linestring.components.length; i < len; ++i) {\n+ array.push(this.extract.point.apply(this, [linestring.components[i]]));\n+ }\n+ return array;\n+ },\n \n- },\n+ /**\n+ * Method: extract.multilinestring\n+ * Return an array of linestring arrays from a linestring.\n+ * \n+ * Parameters:\n+ * multilinestring - {}\n+ * \n+ * Returns:\n+ * {Array} An array of linestring arrays representing\n+ * the multilinestring.\n+ */\n+ 'multilinestring': function(multilinestring) {\n+ var array = [];\n+ for (var i = 0, len = multilinestring.components.length; i < len; ++i) {\n+ array.push(this.extract.linestring.apply(this, [multilinestring.components[i]]));\n+ }\n+ return array;\n+ },\n \n- /** \n- * Method: onmousedown \n- * When mouse goes down within the popup, make a note of\n- * it locally, and then do not propagate the mousedown \n- * (but do so safely so that user can select text inside)\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- onmousedown: function(evt) {\n- this.mousedown = true;\n- OpenLayers.Event.stop(evt, true);\n- },\n+ /**\n+ * Method: extract.polygon\n+ * Return an array of linear ring arrays from a polygon.\n+ *\n+ * Parameters:\n+ * polygon - {}\n+ * \n+ * Returns:\n+ * {Array} An array of linear ring arrays representing the polygon.\n+ */\n+ 'polygon': function(polygon) {\n+ var array = [];\n+ for (var i = 0, len = polygon.components.length; i < len; ++i) {\n+ array.push(this.extract.linestring.apply(this, [polygon.components[i]]));\n+ }\n+ return array;\n+ },\n \n- /** \n- * Method: onmousemove\n- * If the drag was started within the popup, then \n- * do not propagate the mousemove (but do so safely\n- * so that user can select text inside)\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- onmousemove: function(evt) {\n- if (this.mousedown) {\n- OpenLayers.Event.stop(evt, true);\n- }\n- },\n+ /**\n+ * Method: extract.multipolygon\n+ * Return an array of polygon arrays from a multipolygon.\n+ * \n+ * Parameters:\n+ * multipolygon - {}\n+ * \n+ * Returns:\n+ * {Array} An array of polygon arrays representing\n+ * the multipolygon\n+ */\n+ 'multipolygon': function(multipolygon) {\n+ var array = [];\n+ for (var i = 0, len = multipolygon.components.length; i < len; ++i) {\n+ array.push(this.extract.polygon.apply(this, [multipolygon.components[i]]));\n+ }\n+ return array;\n+ },\n \n- /** \n- * Method: onmouseup\n- * When mouse comes up within the popup, after going down \n- * in it, reset the flag, and then (once again) do not \n- * propagate the event, but do so safely so that user can \n- * select text inside\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- onmouseup: function(evt) {\n- if (this.mousedown) {\n- this.mousedown = false;\n- OpenLayers.Event.stop(evt, true);\n+ /**\n+ * Method: extract.collection\n+ * Return an array of geometries from a geometry collection.\n+ * \n+ * Parameters:\n+ * collection - {}\n+ * \n+ * Returns:\n+ * {Array} An array of geometry objects representing the geometry\n+ * collection.\n+ */\n+ 'collection': function(collection) {\n+ var len = collection.components.length;\n+ var array = new Array(len);\n+ for (var i = 0; i < len; ++i) {\n+ array[i] = this.extract.geometry.apply(\n+ this, [collection.components[i]]\n+ );\n+ }\n+ return array;\n }\n- },\n \n- /**\n- * Method: onclick\n- * Ignore clicks, but allowing default browser handling\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- onclick: function(evt) {\n- OpenLayers.Event.stop(evt, true);\n- },\n \n- /** \n- * Method: onmouseout\n- * When mouse goes out of the popup set the flag to false so that\n- * if they let go and then drag back in, we won't be confused.\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- onmouseout: function(evt) {\n- this.mousedown = false;\n },\n \n- /** \n- * Method: ondblclick\n- * Ignore double-clicks, but allowing default browser handling\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- ondblclick: function(evt) {\n- OpenLayers.Event.stop(evt, true);\n- },\n+ CLASS_NAME: \"OpenLayers.Format.GeoJSON\"\n \n- CLASS_NAME: \"OpenLayers.Popup\"\n });\n-\n-OpenLayers.Popup.WIDTH = 200;\n-OpenLayers.Popup.HEIGHT = 200;\n-OpenLayers.Popup.COLOR = \"white\";\n-OpenLayers.Popup.OPACITY = 1;\n-OpenLayers.Popup.BORDER = \"0px\";\n /* ======================================================================\n- OpenLayers/Control.js\n+ OpenLayers/Format/XML.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Format.js\n */\n \n /**\n- * Class: OpenLayers.Control\n- * Controls affect the display or behavior of the map. They allow everything\n- * from panning and zooming to displaying a scale indicator. Controls by \n- * default are added to the map they are contained within however it is\n- * possible to add a control to an external div by passing the div in the\n- * options parameter.\n- * \n- * Example:\n- * The following example shows how to add many of the common controls\n- * to a map.\n- * \n- * > var map = new OpenLayers.Map('map', { controls: [] });\n- * >\n- * > map.addControl(new OpenLayers.Control.PanZoomBar());\n- * > map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false}));\n- * > map.addControl(new OpenLayers.Control.Permalink());\n- * > map.addControl(new OpenLayers.Control.Permalink('permalink'));\n- * > map.addControl(new OpenLayers.Control.MousePosition());\n- * > map.addControl(new OpenLayers.Control.OverviewMap());\n- * > map.addControl(new OpenLayers.Control.KeyboardDefaults());\n- *\n- * The next code fragment is a quick example of how to intercept \n- * shift-mouse click to display the extent of the bounding box\n- * dragged out by the user. Usually controls are not created\n- * in exactly this manner. See the source for a more complete \n- * example:\n+ * Class: OpenLayers.Format.XML\n+ * Read and write XML. For cross-browser XML generation, use methods on an\n+ * instance of the XML format class instead of on document.\n+ * The DOM creation and traversing methods exposed here all mimic the\n+ * W3C XML DOM methods. Create a new parser with the\n+ * constructor.\n *\n- * > var control = new OpenLayers.Control();\n- * > OpenLayers.Util.extend(control, {\n- * > draw: function () {\n- * > // this Handler.Box will intercept the shift-mousedown\n- * > // before Control.MouseDefault gets to see it\n- * > this.box = new OpenLayers.Handler.Box( control, \n- * > {\"done\": this.notice},\n- * > {keyMask: OpenLayers.Handler.MOD_SHIFT});\n- * > this.box.activate();\n- * > },\n- * >\n- * > notice: function (bounds) {\n- * > OpenLayers.Console.userError(bounds);\n- * > }\n- * > }); \n- * > map.addControl(control);\n- * \n+ * Inherits from:\n+ * - \n */\n-OpenLayers.Control = OpenLayers.Class({\n-\n- /** \n- * Property: id \n- * {String} \n- */\n- id: null,\n-\n- /** \n- * Property: map \n- * {} this gets set in the addControl() function in\n- * OpenLayers.Map \n- */\n- map: null,\n-\n- /** \n- * APIProperty: div \n- * {DOMElement} The element that contains the control, if not present the \n- * control is placed inside the map.\n- */\n- div: null,\n-\n- /** \n- * APIProperty: type \n- * {Number} Controls can have a 'type'. The type determines the type of\n- * interactions which are possible with them when they are placed in an\n- * . \n- */\n- type: null,\n-\n- /** \n- * Property: allowSelection\n- * {Boolean} By default, controls do not allow selection, because\n- * it may interfere with map dragging. If this is true, OpenLayers\n- * will not prevent selection of the control.\n- * Default is false.\n- */\n- allowSelection: false,\n-\n- /** \n- * Property: displayClass \n- * {string} This property is used for CSS related to the drawing of the\n- * Control. \n- */\n- displayClass: \"\",\n+OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {\n \n /**\n- * APIProperty: title \n- * {string} This property is used for showing a tooltip over the \n- * Control. \n+ * Property: namespaces\n+ * {Object} Mapping of namespace aliases to namespace URIs. Properties\n+ * of this object should not be set individually. Read-only. All\n+ * XML subclasses should have their own namespaces object. Use\n+ * to add or set a namespace alias after construction.\n */\n- title: \"\",\n+ namespaces: null,\n \n /**\n- * APIProperty: autoActivate\n- * {Boolean} Activate the control when it is added to a map. Default is\n- * false.\n- */\n- autoActivate: false,\n-\n- /** \n- * APIProperty: active \n- * {Boolean} The control is active (read-only). Use and \n- * to change control state.\n+ * Property: namespaceAlias\n+ * {Object} Mapping of namespace URI to namespace alias. This object\n+ * is read-only. Use to add or set a namespace alias.\n */\n- active: null,\n+ namespaceAlias: null,\n \n /**\n- * Property: handlerOptions\n- * {Object} Used to set non-default properties on the control's handler\n+ * Property: defaultPrefix\n+ * {String} The default namespace alias for creating element nodes.\n */\n- handlerOptions: null,\n+ defaultPrefix: null,\n \n- /** \n- * Property: handler \n- * {} null\n+ /**\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n */\n- handler: null,\n+ readers: {},\n \n /**\n- * APIProperty: eventListeners\n- * {Object} If set as an option at construction, the eventListeners\n- * object will be registered with . Object\n- * structure must be a listeners object as shown in the example for\n- * the events.on method.\n+ * Property: writers\n+ * As a compliment to the property, this structure contains public\n+ * writing functions grouped by namespace alias and named like the\n+ * node names they produce.\n */\n- eventListeners: null,\n+ writers: {},\n \n- /** \n- * APIProperty: events\n- * {} Events instance for listeners and triggering\n- * control specific events.\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * control.events.register(type, obj, listener);\n- * (end)\n- *\n- * Listeners will be called with a reference to an event object. The\n- * properties of this event depends on exactly what happened.\n- *\n- * All event objects have at least the following properties:\n- * object - {Object} A reference to control.events.object (a reference\n- * to the control).\n- * element - {DOMElement} A reference to control.events.element (which\n- * will be null unless documented otherwise).\n- *\n- * Supported map event types:\n- * activate - Triggered when activated.\n- * deactivate - Triggered when deactivated.\n+ /**\n+ * Property: xmldom\n+ * {XMLDom} If this browser uses ActiveX, this will be set to a XMLDOM\n+ * object. It is not intended to be a browser sniffing property.\n+ * Instead, the xmldom property is used instead of document\n+ * where namespaced node creation methods are not supported. In all\n+ * other browsers, this remains null.\n */\n- events: null,\n+ xmldom: null,\n \n /**\n- * Constructor: OpenLayers.Control\n- * Create an OpenLayers Control. The options passed as a parameter\n- * directly extend the control. For example passing the following:\n- * \n- * > var control = new OpenLayers.Control({div: myDiv});\n+ * Constructor: OpenLayers.Format.XML\n+ * Construct an XML parser. The parser is used to read and write XML.\n+ * Reading XML from a string returns a DOM element. Writing XML from\n+ * a DOM element returns a string.\n *\n- * Overrides the default div attribute value of null.\n- * \n * Parameters:\n- * options - {Object} \n+ * options - {Object} Optional object whose properties will be set on\n+ * the object.\n */\n initialize: function(options) {\n- // We do this before the extend so that instances can override\n- // className in options.\n- this.displayClass =\n- this.CLASS_NAME.replace(\"OpenLayers.\", \"ol\").replace(/\\./g, \"\");\n-\n- OpenLayers.Util.extend(this, options);\n-\n- this.events = new OpenLayers.Events(this);\n- if (this.eventListeners instanceof Object) {\n- this.events.on(this.eventListeners);\n+ if (window.ActiveXObject) {\n+ this.xmldom = new ActiveXObject(\"Microsoft.XMLDOM\");\n }\n- if (this.id == null) {\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+ OpenLayers.Format.prototype.initialize.apply(this, [options]);\n+ // clone the namespace object and set all namespace aliases\n+ this.namespaces = OpenLayers.Util.extend({}, this.namespaces);\n+ this.namespaceAlias = {};\n+ for (var alias in this.namespaces) {\n+ this.namespaceAlias[this.namespaces[alias]] = alias;\n }\n },\n \n /**\n- * Method: destroy\n- * The destroy method is used to perform any clean up before the control\n- * is dereferenced. Typically this is where event listeners are removed\n- * to prevent memory leaks.\n+ * APIMethod: destroy\n+ * Clean up.\n */\n destroy: function() {\n- if (this.events) {\n- if (this.eventListeners) {\n- this.events.un(this.eventListeners);\n- }\n- this.events.destroy();\n- this.events = null;\n- }\n- this.eventListeners = null;\n+ this.xmldom = null;\n+ OpenLayers.Format.prototype.destroy.apply(this, arguments);\n+ },\n \n- // eliminate circular references\n- if (this.handler) {\n- this.handler.destroy();\n- this.handler = null;\n+ /**\n+ * Method: setNamespace\n+ * Set a namespace alias and URI for the format.\n+ *\n+ * Parameters:\n+ * alias - {String} The namespace alias (prefix).\n+ * uri - {String} The namespace URI.\n+ */\n+ setNamespace: function(alias, uri) {\n+ this.namespaces[alias] = uri;\n+ this.namespaceAlias[uri] = alias;\n+ },\n+\n+ /**\n+ * APIMethod: read\n+ * Deserialize a XML string and return a DOM node.\n+ *\n+ * Parameters:\n+ * text - {String} A XML string\n+ \n+ * Returns:\n+ * {DOMElement} A DOM node\n+ */\n+ read: function(text) {\n+ var index = text.indexOf('<');\n+ if (index > 0) {\n+ text = text.substring(index);\n }\n- if (this.handlers) {\n- for (var key in this.handlers) {\n- if (this.handlers.hasOwnProperty(key) &&\n- typeof this.handlers[key].destroy == \"function\") {\n- this.handlers[key].destroy();\n+ var node = OpenLayers.Util.Try(\n+ OpenLayers.Function.bind((\n+ function() {\n+ var xmldom;\n+ /**\n+ * Since we want to be able to call this method on the prototype\n+ * itself, this.xmldom may not exist even if in IE.\n+ */\n+ if (window.ActiveXObject && !this.xmldom) {\n+ xmldom = new ActiveXObject(\"Microsoft.XMLDOM\");\n+ } else {\n+ xmldom = this.xmldom;\n+\n+ }\n+ xmldom.loadXML(text);\n+ return xmldom;\n+ }\n+ ), this),\n+ function() {\n+ return new DOMParser().parseFromString(text, 'text/xml');\n+ },\n+ function() {\n+ var req = new XMLHttpRequest();\n+ req.open(\"GET\", \"data:\" + \"text/xml\" +\n+ \";charset=utf-8,\" + encodeURIComponent(text), false);\n+ if (req.overrideMimeType) {\n+ req.overrideMimeType(\"text/xml\");\n }\n+ req.send(null);\n+ return req.responseXML;\n }\n- this.handlers = null;\n- }\n- if (this.map) {\n- this.map.removeControl(this);\n- this.map = null;\n+ );\n+\n+ if (this.keepData) {\n+ this.data = node;\n }\n- this.div = null;\n+\n+ return node;\n },\n \n- /** \n- * Method: setMap\n- * Set the map property for the control. This is done through an accessor\n- * so that subclasses can override this and take special action once \n- * they have their map variable set. \n- *\n+ /**\n+ * APIMethod: write\n+ * Serialize a DOM node into a XML string.\n+ * \n * Parameters:\n- * map - {} \n+ * node - {DOMElement} A DOM node.\n+ *\n+ * Returns:\n+ * {String} The XML string representation of the input node.\n */\n- setMap: function(map) {\n- this.map = map;\n- if (this.handler) {\n- this.handler.setMap(map);\n+ write: function(node) {\n+ var data;\n+ if (this.xmldom) {\n+ data = node.xml;\n+ } else {\n+ var serializer = new XMLSerializer();\n+ if (node.nodeType == 1) {\n+ // Add nodes to a document before serializing. Everything else\n+ // is serialized as is. This may need more work. See #1218 .\n+ var doc = document.implementation.createDocument(\"\", \"\", null);\n+ if (doc.importNode) {\n+ node = doc.importNode(node, true);\n+ }\n+ doc.appendChild(node);\n+ data = serializer.serializeToString(doc);\n+ } else {\n+ data = serializer.serializeToString(node);\n+ }\n }\n+ return data;\n },\n \n /**\n- * Method: draw\n- * The draw method is called when the control is ready to be displayed\n- * on the page. If a div has not been created one is created. Controls\n- * with a visual component will almost always want to override this method \n- * to customize the look of control. \n+ * APIMethod: createElementNS\n+ * Create a new element with namespace. This node can be appended to\n+ * another node with the standard node.appendChild method. For\n+ * cross-browser support, this method must be used instead of\n+ * document.createElementNS.\n *\n * Parameters:\n- * px - {} The top-left pixel position of the control\n- * or null.\n- *\n+ * uri - {String} Namespace URI for the element.\n+ * name - {String} The qualified name of the element (prefix:localname).\n+ * \n * Returns:\n- * {DOMElement} A reference to the DIV DOMElement containing the control\n+ * {Element} A DOM element with namespace.\n */\n- draw: function(px) {\n- if (this.div == null) {\n- this.div = OpenLayers.Util.createDiv(this.id);\n- this.div.className = this.displayClass;\n- if (!this.allowSelection) {\n- this.div.className += \" olControlNoSelect\";\n- this.div.setAttribute(\"unselectable\", \"on\", 0);\n- this.div.onselectstart = OpenLayers.Function.False;\n- }\n- if (this.title != \"\") {\n- this.div.title = this.title;\n+ createElementNS: function(uri, name) {\n+ var element;\n+ if (this.xmldom) {\n+ if (typeof uri == \"string\") {\n+ element = this.xmldom.createNode(1, name, uri);\n+ } else {\n+ element = this.xmldom.createNode(1, name, \"\");\n }\n+ } else {\n+ element = document.createElementNS(uri, name);\n }\n- if (px != null) {\n- this.position = px.clone();\n- }\n- this.moveTo(this.position);\n- return this.div;\n+ return element;\n },\n \n /**\n- * Method: moveTo\n- * Sets the left and top style attributes to the passed in pixel \n- * coordinates.\n+ * APIMethod: createDocumentFragment\n+ * Create a document fragment node that can be appended to another node\n+ * created by createElementNS. This will call \n+ * document.createDocumentFragment outside of IE. In IE, the ActiveX\n+ * object's createDocumentFragment method is used.\n *\n- * Parameters:\n- * px - {}\n+ * Returns:\n+ * {Element} A document fragment.\n */\n- moveTo: function(px) {\n- if ((px != null) && (this.div != null)) {\n- this.div.style.left = px.x + \"px\";\n- this.div.style.top = px.y + \"px\";\n+ createDocumentFragment: function() {\n+ var element;\n+ if (this.xmldom) {\n+ element = this.xmldom.createDocumentFragment();\n+ } else {\n+ element = document.createDocumentFragment();\n }\n+ return element;\n },\n \n /**\n- * APIMethod: activate\n- * Explicitly activates a control and it's associated\n- * handler if one has been set. Controls can be\n- * deactivated by calling the deactivate() method.\n+ * APIMethod: createTextNode\n+ * Create a text node. This node can be appended to another node with\n+ * the standard node.appendChild method. For cross-browser support,\n+ * this method must be used instead of document.createTextNode.\n * \n- * Returns:\n- * {Boolean} True if the control was successfully activated or\n- * false if the control was already active.\n+ * Parameters:\n+ * text - {String} The text of the node.\n+ * \n+ * Returns: \n+ * {DOMElement} A DOM text node.\n */\n- activate: function() {\n- if (this.active) {\n- return false;\n- }\n- if (this.handler) {\n- this.handler.activate();\n+ createTextNode: function(text) {\n+ var node;\n+ if (typeof text !== \"string\") {\n+ text = String(text);\n }\n- this.active = true;\n- if (this.map) {\n- OpenLayers.Element.addClass(\n- this.map.viewPortDiv,\n- this.displayClass.replace(/ /g, \"\") + \"Active\"\n- );\n+ if (this.xmldom) {\n+ node = this.xmldom.createTextNode(text);\n+ } else {\n+ node = document.createTextNode(text);\n }\n- this.events.triggerEvent(\"activate\");\n- return true;\n+ return node;\n },\n \n /**\n- * APIMethod: deactivate\n- * Deactivates a control and it's associated handler if any. The exact\n- * effect of this depends on the control itself.\n+ * APIMethod: getElementsByTagNameNS\n+ * Get a list of elements on a node given the namespace URI and local name.\n+ * To return all nodes in a given namespace, use '*' for the name\n+ * argument. To return all nodes of a given (local) name, regardless\n+ * of namespace, use '*' for the uri argument.\n+ * \n+ * Parameters:\n+ * node - {Element} Node on which to search for other nodes.\n+ * uri - {String} Namespace URI.\n+ * name - {String} Local name of the tag (without the prefix).\n * \n * Returns:\n- * {Boolean} True if the control was effectively deactivated or false\n- * if the control was already inactive.\n+ * {NodeList} A node list or array of elements.\n */\n- deactivate: function() {\n- if (this.active) {\n- if (this.handler) {\n- this.handler.deactivate();\n- }\n- this.active = false;\n- if (this.map) {\n- OpenLayers.Element.removeClass(\n- this.map.viewPortDiv,\n- this.displayClass.replace(/ /g, \"\") + \"Active\"\n- );\n+ getElementsByTagNameNS: function(node, uri, name) {\n+ var elements = [];\n+ if (node.getElementsByTagNameNS) {\n+ elements = node.getElementsByTagNameNS(uri, name);\n+ } else {\n+ // brute force method\n+ var allNodes = node.getElementsByTagName(\"*\");\n+ var potentialNode, fullName;\n+ for (var i = 0, len = allNodes.length; i < len; ++i) {\n+ potentialNode = allNodes[i];\n+ fullName = (potentialNode.prefix) ?\n+ (potentialNode.prefix + \":\" + name) : name;\n+ if ((name == \"*\") || (fullName == potentialNode.nodeName)) {\n+ if ((uri == \"*\") || (uri == potentialNode.namespaceURI)) {\n+ elements.push(potentialNode);\n+ }\n+ }\n }\n- this.events.triggerEvent(\"deactivate\");\n- return true;\n }\n- return false;\n+ return elements;\n },\n \n- CLASS_NAME: \"OpenLayers.Control\"\n-});\n-\n-/**\n- * Constant: OpenLayers.Control.TYPE_BUTTON\n- */\n-OpenLayers.Control.TYPE_BUTTON = 1;\n-\n-/**\n- * Constant: OpenLayers.Control.TYPE_TOGGLE\n- */\n-OpenLayers.Control.TYPE_TOGGLE = 2;\n-\n-/**\n- * Constant: OpenLayers.Control.TYPE_TOOL\n- */\n-OpenLayers.Control.TYPE_TOOL = 3;\n-/* ======================================================================\n- OpenLayers/Renderer.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- */\n-\n-/**\n- * Class: OpenLayers.Renderer \n- * This is the base class for all renderers.\n- *\n- * This is based on a merger code written by Paul Spencer and Bertil Chapuis.\n- * It is largely composed of virtual functions that are to be implemented\n- * in technology-specific subclasses, but there is some generic code too.\n- * \n- * The functions that *are* implemented here merely deal with the maintenance\n- * of the size and extent variables, as well as the cached 'resolution' \n- * value. \n- * \n- * A note to the user that all subclasses should use getResolution() instead\n- * of directly accessing this.resolution in order to correctly use the \n- * cacheing system.\n- *\n- */\n-OpenLayers.Renderer = OpenLayers.Class({\n-\n- /** \n- * Property: container\n- * {DOMElement} \n- */\n- container: null,\n-\n- /**\n- * Property: root\n- * {DOMElement}\n- */\n- root: null,\n-\n- /** \n- * Property: extent\n- * {}\n- */\n- extent: null,\n-\n- /**\n- * Property: locked\n- * {Boolean} If the renderer is currently in a state where many things\n- * are changing, the 'locked' property is set to true. This means \n- * that renderers can expect at least one more drawFeature event to be\n- * called with the 'locked' property set to 'true': In some renderers,\n- * this might make sense to use as a 'only update local information'\n- * flag. \n- */\n- locked: false,\n-\n- /** \n- * Property: size\n- * {} \n- */\n- size: null,\n-\n- /**\n- * Property: resolution\n- * {Float} cache of current map resolution\n- */\n- resolution: null,\n-\n- /**\n- * Property: map \n- * {} Reference to the map -- this is set in Vector's setMap()\n- */\n- map: null,\n-\n /**\n- * Property: featureDx\n- * {Number} Feature offset in x direction. Will be calculated for and\n- * applied to the current feature while rendering (see\n- * ).\n+ * APIMethod: getAttributeNodeNS\n+ * Get an attribute node given the namespace URI and local name.\n+ * \n+ * Parameters:\n+ * node - {Element} Node on which to search for attribute nodes.\n+ * uri - {String} Namespace URI.\n+ * name - {String} Local name of the attribute (without the prefix).\n+ * \n+ * Returns:\n+ * {DOMElement} An attribute node or null if none found.\n */\n- featureDx: 0,\n+ getAttributeNodeNS: function(node, uri, name) {\n+ var attributeNode = null;\n+ if (node.getAttributeNodeNS) {\n+ attributeNode = node.getAttributeNodeNS(uri, name);\n+ } else {\n+ var attributes = node.attributes;\n+ var potentialNode, fullName;\n+ for (var i = 0, len = attributes.length; i < len; ++i) {\n+ potentialNode = attributes[i];\n+ if (potentialNode.namespaceURI == uri) {\n+ fullName = (potentialNode.prefix) ?\n+ (potentialNode.prefix + \":\" + name) : name;\n+ if (fullName == potentialNode.nodeName) {\n+ attributeNode = potentialNode;\n+ break;\n+ }\n+ }\n+ }\n+ }\n+ return attributeNode;\n+ },\n \n /**\n- * Constructor: OpenLayers.Renderer \n- *\n+ * APIMethod: getAttributeNS\n+ * Get an attribute value given the namespace URI and local name.\n+ * \n * Parameters:\n- * containerID - {} \n- * options - {Object} options for this renderer. See sublcasses for\n- * supported options.\n+ * node - {Element} Node on which to search for an attribute.\n+ * uri - {String} Namespace URI.\n+ * name - {String} Local name of the attribute (without the prefix).\n+ * \n+ * Returns:\n+ * {String} An attribute value or and empty string if none found.\n */\n- initialize: function(containerID, options) {\n- this.container = OpenLayers.Util.getElement(containerID);\n- OpenLayers.Util.extend(this, options);\n+ getAttributeNS: function(node, uri, name) {\n+ var attributeValue = \"\";\n+ if (node.getAttributeNS) {\n+ attributeValue = node.getAttributeNS(uri, name) || \"\";\n+ } else {\n+ var attributeNode = this.getAttributeNodeNS(node, uri, name);\n+ if (attributeNode) {\n+ attributeValue = attributeNode.nodeValue;\n+ }\n+ }\n+ return attributeValue;\n },\n \n /**\n- * APIMethod: destroy\n+ * APIMethod: getChildValue\n+ * Get the textual value of the node if it exists, or return an\n+ * optional default string. Returns an empty string if no first child\n+ * exists and no default value is supplied.\n+ *\n+ * Parameters:\n+ * node - {DOMElement} The element used to look for a first child value.\n+ * def - {String} Optional string to return in the event that no\n+ * first child value exists.\n+ *\n+ * Returns:\n+ * {String} The value of the first child of the given node.\n */\n- destroy: function() {\n- this.container = null;\n- this.extent = null;\n- this.size = null;\n- this.resolution = null;\n- this.map = null;\n+ getChildValue: function(node, def) {\n+ var value = def || \"\";\n+ if (node) {\n+ for (var child = node.firstChild; child; child = child.nextSibling) {\n+ switch (child.nodeType) {\n+ case 3: // text node\n+ case 4: // cdata section\n+ value += child.nodeValue;\n+ }\n+ }\n+ }\n+ return value;\n },\n \n /**\n- * APIMethod: supported\n- * This should be overridden by specific subclasses\n- * \n+ * APIMethod: isSimpleContent\n+ * Test if the given node has only simple content (i.e. no child element\n+ * nodes).\n+ *\n+ * Parameters:\n+ * node - {DOMElement} An element node.\n+ *\n * Returns:\n- * {Boolean} Whether or not the browser supports the renderer class\n+ * {Boolean} The node has no child element nodes (nodes of type 1). \n */\n- supported: function() {\n- return false;\n+ isSimpleContent: function(node) {\n+ var simple = true;\n+ for (var child = node.firstChild; child; child = child.nextSibling) {\n+ if (child.nodeType === 1) {\n+ simple = false;\n+ break;\n+ }\n+ }\n+ return simple;\n },\n \n /**\n- * Method: setExtent\n- * Set the visible part of the layer.\n- *\n- * Resolution has probably changed, so we nullify the resolution \n- * cache (this.resolution) -- this way it will be re-computed when \n- * next it is needed.\n- * We nullify the resolution cache (this.resolution) if resolutionChanged\n- * is set to true - this way it will be re-computed on the next\n- * getResolution() request.\n+ * APIMethod: contentType\n+ * Determine the content type for a given node.\n *\n * Parameters:\n- * extent - {}\n- * resolutionChanged - {Boolean}\n+ * node - {DOMElement}\n *\n * Returns:\n- * {Boolean} true to notify the layer that the new extent does not exceed\n- * the coordinate range, and the features will not need to be redrawn.\n- * False otherwise.\n+ * {Integer} One of OpenLayers.Format.XML.CONTENT_TYPE.{EMPTY,SIMPLE,COMPLEX,MIXED}\n+ * if the node has no, simple, complex, or mixed content.\n */\n- setExtent: function(extent, resolutionChanged) {\n- this.extent = extent.clone();\n- if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {\n- var ratio = extent.getWidth() / this.map.getExtent().getWidth(),\n- extent = extent.scale(1 / ratio);\n- this.extent = extent.wrapDateLine(this.map.getMaxExtent()).scale(ratio);\n+ contentType: function(node) {\n+ var simple = false,\n+ complex = false;\n+\n+ var type = OpenLayers.Format.XML.CONTENT_TYPE.EMPTY;\n+\n+ for (var child = node.firstChild; child; child = child.nextSibling) {\n+ switch (child.nodeType) {\n+ case 1: // element\n+ complex = true;\n+ break;\n+ case 8: // comment\n+ break;\n+ default:\n+ simple = true;\n+ }\n+ if (complex && simple) {\n+ break;\n+ }\n }\n- if (resolutionChanged) {\n- this.resolution = null;\n+\n+ if (complex && simple) {\n+ type = OpenLayers.Format.XML.CONTENT_TYPE.MIXED;\n+ } else if (complex) {\n+ return OpenLayers.Format.XML.CONTENT_TYPE.COMPLEX;\n+ } else if (simple) {\n+ return OpenLayers.Format.XML.CONTENT_TYPE.SIMPLE;\n }\n- return true;\n+ return type;\n },\n \n /**\n- * Method: setSize\n- * Sets the size of the drawing surface.\n+ * APIMethod: hasAttributeNS\n+ * Determine whether a node has a particular attribute matching the given\n+ * name and namespace.\n * \n- * Resolution has probably changed, so we nullify the resolution \n- * cache (this.resolution) -- this way it will be re-computed when \n- * next it is needed.\n- *\n * Parameters:\n- * size - {} \n- */\n- setSize: function(size) {\n- this.size = size.clone();\n- this.resolution = null;\n- },\n-\n- /** \n- * Method: getResolution\n- * Uses cached copy of resolution if available to minimize computing\n+ * node - {Element} Node on which to search for an attribute.\n+ * uri - {String} Namespace URI.\n+ * name - {String} Local name of the attribute (without the prefix).\n * \n * Returns:\n- * {Float} The current map's resolution\n+ * {Boolean} The node has an attribute matching the name and namespace.\n */\n- getResolution: function() {\n- this.resolution = this.resolution || this.map.getResolution();\n- return this.resolution;\n+ hasAttributeNS: function(node, uri, name) {\n+ var found = false;\n+ if (node.hasAttributeNS) {\n+ found = node.hasAttributeNS(uri, name);\n+ } else {\n+ found = !!this.getAttributeNodeNS(node, uri, name);\n+ }\n+ return found;\n },\n \n /**\n- * Method: drawFeature\n- * Draw the feature. The optional style argument can be used\n- * to override the feature's own style. This method should only\n- * be called from layer.drawFeature().\n+ * APIMethod: setAttributeNS\n+ * Adds a new attribute or changes the value of an attribute with the given\n+ * namespace and name.\n *\n * Parameters:\n- * feature - {} \n- * style - {}\n- * \n- * Returns:\n- * {Boolean} true if the feature has been drawn completely, false if not,\n- * undefined if the feature had no geometry\n+ * node - {Element} Element node on which to set the attribute.\n+ * uri - {String} Namespace URI for the attribute.\n+ * name - {String} Qualified name (prefix:localname) for the attribute.\n+ * value - {String} Attribute value.\n */\n- drawFeature: function(feature, style) {\n- if (style == null) {\n- style = feature.style;\n- }\n- if (feature.geometry) {\n- var bounds = feature.geometry.getBounds();\n- if (bounds) {\n- var worldBounds;\n- if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {\n- worldBounds = this.map.getMaxExtent();\n- }\n- if (!bounds.intersectsBounds(this.extent, {\n- worldBounds: worldBounds\n- })) {\n- style = {\n- display: \"none\"\n- };\n- } else {\n- this.calculateFeatureDx(bounds, worldBounds);\n- }\n- var rendered = this.drawGeometry(feature.geometry, style, feature.id);\n- if (style.display != \"none\" && style.label && rendered !== false) {\n-\n- var location = feature.geometry.getCentroid();\n- if (style.labelXOffset || style.labelYOffset) {\n- var xOffset = isNaN(style.labelXOffset) ? 0 : style.labelXOffset;\n- var yOffset = isNaN(style.labelYOffset) ? 0 : style.labelYOffset;\n- var res = this.getResolution();\n- location.move(xOffset * res, yOffset * res);\n- }\n- this.drawText(feature.id, style, location);\n+ setAttributeNS: function(node, uri, name, value) {\n+ if (node.setAttributeNS) {\n+ node.setAttributeNS(uri, name, value);\n+ } else {\n+ if (this.xmldom) {\n+ if (uri) {\n+ var attribute = node.ownerDocument.createNode(\n+ 2, name, uri\n+ );\n+ attribute.nodeValue = value;\n+ node.setAttributeNode(attribute);\n } else {\n- this.removeText(feature.id);\n+ node.setAttribute(name, value);\n }\n- return rendered;\n+ } else {\n+ throw \"setAttributeNS not implemented\";\n }\n }\n },\n \n /**\n- * Method: calculateFeatureDx\n- * {Number} Calculates the feature offset in x direction. Looking at the\n- * center of the feature bounds and the renderer extent, we calculate how\n- * many world widths the two are away from each other. This distance is\n- * used to shift the feature as close as possible to the center of the\n- * current enderer extent, which ensures that the feature is visible in the\n- * current viewport.\n+ * Method: createElementNSPlus\n+ * Shorthand for creating namespaced elements with optional attributes and\n+ * child text nodes.\n *\n * Parameters:\n- * bounds - {} Bounds of the feature\n- * worldBounds - {} Bounds of the world\n+ * name - {String} The qualified node name.\n+ * options - {Object} Optional object for node configuration.\n+ *\n+ * Valid options:\n+ * uri - {String} Optional namespace uri for the element - supply a prefix\n+ * instead if the namespace uri is a property of the format's namespace\n+ * object.\n+ * attributes - {Object} Optional attributes to be set using the\n+ * method.\n+ * value - {String} Optional text to be appended as a text node.\n+ *\n+ * Returns:\n+ * {Element} An element node.\n */\n- calculateFeatureDx: function(bounds, worldBounds) {\n- this.featureDx = 0;\n- if (worldBounds) {\n- var worldWidth = worldBounds.getWidth(),\n- rendererCenterX = (this.extent.left + this.extent.right) / 2,\n- featureCenterX = (bounds.left + bounds.right) / 2,\n- worldsAway = Math.round((featureCenterX - rendererCenterX) / worldWidth);\n- this.featureDx = worldsAway * worldWidth;\n+ createElementNSPlus: function(name, options) {\n+ options = options || {};\n+ // order of prefix preference\n+ // 1. in the uri option\n+ // 2. in the prefix option\n+ // 3. in the qualified name\n+ // 4. from the defaultPrefix\n+ var uri = options.uri || this.namespaces[options.prefix];\n+ if (!uri) {\n+ var loc = name.indexOf(\":\");\n+ uri = this.namespaces[name.substring(0, loc)];\n+ }\n+ if (!uri) {\n+ uri = this.namespaces[this.defaultPrefix];\n+ }\n+ var node = this.createElementNS(uri, name);\n+ if (options.attributes) {\n+ this.setAttributes(node, options.attributes);\n }\n+ var value = options.value;\n+ if (value != null) {\n+ node.appendChild(this.createTextNode(value));\n+ }\n+ return node;\n },\n \n- /** \n- * Method: drawGeometry\n- * \n- * Draw a geometry. This should only be called from the renderer itself.\n- * Use layer.drawFeature() from outside the renderer.\n- * virtual function\n+ /**\n+ * Method: setAttributes\n+ * Set multiple attributes given key value pairs from an object.\n *\n * Parameters:\n- * geometry - {} \n- * style - {Object} \n- * featureId - {} \n- */\n- drawGeometry: function(geometry, style, featureId) {},\n-\n- /**\n- * Method: drawText\n- * Function for drawing text labels.\n- * This method is only called by the renderer itself.\n- * \n- * Parameters: \n- * featureId - {String}\n- * style -\n- * location - {}\n- */\n- drawText: function(featureId, style, location) {},\n-\n- /**\n- * Method: removeText\n- * Function for removing text labels.\n- * This method is only called by the renderer itself.\n- * \n- * Parameters: \n- * featureId - {String}\n+ * node - {Element} An element node.\n+ * obj - {Object || Array} An object whose properties represent attribute\n+ * names and values represent attribute values. If an attribute name\n+ * is a qualified name (\"prefix:local\"), the prefix will be looked up\n+ * in the parsers {namespaces} object. If the prefix is found,\n+ * setAttributeNS will be used instead of setAttribute.\n */\n- removeText: function(featureId) {},\n+ setAttributes: function(node, obj) {\n+ var value, uri;\n+ for (var name in obj) {\n+ if (obj[name] != null && obj[name].toString) {\n+ value = obj[name].toString();\n+ // check for qualified attribute name (\"prefix:local\")\n+ uri = this.namespaces[name.substring(0, name.indexOf(\":\"))] || null;\n+ this.setAttributeNS(node, uri, name, value);\n+ }\n+ }\n+ },\n \n /**\n- * Method: clear\n- * Clear all vectors from the renderer.\n- * virtual function.\n+ * Method: readNode\n+ * Shorthand for applying one of the named readers given the node\n+ * namespace and local name. Readers take two args (node, obj) and\n+ * generally extend or modify the second.\n+ *\n+ * Parameters:\n+ * node - {DOMElement} The node to be read (required).\n+ * obj - {Object} The object to be modified (optional).\n+ *\n+ * Returns:\n+ * {Object} The input object, modified (or a new one if none was provided).\n */\n- clear: function() {},\n+ readNode: function(node, obj) {\n+ if (!obj) {\n+ obj = {};\n+ }\n+ var group = this.readers[node.namespaceURI ? this.namespaceAlias[node.namespaceURI] : this.defaultPrefix];\n+ if (group) {\n+ var local = node.localName || node.nodeName.split(\":\").pop();\n+ var reader = group[local] || group[\"*\"];\n+ if (reader) {\n+ reader.apply(this, [node, obj]);\n+ }\n+ }\n+ return obj;\n+ },\n \n /**\n- * Method: getFeatureIdFromEvent\n- * Returns a feature id from an event on the renderer. \n- * How this happens is specific to the renderer. This should be\n- * called from layer.getFeatureFromEvent().\n- * Virtual function.\n- * \n+ * Method: readChildNodes\n+ * Shorthand for applying the named readers to all children of a node.\n+ * For each child of type 1 (element), is called.\n+ *\n * Parameters:\n- * evt - {} \n+ * node - {DOMElement} The node to be read (required).\n+ * obj - {Object} The object to be modified (optional).\n *\n * Returns:\n- * {String} A feature id or undefined.\n+ * {Object} The input object, modified.\n */\n- getFeatureIdFromEvent: function(evt) {},\n+ readChildNodes: function(node, obj) {\n+ if (!obj) {\n+ obj = {};\n+ }\n+ var children = node.childNodes;\n+ var child;\n+ for (var i = 0, len = children.length; i < len; ++i) {\n+ child = children[i];\n+ if (child.nodeType == 1) {\n+ this.readNode(child, obj);\n+ }\n+ }\n+ return obj;\n+ },\n \n /**\n- * Method: eraseFeatures \n- * This is called by the layer to erase features\n- * \n+ * Method: writeNode\n+ * Shorthand for applying one of the named writers and appending the\n+ * results to a node. If a qualified name is not provided for the\n+ * second argument (and a local name is used instead), the namespace\n+ * of the parent node will be assumed.\n+ *\n * Parameters:\n- * features - {Array()} \n+ * name - {String} The name of a node to generate. If a qualified name\n+ * (e.g. \"pre:Name\") is used, the namespace prefix is assumed to be\n+ * in the group. If a local name is used (e.g. \"Name\") then\n+ * the namespace of the parent is assumed. If a local name is used\n+ * and no parent is supplied, then the default namespace is assumed.\n+ * obj - {Object} Structure containing data for the writer.\n+ * parent - {DOMElement} Result will be appended to this node. If no parent\n+ * is supplied, the node will not be appended to anything.\n+ *\n+ * Returns:\n+ * {DOMElement} The child node.\n */\n- eraseFeatures: function(features) {\n- if (!(OpenLayers.Util.isArray(features))) {\n- features = [features];\n+ writeNode: function(name, obj, parent) {\n+ var prefix, local;\n+ var split = name.indexOf(\":\");\n+ if (split > 0) {\n+ prefix = name.substring(0, split);\n+ local = name.substring(split + 1);\n+ } else {\n+ if (parent) {\n+ prefix = this.namespaceAlias[parent.namespaceURI];\n+ } else {\n+ prefix = this.defaultPrefix;\n+ }\n+ local = name;\n }\n- for (var i = 0, len = features.length; i < len; ++i) {\n- var feature = features[i];\n- this.eraseGeometry(feature.geometry, feature.id);\n- this.removeText(feature.id);\n+ var child = this.writers[prefix][local].apply(this, [obj]);\n+ if (parent) {\n+ parent.appendChild(child);\n }\n+ return child;\n },\n \n /**\n- * Method: eraseGeometry\n- * Remove a geometry from the renderer (by id).\n- * virtual function.\n- * \n+ * APIMethod: getChildEl\n+ * Get the first child element. Optionally only return the first child\n+ * if it matches the given name and namespace URI.\n+ *\n * Parameters:\n- * geometry - {} \n- * featureId - {String}\n+ * node - {DOMElement} The parent node.\n+ * name - {String} Optional node name (local) to search for.\n+ * uri - {String} Optional namespace URI to search for.\n+ *\n+ * Returns:\n+ * {DOMElement} The first child. Returns null if no element is found, if\n+ * something significant besides an element is found, or if the element\n+ * found does not match the optional name and uri.\n */\n- eraseGeometry: function(geometry, featureId) {},\n+ getChildEl: function(node, name, uri) {\n+ return node && this.getThisOrNextEl(node.firstChild, name, uri);\n+ },\n \n /**\n- * Method: moveRoot\n- * moves this renderer's root to a (different) renderer.\n- * To be implemented by subclasses that require a common renderer root for\n- * feature selection.\n- * \n+ * APIMethod: getNextEl\n+ * Get the next sibling element. Optionally get the first sibling only\n+ * if it matches the given local name and namespace URI.\n+ *\n * Parameters:\n- * renderer - {} target renderer for the moved root\n+ * node - {DOMElement} The node.\n+ * name - {String} Optional local name of the sibling to search for.\n+ * uri - {String} Optional namespace URI of the sibling to search for.\n+ *\n+ * Returns:\n+ * {DOMElement} The next sibling element. Returns null if no element is\n+ * found, something significant besides an element is found, or the\n+ * found element does not match the optional name and uri.\n */\n- moveRoot: function(renderer) {},\n+ getNextEl: function(node, name, uri) {\n+ return node && this.getThisOrNextEl(node.nextSibling, name, uri);\n+ },\n \n /**\n- * Method: getRenderLayerId\n- * Gets the layer that this renderer's output appears on. If moveRoot was\n- * used, this will be different from the id of the layer containing the\n- * features rendered by this renderer.\n- * \n+ * Method: getThisOrNextEl\n+ * Return this node or the next element node. Optionally get the first\n+ * sibling with the given local name or namespace URI.\n+ *\n+ * Parameters:\n+ * node - {DOMElement} The node.\n+ * name - {String} Optional local name of the sibling to search for.\n+ * uri - {String} Optional namespace URI of the sibling to search for.\n+ *\n * Returns:\n- * {String} the id of the output layer.\n+ * {DOMElement} The next sibling element. Returns null if no element is\n+ * found, something significant besides an element is found, or the\n+ * found element does not match the query.\n */\n- getRenderLayerId: function() {\n- return this.container.id;\n+ getThisOrNextEl: function(node, name, uri) {\n+ outer: for (var sibling = node; sibling; sibling = sibling.nextSibling) {\n+ switch (sibling.nodeType) {\n+ case 1: // Element\n+ if ((!name || name === (sibling.localName || sibling.nodeName.split(\":\").pop())) &&\n+ (!uri || uri === sibling.namespaceURI)) {\n+ // matches\n+ break outer;\n+ }\n+ sibling = null;\n+ break outer;\n+ case 3: // Text\n+ if (/^\\s*$/.test(sibling.nodeValue)) {\n+ break;\n+ }\n+ case 4: // CDATA\n+ case 6: // ENTITY_NODE\n+ case 12: // NOTATION_NODE\n+ case 10: // DOCUMENT_TYPE_NODE\n+ case 11: // DOCUMENT_FRAGMENT_NODE\n+ sibling = null;\n+ break outer;\n+ } // ignore comments and processing instructions\n+ }\n+ return sibling || null;\n },\n \n /**\n- * Method: applyDefaultSymbolizer\n- * \n+ * APIMethod: lookupNamespaceURI\n+ * Takes a prefix and returns the namespace URI associated with it on the given\n+ * node if found (and null if not). Supplying null for the prefix will\n+ * return the default namespace.\n+ *\n+ * For browsers that support it, this calls the native lookupNamesapceURI\n+ * function. In other browsers, this is an implementation of\n+ * http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespaceURI.\n+ *\n+ * For browsers that don't support the attribute.ownerElement property, this\n+ * method cannot be called on attribute nodes.\n+ * \n * Parameters:\n- * symbolizer - {Object}\n+ * node - {DOMElement} The node from which to start looking.\n+ * prefix - {String} The prefix to lookup or null to lookup the default namespace.\n * \n * Returns:\n- * {Object}\n+ * {String} The namespace URI for the given prefix. Returns null if the prefix\n+ * cannot be found or the node is the wrong type.\n */\n- applyDefaultSymbolizer: function(symbolizer) {\n- var result = OpenLayers.Util.extend({},\n- OpenLayers.Renderer.defaultSymbolizer);\n- if (symbolizer.stroke === false) {\n- delete result.strokeWidth;\n- delete result.strokeColor;\n- }\n- if (symbolizer.fill === false) {\n- delete result.fillColor;\n- }\n- OpenLayers.Util.extend(result, symbolizer);\n- return result;\n+ lookupNamespaceURI: function(node, prefix) {\n+ var uri = null;\n+ if (node) {\n+ if (node.lookupNamespaceURI) {\n+ uri = node.lookupNamespaceURI(prefix);\n+ } else {\n+ outer: switch (node.nodeType) {\n+ case 1: // ELEMENT_NODE\n+ if (node.namespaceURI !== null && node.prefix === prefix) {\n+ uri = node.namespaceURI;\n+ break outer;\n+ }\n+ var len = node.attributes.length;\n+ if (len) {\n+ var attr;\n+ for (var i = 0; i < len; ++i) {\n+ attr = node.attributes[i];\n+ if (attr.prefix === \"xmlns\" && attr.name === \"xmlns:\" + prefix) {\n+ uri = attr.value || null;\n+ break outer;\n+ } else if (attr.name === \"xmlns\" && prefix === null) {\n+ uri = attr.value || null;\n+ break outer;\n+ }\n+ }\n+ }\n+ uri = this.lookupNamespaceURI(node.parentNode, prefix);\n+ break outer;\n+ case 2: // ATTRIBUTE_NODE\n+ uri = this.lookupNamespaceURI(node.ownerElement, prefix);\n+ break outer;\n+ case 9: // DOCUMENT_NODE\n+ uri = this.lookupNamespaceURI(node.documentElement, prefix);\n+ break outer;\n+ case 6: // ENTITY_NODE\n+ case 12: // NOTATION_NODE\n+ case 10: // DOCUMENT_TYPE_NODE\n+ case 11: // DOCUMENT_FRAGMENT_NODE\n+ break outer;\n+ default:\n+ // TEXT_NODE (3), CDATA_SECTION_NODE (4), ENTITY_REFERENCE_NODE (5),\n+ // PROCESSING_INSTRUCTION_NODE (7), COMMENT_NODE (8)\n+ uri = this.lookupNamespaceURI(node.parentNode, prefix);\n+ break outer;\n+ }\n+ }\n+ }\n+ return uri;\n },\n \n- CLASS_NAME: \"OpenLayers.Renderer\"\n+ /**\n+ * Method: getXMLDoc\n+ * Get an XML document for nodes that are not supported in HTML (e.g.\n+ * createCDATASection). On IE, this will either return an existing or\n+ * create a new on the instance. On other browsers, this will\n+ * either return an existing or create a new shared document (see\n+ * ).\n+ *\n+ * Returns:\n+ * {XMLDocument}\n+ */\n+ getXMLDoc: function() {\n+ if (!OpenLayers.Format.XML.document && !this.xmldom) {\n+ if (document.implementation && document.implementation.createDocument) {\n+ OpenLayers.Format.XML.document =\n+ document.implementation.createDocument(\"\", \"\", null);\n+ } else if (!this.xmldom && window.ActiveXObject) {\n+ this.xmldom = new ActiveXObject(\"Microsoft.XMLDOM\");\n+ }\n+ }\n+ return OpenLayers.Format.XML.document || this.xmldom;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Format.XML\"\n+\n });\n \n-/**\n- * Constant: OpenLayers.Renderer.defaultSymbolizer\n- * {Object} Properties from this symbolizer will be applied to symbolizers\n- * with missing properties. This can also be used to set a global\n- * symbolizer default in OpenLayers. To be SLD 1.x compliant, add the\n- * following code before rendering any vector features:\n- * (code)\n- * OpenLayers.Renderer.defaultSymbolizer = {\n- * fillColor: \"#808080\",\n- * fillOpacity: 1,\n- * strokeColor: \"#000000\",\n- * strokeOpacity: 1,\n- * strokeWidth: 1,\n- * pointRadius: 3,\n- * graphicName: \"square\"\n- * };\n- * (end)\n- */\n-OpenLayers.Renderer.defaultSymbolizer = {\n- fillColor: \"#000000\",\n- strokeColor: \"#000000\",\n- strokeWidth: 2,\n- fillOpacity: 1,\n- strokeOpacity: 1,\n- pointRadius: 0,\n- labelAlign: 'cm'\n+OpenLayers.Format.XML.CONTENT_TYPE = {\n+ EMPTY: 0,\n+ SIMPLE: 1,\n+ COMPLEX: 2,\n+ MIXED: 3\n };\n \n-\n+/**\n+ * APIFunction: OpenLayers.Format.XML.lookupNamespaceURI\n+ * Takes a prefix and returns the namespace URI associated with it on the given\n+ * node if found (and null if not). Supplying null for the prefix will\n+ * return the default namespace.\n+ *\n+ * For browsers that support it, this calls the native lookupNamesapceURI\n+ * function. In other browsers, this is an implementation of\n+ * http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespaceURI.\n+ *\n+ * For browsers that don't support the attribute.ownerElement property, this\n+ * method cannot be called on attribute nodes.\n+ * \n+ * Parameters:\n+ * node - {DOMElement} The node from which to start looking.\n+ * prefix - {String} The prefix to lookup or null to lookup the default namespace.\n+ * \n+ * Returns:\n+ * {String} The namespace URI for the given prefix. Returns null if the prefix\n+ * cannot be found or the node is the wrong type.\n+ */\n+OpenLayers.Format.XML.lookupNamespaceURI = OpenLayers.Function.bind(\n+ OpenLayers.Format.XML.prototype.lookupNamespaceURI,\n+ OpenLayers.Format.XML.prototype\n+);\n \n /**\n- * Constant: OpenLayers.Renderer.symbol\n- * Coordinate arrays for well known (named) symbols.\n+ * Property: OpenLayers.Format.XML.document\n+ * {XMLDocument} XML document to reuse for creating non-HTML compliant nodes,\n+ * like document.createCDATASection.\n */\n-OpenLayers.Renderer.symbol = {\n- \"star\": [350, 75, 379, 161, 469, 161, 397, 215, 423, 301, 350, 250, 277, 301,\n- 303, 215, 231, 161, 321, 161, 350, 75\n- ],\n- \"cross\": [4, 0, 6, 0, 6, 4, 10, 4, 10, 6, 6, 6, 6, 10, 4, 10, 4, 6, 0, 6, 0, 4, 4, 4,\n- 4, 0\n- ],\n- \"x\": [0, 0, 25, 0, 50, 35, 75, 0, 100, 0, 65, 50, 100, 100, 75, 100, 50, 65, 25, 100, 0, 100, 35, 50, 0, 0],\n- \"square\": [0, 0, 0, 1, 1, 1, 1, 0, 0, 0],\n- \"triangle\": [0, 10, 10, 10, 5, 0, 0, 10]\n-};\n+OpenLayers.Format.XML.document = null;\n /* ======================================================================\n- OpenLayers/Symbolizer.js\n+ OpenLayers/Format/OGCExceptionReport.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Format/XML.js\n */\n \n /**\n- * Class: OpenLayers.Symbolizer\n- * Base class representing a symbolizer used for feature rendering.\n+ * Class: OpenLayers.Format.OGCExceptionReport\n+ * Class to read exception reports for various OGC services and versions.\n+ *\n+ * Inherits from:\n+ * - \n */\n-OpenLayers.Symbolizer = OpenLayers.Class({\n+OpenLayers.Format.OGCExceptionReport = OpenLayers.Class(OpenLayers.Format.XML, {\n \n+ /**\n+ * Property: namespaces\n+ * {Object} Mapping of namespace aliases to namespace URIs.\n+ */\n+ namespaces: {\n+ ogc: \"http://www.opengis.net/ogc\"\n+ },\n \n /**\n- * APIProperty: zIndex\n- * {Number} The zIndex determines the rendering order for a symbolizer.\n- * Symbolizers with larger zIndex values are rendered over symbolizers\n- * with smaller zIndex values. Default is 0.\n+ * Property: regExes\n+ * Compiled regular expressions for manipulating strings.\n */\n- zIndex: 0,\n+ regExes: {\n+ trimSpace: (/^\\s*|\\s*$/g),\n+ removeSpace: (/\\s*/g),\n+ splitSpace: (/\\s+/),\n+ trimComma: (/\\s*,\\s*/g)\n+ },\n \n /**\n- * Constructor: OpenLayers.Symbolizer\n- * Instances of this class are not useful. See one of the subclasses.\n+ * Property: defaultPrefix\n+ */\n+ defaultPrefix: \"ogc\",\n+\n+ /**\n+ * Constructor: OpenLayers.Format.OGCExceptionReport\n+ * Create a new parser for OGC exception reports.\n *\n * Parameters:\n- * config - {Object} An object containing properties to be set on the \n- * symbolizer. Any documented symbolizer property can be set at \n- * construction.\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n+ */\n+\n+ /**\n+ * APIMethod: read\n+ * Read OGC exception report data from a string, and return an object with\n+ * information about the exceptions.\n+ *\n+ * Parameters:\n+ * data - {String} or {DOMElement} data to read/parse.\n *\n * Returns:\n- * A new symbolizer.\n+ * {Object} Information about the exceptions that occurred.\n */\n- initialize: function(config) {\n- OpenLayers.Util.extend(this, config);\n+ read: function(data) {\n+ var result;\n+ if (typeof data == \"string\") {\n+ data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n+ }\n+ var root = data.documentElement;\n+ var exceptionInfo = {\n+ exceptionReport: null\n+ };\n+ if (root) {\n+ this.readChildNodes(data, exceptionInfo);\n+ if (exceptionInfo.exceptionReport === null) {\n+ // fall-back to OWSCommon since this is a common output format for exceptions\n+ // we cannot easily use the ows readers directly since they differ for 1.0 and 1.1\n+ exceptionInfo = new OpenLayers.Format.OWSCommon().read(data);\n+ }\n+ }\n+ return exceptionInfo;\n },\n \n- /** \n- * APIMethod: clone\n- * Create a copy of this symbolizer.\n- *\n- * Returns a symbolizer of the same type with the same properties.\n+ /**\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n */\n- clone: function() {\n- var Type = eval(this.CLASS_NAME);\n- return new Type(OpenLayers.Util.extend({}, this));\n+ readers: {\n+ \"ogc\": {\n+ \"ServiceExceptionReport\": function(node, obj) {\n+ obj.exceptionReport = {\n+ exceptions: []\n+ };\n+ this.readChildNodes(node, obj.exceptionReport);\n+ },\n+ \"ServiceException\": function(node, exceptionReport) {\n+ var exception = {\n+ code: node.getAttribute(\"code\"),\n+ locator: node.getAttribute(\"locator\"),\n+ text: this.getChildValue(node)\n+ };\n+ exceptionReport.exceptions.push(exception);\n+ }\n+ }\n },\n \n- CLASS_NAME: \"OpenLayers.Symbolizer\"\n+ CLASS_NAME: \"OpenLayers.Format.OGCExceptionReport\"\n \n });\n-\n /* ======================================================================\n- OpenLayers/Rule.js\n+ OpenLayers/Format/XML/VersionedOGC.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n- * @requires OpenLayers/Style.js\n+ * @requires OpenLayers/Format/XML.js\n+ * @requires OpenLayers/Format/OGCExceptionReport.js\n */\n \n /**\n- * Class: OpenLayers.Rule\n- * This class represents an SLD Rule, as being used for rule-based SLD styling.\n+ * Class: OpenLayers.Format.XML.VersionedOGC\n+ * Base class for versioned formats, i.e. a format which supports multiple\n+ * versions.\n+ *\n+ * To enable checking if parsing succeeded, you will need to define a property\n+ * called errorProperty on the parser you want to check. The parser will then\n+ * check the returned object to see if that property is present. If it is, it\n+ * assumes the parsing was successful. If it is not present (or is null), it will\n+ * pass the document through an OGCExceptionReport parser.\n+ * \n+ * If errorProperty is undefined for the parser, this error checking mechanism\n+ * will be disabled.\n+ *\n+ *\n+ * \n+ * Inherits from:\n+ * - \n */\n-OpenLayers.Rule = OpenLayers.Class({\n-\n- /**\n- * Property: id\n- * {String} A unique id for this session.\n- */\n- id: null,\n-\n- /**\n- * APIProperty: name\n- * {String} name of this rule\n- */\n- name: null,\n-\n- /**\n- * Property: title\n- * {String} Title of this rule (set if included in SLD)\n- */\n- title: null,\n+OpenLayers.Format.XML.VersionedOGC = OpenLayers.Class(OpenLayers.Format.XML, {\n \n /**\n- * Property: description\n- * {String} Description of this rule (set if abstract is included in SLD)\n+ * APIProperty: defaultVersion\n+ * {String} Version number to assume if none found.\n */\n- description: null,\n+ defaultVersion: null,\n \n /**\n- * Property: context\n- * {Object} An optional object with properties that the rule should be\n- * evaluated against. If no context is specified, feature.attributes will\n- * be used.\n+ * APIProperty: version\n+ * {String} Specify a version string if one is known.\n */\n- context: null,\n+ version: null,\n \n /**\n- * Property: filter\n- * {} Optional filter for the rule.\n+ * APIProperty: profile\n+ * {String} If provided, use a custom profile.\n */\n- filter: null,\n+ profile: null,\n \n /**\n- * Property: elseFilter\n- * {Boolean} Determines whether this rule is only to be applied only if\n- * no other rules match (ElseFilter according to the SLD specification). \n- * Default is false. For instances of OpenLayers.Rule, if elseFilter is\n- * false, the rule will always apply. For subclasses, the else property is \n- * ignored.\n+ * APIProperty: allowFallback\n+ * {Boolean} If a profiled parser cannot be found for the returned version,\n+ * use a non-profiled parser as the fallback. Application code using this\n+ * should take into account that the return object structure might be\n+ * missing the specifics of the profile. Defaults to false.\n */\n- elseFilter: false,\n+ allowFallback: false,\n \n /**\n- * Property: symbolizer\n- * {Object} Symbolizer or hash of symbolizers for this rule. If hash of\n- * symbolizers, keys are one or more of [\"Point\", \"Line\", \"Polygon\"]. The\n- * latter if useful if it is required to style e.g. vertices of a line\n- * with a point symbolizer. Note, however, that this is not implemented\n- * yet in OpenLayers, but it is the way how symbolizers are defined in\n- * SLD.\n+ * Property: name\n+ * {String} The name of this parser, this is the part of the CLASS_NAME\n+ * except for \"OpenLayers.Format.\"\n */\n- symbolizer: null,\n+ name: null,\n \n /**\n- * Property: symbolizers\n- * {Array} Collection of symbolizers associated with this rule. If \n- * provided at construction, the symbolizers array has precedence\n- * over the deprecated symbolizer property. Note that multiple \n- * symbolizers are not currently supported by the vector renderers.\n- * Rules with multiple symbolizers are currently only useful for\n- * maintaining elements in an SLD document.\n+ * APIProperty: stringifyOutput\n+ * {Boolean} If true, write will return a string otherwise a DOMElement.\n+ * Default is false.\n */\n- symbolizers: null,\n+ stringifyOutput: false,\n \n /**\n- * APIProperty: minScaleDenominator\n- * {Number} or {String} minimum scale at which to draw the feature.\n- * In the case of a String, this can be a combination of text and\n- * propertyNames in the form \"literal ${propertyName}\"\n+ * Property: parser\n+ * {Object} Instance of the versioned parser. Cached for multiple read and\n+ * write calls of the same version.\n */\n- minScaleDenominator: null,\n+ parser: null,\n \n /**\n- * APIProperty: maxScaleDenominator\n- * {Number} or {String} maximum scale at which to draw the feature.\n- * In the case of a String, this can be a combination of text and\n- * propertyNames in the form \"literal ${propertyName}\"\n- */\n- maxScaleDenominator: null,\n-\n- /** \n- * Constructor: OpenLayers.Rule\n- * Creates a Rule.\n+ * Constructor: OpenLayers.Format.XML.VersionedOGC.\n+ * Constructor.\n *\n * Parameters:\n- * options - {Object} An optional object with properties to set on the\n- * rule\n- * \n- * Returns:\n- * {}\n+ * options - {Object} Optional object whose properties will be set on\n+ * the object.\n */\n initialize: function(options) {\n- this.symbolizer = {};\n- OpenLayers.Util.extend(this, options);\n- if (this.symbolizers) {\n- delete this.symbolizer;\n- }\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+ OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);\n+ var className = this.CLASS_NAME;\n+ this.name = className.substring(className.lastIndexOf(\".\") + 1);\n },\n \n- /** \n- * APIMethod: destroy\n- * nullify references to prevent circular references and memory leaks\n+ /**\n+ * Method: getVersion\n+ * Returns the version to use. Subclasses can override this function\n+ * if a different version detection is needed.\n+ *\n+ * Parameters:\n+ * root - {DOMElement}\n+ * options - {Object} Optional configuration object.\n+ *\n+ * Returns:\n+ * {String} The version to use.\n */\n- destroy: function() {\n- for (var i in this.symbolizer) {\n- this.symbolizer[i] = null;\n+ getVersion: function(root, options) {\n+ var version;\n+ // read\n+ if (root) {\n+ version = this.version;\n+ if (!version) {\n+ version = root.getAttribute(\"version\");\n+ if (!version) {\n+ version = this.defaultVersion;\n+ }\n+ }\n+ } else { // write\n+ version = (options && options.version) ||\n+ this.version || this.defaultVersion;\n }\n- this.symbolizer = null;\n- delete this.symbolizers;\n+ return version;\n },\n \n /**\n- * APIMethod: evaluate\n- * evaluates this rule for a specific feature\n- * \n+ * Method: getParser\n+ * Get an instance of the cached parser if available, otherwise create one.\n+ *\n * Parameters:\n- * feature - {} feature to apply the rule to.\n- * \n+ * version - {String}\n+ *\n * Returns:\n- * {Boolean} true if the rule applies, false if it does not.\n- * This rule is the default rule and always returns true.\n+ * {}\n */\n- evaluate: function(feature) {\n- var context = this.getContext(feature);\n- var applies = true;\n-\n- if (this.minScaleDenominator || this.maxScaleDenominator) {\n- var scale = feature.layer.map.getScale();\n- }\n-\n- // check if within minScale/maxScale bounds\n- if (this.minScaleDenominator) {\n- applies = scale >= OpenLayers.Style.createLiteral(\n- this.minScaleDenominator, context);\n- }\n- if (applies && this.maxScaleDenominator) {\n- applies = scale < OpenLayers.Style.createLiteral(\n- this.maxScaleDenominator, context);\n- }\n-\n- // check if optional filter applies\n- if (applies && this.filter) {\n- // feature id filters get the feature, others get the context\n- if (this.filter.CLASS_NAME == \"OpenLayers.Filter.FeatureId\") {\n- applies = this.filter.evaluate(feature);\n- } else {\n- applies = this.filter.evaluate(context);\n+ getParser: function(version) {\n+ version = version || this.defaultVersion;\n+ var profile = this.profile ? \"_\" + this.profile : \"\";\n+ if (!this.parser || this.parser.VERSION != version) {\n+ var format = OpenLayers.Format[this.name][\n+ \"v\" + version.replace(/\\./g, \"_\") + profile\n+ ];\n+ if (!format) {\n+ if (profile !== \"\" && this.allowFallback) {\n+ // fallback to the non-profiled version of the parser\n+ profile = \"\";\n+ format = OpenLayers.Format[this.name][\n+ \"v\" + version.replace(/\\./g, \"_\")\n+ ];\n+ }\n+ if (!format) {\n+ throw \"Can't find a \" + this.name + \" parser for version \" +\n+ version + profile;\n+ }\n }\n+ this.parser = new format(this.options);\n }\n-\n- return applies;\n+ return this.parser;\n },\n \n /**\n- * Method: getContext\n- * Gets the context for evaluating this rule\n- * \n- * Paramters:\n- * feature - {} feature to take the context from if\n- * none is specified.\n+ * APIMethod: write\n+ * Write a document.\n+ *\n+ * Parameters:\n+ * obj - {Object} An object representing the document.\n+ * options - {Object} Optional configuration object.\n+ *\n+ * Returns:\n+ * {String} The document as a string\n */\n- getContext: function(feature) {\n- var context = this.context;\n- if (!context) {\n- context = feature.attributes || feature.data;\n- }\n- if (typeof this.context == \"function\") {\n- context = this.context(feature);\n+ write: function(obj, options) {\n+ var version = this.getVersion(null, options);\n+ this.parser = this.getParser(version);\n+ var root = this.parser.write(obj, options);\n+ if (this.stringifyOutput === false) {\n+ return root;\n+ } else {\n+ return OpenLayers.Format.XML.prototype.write.apply(this, [root]);\n }\n- return context;\n },\n \n /**\n- * APIMethod: clone\n- * Clones this rule.\n- * \n+ * APIMethod: read\n+ * Read a doc and return an object representing the document.\n+ *\n+ * Parameters:\n+ * data - {String | DOMElement} Data to read.\n+ * options - {Object} Options for the reader.\n+ *\n * Returns:\n- * {} Clone of this rule.\n+ * {Object} An object representing the document.\n */\n- clone: function() {\n- var options = OpenLayers.Util.extend({}, this);\n- if (this.symbolizers) {\n- // clone symbolizers\n- var len = this.symbolizers.length;\n- options.symbolizers = new Array(len);\n- for (var i = 0; i < len; ++i) {\n- options.symbolizers[i] = this.symbolizers[i].clone();\n- }\n- } else {\n- // clone symbolizer\n- options.symbolizer = {};\n- var value, type;\n- for (var key in this.symbolizer) {\n- value = this.symbolizer[key];\n- type = typeof value;\n- if (type === \"object\") {\n- options.symbolizer[key] = OpenLayers.Util.extend({}, value);\n- } else if (type === \"string\") {\n- options.symbolizer[key] = value;\n- }\n- }\n+ read: function(data, options) {\n+ if (typeof data == \"string\") {\n+ data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n }\n- // clone filter\n- options.filter = this.filter && this.filter.clone();\n- // clone context\n- options.context = this.context && OpenLayers.Util.extend({}, this.context);\n- return new OpenLayers.Rule(options);\n+ var root = data.documentElement;\n+ var version = this.getVersion(root);\n+ this.parser = this.getParser(version); // Select the parser\n+ var obj = this.parser.read(data, options); // Parse the data\n+\n+ var errorProperty = this.parser.errorProperty || null;\n+ if (errorProperty !== null && obj[errorProperty] === undefined) {\n+ // an error must have happened, so parse it and report back\n+ var format = new OpenLayers.Format.OGCExceptionReport();\n+ obj.error = format.read(data);\n+ }\n+ obj.version = version;\n+ return obj;\n },\n \n- CLASS_NAME: \"OpenLayers.Rule\"\n+ CLASS_NAME: \"OpenLayers.Format.XML.VersionedOGC\"\n });\n /* ======================================================================\n- OpenLayers/Format/WPSDescribeProcess.js\n+ OpenLayers/Format/OWSCommon.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format/XML.js\n- * @requires OpenLayers/Format/OWSCommon/v1_1_0.js\n+ * @requires OpenLayers/Format/XML/VersionedOGC.js\n */\n \n /**\n- * Class: OpenLayers.Format.WPSDescribeProcess\n- * Read WPS DescribeProcess responses. \n- *\n+ * Class: OpenLayers.Format.OWSCommon\n+ * Read OWSCommon. Create a new instance with the \n+ * constructor.\n+ * \n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Format.WPSDescribeProcess = OpenLayers.Class(\n- OpenLayers.Format.XML, {\n-\n- /**\n- * Constant: VERSION\n- * {String} 1.0.0\n- */\n- VERSION: \"1.0.0\",\n-\n- /**\n- * Property: namespaces\n- * {Object} Mapping of namespace aliases to namespace URIs.\n- */\n- namespaces: {\n- wps: \"http://www.opengis.net/wps/1.0.0\",\n- ows: \"http://www.opengis.net/ows/1.1\",\n- xsi: \"http://www.w3.org/2001/XMLSchema-instance\"\n- },\n-\n- /**\n- * Property: schemaLocation\n- * {String} Schema location\n- */\n- schemaLocation: \"http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd\",\n-\n- /**\n- * Property: defaultPrefix\n- */\n- defaultPrefix: \"wps\",\n+OpenLayers.Format.OWSCommon = OpenLayers.Class(OpenLayers.Format.XML.VersionedOGC, {\n \n- /**\n- * Property: regExes\n- * Compiled regular expressions for manipulating strings.\n- */\n- regExes: {\n- trimSpace: (/^\\s*|\\s*$/g),\n- removeSpace: (/\\s*/g),\n- splitSpace: (/\\s+/),\n- trimComma: (/\\s*,\\s*/g)\n- },\n+ /**\n+ * APIProperty: defaultVersion\n+ * {String} Version number to assume if none found. Default is \"1.0.0\".\n+ */\n+ defaultVersion: \"1.0.0\",\n \n- /**\n- * Constructor: OpenLayers.Format.WPSDescribeProcess\n- *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n- */\n+ /**\n+ * Constructor: OpenLayers.Format.OWSCommon\n+ * Create a new parser for OWSCommon.\n+ *\n+ * Parameters:\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n+ */\n \n- /**\n- * APIMethod: read\n- * Parse a WPS DescribeProcess and return an object with its information.\n- * \n- * Parameters: \n- * data - {String} or {DOMElement} data to read/parse.\n- *\n- * Returns:\n- * {Object}\n- */\n- read: function(data) {\n- if (typeof data == \"string\") {\n- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n+ /**\n+ * Method: getVersion\n+ * Returns the version to use. Subclasses can override this function\n+ * if a different version detection is needed.\n+ *\n+ * Parameters:\n+ * root - {DOMElement}\n+ * options - {Object} Optional configuration object.\n+ *\n+ * Returns:\n+ * {String} The version to use.\n+ */\n+ getVersion: function(root, options) {\n+ var version = this.version;\n+ if (!version) {\n+ // remember version does not correspond to the OWS version\n+ // it corresponds to the WMS/WFS/WCS etc. request version\n+ var uri = root.getAttribute(\"xmlns:ows\");\n+ // the above will fail if the namespace prefix is different than\n+ // ows and if the namespace is declared on a different element\n+ if (uri && uri.substring(uri.lastIndexOf(\"/\") + 1) === \"1.1\") {\n+ version = \"1.1.0\";\n }\n- if (data && data.nodeType == 9) {\n- data = data.documentElement;\n+ if (!version) {\n+ version = this.defaultVersion;\n }\n- var info = {};\n- this.readNode(data, info);\n- return info;\n- },\n-\n- /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n- */\n- readers: {\n- \"wps\": {\n- \"ProcessDescriptions\": function(node, obj) {\n- obj.processDescriptions = {};\n- this.readChildNodes(node, obj.processDescriptions);\n- },\n- \"ProcessDescription\": function(node, processDescriptions) {\n- var processVersion = this.getAttributeNS(node, this.namespaces.wps, \"processVersion\");\n- var processDescription = {\n- processVersion: processVersion,\n- statusSupported: (node.getAttribute(\"statusSupported\") === \"true\"),\n- storeSupported: (node.getAttribute(\"storeSupported\") === \"true\")\n- };\n- this.readChildNodes(node, processDescription);\n- processDescriptions[processDescription.identifier] = processDescription;\n- },\n- \"DataInputs\": function(node, processDescription) {\n- processDescription.dataInputs = [];\n- this.readChildNodes(node, processDescription.dataInputs);\n- },\n- \"ProcessOutputs\": function(node, processDescription) {\n- processDescription.processOutputs = [];\n- this.readChildNodes(node, processDescription.processOutputs);\n- },\n- \"Output\": function(node, processOutputs) {\n- var output = {};\n- this.readChildNodes(node, output);\n- processOutputs.push(output);\n- },\n- \"ComplexOutput\": function(node, output) {\n- output.complexOutput = {};\n- this.readChildNodes(node, output.complexOutput);\n- },\n- \"LiteralOutput\": function(node, output) {\n- output.literalOutput = {};\n- this.readChildNodes(node, output.literalOutput);\n- },\n- \"Input\": function(node, dataInputs) {\n- var input = {\n- maxOccurs: parseInt(node.getAttribute(\"maxOccurs\")),\n- minOccurs: parseInt(node.getAttribute(\"minOccurs\"))\n- };\n- this.readChildNodes(node, input);\n- dataInputs.push(input);\n- },\n- \"BoundingBoxData\": function(node, input) {\n- input.boundingBoxData = {};\n- this.readChildNodes(node, input.boundingBoxData);\n- },\n- \"CRS\": function(node, obj) {\n- if (!obj.CRSs) {\n- obj.CRSs = {};\n- }\n- obj.CRSs[this.getChildValue(node)] = true;\n- },\n- \"LiteralData\": function(node, input) {\n- input.literalData = {};\n- this.readChildNodes(node, input.literalData);\n- },\n- \"ComplexData\": function(node, input) {\n- input.complexData = {};\n- this.readChildNodes(node, input.complexData);\n- },\n- \"Default\": function(node, complexData) {\n- complexData[\"default\"] = {};\n- this.readChildNodes(node, complexData[\"default\"]);\n- },\n- \"Supported\": function(node, complexData) {\n- complexData[\"supported\"] = {};\n- this.readChildNodes(node, complexData[\"supported\"]);\n- },\n- \"Format\": function(node, obj) {\n- var format = {};\n- this.readChildNodes(node, format);\n- if (!obj.formats) {\n- obj.formats = {};\n- }\n- obj.formats[format.mimeType] = true;\n- },\n- \"MimeType\": function(node, format) {\n- format.mimeType = this.getChildValue(node);\n- }\n- },\n- \"ows\": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers[\"ows\"]\n- },\n+ }\n+ return version;\n+ },\n \n- CLASS_NAME: \"OpenLayers.Format.WPSDescribeProcess\"\n+ /**\n+ * APIMethod: read\n+ * Read an OWSCommon document and return an object.\n+ *\n+ * Parameters:\n+ * data - {String | DOMElement} Data to read.\n+ * options - {Object} Options for the reader.\n+ *\n+ * Returns:\n+ * {Object} An object representing the structure of the document.\n+ */\n \n- });\n+ CLASS_NAME: \"OpenLayers.Format.OWSCommon\"\n+});\n /* ======================================================================\n- OpenLayers/WPSClient.js\n+ OpenLayers/Format/OWSCommon/v1.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/SingleFile.js\n- */\n-\n-/**\n- * @requires OpenLayers/Events.js\n- * @requires OpenLayers/WPSProcess.js\n- * @requires OpenLayers/Format/WPSDescribeProcess.js\n- * @requires OpenLayers/Request.js\n+ * @requires OpenLayers/Format/OWSCommon.js\n */\n \n /**\n- * Class: OpenLayers.WPSClient\n- * High level API for interaction with Web Processing Services (WPS).\n- * An instance is used to create \n- * instances for servers known to the WPSClient. The WPSClient also caches\n- * DescribeProcess responses to reduce the number of requests sent to servers\n- * when processes are created.\n+ * Class: OpenLayers.Format.OWSCommon.v1\n+ * Common readers and writers for OWSCommon v1.X formats\n+ *\n+ * Inherits from:\n+ * - \n */\n-OpenLayers.WPSClient = OpenLayers.Class({\n-\n- /**\n- * Property: servers\n- * {Object} Service metadata, keyed by a local identifier.\n- *\n- * Properties:\n- * url - {String} the url of the server\n- * version - {String} WPS version of the server\n- * processDescription - {Object} Cache of raw DescribeProcess\n- * responses, keyed by process identifier.\n- */\n- servers: null,\n-\n- /**\n- * Property: version\n- * {String} The default WPS version to use if none is configured. Default\n- * is '1.0.0'.\n- */\n- version: '1.0.0',\n-\n- /**\n- * Property: lazy\n- * {Boolean} Should the DescribeProcess be deferred until a process is\n- * fully configured? Default is false.\n- */\n- lazy: false,\n-\n- /**\n- * Property: events\n- * {}\n- *\n- * Supported event types:\n- * describeprocess - Fires when the process description is available.\n- * Listeners receive an object with a 'raw' property holding the raw\n- * DescribeProcess response, and an 'identifier' property holding the\n- * process identifier of the described process.\n- */\n- events: null,\n+OpenLayers.Format.OWSCommon.v1 = OpenLayers.Class(OpenLayers.Format.XML, {\n \n /**\n- * Constructor: OpenLayers.WPSClient\n- *\n- * Parameters:\n- * options - {Object} Object whose properties will be set on the instance.\n- *\n- * Avaliable options:\n- * servers - {Object} Mandatory. Service metadata, keyed by a local\n- * identifier. Can either be a string with the service url or an\n- * object literal with additional metadata:\n- *\n- * (code)\n- * servers: {\n- * local: '/geoserver/wps'\n- * }, {\n- * opengeo: {\n- * url: 'http://demo.opengeo.org/geoserver/wps',\n- * version: '1.0.0'\n- * }\n- * }\n- * (end)\n- *\n- * lazy - {Boolean} Optional. Set to true if DescribeProcess should not be\n- * requested until a process is fully configured. Default is false.\n+ * Property: regExes\n+ * Compiled regular expressions for manipulating strings.\n */\n- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n- this.events = new OpenLayers.Events(this);\n- this.servers = {};\n- for (var s in options.servers) {\n- this.servers[s] = typeof options.servers[s] == 'string' ? {\n- url: options.servers[s],\n- version: this.version,\n- processDescription: {}\n- } : options.servers[s];\n- }\n+ regExes: {\n+ trimSpace: (/^\\s*|\\s*$/g),\n+ removeSpace: (/\\s*/g),\n+ splitSpace: (/\\s+/),\n+ trimComma: (/\\s*,\\s*/g)\n },\n \n /**\n- * APIMethod: execute\n- * Shortcut to execute a process with a single function call. This is\n- * equivalent to using and then calling execute on the\n- * process.\n+ * Method: read\n *\n * Parameters:\n- * options - {Object} Options for the execute operation.\n+ * data - {DOMElement} An OWSCommon document element.\n+ * options - {Object} Options for the reader.\n *\n- * Available options:\n- * server - {String} Mandatory. One of the local identifiers of the\n- * configured servers.\n- * process - {String} Mandatory. A process identifier known to the\n- * server.\n- * inputs - {Object} The inputs for the process, keyed by input identifier.\n- * For spatial data inputs, the value of an input is usually an\n- * , an or an array of\n- * geometries or features.\n- * output - {String} The identifier of an output to parse. Optional. If not\n- * provided, the first output will be parsed.\n- * success - {Function} Callback to call when the process is complete.\n- * This function is called with an outputs object as argument, which\n- * will have a property with the identifier of the requested output\n- * (e.g. 'result'). For processes that generate spatial output, the\n- * value will either be a single or an\n- * array of features.\n- * scope - {Object} Optional scope for the success callback.\n+ * Returns:\n+ * {Object} An object representing the OWSCommon document.\n */\n- execute: function(options) {\n- var process = this.getProcess(options.server, options.process);\n- process.execute({\n- inputs: options.inputs,\n- success: options.success,\n- scope: options.scope\n- });\n+ read: function(data, options) {\n+ options = OpenLayers.Util.applyDefaults(options, this.options);\n+ var ows = {};\n+ this.readChildNodes(data, ows);\n+ return ows;\n },\n \n /**\n- * APIMethod: getProcess\n- * Creates an .\n- *\n- * Parameters:\n- * serverID - {String} Local identifier from the servers that this instance\n- * was constructed with.\n- * processID - {String} Process identifier known to the server.\n- *\n- * Returns:\n- * {}\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n */\n- getProcess: function(serverID, processID) {\n- var process = new OpenLayers.WPSProcess({\n- client: this,\n- server: serverID,\n- identifier: processID\n- });\n- if (!this.lazy) {\n- process.describe();\n+ readers: {\n+ \"ows\": {\n+ \"Exception\": function(node, exceptionReport) {\n+ var exception = {\n+ code: node.getAttribute('exceptionCode'),\n+ locator: node.getAttribute('locator'),\n+ texts: []\n+ };\n+ exceptionReport.exceptions.push(exception);\n+ this.readChildNodes(node, exception);\n+ },\n+ \"ExceptionText\": function(node, exception) {\n+ var text = this.getChildValue(node);\n+ exception.texts.push(text);\n+ },\n+ \"ServiceIdentification\": function(node, obj) {\n+ obj.serviceIdentification = {};\n+ this.readChildNodes(node, obj.serviceIdentification);\n+ },\n+ \"Title\": function(node, obj) {\n+ obj.title = this.getChildValue(node);\n+ },\n+ \"Abstract\": function(node, serviceIdentification) {\n+ serviceIdentification[\"abstract\"] = this.getChildValue(node);\n+ },\n+ \"Keywords\": function(node, serviceIdentification) {\n+ serviceIdentification.keywords = {};\n+ this.readChildNodes(node, serviceIdentification.keywords);\n+ },\n+ \"Keyword\": function(node, keywords) {\n+ keywords[this.getChildValue(node)] = true;\n+ },\n+ \"ServiceType\": function(node, serviceIdentification) {\n+ serviceIdentification.serviceType = {\n+ codeSpace: node.getAttribute('codeSpace'),\n+ value: this.getChildValue(node)\n+ };\n+ },\n+ \"ServiceTypeVersion\": function(node, serviceIdentification) {\n+ serviceIdentification.serviceTypeVersion = this.getChildValue(node);\n+ },\n+ \"Fees\": function(node, serviceIdentification) {\n+ serviceIdentification.fees = this.getChildValue(node);\n+ },\n+ \"AccessConstraints\": function(node, serviceIdentification) {\n+ serviceIdentification.accessConstraints =\n+ this.getChildValue(node);\n+ },\n+ \"ServiceProvider\": function(node, obj) {\n+ obj.serviceProvider = {};\n+ this.readChildNodes(node, obj.serviceProvider);\n+ },\n+ \"ProviderName\": function(node, serviceProvider) {\n+ serviceProvider.providerName = this.getChildValue(node);\n+ },\n+ \"ProviderSite\": function(node, serviceProvider) {\n+ serviceProvider.providerSite = this.getAttributeNS(node,\n+ this.namespaces.xlink, \"href\");\n+ },\n+ \"ServiceContact\": function(node, serviceProvider) {\n+ serviceProvider.serviceContact = {};\n+ this.readChildNodes(node, serviceProvider.serviceContact);\n+ },\n+ \"IndividualName\": function(node, serviceContact) {\n+ serviceContact.individualName = this.getChildValue(node);\n+ },\n+ \"PositionName\": function(node, serviceContact) {\n+ serviceContact.positionName = this.getChildValue(node);\n+ },\n+ \"ContactInfo\": function(node, serviceContact) {\n+ serviceContact.contactInfo = {};\n+ this.readChildNodes(node, serviceContact.contactInfo);\n+ },\n+ \"Phone\": function(node, contactInfo) {\n+ contactInfo.phone = {};\n+ this.readChildNodes(node, contactInfo.phone);\n+ },\n+ \"Voice\": function(node, phone) {\n+ phone.voice = this.getChildValue(node);\n+ },\n+ \"Address\": function(node, contactInfo) {\n+ contactInfo.address = {};\n+ this.readChildNodes(node, contactInfo.address);\n+ },\n+ \"DeliveryPoint\": function(node, address) {\n+ address.deliveryPoint = this.getChildValue(node);\n+ },\n+ \"City\": function(node, address) {\n+ address.city = this.getChildValue(node);\n+ },\n+ \"AdministrativeArea\": function(node, address) {\n+ address.administrativeArea = this.getChildValue(node);\n+ },\n+ \"PostalCode\": function(node, address) {\n+ address.postalCode = this.getChildValue(node);\n+ },\n+ \"Country\": function(node, address) {\n+ address.country = this.getChildValue(node);\n+ },\n+ \"ElectronicMailAddress\": function(node, address) {\n+ address.electronicMailAddress = this.getChildValue(node);\n+ },\n+ \"Role\": function(node, serviceContact) {\n+ serviceContact.role = this.getChildValue(node);\n+ },\n+ \"OperationsMetadata\": function(node, obj) {\n+ obj.operationsMetadata = {};\n+ this.readChildNodes(node, obj.operationsMetadata);\n+ },\n+ \"Operation\": function(node, operationsMetadata) {\n+ var name = node.getAttribute(\"name\");\n+ operationsMetadata[name] = {};\n+ this.readChildNodes(node, operationsMetadata[name]);\n+ },\n+ \"DCP\": function(node, operation) {\n+ operation.dcp = {};\n+ this.readChildNodes(node, operation.dcp);\n+ },\n+ \"HTTP\": function(node, dcp) {\n+ dcp.http = {};\n+ this.readChildNodes(node, dcp.http);\n+ },\n+ \"Get\": function(node, http) {\n+ if (!http.get) {\n+ http.get = [];\n+ }\n+ var obj = {\n+ url: this.getAttributeNS(node, this.namespaces.xlink, \"href\")\n+ };\n+ this.readChildNodes(node, obj);\n+ http.get.push(obj);\n+ },\n+ \"Post\": function(node, http) {\n+ if (!http.post) {\n+ http.post = [];\n+ }\n+ var obj = {\n+ url: this.getAttributeNS(node, this.namespaces.xlink, \"href\")\n+ };\n+ this.readChildNodes(node, obj);\n+ http.post.push(obj);\n+ },\n+ \"Parameter\": function(node, operation) {\n+ if (!operation.parameters) {\n+ operation.parameters = {};\n+ }\n+ var name = node.getAttribute(\"name\");\n+ operation.parameters[name] = {};\n+ this.readChildNodes(node, operation.parameters[name]);\n+ },\n+ \"Constraint\": function(node, obj) {\n+ if (!obj.constraints) {\n+ obj.constraints = {};\n+ }\n+ var name = node.getAttribute(\"name\");\n+ obj.constraints[name] = {};\n+ this.readChildNodes(node, obj.constraints[name]);\n+ },\n+ \"Value\": function(node, allowedValues) {\n+ allowedValues[this.getChildValue(node)] = true;\n+ },\n+ \"OutputFormat\": function(node, obj) {\n+ obj.formats.push({\n+ value: this.getChildValue(node)\n+ });\n+ this.readChildNodes(node, obj);\n+ },\n+ \"WGS84BoundingBox\": function(node, obj) {\n+ var boundingBox = {};\n+ boundingBox.crs = node.getAttribute(\"crs\");\n+ if (obj.BoundingBox) {\n+ obj.BoundingBox.push(boundingBox);\n+ } else {\n+ obj.projection = boundingBox.crs;\n+ boundingBox = obj;\n+ }\n+ this.readChildNodes(node, boundingBox);\n+ },\n+ \"BoundingBox\": function(node, obj) {\n+ // FIXME: We consider that BoundingBox is the same as WGS84BoundingBox\n+ // LowerCorner = \"min_x min_y\"\n+ // UpperCorner = \"max_x max_y\"\n+ // It should normally depend on the projection\n+ this.readers['ows']['WGS84BoundingBox'].apply(this, [node, obj]);\n+ },\n+ \"LowerCorner\": function(node, obj) {\n+ var str = this.getChildValue(node).replace(\n+ this.regExes.trimSpace, \"\");\n+ str = str.replace(this.regExes.trimComma, \",\");\n+ var pointList = str.split(this.regExes.splitSpace);\n+ obj.left = pointList[0];\n+ obj.bottom = pointList[1];\n+ },\n+ \"UpperCorner\": function(node, obj) {\n+ var str = this.getChildValue(node).replace(\n+ this.regExes.trimSpace, \"\");\n+ str = str.replace(this.regExes.trimComma, \",\");\n+ var pointList = str.split(this.regExes.splitSpace);\n+ obj.right = pointList[0];\n+ obj.top = pointList[1];\n+ obj.bounds = new OpenLayers.Bounds(obj.left, obj.bottom,\n+ obj.right, obj.top);\n+ delete obj.left;\n+ delete obj.bottom;\n+ delete obj.right;\n+ delete obj.top;\n+ },\n+ \"Language\": function(node, obj) {\n+ obj.language = this.getChildValue(node);\n+ }\n }\n- return process;\n },\n \n /**\n- * Method: describeProcess\n- *\n- * Parameters:\n- * serverID - {String} Identifier of the server\n- * processID - {String} Identifier of the requested process\n- * callback - {Function} Callback to call when the description is available\n- * scope - {Object} Optional execution scope for the callback function\n+ * Property: writers\n+ * As a compliment to the readers property, this structure contains public\n+ * writing functions grouped by namespace alias and named like the\n+ * node names they produce.\n */\n- describeProcess: function(serverID, processID, callback, scope) {\n- var server = this.servers[serverID];\n- if (!server.processDescription[processID]) {\n- if (!(processID in server.processDescription)) {\n- // set to null so we know a describeFeature request is pending\n- server.processDescription[processID] = null;\n- OpenLayers.Request.GET({\n- url: server.url,\n- params: {\n- SERVICE: 'WPS',\n- VERSION: server.version,\n- REQUEST: 'DescribeProcess',\n- IDENTIFIER: processID\n- },\n- success: function(response) {\n- server.processDescription[processID] = response.responseText;\n- this.events.triggerEvent('describeprocess', {\n- identifier: processID,\n- raw: response.responseText\n- });\n- },\n- scope: this\n- });\n- } else {\n- // pending request\n- this.events.register('describeprocess', this, function describe(evt) {\n- if (evt.identifier === processID) {\n- this.events.unregister('describeprocess', this, describe);\n- callback.call(scope, evt.raw);\n+ writers: {\n+ \"ows\": {\n+ \"BoundingBox\": function(options, nodeName) {\n+ var node = this.createElementNSPlus(nodeName || \"ows:BoundingBox\", {\n+ attributes: {\n+ crs: options.projection\n }\n });\n+ this.writeNode(\"ows:LowerCorner\", options, node);\n+ this.writeNode(\"ows:UpperCorner\", options, node);\n+ return node;\n+ },\n+ \"LowerCorner\": function(options) {\n+ var node = this.createElementNSPlus(\"ows:LowerCorner\", {\n+ value: options.bounds.left + \" \" + options.bounds.bottom\n+ });\n+ return node;\n+ },\n+ \"UpperCorner\": function(options) {\n+ var node = this.createElementNSPlus(\"ows:UpperCorner\", {\n+ value: options.bounds.right + \" \" + options.bounds.top\n+ });\n+ return node;\n+ },\n+ \"Identifier\": function(identifier) {\n+ var node = this.createElementNSPlus(\"ows:Identifier\", {\n+ value: identifier\n+ });\n+ return node;\n+ },\n+ \"Title\": function(title) {\n+ var node = this.createElementNSPlus(\"ows:Title\", {\n+ value: title\n+ });\n+ return node;\n+ },\n+ \"Abstract\": function(abstractValue) {\n+ var node = this.createElementNSPlus(\"ows:Abstract\", {\n+ value: abstractValue\n+ });\n+ return node;\n+ },\n+ \"OutputFormat\": function(format) {\n+ var node = this.createElementNSPlus(\"ows:OutputFormat\", {\n+ value: format\n+ });\n+ return node;\n }\n- } else {\n- window.setTimeout(function() {\n- callback.call(scope, server.processDescription[processID]);\n- }, 0);\n }\n },\n \n- /**\n- * Method: destroy\n- */\n- destroy: function() {\n- this.events.destroy();\n- this.events = null;\n- this.servers = null;\n- },\n-\n- CLASS_NAME: 'OpenLayers.WPSClient'\n+ CLASS_NAME: \"OpenLayers.Format.OWSCommon.v1\"\n \n });\n /* ======================================================================\n- OpenLayers/Kinetic.js\n+ OpenLayers/Format/OWSCommon/v1_1_0.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Animation.js\n+ * @requires OpenLayers/Format/OWSCommon/v1.js\n */\n \n-OpenLayers.Kinetic = OpenLayers.Class({\n+/**\n+ * Class: OpenLayers.Format.OWSCommon.v1_1_0\n+ * Parser for OWS Common version 1.1.0.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Format.OWSCommon.v1_1_0 = OpenLayers.Class(OpenLayers.Format.OWSCommon.v1, {\n \n /**\n- * Property: threshold\n- * In most cases changing the threshold isn't needed.\n- * In px/ms, default to 0.\n+ * Property: namespaces\n+ * {Object} Mapping of namespace aliases to namespace URIs.\n */\n- threshold: 0,\n+ namespaces: {\n+ ows: \"http://www.opengis.net/ows/1.1\",\n+ xlink: \"http://www.w3.org/1999/xlink\"\n+ },\n \n /**\n- * Property: deceleration\n- * {Float} the deseleration in px/ms\u00b2, default to 0.0035.\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n */\n- deceleration: 0.0035,\n+ readers: {\n+ \"ows\": OpenLayers.Util.applyDefaults({\n+ \"ExceptionReport\": function(node, obj) {\n+ obj.exceptionReport = {\n+ version: node.getAttribute('version'),\n+ language: node.getAttribute('xml:lang'),\n+ exceptions: []\n+ };\n+ this.readChildNodes(node, obj.exceptionReport);\n+ },\n+ \"AllowedValues\": function(node, parameter) {\n+ parameter.allowedValues = {};\n+ this.readChildNodes(node, parameter.allowedValues);\n+ },\n+ \"AnyValue\": function(node, parameter) {\n+ parameter.anyValue = true;\n+ },\n+ \"DataType\": function(node, parameter) {\n+ parameter.dataType = this.getChildValue(node);\n+ },\n+ \"Range\": function(node, allowedValues) {\n+ allowedValues.range = {};\n+ this.readChildNodes(node, allowedValues.range);\n+ },\n+ \"MinimumValue\": function(node, range) {\n+ range.minValue = this.getChildValue(node);\n+ },\n+ \"MaximumValue\": function(node, range) {\n+ range.maxValue = this.getChildValue(node);\n+ },\n+ \"Identifier\": function(node, obj) {\n+ obj.identifier = this.getChildValue(node);\n+ },\n+ \"SupportedCRS\": function(node, obj) {\n+ obj.supportedCRS = this.getChildValue(node);\n+ }\n+ }, OpenLayers.Format.OWSCommon.v1.prototype.readers[\"ows\"])\n+ },\n \n /**\n- * Property: nbPoints\n- * {Integer} the number of points we use to calculate the kinetic\n- * initial values.\n+ * Property: writers\n+ * As a compliment to the readers property, this structure contains public\n+ * writing functions grouped by namespace alias and named like the\n+ * node names they produce.\n */\n- nbPoints: 100,\n+ writers: {\n+ \"ows\": OpenLayers.Util.applyDefaults({\n+ \"Range\": function(range) {\n+ var node = this.createElementNSPlus(\"ows:Range\", {\n+ attributes: {\n+ 'ows:rangeClosure': range.closure\n+ }\n+ });\n+ this.writeNode(\"ows:MinimumValue\", range.minValue, node);\n+ this.writeNode(\"ows:MaximumValue\", range.maxValue, node);\n+ return node;\n+ },\n+ \"MinimumValue\": function(minValue) {\n+ var node = this.createElementNSPlus(\"ows:MinimumValue\", {\n+ value: minValue\n+ });\n+ return node;\n+ },\n+ \"MaximumValue\": function(maxValue) {\n+ var node = this.createElementNSPlus(\"ows:MaximumValue\", {\n+ value: maxValue\n+ });\n+ return node;\n+ },\n+ \"Value\": function(value) {\n+ var node = this.createElementNSPlus(\"ows:Value\", {\n+ value: value\n+ });\n+ return node;\n+ }\n+ }, OpenLayers.Format.OWSCommon.v1.prototype.writers[\"ows\"])\n+ },\n \n- /**\n- * Property: delay\n- * {Float} time to consider to calculate the kinetic initial values.\n- * In ms, default to 200.\n- */\n- delay: 200,\n+ CLASS_NAME: \"OpenLayers.Format.OWSCommon.v1_1_0\"\n+\n+});\n+/* ======================================================================\n+ OpenLayers/Format/WCSGetCoverage.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Format/XML.js\n+ * @requires OpenLayers/Format/OWSCommon/v1_1_0.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Format.WCSGetCoverage version 1.1.0\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Format.WCSGetCoverage = OpenLayers.Class(OpenLayers.Format.XML, {\n \n /**\n- * Property: points\n- * List of points use to calculate the kinetic initial values.\n+ * Property: namespaces\n+ * {Object} Mapping of namespace aliases to namespace URIs.\n */\n- points: undefined,\n+ namespaces: {\n+ ows: \"http://www.opengis.net/ows/1.1\",\n+ wcs: \"http://www.opengis.net/wcs/1.1\",\n+ xlink: \"http://www.w3.org/1999/xlink\",\n+ xsi: \"http://www.w3.org/2001/XMLSchema-instance\"\n+ },\n \n /**\n- * Property: timerId\n- * ID of the timer.\n+ * Property: regExes\n+ * Compiled regular expressions for manipulating strings.\n */\n- timerId: undefined,\n+ regExes: {\n+ trimSpace: (/^\\s*|\\s*$/g),\n+ removeSpace: (/\\s*/g),\n+ splitSpace: (/\\s+/),\n+ trimComma: (/\\s*,\\s*/g)\n+ },\n \n /**\n- * Constructor: OpenLayers.Kinetic\n- *\n- * Parameters:\n- * options - {Object}\n+ * Constant: VERSION\n+ * {String} 1.1.2\n */\n- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n- },\n+ VERSION: \"1.1.2\",\n \n /**\n- * Method: begin\n- * Begins the dragging.\n+ * Property: schemaLocation\n+ * {String} Schema location\n */\n- begin: function() {\n- OpenLayers.Animation.stop(this.timerId);\n- this.timerId = undefined;\n- this.points = [];\n- },\n+ schemaLocation: \"http://www.opengis.net/wcs/1.1 http://schemas.opengis.net/wcs/1.1/wcsGetCoverage.xsd\",\n \n /**\n- * Method: update\n- * Updates during the dragging.\n+ * Constructor: OpenLayers.Format.WCSGetCoverage\n *\n * Parameters:\n- * xy - {} The new position.\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n */\n- update: function(xy) {\n- this.points.unshift({\n- xy: xy,\n- tick: new Date().getTime()\n- });\n- if (this.points.length > this.nbPoints) {\n- this.points.pop();\n- }\n- },\n \n /**\n- * Method: end\n- * Ends the dragging, start the kinetic.\n+ * Method: write\n *\n * Parameters:\n- * xy - {} The last position.\n+ * options - {Object} Optional object.\n *\n * Returns:\n- * {Object} An object with two properties: \"speed\", and \"theta\". The\n- * \"speed\" and \"theta\" values are to be passed to the move \n- * function when starting the animation.\n+ * {String} A WCS GetCoverage request XML string.\n */\n- end: function(xy) {\n- var last, now = new Date().getTime();\n- for (var i = 0, l = this.points.length, point; i < l; i++) {\n- point = this.points[i];\n- if (now - point.tick > this.delay) {\n- break;\n- }\n- last = point;\n- }\n- if (!last) {\n- return;\n- }\n- var time = new Date().getTime() - last.tick;\n- var dist = Math.sqrt(Math.pow(xy.x - last.xy.x, 2) +\n- Math.pow(xy.y - last.xy.y, 2));\n- var speed = dist / time;\n- if (speed == 0 || speed < this.threshold) {\n- return;\n- }\n- var theta = Math.asin((xy.y - last.xy.y) / dist);\n- if (last.xy.x <= xy.x) {\n- theta = Math.PI - theta;\n- }\n- return {\n- speed: speed,\n- theta: theta\n- };\n+ write: function(options) {\n+ var node = this.writeNode(\"wcs:GetCoverage\", options);\n+ this.setAttributeNS(\n+ node, this.namespaces.xsi,\n+ \"xsi:schemaLocation\", this.schemaLocation\n+ );\n+ return OpenLayers.Format.XML.prototype.write.apply(this, [node]);\n },\n \n /**\n- * Method: move\n- * Launch the kinetic move pan.\n- *\n- * Parameters:\n- * info - {Object} An object with two properties, \"speed\", and \"theta\".\n- * These values are those returned from the \"end\" call.\n- * callback - {Function} Function called on every step of the animation,\n- * receives x, y (values to pan), end (is the last point).\n+ * Property: writers\n+ * As a compliment to the readers property, this structure contains public\n+ * writing functions grouped by namespace alias and named like the\n+ * node names they produce.\n */\n- move: function(info, callback) {\n- var v0 = info.speed;\n- var fx = Math.cos(info.theta);\n- var fy = -Math.sin(info.theta);\n-\n- var initialTime = new Date().getTime();\n-\n- var lastX = 0;\n- var lastY = 0;\n-\n- var timerCallback = function() {\n- if (this.timerId == null) {\n- return;\n- }\n-\n- var t = new Date().getTime() - initialTime;\n-\n- var p = (-this.deceleration * Math.pow(t, 2)) / 2.0 + v0 * t;\n- var x = p * fx;\n- var y = p * fy;\n-\n- var args = {};\n- args.end = false;\n- var v = -this.deceleration * t + v0;\n-\n- if (v <= 0) {\n- OpenLayers.Animation.stop(this.timerId);\n- this.timerId = null;\n- args.end = true;\n+ writers: {\n+ \"wcs\": {\n+ \"GetCoverage\": function(options) {\n+ var node = this.createElementNSPlus(\"wcs:GetCoverage\", {\n+ attributes: {\n+ version: options.version || this.VERSION,\n+ service: 'WCS'\n+ }\n+ });\n+ this.writeNode(\"ows:Identifier\", options.identifier, node);\n+ this.writeNode(\"wcs:DomainSubset\", options.domainSubset, node);\n+ this.writeNode(\"wcs:Output\", options.output, node);\n+ return node;\n+ },\n+ \"DomainSubset\": function(domainSubset) {\n+ var node = this.createElementNSPlus(\"wcs:DomainSubset\", {});\n+ this.writeNode(\"ows:BoundingBox\", domainSubset.boundingBox, node);\n+ if (domainSubset.temporalSubset) {\n+ this.writeNode(\"wcs:TemporalSubset\", domainSubset.temporalSubset, node);\n+ }\n+ return node;\n+ },\n+ \"TemporalSubset\": function(temporalSubset) {\n+ var node = this.createElementNSPlus(\"wcs:TemporalSubset\", {});\n+ for (var i = 0, len = temporalSubset.timePeriods.length; i < len; ++i) {\n+ this.writeNode(\"wcs:TimePeriod\", temporalSubset.timePeriods[i], node);\n+ }\n+ return node;\n+ },\n+ \"TimePeriod\": function(timePeriod) {\n+ var node = this.createElementNSPlus(\"wcs:TimePeriod\", {});\n+ this.writeNode(\"wcs:BeginPosition\", timePeriod.begin, node);\n+ this.writeNode(\"wcs:EndPosition\", timePeriod.end, node);\n+ if (timePeriod.resolution) {\n+ this.writeNode(\"wcs:TimeResolution\", timePeriod.resolution, node);\n+ }\n+ return node;\n+ },\n+ \"BeginPosition\": function(begin) {\n+ var node = this.createElementNSPlus(\"wcs:BeginPosition\", {\n+ value: begin\n+ });\n+ return node;\n+ },\n+ \"EndPosition\": function(end) {\n+ var node = this.createElementNSPlus(\"wcs:EndPosition\", {\n+ value: end\n+ });\n+ return node;\n+ },\n+ \"TimeResolution\": function(resolution) {\n+ var node = this.createElementNSPlus(\"wcs:TimeResolution\", {\n+ value: resolution\n+ });\n+ return node;\n+ },\n+ \"Output\": function(output) {\n+ var node = this.createElementNSPlus(\"wcs:Output\", {\n+ attributes: {\n+ format: output.format,\n+ store: output.store\n+ }\n+ });\n+ if (output.gridCRS) {\n+ this.writeNode(\"wcs:GridCRS\", output.gridCRS, node);\n+ }\n+ return node;\n+ },\n+ \"GridCRS\": function(gridCRS) {\n+ var node = this.createElementNSPlus(\"wcs:GridCRS\", {});\n+ this.writeNode(\"wcs:GridBaseCRS\", gridCRS.baseCRS, node);\n+ if (gridCRS.type) {\n+ this.writeNode(\"wcs:GridType\", gridCRS.type, node);\n+ }\n+ if (gridCRS.origin) {\n+ this.writeNode(\"wcs:GridOrigin\", gridCRS.origin, node);\n+ }\n+ this.writeNode(\"wcs:GridOffsets\", gridCRS.offsets, node);\n+ if (gridCRS.CS) {\n+ this.writeNode(\"wcs:GridCS\", gridCRS.CS, node);\n+ }\n+ return node;\n+ },\n+ \"GridBaseCRS\": function(baseCRS) {\n+ return this.createElementNSPlus(\"wcs:GridBaseCRS\", {\n+ value: baseCRS\n+ });\n+ },\n+ \"GridOrigin\": function(origin) {\n+ return this.createElementNSPlus(\"wcs:GridOrigin\", {\n+ value: origin\n+ });\n+ },\n+ \"GridType\": function(type) {\n+ return this.createElementNSPlus(\"wcs:GridType\", {\n+ value: type\n+ });\n+ },\n+ \"GridOffsets\": function(offsets) {\n+ return this.createElementNSPlus(\"wcs:GridOffsets\", {\n+ value: offsets\n+ });\n+ },\n+ \"GridCS\": function(CS) {\n+ return this.createElementNSPlus(\"wcs:GridCS\", {\n+ value: CS\n+ });\n }\n-\n- args.x = x - lastX;\n- args.y = y - lastY;\n- lastX = x;\n- lastY = y;\n- callback(args.x, args.y, args.end);\n- };\n-\n- this.timerId = OpenLayers.Animation.start(\n- OpenLayers.Function.bind(timerCallback, this)\n- );\n+ },\n+ \"ows\": OpenLayers.Format.OWSCommon.v1_1_0.prototype.writers.ows\n },\n \n- CLASS_NAME: \"OpenLayers.Kinetic\"\n+ CLASS_NAME: \"OpenLayers.Format.WCSGetCoverage\"\n+\n });\n /* ======================================================================\n- OpenLayers/Layer.js\n+ OpenLayers/Format/WFST.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Map.js\n- * @requires OpenLayers/Projection.js\n+ * @requires OpenLayers/Format.js\n */\n \n /**\n- * Class: OpenLayers.Layer\n+ * Function: OpenLayers.Format.WFST\n+ * Used to create a versioned WFS protocol. Default version is 1.0.0.\n+ *\n+ * Returns:\n+ * {} A WFST format of the given version.\n */\n-OpenLayers.Layer = OpenLayers.Class({\n-\n- /**\n- * APIProperty: id\n- * {String}\n- */\n- id: null,\n+OpenLayers.Format.WFST = function(options) {\n+ options = OpenLayers.Util.applyDefaults(\n+ options, OpenLayers.Format.WFST.DEFAULTS\n+ );\n+ var cls = OpenLayers.Format.WFST[\"v\" + options.version.replace(/\\./g, \"_\")];\n+ if (!cls) {\n+ throw \"Unsupported WFST version: \" + options.version;\n+ }\n+ return new cls(options);\n+};\n \n- /** \n- * APIProperty: name\n- * {String}\n- */\n- name: null,\n+/**\n+ * Constant: OpenLayers.Format.WFST.DEFAULTS\n+ * {Object} Default properties for the WFST format.\n+ */\n+OpenLayers.Format.WFST.DEFAULTS = {\n+ \"version\": \"1.0.0\"\n+};\n+/* ======================================================================\n+ OpenLayers/Filter/Spatial.js\n+ ====================================================================== */\n \n- /** \n- * APIProperty: div\n- * {DOMElement}\n- */\n- div: null,\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- /**\n- * APIProperty: opacity\n- * {Float} The layer's opacity. Float number between 0.0 and 1.0. Default\n- * is 1.\n- */\n- opacity: 1,\n+/**\n+ * @requires OpenLayers/Filter.js\n+ */\n \n- /**\n- * APIProperty: alwaysInRange\n- * {Boolean} If a layer's display should not be scale-based, this should \n- * be set to true. This will cause the layer, as an overlay, to always \n- * be 'active', by always returning true from the calculateInRange() \n- * function. \n- * \n- * If not explicitly specified for a layer, its value will be \n- * determined on startup in initResolutions() based on whether or not \n- * any scale-specific properties have been set as options on the \n- * layer. If no scale-specific options have been set on the layer, we \n- * assume that it should always be in range.\n- * \n- * See #987 for more info.\n- */\n- alwaysInRange: null,\n+/**\n+ * Class: OpenLayers.Filter.Spatial\n+ * This class represents a spatial filter.\n+ * Currently implemented: BBOX, DWithin and Intersects\n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Filter.Spatial = OpenLayers.Class(OpenLayers.Filter, {\n \n /**\n- * Constant: RESOLUTION_PROPERTIES\n- * {Array} The properties that are used for calculating resolutions\n- * information.\n+ * APIProperty: type\n+ * {String} Type of spatial filter.\n+ *\n+ * The type should be one of:\n+ * - OpenLayers.Filter.Spatial.BBOX\n+ * - OpenLayers.Filter.Spatial.INTERSECTS\n+ * - OpenLayers.Filter.Spatial.DWITHIN\n+ * - OpenLayers.Filter.Spatial.WITHIN\n+ * - OpenLayers.Filter.Spatial.CONTAINS\n */\n- RESOLUTION_PROPERTIES: [\n- 'scales', 'resolutions',\n- 'maxScale', 'minScale',\n- 'maxResolution', 'minResolution',\n- 'numZoomLevels', 'maxZoomLevel'\n- ],\n+ type: null,\n \n /**\n- * APIProperty: events\n- * {}\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * layer.events.register(type, obj, listener);\n- * (end)\n- *\n- * Listeners will be called with a reference to an event object. The\n- * properties of this event depends on exactly what happened.\n- *\n- * All event objects have at least the following properties:\n- * object - {Object} A reference to layer.events.object.\n- * element - {DOMElement} A reference to layer.events.element.\n- *\n- * Supported map event types:\n- * loadstart - Triggered when layer loading starts. When using a Vector \n- * layer with a Fixed or BBOX strategy, the event object includes \n- * a *filter* property holding the OpenLayers.Filter used when \n- * calling read on the protocol.\n- * loadend - Triggered when layer loading ends. When using a Vector layer\n- * with a Fixed or BBOX strategy, the event object includes a \n- * *response* property holding an OpenLayers.Protocol.Response object.\n- * visibilitychanged - Triggered when the layer's visibility property is\n- * changed, e.g. by turning the layer on or off in the layer switcher.\n- * Note that the actual visibility of the layer can also change if it\n- * gets out of range (see ). If you also want to catch\n- * these cases, register for the map's 'changelayer' event instead.\n- * move - Triggered when layer moves (triggered with every mousemove\n- * during a drag).\n- * moveend - Triggered when layer is done moving, object passed as\n- * argument has a zoomChanged boolean property which tells that the\n- * zoom has changed.\n- * added - Triggered after the layer is added to a map. Listeners will\n- * receive an object with a *map* property referencing the map and a\n- * *layer* property referencing the layer.\n- * removed - Triggered after the layer is removed from the map. Listeners\n- * will receive an object with a *map* property referencing the map and\n- * a *layer* property referencing the layer.\n+ * APIProperty: property\n+ * {String} Name of the context property to compare.\n */\n- events: null,\n+ property: null,\n \n /**\n- * APIProperty: map\n- * {} This variable is set when the layer is added to \n- * the map, via the accessor function setMap().\n+ * APIProperty: value\n+ * { || } The bounds or geometry\n+ * to be used by the filter. Use bounds for BBOX filters and geometry\n+ * for INTERSECTS or DWITHIN filters.\n */\n- map: null,\n+ value: null,\n \n /**\n- * APIProperty: isBaseLayer\n- * {Boolean} Whether or not the layer is a base layer. This should be set \n- * individually by all subclasses. Default is false\n+ * APIProperty: distance\n+ * {Number} The distance to use in a DWithin spatial filter.\n */\n- isBaseLayer: false,\n+ distance: null,\n \n /**\n- * Property: alpha\n- * {Boolean} The layer's images have an alpha channel. Default is false.\n+ * APIProperty: distanceUnits\n+ * {String} The units to use for the distance, e.g. 'm'.\n */\n- alpha: false,\n+ distanceUnits: null,\n \n /** \n- * APIProperty: displayInLayerSwitcher\n- * {Boolean} Display the layer's name in the layer switcher. Default is\n- * true.\n+ * Constructor: OpenLayers.Filter.Spatial\n+ * Creates a spatial filter.\n+ *\n+ * Parameters:\n+ * options - {Object} An optional object with properties to set on the\n+ * filter.\n+ * \n+ * Returns:\n+ * {}\n */\n- displayInLayerSwitcher: true,\n \n /**\n- * APIProperty: visibility\n- * {Boolean} The layer should be displayed in the map. Default is true.\n+ * Method: evaluate\n+ * Evaluates this filter for a specific feature.\n+ * \n+ * Parameters:\n+ * feature - {} feature to apply the filter to.\n+ * \n+ * Returns:\n+ * {Boolean} The feature meets filter criteria.\n */\n- visibility: true,\n+ evaluate: function(feature) {\n+ var intersect = false;\n+ switch (this.type) {\n+ case OpenLayers.Filter.Spatial.BBOX:\n+ case OpenLayers.Filter.Spatial.INTERSECTS:\n+ if (feature.geometry) {\n+ var geom = this.value;\n+ if (this.value.CLASS_NAME == \"OpenLayers.Bounds\") {\n+ geom = this.value.toGeometry();\n+ }\n+ if (feature.geometry.intersects(geom)) {\n+ intersect = true;\n+ }\n+ }\n+ break;\n+ default:\n+ throw new Error('evaluate is not implemented for this filter type.');\n+ }\n+ return intersect;\n+ },\n \n /**\n- * APIProperty: attribution\n- * {String} Attribution string, displayed when an \n- * has been added to the map.\n+ * APIMethod: clone\n+ * Clones this filter.\n+ * \n+ * Returns:\n+ * {} Clone of this filter.\n */\n- attribution: null,\n+ clone: function() {\n+ var options = OpenLayers.Util.applyDefaults({\n+ value: this.value && this.value.clone && this.value.clone()\n+ }, this);\n+ return new OpenLayers.Filter.Spatial(options);\n+ },\n+ CLASS_NAME: \"OpenLayers.Filter.Spatial\"\n+});\n \n- /** \n- * Property: inRange\n- * {Boolean} The current map resolution is within the layer's min/max \n- * range. This is set in whenever the zoom \n- * changes.\n- */\n- inRange: false,\n+OpenLayers.Filter.Spatial.BBOX = \"BBOX\";\n+OpenLayers.Filter.Spatial.INTERSECTS = \"INTERSECTS\";\n+OpenLayers.Filter.Spatial.DWITHIN = \"DWITHIN\";\n+OpenLayers.Filter.Spatial.WITHIN = \"WITHIN\";\n+OpenLayers.Filter.Spatial.CONTAINS = \"CONTAINS\";\n+/* ======================================================================\n+ OpenLayers/Filter/FeatureId.js\n+ ====================================================================== */\n \n- /**\n- * Propery: imageSize\n- * {} For layers with a gutter, the image is larger than \n- * the tile by twice the gutter in each dimension.\n- */\n- imageSize: null,\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- // OPTIONS\n+\n+/**\n+ * @requires OpenLayers/Filter.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Filter.FeatureId\n+ * This class represents a ogc:FeatureId Filter, as being used for rule-based SLD\n+ * styling\n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Filter.FeatureId = OpenLayers.Class(OpenLayers.Filter, {\n \n /** \n- * Property: options\n- * {Object} An optional object whose properties will be set on the layer.\n- * Any of the layer properties can be set as a property of the options\n- * object and sent to the constructor when the layer is created.\n+ * APIProperty: fids\n+ * {Array(String)} Feature Ids to evaluate this rule against. \n+ * To be passed inside the params object.\n */\n- options: null,\n+ fids: null,\n \n- /**\n- * APIProperty: eventListeners\n- * {Object} If set as an option at construction, the eventListeners\n- * object will be registered with . Object\n- * structure must be a listeners object as shown in the example for\n- * the events.on method.\n+ /** \n+ * Property: type\n+ * {String} Type to identify this filter.\n */\n- eventListeners: null,\n+ type: \"FID\",\n \n- /**\n- * APIProperty: gutter\n- * {Integer} Determines the width (in pixels) of the gutter around image\n- * tiles to ignore. By setting this property to a non-zero value,\n- * images will be requested that are wider and taller than the tile\n- * size by a value of 2 x gutter. This allows artifacts of rendering\n- * at tile edges to be ignored. Set a gutter value that is equal to\n- * half the size of the widest symbol that needs to be displayed.\n- * Defaults to zero. Non-tiled layers always have zero gutter.\n+ /** \n+ * Constructor: OpenLayers.Filter.FeatureId\n+ * Creates an ogc:FeatureId rule.\n+ *\n+ * Parameters:\n+ * options - {Object} An optional object with properties to set on the\n+ * rule\n+ * \n+ * Returns:\n+ * {}\n */\n- gutter: 0,\n+ initialize: function(options) {\n+ this.fids = [];\n+ OpenLayers.Filter.prototype.initialize.apply(this, [options]);\n+ },\n \n /**\n- * APIProperty: projection\n- * {} or {} Specifies the projection of the layer.\n- * Can be set in the layer options. If not specified in the layer options,\n- * it is set to the default projection specified in the map,\n- * when the layer is added to the map.\n- * Projection along with default maxExtent and resolutions\n- * are set automatically with commercial baselayers in EPSG:3857,\n- * such as Google, Bing and OpenStreetMap, and do not need to be specified.\n- * Otherwise, if specifying projection, also set maxExtent,\n- * maxResolution or resolutions as appropriate.\n- * When using vector layers with strategies, layer projection should be set\n- * to the projection of the source data if that is different from the map default.\n+ * APIMethod: evaluate\n+ * evaluates this rule for a specific feature\n * \n- * Can be either a string or an object;\n- * if a string is passed, will be converted to an object when\n- * the layer is added to the map.\n+ * Parameters:\n+ * feature - {} feature to apply the rule to.\n+ * For vector features, the check is run against the fid,\n+ * for plain features against the id.\n * \n+ * Returns:\n+ * {Boolean} true if the rule applies, false if it does not\n */\n- projection: null,\n+ evaluate: function(feature) {\n+ for (var i = 0, len = this.fids.length; i < len; i++) {\n+ var fid = feature.fid || feature.id;\n+ if (fid == this.fids[i]) {\n+ return true;\n+ }\n+ }\n+ return false;\n+ },\n \n /**\n- * APIProperty: units\n- * {String} The layer map units. Defaults to null. Possible values\n- * are 'degrees' (or 'dd'), 'm', 'ft', 'km', 'mi', 'inches'.\n- * Normally taken from the projection.\n- * Only required if both map and layers do not define a projection,\n- * or if they define a projection which does not define units.\n+ * APIMethod: clone\n+ * Clones this filter.\n+ * \n+ * Returns:\n+ * {} Clone of this filter.\n */\n- units: null,\n+ clone: function() {\n+ var filter = new OpenLayers.Filter.FeatureId();\n+ OpenLayers.Util.extend(filter, this);\n+ filter.fids = this.fids.slice();\n+ return filter;\n+ },\n \n- /**\n- * APIProperty: scales\n- * {Array} An array of map scales in descending order. The values in the\n- * array correspond to the map scale denominator. Note that these\n- * values only make sense if the display (monitor) resolution of the\n- * client is correctly guessed by whomever is configuring the\n- * application. In addition, the units property must also be set.\n- * Use instead wherever possible.\n- */\n- scales: null,\n+ CLASS_NAME: \"OpenLayers.Filter.FeatureId\"\n+});\n+/* ======================================================================\n+ OpenLayers/Format/WFST/v1.js\n+ ====================================================================== */\n \n- /**\n- * APIProperty: resolutions\n- * {Array} A list of map resolutions (map units per pixel) in descending\n- * order. If this is not set in the layer constructor, it will be set\n- * based on other resolution related properties (maxExtent,\n- * maxResolution, maxScale, etc.).\n- */\n- resolutions: null,\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- /**\n- * APIProperty: maxExtent\n- * {|Array} If provided as an array, the array\n- * should consist of four values (left, bottom, right, top).\n- * The maximum extent for the layer. Defaults to null.\n- * \n- * The center of these bounds will not stray outside\n- * of the viewport extent during panning. In addition, if\n- * is set to false, data will not be\n- * requested that falls completely outside of these bounds.\n- */\n- maxExtent: null,\n+/**\n+ * @requires OpenLayers/Format/XML.js\n+ * @requires OpenLayers/Format/WFST.js\n+ * @requires OpenLayers/Filter/Spatial.js\n+ * @requires OpenLayers/Filter/FeatureId.js\n+ */\n \n- /**\n- * APIProperty: minExtent\n- * {|Array} If provided as an array, the array\n- * should consist of four values (left, bottom, right, top).\n- * The minimum extent for the layer. Defaults to null.\n- */\n- minExtent: null,\n+/**\n+ * Class: OpenLayers.Format.WFST.v1\n+ * Superclass for WFST parsers.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {\n \n /**\n- * APIProperty: maxResolution\n- * {Float} Default max is 360 deg / 256 px, which corresponds to\n- * zoom level 0 on gmaps. Specify a different value in the layer \n- * options if you are not using the default \n- * and displaying the whole world.\n+ * Property: namespaces\n+ * {Object} Mapping of namespace aliases to namespace URIs.\n */\n- maxResolution: null,\n+ namespaces: {\n+ xlink: \"http://www.w3.org/1999/xlink\",\n+ xsi: \"http://www.w3.org/2001/XMLSchema-instance\",\n+ wfs: \"http://www.opengis.net/wfs\",\n+ gml: \"http://www.opengis.net/gml\",\n+ ogc: \"http://www.opengis.net/ogc\",\n+ ows: \"http://www.opengis.net/ows\"\n+ },\n \n /**\n- * APIProperty: minResolution\n- * {Float}\n+ * Property: defaultPrefix\n */\n- minResolution: null,\n+ defaultPrefix: \"wfs\",\n \n /**\n- * APIProperty: numZoomLevels\n- * {Integer}\n+ * Property: version\n+ * {String} WFS version number.\n */\n- numZoomLevels: null,\n+ version: null,\n \n /**\n- * APIProperty: minScale\n- * {Float}\n+ * Property: schemaLocation\n+ * {String} Schema location for a particular minor version.\n */\n- minScale: null,\n+ schemaLocations: null,\n \n /**\n- * APIProperty: maxScale\n- * {Float}\n+ * APIProperty: srsName\n+ * {String} URI for spatial reference system.\n */\n- maxScale: null,\n+ srsName: null,\n \n /**\n- * APIProperty: displayOutsideMaxExtent\n- * {Boolean} Request map tiles that are completely outside of the max \n- * extent for this layer. Defaults to false.\n+ * APIProperty: extractAttributes\n+ * {Boolean} Extract attributes from GML. Default is true.\n */\n- displayOutsideMaxExtent: false,\n+ extractAttributes: true,\n \n /**\n- * APIProperty: wrapDateLine\n- * {Boolean} Wraps the world at the international dateline, so the map can\n- * be panned infinitely in longitudinal direction. Only use this on the\n- * base layer, and only if the layer's maxExtent equals the world bounds.\n- * #487 for more info. \n+ * APIProperty: xy\n+ * {Boolean} Order of the GML coordinate true:(x,y) or false:(y,x)\n+ * Changing is not recommended, a new Format should be instantiated.\n */\n- wrapDateLine: false,\n+ xy: true,\n \n /**\n- * Property: metadata\n- * {Object} This object can be used to store additional information on a\n- * layer object.\n+ * Property: stateName\n+ * {Object} Maps feature states to node names.\n */\n- metadata: null,\n+ stateName: null,\n \n /**\n- * Constructor: OpenLayers.Layer\n+ * Constructor: OpenLayers.Format.WFST.v1\n+ * Instances of this class are not created directly. Use the\n+ * or \n+ * constructor instead.\n *\n * Parameters:\n- * name - {String} The layer name\n- * options - {Object} Hashtable of extra options to tag onto the layer\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n */\n- initialize: function(name, options) {\n-\n- this.metadata = {};\n-\n- options = OpenLayers.Util.extend({}, options);\n- // make sure we respect alwaysInRange if set on the prototype\n- if (this.alwaysInRange != null) {\n- options.alwaysInRange = this.alwaysInRange;\n- }\n- this.addOptions(options);\n-\n- this.name = name;\n-\n- if (this.id == null) {\n-\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n-\n- this.div = OpenLayers.Util.createDiv(this.id);\n- this.div.style.width = \"100%\";\n- this.div.style.height = \"100%\";\n- this.div.dir = \"ltr\";\n-\n- this.events = new OpenLayers.Events(this, this.div);\n- if (this.eventListeners instanceof Object) {\n- this.events.on(this.eventListeners);\n- }\n-\n- }\n+ initialize: function(options) {\n+ // set state name mapping\n+ this.stateName = {};\n+ this.stateName[OpenLayers.State.INSERT] = \"wfs:Insert\";\n+ this.stateName[OpenLayers.State.UPDATE] = \"wfs:Update\";\n+ this.stateName[OpenLayers.State.DELETE] = \"wfs:Delete\";\n+ OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);\n },\n \n /**\n- * Method: destroy\n- * Destroy is a destructor: this is to alleviate cyclic references which\n- * the Javascript garbage cleaner can not take care of on its own.\n- *\n- * Parameters:\n- * setNewBaseLayer - {Boolean} Set a new base layer when this layer has\n- * been destroyed. Default is true.\n+ * Method: getSrsName\n */\n- destroy: function(setNewBaseLayer) {\n- if (setNewBaseLayer == null) {\n- setNewBaseLayer = true;\n- }\n- if (this.map != null) {\n- this.map.removeLayer(this, setNewBaseLayer);\n- }\n- this.projection = null;\n- this.map = null;\n- this.name = null;\n- this.div = null;\n- this.options = null;\n-\n- if (this.events) {\n- if (this.eventListeners) {\n- this.events.un(this.eventListeners);\n+ getSrsName: function(feature, options) {\n+ var srsName = options && options.srsName;\n+ if (!srsName) {\n+ if (feature && feature.layer) {\n+ srsName = feature.layer.projection.getCode();\n+ } else {\n+ srsName = this.srsName;\n }\n- this.events.destroy();\n }\n- this.eventListeners = null;\n- this.events = null;\n+ return srsName;\n },\n \n /**\n- * Method: clone\n+ * APIMethod: read\n+ * Parse the response from a transaction. Because WFS is split into\n+ * Transaction requests (create, update, and delete) and GetFeature\n+ * requests (read), this method handles parsing of both types of\n+ * responses.\n *\n * Parameters:\n- * obj - {} The layer to be cloned\n+ * data - {String | Document} The WFST document to read\n+ * options - {Object} Options for the reader\n+ *\n+ * Valid options properties:\n+ * output - {String} either \"features\" or \"object\". The default is\n+ * \"features\", which means that the method will return an array of\n+ * features. If set to \"object\", an object with a \"features\" property\n+ * and other properties read by the parser will be returned.\n *\n * Returns:\n- * {} An exact clone of this \n+ * {Array | Object} Output depending on the output option.\n */\n- clone: function(obj) {\n+ read: function(data, options) {\n+ options = options || {};\n+ OpenLayers.Util.applyDefaults(options, {\n+ output: \"features\"\n+ });\n \n- if (obj == null) {\n- obj = new OpenLayers.Layer(this.name, this.getOptions());\n+ if (typeof data == \"string\") {\n+ data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n+ }\n+ if (data && data.nodeType == 9) {\n+ data = data.documentElement;\n+ }\n+ var obj = {};\n+ if (data) {\n+ this.readNode(data, obj, true);\n+ }\n+ if (obj.features && options.output === \"features\") {\n+ obj = obj.features;\n }\n-\n- // catch any randomly tagged-on properties\n- OpenLayers.Util.applyDefaults(obj, this);\n-\n- // a cloned layer should never have its map property set\n- // because it has not been added to a map yet. \n- obj.map = null;\n-\n return obj;\n },\n \n /**\n- * Method: getOptions\n- * Extracts an object from the layer with the properties that were set as\n- * options, but updates them with the values currently set on the\n- * instance.\n- * \n- * Returns:\n- * {Object} the of the layer, representing the current state.\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n */\n- getOptions: function() {\n- var options = {};\n- for (var o in this.options) {\n- options[o] = this[o];\n+ readers: {\n+ \"wfs\": {\n+ \"FeatureCollection\": function(node, obj) {\n+ obj.features = [];\n+ this.readChildNodes(node, obj);\n+ }\n }\n- return options;\n },\n \n- /** \n- * APIMethod: setName\n- * Sets the new layer name for this layer. Can trigger a changelayer event\n- * on the map.\n+ /**\n+ * Method: write\n+ * Given an array of features, write a WFS transaction. This assumes\n+ * the features have a state property that determines the operation\n+ * type - insert, update, or delete.\n *\n * Parameters:\n- * newName - {String} The new name.\n+ * features - {Array()} A list of features. See\n+ * below for a more detailed description of the influence of the\n+ * feature's *modified* property.\n+ * options - {Object}\n+ *\n+ * feature.modified rules:\n+ * If a feature has a modified property set, the following checks will be\n+ * made before a feature's geometry or attribute is included in an Update\n+ * transaction:\n+ * - *modified* is not set at all: The geometry and all attributes will be\n+ * included.\n+ * - *modified.geometry* is set (null or a geometry): The geometry will be\n+ * included. If *modified.attributes* is not set, all attributes will\n+ * be included.\n+ * - *modified.attributes* is set: Only the attributes set (i.e. to null or\n+ * a value) in *modified.attributes* will be included. \n+ * If *modified.geometry* is not set, the geometry will not be included.\n+ *\n+ * Valid options include:\n+ * - *multi* {Boolean} If set to true, geometries will be casted to\n+ * Multi geometries before writing.\n+ *\n+ * Returns:\n+ * {String} A serialized WFS transaction.\n */\n- setName: function(newName) {\n- if (newName != this.name) {\n- this.name = newName;\n- if (this.map != null) {\n- this.map.events.triggerEvent(\"changelayer\", {\n- layer: this,\n- property: \"name\"\n- });\n- }\n+ write: function(features, options) {\n+ var node = this.writeNode(\"wfs:Transaction\", {\n+ features: features,\n+ options: options\n+ });\n+ var value = this.schemaLocationAttr();\n+ if (value) {\n+ this.setAttributeNS(\n+ node, this.namespaces[\"xsi\"], \"xsi:schemaLocation\", value\n+ );\n }\n+ return OpenLayers.Format.XML.prototype.write.apply(this, [node]);\n },\n \n /**\n- * APIMethod: addOptions\n- * \n- * Parameters:\n- * newOptions - {Object}\n- * reinitialize - {Boolean} If set to true, and if resolution options of the\n- * current baseLayer were changed, the map will be recentered to make\n- * sure that it is displayed with a valid resolution, and a\n- * changebaselayer event will be triggered.\n+ * Property: writers\n+ * As a compliment to the readers property, this structure contains public\n+ * writing functions grouped by namespace alias and named like the\n+ * node names they produce.\n */\n- addOptions: function(newOptions, reinitialize) {\n-\n- if (this.options == null) {\n- this.options = {};\n- }\n-\n- if (newOptions) {\n- // make sure this.projection references a projection object\n- if (typeof newOptions.projection == \"string\") {\n- newOptions.projection = new OpenLayers.Projection(newOptions.projection);\n- }\n- if (newOptions.projection) {\n- // get maxResolution, units and maxExtent from projection defaults if\n- // they are not defined already\n- OpenLayers.Util.applyDefaults(newOptions,\n- OpenLayers.Projection.defaults[newOptions.projection.getCode()]);\n- }\n- // allow array for extents\n- if (newOptions.maxExtent && !(newOptions.maxExtent instanceof OpenLayers.Bounds)) {\n- newOptions.maxExtent = new OpenLayers.Bounds(newOptions.maxExtent);\n- }\n- if (newOptions.minExtent && !(newOptions.minExtent instanceof OpenLayers.Bounds)) {\n- newOptions.minExtent = new OpenLayers.Bounds(newOptions.minExtent);\n- }\n- }\n-\n- // update our copy for clone\n- OpenLayers.Util.extend(this.options, newOptions);\n+ writers: {\n+ \"wfs\": {\n+ \"GetFeature\": function(options) {\n+ var node = this.createElementNSPlus(\"wfs:GetFeature\", {\n+ attributes: {\n+ service: \"WFS\",\n+ version: this.version,\n+ handle: options && options.handle,\n+ outputFormat: options && options.outputFormat,\n+ maxFeatures: options && options.maxFeatures,\n+ \"xsi:schemaLocation\": this.schemaLocationAttr(options)\n+ }\n+ });\n+ if (typeof this.featureType == \"string\") {\n+ this.writeNode(\"Query\", options, node);\n+ } else {\n+ for (var i = 0, len = this.featureType.length; i < len; i++) {\n+ options.featureType = this.featureType[i];\n+ this.writeNode(\"Query\", options, node);\n+ }\n+ }\n+ return node;\n+ },\n+ \"Transaction\": function(obj) {\n+ obj = obj || {};\n+ var options = obj.options || {};\n+ var node = this.createElementNSPlus(\"wfs:Transaction\", {\n+ attributes: {\n+ service: \"WFS\",\n+ version: this.version,\n+ handle: options.handle\n+ }\n+ });\n+ var i, len;\n+ var features = obj.features;\n+ if (features) {\n+ // temporarily re-assigning geometry types\n+ if (options.multi === true) {\n+ OpenLayers.Util.extend(this.geometryTypes, {\n+ \"OpenLayers.Geometry.Point\": \"MultiPoint\",\n+ \"OpenLayers.Geometry.LineString\": (this.multiCurve === true) ? \"MultiCurve\" : \"MultiLineString\",\n+ \"OpenLayers.Geometry.Polygon\": (this.multiSurface === true) ? \"MultiSurface\" : \"MultiPolygon\"\n+ });\n+ }\n+ var name, feature;\n+ for (i = 0, len = features.length; i < len; ++i) {\n+ feature = features[i];\n+ name = this.stateName[feature.state];\n+ if (name) {\n+ this.writeNode(name, {\n+ feature: feature,\n+ options: options\n+ }, node);\n+ }\n+ }\n+ // switch back to original geometry types assignment\n+ if (options.multi === true) {\n+ this.setGeometryTypes();\n+ }\n+ }\n+ if (options.nativeElements) {\n+ for (i = 0, len = options.nativeElements.length; i < len; ++i) {\n+ this.writeNode(\"wfs:Native\",\n+ options.nativeElements[i], node);\n+ }\n+ }\n+ return node;\n+ },\n+ \"Native\": function(nativeElement) {\n+ var node = this.createElementNSPlus(\"wfs:Native\", {\n+ attributes: {\n+ vendorId: nativeElement.vendorId,\n+ safeToIgnore: nativeElement.safeToIgnore\n+ },\n+ value: nativeElement.value\n+ });\n+ return node;\n+ },\n+ \"Insert\": function(obj) {\n+ var feature = obj.feature;\n+ var options = obj.options;\n+ var node = this.createElementNSPlus(\"wfs:Insert\", {\n+ attributes: {\n+ handle: options && options.handle\n+ }\n+ });\n+ this.srsName = this.getSrsName(feature);\n+ this.writeNode(\"feature:_typeName\", feature, node);\n+ return node;\n+ },\n+ \"Update\": function(obj) {\n+ var feature = obj.feature;\n+ var options = obj.options;\n+ var node = this.createElementNSPlus(\"wfs:Update\", {\n+ attributes: {\n+ handle: options && options.handle,\n+ typeName: (this.featureNS ? this.featurePrefix + \":\" : \"\") +\n+ this.featureType\n+ }\n+ });\n+ if (this.featureNS) {\n+ node.setAttribute(\"xmlns:\" + this.featurePrefix, this.featureNS);\n+ }\n \n- // add new options to this\n- OpenLayers.Util.extend(this, newOptions);\n+ // add in geometry\n+ var modified = feature.modified;\n+ if (this.geometryName !== null && (!modified || modified.geometry !== undefined)) {\n+ this.srsName = this.getSrsName(feature);\n+ this.writeNode(\n+ \"Property\", {\n+ name: this.geometryName,\n+ value: feature.geometry\n+ }, node\n+ );\n+ }\n \n- // get the units from the projection, if we have a projection\n- // and it it has units\n- if (this.projection && this.projection.getUnits()) {\n- this.units = this.projection.getUnits();\n- }\n+ // add in attributes\n+ for (var key in feature.attributes) {\n+ if (feature.attributes[key] !== undefined &&\n+ (!modified || !modified.attributes ||\n+ (modified.attributes && modified.attributes[key] !== undefined))) {\n+ this.writeNode(\n+ \"Property\", {\n+ name: key,\n+ value: feature.attributes[key]\n+ }, node\n+ );\n+ }\n+ }\n \n- // re-initialize resolutions if necessary, i.e. if any of the\n- // properties of the \"properties\" array defined below is set\n- // in the new options\n- if (this.map) {\n- // store current resolution so we can try to restore it later\n- var resolution = this.map.getResolution();\n- var properties = this.RESOLUTION_PROPERTIES.concat(\n- [\"projection\", \"units\", \"minExtent\", \"maxExtent\"]\n- );\n- for (var o in newOptions) {\n- if (newOptions.hasOwnProperty(o) &&\n- OpenLayers.Util.indexOf(properties, o) >= 0) {\n+ // add feature id filter\n+ this.writeNode(\"ogc:Filter\", new OpenLayers.Filter.FeatureId({\n+ fids: [feature.fid]\n+ }), node);\n \n- this.initResolutions();\n- if (reinitialize && this.map.baseLayer === this) {\n- // update map position, and restore previous resolution\n- this.map.setCenter(this.map.getCenter(),\n- this.map.getZoomForResolution(resolution),\n- false, true\n- );\n- // trigger a changebaselayer event to make sure that\n- // all controls (especially\n- // OpenLayers.Control.PanZoomBar) get notified of the\n- // new options\n- this.map.events.triggerEvent(\"changebaselayer\", {\n- layer: this\n- });\n+ return node;\n+ },\n+ \"Property\": function(obj) {\n+ var node = this.createElementNSPlus(\"wfs:Property\");\n+ this.writeNode(\"Name\", obj.name, node);\n+ if (obj.value !== null) {\n+ this.writeNode(\"Value\", obj.value, node);\n+ }\n+ return node;\n+ },\n+ \"Name\": function(name) {\n+ return this.createElementNSPlus(\"wfs:Name\", {\n+ value: name\n+ });\n+ },\n+ \"Value\": function(obj) {\n+ var node;\n+ if (obj instanceof OpenLayers.Geometry) {\n+ node = this.createElementNSPlus(\"wfs:Value\");\n+ var geom = this.writeNode(\"feature:_geometry\", obj).firstChild;\n+ node.appendChild(geom);\n+ } else {\n+ node = this.createElementNSPlus(\"wfs:Value\", {\n+ value: obj\n+ });\n+ }\n+ return node;\n+ },\n+ \"Delete\": function(obj) {\n+ var feature = obj.feature;\n+ var options = obj.options;\n+ var node = this.createElementNSPlus(\"wfs:Delete\", {\n+ attributes: {\n+ handle: options && options.handle,\n+ typeName: (this.featureNS ? this.featurePrefix + \":\" : \"\") +\n+ this.featureType\n }\n- break;\n+ });\n+ if (this.featureNS) {\n+ node.setAttribute(\"xmlns:\" + this.featurePrefix, this.featureNS);\n }\n+ this.writeNode(\"ogc:Filter\", new OpenLayers.Filter.FeatureId({\n+ fids: [feature.fid]\n+ }), node);\n+ return node;\n }\n }\n },\n \n /**\n- * APIMethod: onMapResize\n- * This function can be implemented by subclasses\n- */\n- onMapResize: function() {\n- //this function can be implemented by subclasses \n- },\n-\n- /**\n- * APIMethod: redraw\n- * Redraws the layer. Returns true if the layer was redrawn, false if not.\n+ * Method: schemaLocationAttr\n+ * Generate the xsi:schemaLocation attribute value.\n *\n * Returns:\n- * {Boolean} The layer was redrawn.\n+ * {String} The xsi:schemaLocation attribute or undefined if none.\n */\n- redraw: function() {\n- var redrawn = false;\n- if (this.map) {\n-\n- // min/max Range may have changed\n- this.inRange = this.calculateInRange();\n-\n- // map's center might not yet be set\n- var extent = this.getExtent();\n-\n- if (extent && this.inRange && this.visibility) {\n- var zoomChanged = true;\n- this.moveTo(extent, zoomChanged, false);\n- this.events.triggerEvent(\"moveend\", {\n- \"zoomChanged\": zoomChanged\n- });\n- redrawn = true;\n+ schemaLocationAttr: function(options) {\n+ options = OpenLayers.Util.extend({\n+ featurePrefix: this.featurePrefix,\n+ schema: this.schema\n+ }, options);\n+ var schemaLocations = OpenLayers.Util.extend({}, this.schemaLocations);\n+ if (options.schema) {\n+ schemaLocations[options.featurePrefix] = options.schema;\n+ }\n+ var parts = [];\n+ var uri;\n+ for (var key in schemaLocations) {\n+ uri = this.namespaces[key];\n+ if (uri) {\n+ parts.push(uri + \" \" + schemaLocations[key]);\n }\n }\n- return redrawn;\n+ var value = parts.join(\" \") || undefined;\n+ return value;\n },\n \n /**\n- * Method: moveTo\n- * \n+ * Method: setFilterProperty\n+ * Set the property of each spatial filter.\n+ *\n * Parameters:\n- * bounds - {}\n- * zoomChanged - {Boolean} Tells when zoom has changed, as layers have to\n- * do some init work in that case.\n- * dragging - {Boolean}\n+ * filter - {}\n */\n- moveTo: function(bounds, zoomChanged, dragging) {\n- var display = this.visibility;\n- if (!this.isBaseLayer) {\n- display = display && this.inRange;\n+ setFilterProperty: function(filter) {\n+ if (filter.filters) {\n+ for (var i = 0, len = filter.filters.length; i < len; ++i) {\n+ OpenLayers.Format.WFST.v1.prototype.setFilterProperty.call(this, filter.filters[i]);\n+ }\n+ } else {\n+ if (filter instanceof OpenLayers.Filter.Spatial && !filter.property) {\n+ // got a spatial filter without property, so set it\n+ filter.property = this.geometryName;\n+ }\n }\n- this.display(display);\n },\n \n- /**\n- * Method: moveByPx\n- * Move the layer based on pixel vector. To be implemented by subclasses.\n- *\n- * Parameters:\n- * dx - {Number} The x coord of the displacement vector.\n- * dy - {Number} The y coord of the displacement vector.\n- */\n- moveByPx: function(dx, dy) {},\n-\n- /**\n- * Method: setMap\n- * Set the map property for the layer. This is done through an accessor\n- * so that subclasses can override this and take special action once \n- * they have their map variable set. \n- * \n- * Here we take care to bring over any of the necessary default \n- * properties from the map. \n- * \n- * Parameters:\n- * map - {}\n- */\n- setMap: function(map) {\n- if (this.map == null) {\n-\n- this.map = map;\n-\n- // grab some essential layer data from the map if it hasn't already\n- // been set\n- this.maxExtent = this.maxExtent || this.map.maxExtent;\n- this.minExtent = this.minExtent || this.map.minExtent;\n+ CLASS_NAME: \"OpenLayers.Format.WFST.v1\"\n \n- this.projection = this.projection || this.map.projection;\n- if (typeof this.projection == \"string\") {\n- this.projection = new OpenLayers.Projection(this.projection);\n- }\n+});\n+/* ======================================================================\n+ OpenLayers/Filter/Logical.js\n+ ====================================================================== */\n \n- // Check the projection to see if we can get units -- if not, refer\n- // to properties.\n- this.units = this.projection.getUnits() ||\n- this.units || this.map.units;\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- this.initResolutions();\n \n- if (!this.isBaseLayer) {\n- this.inRange = this.calculateInRange();\n- var show = ((this.visibility) && (this.inRange));\n- this.div.style.display = show ? \"\" : \"none\";\n- }\n+/**\n+ * @requires OpenLayers/Filter.js\n+ */\n \n- // deal with gutters\n- this.setTileSize();\n- }\n- },\n+/**\n+ * Class: OpenLayers.Filter.Logical\n+ * This class represents ogc:And, ogc:Or and ogc:Not rules.\n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Filter.Logical = OpenLayers.Class(OpenLayers.Filter, {\n \n /**\n- * Method: afterAdd\n- * Called at the end of the map.addLayer sequence. At this point, the map\n- * will have a base layer. To be overridden by subclasses.\n+ * APIProperty: filters\n+ * {Array()} Child filters for this filter.\n */\n- afterAdd: function() {},\n+ filters: null,\n \n /**\n- * APIMethod: removeMap\n- * Just as setMap() allows each layer the possibility to take a \n- * personalized action on being added to the map, removeMap() allows\n- * each layer to take a personalized action on being removed from it. \n- * For now, this will be mostly unused, except for the EventPane layer,\n- * which needs this hook so that it can remove the special invisible\n- * pane. \n- * \n- * Parameters:\n- * map - {}\n+ * APIProperty: type\n+ * {String} type of logical operator. Available types are:\n+ * - OpenLayers.Filter.Logical.AND = \"&&\";\n+ * - OpenLayers.Filter.Logical.OR = \"||\";\n+ * - OpenLayers.Filter.Logical.NOT = \"!\";\n */\n- removeMap: function(map) {\n- //to be overridden by subclasses\n- },\n+ type: null,\n \n- /**\n- * APIMethod: getImageSize\n+ /** \n+ * Constructor: OpenLayers.Filter.Logical\n+ * Creates a logical filter (And, Or, Not).\n *\n * Parameters:\n- * bounds - {} optional tile bounds, can be used\n- * by subclasses that have to deal with different tile sizes at the\n- * layer extent edges (e.g. Zoomify)\n+ * options - {Object} An optional object with properties to set on the\n+ * filter.\n * \n * Returns:\n- * {} The size that the image should be, taking into \n- * account gutters.\n+ * {}\n */\n- getImageSize: function(bounds) {\n- return (this.imageSize || this.tileSize);\n+ initialize: function(options) {\n+ this.filters = [];\n+ OpenLayers.Filter.prototype.initialize.apply(this, [options]);\n },\n \n- /**\n- * APIMethod: setTileSize\n- * Set the tile size based on the map size. This also sets layer.imageSize\n- * or use by Tile.Image.\n- * \n- * Parameters:\n- * size - {}\n+ /** \n+ * APIMethod: destroy\n+ * Remove reference to child filters.\n */\n- setTileSize: function(size) {\n- var tileSize = (size) ? size :\n- ((this.tileSize) ? this.tileSize :\n- this.map.getTileSize());\n- this.tileSize = tileSize;\n- if (this.gutter) {\n- // layers with gutters need non-null tile sizes\n- //if(tileSize == null) {\n- // OpenLayers.console.error(\"Error in layer.setMap() for \" +\n- // this.name + \": layers with \" +\n- // \"gutters need non-null tile sizes\");\n- //}\n- this.imageSize = new OpenLayers.Size(tileSize.w + (2 * this.gutter),\n- tileSize.h + (2 * this.gutter));\n- }\n+ destroy: function() {\n+ this.filters = null;\n+ OpenLayers.Filter.prototype.destroy.apply(this);\n },\n \n /**\n- * APIMethod: getVisibility\n+ * APIMethod: evaluate\n+ * Evaluates this filter in a specific context.\n+ * \n+ * Parameters:\n+ * context - {Object} Context to use in evaluating the filter. A vector\n+ * feature may also be provided to evaluate feature attributes in \n+ * comparison filters or geometries in spatial filters.\n * \n * Returns:\n- * {Boolean} The layer should be displayed (if in range).\n+ * {Boolean} The filter applies.\n */\n- getVisibility: function() {\n- return this.visibility;\n- },\n+ evaluate: function(context) {\n+ var i, len;\n+ switch (this.type) {\n+ case OpenLayers.Filter.Logical.AND:\n+ for (i = 0, len = this.filters.length; i < len; i++) {\n+ if (this.filters[i].evaluate(context) == false) {\n+ return false;\n+ }\n+ }\n+ return true;\n \n- /** \n- * APIMethod: setVisibility\n- * Set the visibility flag for the layer and hide/show & redraw \n- * accordingly. Fire event unless otherwise specified\n- * \n- * Note that visibility is no longer simply whether or not the layer's\n- * style.display is set to \"block\". Now we store a 'visibility' state \n- * property on the layer class, this allows us to remember whether or \n- * not we *desire* for a layer to be visible. In the case where the \n- * map's resolution is out of the layer's range, this desire may be \n- * subverted.\n- * \n- * Parameters:\n- * visibility - {Boolean} Whether or not to display the layer (if in range)\n- */\n- setVisibility: function(visibility) {\n- if (visibility != this.visibility) {\n- this.visibility = visibility;\n- this.display(visibility);\n- this.redraw();\n- if (this.map != null) {\n- this.map.events.triggerEvent(\"changelayer\", {\n- layer: this,\n- property: \"visibility\"\n- });\n- }\n- this.events.triggerEvent(\"visibilitychanged\");\n- }\n- },\n+ case OpenLayers.Filter.Logical.OR:\n+ for (i = 0, len = this.filters.length; i < len; i++) {\n+ if (this.filters[i].evaluate(context) == true) {\n+ return true;\n+ }\n+ }\n+ return false;\n \n- /** \n- * APIMethod: display\n- * Hide or show the Layer. This is designed to be used internally, and \n- * is not generally the way to enable or disable the layer. For that,\n- * use the setVisibility function instead..\n- * \n- * Parameters:\n- * display - {Boolean}\n- */\n- display: function(display) {\n- if (display != (this.div.style.display != \"none\")) {\n- this.div.style.display = (display && this.calculateInRange()) ? \"block\" : \"none\";\n+ case OpenLayers.Filter.Logical.NOT:\n+ return (!this.filters[0].evaluate(context));\n }\n+ return undefined;\n },\n \n /**\n- * APIMethod: calculateInRange\n+ * APIMethod: clone\n+ * Clones this filter.\n * \n * Returns:\n- * {Boolean} The layer is displayable at the current map's current\n- * resolution. Note that if 'alwaysInRange' is true for the layer, \n- * this function will always return true.\n- */\n- calculateInRange: function() {\n- var inRange = false;\n-\n- if (this.alwaysInRange) {\n- inRange = true;\n- } else {\n- if (this.map) {\n- var resolution = this.map.getResolution();\n- inRange = ((resolution >= this.minResolution) &&\n- (resolution <= this.maxResolution));\n- }\n- }\n- return inRange;\n- },\n-\n- /** \n- * APIMethod: setIsBaseLayer\n- * \n- * Parameters:\n- * isBaseLayer - {Boolean}\n+ * {} Clone of this filter.\n */\n- setIsBaseLayer: function(isBaseLayer) {\n- if (isBaseLayer != this.isBaseLayer) {\n- this.isBaseLayer = isBaseLayer;\n- if (this.map != null) {\n- this.map.events.triggerEvent(\"changebaselayer\", {\n- layer: this\n- });\n- }\n+ clone: function() {\n+ var filters = [];\n+ for (var i = 0, len = this.filters.length; i < len; ++i) {\n+ filters.push(this.filters[i].clone());\n }\n+ return new OpenLayers.Filter.Logical({\n+ type: this.type,\n+ filters: filters\n+ });\n },\n \n- /********************************************************/\n- /* */\n- /* Baselayer Functions */\n- /* */\n- /********************************************************/\n-\n- /** \n- * Method: initResolutions\n- * This method's responsibility is to set up the 'resolutions' array \n- * for the layer -- this array is what the layer will use to interface\n- * between the zoom levels of the map and the resolution display \n- * of the layer.\n- * \n- * The user has several options that determine how the array is set up.\n- * \n- * For a detailed explanation, see the following wiki from the \n- * openlayers.org homepage:\n- * http://trac.openlayers.org/wiki/SettingZoomLevels\n- */\n- initResolutions: function() {\n-\n- // ok we want resolutions, here's our strategy:\n- //\n- // 1. if resolutions are defined in the layer config, use them\n- // 2. else, if scales are defined in the layer config then derive\n- // resolutions from these scales\n- // 3. else, attempt to calculate resolutions from maxResolution,\n- // minResolution, numZoomLevels, maxZoomLevel set in the\n- // layer config\n- // 4. if we still don't have resolutions, and if resolutions\n- // are defined in the same, use them\n- // 5. else, if scales are defined in the map then derive\n- // resolutions from these scales\n- // 6. else, attempt to calculate resolutions from maxResolution,\n- // minResolution, numZoomLevels, maxZoomLevel set in the\n- // map\n- // 7. hope for the best!\n-\n- var i, len, p;\n- var props = {},\n- alwaysInRange = true;\n-\n- // get resolution data from layer config\n- // (we also set alwaysInRange in the layer as appropriate)\n- for (i = 0, len = this.RESOLUTION_PROPERTIES.length; i < len; i++) {\n- p = this.RESOLUTION_PROPERTIES[i];\n- props[p] = this.options[p];\n- if (alwaysInRange && this.options[p]) {\n- alwaysInRange = false;\n- }\n- }\n- if (this.options.alwaysInRange == null) {\n- this.alwaysInRange = alwaysInRange;\n- }\n-\n- // if we don't have resolutions then attempt to derive them from scales\n- if (props.resolutions == null) {\n- props.resolutions = this.resolutionsFromScales(props.scales);\n- }\n-\n- // if we still don't have resolutions then attempt to calculate them\n- if (props.resolutions == null) {\n- props.resolutions = this.calculateResolutions(props);\n- }\n-\n- // if we couldn't calculate resolutions then we look at we have\n- // in the map\n- if (props.resolutions == null) {\n- for (i = 0, len = this.RESOLUTION_PROPERTIES.length; i < len; i++) {\n- p = this.RESOLUTION_PROPERTIES[i];\n- props[p] = this.options[p] != null ?\n- this.options[p] : this.map[p];\n- }\n- if (props.resolutions == null) {\n- props.resolutions = this.resolutionsFromScales(props.scales);\n- }\n- if (props.resolutions == null) {\n- props.resolutions = this.calculateResolutions(props);\n- }\n- }\n-\n- // ok, we new need to set properties in the instance\n-\n- // get maxResolution from the config if it's defined there\n- var maxResolution;\n- if (this.options.maxResolution &&\n- this.options.maxResolution !== \"auto\") {\n- maxResolution = this.options.maxResolution;\n- }\n- if (this.options.minScale) {\n- maxResolution = OpenLayers.Util.getResolutionFromScale(\n- this.options.minScale, this.units);\n- }\n-\n- // get minResolution from the config if it's defined there\n- var minResolution;\n- if (this.options.minResolution &&\n- this.options.minResolution !== \"auto\") {\n- minResolution = this.options.minResolution;\n- }\n- if (this.options.maxScale) {\n- minResolution = OpenLayers.Util.getResolutionFromScale(\n- this.options.maxScale, this.units);\n- }\n+ CLASS_NAME: \"OpenLayers.Filter.Logical\"\n+});\n \n- if (props.resolutions) {\n \n- //sort resolutions array descendingly\n- props.resolutions.sort(function(a, b) {\n- return (b - a);\n- });\n+OpenLayers.Filter.Logical.AND = \"&&\";\n+OpenLayers.Filter.Logical.OR = \"||\";\n+OpenLayers.Filter.Logical.NOT = \"!\";\n+/* ======================================================================\n+ OpenLayers/Filter/Comparison.js\n+ ====================================================================== */\n \n- // if we still don't have a maxResolution get it from the\n- // resolutions array\n- if (!maxResolution) {\n- maxResolution = props.resolutions[0];\n- }\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- // if we still don't have a minResolution get it from the\n- // resolutions array\n- if (!minResolution) {\n- var lastIdx = props.resolutions.length - 1;\n- minResolution = props.resolutions[lastIdx];\n- }\n- }\n+/**\n+ * @requires OpenLayers/Filter.js\n+ */\n \n- this.resolutions = props.resolutions;\n- if (this.resolutions) {\n- len = this.resolutions.length;\n- this.scales = new Array(len);\n- for (i = 0; i < len; i++) {\n- this.scales[i] = OpenLayers.Util.getScaleFromResolution(\n- this.resolutions[i], this.units);\n- }\n- this.numZoomLevels = len;\n- }\n- this.minResolution = minResolution;\n- if (minResolution) {\n- this.maxScale = OpenLayers.Util.getScaleFromResolution(\n- minResolution, this.units);\n- }\n- this.maxResolution = maxResolution;\n- if (maxResolution) {\n- this.minScale = OpenLayers.Util.getScaleFromResolution(\n- maxResolution, this.units);\n- }\n- },\n+/**\n+ * Class: OpenLayers.Filter.Comparison\n+ * This class represents a comparison filter.\n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Filter.Comparison = OpenLayers.Class(OpenLayers.Filter, {\n \n /**\n- * Method: resolutionsFromScales\n- * Derive resolutions from scales.\n- *\n- * Parameters:\n- * scales - {Array(Number)} Scales\n- *\n- * Returns\n- * {Array(Number)} Resolutions\n+ * APIProperty: type\n+ * {String} type: type of the comparison. This is one of\n+ * - OpenLayers.Filter.Comparison.EQUAL_TO = \"==\";\n+ * - OpenLayers.Filter.Comparison.NOT_EQUAL_TO = \"!=\";\n+ * - OpenLayers.Filter.Comparison.LESS_THAN = \"<\";\n+ * - OpenLayers.Filter.Comparison.GREATER_THAN = \">\";\n+ * - OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO = \"<=\";\n+ * - OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO = \">=\";\n+ * - OpenLayers.Filter.Comparison.BETWEEN = \"..\";\n+ * - OpenLayers.Filter.Comparison.LIKE = \"~\";\n+ * - OpenLayers.Filter.Comparison.IS_NULL = \"NULL\";\n */\n- resolutionsFromScales: function(scales) {\n- if (scales == null) {\n- return;\n- }\n- var resolutions, i, len;\n- len = scales.length;\n- resolutions = new Array(len);\n- for (i = 0; i < len; i++) {\n- resolutions[i] = OpenLayers.Util.getResolutionFromScale(\n- scales[i], this.units);\n- }\n- return resolutions;\n- },\n+ type: null,\n \n /**\n- * Method: calculateResolutions\n- * Calculate resolutions based on the provided properties.\n- *\n- * Parameters:\n- * props - {Object} Properties\n- *\n- * Returns:\n- * {Array({Number})} Array of resolutions.\n+ * APIProperty: property\n+ * {String}\n+ * name of the context property to compare\n */\n- calculateResolutions: function(props) {\n-\n- var viewSize, wRes, hRes;\n-\n- // determine maxResolution\n- var maxResolution = props.maxResolution;\n- if (props.minScale != null) {\n- maxResolution =\n- OpenLayers.Util.getResolutionFromScale(props.minScale,\n- this.units);\n- } else if (maxResolution == \"auto\" && this.maxExtent != null) {\n- viewSize = this.map.getSize();\n- wRes = this.maxExtent.getWidth() / viewSize.w;\n- hRes = this.maxExtent.getHeight() / viewSize.h;\n- maxResolution = Math.max(wRes, hRes);\n- }\n-\n- // determine minResolution\n- var minResolution = props.minResolution;\n- if (props.maxScale != null) {\n- minResolution =\n- OpenLayers.Util.getResolutionFromScale(props.maxScale,\n- this.units);\n- } else if (props.minResolution == \"auto\" && this.minExtent != null) {\n- viewSize = this.map.getSize();\n- wRes = this.minExtent.getWidth() / viewSize.w;\n- hRes = this.minExtent.getHeight() / viewSize.h;\n- minResolution = Math.max(wRes, hRes);\n- }\n-\n- if (typeof maxResolution !== \"number\" &&\n- typeof minResolution !== \"number\" &&\n- this.maxExtent != null) {\n- // maxResolution for default grid sets assumes that at zoom\n- // level zero, the whole world fits on one tile.\n- var tileSize = this.map.getTileSize();\n- maxResolution = Math.max(\n- this.maxExtent.getWidth() / tileSize.w,\n- this.maxExtent.getHeight() / tileSize.h\n- );\n- }\n-\n- // determine numZoomLevels\n- var maxZoomLevel = props.maxZoomLevel;\n- var numZoomLevels = props.numZoomLevels;\n- if (typeof minResolution === \"number\" &&\n- typeof maxResolution === \"number\" && numZoomLevels === undefined) {\n- var ratio = maxResolution / minResolution;\n- numZoomLevels = Math.floor(Math.log(ratio) / Math.log(2)) + 1;\n- } else if (numZoomLevels === undefined && maxZoomLevel != null) {\n- numZoomLevels = maxZoomLevel + 1;\n- }\n-\n- // are we able to calculate resolutions?\n- if (typeof numZoomLevels !== \"number\" || numZoomLevels <= 0 ||\n- (typeof maxResolution !== \"number\" &&\n- typeof minResolution !== \"number\")) {\n- return;\n- }\n-\n- // now we have numZoomLevels and at least one of maxResolution\n- // or minResolution, we can populate the resolutions array\n-\n- var resolutions = new Array(numZoomLevels);\n- var base = 2;\n- if (typeof minResolution == \"number\" &&\n- typeof maxResolution == \"number\") {\n- // if maxResolution and minResolution are set, we calculate\n- // the base for exponential scaling that starts at\n- // maxResolution and ends at minResolution in numZoomLevels\n- // steps.\n- base = Math.pow(\n- (maxResolution / minResolution),\n- (1 / (numZoomLevels - 1))\n- );\n- }\n-\n- var i;\n- if (typeof maxResolution === \"number\") {\n- for (i = 0; i < numZoomLevels; i++) {\n- resolutions[i] = maxResolution / Math.pow(base, i);\n- }\n- } else {\n- for (i = 0; i < numZoomLevels; i++) {\n- resolutions[numZoomLevels - 1 - i] =\n- minResolution * Math.pow(base, i);\n- }\n- }\n-\n- return resolutions;\n- },\n+ property: null,\n \n /**\n- * APIMethod: getResolution\n- * \n- * Returns:\n- * {Float} The currently selected resolution of the map, taken from the\n- * resolutions array, indexed by current zoom level.\n+ * APIProperty: value\n+ * {Number} or {String}\n+ * comparison value for binary comparisons. In the case of a String, this\n+ * can be a combination of text and propertyNames in the form\n+ * \"literal ${propertyName}\"\n */\n- getResolution: function() {\n- var zoom = this.map.getZoom();\n- return this.getResolutionForZoom(zoom);\n- },\n+ value: null,\n \n- /** \n- * APIMethod: getExtent\n- * \n- * Returns:\n- * {} A Bounds object which represents the lon/lat \n- * bounds of the current viewPort.\n+ /**\n+ * Property: matchCase\n+ * {Boolean} Force case sensitive searches for EQUAL_TO and NOT_EQUAL_TO\n+ * comparisons. The Filter Encoding 1.1 specification added a matchCase\n+ * attribute to ogc:PropertyIsEqualTo and ogc:PropertyIsNotEqualTo\n+ * elements. This property will be serialized with those elements only\n+ * if using the v1.1.0 filter format. However, when evaluating filters\n+ * here, the matchCase property will always be respected (for EQUAL_TO\n+ * and NOT_EQUAL_TO). Default is true. \n */\n- getExtent: function() {\n- // just use stock map calculateBounds function -- passing no arguments\n- // means it will user map's current center & resolution\n- //\n- return this.map.calculateBounds();\n- },\n+ matchCase: true,\n \n /**\n- * APIMethod: getZoomForExtent\n- * \n- * Parameters:\n- * extent - {}\n- * closest - {Boolean} Find the zoom level that most closely fits the \n- * specified bounds. Note that this may result in a zoom that does \n- * not exactly contain the entire extent.\n- * Default is false.\n- *\n- * Returns:\n- * {Integer} The index of the zoomLevel (entry in the resolutions array) \n- * for the passed-in extent. We do this by calculating the ideal \n- * resolution for the given extent (based on the map size) and then \n- * calling getZoomForResolution(), passing along the 'closest'\n- * parameter.\n+ * APIProperty: lowerBoundary\n+ * {Number} or {String}\n+ * lower boundary for between comparisons. In the case of a String, this\n+ * can be a combination of text and propertyNames in the form\n+ * \"literal ${propertyName}\"\n */\n- getZoomForExtent: function(extent, closest) {\n- var viewSize = this.map.getSize();\n- var idealResolution = Math.max(extent.getWidth() / viewSize.w,\n- extent.getHeight() / viewSize.h);\n-\n- return this.getZoomForResolution(idealResolution, closest);\n- },\n+ lowerBoundary: null,\n \n- /** \n- * Method: getDataExtent\n- * Calculates the max extent which includes all of the data for the layer.\n- * This function is to be implemented by subclasses.\n- * \n- * Returns:\n- * {}\n+ /**\n+ * APIProperty: upperBoundary\n+ * {Number} or {String}\n+ * upper boundary for between comparisons. In the case of a String, this\n+ * can be a combination of text and propertyNames in the form\n+ * \"literal ${propertyName}\"\n */\n- getDataExtent: function() {\n- //to be implemented by subclasses\n- },\n+ upperBoundary: null,\n \n- /**\n- * APIMethod: getResolutionForZoom\n- * \n+ /** \n+ * Constructor: OpenLayers.Filter.Comparison\n+ * Creates a comparison rule.\n+ *\n * Parameters:\n- * zoom - {Float}\n+ * options - {Object} An optional object with properties to set on the\n+ * rule\n * \n * Returns:\n- * {Float} A suitable resolution for the specified zoom.\n+ * {}\n */\n- getResolutionForZoom: function(zoom) {\n- zoom = Math.max(0, Math.min(zoom, this.resolutions.length - 1));\n- var resolution;\n- if (this.map.fractionalZoom) {\n- var low = Math.floor(zoom);\n- var high = Math.ceil(zoom);\n- resolution = this.resolutions[low] -\n- ((zoom - low) * (this.resolutions[low] - this.resolutions[high]));\n- } else {\n- resolution = this.resolutions[Math.round(zoom)];\n+ initialize: function(options) {\n+ OpenLayers.Filter.prototype.initialize.apply(this, [options]);\n+ // since matchCase on PropertyIsLike is not schema compliant, we only\n+ // want to use this if explicitly asked for\n+ if (this.type === OpenLayers.Filter.Comparison.LIKE &&\n+ options.matchCase === undefined) {\n+ this.matchCase = null;\n }\n- return resolution;\n },\n \n /**\n- * APIMethod: getZoomForResolution\n+ * APIMethod: evaluate\n+ * Evaluates this filter in a specific context.\n * \n * Parameters:\n- * resolution - {Float}\n- * closest - {Boolean} Find the zoom level that corresponds to the absolute \n- * closest resolution, which may result in a zoom whose corresponding\n- * resolution is actually smaller than we would have desired (if this\n- * is being called from a getZoomForExtent() call, then this means that\n- * the returned zoom index might not actually contain the entire \n- * extent specified... but it'll be close).\n- * Default is false.\n+ * context - {Object} Context to use in evaluating the filter. If a vector\n+ * feature is provided, the feature.attributes will be used as context.\n * \n * Returns:\n- * {Integer} The index of the zoomLevel (entry in the resolutions array) \n- * that corresponds to the best fit resolution given the passed in \n- * value and the 'closest' specification.\n+ * {Boolean} The filter applies.\n */\n- getZoomForResolution: function(resolution, closest) {\n- var zoom, i, len;\n- if (this.map.fractionalZoom) {\n- var lowZoom = 0;\n- var highZoom = this.resolutions.length - 1;\n- var highRes = this.resolutions[lowZoom];\n- var lowRes = this.resolutions[highZoom];\n- var res;\n- for (i = 0, len = this.resolutions.length; i < len; ++i) {\n- res = this.resolutions[i];\n- if (res >= resolution) {\n- highRes = res;\n- lowZoom = i;\n- }\n- if (res <= resolution) {\n- lowRes = res;\n- highZoom = i;\n- break;\n+ evaluate: function(context) {\n+ if (context instanceof OpenLayers.Feature.Vector) {\n+ context = context.attributes;\n+ }\n+ var result = false;\n+ var got = context[this.property];\n+ var exp;\n+ switch (this.type) {\n+ case OpenLayers.Filter.Comparison.EQUAL_TO:\n+ exp = this.value;\n+ if (!this.matchCase &&\n+ typeof got == \"string\" && typeof exp == \"string\") {\n+ result = (got.toUpperCase() == exp.toUpperCase());\n+ } else {\n+ result = (got == exp);\n }\n- }\n- var dRes = highRes - lowRes;\n- if (dRes > 0) {\n- zoom = lowZoom + ((highRes - resolution) / dRes);\n- } else {\n- zoom = lowZoom;\n- }\n- } else {\n- var diff;\n- var minDiff = Number.POSITIVE_INFINITY;\n- for (i = 0, len = this.resolutions.length; i < len; i++) {\n- if (closest) {\n- diff = Math.abs(this.resolutions[i] - resolution);\n- if (diff > minDiff) {\n- break;\n- }\n- minDiff = diff;\n+ break;\n+ case OpenLayers.Filter.Comparison.NOT_EQUAL_TO:\n+ exp = this.value;\n+ if (!this.matchCase &&\n+ typeof got == \"string\" && typeof exp == \"string\") {\n+ result = (got.toUpperCase() != exp.toUpperCase());\n } else {\n- if (this.resolutions[i] < resolution) {\n- break;\n- }\n+ result = (got != exp);\n }\n- }\n- zoom = Math.max(0, i - 1);\n+ break;\n+ case OpenLayers.Filter.Comparison.LESS_THAN:\n+ result = got < this.value;\n+ break;\n+ case OpenLayers.Filter.Comparison.GREATER_THAN:\n+ result = got > this.value;\n+ break;\n+ case OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO:\n+ result = got <= this.value;\n+ break;\n+ case OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO:\n+ result = got >= this.value;\n+ break;\n+ case OpenLayers.Filter.Comparison.BETWEEN:\n+ result = (got >= this.lowerBoundary) &&\n+ (got <= this.upperBoundary);\n+ break;\n+ case OpenLayers.Filter.Comparison.LIKE:\n+ var regexp = new RegExp(this.value, \"gi\");\n+ result = regexp.test(got);\n+ break;\n+ case OpenLayers.Filter.Comparison.IS_NULL:\n+ result = (got === null);\n+ break;\n }\n- return zoom;\n+ return result;\n },\n \n /**\n- * APIMethod: getLonLatFromViewPortPx\n+ * APIMethod: value2regex\n+ * Converts the value of this rule into a regular expression string,\n+ * according to the wildcard characters specified. This method has to\n+ * be called after instantiation of this class, if the value is not a\n+ * regular expression already.\n * \n * Parameters:\n- * viewPortPx - {|Object} An OpenLayers.Pixel or\n- * an object with a 'x'\n- * and 'y' properties.\n- *\n+ * wildCard - {Char} wildcard character in the above value, default\n+ * is \"*\"\n+ * singleChar - {Char} single-character wildcard in the above value\n+ * default is \".\"\n+ * escapeChar - {Char} escape character in the above value, default is\n+ * \"!\"\n+ * \n * Returns:\n- * {} An OpenLayers.LonLat which is the passed-in \n- * view port , translated into lon/lat by the layer.\n+ * {String} regular expression string\n */\n- getLonLatFromViewPortPx: function(viewPortPx) {\n- var lonlat = null;\n- var map = this.map;\n- if (viewPortPx != null && map.minPx) {\n- var res = map.getResolution();\n- var maxExtent = map.getMaxExtent({\n- restricted: true\n- });\n- var lon = (viewPortPx.x - map.minPx.x) * res + maxExtent.left;\n- var lat = (map.minPx.y - viewPortPx.y) * res + maxExtent.top;\n- lonlat = new OpenLayers.LonLat(lon, lat);\n-\n- if (this.wrapDateLine) {\n- lonlat = lonlat.wrapDateLine(this.maxExtent);\n- }\n+ value2regex: function(wildCard, singleChar, escapeChar) {\n+ if (wildCard == \".\") {\n+ throw new Error(\"'.' is an unsupported wildCard character for \" +\n+ \"OpenLayers.Filter.Comparison\");\n }\n- return lonlat;\n- },\n \n- /**\n- * APIMethod: getViewPortPxFromLonLat\n- * Returns a pixel location given a map location. This method will return\n- * fractional pixel values.\n- * \n- * Parameters:\n- * lonlat - {|Object} An OpenLayers.LonLat or\n- * an object with a 'lon'\n- * and 'lat' properties.\n- *\n- * Returns: \n- * {} An which is the passed-in \n- * lonlat translated into view port pixels.\n- */\n- getViewPortPxFromLonLat: function(lonlat, resolution) {\n- var px = null;\n- if (lonlat != null) {\n- resolution = resolution || this.map.getResolution();\n- var extent = this.map.calculateBounds(null, resolution);\n- px = new OpenLayers.Pixel(\n- (1 / resolution * (lonlat.lon - extent.left)),\n- (1 / resolution * (extent.top - lonlat.lat))\n- );\n- }\n- return px;\n- },\n \n- /**\n- * APIMethod: setOpacity\n- * Sets the opacity for the entire layer (all images)\n- * \n- * Parameters:\n- * opacity - {Float}\n- */\n- setOpacity: function(opacity) {\n- if (opacity != this.opacity) {\n- this.opacity = opacity;\n- var childNodes = this.div.childNodes;\n- for (var i = 0, len = childNodes.length; i < len; ++i) {\n- var element = childNodes[i].firstChild || childNodes[i];\n- var lastChild = childNodes[i].lastChild;\n- //TODO de-uglify this\n- if (lastChild && lastChild.nodeName.toLowerCase() === \"iframe\") {\n- element = lastChild.parentNode;\n- }\n- OpenLayers.Util.modifyDOMElement(element, null, null, null,\n- null, null, null, opacity);\n- }\n- if (this.map != null) {\n- this.map.events.triggerEvent(\"changelayer\", {\n- layer: this,\n- property: \"opacity\"\n- });\n- }\n- }\n- },\n+ // set UMN MapServer defaults for unspecified parameters\n+ wildCard = wildCard ? wildCard : \"*\";\n+ singleChar = singleChar ? singleChar : \".\";\n+ escapeChar = escapeChar ? escapeChar : \"!\";\n \n- /**\n- * Method: getZIndex\n- * \n- * Returns: \n- * {Integer} the z-index of this layer\n- */\n- getZIndex: function() {\n- return this.div.style.zIndex;\n+ this.value = this.value.replace(\n+ new RegExp(\"\\\\\" + escapeChar + \"(.|$)\", \"g\"), \"\\\\$1\");\n+ this.value = this.value.replace(\n+ new RegExp(\"\\\\\" + singleChar, \"g\"), \".\");\n+ this.value = this.value.replace(\n+ new RegExp(\"\\\\\" + wildCard, \"g\"), \".*\");\n+ this.value = this.value.replace(\n+ new RegExp(\"\\\\\\\\.\\\\*\", \"g\"), \"\\\\\" + wildCard);\n+ this.value = this.value.replace(\n+ new RegExp(\"\\\\\\\\\\\\.\", \"g\"), \"\\\\\" + singleChar);\n+\n+ return this.value;\n },\n \n /**\n- * Method: setZIndex\n+ * Method: regex2value\n+ * Convert the value of this rule from a regular expression string into an\n+ * ogc literal string using a wildCard of *, a singleChar of ., and an\n+ * escape of !. Leaves the property unmodified.\n * \n- * Parameters: \n- * zIndex - {Integer}\n+ * Returns:\n+ * {String} A string value.\n */\n- setZIndex: function(zIndex) {\n- this.div.style.zIndex = zIndex;\n+ regex2value: function() {\n+\n+ var value = this.value;\n+\n+ // replace ! with !!\n+ value = value.replace(/!/g, \"!!\");\n+\n+ // replace \\. with !. (watching out for \\\\.)\n+ value = value.replace(/(\\\\)?\\\\\\./g, function($0, $1) {\n+ return $1 ? $0 : \"!.\";\n+ });\n+\n+ // replace \\* with #* (watching out for \\\\*)\n+ value = value.replace(/(\\\\)?\\\\\\*/g, function($0, $1) {\n+ return $1 ? $0 : \"!*\";\n+ });\n+\n+ // replace \\\\ with \\\n+ value = value.replace(/\\\\\\\\/g, \"\\\\\");\n+\n+ // convert .* to * (the sequence #.* is not allowed)\n+ value = value.replace(/\\.\\*/g, \"*\");\n+\n+ return value;\n },\n \n /**\n- * Method: adjustBounds\n- * This function will take a bounds, and if wrapDateLine option is set\n- * on the layer, it will return a bounds which is wrapped around the \n- * world. We do not wrap for bounds which *cross* the \n- * maxExtent.left/right, only bounds which are entirely to the left \n- * or entirely to the right.\n+ * APIMethod: clone\n+ * Clones this filter.\n * \n- * Parameters:\n- * bounds - {}\n+ * Returns:\n+ * {} Clone of this filter.\n */\n- adjustBounds: function(bounds) {\n-\n- if (this.gutter) {\n- // Adjust the extent of a bounds in map units by the \n- // layer's gutter in pixels.\n- var mapGutter = this.gutter * this.map.getResolution();\n- bounds = new OpenLayers.Bounds(bounds.left - mapGutter,\n- bounds.bottom - mapGutter,\n- bounds.right + mapGutter,\n- bounds.top + mapGutter);\n- }\n-\n- if (this.wrapDateLine) {\n- // wrap around the date line, within the limits of rounding error\n- var wrappingOptions = {\n- 'rightTolerance': this.getResolution(),\n- 'leftTolerance': this.getResolution()\n- };\n- bounds = bounds.wrapDateLine(this.maxExtent, wrappingOptions);\n-\n- }\n- return bounds;\n+ clone: function() {\n+ return OpenLayers.Util.extend(new OpenLayers.Filter.Comparison(), this);\n },\n \n- CLASS_NAME: \"OpenLayers.Layer\"\n+ CLASS_NAME: \"OpenLayers.Filter.Comparison\"\n });\n+\n+\n+OpenLayers.Filter.Comparison.EQUAL_TO = \"==\";\n+OpenLayers.Filter.Comparison.NOT_EQUAL_TO = \"!=\";\n+OpenLayers.Filter.Comparison.LESS_THAN = \"<\";\n+OpenLayers.Filter.Comparison.GREATER_THAN = \">\";\n+OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO = \"<=\";\n+OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO = \">=\";\n+OpenLayers.Filter.Comparison.BETWEEN = \"..\";\n+OpenLayers.Filter.Comparison.LIKE = \"~\";\n+OpenLayers.Filter.Comparison.IS_NULL = \"NULL\";\n /* ======================================================================\n- OpenLayers/Symbolizer/Point.js\n+ OpenLayers/Format/Filter.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Symbolizer.js\n+ * @requires OpenLayers/Format/XML/VersionedOGC.js\n+ * @requires OpenLayers/Filter/FeatureId.js\n+ * @requires OpenLayers/Filter/Logical.js\n+ * @requires OpenLayers/Filter/Comparison.js\n */\n \n /**\n- * Class: OpenLayers.Symbolizer.Point\n- * A symbolizer used to render point features.\n+ * Class: OpenLayers.Format.Filter\n+ * Read/Write ogc:Filter. Create a new instance with the \n+ * constructor.\n+ * \n+ * Inherits from:\n+ * - \n */\n-OpenLayers.Symbolizer.Point = OpenLayers.Class(OpenLayers.Symbolizer, {\n-\n- /**\n- * APIProperty: strokeColor\n- * {String} Color for line stroke. This is a RGB hex value (e.g. \"#ff0000\"\n- * for red).\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n- /**\n- * APIProperty: strokeOpacity\n- * {Number} Stroke opacity (0-1).\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n- /**\n- * APIProperty: strokeWidth\n- * {Number} Pixel stroke width.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n- /**\n- * APIProperty: strokeLinecap\n- * {String} Stroke cap type (\"butt\", \"round\", or \"square\").\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n- /**\n- * Property: strokeDashstyle\n- * {String} Stroke dash style according to the SLD spec. Note that the\n- * OpenLayers values for strokeDashstyle (\"dot\", \"dash\", \"dashdot\",\n- * \"longdash\", \"longdashdot\", or \"solid\") will not work in SLD, but\n- * most SLD patterns will render correctly in OpenLayers.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n- /**\n- * APIProperty: fillColor\n- * {String} RGB hex fill color (e.g. \"#ff0000\" for red).\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n- /**\n- * APIProperty: fillOpacity\n- * {Number} Fill opacity (0-1).\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n+OpenLayers.Format.Filter = OpenLayers.Class(OpenLayers.Format.XML.VersionedOGC, {\n \n /**\n- * APIProperty: pointRadius\n- * {Number} Pixel point radius.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n+ * APIProperty: defaultVersion\n+ * {String} Version number to assume if none found. Default is \"1.0.0\".\n */\n+ defaultVersion: \"1.0.0\",\n \n /**\n- * APIProperty: externalGraphic\n- * {String} Url to an external graphic that will be used for rendering \n- * points.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n+ * APIMethod: write\n+ * Write an ogc:Filter given a filter object.\n+ *\n+ * Parameters:\n+ * filter - {} An filter.\n+ * options - {Object} Optional configuration object.\n+ *\n+ * Returns:\n+ * {Elment} An ogc:Filter element node.\n */\n \n /**\n- * APIProperty: graphicWidth\n- * {Number} Pixel width for sizing an external graphic.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n+ * APIMethod: read\n+ * Read and Filter doc and return an object representing the Filter.\n+ *\n+ * Parameters:\n+ * data - {String | DOMElement} Data to read.\n+ *\n+ * Returns:\n+ * {} A filter object.\n */\n \n- /**\n- * APIProperty: graphicHeight\n- * {Number} Pixel height for sizing an external graphic.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n+ CLASS_NAME: \"OpenLayers.Format.Filter\"\n+});\n+/* ======================================================================\n+ OpenLayers/Filter/Function.js\n+ ====================================================================== */\n \n- /**\n- * APIProperty: graphicOpacity\n- * {Number} Opacity (0-1) for an external graphic.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- /**\n- * APIProperty: graphicXOffset\n- * {Number} Pixel offset along the positive x axis for displacing an \n- * external graphic.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n+/**\n+ * @requires OpenLayers/Filter.js\n+ */\n \n- /**\n- * APIProperty: graphicYOffset\n- * {Number} Pixel offset along the positive y axis for displacing an \n- * external graphic.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n+/**\n+ * Class: OpenLayers.Filter.Function\n+ * This class represents a filter function.\n+ * We are using this class for creation of complex \n+ * filters that can contain filter functions as values.\n+ * Nesting function as other functions parameter is supported.\n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Filter.Function = OpenLayers.Class(OpenLayers.Filter, {\n \n /**\n- * APIProperty: rotation\n- * {Number} The rotation of a graphic in the clockwise direction about its \n- * center point (or any point off center as specified by \n- * and ).\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n+ * APIProperty: name\n+ * {String} Name of the function.\n */\n+ name: null,\n \n /**\n- * APIProperty: graphicName\n- * {String} Named graphic to use when rendering points. Supported values \n- * include \"circle\", \"square\", \"star\", \"x\", \"cross\", and \"triangle\".\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n+ * APIProperty: params\n+ * {Array( || String || Number)} Function parameters\n+ * For now support only other Functions, String or Number\n */\n+ params: null,\n \n- /**\n- * Constructor: OpenLayers.Symbolizer.Point\n- * Create a symbolizer for rendering points.\n+ /** \n+ * Constructor: OpenLayers.Filter.Function\n+ * Creates a filter function.\n *\n * Parameters:\n- * config - {Object} An object containing properties to be set on the \n- * symbolizer. Any documented symbolizer property can be set at \n- * construction.\n- *\n+ * options - {Object} An optional object with properties to set on the\n+ * function.\n+ * \n * Returns:\n- * A new point symbolizer.\n+ * {}\n */\n- initialize: function(config) {\n- OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Symbolizer.Point\"\n \n+ CLASS_NAME: \"OpenLayers.Filter.Function\"\n });\n \n /* ======================================================================\n- OpenLayers/Symbolizer/Line.js\n+ OpenLayers/BaseTypes/Date.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Symbolizer.js\n+ * @requires OpenLayers/SingleFile.js\n */\n \n /**\n- * Class: OpenLayers.Symbolizer.Line\n- * A symbolizer used to render line features.\n+ * Namespace: OpenLayers.Date\n+ * Contains implementations of Date.parse and date.toISOString that match the\n+ * ECMAScript 5 specification for parsing RFC 3339 dates.\n+ * http://tools.ietf.org/html/rfc3339\n */\n-OpenLayers.Symbolizer.Line = OpenLayers.Class(OpenLayers.Symbolizer, {\n-\n- /**\n- * APIProperty: strokeColor\n- * {String} Color for line stroke. This is a RGB hex value (e.g. \"#ff0000\"\n- * for red). \n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n- /**\n- * APIProperty: strokeOpacity\n- * {Number} Stroke opacity (0-1).\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n+OpenLayers.Date = {\n \n- /**\n- * APIProperty: strokeWidth\n- * {Number} Pixel stroke width.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n+ /** \n+ * APIProperty: dateRegEx\n+ * The regex to be used for validating dates. You can provide your own\n+ * regex for instance for adding support for years before BC. Default\n+ * value is: /^(?:(\\d{4})(?:-(\\d{2})(?:-(\\d{2}))?)?)?(?:(?:T(\\d{1,2}):(\\d{2}):(\\d{2}(?:\\.\\d+)?)(Z|(?:[+-]\\d{1,2}(?::(\\d{2}))?)))|Z)?$/\n */\n+ dateRegEx: /^(?:(\\d{4})(?:-(\\d{2})(?:-(\\d{2}))?)?)?(?:(?:T(\\d{1,2}):(\\d{2}):(\\d{2}(?:\\.\\d+)?)(Z|(?:[+-]\\d{1,2}(?::(\\d{2}))?)))|Z)?$/,\n \n /**\n- * APIProperty: strokeLinecap\n- * {String} Stroke cap type (\"butt\", \"round\", or \"square\").\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n+ * APIMethod: toISOString\n+ * Generates a string representing a date. The format of the string follows\n+ * the profile of ISO 8601 for date and time on the Internet (see\n+ * http://tools.ietf.org/html/rfc3339). If the toISOString method is\n+ * available on the Date prototype, that is used. The toISOString\n+ * method for Date instances is defined in ECMA-262.\n+ *\n+ * Parameters:\n+ * date - {Date} A date object.\n+ *\n+ * Returns:\n+ * {String} A string representing the date (e.g.\n+ * \"2010-08-07T16:58:23.123Z\"). If the date does not have a valid time\n+ * (i.e. isNaN(date.getTime())) this method returns the string \"Invalid\n+ * Date\". The ECMA standard says the toISOString method should throw\n+ * RangeError in this case, but Firefox returns a string instead. For\n+ * best results, use isNaN(date.getTime()) to determine date validity\n+ * before generating date strings.\n */\n+ toISOString: (function() {\n+ if (\"toISOString\" in Date.prototype) {\n+ return function(date) {\n+ return date.toISOString();\n+ };\n+ } else {\n+ return function(date) {\n+ var str;\n+ if (isNaN(date.getTime())) {\n+ // ECMA-262 says throw RangeError, Firefox returns\n+ // \"Invalid Date\"\n+ str = \"Invalid Date\";\n+ } else {\n+ str =\n+ date.getUTCFullYear() + \"-\" +\n+ OpenLayers.Number.zeroPad(date.getUTCMonth() + 1, 2) + \"-\" +\n+ OpenLayers.Number.zeroPad(date.getUTCDate(), 2) + \"T\" +\n+ OpenLayers.Number.zeroPad(date.getUTCHours(), 2) + \":\" +\n+ OpenLayers.Number.zeroPad(date.getUTCMinutes(), 2) + \":\" +\n+ OpenLayers.Number.zeroPad(date.getUTCSeconds(), 2) + \".\" +\n+ OpenLayers.Number.zeroPad(date.getUTCMilliseconds(), 3) + \"Z\";\n+ }\n+ return str;\n+ };\n+ }\n \n- /**\n- * Property: strokeDashstyle\n- * {String} Stroke dash style according to the SLD spec. Note that the\n- * OpenLayers values for strokeDashstyle (\"dot\", \"dash\", \"dashdot\",\n- * \"longdash\", \"longdashdot\", or \"solid\") will not work in SLD, but\n- * most SLD patterns will render correctly in OpenLayers.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n+ })(),\n \n /**\n- * Constructor: OpenLayers.Symbolizer.Line\n- * Create a symbolizer for rendering lines.\n+ * APIMethod: parse\n+ * Generate a date object from a string. The format for the string follows\n+ * the profile of ISO 8601 for date and time on the Internet (see\n+ * http://tools.ietf.org/html/rfc3339). We don't call the native\n+ * Date.parse because of inconsistency between implmentations. In\n+ * Chrome, calling Date.parse with a string that doesn't contain any\n+ * indication of the timezone (e.g. \"2011\"), the date is interpreted\n+ * in local time. On Firefox, the assumption is UTC.\n *\n * Parameters:\n- * config - {Object} An object containing properties to be set on the \n- * symbolizer. Any documented symbolizer property can be set at \n- * construction.\n+ * str - {String} A string representing the date (e.g.\n+ * \"2010\", \"2010-08\", \"2010-08-07\", \"2010-08-07T16:58:23.123Z\",\n+ * \"2010-08-07T11:58:23.123-06\").\n *\n * Returns:\n- * A new line symbolizer.\n+ * {Date} A date object. If the string could not be parsed, an invalid\n+ * date is returned (i.e. isNaN(date.getTime())).\n */\n- initialize: function(config) {\n- OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Symbolizer.Line\"\n-\n-});\n-\n+ parse: function(str) {\n+ var date;\n+ var match = str.match(this.dateRegEx);\n+ if (match && (match[1] || match[7])) { // must have at least year or time\n+ var year = parseInt(match[1], 10) || 0;\n+ var month = (parseInt(match[2], 10) - 1) || 0;\n+ var day = parseInt(match[3], 10) || 1;\n+ date = new Date(Date.UTC(year, month, day));\n+ // optional time\n+ var type = match[7];\n+ if (type) {\n+ var hours = parseInt(match[4], 10);\n+ var minutes = parseInt(match[5], 10);\n+ var secFrac = parseFloat(match[6]);\n+ var seconds = secFrac | 0;\n+ var milliseconds = Math.round(1000 * (secFrac - seconds));\n+ date.setUTCHours(hours, minutes, seconds, milliseconds);\n+ // check offset\n+ if (type !== \"Z\") {\n+ var hoursOffset = parseInt(type, 10);\n+ var minutesOffset = parseInt(match[8], 10) || 0;\n+ var offset = -1000 * (60 * (hoursOffset * 60) + minutesOffset * 60);\n+ date = new Date(date.getTime() + offset);\n+ }\n+ }\n+ } else {\n+ date = new Date(\"invalid\");\n+ }\n+ return date;\n+ }\n+};\n /* ======================================================================\n- OpenLayers/Symbolizer/Polygon.js\n+ OpenLayers/Format/Filter/v1.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n-\n /**\n- * @requires OpenLayers/Symbolizer.js\n+ * @requires OpenLayers/Format/Filter.js\n+ * @requires OpenLayers/Format/XML.js\n+ * @requires OpenLayers/Filter/Function.js\n+ * @requires OpenLayers/BaseTypes/Date.js\n */\n \n /**\n- * Class: OpenLayers.Symbolizer.Polygon\n- * A symbolizer used to render line features.\n+ * Class: OpenLayers.Format.Filter.v1\n+ * Superclass for Filter version 1 parsers.\n+ *\n+ * Inherits from:\n+ * - \n */\n-OpenLayers.Symbolizer.Polygon = OpenLayers.Class(OpenLayers.Symbolizer, {\n+OpenLayers.Format.Filter.v1 = OpenLayers.Class(OpenLayers.Format.XML, {\n \n /**\n- * APIProperty: strokeColor\n- * {String} Color for line stroke. This is a RGB hex value (e.g. \"#ff0000\"\n- * for red).\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n+ * Property: namespaces\n+ * {Object} Mapping of namespace aliases to namespace URIs.\n */\n+ namespaces: {\n+ ogc: \"http://www.opengis.net/ogc\",\n+ gml: \"http://www.opengis.net/gml\",\n+ xlink: \"http://www.w3.org/1999/xlink\",\n+ xsi: \"http://www.w3.org/2001/XMLSchema-instance\"\n+ },\n \n /**\n- * APIProperty: strokeOpacity\n- * {Number} Stroke opacity (0-1).\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n+ * Property: defaultPrefix\n */\n+ defaultPrefix: \"ogc\",\n \n /**\n- * APIProperty: strokeWidth\n- * {Number} Pixel stroke width.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n+ * Property: schemaLocation\n+ * {String} Schema location for a particular minor version.\n */\n+ schemaLocation: null,\n \n /**\n- * APIProperty: strokeLinecap\n- * {String} Stroke cap type (\"butt\", \"round\", or \"square\").\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n+ * Constructor: OpenLayers.Format.Filter.v1\n+ * Instances of this class are not created directly. Use the\n+ * constructor instead.\n+ *\n+ * Parameters:\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n */\n+ initialize: function(options) {\n+ OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);\n+ },\n \n /**\n- * Property: strokeDashstyle\n- * {String} Stroke dash style according to the SLD spec. Note that the\n- * OpenLayers values for strokeDashstyle (\"dot\", \"dash\", \"dashdot\",\n- * \"longdash\", \"longdashdot\", or \"solid\") will not work in SLD, but\n- * most SLD patterns will render correctly in OpenLayers.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n- /**\n- * APIProperty: fillColor\n- * {String} RGB hex fill color (e.g. \"#ff0000\" for red).\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n- /**\n- * APIProperty: fillOpacity\n- * {Number} Fill opacity (0-1).\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n- /**\n- * Constructor: OpenLayers.Symbolizer.Polygon\n- * Create a symbolizer for rendering polygons.\n+ * Method: read\n *\n * Parameters:\n- * config - {Object} An object containing properties to be set on the \n- * symbolizer. Any documented symbolizer property can be set at \n- * construction.\n+ * data - {DOMElement} A Filter document element.\n *\n * Returns:\n- * A new polygon symbolizer.\n+ * {} A filter object.\n */\n- initialize: function(config) {\n- OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);\n+ read: function(data) {\n+ var obj = {};\n+ this.readers.ogc[\"Filter\"].apply(this, [data, obj]);\n+ return obj.filter;\n },\n \n- CLASS_NAME: \"OpenLayers.Symbolizer.Polygon\"\n-\n-});\n-\n-/* ======================================================================\n- OpenLayers/Symbolizer/Text.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Symbolizer.js\n- */\n-\n-/**\n- * Class: OpenLayers.Symbolizer.Text\n- * A symbolizer used to render text labels for features.\n- */\n-OpenLayers.Symbolizer.Text = OpenLayers.Class(OpenLayers.Symbolizer, {\n-\n- /** \n- * APIProperty: label\n- * {String} The text for the label.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n- /** \n- * APIProperty: fontFamily\n- * {String} The font family for the label.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n- /** \n- * APIProperty: fontSize\n- * {String} The font size for the label.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n- /** \n- * APIProperty: fontWeight\n- * {String} The font weight for the label.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n- */\n-\n /**\n- * Property: fontStyle\n- * {String} The font style for the label.\n- * \n- * No default set here. Use OpenLayers.Renderer.defaultRenderer for defaults.\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n */\n+ readers: {\n+ \"ogc\": {\n+ \"_expression\": function(node) {\n+ // only the simplest of ogc:expression handled\n+ // \"some text and an attribute\"}\n+ var obj, value = \"\";\n+ for (var child = node.firstChild; child; child = child.nextSibling) {\n+ switch (child.nodeType) {\n+ case 1:\n+ obj = this.readNode(child);\n+ if (obj.property) {\n+ value += \"${\" + obj.property + \"}\";\n+ } else if (obj.value !== undefined) {\n+ value += obj.value;\n+ }\n+ break;\n+ case 3: // text node\n+ case 4: // cdata section\n+ value += child.nodeValue;\n+ }\n+ }\n+ return value;\n+ },\n+ \"Filter\": function(node, parent) {\n+ // Filters correspond to subclasses of OpenLayers.Filter.\n+ // Since they contain information we don't persist, we\n+ // create a temporary object and then pass on the filter\n+ // (ogc:Filter) to the parent obj.\n+ var obj = {\n+ fids: [],\n+ filters: []\n+ };\n+ this.readChildNodes(node, obj);\n+ if (obj.fids.length > 0) {\n+ parent.filter = new OpenLayers.Filter.FeatureId({\n+ fids: obj.fids\n+ });\n+ } else if (obj.filters.length > 0) {\n+ parent.filter = obj.filters[0];\n+ }\n+ },\n+ \"FeatureId\": function(node, obj) {\n+ var fid = node.getAttribute(\"fid\");\n+ if (fid) {\n+ obj.fids.push(fid);\n+ }\n+ },\n+ \"And\": function(node, obj) {\n+ var filter = new OpenLayers.Filter.Logical({\n+ type: OpenLayers.Filter.Logical.AND\n+ });\n+ this.readChildNodes(node, filter);\n+ obj.filters.push(filter);\n+ },\n+ \"Or\": function(node, obj) {\n+ var filter = new OpenLayers.Filter.Logical({\n+ type: OpenLayers.Filter.Logical.OR\n+ });\n+ this.readChildNodes(node, filter);\n+ obj.filters.push(filter);\n+ },\n+ \"Not\": function(node, obj) {\n+ var filter = new OpenLayers.Filter.Logical({\n+ type: OpenLayers.Filter.Logical.NOT\n+ });\n+ this.readChildNodes(node, filter);\n+ obj.filters.push(filter);\n+ },\n+ \"PropertyIsLessThan\": function(node, obj) {\n+ var filter = new OpenLayers.Filter.Comparison({\n+ type: OpenLayers.Filter.Comparison.LESS_THAN\n+ });\n+ this.readChildNodes(node, filter);\n+ obj.filters.push(filter);\n+ },\n+ \"PropertyIsGreaterThan\": function(node, obj) {\n+ var filter = new OpenLayers.Filter.Comparison({\n+ type: OpenLayers.Filter.Comparison.GREATER_THAN\n+ });\n+ this.readChildNodes(node, filter);\n+ obj.filters.push(filter);\n+ },\n+ \"PropertyIsLessThanOrEqualTo\": function(node, obj) {\n+ var filter = new OpenLayers.Filter.Comparison({\n+ type: OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO\n+ });\n+ this.readChildNodes(node, filter);\n+ obj.filters.push(filter);\n+ },\n+ \"PropertyIsGreaterThanOrEqualTo\": function(node, obj) {\n+ var filter = new OpenLayers.Filter.Comparison({\n+ type: OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO\n+ });\n+ this.readChildNodes(node, filter);\n+ obj.filters.push(filter);\n+ },\n+ \"PropertyIsBetween\": function(node, obj) {\n+ var filter = new OpenLayers.Filter.Comparison({\n+ type: OpenLayers.Filter.Comparison.BETWEEN\n+ });\n+ this.readChildNodes(node, filter);\n+ obj.filters.push(filter);\n+ },\n+ \"Literal\": function(node, obj) {\n+ obj.value = OpenLayers.String.numericIf(\n+ this.getChildValue(node), true);\n+ },\n+ \"PropertyName\": function(node, filter) {\n+ filter.property = this.getChildValue(node);\n+ },\n+ \"LowerBoundary\": function(node, filter) {\n+ filter.lowerBoundary = OpenLayers.String.numericIf(\n+ this.readers.ogc._expression.call(this, node), true);\n+ },\n+ \"UpperBoundary\": function(node, filter) {\n+ filter.upperBoundary = OpenLayers.String.numericIf(\n+ this.readers.ogc._expression.call(this, node), true);\n+ },\n+ \"Intersects\": function(node, obj) {\n+ this.readSpatial(node, obj, OpenLayers.Filter.Spatial.INTERSECTS);\n+ },\n+ \"Within\": function(node, obj) {\n+ this.readSpatial(node, obj, OpenLayers.Filter.Spatial.WITHIN);\n+ },\n+ \"Contains\": function(node, obj) {\n+ this.readSpatial(node, obj, OpenLayers.Filter.Spatial.CONTAINS);\n+ },\n+ \"DWithin\": function(node, obj) {\n+ this.readSpatial(node, obj, OpenLayers.Filter.Spatial.DWITHIN);\n+ },\n+ \"Distance\": function(node, obj) {\n+ obj.distance = parseInt(this.getChildValue(node));\n+ obj.distanceUnits = node.getAttribute(\"units\");\n+ },\n+ \"Function\": function(node, obj) {\n+ //TODO write decoder for it\n+ return;\n+ },\n+ \"PropertyIsNull\": function(node, obj) {\n+ var filter = new OpenLayers.Filter.Comparison({\n+ type: OpenLayers.Filter.Comparison.IS_NULL\n+ });\n+ this.readChildNodes(node, filter);\n+ obj.filters.push(filter);\n+ }\n+ }\n+ },\n \n /**\n- * Constructor: OpenLayers.Symbolizer.Text\n- * Create a symbolizer for rendering text labels.\n+ * Method: readSpatial\n *\n+ * Read a {} filter.\n+ * \n * Parameters:\n- * config - {Object} An object containing properties to be set on the \n- * symbolizer. Any documented symbolizer property can be set at \n- * construction.\n+ * node - {DOMElement} A DOM element that contains an ogc:expression.\n+ * obj - {Object} The target object.\n+ * type - {String} One of the OpenLayers.Filter.Spatial.* constants.\n *\n * Returns:\n- * A new text symbolizer.\n+ * {} The created filter.\n */\n- initialize: function(config) {\n- OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);\n+ readSpatial: function(node, obj, type) {\n+ var filter = new OpenLayers.Filter.Spatial({\n+ type: type\n+ });\n+ this.readChildNodes(node, filter);\n+ filter.value = filter.components[0];\n+ delete filter.components;\n+ obj.filters.push(filter);\n },\n \n- CLASS_NAME: \"OpenLayers.Symbolizer.Text\"\n-\n-});\n-\n-/* ======================================================================\n- OpenLayers/Symbolizer/Raster.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Symbolizer.js\n- */\n-\n-/**\n- * Class: OpenLayers.Symbolizer.Raster\n- * A symbolizer used to render raster images.\n- */\n-OpenLayers.Symbolizer.Raster = OpenLayers.Class(OpenLayers.Symbolizer, {\n-\n /**\n- * Constructor: OpenLayers.Symbolizer.Raster\n- * Create a symbolizer for rendering rasters.\n+ * APIMethod: encodeLiteral\n+ * Generates the string representation of a value for use in \n+ * elements. The default encoder writes Date values as ISO 8601 \n+ * strings.\n *\n * Parameters:\n- * config - {Object} An object containing properties to be set on the \n- * symbolizer. Any documented symbolizer property can be set at \n- * construction.\n+ * value - {Object} Literal value to encode\n *\n * Returns:\n- * A new raster symbolizer.\n+ * {String} String representation of the provided value.\n */\n- initialize: function(config) {\n- OpenLayers.Symbolizer.prototype.initialize.apply(this, arguments);\n+ encodeLiteral: function(value) {\n+ if (value instanceof Date) {\n+ value = OpenLayers.Date.toISOString(value);\n+ }\n+ return value;\n },\n \n- CLASS_NAME: \"OpenLayers.Symbolizer.Raster\"\n-\n-});\n-/* ======================================================================\n- OpenLayers/Style2.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Rule.js\n- * @requires OpenLayers/Symbolizer/Point.js\n- * @requires OpenLayers/Symbolizer/Line.js\n- * @requires OpenLayers/Symbolizer/Polygon.js\n- * @requires OpenLayers/Symbolizer/Text.js\n- * @requires OpenLayers/Symbolizer/Raster.js\n- */\n-\n-/**\n- * Class: OpenLayers.Style2\n- * This class represents a collection of rules for rendering features.\n- */\n-OpenLayers.Style2 = OpenLayers.Class({\n-\n- /**\n- * Property: id\n- * {String} A unique id for this session.\n- */\n- id: null,\n-\n- /**\n- * APIProperty: name\n- * {String} Style identifier.\n- */\n- name: null,\n-\n /**\n- * APIProperty: title\n- * {String} Title of this style.\n- */\n- title: null,\n-\n- /**\n- * APIProperty: description\n- * {String} Description of this style.\n- */\n- description: null,\n-\n- /**\n- * APIProperty: layerName\n- * {} Name of the layer that this style belongs to, usually\n- * according to the NamedLayer attribute of an SLD document.\n+ * Method: writeOgcExpression\n+ * Limited support for writing OGC expressions. Currently it supports\n+ * ( || String || Number)\n+ *\n+ * Parameters:\n+ * value - ( || String || Number)\n+ * node - {DOMElement} A parent DOM element \n+ *\n+ * Returns:\n+ * {DOMElement} Updated node element.\n */\n- layerName: null,\n+ writeOgcExpression: function(value, node) {\n+ if (value instanceof OpenLayers.Filter.Function) {\n+ this.writeNode(\"Function\", value, node);\n+ } else {\n+ this.writeNode(\"Literal\", value, node);\n+ }\n+ return node;\n+ },\n \n /**\n- * APIProperty: isDefault\n- * {Boolean}\n- */\n- isDefault: false,\n-\n- /** \n- * APIProperty: rules \n- * {Array()} Collection of rendering rules.\n- */\n- rules: null,\n-\n- /** \n- * Constructor: OpenLayers.Style2\n- * Creates a style representing a collection of rendering rules.\n+ * Method: write\n *\n * Parameters:\n- * config - {Object} An object containing properties to be set on the \n- * style. Any documented properties may be set at construction.\n+ * filter - {} A filter object.\n *\n * Returns:\n- * {} A new style object.\n+ * {DOMElement} An ogc:Filter element.\n */\n- initialize: function(config) {\n- OpenLayers.Util.extend(this, config);\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+ write: function(filter) {\n+ return this.writers.ogc[\"Filter\"].apply(this, [filter]);\n },\n \n- /** \n- * APIMethod: destroy\n- * nullify references to prevent circular references and memory leaks\n+ /**\n+ * Property: writers\n+ * As a compliment to the readers property, this structure contains public\n+ * writing functions grouped by namespace alias and named like the\n+ * node names they produce.\n */\n- destroy: function() {\n- for (var i = 0, len = this.rules.length; i < len; i++) {\n- this.rules[i].destroy();\n+ writers: {\n+ \"ogc\": {\n+ \"Filter\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:Filter\");\n+ this.writeNode(this.getFilterType(filter), filter, node);\n+ return node;\n+ },\n+ \"_featureIds\": function(filter) {\n+ var node = this.createDocumentFragment();\n+ for (var i = 0, ii = filter.fids.length; i < ii; ++i) {\n+ this.writeNode(\"ogc:FeatureId\", filter.fids[i], node);\n+ }\n+ return node;\n+ },\n+ \"FeatureId\": function(fid) {\n+ return this.createElementNSPlus(\"ogc:FeatureId\", {\n+ attributes: {\n+ fid: fid\n+ }\n+ });\n+ },\n+ \"And\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:And\");\n+ var childFilter;\n+ for (var i = 0, ii = filter.filters.length; i < ii; ++i) {\n+ childFilter = filter.filters[i];\n+ this.writeNode(\n+ this.getFilterType(childFilter), childFilter, node\n+ );\n+ }\n+ return node;\n+ },\n+ \"Or\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:Or\");\n+ var childFilter;\n+ for (var i = 0, ii = filter.filters.length; i < ii; ++i) {\n+ childFilter = filter.filters[i];\n+ this.writeNode(\n+ this.getFilterType(childFilter), childFilter, node\n+ );\n+ }\n+ return node;\n+ },\n+ \"Not\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:Not\");\n+ var childFilter = filter.filters[0];\n+ this.writeNode(\n+ this.getFilterType(childFilter), childFilter, node\n+ );\n+ return node;\n+ },\n+ \"PropertyIsLessThan\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:PropertyIsLessThan\");\n+ // no ogc:expression handling for PropertyName for now\n+ this.writeNode(\"PropertyName\", filter, node);\n+ // handle Literals or Functions for now\n+ this.writeOgcExpression(filter.value, node);\n+ return node;\n+ },\n+ \"PropertyIsGreaterThan\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:PropertyIsGreaterThan\");\n+ // no ogc:expression handling for PropertyName for now\n+ this.writeNode(\"PropertyName\", filter, node);\n+ // handle Literals or Functions for now\n+ this.writeOgcExpression(filter.value, node);\n+ return node;\n+ },\n+ \"PropertyIsLessThanOrEqualTo\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:PropertyIsLessThanOrEqualTo\");\n+ // no ogc:expression handling for PropertyName for now\n+ this.writeNode(\"PropertyName\", filter, node);\n+ // handle Literals or Functions for now\n+ this.writeOgcExpression(filter.value, node);\n+ return node;\n+ },\n+ \"PropertyIsGreaterThanOrEqualTo\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:PropertyIsGreaterThanOrEqualTo\");\n+ // no ogc:expression handling for PropertyName for now\n+ this.writeNode(\"PropertyName\", filter, node);\n+ // handle Literals or Functions for now\n+ this.writeOgcExpression(filter.value, node);\n+ return node;\n+ },\n+ \"PropertyIsBetween\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:PropertyIsBetween\");\n+ // no ogc:expression handling for PropertyName for now\n+ this.writeNode(\"PropertyName\", filter, node);\n+ this.writeNode(\"LowerBoundary\", filter, node);\n+ this.writeNode(\"UpperBoundary\", filter, node);\n+ return node;\n+ },\n+ \"PropertyName\": function(filter) {\n+ // no ogc:expression handling for now\n+ return this.createElementNSPlus(\"ogc:PropertyName\", {\n+ value: filter.property\n+ });\n+ },\n+ \"Literal\": function(value) {\n+ var encode = this.encodeLiteral ||\n+ OpenLayers.Format.Filter.v1.prototype.encodeLiteral;\n+ return this.createElementNSPlus(\"ogc:Literal\", {\n+ value: encode(value)\n+ });\n+ },\n+ \"LowerBoundary\": function(filter) {\n+ // handle Literals or Functions for now\n+ var node = this.createElementNSPlus(\"ogc:LowerBoundary\");\n+ this.writeOgcExpression(filter.lowerBoundary, node);\n+ return node;\n+ },\n+ \"UpperBoundary\": function(filter) {\n+ // handle Literals or Functions for now\n+ var node = this.createElementNSPlus(\"ogc:UpperBoundary\");\n+ this.writeNode(\"Literal\", filter.upperBoundary, node);\n+ return node;\n+ },\n+ \"INTERSECTS\": function(filter) {\n+ return this.writeSpatial(filter, \"Intersects\");\n+ },\n+ \"WITHIN\": function(filter) {\n+ return this.writeSpatial(filter, \"Within\");\n+ },\n+ \"CONTAINS\": function(filter) {\n+ return this.writeSpatial(filter, \"Contains\");\n+ },\n+ \"DWITHIN\": function(filter) {\n+ var node = this.writeSpatial(filter, \"DWithin\");\n+ this.writeNode(\"Distance\", filter, node);\n+ return node;\n+ },\n+ \"Distance\": function(filter) {\n+ return this.createElementNSPlus(\"ogc:Distance\", {\n+ attributes: {\n+ units: filter.distanceUnits\n+ },\n+ value: filter.distance\n+ });\n+ },\n+ \"Function\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:Function\", {\n+ attributes: {\n+ name: filter.name\n+ }\n+ });\n+ var params = filter.params;\n+ for (var i = 0, len = params.length; i < len; i++) {\n+ this.writeOgcExpression(params[i], node);\n+ }\n+ return node;\n+ },\n+ \"PropertyIsNull\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:PropertyIsNull\");\n+ this.writeNode(\"PropertyName\", filter, node);\n+ return node;\n+ }\n }\n- delete this.rules;\n },\n \n /**\n- * APIMethod: clone\n- * Clones this style.\n- * \n- * Returns:\n- * {} Clone of this style.\n+ * Method: getFilterType\n */\n- clone: function() {\n- var config = OpenLayers.Util.extend({}, this);\n- // clone rules\n- if (this.rules) {\n- config.rules = [];\n- for (var i = 0, len = this.rules.length; i < len; ++i) {\n- config.rules.push(this.rules[i].clone());\n- }\n+ getFilterType: function(filter) {\n+ var filterType = this.filterMap[filter.type];\n+ if (!filterType) {\n+ throw \"Filter writing not supported for rule type: \" + filter.type;\n }\n- return new OpenLayers.Style2(config);\n+ return filterType;\n },\n \n- CLASS_NAME: \"OpenLayers.Style2\"\n+ /**\n+ * Property: filterMap\n+ * {Object} Contains a member for each filter type. Values are node names\n+ * for corresponding OGC Filter child elements.\n+ */\n+ filterMap: {\n+ \"&&\": \"And\",\n+ \"||\": \"Or\",\n+ \"!\": \"Not\",\n+ \"==\": \"PropertyIsEqualTo\",\n+ \"!=\": \"PropertyIsNotEqualTo\",\n+ \"<\": \"PropertyIsLessThan\",\n+ \">\": \"PropertyIsGreaterThan\",\n+ \"<=\": \"PropertyIsLessThanOrEqualTo\",\n+ \">=\": \"PropertyIsGreaterThanOrEqualTo\",\n+ \"..\": \"PropertyIsBetween\",\n+ \"~\": \"PropertyIsLike\",\n+ \"NULL\": \"PropertyIsNull\",\n+ \"BBOX\": \"BBOX\",\n+ \"DWITHIN\": \"DWITHIN\",\n+ \"WITHIN\": \"WITHIN\",\n+ \"CONTAINS\": \"CONTAINS\",\n+ \"INTERSECTS\": \"INTERSECTS\",\n+ \"FID\": \"_featureIds\"\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Format.Filter.v1\"\n+\n });\n /* ======================================================================\n- OpenLayers/Layer/HTTPRequest.js\n+ OpenLayers/Format/GML.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/Layer.js\n+ * @requires OpenLayers/Format/XML.js\n+ * @requires OpenLayers/Feature/Vector.js\n+ * @requires OpenLayers/Geometry/Point.js\n+ * @requires OpenLayers/Geometry/MultiPoint.js\n+ * @requires OpenLayers/Geometry/LineString.js\n+ * @requires OpenLayers/Geometry/MultiLineString.js\n+ * @requires OpenLayers/Geometry/Polygon.js\n+ * @requires OpenLayers/Geometry/MultiPolygon.js\n */\n \n /**\n- * Class: OpenLayers.Layer.HTTPRequest\n+ * Class: OpenLayers.Format.GML\n+ * Read/Write GML. Create a new instance with the \n+ * constructor. Supports the GML simple features profile.\n * \n- * Inherits from: \n- * - \n+ * Inherits from:\n+ * - \n */\n-OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {\n+OpenLayers.Format.GML = OpenLayers.Class(OpenLayers.Format.XML, {\n \n- /** \n- * Constant: URL_HASH_FACTOR\n- * {Float} Used to hash URL param strings for multi-WMS server selection.\n- * Set to the Golden Ratio per Knuth's recommendation.\n+ /**\n+ * APIProperty: featureNS\n+ * {String} Namespace used for feature attributes. Default is\n+ * \"http://mapserver.gis.umn.edu/mapserver\".\n */\n- URL_HASH_FACTOR: (Math.sqrt(5) - 1) / 2,\n+ featureNS: \"http://mapserver.gis.umn.edu/mapserver\",\n \n- /** \n- * Property: url\n- * {Array(String) or String} This is either an array of url strings or \n- * a single url string. \n+ /**\n+ * APIProperty: featurePrefix\n+ * {String} Namespace alias (or prefix) for feature nodes. Default is\n+ * \"feature\".\n */\n- url: null,\n+ featurePrefix: \"feature\",\n \n- /** \n- * Property: params\n- * {Object} Hashtable of key/value parameters\n+ /**\n+ * APIProperty: featureName\n+ * {String} Element name for features. Default is \"featureMember\".\n */\n- params: null,\n+ featureName: \"featureMember\",\n \n- /** \n- * APIProperty: reproject\n- * *Deprecated*. See http://docs.openlayers.org/library/spherical_mercator.html\n- * for information on the replacement for this functionality. \n- * {Boolean} Whether layer should reproject itself based on base layer \n- * locations. This allows reprojection onto commercial layers. \n- * Default is false: Most layers can't reproject, but layers \n- * which can create non-square geographic pixels can, like WMS.\n- * \n+ /**\n+ * APIProperty: layerName\n+ * {String} Name of data layer. Default is \"features\".\n */\n- reproject: false,\n+ layerName: \"features\",\n \n /**\n- * Constructor: OpenLayers.Layer.HTTPRequest\n- * \n- * Parameters:\n- * name - {String}\n- * url - {Array(String) or String}\n- * params - {Object}\n- * options - {Object} Hashtable of extra options to tag onto the layer\n+ * APIProperty: geometryName\n+ * {String} Name of geometry element. Defaults to \"geometry\".\n */\n- initialize: function(name, url, params, options) {\n- OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);\n- this.url = url;\n- if (!this.params) {\n- this.params = OpenLayers.Util.extend({}, params);\n- }\n- },\n+ geometryName: \"geometry\",\n \n- /**\n- * APIMethod: destroy\n+ /** \n+ * APIProperty: collectionName\n+ * {String} Name of featureCollection element.\n */\n- destroy: function() {\n- this.url = null;\n- this.params = null;\n- OpenLayers.Layer.prototype.destroy.apply(this, arguments);\n- },\n+ collectionName: \"FeatureCollection\",\n \n /**\n- * APIMethod: clone\n- * \n- * Parameters:\n- * obj - {Object}\n- * \n- * Returns:\n- * {} An exact clone of this \n- * \n+ * APIProperty: gmlns\n+ * {String} GML Namespace.\n */\n- clone: function(obj) {\n-\n- if (obj == null) {\n- obj = new OpenLayers.Layer.HTTPRequest(this.name,\n- this.url,\n- this.params,\n- this.getOptions());\n- }\n-\n- //get all additions from superclasses\n- obj = OpenLayers.Layer.prototype.clone.apply(this, [obj]);\n-\n- // copy/set any non-init, non-simple values here\n-\n- return obj;\n- },\n+ gmlns: \"http://www.opengis.net/gml\",\n \n- /** \n- * APIMethod: setUrl\n- * \n- * Parameters:\n- * newUrl - {String}\n+ /**\n+ * APIProperty: extractAttributes\n+ * {Boolean} Extract attributes from GML.\n */\n- setUrl: function(newUrl) {\n- this.url = newUrl;\n- },\n+ extractAttributes: true,\n \n /**\n- * APIMethod: mergeNewParams\n- * \n- * Parameters:\n- * newParams - {Object}\n- *\n- * Returns:\n- * redrawn: {Boolean} whether the layer was actually redrawn.\n+ * APIProperty: xy\n+ * {Boolean} Order of the GML coordinate true:(x,y) or false:(y,x)\n+ * Changing is not recommended, a new Format should be instantiated.\n */\n- mergeNewParams: function(newParams) {\n- this.params = OpenLayers.Util.extend(this.params, newParams);\n- var ret = this.redraw();\n- if (this.map != null) {\n- this.map.events.triggerEvent(\"changelayer\", {\n- layer: this,\n- property: \"params\"\n- });\n- }\n- return ret;\n- },\n+ xy: true,\n \n /**\n- * APIMethod: redraw\n- * Redraws the layer. Returns true if the layer was redrawn, false if not.\n+ * Constructor: OpenLayers.Format.GML\n+ * Create a new parser for GML.\n *\n * Parameters:\n- * force - {Boolean} Force redraw by adding random parameter.\n- *\n- * Returns:\n- * {Boolean} The layer was redrawn.\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n */\n- redraw: function(force) {\n- if (force) {\n- return this.mergeNewParams({\n- \"_olSalt\": Math.random()\n- });\n- } else {\n- return OpenLayers.Layer.prototype.redraw.apply(this, []);\n- }\n+ initialize: function(options) {\n+ // compile regular expressions once instead of every time they are used\n+ this.regExes = {\n+ trimSpace: (/^\\s*|\\s*$/g),\n+ removeSpace: (/\\s*/g),\n+ splitSpace: (/\\s+/),\n+ trimComma: (/\\s*,\\s*/g)\n+ };\n+ OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);\n },\n \n /**\n- * Method: selectUrl\n- * selectUrl() implements the standard floating-point multiplicative\n- * hash function described by Knuth, and hashes the contents of the \n- * given param string into a float between 0 and 1. This float is then\n- * scaled to the size of the provided urls array, and used to select\n- * a URL.\n- *\n- * Parameters:\n- * paramString - {String}\n- * urls - {Array(String)}\n+ * APIMethod: read\n+ * Read data from a string, and return a list of features. \n * \n+ * Parameters:\n+ * data - {String} or {DOMElement} data to read/parse.\n+ *\n * Returns:\n- * {String} An entry from the urls array, deterministically selected based\n- * on the paramString.\n+ * {Array()} An array of features.\n */\n- selectUrl: function(paramString, urls) {\n- var product = 1;\n- for (var i = 0, len = paramString.length; i < len; i++) {\n- product *= paramString.charCodeAt(i) * this.URL_HASH_FACTOR;\n- product -= Math.floor(product);\n+ read: function(data) {\n+ if (typeof data == \"string\") {\n+ data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n }\n- return urls[Math.floor(product * urls.length)];\n+ var featureNodes = this.getElementsByTagNameNS(data.documentElement,\n+ this.gmlns,\n+ this.featureName);\n+ var features = [];\n+ for (var i = 0; i < featureNodes.length; i++) {\n+ var feature = this.parseFeature(featureNodes[i]);\n+ if (feature) {\n+ features.push(feature);\n+ }\n+ }\n+ return features;\n },\n \n- /** \n- * Method: getFullRequestString\n- * Combine url with layer's params and these newParams. \n- * \n- * does checking on the serverPath variable, allowing for cases when it \n- * is supplied with trailing ? or &, as well as cases where not. \n- *\n- * return in formatted string like this:\n- * \"server?key1=value1&key2=value2&key3=value3\"\n- * \n- * WARNING: The altUrl parameter is deprecated and will be removed in 3.0.\n- *\n+ /**\n+ * Method: parseFeature\n+ * This function is the core of the GML parsing code in OpenLayers.\n+ * It creates the geometries that are then attached to the returned\n+ * feature, and calls parseAttributes() to get attribute data out.\n+ * \n * Parameters:\n- * newParams - {Object}\n- * altUrl - {String} Use this as the url instead of the layer's url\n- * \n- * Returns: \n- * {String}\n+ * node - {DOMElement} A GML feature node. \n */\n- getFullRequestString: function(newParams, altUrl) {\n-\n- // if not altUrl passed in, use layer's url\n- var url = altUrl || this.url;\n-\n- // create a new params hashtable with all the layer params and the \n- // new params together. then convert to string\n- var allParams = OpenLayers.Util.extend({}, this.params);\n- allParams = OpenLayers.Util.extend(allParams, newParams);\n- var paramsString = OpenLayers.Util.getParameterString(allParams);\n-\n- // if url is not a string, it should be an array of strings, \n- // in which case we will deterministically select one of them in \n- // order to evenly distribute requests to different urls.\n- //\n- if (OpenLayers.Util.isArray(url)) {\n- url = this.selectUrl(paramsString, url);\n+ parseFeature: function(node) {\n+ // only accept one geometry per feature - look for highest \"order\"\n+ var order = [\"MultiPolygon\", \"Polygon\",\n+ \"MultiLineString\", \"LineString\",\n+ \"MultiPoint\", \"Point\", \"Envelope\"\n+ ];\n+ // FIXME: In case we parse a feature with no geometry, but boundedBy an Envelope,\n+ // this code creates a geometry derived from the Envelope. This is not correct.\n+ var type, nodeList, geometry, parser;\n+ for (var i = 0; i < order.length; ++i) {\n+ type = order[i];\n+ nodeList = this.getElementsByTagNameNS(node, this.gmlns, type);\n+ if (nodeList.length > 0) {\n+ // only deal with first geometry of this type\n+ parser = this.parseGeometry[type.toLowerCase()];\n+ if (parser) {\n+ geometry = parser.apply(this, [nodeList[0]]);\n+ if (this.internalProjection && this.externalProjection) {\n+ geometry.transform(this.externalProjection,\n+ this.internalProjection);\n+ }\n+ } else {\n+ throw new TypeError(\"Unsupported geometry type: \" + type);\n+ }\n+ // stop looking for different geometry types\n+ break;\n+ }\n }\n \n- // ignore parameters that are already in the url search string\n- var urlParams =\n- OpenLayers.Util.upperCaseObject(OpenLayers.Util.getParameters(url));\n- for (var key in allParams) {\n- if (key.toUpperCase() in urlParams) {\n- delete allParams[key];\n+ var bounds;\n+ var boxNodes = this.getElementsByTagNameNS(node, this.gmlns, \"Box\");\n+ for (i = 0; i < boxNodes.length; ++i) {\n+ var boxNode = boxNodes[i];\n+ var box = this.parseGeometry[\"box\"].apply(this, [boxNode]);\n+ var parentNode = boxNode.parentNode;\n+ var parentName = parentNode.localName ||\n+ parentNode.nodeName.split(\":\").pop();\n+ if (parentName === \"boundedBy\") {\n+ bounds = box;\n+ } else {\n+ geometry = box.toGeometry();\n }\n }\n- paramsString = OpenLayers.Util.getParameterString(allParams);\n-\n- return OpenLayers.Util.urlAppend(url, paramsString);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Layer.HTTPRequest\"\n-});\n-/* ======================================================================\n- OpenLayers/Tile/Image.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n \n+ // construct feature (optionally with attributes)\n+ var attributes;\n+ if (this.extractAttributes) {\n+ attributes = this.parseAttributes(node);\n+ }\n+ var feature = new OpenLayers.Feature.Vector(geometry, attributes);\n+ feature.bounds = bounds;\n \n-/**\n- * @requires OpenLayers/Tile.js\n- * @requires OpenLayers/Animation.js\n- * @requires OpenLayers/Util.js\n- */\n+ feature.gml = {\n+ featureType: node.firstChild.nodeName.split(\":\")[1],\n+ featureNS: node.firstChild.namespaceURI,\n+ featureNSPrefix: node.firstChild.prefix\n+ };\n \n-/**\n- * Class: OpenLayers.Tile.Image\n- * Instances of OpenLayers.Tile.Image are used to manage the image tiles\n- * used by various layers. Create a new image tile with the\n- * constructor.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {\n+ // assign fid - this can come from a \"fid\" or \"id\" attribute\n+ var childNode = node.firstChild;\n+ var fid;\n+ while (childNode) {\n+ if (childNode.nodeType == 1) {\n+ fid = childNode.getAttribute(\"fid\") ||\n+ childNode.getAttribute(\"id\");\n+ if (fid) {\n+ break;\n+ }\n+ }\n+ childNode = childNode.nextSibling;\n+ }\n+ feature.fid = fid;\n+ return feature;\n+ },\n \n /**\n- * APIProperty: events\n- * {} An events object that handles all \n- * events on the tile.\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * tile.events.register(type, obj, listener);\n- * (end)\n- *\n- * Supported event types (in addition to the events):\n- * beforeload - Triggered before an image is prepared for loading, when the\n- * url for the image is known already. Listeners may call on\n- * the tile instance. If they do so, that image will be used and no new\n- * one will be created.\n+ * Property: parseGeometry\n+ * Properties of this object are the functions that parse geometries based\n+ * on their type.\n */\n+ parseGeometry: {\n \n- /** \n- * APIProperty: url\n- * {String} The URL of the image being requested. No default. Filled in by\n- * layer.getURL() function. May be modified by loadstart listeners.\n- */\n- url: null,\n+ /**\n+ * Method: parseGeometry.point\n+ * Given a GML node representing a point geometry, create an OpenLayers\n+ * point geometry.\n+ *\n+ * Parameters:\n+ * node - {DOMElement} A GML node.\n+ *\n+ * Returns:\n+ * {} A point geometry.\n+ */\n+ point: function(node) {\n+ /**\n+ * Three coordinate variations to consider:\n+ * 1) x y z\n+ * 2) x, y, z\n+ * 3) xy\n+ */\n+ var nodeList, coordString;\n+ var coords = [];\n \n- /** \n- * Property: imgDiv\n- * {HTMLImageElement} The image for this tile.\n- */\n- imgDiv: null,\n+ // look for \n+ var nodeList = this.getElementsByTagNameNS(node, this.gmlns, \"pos\");\n+ if (nodeList.length > 0) {\n+ coordString = nodeList[0].firstChild.nodeValue;\n+ coordString = coordString.replace(this.regExes.trimSpace, \"\");\n+ coords = coordString.split(this.regExes.splitSpace);\n+ }\n \n- /**\n- * Property: frame\n- * {DOMElement} The image element is appended to the frame. Any gutter on\n- * the image will be hidden behind the frame. If no gutter is set,\n- * this will be null.\n- */\n- frame: null,\n+ // look for \n+ if (coords.length == 0) {\n+ nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n+ \"coordinates\");\n+ if (nodeList.length > 0) {\n+ coordString = nodeList[0].firstChild.nodeValue;\n+ coordString = coordString.replace(this.regExes.removeSpace,\n+ \"\");\n+ coords = coordString.split(\",\");\n+ }\n+ }\n \n- /** \n- * Property: imageReloadAttempts\n- * {Integer} Attempts to load the image.\n- */\n- imageReloadAttempts: null,\n+ // look for \n+ if (coords.length == 0) {\n+ nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n+ \"coord\");\n+ if (nodeList.length > 0) {\n+ var xList = this.getElementsByTagNameNS(nodeList[0],\n+ this.gmlns, \"X\");\n+ var yList = this.getElementsByTagNameNS(nodeList[0],\n+ this.gmlns, \"Y\");\n+ if (xList.length > 0 && yList.length > 0) {\n+ coords = [xList[0].firstChild.nodeValue,\n+ yList[0].firstChild.nodeValue\n+ ];\n+ }\n+ }\n+ }\n \n- /**\n- * Property: layerAlphaHack\n- * {Boolean} True if the png alpha hack needs to be applied on the layer's div.\n- */\n- layerAlphaHack: null,\n+ // preserve third dimension\n+ if (coords.length == 2) {\n+ coords[2] = null;\n+ }\n \n- /**\n- * Property: asyncRequestId\n- * {Integer} ID of an request to see if request is still valid. This is a\n- * number which increments by 1 for each asynchronous request.\n- */\n- asyncRequestId: null,\n+ if (this.xy) {\n+ return new OpenLayers.Geometry.Point(coords[0], coords[1],\n+ coords[2]);\n+ } else {\n+ return new OpenLayers.Geometry.Point(coords[1], coords[0],\n+ coords[2]);\n+ }\n+ },\n \n- /**\n- * APIProperty: maxGetUrlLength\n- * {Number} If set, requests that would result in GET urls with more\n- * characters than the number provided will be made using form-encoded\n- * HTTP POST. It is good practice to avoid urls that are longer than 2048\n- * characters.\n- *\n- * Caution:\n- * Older versions of Gecko based browsers (e.g. Firefox < 3.5) and most\n- * Opera versions do not fully support this option. On all browsers,\n- * transition effects are not supported if POST requests are used.\n- */\n- maxGetUrlLength: null,\n+ /**\n+ * Method: parseGeometry.multipoint\n+ * Given a GML node representing a multipoint geometry, create an\n+ * OpenLayers multipoint geometry.\n+ *\n+ * Parameters:\n+ * node - {DOMElement} A GML node.\n+ *\n+ * Returns:\n+ * {} A multipoint geometry.\n+ */\n+ multipoint: function(node) {\n+ var nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n+ \"Point\");\n+ var components = [];\n+ if (nodeList.length > 0) {\n+ var point;\n+ for (var i = 0; i < nodeList.length; ++i) {\n+ point = this.parseGeometry.point.apply(this, [nodeList[i]]);\n+ if (point) {\n+ components.push(point);\n+ }\n+ }\n+ }\n+ return new OpenLayers.Geometry.MultiPoint(components);\n+ },\n \n- /**\n- * Property: canvasContext\n- * {CanvasRenderingContext2D} A canvas context associated with\n- * the tile image.\n- */\n- canvasContext: null,\n+ /**\n+ * Method: parseGeometry.linestring\n+ * Given a GML node representing a linestring geometry, create an\n+ * OpenLayers linestring geometry.\n+ *\n+ * Parameters:\n+ * node - {DOMElement} A GML node.\n+ *\n+ * Returns:\n+ * {} A linestring geometry.\n+ */\n+ linestring: function(node, ring) {\n+ /**\n+ * Two coordinate variations to consider:\n+ * 1) x0 y0 z0 x1 y1 z1\n+ * 2) x0, y0, z0 x1, y1, z1\n+ */\n+ var nodeList, coordString;\n+ var coords = [];\n+ var points = [];\n \n- /**\n- * APIProperty: crossOriginKeyword\n- * The value of the crossorigin keyword to use when loading images. This is\n- * only relevant when using for tiles from remote\n- * origins and should be set to either 'anonymous' or 'use-credentials'\n- * for servers that send Access-Control-Allow-Origin headers with their\n- * tiles.\n- */\n- crossOriginKeyword: null,\n+ // look for \n+ nodeList = this.getElementsByTagNameNS(node, this.gmlns, \"posList\");\n+ if (nodeList.length > 0) {\n+ coordString = this.getChildValue(nodeList[0]);\n+ coordString = coordString.replace(this.regExes.trimSpace, \"\");\n+ coords = coordString.split(this.regExes.splitSpace);\n+ var dim = parseInt(nodeList[0].getAttribute(\"dimension\"));\n+ var j, x, y, z;\n+ for (var i = 0; i < coords.length / dim; ++i) {\n+ j = i * dim;\n+ x = coords[j];\n+ y = coords[j + 1];\n+ z = (dim == 2) ? null : coords[j + 2];\n+ if (this.xy) {\n+ points.push(new OpenLayers.Geometry.Point(x, y, z));\n+ } else {\n+ points.push(new OpenLayers.Geometry.Point(y, x, z));\n+ }\n+ }\n+ }\n \n- /** TBD 3.0 - reorder the parameters to the init function to remove \n- * URL. the getUrl() function on the layer gets called on \n- * each draw(), so no need to specify it here.\n- */\n+ // look for \n+ if (coords.length == 0) {\n+ nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n+ \"coordinates\");\n+ if (nodeList.length > 0) {\n+ coordString = this.getChildValue(nodeList[0]);\n+ coordString = coordString.replace(this.regExes.trimSpace,\n+ \"\");\n+ coordString = coordString.replace(this.regExes.trimComma,\n+ \",\");\n+ var pointList = coordString.split(this.regExes.splitSpace);\n+ for (var i = 0; i < pointList.length; ++i) {\n+ coords = pointList[i].split(\",\");\n+ if (coords.length == 2) {\n+ coords[2] = null;\n+ }\n+ if (this.xy) {\n+ points.push(new OpenLayers.Geometry.Point(coords[0],\n+ coords[1],\n+ coords[2]));\n+ } else {\n+ points.push(new OpenLayers.Geometry.Point(coords[1],\n+ coords[0],\n+ coords[2]));\n+ }\n+ }\n+ }\n+ }\n \n- /** \n- * Constructor: OpenLayers.Tile.Image\n- * Constructor for a new instance.\n- * \n- * Parameters:\n- * layer - {} layer that the tile will go in.\n- * position - {}\n- * bounds - {}\n- * url - {} Deprecated. Remove me in 3.0.\n- * size - {}\n- * options - {Object}\n- */\n- initialize: function(layer, position, bounds, url, size, options) {\n- OpenLayers.Tile.prototype.initialize.apply(this, arguments);\n+ var line = null;\n+ if (points.length != 0) {\n+ if (ring) {\n+ line = new OpenLayers.Geometry.LinearRing(points);\n+ } else {\n+ line = new OpenLayers.Geometry.LineString(points);\n+ }\n+ }\n+ return line;\n+ },\n \n- this.url = url; //deprecated remove me\n+ /**\n+ * Method: parseGeometry.multilinestring\n+ * Given a GML node representing a multilinestring geometry, create an\n+ * OpenLayers multilinestring geometry.\n+ *\n+ * Parameters:\n+ * node - {DOMElement} A GML node.\n+ *\n+ * Returns:\n+ * {} A multilinestring geometry.\n+ */\n+ multilinestring: function(node) {\n+ var nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n+ \"LineString\");\n+ var components = [];\n+ if (nodeList.length > 0) {\n+ var line;\n+ for (var i = 0; i < nodeList.length; ++i) {\n+ line = this.parseGeometry.linestring.apply(this,\n+ [nodeList[i]]);\n+ if (line) {\n+ components.push(line);\n+ }\n+ }\n+ }\n+ return new OpenLayers.Geometry.MultiLineString(components);\n+ },\n \n- this.layerAlphaHack = this.layer.alpha && OpenLayers.Util.alphaHack();\n+ /**\n+ * Method: parseGeometry.polygon\n+ * Given a GML node representing a polygon geometry, create an\n+ * OpenLayers polygon geometry.\n+ *\n+ * Parameters:\n+ * node - {DOMElement} A GML node.\n+ *\n+ * Returns:\n+ * {} A polygon geometry.\n+ */\n+ polygon: function(node) {\n+ var nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n+ \"LinearRing\");\n+ var components = [];\n+ if (nodeList.length > 0) {\n+ // this assumes exterior ring first, inner rings after\n+ var ring;\n+ for (var i = 0; i < nodeList.length; ++i) {\n+ ring = this.parseGeometry.linestring.apply(this,\n+ [nodeList[i], true]);\n+ if (ring) {\n+ components.push(ring);\n+ }\n+ }\n+ }\n+ return new OpenLayers.Geometry.Polygon(components);\n+ },\n \n- if (this.maxGetUrlLength != null || this.layer.gutter || this.layerAlphaHack) {\n- // only create frame if it's needed\n- this.frame = document.createElement(\"div\");\n- this.frame.style.position = \"absolute\";\n- this.frame.style.overflow = \"hidden\";\n- }\n- if (this.maxGetUrlLength != null) {\n- OpenLayers.Util.extend(this, OpenLayers.Tile.Image.IFrame);\n- }\n- },\n+ /**\n+ * Method: parseGeometry.multipolygon\n+ * Given a GML node representing a multipolygon geometry, create an\n+ * OpenLayers multipolygon geometry.\n+ *\n+ * Parameters:\n+ * node - {DOMElement} A GML node.\n+ *\n+ * Returns:\n+ * {} A multipolygon geometry.\n+ */\n+ multipolygon: function(node) {\n+ var nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n+ \"Polygon\");\n+ var components = [];\n+ if (nodeList.length > 0) {\n+ var polygon;\n+ for (var i = 0; i < nodeList.length; ++i) {\n+ polygon = this.parseGeometry.polygon.apply(this,\n+ [nodeList[i]]);\n+ if (polygon) {\n+ components.push(polygon);\n+ }\n+ }\n+ }\n+ return new OpenLayers.Geometry.MultiPolygon(components);\n+ },\n \n- /** \n- * APIMethod: destroy\n- * nullify references to prevent circular references and memory leaks\n- */\n- destroy: function() {\n- if (this.imgDiv) {\n- this.clear();\n- this.imgDiv = null;\n- this.frame = null;\n- }\n- // don't handle async requests any more\n- this.asyncRequestId = null;\n- OpenLayers.Tile.prototype.destroy.apply(this, arguments);\n- },\n+ envelope: function(node) {\n+ var components = [];\n+ var coordString;\n+ var envelope;\n \n- /**\n- * Method: draw\n- * Check that a tile should be drawn, and draw it.\n- * \n- * Returns:\n- * {Boolean} Was a tile drawn? Or null if a beforedraw listener returned\n- * false.\n- */\n- draw: function() {\n- var shouldDraw = OpenLayers.Tile.prototype.draw.apply(this, arguments);\n- if (shouldDraw) {\n- // The layer's reproject option is deprecated.\n- if (this.layer != this.layer.map.baseLayer && this.layer.reproject) {\n- // getBoundsFromBaseLayer is defined in deprecated.js.\n- this.bounds = this.getBoundsFromBaseLayer(this.position);\n- }\n- if (this.isLoading) {\n- //if we're already loading, send 'reload' instead of 'loadstart'.\n- this._loadEvent = \"reload\";\n- } else {\n- this.isLoading = true;\n- this._loadEvent = \"loadstart\";\n- }\n- this.renderTile();\n- this.positionTile();\n- } else if (shouldDraw === false) {\n- this.unload();\n- }\n- return shouldDraw;\n- },\n+ var lpoint = this.getElementsByTagNameNS(node, this.gmlns, \"lowerCorner\");\n+ if (lpoint.length > 0) {\n+ var coords = [];\n \n- /**\n- * Method: renderTile\n- * Internal function to actually initialize the image tile,\n- * position it correctly, and set its url.\n- */\n- renderTile: function() {\n- if (this.layer.async) {\n- // Asynchronous image requests call the asynchronous getURL method\n- // on the layer to fetch an image that covers 'this.bounds'.\n- var id = this.asyncRequestId = (this.asyncRequestId || 0) + 1;\n- this.layer.getURLasync(this.bounds, function(url) {\n- if (id == this.asyncRequestId) {\n- this.url = url;\n- this.initImage();\n+ if (lpoint.length > 0) {\n+ coordString = lpoint[0].firstChild.nodeValue;\n+ coordString = coordString.replace(this.regExes.trimSpace, \"\");\n+ coords = coordString.split(this.regExes.splitSpace);\n }\n- }, this);\n- } else {\n- // synchronous image requests get the url immediately.\n- this.url = this.layer.getURL(this.bounds);\n- this.initImage();\n- }\n- },\n-\n- /**\n- * Method: positionTile\n- * Using the properties currenty set on the layer, position the tile correctly.\n- * This method is used both by the async and non-async versions of the Tile.Image\n- * code.\n- */\n- positionTile: function() {\n- var style = this.getTile().style,\n- size = this.frame ? this.size :\n- this.layer.getImageSize(this.bounds),\n- ratio = 1;\n- if (this.layer instanceof OpenLayers.Layer.Grid) {\n- ratio = this.layer.getServerResolution() / this.layer.map.getResolution();\n- }\n- style.left = this.position.x + \"px\";\n- style.top = this.position.y + \"px\";\n- style.width = Math.round(ratio * size.w) + \"px\";\n- style.height = Math.round(ratio * size.h) + \"px\";\n- },\n \n- /** \n- * Method: clear\n- * Remove the tile from the DOM, clear it of any image related data so that\n- * it can be reused in a new location.\n- */\n- clear: function() {\n- OpenLayers.Tile.prototype.clear.apply(this, arguments);\n- var img = this.imgDiv;\n- if (img) {\n- var tile = this.getTile();\n- if (tile.parentNode === this.layer.div) {\n- this.layer.div.removeChild(tile);\n- }\n- this.setImgSrc();\n- if (this.layerAlphaHack === true) {\n- img.style.filter = \"\";\n+ if (coords.length == 2) {\n+ coords[2] = null;\n+ }\n+ if (this.xy) {\n+ var lowerPoint = new OpenLayers.Geometry.Point(coords[0], coords[1], coords[2]);\n+ } else {\n+ var lowerPoint = new OpenLayers.Geometry.Point(coords[1], coords[0], coords[2]);\n+ }\n }\n- OpenLayers.Element.removeClass(img, \"olImageLoadError\");\n- }\n- this.canvasContext = null;\n- },\n \n- /**\n- * Method: getImage\n- * Returns or creates and returns the tile image.\n- */\n- getImage: function() {\n- if (!this.imgDiv) {\n- this.imgDiv = OpenLayers.Tile.Image.IMAGE.cloneNode(false);\n+ var upoint = this.getElementsByTagNameNS(node, this.gmlns, \"upperCorner\");\n+ if (upoint.length > 0) {\n+ var coords = [];\n \n- var style = this.imgDiv.style;\n- if (this.frame) {\n- var left = 0,\n- top = 0;\n- if (this.layer.gutter) {\n- left = this.layer.gutter / this.layer.tileSize.w * 100;\n- top = this.layer.gutter / this.layer.tileSize.h * 100;\n+ if (upoint.length > 0) {\n+ coordString = upoint[0].firstChild.nodeValue;\n+ coordString = coordString.replace(this.regExes.trimSpace, \"\");\n+ coords = coordString.split(this.regExes.splitSpace);\n+ }\n+\n+ if (coords.length == 2) {\n+ coords[2] = null;\n+ }\n+ if (this.xy) {\n+ var upperPoint = new OpenLayers.Geometry.Point(coords[0], coords[1], coords[2]);\n+ } else {\n+ var upperPoint = new OpenLayers.Geometry.Point(coords[1], coords[0], coords[2]);\n }\n- style.left = -left + \"%\";\n- style.top = -top + \"%\";\n- style.width = (2 * left + 100) + \"%\";\n- style.height = (2 * top + 100) + \"%\";\n- }\n- style.visibility = \"hidden\";\n- style.opacity = 0;\n- if (this.layer.opacity < 1) {\n- style.filter = 'alpha(opacity=' +\n- (this.layer.opacity * 100) +\n- ')';\n- }\n- style.position = \"absolute\";\n- if (this.layerAlphaHack) {\n- // move the image out of sight\n- style.paddingTop = style.height;\n- style.height = \"0\";\n- style.width = \"100%\";\n- }\n- if (this.frame) {\n- this.frame.appendChild(this.imgDiv);\n }\n- }\n \n- return this.imgDiv;\n- },\n+ if (lowerPoint && upperPoint) {\n+ components.push(new OpenLayers.Geometry.Point(lowerPoint.x, lowerPoint.y));\n+ components.push(new OpenLayers.Geometry.Point(upperPoint.x, lowerPoint.y));\n+ components.push(new OpenLayers.Geometry.Point(upperPoint.x, upperPoint.y));\n+ components.push(new OpenLayers.Geometry.Point(lowerPoint.x, upperPoint.y));\n+ components.push(new OpenLayers.Geometry.Point(lowerPoint.x, lowerPoint.y));\n \n- /**\n- * APIMethod: setImage\n- * Sets the image element for this tile. This method should only be called\n- * from beforeload listeners.\n- *\n- * Parameters\n- * img - {HTMLImageElement} The image to use for this tile.\n- */\n- setImage: function(img) {\n- this.imgDiv = img;\n- },\n+ var ring = new OpenLayers.Geometry.LinearRing(components);\n+ envelope = new OpenLayers.Geometry.Polygon([ring]);\n+ }\n+ return envelope;\n+ },\n \n- /**\n- * Method: initImage\n- * Creates the content for the frame on the tile.\n- */\n- initImage: function() {\n- if (!this.url && !this.imgDiv) {\n- // fast path out - if there is no tile url and no previous image\n- this.isLoading = false;\n- return;\n- }\n- this.events.triggerEvent('beforeload');\n- this.layer.div.appendChild(this.getTile());\n- this.events.triggerEvent(this._loadEvent);\n- var img = this.getImage();\n- var src = img.getAttribute('src') || '';\n- if (this.url && OpenLayers.Util.isEquivalentUrl(src, this.url)) {\n- this._loadTimeout = window.setTimeout(\n- OpenLayers.Function.bind(this.onImageLoad, this), 0\n- );\n- } else {\n- this.stopLoading();\n- if (this.crossOriginKeyword) {\n- img.removeAttribute(\"crossorigin\");\n+ /**\n+ * Method: parseGeometry.box\n+ * Given a GML node representing a box geometry, create an\n+ * OpenLayers.Bounds.\n+ *\n+ * Parameters:\n+ * node - {DOMElement} A GML node.\n+ *\n+ * Returns:\n+ * {} A bounds representing the box.\n+ */\n+ box: function(node) {\n+ var nodeList = this.getElementsByTagNameNS(node, this.gmlns,\n+ \"coordinates\");\n+ var coordString;\n+ var coords, beginPoint = null,\n+ endPoint = null;\n+ if (nodeList.length > 0) {\n+ coordString = nodeList[0].firstChild.nodeValue;\n+ coords = coordString.split(\" \");\n+ if (coords.length == 2) {\n+ beginPoint = coords[0].split(\",\");\n+ endPoint = coords[1].split(\",\");\n+ }\n+ }\n+ if (beginPoint !== null && endPoint !== null) {\n+ return new OpenLayers.Bounds(parseFloat(beginPoint[0]),\n+ parseFloat(beginPoint[1]),\n+ parseFloat(endPoint[0]),\n+ parseFloat(endPoint[1]));\n }\n- OpenLayers.Event.observe(img, \"load\",\n- OpenLayers.Function.bind(this.onImageLoad, this)\n- );\n- OpenLayers.Event.observe(img, \"error\",\n- OpenLayers.Function.bind(this.onImageError, this)\n- );\n- this.imageReloadAttempts = 0;\n- this.setImgSrc(this.url);\n }\n+\n },\n \n /**\n- * Method: setImgSrc\n- * Sets the source for the tile image\n+ * Method: parseAttributes\n *\n * Parameters:\n- * url - {String} or undefined to hide the image\n+ * node - {DOMElement}\n+ *\n+ * Returns:\n+ * {Object} An attributes object.\n */\n- setImgSrc: function(url) {\n- var img = this.imgDiv;\n- if (url) {\n- img.style.visibility = 'hidden';\n- img.style.opacity = 0;\n- // don't set crossOrigin if the url is a data URL\n- if (this.crossOriginKeyword) {\n- if (url.substr(0, 5) !== 'data:') {\n- img.setAttribute(\"crossorigin\", this.crossOriginKeyword);\n- } else {\n- img.removeAttribute(\"crossorigin\");\n+ parseAttributes: function(node) {\n+ var attributes = {};\n+ // assume attributes are children of the first type 1 child\n+ var childNode = node.firstChild;\n+ var children, i, child, grandchildren, grandchild, name, value;\n+ while (childNode) {\n+ if (childNode.nodeType == 1) {\n+ // attributes are type 1 children with one type 3 child\n+ children = childNode.childNodes;\n+ for (i = 0; i < children.length; ++i) {\n+ child = children[i];\n+ if (child.nodeType == 1) {\n+ grandchildren = child.childNodes;\n+ if (grandchildren.length == 1) {\n+ grandchild = grandchildren[0];\n+ if (grandchild.nodeType == 3 ||\n+ grandchild.nodeType == 4) {\n+ name = (child.prefix) ?\n+ child.nodeName.split(\":\")[1] :\n+ child.nodeName;\n+ value = grandchild.nodeValue.replace(\n+ this.regExes.trimSpace, \"\");\n+ attributes[name] = value;\n+ }\n+ } else {\n+ // If child has no childNodes (grandchildren),\n+ // set an attribute with null value.\n+ // e.g. becomes\n+ // {fieldname: null}\n+ attributes[child.nodeName.split(\":\").pop()] = null;\n+ }\n+ }\n }\n+ break;\n }\n- img.src = url;\n- } else {\n- // Remove reference to the image, and leave it to the browser's\n- // caching and garbage collection.\n- this.stopLoading();\n- this.imgDiv = null;\n- if (img.parentNode) {\n- img.parentNode.removeChild(img);\n- }\n+ childNode = childNode.nextSibling;\n }\n+ return attributes;\n },\n \n /**\n- * Method: getTile\n- * Get the tile's markup.\n+ * APIMethod: write\n+ * Generate a GML document string given a list of features. \n+ * \n+ * Parameters:\n+ * features - {Array()} List of features to\n+ * serialize into a string.\n *\n * Returns:\n- * {DOMElement} The tile's markup\n+ * {String} A string representing the GML document.\n */\n- getTile: function() {\n- return this.frame ? this.frame : this.getImage();\n+ write: function(features) {\n+ if (!(OpenLayers.Util.isArray(features))) {\n+ features = [features];\n+ }\n+ var gml = this.createElementNS(\"http://www.opengis.net/wfs\",\n+ \"wfs:\" + this.collectionName);\n+ for (var i = 0; i < features.length; i++) {\n+ gml.appendChild(this.createFeatureXML(features[i]));\n+ }\n+ return OpenLayers.Format.XML.prototype.write.apply(this, [gml]);\n },\n \n- /**\n- * Method: createBackBuffer\n- * Create a backbuffer for this tile. A backbuffer isn't exactly a clone\n- * of the tile's markup, because we want to avoid the reloading of the\n- * image. So we clone the frame, and steal the image from the tile.\n+ /** \n+ * Method: createFeatureXML\n+ * Accept an OpenLayers.Feature.Vector, and build a GML node for it.\n+ *\n+ * Parameters:\n+ * feature - {} The feature to be built as GML.\n *\n * Returns:\n- * {DOMElement} The markup, or undefined if the tile has no image\n- * or if it's currently loading.\n+ * {DOMElement} A node reprensting the feature in GML.\n */\n- createBackBuffer: function() {\n- if (!this.imgDiv || this.isLoading) {\n- return;\n- }\n- var backBuffer;\n- if (this.frame) {\n- backBuffer = this.frame.cloneNode(false);\n- backBuffer.appendChild(this.imgDiv);\n- } else {\n- backBuffer = this.imgDiv;\n+ createFeatureXML: function(feature) {\n+ var geometry = feature.geometry;\n+ var geometryNode = this.buildGeometryNode(geometry);\n+ var geomContainer = this.createElementNS(this.featureNS,\n+ this.featurePrefix + \":\" +\n+ this.geometryName);\n+ geomContainer.appendChild(geometryNode);\n+ var featureNode = this.createElementNS(this.gmlns,\n+ \"gml:\" + this.featureName);\n+ var featureContainer = this.createElementNS(this.featureNS,\n+ this.featurePrefix + \":\" +\n+ this.layerName);\n+ var fid = feature.fid || feature.id;\n+ featureContainer.setAttribute(\"fid\", fid);\n+ featureContainer.appendChild(geomContainer);\n+ for (var attr in feature.attributes) {\n+ var attrText = this.createTextNode(feature.attributes[attr]);\n+ var nodename = attr.substring(attr.lastIndexOf(\":\") + 1);\n+ var attrContainer = this.createElementNS(this.featureNS,\n+ this.featurePrefix + \":\" +\n+ nodename);\n+ attrContainer.appendChild(attrText);\n+ featureContainer.appendChild(attrContainer);\n }\n- this.imgDiv = null;\n- return backBuffer;\n+ featureNode.appendChild(featureContainer);\n+ return featureNode;\n },\n \n /**\n- * Method: onImageLoad\n- * Handler for the image onload event\n+ * APIMethod: buildGeometryNode\n */\n- onImageLoad: function() {\n- var img = this.imgDiv;\n- this.stopLoading();\n- img.style.visibility = 'inherit';\n- img.style.opacity = this.layer.opacity;\n- this.isLoading = false;\n- this.canvasContext = null;\n- this.events.triggerEvent(\"loadend\");\n-\n- if (this.layerAlphaHack === true) {\n- img.style.filter =\n- \"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='\" +\n- img.src + \"', sizingMethod='scale')\";\n+ buildGeometryNode: function(geometry) {\n+ if (this.externalProjection && this.internalProjection) {\n+ geometry = geometry.clone();\n+ geometry.transform(this.internalProjection,\n+ this.externalProjection);\n }\n+ var className = geometry.CLASS_NAME;\n+ var type = className.substring(className.lastIndexOf(\".\") + 1);\n+ var builder = this.buildGeometry[type.toLowerCase()];\n+ return builder.apply(this, [geometry]);\n },\n \n /**\n- * Method: onImageError\n- * Handler for the image onerror event\n+ * Property: buildGeometry\n+ * Object containing methods to do the actual geometry node building\n+ * based on geometry type.\n */\n- onImageError: function() {\n- var img = this.imgDiv;\n- if (img.src != null) {\n- this.imageReloadAttempts++;\n- if (this.imageReloadAttempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {\n- this.setImgSrc(this.layer.getURL(this.bounds));\n- } else {\n- OpenLayers.Element.addClass(img, \"olImageLoadError\");\n- this.events.triggerEvent(\"loaderror\");\n- this.onImageLoad();\n+ buildGeometry: {\n+ // TBD retrieve the srs from layer\n+ // srsName is non-standard, so not including it until it's right.\n+ // gml.setAttribute(\"srsName\",\n+ // \"http://www.opengis.net/gml/srs/epsg.xml#4326\");\n+\n+ /**\n+ * Method: buildGeometry.point\n+ * Given an OpenLayers point geometry, create a GML point.\n+ *\n+ * Parameters:\n+ * geometry - {} A point geometry.\n+ *\n+ * Returns:\n+ * {DOMElement} A GML point node.\n+ */\n+ point: function(geometry) {\n+ var gml = this.createElementNS(this.gmlns, \"gml:Point\");\n+ gml.appendChild(this.buildCoordinatesNode(geometry));\n+ return gml;\n+ },\n+\n+ /**\n+ * Method: buildGeometry.multipoint\n+ * Given an OpenLayers multipoint geometry, create a GML multipoint.\n+ *\n+ * Parameters:\n+ * geometry - {} A multipoint geometry.\n+ *\n+ * Returns:\n+ * {DOMElement} A GML multipoint node.\n+ */\n+ multipoint: function(geometry) {\n+ var gml = this.createElementNS(this.gmlns, \"gml:MultiPoint\");\n+ var points = geometry.components;\n+ var pointMember, pointGeom;\n+ for (var i = 0; i < points.length; i++) {\n+ pointMember = this.createElementNS(this.gmlns,\n+ \"gml:pointMember\");\n+ pointGeom = this.buildGeometry.point.apply(this,\n+ [points[i]]);\n+ pointMember.appendChild(pointGeom);\n+ gml.appendChild(pointMember);\n }\n- }\n- },\n+ return gml;\n+ },\n \n- /**\n- * Method: stopLoading\n- * Stops a loading sequence so won't be executed.\n- */\n- stopLoading: function() {\n- OpenLayers.Event.stopObservingElement(this.imgDiv);\n- window.clearTimeout(this._loadTimeout);\n- delete this._loadTimeout;\n+ /**\n+ * Method: buildGeometry.linestring\n+ * Given an OpenLayers linestring geometry, create a GML linestring.\n+ *\n+ * Parameters:\n+ * geometry - {} A linestring geometry.\n+ *\n+ * Returns:\n+ * {DOMElement} A GML linestring node.\n+ */\n+ linestring: function(geometry) {\n+ var gml = this.createElementNS(this.gmlns, \"gml:LineString\");\n+ gml.appendChild(this.buildCoordinatesNode(geometry));\n+ return gml;\n+ },\n+\n+ /**\n+ * Method: buildGeometry.multilinestring\n+ * Given an OpenLayers multilinestring geometry, create a GML\n+ * multilinestring.\n+ *\n+ * Parameters:\n+ * geometry - {} A multilinestring\n+ * geometry.\n+ *\n+ * Returns:\n+ * {DOMElement} A GML multilinestring node.\n+ */\n+ multilinestring: function(geometry) {\n+ var gml = this.createElementNS(this.gmlns, \"gml:MultiLineString\");\n+ var lines = geometry.components;\n+ var lineMember, lineGeom;\n+ for (var i = 0; i < lines.length; ++i) {\n+ lineMember = this.createElementNS(this.gmlns,\n+ \"gml:lineStringMember\");\n+ lineGeom = this.buildGeometry.linestring.apply(this,\n+ [lines[i]]);\n+ lineMember.appendChild(lineGeom);\n+ gml.appendChild(lineMember);\n+ }\n+ return gml;\n+ },\n+\n+ /**\n+ * Method: buildGeometry.linearring\n+ * Given an OpenLayers linearring geometry, create a GML linearring.\n+ *\n+ * Parameters:\n+ * geometry - {} A linearring geometry.\n+ *\n+ * Returns:\n+ * {DOMElement} A GML linearring node.\n+ */\n+ linearring: function(geometry) {\n+ var gml = this.createElementNS(this.gmlns, \"gml:LinearRing\");\n+ gml.appendChild(this.buildCoordinatesNode(geometry));\n+ return gml;\n+ },\n+\n+ /**\n+ * Method: buildGeometry.polygon\n+ * Given an OpenLayers polygon geometry, create a GML polygon.\n+ *\n+ * Parameters:\n+ * geometry - {} A polygon geometry.\n+ *\n+ * Returns:\n+ * {DOMElement} A GML polygon node.\n+ */\n+ polygon: function(geometry) {\n+ var gml = this.createElementNS(this.gmlns, \"gml:Polygon\");\n+ var rings = geometry.components;\n+ var ringMember, ringGeom, type;\n+ for (var i = 0; i < rings.length; ++i) {\n+ type = (i == 0) ? \"outerBoundaryIs\" : \"innerBoundaryIs\";\n+ ringMember = this.createElementNS(this.gmlns,\n+ \"gml:\" + type);\n+ ringGeom = this.buildGeometry.linearring.apply(this,\n+ [rings[i]]);\n+ ringMember.appendChild(ringGeom);\n+ gml.appendChild(ringMember);\n+ }\n+ return gml;\n+ },\n+\n+ /**\n+ * Method: buildGeometry.multipolygon\n+ * Given an OpenLayers multipolygon geometry, create a GML multipolygon.\n+ *\n+ * Parameters:\n+ * geometry - {} A multipolygon\n+ * geometry.\n+ *\n+ * Returns:\n+ * {DOMElement} A GML multipolygon node.\n+ */\n+ multipolygon: function(geometry) {\n+ var gml = this.createElementNS(this.gmlns, \"gml:MultiPolygon\");\n+ var polys = geometry.components;\n+ var polyMember, polyGeom;\n+ for (var i = 0; i < polys.length; ++i) {\n+ polyMember = this.createElementNS(this.gmlns,\n+ \"gml:polygonMember\");\n+ polyGeom = this.buildGeometry.polygon.apply(this,\n+ [polys[i]]);\n+ polyMember.appendChild(polyGeom);\n+ gml.appendChild(polyMember);\n+ }\n+ return gml;\n+\n+ },\n+\n+ /**\n+ * Method: buildGeometry.bounds\n+ * Given an OpenLayers bounds, create a GML box.\n+ *\n+ * Parameters:\n+ * bounds - {} A bounds object.\n+ *\n+ * Returns:\n+ * {DOMElement} A GML box node.\n+ */\n+ bounds: function(bounds) {\n+ var gml = this.createElementNS(this.gmlns, \"gml:Box\");\n+ gml.appendChild(this.buildCoordinatesNode(bounds));\n+ return gml;\n+ }\n },\n \n /**\n- * APIMethod: getCanvasContext\n- * Returns a canvas context associated with the tile image (with\n- * the image drawn on it).\n- * Returns undefined if the browser does not support canvas, if\n- * the tile has no image or if it's currently loading.\n- *\n- * The function returns a canvas context instance but the\n- * underlying canvas is still available in the 'canvas' property:\n+ * Method: buildCoordinates\n+ * builds the coordinates XmlNode\n * (code)\n- * var context = tile.getCanvasContext();\n- * if (context) {\n- * var data = context.canvas.toDataURL('image/jpeg');\n- * }\n+ * ...\n * (end)\n *\n+ * Parameters: \n+ * geometry - {} \n+ *\n * Returns:\n- * {Boolean}\n+ * {XmlNode} created xmlNode\n */\n- getCanvasContext: function() {\n- if (OpenLayers.CANVAS_SUPPORTED && this.imgDiv && !this.isLoading) {\n- if (!this.canvasContext) {\n- var canvas = document.createElement(\"canvas\");\n- canvas.width = this.size.w;\n- canvas.height = this.size.h;\n- this.canvasContext = canvas.getContext(\"2d\");\n- this.canvasContext.drawImage(this.imgDiv, 0, 0);\n+ buildCoordinatesNode: function(geometry) {\n+ var coordinatesNode = this.createElementNS(this.gmlns,\n+ \"gml:coordinates\");\n+ coordinatesNode.setAttribute(\"decimal\", \".\");\n+ coordinatesNode.setAttribute(\"cs\", \",\");\n+ coordinatesNode.setAttribute(\"ts\", \" \");\n+\n+ var parts = [];\n+\n+ if (geometry instanceof OpenLayers.Bounds) {\n+ parts.push(geometry.left + \",\" + geometry.bottom);\n+ parts.push(geometry.right + \",\" + geometry.top);\n+ } else {\n+ var points = (geometry.components) ? geometry.components : [geometry];\n+ for (var i = 0; i < points.length; i++) {\n+ parts.push(points[i].x + \",\" + points[i].y);\n }\n- return this.canvasContext;\n }\n- },\n-\n- CLASS_NAME: \"OpenLayers.Tile.Image\"\n \n-});\n+ var txtNode = this.createTextNode(parts.join(\" \"));\n+ coordinatesNode.appendChild(txtNode);\n \n-/** \n- * Constant: OpenLayers.Tile.Image.IMAGE\n- * {HTMLImageElement} The image for a tile.\n- */\n-OpenLayers.Tile.Image.IMAGE = (function() {\n- var img = new Image();\n- img.className = \"olTileImage\";\n- // avoid image gallery menu in IE6\n- img.galleryImg = \"no\";\n- return img;\n-}());\n+ return coordinatesNode;\n+ },\n \n+ CLASS_NAME: \"OpenLayers.Format.GML\"\n+});\n /* ======================================================================\n- OpenLayers/Layer/Grid.js\n+ OpenLayers/Format/GML/Base.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+/**\n+ * @requires OpenLayers/Format/XML.js\n+ * @requires OpenLayers/Format/GML.js\n+ */\n \n /**\n- * @requires OpenLayers/Layer/HTTPRequest.js\n- * @requires OpenLayers/Tile/Image.js\n+ * Though required in the full build, if the GML format is excluded, we set\n+ * the namespace here.\n */\n+if (!OpenLayers.Format.GML) {\n+ OpenLayers.Format.GML = {};\n+}\n \n /**\n- * Class: OpenLayers.Layer.Grid\n- * Base class for layers that use a lattice of tiles. Create a new grid\n- * layer with the constructor.\n+ * Class: OpenLayers.Format.GML.Base\n+ * Superclass for GML parsers.\n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {\n-\n- /**\n- * APIProperty: tileSize\n- * {}\n- */\n- tileSize: null,\n-\n- /**\n- * Property: tileOriginCorner\n- * {String} If the property is not provided, the tile origin \n- * will be derived from the layer's . The corner of the \n- * used is determined by this property. Acceptable values\n- * are \"tl\" (top left), \"tr\" (top right), \"bl\" (bottom left), and \"br\"\n- * (bottom right). Default is \"bl\".\n- */\n- tileOriginCorner: \"bl\",\n-\n- /**\n- * APIProperty: tileOrigin\n- * {} Optional origin for aligning the grid of tiles.\n- * If provided, requests for tiles at all resolutions will be aligned\n- * with this location (no tiles shall overlap this location). If\n- * not provided, the grid of tiles will be aligned with the layer's\n- * . Default is ``null``.\n- */\n- tileOrigin: null,\n-\n- /** APIProperty: tileOptions\n- * {Object} optional configuration options for instances\n- * created by this Layer, if supported by the tile class.\n- */\n- tileOptions: null,\n-\n- /**\n- * APIProperty: tileClass\n- * {} The tile class to use for this layer.\n- * Defaults is OpenLayers.Tile.Image.\n- */\n- tileClass: OpenLayers.Tile.Image,\n-\n- /**\n- * Property: grid\n- * {Array(Array())} This is an array of rows, each row is \n- * an array of tiles.\n- */\n- grid: null,\n-\n- /**\n- * APIProperty: singleTile\n- * {Boolean} Moves the layer into single-tile mode, meaning that one tile \n- * will be loaded. The tile's size will be determined by the 'ratio'\n- * property. When the tile is dragged such that it does not cover the \n- * entire viewport, it is reloaded.\n- */\n- singleTile: false,\n-\n- /** APIProperty: ratio\n- * {Float} Used only when in single-tile mode, this specifies the \n- * ratio of the size of the single tile to the size of the map.\n- * Default value is 1.5.\n- */\n- ratio: 1.5,\n-\n- /**\n- * APIProperty: buffer\n- * {Integer} Used only when in gridded mode, this specifies the number of \n- * extra rows and colums of tiles on each side which will\n- * surround the minimum grid tiles to cover the map.\n- * For very slow loading layers, a larger value may increase\n- * performance somewhat when dragging, but will increase bandwidth\n- * use significantly. \n- */\n- buffer: 0,\n-\n- /**\n- * APIProperty: transitionEffect\n- * {String} The transition effect to use when the map is zoomed.\n- * Two posible values:\n- *\n- * \"resize\" - Existing tiles are resized on zoom to provide a visual\n- * effect of the zoom having taken place immediately. As the\n- * new tiles become available, they are drawn on top of the\n- * resized tiles (this is the default setting).\n- * \"map-resize\" - Existing tiles are resized on zoom and placed below the\n- * base layer. New tiles for the base layer will cover existing tiles.\n- * This setting is recommended when having an overlay duplicated during\n- * the transition is undesirable (e.g. street labels or big transparent\n- * fills). \n- * null - No transition effect.\n- *\n- * Using \"resize\" on non-opaque layers can cause undesired visual\n- * effects. Set transitionEffect to null in this case.\n- */\n- transitionEffect: \"resize\",\n-\n- /**\n- * APIProperty: numLoadingTiles\n- * {Integer} How many tiles are still loading?\n- */\n- numLoadingTiles: 0,\n-\n- /**\n- * Property: serverResolutions\n- * {Array(Number}} This property is documented in subclasses as\n- * an API property.\n- */\n- serverResolutions: null,\n-\n- /**\n- * Property: loading\n- * {Boolean} Indicates if tiles are being loaded.\n- */\n- loading: false,\n+OpenLayers.Format.GML.Base = OpenLayers.Class(OpenLayers.Format.XML, {\n \n /**\n- * Property: backBuffer\n- * {DOMElement} The back buffer.\n+ * Property: namespaces\n+ * {Object} Mapping of namespace aliases to namespace URIs.\n */\n- backBuffer: null,\n+ namespaces: {\n+ gml: \"http://www.opengis.net/gml\",\n+ xlink: \"http://www.w3.org/1999/xlink\",\n+ xsi: \"http://www.w3.org/2001/XMLSchema-instance\",\n+ wfs: \"http://www.opengis.net/wfs\" // this is a convenience for reading wfs:FeatureCollection\n+ },\n \n /**\n- * Property: gridResolution\n- * {Number} The resolution of the current grid. Used for backbuffer and\n- * client zoom. This property is updated every time the grid is\n- * initialized.\n+ * Property: defaultPrefix\n */\n- gridResolution: null,\n+ defaultPrefix: \"gml\",\n \n /**\n- * Property: backBufferResolution\n- * {Number} The resolution of the current back buffer. This property is\n- * updated each time a back buffer is created.\n+ * Property: schemaLocation\n+ * {String} Schema location for a particular minor version.\n */\n- backBufferResolution: null,\n+ schemaLocation: null,\n \n /**\n- * Property: backBufferLonLat\n- * {Object} The top-left corner of the current back buffer. Includes lon\n- * and lat properties. This object is updated each time a back buffer\n- * is created.\n+ * APIProperty: featureType\n+ * {Array(String) or String} The local (without prefix) feature typeName(s).\n */\n- backBufferLonLat: null,\n+ featureType: null,\n \n /**\n- * Property: backBufferTimerId\n- * {Number} The id of the back buffer timer. This timer is used to\n- * delay the removal of the back buffer, thereby preventing\n- * flash effects caused by tile animation.\n+ * APIProperty: featureNS\n+ * {String} The feature namespace. Must be set in the options at\n+ * construction.\n */\n- backBufferTimerId: null,\n+ featureNS: null,\n \n /**\n- * APIProperty: removeBackBufferDelay\n- * {Number} Delay for removing the backbuffer when all tiles have finished\n- * loading. Can be set to 0 when no css opacity transitions for the\n- * olTileImage class are used. Default is 0 for layers,\n- * 2500 for tiled layers. See for more information on\n- * tile animation.\n+ * APIProperty: geometry\n+ * {String} Name of geometry element. Defaults to \"geometry\". If null, it\n+ * will be set on when the first geometry is parsed.\n */\n- removeBackBufferDelay: null,\n+ geometryName: \"geometry\",\n \n /**\n- * APIProperty: className\n- * {String} Name of the class added to the layer div. If not set in the\n- * options passed to the constructor then className defaults to\n- * \"olLayerGridSingleTile\" for single tile layers (see ),\n- * and \"olLayerGrid\" for non single tile layers.\n- *\n- * Note:\n- *\n- * The displaying of tiles is not animated by default for single tile\n- * layers - OpenLayers' default theme (style.css) includes this:\n- * (code)\n- * .olLayerGrid .olTileImage {\n- * -webkit-transition: opacity 0.2s linear;\n- * -moz-transition: opacity 0.2s linear;\n- * -o-transition: opacity 0.2s linear;\n- * transition: opacity 0.2s linear;\n- * }\n- * (end)\n- * To animate tile displaying for any grid layer the following\n- * CSS rule can be used:\n- * (code)\n- * .olTileImage {\n- * -webkit-transition: opacity 0.2s linear;\n- * -moz-transition: opacity 0.2s linear;\n- * -o-transition: opacity 0.2s linear;\n- * transition: opacity 0.2s linear;\n- * }\n- * (end)\n- * In that case, to avoid flash effects, \n- * should not be zero.\n+ * APIProperty: extractAttributes\n+ * {Boolean} Extract attributes from GML. Default is true.\n */\n- className: null,\n+ extractAttributes: true,\n \n /**\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * layer.events.register(type, obj, listener);\n- * (end)\n- *\n- * Listeners will be called with a reference to an event object. The\n- * properties of this event depends on exactly what happened.\n- *\n- * All event objects have at least the following properties:\n- * object - {Object} A reference to layer.events.object.\n- * element - {DOMElement} A reference to layer.events.element.\n- *\n- * Supported event types:\n- * addtile - Triggered when a tile is added to this layer. Listeners receive\n- * an object as first argument, which has a tile property that\n- * references the tile that has been added.\n- * tileloadstart - Triggered when a tile starts loading. Listeners receive\n- * an object as first argument, which has a tile property that\n- * references the tile that starts loading.\n- * tileloaded - Triggered when each new tile is\n- * loaded, as a means of progress update to listeners.\n- * listeners can access 'numLoadingTiles' if they wish to keep\n- * track of the loading progress. Listeners are called with an object\n- * with a 'tile' property as first argument, making the loaded tile\n- * available to the listener, and an 'aborted' property, which will be\n- * true when loading was aborted and no tile data is available.\n- * tileerror - Triggered before the tileloaded event (i.e. when the tile is\n- * still hidden) if a tile failed to load. Listeners receive an object\n- * as first argument, which has a tile property that references the\n- * tile that could not be loaded.\n- * retile - Triggered when the layer recreates its tile grid.\n+ * APIProperty: srsName\n+ * {String} URI for spatial reference system. This is optional for\n+ * single part geometries and mandatory for collections and multis.\n+ * If set, the srsName attribute will be written for all geometries.\n+ * Default is null.\n */\n+ srsName: null,\n \n /**\n- * Property: gridLayout\n- * {Object} Object containing properties tilelon, tilelat, startcol,\n- * startrow\n+ * APIProperty: xy\n+ * {Boolean} Order of the GML coordinate true:(x,y) or false:(y,x)\n+ * Changing is not recommended, a new Format should be instantiated.\n */\n- gridLayout: null,\n+ xy: true,\n \n /**\n- * Property: rowSign\n- * {Number} 1 for grids starting at the top, -1 for grids starting at the\n- * bottom. This is used for several grid index and offset calculations.\n+ * Property: geometryTypes\n+ * {Object} Maps OpenLayers geometry class names to GML element names.\n+ * Use before accessing this property.\n */\n- rowSign: null,\n+ geometryTypes: null,\n \n /**\n- * Property: transitionendEvents\n- * {Array} Event names for transitionend\n+ * Property: singleFeatureType\n+ * {Boolean} True if there is only 1 featureType, and not an array\n+ * of featuretypes.\n */\n- transitionendEvents: [\n- 'transitionend', 'webkitTransitionEnd', 'otransitionend',\n- 'oTransitionEnd'\n- ],\n+ singleFeatureType: null,\n \n /**\n- * Constructor: OpenLayers.Layer.Grid\n- * Create a new grid layer\n- *\n- * Parameters:\n- * name - {String}\n- * url - {String}\n- * params - {Object}\n- * options - {Object} Hashtable of extra options to tag onto the layer\n+ * Property: autoConfig\n+ * {Boolean} Indicates if the format was configured without a ,\n+ * but auto-configured and during read.\n+ * Subclasses making use of auto-configuration should make\n+ * the first call to the method (usually in the read method)\n+ * with true as 3rd argument, so the auto-configured featureType can be\n+ * reset and the format can be reused for subsequent reads with data from\n+ * different featureTypes. Set to false after read if you want to keep the\n+ * auto-configured values.\n */\n- initialize: function(name, url, params, options) {\n- OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this,\n- arguments);\n- this.grid = [];\n- this._removeBackBuffer = OpenLayers.Function.bind(this.removeBackBuffer, this);\n-\n- this.initProperties();\n-\n- this.rowSign = this.tileOriginCorner.substr(0, 1) === \"t\" ? 1 : -1;\n- },\n \n /**\n- * Method: initProperties\n- * Set any properties that depend on the value of singleTile.\n- * Currently sets removeBackBufferDelay and className\n+ * Property: regExes\n+ * Compiled regular expressions for manipulating strings.\n */\n- initProperties: function() {\n- if (this.options.removeBackBufferDelay === undefined) {\n- this.removeBackBufferDelay = this.singleTile ? 0 : 2500;\n- }\n-\n- if (this.options.className === undefined) {\n- this.className = this.singleTile ? 'olLayerGridSingleTile' :\n- 'olLayerGrid';\n- }\n+ regExes: {\n+ trimSpace: (/^\\s*|\\s*$/g),\n+ removeSpace: (/\\s*/g),\n+ splitSpace: (/\\s+/),\n+ trimComma: (/\\s*,\\s*/g),\n+ featureMember: (/^(.*:)?featureMembers?$/)\n },\n \n /**\n- * Method: setMap\n+ * Constructor: OpenLayers.Format.GML.Base\n+ * Instances of this class are not created directly. Use the\n+ * or constructor\n+ * instead.\n *\n * Parameters:\n- * map - {} The map.\n- */\n- setMap: function(map) {\n- OpenLayers.Layer.HTTPRequest.prototype.setMap.call(this, map);\n- OpenLayers.Element.addClass(this.div, this.className);\n- },\n-\n- /**\n- * Method: removeMap\n- * Called when the layer is removed from the map.\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n *\n- * Parameters:\n- * map - {} The map.\n- */\n- removeMap: function(map) {\n- this.removeBackBuffer();\n- },\n-\n- /**\n- * APIMethod: destroy\n- * Deconstruct the layer and clear the grid.\n+ * Valid options properties:\n+ * featureType - {Array(String) or String} Local (without prefix) feature \n+ * typeName(s) (required for write).\n+ * featureNS - {String} Feature namespace (required for write).\n+ * geometryName - {String} Geometry element name (required for write).\n */\n- destroy: function() {\n- this.removeBackBuffer();\n- this.clearGrid();\n-\n- this.grid = null;\n- this.tileSize = null;\n- OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments);\n+ initialize: function(options) {\n+ OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);\n+ this.setGeometryTypes();\n+ if (options && options.featureNS) {\n+ this.setNamespace(\"feature\", options.featureNS);\n+ }\n+ this.singleFeatureType = !options || (typeof options.featureType === \"string\");\n },\n \n /**\n- * APIMethod: mergeNewParams\n- * Refetches tiles with new params merged, keeping a backbuffer. Each\n- * loading new tile will have a css class of '.olTileReplacing'. If a\n- * stylesheet applies a 'display: none' style to that class, any fade-in\n- * transition will not apply, and backbuffers for each tile will be removed\n- * as soon as the tile is loaded.\n- * \n+ * Method: read\n+ *\n * Parameters:\n- * newParams - {Object}\n+ * data - {DOMElement} A gml:featureMember element, a gml:featureMembers\n+ * element, or an element containing either of the above at any level.\n *\n * Returns:\n- * redrawn: {Boolean} whether the layer was actually redrawn.\n- */\n-\n- /**\n- * Method: clearGrid\n- * Go through and remove all tiles from the grid, calling\n- * destroy() on each of them to kill circular references\n+ * {Array()} An array of features.\n */\n- clearGrid: function() {\n- if (this.grid) {\n- for (var iRow = 0, len = this.grid.length; iRow < len; iRow++) {\n- var row = this.grid[iRow];\n- for (var iCol = 0, clen = row.length; iCol < clen; iCol++) {\n- var tile = row[iCol];\n- this.destroyTile(tile);\n+ read: function(data) {\n+ if (typeof data == \"string\") {\n+ data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n+ }\n+ if (data && data.nodeType == 9) {\n+ data = data.documentElement;\n+ }\n+ var features = [];\n+ this.readNode(data, {\n+ features: features\n+ }, true);\n+ if (features.length == 0) {\n+ // look for gml:featureMember elements\n+ var elements = this.getElementsByTagNameNS(\n+ data, this.namespaces.gml, \"featureMember\"\n+ );\n+ if (elements.length) {\n+ for (var i = 0, len = elements.length; i < len; ++i) {\n+ this.readNode(elements[i], {\n+ features: features\n+ }, true);\n+ }\n+ } else {\n+ // look for gml:featureMembers elements (this is v3, but does no harm here)\n+ var elements = this.getElementsByTagNameNS(\n+ data, this.namespaces.gml, \"featureMembers\"\n+ );\n+ if (elements.length) {\n+ // there can be only one\n+ this.readNode(elements[0], {\n+ features: features\n+ }, true);\n }\n }\n- this.grid = [];\n- this.gridResolution = null;\n- this.gridLayout = null;\n- }\n- },\n-\n- /**\n- * APIMethod: addOptions\n- * \n- * Parameters:\n- * newOptions - {Object}\n- * reinitialize - {Boolean} If set to true, and if resolution options of the\n- * current baseLayer were changed, the map will be recentered to make\n- * sure that it is displayed with a valid resolution, and a\n- * changebaselayer event will be triggered.\n- */\n- addOptions: function(newOptions, reinitialize) {\n- var singleTileChanged = newOptions.singleTile !== undefined &&\n- newOptions.singleTile !== this.singleTile;\n- OpenLayers.Layer.HTTPRequest.prototype.addOptions.apply(this, arguments);\n- if (this.map && singleTileChanged) {\n- this.initProperties();\n- this.clearGrid();\n- this.tileSize = this.options.tileSize;\n- this.setTileSize();\n- this.moveTo(null, true);\n }\n+ return features;\n },\n \n /**\n- * APIMethod: clone\n- * Create a clone of this layer\n+ * Method: readNode\n+ * Shorthand for applying one of the named readers given the node\n+ * namespace and local name. Readers take two args (node, obj) and\n+ * generally extend or modify the second.\n *\n * Parameters:\n- * obj - {Object} Is this ever used?\n- * \n+ * node - {DOMElement} The node to be read (required).\n+ * obj - {Object} The object to be modified (optional).\n+ * first - {Boolean} Should be set to true for the first node read. This\n+ * is usually the readNode call in the read method. Without this being\n+ * set, auto-configured properties will stick on subsequent reads.\n+ *\n * Returns:\n- * {} An exact clone of this OpenLayers.Layer.Grid\n+ * {Object} The input object, modified (or a new one if none was provided).\n */\n- clone: function(obj) {\n-\n- if (obj == null) {\n- obj = new OpenLayers.Layer.Grid(this.name,\n- this.url,\n- this.params,\n- this.getOptions());\n+ readNode: function(node, obj, first) {\n+ // on subsequent calls of format.read(), we want to reset auto-\n+ // configured properties and auto-configure again.\n+ if (first === true && this.autoConfig === true) {\n+ this.featureType = null;\n+ delete this.namespaceAlias[this.featureNS];\n+ delete this.namespaces[\"feature\"];\n+ this.featureNS = null;\n }\n-\n- //get all additions from superclasses\n- obj = OpenLayers.Layer.HTTPRequest.prototype.clone.apply(this, [obj]);\n-\n- // copy/set any non-init, non-simple values here\n- if (this.tileSize != null) {\n- obj.tileSize = this.tileSize.clone();\n+ // featureType auto-configuration\n+ if (!this.featureNS && (!(node.prefix in this.namespaces) &&\n+ node.parentNode.namespaceURI == this.namespaces[\"gml\"] &&\n+ this.regExes.featureMember.test(node.parentNode.nodeName))) {\n+ this.featureType = node.nodeName.split(\":\").pop();\n+ this.setNamespace(\"feature\", node.namespaceURI);\n+ this.featureNS = node.namespaceURI;\n+ this.autoConfig = true;\n }\n-\n- // we do not want to copy reference to grid, so we make a new array\n- obj.grid = [];\n- obj.gridResolution = null;\n- // same for backbuffer\n- obj.backBuffer = null;\n- obj.backBufferTimerId = null;\n- obj.loading = false;\n- obj.numLoadingTiles = 0;\n-\n- return obj;\n+ return OpenLayers.Format.XML.prototype.readNode.apply(this, [node, obj]);\n },\n \n /**\n- * Method: moveTo\n- * This function is called whenever the map is moved. All the moving\n- * of actual 'tiles' is done by the map, but moveTo's role is to accept\n- * a bounds and make sure the data that that bounds requires is pre-loaded.\n- *\n- * Parameters:\n- * bounds - {}\n- * zoomChanged - {Boolean}\n- * dragging - {Boolean}\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n */\n- moveTo: function(bounds, zoomChanged, dragging) {\n-\n- OpenLayers.Layer.HTTPRequest.prototype.moveTo.apply(this, arguments);\n-\n- bounds = bounds || this.map.getExtent();\n-\n- if (bounds != null) {\n-\n- // if grid is empty or zoom has changed, we *must* re-tile\n- var forceReTile = !this.grid.length || zoomChanged;\n-\n- // total bounds of the tiles\n- var tilesBounds = this.getTilesBounds();\n-\n- // the new map resolution\n- var resolution = this.map.getResolution();\n-\n- // the server-supported resolution for the new map resolution\n- var serverResolution = this.getServerResolution(resolution);\n-\n- if (this.singleTile) {\n-\n- // We want to redraw whenever even the slightest part of the \n- // current bounds is not contained by our tile.\n- // (thus, we do not specify partial -- its default is false)\n-\n- if (forceReTile ||\n- (!dragging && !tilesBounds.containsBounds(bounds))) {\n-\n- // In single tile mode with no transition effect, we insert\n- // a non-scaled backbuffer when the layer is moved. But if\n- // a zoom occurs right after a move, i.e. before the new\n- // image is received, we need to remove the backbuffer, or\n- // an ill-positioned image will be visible during the zoom\n- // transition.\n-\n- if (zoomChanged && this.transitionEffect !== 'resize') {\n- this.removeBackBuffer();\n- }\n-\n- if (!zoomChanged || this.transitionEffect === 'resize') {\n- this.applyBackBuffer(resolution);\n+ readers: {\n+ \"gml\": {\n+ \"_inherit\": function(node, obj, container) {\n+ // To be implemented by version specific parsers\n+ },\n+ \"featureMember\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"featureMembers\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"name\": function(node, obj) {\n+ obj.name = this.getChildValue(node);\n+ },\n+ \"boundedBy\": function(node, obj) {\n+ var container = {};\n+ this.readChildNodes(node, container);\n+ if (container.components && container.components.length > 0) {\n+ obj.bounds = container.components[0];\n+ }\n+ },\n+ \"Point\": function(node, container) {\n+ var obj = {\n+ points: []\n+ };\n+ this.readChildNodes(node, obj);\n+ if (!container.components) {\n+ container.components = [];\n+ }\n+ container.components.push(obj.points[0]);\n+ },\n+ \"coordinates\": function(node, obj) {\n+ var str = this.getChildValue(node).replace(\n+ this.regExes.trimSpace, \"\"\n+ );\n+ str = str.replace(this.regExes.trimComma, \",\");\n+ var pointList = str.split(this.regExes.splitSpace);\n+ var coords;\n+ var numPoints = pointList.length;\n+ var points = new Array(numPoints);\n+ for (var i = 0; i < numPoints; ++i) {\n+ coords = pointList[i].split(\",\");\n+ if (this.xy) {\n+ points[i] = new OpenLayers.Geometry.Point(\n+ coords[0], coords[1], coords[2]\n+ );\n+ } else {\n+ points[i] = new OpenLayers.Geometry.Point(\n+ coords[1], coords[0], coords[2]\n+ );\n }\n-\n- this.initSingleTile(bounds);\n }\n- } else {\n-\n- // if the bounds have changed such that they are not even \n- // *partially* contained by our tiles (e.g. when user has \n- // programmatically panned to the other side of the earth on\n- // zoom level 18), then moveGriddedTiles could potentially have\n- // to run through thousands of cycles, so we want to reTile\n- // instead (thus, partial true). \n- forceReTile = forceReTile ||\n- !tilesBounds.intersectsBounds(bounds, {\n- worldBounds: this.map.baseLayer.wrapDateLine &&\n- this.map.getMaxExtent()\n- });\n-\n- if (forceReTile) {\n- if (zoomChanged && (this.transitionEffect === 'resize' ||\n- this.gridResolution === resolution)) {\n- this.applyBackBuffer(resolution);\n+ obj.points = points;\n+ },\n+ \"coord\": function(node, obj) {\n+ var coord = {};\n+ this.readChildNodes(node, coord);\n+ if (!obj.points) {\n+ obj.points = [];\n+ }\n+ obj.points.push(new OpenLayers.Geometry.Point(\n+ coord.x, coord.y, coord.z\n+ ));\n+ },\n+ \"X\": function(node, coord) {\n+ coord.x = this.getChildValue(node);\n+ },\n+ \"Y\": function(node, coord) {\n+ coord.y = this.getChildValue(node);\n+ },\n+ \"Z\": function(node, coord) {\n+ coord.z = this.getChildValue(node);\n+ },\n+ \"MultiPoint\": function(node, container) {\n+ var obj = {\n+ components: []\n+ };\n+ this.readers.gml._inherit.apply(this, [node, obj, container]);\n+ this.readChildNodes(node, obj);\n+ container.components = [\n+ new OpenLayers.Geometry.MultiPoint(obj.components)\n+ ];\n+ },\n+ \"pointMember\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"LineString\": function(node, container) {\n+ var obj = {};\n+ this.readers.gml._inherit.apply(this, [node, obj, container]);\n+ this.readChildNodes(node, obj);\n+ if (!container.components) {\n+ container.components = [];\n+ }\n+ container.components.push(\n+ new OpenLayers.Geometry.LineString(obj.points)\n+ );\n+ },\n+ \"MultiLineString\": function(node, container) {\n+ var obj = {\n+ components: []\n+ };\n+ this.readers.gml._inherit.apply(this, [node, obj, container]);\n+ this.readChildNodes(node, obj);\n+ container.components = [\n+ new OpenLayers.Geometry.MultiLineString(obj.components)\n+ ];\n+ },\n+ \"lineStringMember\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"Polygon\": function(node, container) {\n+ var obj = {\n+ outer: null,\n+ inner: []\n+ };\n+ this.readers.gml._inherit.apply(this, [node, obj, container]);\n+ this.readChildNodes(node, obj);\n+ obj.inner.unshift(obj.outer);\n+ if (!container.components) {\n+ container.components = [];\n+ }\n+ container.components.push(\n+ new OpenLayers.Geometry.Polygon(obj.inner)\n+ );\n+ },\n+ \"LinearRing\": function(node, obj) {\n+ var container = {};\n+ this.readers.gml._inherit.apply(this, [node, container]);\n+ this.readChildNodes(node, container);\n+ obj.components = [new OpenLayers.Geometry.LinearRing(\n+ container.points\n+ )];\n+ },\n+ \"MultiPolygon\": function(node, container) {\n+ var obj = {\n+ components: []\n+ };\n+ this.readers.gml._inherit.apply(this, [node, obj, container]);\n+ this.readChildNodes(node, obj);\n+ container.components = [\n+ new OpenLayers.Geometry.MultiPolygon(obj.components)\n+ ];\n+ },\n+ \"polygonMember\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"GeometryCollection\": function(node, container) {\n+ var obj = {\n+ components: []\n+ };\n+ this.readers.gml._inherit.apply(this, [node, obj, container]);\n+ this.readChildNodes(node, obj);\n+ container.components = [\n+ new OpenLayers.Geometry.Collection(obj.components)\n+ ];\n+ },\n+ \"geometryMember\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ }\n+ },\n+ \"feature\": {\n+ \"*\": function(node, obj) {\n+ // The node can either be named like the featureType, or it\n+ // can be a child of the feature:featureType. Children can be\n+ // geometry or attributes.\n+ var name;\n+ var local = node.localName || node.nodeName.split(\":\").pop();\n+ // Since an attribute can have the same name as the feature type\n+ // we only want to read the node as a feature if the parent\n+ // node can have feature nodes as children. In this case, the\n+ // obj.features property is set.\n+ if (obj.features) {\n+ if (!this.singleFeatureType &&\n+ (OpenLayers.Util.indexOf(this.featureType, local) !== -1)) {\n+ name = \"_typeName\";\n+ } else if (local === this.featureType) {\n+ name = \"_typeName\";\n }\n- this.initGriddedTiles(bounds);\n } else {\n- this.moveGriddedTiles();\n+ // Assume attribute elements have one child node and that the child\n+ // is a text node. Otherwise assume it is a geometry node.\n+ if (node.childNodes.length == 0 ||\n+ (node.childNodes.length == 1 && node.firstChild.nodeType == 3)) {\n+ if (this.extractAttributes) {\n+ name = \"_attribute\";\n+ }\n+ } else {\n+ name = \"_geometry\";\n+ }\n+ }\n+ if (name) {\n+ this.readers.feature[name].apply(this, [node, obj]);\n+ }\n+ },\n+ \"_typeName\": function(node, obj) {\n+ var container = {\n+ components: [],\n+ attributes: {}\n+ };\n+ this.readChildNodes(node, container);\n+ // look for common gml namespaced elements\n+ if (container.name) {\n+ container.attributes.name = container.name;\n+ }\n+ var feature = new OpenLayers.Feature.Vector(\n+ container.components[0], container.attributes\n+ );\n+ if (!this.singleFeatureType) {\n+ feature.type = node.nodeName.split(\":\").pop();\n+ feature.namespace = node.namespaceURI;\n+ }\n+ var fid = node.getAttribute(\"fid\") ||\n+ this.getAttributeNS(node, this.namespaces[\"gml\"], \"id\");\n+ if (fid) {\n+ feature.fid = fid;\n+ }\n+ if (this.internalProjection && this.externalProjection &&\n+ feature.geometry) {\n+ feature.geometry.transform(\n+ this.externalProjection, this.internalProjection\n+ );\n+ }\n+ if (container.bounds) {\n+ feature.bounds = container.bounds;\n+ }\n+ obj.features.push(feature);\n+ },\n+ \"_geometry\": function(node, obj) {\n+ if (!this.geometryName) {\n+ this.geometryName = node.nodeName.split(\":\").pop();\n }\n+ this.readChildNodes(node, obj);\n+ },\n+ \"_attribute\": function(node, obj) {\n+ var local = node.localName || node.nodeName.split(\":\").pop();\n+ var value = this.getChildValue(node);\n+ obj.attributes[local] = value;\n+ }\n+ },\n+ \"wfs\": {\n+ \"FeatureCollection\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n }\n }\n },\n \n /**\n- * Method: getTileData\n- * Given a map location, retrieve a tile and the pixel offset within that\n- * tile corresponding to the location. If there is not an existing \n- * tile in the grid that covers the given location, null will be \n- * returned.\n+ * Method: write\n *\n * Parameters:\n- * loc - {} map location\n+ * features - {Array() | OpenLayers.Feature.Vector}\n+ * An array of features or a single feature.\n *\n * Returns:\n- * {Object} Object with the following properties: tile ({}),\n- * i ({Number} x-pixel offset from top left), and j ({Integer} y-pixel\n- * offset from top left).\n+ * {String} Given an array of features, a doc with a gml:featureMembers\n+ * element will be returned. Given a single feature, a doc with a\n+ * gml:featureMember element will be returned.\n */\n- getTileData: function(loc) {\n- var data = null,\n- x = loc.lon,\n- y = loc.lat,\n- numRows = this.grid.length;\n-\n- if (this.map && numRows) {\n- var res = this.map.getResolution(),\n- tileWidth = this.tileSize.w,\n- tileHeight = this.tileSize.h,\n- bounds = this.grid[0][0].bounds,\n- left = bounds.left,\n- top = bounds.top;\n-\n- if (x < left) {\n- // deal with multiple worlds\n- if (this.map.baseLayer.wrapDateLine) {\n- var worldWidth = this.map.getMaxExtent().getWidth();\n- var worldsAway = Math.ceil((left - x) / worldWidth);\n- x += worldWidth * worldsAway;\n- }\n- }\n- // tile distance to location (fractional number of tiles);\n- var dtx = (x - left) / (res * tileWidth);\n- var dty = (top - y) / (res * tileHeight);\n- // index of tile in grid\n- var col = Math.floor(dtx);\n- var row = Math.floor(dty);\n- if (row >= 0 && row < numRows) {\n- var tile = this.grid[row][col];\n- if (tile) {\n- data = {\n- tile: tile,\n- // pixel index within tile\n- i: Math.floor((dtx - col) * tileWidth),\n- j: Math.floor((dty - row) * tileHeight)\n- };\n- }\n- }\n+ write: function(features) {\n+ var name;\n+ if (OpenLayers.Util.isArray(features)) {\n+ name = \"featureMembers\";\n+ } else {\n+ name = \"featureMember\";\n }\n- return data;\n- },\n+ var root = this.writeNode(\"gml:\" + name, features);\n+ this.setAttributeNS(\n+ root, this.namespaces[\"xsi\"],\n+ \"xsi:schemaLocation\", this.schemaLocation\n+ );\n \n- /**\n- * Method: destroyTile\n- *\n- * Parameters:\n- * tile - {}\n- */\n- destroyTile: function(tile) {\n- this.removeTileMonitoringHooks(tile);\n- tile.destroy();\n+ return OpenLayers.Format.XML.prototype.write.apply(this, [root]);\n },\n \n /**\n- * Method: getServerResolution\n- * Return the closest server-supported resolution.\n- *\n- * Parameters:\n- * resolution - {Number} The base resolution. If undefined the\n- * map resolution is used.\n- *\n- * Returns:\n- * {Number} The closest server resolution value.\n+ * Property: writers\n+ * As a compliment to the readers property, this structure contains public\n+ * writing functions grouped by namespace alias and named like the\n+ * node names they produce.\n */\n- getServerResolution: function(resolution) {\n- var distance = Number.POSITIVE_INFINITY;\n- resolution = resolution || this.map.getResolution();\n- if (this.serverResolutions &&\n- OpenLayers.Util.indexOf(this.serverResolutions, resolution) === -1) {\n- var i, newDistance, newResolution, serverResolution;\n- for (i = this.serverResolutions.length - 1; i >= 0; i--) {\n- newResolution = this.serverResolutions[i];\n- newDistance = Math.abs(newResolution - resolution);\n- if (newDistance > distance) {\n- break;\n+ writers: {\n+ \"gml\": {\n+ \"featureMember\": function(feature) {\n+ var node = this.createElementNSPlus(\"gml:featureMember\");\n+ this.writeNode(\"feature:_typeName\", feature, node);\n+ return node;\n+ },\n+ \"MultiPoint\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:MultiPoint\");\n+ var components = geometry.components || [geometry];\n+ for (var i = 0, ii = components.length; i < ii; ++i) {\n+ this.writeNode(\"pointMember\", components[i], node);\n }\n- distance = newDistance;\n- serverResolution = newResolution;\n+ return node;\n+ },\n+ \"pointMember\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:pointMember\");\n+ this.writeNode(\"Point\", geometry, node);\n+ return node;\n+ },\n+ \"MultiLineString\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:MultiLineString\");\n+ var components = geometry.components || [geometry];\n+ for (var i = 0, ii = components.length; i < ii; ++i) {\n+ this.writeNode(\"lineStringMember\", components[i], node);\n+ }\n+ return node;\n+ },\n+ \"lineStringMember\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:lineStringMember\");\n+ this.writeNode(\"LineString\", geometry, node);\n+ return node;\n+ },\n+ \"MultiPolygon\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:MultiPolygon\");\n+ var components = geometry.components || [geometry];\n+ for (var i = 0, ii = components.length; i < ii; ++i) {\n+ this.writeNode(\n+ \"polygonMember\", components[i], node\n+ );\n+ }\n+ return node;\n+ },\n+ \"polygonMember\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:polygonMember\");\n+ this.writeNode(\"Polygon\", geometry, node);\n+ return node;\n+ },\n+ \"GeometryCollection\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:GeometryCollection\");\n+ for (var i = 0, len = geometry.components.length; i < len; ++i) {\n+ this.writeNode(\"geometryMember\", geometry.components[i], node);\n+ }\n+ return node;\n+ },\n+ \"geometryMember\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:geometryMember\");\n+ var child = this.writeNode(\"feature:_geometry\", geometry);\n+ node.appendChild(child.firstChild);\n+ return node;\n+ }\n+ },\n+ \"feature\": {\n+ \"_typeName\": function(feature) {\n+ var node = this.createElementNSPlus(\"feature:\" + this.featureType, {\n+ attributes: {\n+ fid: feature.fid\n+ }\n+ });\n+ if (feature.geometry) {\n+ this.writeNode(\"feature:_geometry\", feature.geometry, node);\n+ }\n+ for (var name in feature.attributes) {\n+ var value = feature.attributes[name];\n+ if (value != null) {\n+ this.writeNode(\n+ \"feature:_attribute\", {\n+ name: name,\n+ value: value\n+ }, node\n+ );\n+ }\n+ }\n+ return node;\n+ },\n+ \"_geometry\": function(geometry) {\n+ if (this.externalProjection && this.internalProjection) {\n+ geometry = geometry.clone().transform(\n+ this.internalProjection, this.externalProjection\n+ );\n+ }\n+ var node = this.createElementNSPlus(\n+ \"feature:\" + this.geometryName\n+ );\n+ var type = this.geometryTypes[geometry.CLASS_NAME];\n+ var child = this.writeNode(\"gml:\" + type, geometry, node);\n+ if (this.srsName) {\n+ child.setAttribute(\"srsName\", this.srsName);\n+ }\n+ return node;\n+ },\n+ \"_attribute\": function(obj) {\n+ return this.createElementNSPlus(\"feature:\" + obj.name, {\n+ value: obj.value\n+ });\n+ }\n+ },\n+ \"wfs\": {\n+ \"FeatureCollection\": function(features) {\n+ /**\n+ * This is only here because GML2 only describes abstract\n+ * feature collections. Typically, you would not be using\n+ * the GML format to write wfs elements. This just provides\n+ * some way to write out lists of features. GML3 defines the\n+ * featureMembers element, so that is used by default instead.\n+ */\n+ var node = this.createElementNSPlus(\"wfs:FeatureCollection\");\n+ for (var i = 0, len = features.length; i < len; ++i) {\n+ this.writeNode(\"gml:featureMember\", features[i], node);\n+ }\n+ return node;\n }\n- resolution = serverResolution;\n }\n- return resolution;\n },\n \n /**\n- * Method: getServerZoom\n- * Return the zoom value corresponding to the best matching server\n- * resolution, taking into account and .\n- *\n- * Returns:\n- * {Number} The closest server supported zoom. This is not the map zoom\n- * level, but an index of the server's resolutions array.\n+ * Method: setGeometryTypes\n+ * Sets the mapping.\n */\n- getServerZoom: function() {\n- var resolution = this.getServerResolution();\n- return this.serverResolutions ?\n- OpenLayers.Util.indexOf(this.serverResolutions, resolution) :\n- this.map.getZoomForResolution(resolution) + (this.zoomOffset || 0);\n+ setGeometryTypes: function() {\n+ this.geometryTypes = {\n+ \"OpenLayers.Geometry.Point\": \"Point\",\n+ \"OpenLayers.Geometry.MultiPoint\": \"MultiPoint\",\n+ \"OpenLayers.Geometry.LineString\": \"LineString\",\n+ \"OpenLayers.Geometry.MultiLineString\": \"MultiLineString\",\n+ \"OpenLayers.Geometry.Polygon\": \"Polygon\",\n+ \"OpenLayers.Geometry.MultiPolygon\": \"MultiPolygon\",\n+ \"OpenLayers.Geometry.Collection\": \"GeometryCollection\"\n+ };\n },\n \n- /**\n- * Method: applyBackBuffer\n- * Create, insert, scale and position a back buffer for the layer.\n- *\n- * Parameters:\n- * resolution - {Number} The resolution to transition to.\n- */\n- applyBackBuffer: function(resolution) {\n- if (this.backBufferTimerId !== null) {\n- this.removeBackBuffer();\n- }\n- var backBuffer = this.backBuffer;\n- if (!backBuffer) {\n- backBuffer = this.createBackBuffer();\n- if (!backBuffer) {\n- return;\n- }\n- if (resolution === this.gridResolution) {\n- this.div.insertBefore(backBuffer, this.div.firstChild);\n- } else {\n- this.map.baseLayer.div.parentNode.insertBefore(backBuffer, this.map.baseLayer.div);\n- }\n- this.backBuffer = backBuffer;\n+ CLASS_NAME: \"OpenLayers.Format.GML.Base\"\n \n- // set some information in the instance for subsequent\n- // calls to applyBackBuffer where the same back buffer\n- // is reused\n- var topLeftTileBounds = this.grid[0][0].bounds;\n- this.backBufferLonLat = {\n- lon: topLeftTileBounds.left,\n- lat: topLeftTileBounds.top\n- };\n- this.backBufferResolution = this.gridResolution;\n- }\n+});\n+/* ======================================================================\n+ OpenLayers/Format/GML/v3.js\n+ ====================================================================== */\n \n- var ratio = this.backBufferResolution / resolution;\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- // scale the tiles inside the back buffer\n- var tiles = backBuffer.childNodes,\n- tile;\n- for (var i = tiles.length - 1; i >= 0; --i) {\n- tile = tiles[i];\n- tile.style.top = ((ratio * tile._i * tile._h) | 0) + 'px';\n- tile.style.left = ((ratio * tile._j * tile._w) | 0) + 'px';\n- tile.style.width = Math.round(ratio * tile._w) + 'px';\n- tile.style.height = Math.round(ratio * tile._h) + 'px';\n- }\n+/**\n+ * @requires OpenLayers/Format/GML/Base.js\n+ */\n \n- // and position it (based on the grid's top-left corner)\n- var position = this.getViewPortPxFromLonLat(\n- this.backBufferLonLat, resolution);\n- var leftOffset = this.map.layerContainerOriginPx.x;\n- var topOffset = this.map.layerContainerOriginPx.y;\n- backBuffer.style.left = Math.round(position.x - leftOffset) + 'px';\n- backBuffer.style.top = Math.round(position.y - topOffset) + 'px';\n- },\n+/**\n+ * Class: OpenLayers.Format.GML.v3\n+ * Parses GML version 3.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Format.GML.v3 = OpenLayers.Class(OpenLayers.Format.GML.Base, {\n \n /**\n- * Method: createBackBuffer\n- * Create a back buffer.\n- *\n- * Returns:\n- * {DOMElement} The DOM element for the back buffer, undefined if the\n- * grid isn't initialized yet.\n+ * Property: schemaLocation\n+ * {String} Schema location for a particular minor version. The writers\n+ * conform with the Simple Features Profile for GML.\n */\n- createBackBuffer: function() {\n- var backBuffer;\n- if (this.grid.length > 0) {\n- backBuffer = document.createElement('div');\n- backBuffer.id = this.div.id + '_bb';\n- backBuffer.className = 'olBackBuffer';\n- backBuffer.style.position = 'absolute';\n- var map = this.map;\n- backBuffer.style.zIndex = this.transitionEffect === 'resize' ?\n- this.getZIndex() - 1 :\n- // 'map-resize':\n- map.Z_INDEX_BASE.BaseLayer -\n- (map.getNumLayers() - map.getLayerIndex(this));\n- for (var i = 0, lenI = this.grid.length; i < lenI; i++) {\n- for (var j = 0, lenJ = this.grid[i].length; j < lenJ; j++) {\n- var tile = this.grid[i][j],\n- markup = this.grid[i][j].createBackBuffer();\n- if (markup) {\n- markup._i = i;\n- markup._j = j;\n- markup._w = tile.size.w;\n- markup._h = tile.size.h;\n- markup.id = tile.id + '_bb';\n- backBuffer.appendChild(markup);\n- }\n- }\n- }\n- }\n- return backBuffer;\n- },\n+ schemaLocation: \"http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/1.0.0/gmlsf.xsd\",\n \n /**\n- * Method: removeBackBuffer\n- * Remove back buffer from DOM.\n+ * Property: curve\n+ * {Boolean} Write gml:Curve instead of gml:LineString elements. This also\n+ * affects the elements in multi-part geometries. Default is false.\n+ * To write gml:Curve elements instead of gml:LineString, set curve\n+ * to true in the options to the contstructor (cannot be changed after\n+ * instantiation).\n */\n- removeBackBuffer: function() {\n- if (this._transitionElement) {\n- for (var i = this.transitionendEvents.length - 1; i >= 0; --i) {\n- OpenLayers.Event.stopObserving(this._transitionElement,\n- this.transitionendEvents[i], this._removeBackBuffer);\n- }\n- delete this._transitionElement;\n- }\n- if (this.backBuffer) {\n- if (this.backBuffer.parentNode) {\n- this.backBuffer.parentNode.removeChild(this.backBuffer);\n- }\n- this.backBuffer = null;\n- this.backBufferResolution = null;\n- if (this.backBufferTimerId !== null) {\n- window.clearTimeout(this.backBufferTimerId);\n- this.backBufferTimerId = null;\n- }\n- }\n- },\n+ curve: false,\n \n /**\n- * Method: moveByPx\n- * Move the layer based on pixel vector.\n- *\n- * Parameters:\n- * dx - {Number}\n- * dy - {Number}\n+ * Property: multiCurve\n+ * {Boolean} Write gml:MultiCurve instead of gml:MultiLineString. Since\n+ * the latter is deprecated in GML 3, the default is true. To write\n+ * gml:MultiLineString instead of gml:MultiCurve, set multiCurve to\n+ * false in the options to the constructor (cannot be changed after\n+ * instantiation).\n */\n- moveByPx: function(dx, dy) {\n- if (!this.singleTile) {\n- this.moveGriddedTiles();\n- }\n- },\n+ multiCurve: true,\n \n /**\n- * APIMethod: setTileSize\n- * Check if we are in singleTile mode and if so, set the size as a ratio\n- * of the map size (as specified by the layer's 'ratio' property).\n- * \n- * Parameters:\n- * size - {}\n+ * Property: surface\n+ * {Boolean} Write gml:Surface instead of gml:Polygon elements. This also\n+ * affects the elements in multi-part geometries. Default is false.\n+ * To write gml:Surface elements instead of gml:Polygon, set surface\n+ * to true in the options to the contstructor (cannot be changed after\n+ * instantiation).\n */\n- setTileSize: function(size) {\n- if (this.singleTile) {\n- size = this.map.getSize();\n- size.h = parseInt(size.h * this.ratio, 10);\n- size.w = parseInt(size.w * this.ratio, 10);\n- }\n- OpenLayers.Layer.HTTPRequest.prototype.setTileSize.apply(this, [size]);\n- },\n+ surface: false,\n \n /**\n- * APIMethod: getTilesBounds\n- * Return the bounds of the tile grid.\n- *\n- * Returns:\n- * {} A Bounds object representing the bounds of all the\n- * currently loaded tiles (including those partially or not at all seen \n- * onscreen).\n+ * Property: multiSurface\n+ * {Boolean} Write gml:multiSurface instead of gml:MultiPolygon. Since\n+ * the latter is deprecated in GML 3, the default is true. To write\n+ * gml:MultiPolygon instead of gml:multiSurface, set multiSurface to\n+ * false in the options to the constructor (cannot be changed after\n+ * instantiation).\n */\n- getTilesBounds: function() {\n- var bounds = null;\n-\n- var length = this.grid.length;\n- if (length) {\n- var bottomLeftTileBounds = this.grid[length - 1][0].bounds,\n- width = this.grid[0].length * bottomLeftTileBounds.getWidth(),\n- height = this.grid.length * bottomLeftTileBounds.getHeight();\n-\n- bounds = new OpenLayers.Bounds(bottomLeftTileBounds.left,\n- bottomLeftTileBounds.bottom,\n- bottomLeftTileBounds.left + width,\n- bottomLeftTileBounds.bottom + height);\n- }\n- return bounds;\n- },\n+ multiSurface: true,\n \n /**\n- * Method: initSingleTile\n- * \n- * Parameters: \n- * bounds - {}\n- */\n- initSingleTile: function(bounds) {\n- this.events.triggerEvent(\"retile\");\n-\n- //determine new tile bounds\n- var center = bounds.getCenterLonLat();\n- var tileWidth = bounds.getWidth() * this.ratio;\n- var tileHeight = bounds.getHeight() * this.ratio;\n-\n- var tileBounds =\n- new OpenLayers.Bounds(center.lon - (tileWidth / 2),\n- center.lat - (tileHeight / 2),\n- center.lon + (tileWidth / 2),\n- center.lat + (tileHeight / 2));\n-\n- var px = this.map.getLayerPxFromLonLat({\n- lon: tileBounds.left,\n- lat: tileBounds.top\n- });\n-\n- if (!this.grid.length) {\n- this.grid[0] = [];\n- }\n-\n- var tile = this.grid[0][0];\n- if (!tile) {\n- tile = this.addTile(tileBounds, px);\n-\n- this.addTileMonitoringHooks(tile);\n- tile.draw();\n- this.grid[0][0] = tile;\n- } else {\n- tile.moveTo(tileBounds, px);\n- }\n-\n- //remove all but our single tile\n- this.removeExcessTiles(1, 1);\n-\n- // store the resolution of the grid\n- this.gridResolution = this.getServerResolution();\n- },\n-\n- /** \n- * Method: calculateGridLayout\n- * Generate parameters for the grid layout.\n+ * Constructor: OpenLayers.Format.GML.v3\n+ * Create a parser for GML v3.\n *\n * Parameters:\n- * bounds - {|Object} OpenLayers.Bounds or an\n- * object with a 'left' and 'top' properties.\n- * origin - {|Object} OpenLayers.LonLat or an\n- * object with a 'lon' and 'lat' properties.\n- * resolution - {Number}\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n *\n- * Returns:\n- * {Object} Object containing properties tilelon, tilelat, startcol,\n- * startrow\n+ * Valid options properties:\n+ * featureType - {String} Local (without prefix) feature typeName (required).\n+ * featureNS - {String} Feature namespace (required).\n+ * geometryName - {String} Geometry element name.\n */\n- calculateGridLayout: function(bounds, origin, resolution) {\n- var tilelon = resolution * this.tileSize.w;\n- var tilelat = resolution * this.tileSize.h;\n-\n- var offsetlon = bounds.left - origin.lon;\n- var tilecol = Math.floor(offsetlon / tilelon) - this.buffer;\n-\n- var rowSign = this.rowSign;\n-\n- var offsetlat = rowSign * (origin.lat - bounds.top + tilelat);\n- var tilerow = Math[~rowSign ? 'floor' : 'ceil'](offsetlat / tilelat) - this.buffer * rowSign;\n-\n- return {\n- tilelon: tilelon,\n- tilelat: tilelat,\n- startcol: tilecol,\n- startrow: tilerow\n- };\n-\n+ initialize: function(options) {\n+ OpenLayers.Format.GML.Base.prototype.initialize.apply(this, [options]);\n },\n \n /**\n- * Method: getTileOrigin\n- * Determine the origin for aligning the grid of tiles. If a \n- * property is supplied, that will be returned. Otherwise, the origin\n- * will be derived from the layer's property. In this case,\n- * the tile origin will be the corner of the given by the \n- * property.\n- *\n- * Returns:\n- * {} The tile origin.\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n */\n- getTileOrigin: function() {\n- var origin = this.tileOrigin;\n- if (!origin) {\n- var extent = this.getMaxExtent();\n- var edges = ({\n- \"tl\": [\"left\", \"top\"],\n- \"tr\": [\"right\", \"top\"],\n- \"bl\": [\"left\", \"bottom\"],\n- \"br\": [\"right\", \"bottom\"]\n- })[this.tileOriginCorner];\n- origin = new OpenLayers.LonLat(extent[edges[0]], extent[edges[1]]);\n- }\n- return origin;\n+ readers: {\n+ \"gml\": OpenLayers.Util.applyDefaults({\n+ \"_inherit\": function(node, obj, container) {\n+ // SRSReferenceGroup attributes\n+ var dim = parseInt(node.getAttribute(\"srsDimension\"), 10) ||\n+ (container && container.srsDimension);\n+ if (dim) {\n+ obj.srsDimension = dim;\n+ }\n+ },\n+ \"featureMembers\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"Curve\": function(node, container) {\n+ var obj = {\n+ points: []\n+ };\n+ this.readers.gml._inherit.apply(this, [node, obj, container]);\n+ this.readChildNodes(node, obj);\n+ if (!container.components) {\n+ container.components = [];\n+ }\n+ container.components.push(\n+ new OpenLayers.Geometry.LineString(obj.points)\n+ );\n+ },\n+ \"segments\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"LineStringSegment\": function(node, container) {\n+ var obj = {};\n+ this.readChildNodes(node, obj);\n+ if (obj.points) {\n+ Array.prototype.push.apply(container.points, obj.points);\n+ }\n+ },\n+ \"pos\": function(node, obj) {\n+ var str = this.getChildValue(node).replace(\n+ this.regExes.trimSpace, \"\"\n+ );\n+ var coords = str.split(this.regExes.splitSpace);\n+ var point;\n+ if (this.xy) {\n+ point = new OpenLayers.Geometry.Point(\n+ coords[0], coords[1], coords[2]\n+ );\n+ } else {\n+ point = new OpenLayers.Geometry.Point(\n+ coords[1], coords[0], coords[2]\n+ );\n+ }\n+ obj.points = [point];\n+ },\n+ \"posList\": function(node, obj) {\n+ var str = this.getChildValue(node).replace(\n+ this.regExes.trimSpace, \"\"\n+ );\n+ var coords = str.split(this.regExes.splitSpace);\n+ // The \"dimension\" attribute is from the GML 3.0.1 spec.\n+ var dim = obj.srsDimension ||\n+ parseInt(node.getAttribute(\"srsDimension\") || node.getAttribute(\"dimension\"), 10) || 2;\n+ var j, x, y, z;\n+ var numPoints = coords.length / dim;\n+ var points = new Array(numPoints);\n+ for (var i = 0, len = coords.length; i < len; i += dim) {\n+ x = coords[i];\n+ y = coords[i + 1];\n+ z = (dim == 2) ? undefined : coords[i + 2];\n+ if (this.xy) {\n+ points[i / dim] = new OpenLayers.Geometry.Point(x, y, z);\n+ } else {\n+ points[i / dim] = new OpenLayers.Geometry.Point(y, x, z);\n+ }\n+ }\n+ obj.points = points;\n+ },\n+ \"Surface\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"patches\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"PolygonPatch\": function(node, obj) {\n+ this.readers.gml.Polygon.apply(this, [node, obj]);\n+ },\n+ \"exterior\": function(node, container) {\n+ var obj = {};\n+ this.readChildNodes(node, obj);\n+ container.outer = obj.components[0];\n+ },\n+ \"interior\": function(node, container) {\n+ var obj = {};\n+ this.readChildNodes(node, obj);\n+ container.inner.push(obj.components[0]);\n+ },\n+ \"MultiCurve\": function(node, container) {\n+ var obj = {\n+ components: []\n+ };\n+ this.readers.gml._inherit.apply(this, [node, obj, container]);\n+ this.readChildNodes(node, obj);\n+ if (obj.components.length > 0) {\n+ container.components = [\n+ new OpenLayers.Geometry.MultiLineString(obj.components)\n+ ];\n+ }\n+ },\n+ \"curveMember\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"MultiSurface\": function(node, container) {\n+ var obj = {\n+ components: []\n+ };\n+ this.readers.gml._inherit.apply(this, [node, obj, container]);\n+ this.readChildNodes(node, obj);\n+ if (obj.components.length > 0) {\n+ container.components = [\n+ new OpenLayers.Geometry.MultiPolygon(obj.components)\n+ ];\n+ }\n+ },\n+ \"surfaceMember\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"surfaceMembers\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"pointMembers\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"lineStringMembers\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"polygonMembers\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"geometryMembers\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"Envelope\": function(node, container) {\n+ var obj = {\n+ points: new Array(2)\n+ };\n+ this.readChildNodes(node, obj);\n+ if (!container.components) {\n+ container.components = [];\n+ }\n+ var min = obj.points[0];\n+ var max = obj.points[1];\n+ container.components.push(\n+ new OpenLayers.Bounds(min.x, min.y, max.x, max.y)\n+ );\n+ },\n+ \"lowerCorner\": function(node, container) {\n+ var obj = {};\n+ this.readers.gml.pos.apply(this, [node, obj]);\n+ container.points[0] = obj.points[0];\n+ },\n+ \"upperCorner\": function(node, container) {\n+ var obj = {};\n+ this.readers.gml.pos.apply(this, [node, obj]);\n+ container.points[1] = obj.points[0];\n+ }\n+ }, OpenLayers.Format.GML.Base.prototype.readers[\"gml\"]),\n+ \"feature\": OpenLayers.Format.GML.Base.prototype.readers[\"feature\"],\n+ \"wfs\": OpenLayers.Format.GML.Base.prototype.readers[\"wfs\"]\n },\n \n /**\n- * Method: getTileBoundsForGridIndex\n+ * Method: write\n *\n * Parameters:\n- * row - {Number} The row of the grid\n- * col - {Number} The column of the grid\n+ * features - {Array() | OpenLayers.Feature.Vector}\n+ * An array of features or a single feature.\n *\n * Returns:\n- * {} The bounds for the tile at (row, col)\n+ * {String} Given an array of features, a doc with a gml:featureMembers\n+ * element will be returned. Given a single feature, a doc with a\n+ * gml:featureMember element will be returned.\n */\n- getTileBoundsForGridIndex: function(row, col) {\n- var origin = this.getTileOrigin();\n- var tileLayout = this.gridLayout;\n- var tilelon = tileLayout.tilelon;\n- var tilelat = tileLayout.tilelat;\n- var startcol = tileLayout.startcol;\n- var startrow = tileLayout.startrow;\n- var rowSign = this.rowSign;\n- return new OpenLayers.Bounds(\n- origin.lon + (startcol + col) * tilelon,\n- origin.lat - (startrow + row * rowSign) * tilelat * rowSign,\n- origin.lon + (startcol + col + 1) * tilelon,\n- origin.lat - (startrow + (row - 1) * rowSign) * tilelat * rowSign\n+ write: function(features) {\n+ var name;\n+ if (OpenLayers.Util.isArray(features)) {\n+ name = \"featureMembers\";\n+ } else {\n+ name = \"featureMember\";\n+ }\n+ var root = this.writeNode(\"gml:\" + name, features);\n+ this.setAttributeNS(\n+ root, this.namespaces[\"xsi\"],\n+ \"xsi:schemaLocation\", this.schemaLocation\n );\n+\n+ return OpenLayers.Format.XML.prototype.write.apply(this, [root]);\n },\n \n /**\n- * Method: initGriddedTiles\n- * \n- * Parameters:\n- * bounds - {}\n+ * Property: writers\n+ * As a compliment to the readers property, this structure contains public\n+ * writing functions grouped by namespace alias and named like the\n+ * node names they produce.\n */\n- initGriddedTiles: function(bounds) {\n- this.events.triggerEvent(\"retile\");\n-\n- // work out mininum number of rows and columns; this is the number of\n- // tiles required to cover the viewport plus at least one for panning\n-\n- var viewSize = this.map.getSize();\n-\n- var origin = this.getTileOrigin();\n- var resolution = this.map.getResolution(),\n- serverResolution = this.getServerResolution(),\n- ratio = resolution / serverResolution,\n- tileSize = {\n- w: this.tileSize.w / ratio,\n- h: this.tileSize.h / ratio\n- };\n-\n- var minRows = Math.ceil(viewSize.h / tileSize.h) +\n- 2 * this.buffer + 1;\n- var minCols = Math.ceil(viewSize.w / tileSize.w) +\n- 2 * this.buffer + 1;\n-\n- var tileLayout = this.calculateGridLayout(bounds, origin, serverResolution);\n- this.gridLayout = tileLayout;\n-\n- var tilelon = tileLayout.tilelon;\n- var tilelat = tileLayout.tilelat;\n-\n- var layerContainerDivLeft = this.map.layerContainerOriginPx.x;\n- var layerContainerDivTop = this.map.layerContainerOriginPx.y;\n-\n- var tileBounds = this.getTileBoundsForGridIndex(0, 0);\n- var startPx = this.map.getViewPortPxFromLonLat(\n- new OpenLayers.LonLat(tileBounds.left, tileBounds.top)\n- );\n- startPx.x = Math.round(startPx.x) - layerContainerDivLeft;\n- startPx.y = Math.round(startPx.y) - layerContainerDivTop;\n-\n- var tileData = [],\n- center = this.map.getCenter();\n-\n- var rowidx = 0;\n- do {\n- var row = this.grid[rowidx];\n- if (!row) {\n- row = [];\n- this.grid.push(row);\n- }\n-\n- var colidx = 0;\n- do {\n- tileBounds = this.getTileBoundsForGridIndex(rowidx, colidx);\n- var px = startPx.clone();\n- px.x = px.x + colidx * Math.round(tileSize.w);\n- px.y = px.y + rowidx * Math.round(tileSize.h);\n- var tile = row[colidx];\n- if (!tile) {\n- tile = this.addTile(tileBounds, px);\n- this.addTileMonitoringHooks(tile);\n- row.push(tile);\n+ writers: {\n+ \"gml\": OpenLayers.Util.applyDefaults({\n+ \"featureMembers\": function(features) {\n+ var node = this.createElementNSPlus(\"gml:featureMembers\");\n+ for (var i = 0, len = features.length; i < len; ++i) {\n+ this.writeNode(\"feature:_typeName\", features[i], node);\n+ }\n+ return node;\n+ },\n+ \"Point\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:Point\");\n+ this.writeNode(\"pos\", geometry, node);\n+ return node;\n+ },\n+ \"pos\": function(point) {\n+ // only 2d for simple features profile\n+ var pos = (this.xy) ?\n+ (point.x + \" \" + point.y) : (point.y + \" \" + point.x);\n+ return this.createElementNSPlus(\"gml:pos\", {\n+ value: pos\n+ });\n+ },\n+ \"LineString\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:LineString\");\n+ this.writeNode(\"posList\", geometry.components, node);\n+ return node;\n+ },\n+ \"Curve\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:Curve\");\n+ this.writeNode(\"segments\", geometry, node);\n+ return node;\n+ },\n+ \"segments\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:segments\");\n+ this.writeNode(\"LineStringSegment\", geometry, node);\n+ return node;\n+ },\n+ \"LineStringSegment\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:LineStringSegment\");\n+ this.writeNode(\"posList\", geometry.components, node);\n+ return node;\n+ },\n+ \"posList\": function(points) {\n+ // only 2d for simple features profile\n+ var len = points.length;\n+ var parts = new Array(len);\n+ var point;\n+ for (var i = 0; i < len; ++i) {\n+ point = points[i];\n+ if (this.xy) {\n+ parts[i] = point.x + \" \" + point.y;\n+ } else {\n+ parts[i] = point.y + \" \" + point.x;\n+ }\n+ }\n+ return this.createElementNSPlus(\"gml:posList\", {\n+ value: parts.join(\" \")\n+ });\n+ },\n+ \"Surface\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:Surface\");\n+ this.writeNode(\"patches\", geometry, node);\n+ return node;\n+ },\n+ \"patches\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:patches\");\n+ this.writeNode(\"PolygonPatch\", geometry, node);\n+ return node;\n+ },\n+ \"PolygonPatch\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:PolygonPatch\", {\n+ attributes: {\n+ interpolation: \"planar\"\n+ }\n+ });\n+ this.writeNode(\"exterior\", geometry.components[0], node);\n+ for (var i = 1, len = geometry.components.length; i < len; ++i) {\n+ this.writeNode(\n+ \"interior\", geometry.components[i], node\n+ );\n+ }\n+ return node;\n+ },\n+ \"Polygon\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:Polygon\");\n+ this.writeNode(\"exterior\", geometry.components[0], node);\n+ for (var i = 1, len = geometry.components.length; i < len; ++i) {\n+ this.writeNode(\n+ \"interior\", geometry.components[i], node\n+ );\n+ }\n+ return node;\n+ },\n+ \"exterior\": function(ring) {\n+ var node = this.createElementNSPlus(\"gml:exterior\");\n+ this.writeNode(\"LinearRing\", ring, node);\n+ return node;\n+ },\n+ \"interior\": function(ring) {\n+ var node = this.createElementNSPlus(\"gml:interior\");\n+ this.writeNode(\"LinearRing\", ring, node);\n+ return node;\n+ },\n+ \"LinearRing\": function(ring) {\n+ var node = this.createElementNSPlus(\"gml:LinearRing\");\n+ this.writeNode(\"posList\", ring.components, node);\n+ return node;\n+ },\n+ \"MultiCurve\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:MultiCurve\");\n+ var components = geometry.components || [geometry];\n+ for (var i = 0, len = components.length; i < len; ++i) {\n+ this.writeNode(\"curveMember\", components[i], node);\n+ }\n+ return node;\n+ },\n+ \"curveMember\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:curveMember\");\n+ if (this.curve) {\n+ this.writeNode(\"Curve\", geometry, node);\n } else {\n- tile.moveTo(tileBounds, px, false);\n+ this.writeNode(\"LineString\", geometry, node);\n }\n- var tileCenter = tileBounds.getCenterLonLat();\n- tileData.push({\n- tile: tile,\n- distance: Math.pow(tileCenter.lon - center.lon, 2) +\n- Math.pow(tileCenter.lat - center.lat, 2)\n+ return node;\n+ },\n+ \"MultiSurface\": function(geometry) {\n+ var node = this.createElementNSPlus(\"gml:MultiSurface\");\n+ var components = geometry.components || [geometry];\n+ for (var i = 0, len = components.length; i < len; ++i) {\n+ this.writeNode(\"surfaceMember\", components[i], node);\n+ }\n+ return node;\n+ },\n+ \"surfaceMember\": function(polygon) {\n+ var node = this.createElementNSPlus(\"gml:surfaceMember\");\n+ if (this.surface) {\n+ this.writeNode(\"Surface\", polygon, node);\n+ } else {\n+ this.writeNode(\"Polygon\", polygon, node);\n+ }\n+ return node;\n+ },\n+ \"Envelope\": function(bounds) {\n+ var node = this.createElementNSPlus(\"gml:Envelope\");\n+ this.writeNode(\"lowerCorner\", bounds, node);\n+ this.writeNode(\"upperCorner\", bounds, node);\n+ // srsName attribute is required for gml:Envelope\n+ if (this.srsName) {\n+ node.setAttribute(\"srsName\", this.srsName);\n+ }\n+ return node;\n+ },\n+ \"lowerCorner\": function(bounds) {\n+ // only 2d for simple features profile\n+ var pos = (this.xy) ?\n+ (bounds.left + \" \" + bounds.bottom) :\n+ (bounds.bottom + \" \" + bounds.left);\n+ return this.createElementNSPlus(\"gml:lowerCorner\", {\n+ value: pos\n });\n-\n- colidx += 1;\n- } while ((tileBounds.right <= bounds.right + tilelon * this.buffer) ||\n- colidx < minCols);\n-\n- rowidx += 1;\n- } while ((tileBounds.bottom >= bounds.bottom - tilelat * this.buffer) ||\n- rowidx < minRows);\n-\n- //shave off exceess rows and colums\n- this.removeExcessTiles(rowidx, colidx);\n-\n- var resolution = this.getServerResolution();\n- // store the resolution of the grid\n- this.gridResolution = resolution;\n-\n- //now actually draw the tiles\n- tileData.sort(function(a, b) {\n- return a.distance - b.distance;\n- });\n- for (var i = 0, ii = tileData.length; i < ii; ++i) {\n- tileData[i].tile.draw();\n- }\n+ },\n+ \"upperCorner\": function(bounds) {\n+ // only 2d for simple features profile\n+ var pos = (this.xy) ?\n+ (bounds.right + \" \" + bounds.top) :\n+ (bounds.top + \" \" + bounds.right);\n+ return this.createElementNSPlus(\"gml:upperCorner\", {\n+ value: pos\n+ });\n+ }\n+ }, OpenLayers.Format.GML.Base.prototype.writers[\"gml\"]),\n+ \"feature\": OpenLayers.Format.GML.Base.prototype.writers[\"feature\"],\n+ \"wfs\": OpenLayers.Format.GML.Base.prototype.writers[\"wfs\"]\n },\n \n /**\n- * Method: getMaxExtent\n- * Get this layer's maximum extent. (Implemented as a getter for\n- * potential specific implementations in sub-classes.)\n- *\n- * Returns:\n- * {}\n+ * Method: setGeometryTypes\n+ * Sets the mapping.\n */\n- getMaxExtent: function() {\n- return this.maxExtent;\n+ setGeometryTypes: function() {\n+ this.geometryTypes = {\n+ \"OpenLayers.Geometry.Point\": \"Point\",\n+ \"OpenLayers.Geometry.MultiPoint\": \"MultiPoint\",\n+ \"OpenLayers.Geometry.LineString\": (this.curve === true) ? \"Curve\" : \"LineString\",\n+ \"OpenLayers.Geometry.MultiLineString\": (this.multiCurve === false) ? \"MultiLineString\" : \"MultiCurve\",\n+ \"OpenLayers.Geometry.Polygon\": (this.surface === true) ? \"Surface\" : \"Polygon\",\n+ \"OpenLayers.Geometry.MultiPolygon\": (this.multiSurface === false) ? \"MultiPolygon\" : \"MultiSurface\",\n+ \"OpenLayers.Geometry.Collection\": \"GeometryCollection\"\n+ };\n },\n \n- /**\n- * APIMethod: addTile\n- * Create a tile, initialize it, and add it to the layer div. \n- *\n- * Parameters\n- * bounds - {}\n- * position - {}\n- *\n- * Returns:\n- * {} The added OpenLayers.Tile\n- */\n- addTile: function(bounds, position) {\n- var tile = new this.tileClass(\n- this, position, bounds, null, this.tileSize, this.tileOptions\n- );\n- this.events.triggerEvent(\"addtile\", {\n- tile: tile\n- });\n- return tile;\n- },\n+ CLASS_NAME: \"OpenLayers.Format.GML.v3\"\n \n- /** \n- * Method: addTileMonitoringHooks\n- * This function takes a tile as input and adds the appropriate hooks to \n- * the tile so that the layer can keep track of the loading tiles.\n- * \n- * Parameters: \n- * tile - {}\n- */\n- addTileMonitoringHooks: function(tile) {\n+});\n+/* ======================================================================\n+ OpenLayers/Format/Filter/v1_1_0.js\n+ ====================================================================== */\n \n- var replacingCls = 'olTileReplacing';\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- tile.onLoadStart = function() {\n- //if that was first tile then trigger a 'loadstart' on the layer\n- if (this.loading === false) {\n- this.loading = true;\n- this.events.triggerEvent(\"loadstart\");\n- }\n- this.events.triggerEvent(\"tileloadstart\", {\n- tile: tile\n- });\n- this.numLoadingTiles++;\n- if (!this.singleTile && this.backBuffer && this.gridResolution === this.backBufferResolution) {\n- OpenLayers.Element.addClass(tile.getTile(), replacingCls);\n- }\n- };\n+/**\n+ * @requires OpenLayers/Format/Filter/v1.js\n+ * @requires OpenLayers/Format/GML/v3.js\n+ */\n \n- tile.onLoadEnd = function(evt) {\n- this.numLoadingTiles--;\n- var aborted = evt.type === 'unload';\n- this.events.triggerEvent(\"tileloaded\", {\n- tile: tile,\n- aborted: aborted\n- });\n- if (!this.singleTile && !aborted && this.backBuffer && this.gridResolution === this.backBufferResolution) {\n- var tileDiv = tile.getTile();\n- if (OpenLayers.Element.getStyle(tileDiv, 'display') === 'none') {\n- var bufferTile = document.getElementById(tile.id + '_bb');\n- if (bufferTile) {\n- bufferTile.parentNode.removeChild(bufferTile);\n- }\n- }\n- OpenLayers.Element.removeClass(tileDiv, replacingCls);\n- }\n- //if that was the last tile, then trigger a 'loadend' on the layer\n- if (this.numLoadingTiles === 0) {\n- if (this.backBuffer) {\n- if (this.backBuffer.childNodes.length === 0) {\n- // no tiles transitioning, remove immediately\n- this.removeBackBuffer();\n- } else {\n- // wait until transition has ended or delay has passed\n- this._transitionElement = aborted ?\n- this.div.lastChild : tile.imgDiv;\n- var transitionendEvents = this.transitionendEvents;\n- for (var i = transitionendEvents.length - 1; i >= 0; --i) {\n- OpenLayers.Event.observe(this._transitionElement,\n- transitionendEvents[i],\n- this._removeBackBuffer);\n- }\n- // the removal of the back buffer is delayed to prevent\n- // flash effects due to the animation of tile displaying\n- this.backBufferTimerId = window.setTimeout(\n- this._removeBackBuffer, this.removeBackBufferDelay\n- );\n- }\n- }\n- this.loading = false;\n- this.events.triggerEvent(\"loadend\");\n- }\n- };\n+/**\n+ * Class: OpenLayers.Format.Filter.v1_1_0\n+ * Write ogc:Filter version 1.1.0.\n+ *\n+ * Differences from the v1.0.0 parser:\n+ * - uses GML v3 instead of GML v2\n+ * - reads matchCase attribute on ogc:PropertyIsEqual and\n+ * ogc:PropertyIsNotEqual elements.\n+ * - writes matchCase attribute from comparison filters of type EQUAL_TO,\n+ * NOT_EQUAL_TO and LIKE.\n+ * \n+ * Inherits from: \n+ * - \n+ * - \n+ */\n+OpenLayers.Format.Filter.v1_1_0 = OpenLayers.Class(\n+ OpenLayers.Format.GML.v3, OpenLayers.Format.Filter.v1, {\n \n- tile.onLoadError = function() {\n- this.events.triggerEvent(\"tileerror\", {\n- tile: tile\n- });\n- };\n+ /**\n+ * Constant: VERSION\n+ * {String} 1.1.0\n+ */\n+ VERSION: \"1.1.0\",\n \n- tile.events.on({\n- \"loadstart\": tile.onLoadStart,\n- \"loadend\": tile.onLoadEnd,\n- \"unload\": tile.onLoadEnd,\n- \"loaderror\": tile.onLoadError,\n- scope: this\n- });\n- },\n+ /**\n+ * Property: schemaLocation\n+ * {String} http://www.opengis.net/ogc/filter/1.1.0/filter.xsd\n+ */\n+ schemaLocation: \"http://www.opengis.net/ogc/filter/1.1.0/filter.xsd\",\n \n- /** \n- * Method: removeTileMonitoringHooks\n- * This function takes a tile as input and removes the tile hooks \n- * that were added in addTileMonitoringHooks()\n- * \n- * Parameters: \n- * tile - {}\n- */\n- removeTileMonitoringHooks: function(tile) {\n- tile.unload();\n- tile.events.un({\n- \"loadstart\": tile.onLoadStart,\n- \"loadend\": tile.onLoadEnd,\n- \"unload\": tile.onLoadEnd,\n- \"loaderror\": tile.onLoadError,\n- scope: this\n- });\n- },\n+ /**\n+ * Constructor: OpenLayers.Format.Filter.v1_1_0\n+ * Instances of this class are not created directly. Use the\n+ * constructor instead.\n+ *\n+ * Parameters:\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n+ */\n+ initialize: function(options) {\n+ OpenLayers.Format.GML.v3.prototype.initialize.apply(\n+ this, [options]\n+ );\n+ },\n \n- /**\n- * Method: moveGriddedTiles\n- */\n- moveGriddedTiles: function() {\n- var buffer = this.buffer + 1;\n- while (true) {\n- var tlTile = this.grid[0][0];\n- var tlViewPort = {\n- x: tlTile.position.x +\n- this.map.layerContainerOriginPx.x,\n- y: tlTile.position.y +\n- this.map.layerContainerOriginPx.y\n- };\n- var ratio = this.getServerResolution() / this.map.getResolution();\n- var tileSize = {\n- w: Math.round(this.tileSize.w * ratio),\n- h: Math.round(this.tileSize.h * ratio)\n- };\n- if (tlViewPort.x > -tileSize.w * (buffer - 1)) {\n- this.shiftColumn(true, tileSize);\n- } else if (tlViewPort.x < -tileSize.w * buffer) {\n- this.shiftColumn(false, tileSize);\n- } else if (tlViewPort.y > -tileSize.h * (buffer - 1)) {\n- this.shiftRow(true, tileSize);\n- } else if (tlViewPort.y < -tileSize.h * buffer) {\n- this.shiftRow(false, tileSize);\n+ /**\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n+ */\n+ readers: {\n+ \"ogc\": OpenLayers.Util.applyDefaults({\n+ \"PropertyIsEqualTo\": function(node, obj) {\n+ var matchCase = node.getAttribute(\"matchCase\");\n+ var filter = new OpenLayers.Filter.Comparison({\n+ type: OpenLayers.Filter.Comparison.EQUAL_TO,\n+ matchCase: !(matchCase === \"false\" || matchCase === \"0\")\n+ });\n+ this.readChildNodes(node, filter);\n+ obj.filters.push(filter);\n+ },\n+ \"PropertyIsNotEqualTo\": function(node, obj) {\n+ var matchCase = node.getAttribute(\"matchCase\");\n+ var filter = new OpenLayers.Filter.Comparison({\n+ type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO,\n+ matchCase: !(matchCase === \"false\" || matchCase === \"0\")\n+ });\n+ this.readChildNodes(node, filter);\n+ obj.filters.push(filter);\n+ },\n+ \"PropertyIsLike\": function(node, obj) {\n+ var filter = new OpenLayers.Filter.Comparison({\n+ type: OpenLayers.Filter.Comparison.LIKE\n+ });\n+ this.readChildNodes(node, filter);\n+ var wildCard = node.getAttribute(\"wildCard\");\n+ var singleChar = node.getAttribute(\"singleChar\");\n+ var esc = node.getAttribute(\"escapeChar\");\n+ filter.value2regex(wildCard, singleChar, esc);\n+ obj.filters.push(filter);\n+ }\n+ }, OpenLayers.Format.Filter.v1.prototype.readers[\"ogc\"]),\n+ \"gml\": OpenLayers.Format.GML.v3.prototype.readers[\"gml\"],\n+ \"feature\": OpenLayers.Format.GML.v3.prototype.readers[\"feature\"]\n+ },\n+\n+ /**\n+ * Property: writers\n+ * As a compliment to the readers property, this structure contains public\n+ * writing functions grouped by namespace alias and named like the\n+ * node names they produce.\n+ */\n+ writers: {\n+ \"ogc\": OpenLayers.Util.applyDefaults({\n+ \"PropertyIsEqualTo\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:PropertyIsEqualTo\", {\n+ attributes: {\n+ matchCase: filter.matchCase\n+ }\n+ });\n+ // no ogc:expression handling for PropertyName for now\n+ this.writeNode(\"PropertyName\", filter, node);\n+ // handle Literals or Functions for now\n+ this.writeOgcExpression(filter.value, node);\n+ return node;\n+ },\n+ \"PropertyIsNotEqualTo\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:PropertyIsNotEqualTo\", {\n+ attributes: {\n+ matchCase: filter.matchCase\n+ }\n+ });\n+ // no ogc:expression handling for PropertyName for now\n+ this.writeNode(\"PropertyName\", filter, node);\n+ // handle Literals or Functions for now\n+ this.writeOgcExpression(filter.value, node);\n+ return node;\n+ },\n+ \"PropertyIsLike\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:PropertyIsLike\", {\n+ attributes: {\n+ matchCase: filter.matchCase,\n+ wildCard: \"*\",\n+ singleChar: \".\",\n+ escapeChar: \"!\"\n+ }\n+ });\n+ // no ogc:expression handling for now\n+ this.writeNode(\"PropertyName\", filter, node);\n+ // convert regex string to ogc string\n+ this.writeNode(\"Literal\", filter.regex2value(), node);\n+ return node;\n+ },\n+ \"BBOX\": function(filter) {\n+ var node = this.createElementNSPlus(\"ogc:BBOX\");\n+ // PropertyName is optional in 1.1.0\n+ filter.property && this.writeNode(\"PropertyName\", filter, node);\n+ var box = this.writeNode(\"gml:Envelope\", filter.value);\n+ if (filter.projection) {\n+ box.setAttribute(\"srsName\", filter.projection);\n+ }\n+ node.appendChild(box);\n+ return node;\n+ },\n+ \"SortBy\": function(sortProperties) {\n+ var node = this.createElementNSPlus(\"ogc:SortBy\");\n+ for (var i = 0, l = sortProperties.length; i < l; i++) {\n+ this.writeNode(\n+ \"ogc:SortProperty\",\n+ sortProperties[i],\n+ node\n+ );\n+ }\n+ return node;\n+ },\n+ \"SortProperty\": function(sortProperty) {\n+ var node = this.createElementNSPlus(\"ogc:SortProperty\");\n+ this.writeNode(\n+ \"ogc:PropertyName\",\n+ sortProperty,\n+ node\n+ );\n+ this.writeNode(\n+ \"ogc:SortOrder\",\n+ (sortProperty.order == 'DESC') ? 'DESC' : 'ASC',\n+ node\n+ );\n+ return node;\n+ },\n+ \"SortOrder\": function(value) {\n+ var node = this.createElementNSPlus(\"ogc:SortOrder\", {\n+ value: value\n+ });\n+ return node;\n+ }\n+ }, OpenLayers.Format.Filter.v1.prototype.writers[\"ogc\"]),\n+ \"gml\": OpenLayers.Format.GML.v3.prototype.writers[\"gml\"],\n+ \"feature\": OpenLayers.Format.GML.v3.prototype.writers[\"feature\"]\n+ },\n+\n+ /**\n+ * Method: writeSpatial\n+ *\n+ * Read a {} filter and converts it into XML.\n+ *\n+ * Parameters:\n+ * filter - {} The filter.\n+ * name - {String} Name of the generated XML element.\n+ *\n+ * Returns:\n+ * {DOMElement} The created XML element.\n+ */\n+ writeSpatial: function(filter, name) {\n+ var node = this.createElementNSPlus(\"ogc:\" + name);\n+ this.writeNode(\"PropertyName\", filter, node);\n+ if (filter.value instanceof OpenLayers.Filter.Function) {\n+ this.writeNode(\"Function\", filter.value, node);\n } else {\n- break;\n+ var child;\n+ if (filter.value instanceof OpenLayers.Geometry) {\n+ child = this.writeNode(\"feature:_geometry\", filter.value).firstChild;\n+ } else {\n+ child = this.writeNode(\"gml:Envelope\", filter.value);\n+ }\n+ if (filter.projection) {\n+ child.setAttribute(\"srsName\", filter.projection);\n+ }\n+ node.appendChild(child);\n }\n- }\n- },\n+ return node;\n+ },\n \n- /**\n- * Method: shiftRow\n- * Shifty grid work\n- *\n- * Parameters:\n- * prepend - {Boolean} if true, prepend to beginning.\n- * if false, then append to end\n- * tileSize - {Object} rendered tile size; object with w and h properties\n- */\n- shiftRow: function(prepend, tileSize) {\n- var grid = this.grid;\n- var rowIndex = prepend ? 0 : (grid.length - 1);\n- var sign = prepend ? -1 : 1;\n- var rowSign = this.rowSign;\n- var tileLayout = this.gridLayout;\n- tileLayout.startrow += sign * rowSign;\n+ CLASS_NAME: \"OpenLayers.Format.Filter.v1_1_0\"\n \n- var modelRow = grid[rowIndex];\n- var row = grid[prepend ? 'pop' : 'shift']();\n- for (var i = 0, len = row.length; i < len; i++) {\n- var tile = row[i];\n- var position = modelRow[i].position.clone();\n- position.y += tileSize.h * sign;\n- tile.moveTo(this.getTileBoundsForGridIndex(rowIndex, i), position);\n- }\n- grid[prepend ? 'unshift' : 'push'](row);\n- },\n+ });\n+/* ======================================================================\n+ OpenLayers/Format/OWSCommon/v1_0_0.js\n+ ====================================================================== */\n \n- /**\n- * Method: shiftColumn\n- * Shift grid work in the other dimension\n- *\n- * Parameters:\n- * prepend - {Boolean} if true, prepend to beginning.\n- * if false, then append to end\n- * tileSize - {Object} rendered tile size; object with w and h properties\n- */\n- shiftColumn: function(prepend, tileSize) {\n- var grid = this.grid;\n- var colIndex = prepend ? 0 : (grid[0].length - 1);\n- var sign = prepend ? -1 : 1;\n- var tileLayout = this.gridLayout;\n- tileLayout.startcol += sign;\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- for (var i = 0, len = grid.length; i < len; i++) {\n- var row = grid[i];\n- var position = row[colIndex].position.clone();\n- var tile = row[prepend ? 'pop' : 'shift']();\n- position.x += tileSize.w * sign;\n- tile.moveTo(this.getTileBoundsForGridIndex(i, colIndex), position);\n- row[prepend ? 'unshift' : 'push'](tile);\n- }\n- },\n+/**\n+ * @requires OpenLayers/Format/OWSCommon/v1.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Format.OWSCommon.v1_0_0\n+ * Parser for OWS Common version 1.0.0.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Format.OWSCommon.v1_0_0 = OpenLayers.Class(OpenLayers.Format.OWSCommon.v1, {\n \n /**\n- * Method: removeExcessTiles\n- * When the size of the map or the buffer changes, we may need to\n- * remove some excess rows and columns.\n- * \n- * Parameters:\n- * rows - {Integer} Maximum number of rows we want our grid to have.\n- * columns - {Integer} Maximum number of columns we want our grid to have.\n+ * Property: namespaces\n+ * {Object} Mapping of namespace aliases to namespace URIs.\n */\n- removeExcessTiles: function(rows, columns) {\n- var i, l;\n-\n- // remove extra rows\n- while (this.grid.length > rows) {\n- var row = this.grid.pop();\n- for (i = 0, l = row.length; i < l; i++) {\n- var tile = row[i];\n- this.destroyTile(tile);\n- }\n- }\n-\n- // remove extra columns\n- for (i = 0, l = this.grid.length; i < l; i++) {\n- while (this.grid[i].length > columns) {\n- var row = this.grid[i];\n- var tile = row.pop();\n- this.destroyTile(tile);\n- }\n- }\n+ namespaces: {\n+ ows: \"http://www.opengis.net/ows\",\n+ xlink: \"http://www.w3.org/1999/xlink\"\n },\n \n /**\n- * Method: onMapResize\n- * For singleTile layers, this will set a new tile size according to the\n- * dimensions of the map pane.\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n */\n- onMapResize: function() {\n- if (this.singleTile) {\n- this.clearGrid();\n- this.setTileSize();\n- }\n+ readers: {\n+ \"ows\": OpenLayers.Util.applyDefaults({\n+ \"ExceptionReport\": function(node, obj) {\n+ obj.success = false;\n+ obj.exceptionReport = {\n+ version: node.getAttribute('version'),\n+ language: node.getAttribute('language'),\n+ exceptions: []\n+ };\n+ this.readChildNodes(node, obj.exceptionReport);\n+ }\n+ }, OpenLayers.Format.OWSCommon.v1.prototype.readers.ows)\n },\n \n /**\n- * APIMethod: getTileBounds\n- * Returns The tile bounds for a layer given a pixel location.\n- *\n- * Parameters:\n- * viewPortPx - {} The location in the viewport.\n- *\n- * Returns:\n- * {} Bounds of the tile at the given pixel location.\n+ * Property: writers\n+ * As a compliment to the readers property, this structure contains public\n+ * writing functions grouped by namespace alias and named like the\n+ * node names they produce.\n */\n- getTileBounds: function(viewPortPx) {\n- var maxExtent = this.maxExtent;\n- var resolution = this.getResolution();\n- var tileMapWidth = resolution * this.tileSize.w;\n- var tileMapHeight = resolution * this.tileSize.h;\n- var mapPoint = this.getLonLatFromViewPortPx(viewPortPx);\n- var tileLeft = maxExtent.left + (tileMapWidth *\n- Math.floor((mapPoint.lon -\n- maxExtent.left) /\n- tileMapWidth));\n- var tileBottom = maxExtent.bottom + (tileMapHeight *\n- Math.floor((mapPoint.lat -\n- maxExtent.bottom) /\n- tileMapHeight));\n- return new OpenLayers.Bounds(tileLeft, tileBottom,\n- tileLeft + tileMapWidth,\n- tileBottom + tileMapHeight);\n+ writers: {\n+ \"ows\": OpenLayers.Format.OWSCommon.v1.prototype.writers.ows\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.Grid\"\n+ CLASS_NAME: \"OpenLayers.Format.OWSCommon.v1_0_0\"\n+\n });\n /* ======================================================================\n- OpenLayers/TileManager.js\n+ OpenLayers/Format/WFST/v1_1_0.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/Util.js\n- * @requires OpenLayers/BaseTypes.js\n- * @requires OpenLayers/BaseTypes/Element.js\n- * @requires OpenLayers/Layer/Grid.js\n- * @requires OpenLayers/Tile/Image.js\n+ * @requires OpenLayers/Format/WFST/v1.js\n+ * @requires OpenLayers/Format/Filter/v1_1_0.js\n+ * @requires OpenLayers/Format/OWSCommon/v1_0_0.js\n */\n \n /**\n- * Class: OpenLayers.TileManager\n- * Provides queueing of image requests and caching of image elements.\n+ * Class: OpenLayers.Format.WFST.v1_1_0\n+ * A format for creating WFS v1.1.0 transactions. Create a new instance with the\n+ * constructor.\n *\n- * Queueing avoids unnecessary image requests while changing zoom levels\n- * quickly, and helps improve dragging performance on mobile devices that show\n- * a lag in dragging when loading of new images starts. and\n- * are the configuration options to control this behavior.\n+ * Inherits from:\n+ * - \n+ * - \n+ */\n+OpenLayers.Format.WFST.v1_1_0 = OpenLayers.Class(\n+ OpenLayers.Format.Filter.v1_1_0, OpenLayers.Format.WFST.v1, {\n+\n+ /**\n+ * Property: version\n+ * {String} WFS version number.\n+ */\n+ version: \"1.1.0\",\n+\n+ /**\n+ * Property: schemaLocations\n+ * {Object} Properties are namespace aliases, values are schema locations.\n+ */\n+ schemaLocations: {\n+ \"wfs\": \"http://schemas.opengis.net/wfs/1.1.0/wfs.xsd\"\n+ },\n+\n+ /**\n+ * Constructor: OpenLayers.Format.WFST.v1_1_0\n+ * A class for parsing and generating WFS v1.1.0 transactions.\n+ *\n+ * To read additional information like hit count (numberOfFeatures) from\n+ * the FeatureCollection, call the method\n+ * with {output: \"object\"} as 2nd argument. Note that it is possible to\n+ * just request the hit count from a WFS 1.1.0 server with the\n+ * resultType=\"hits\" request parameter.\n+ *\n+ * Parameters:\n+ * options - {Object} Optional object whose properties will be set on the\n+ * instance.\n+ *\n+ * Valid options properties:\n+ * featureType - {String} Local (without prefix) feature typeName (required).\n+ * featureNS - {String} Feature namespace (optional).\n+ * featurePrefix - {String} Feature namespace alias (optional - only used\n+ * if featureNS is provided). Default is 'feature'.\n+ * geometryName - {String} Name of geometry attribute. Default is 'the_geom'.\n+ */\n+ initialize: function(options) {\n+ OpenLayers.Format.Filter.v1_1_0.prototype.initialize.apply(this, [options]);\n+ OpenLayers.Format.WFST.v1.prototype.initialize.apply(this, [options]);\n+ },\n+\n+ /**\n+ * Method: readNode\n+ * Shorthand for applying one of the named readers given the node\n+ * namespace and local name. Readers take two args (node, obj) and\n+ * generally extend or modify the second.\n+ *\n+ * Parameters:\n+ * node - {DOMElement} The node to be read (required).\n+ * obj - {Object} The object to be modified (optional).\n+ * first - {Boolean} Should be set to true for the first node read. This\n+ * is usually the readNode call in the read method. Without this being\n+ * set, auto-configured properties will stick on subsequent reads.\n+ *\n+ * Returns:\n+ * {Object} The input object, modified (or a new one if none was provided).\n+ */\n+ readNode: function(node, obj, first) {\n+ // Not the superclass, only the mixin classes inherit from\n+ // Format.GML.v3. We need this because we don't want to get readNode\n+ // from the superclass's superclass, which is OpenLayers.Format.XML.\n+ return OpenLayers.Format.GML.v3.prototype.readNode.apply(this, arguments);\n+ },\n+\n+ /**\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n+ */\n+ readers: {\n+ \"wfs\": OpenLayers.Util.applyDefaults({\n+ \"FeatureCollection\": function(node, obj) {\n+ obj.numberOfFeatures = parseInt(node.getAttribute(\n+ \"numberOfFeatures\"));\n+ OpenLayers.Format.WFST.v1.prototype.readers[\"wfs\"][\"FeatureCollection\"].apply(\n+ this, arguments);\n+ },\n+ \"TransactionResponse\": function(node, obj) {\n+ obj.insertIds = [];\n+ obj.success = false;\n+ this.readChildNodes(node, obj);\n+ },\n+ \"TransactionSummary\": function(node, obj) {\n+ // this is a limited test of success\n+ obj.success = true;\n+ },\n+ \"InsertResults\": function(node, obj) {\n+ this.readChildNodes(node, obj);\n+ },\n+ \"Feature\": function(node, container) {\n+ var obj = {\n+ fids: []\n+ };\n+ this.readChildNodes(node, obj);\n+ container.insertIds.push(obj.fids[0]);\n+ }\n+ }, OpenLayers.Format.WFST.v1.prototype.readers[\"wfs\"]),\n+ \"gml\": OpenLayers.Format.GML.v3.prototype.readers[\"gml\"],\n+ \"feature\": OpenLayers.Format.GML.v3.prototype.readers[\"feature\"],\n+ \"ogc\": OpenLayers.Format.Filter.v1_1_0.prototype.readers[\"ogc\"],\n+ \"ows\": OpenLayers.Format.OWSCommon.v1_0_0.prototype.readers[\"ows\"]\n+ },\n+\n+ /**\n+ * Property: writers\n+ * As a compliment to the readers property, this structure contains public\n+ * writing functions grouped by namespace alias and named like the\n+ * node names they produce.\n+ */\n+ writers: {\n+ \"wfs\": OpenLayers.Util.applyDefaults({\n+ \"GetFeature\": function(options) {\n+ var node = OpenLayers.Format.WFST.v1.prototype.writers[\"wfs\"][\"GetFeature\"].apply(this, arguments);\n+ options && this.setAttributes(node, {\n+ resultType: options.resultType,\n+ startIndex: options.startIndex,\n+ count: options.count\n+ });\n+ return node;\n+ },\n+ \"Query\": function(options) {\n+ options = OpenLayers.Util.extend({\n+ featureNS: this.featureNS,\n+ featurePrefix: this.featurePrefix,\n+ featureType: this.featureType,\n+ srsName: this.srsName\n+ }, options);\n+ var prefix = options.featurePrefix;\n+ var node = this.createElementNSPlus(\"wfs:Query\", {\n+ attributes: {\n+ typeName: (prefix ? prefix + \":\" : \"\") +\n+ options.featureType,\n+ srsName: options.srsName\n+ }\n+ });\n+ if (options.featureNS) {\n+ node.setAttribute(\"xmlns:\" + prefix, options.featureNS);\n+ }\n+ if (options.propertyNames) {\n+ for (var i = 0, len = options.propertyNames.length; i < len; i++) {\n+ this.writeNode(\n+ \"wfs:PropertyName\", {\n+ property: options.propertyNames[i]\n+ },\n+ node\n+ );\n+ }\n+ }\n+ if (options.filter) {\n+ OpenLayers.Format.WFST.v1_1_0.prototype.setFilterProperty.call(this, options.filter);\n+ this.writeNode(\"ogc:Filter\", options.filter, node);\n+ }\n+ return node;\n+ },\n+ \"PropertyName\": function(obj) {\n+ return this.createElementNSPlus(\"wfs:PropertyName\", {\n+ value: obj.property\n+ });\n+ }\n+ }, OpenLayers.Format.WFST.v1.prototype.writers[\"wfs\"]),\n+ \"gml\": OpenLayers.Format.GML.v3.prototype.writers[\"gml\"],\n+ \"feature\": OpenLayers.Format.GML.v3.prototype.writers[\"feature\"],\n+ \"ogc\": OpenLayers.Format.Filter.v1_1_0.prototype.writers[\"ogc\"]\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Format.WFST.v1_1_0\"\n+ });\n+/* ======================================================================\n+ OpenLayers/Format/WPSExecute.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Format/XML.js\n+ * @requires OpenLayers/Format/OWSCommon/v1_1_0.js\n+ * @requires OpenLayers/Format/WCSGetCoverage.js\n+ * @requires OpenLayers/Format/WFST/v1_1_0.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Format.WPSExecute version 1.0.0\n *\n- * Caching avoids setting the src on image elements for images that have already\n- * been used. Several maps can share a TileManager instance, in which case each\n- * map gets its own tile queue, but all maps share the same tile cache.\n+ * Inherits from:\n+ * - \n */\n-OpenLayers.TileManager = OpenLayers.Class({\n+OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML,\n+ OpenLayers.Format.Filter.v1_1_0, {\n \n- /**\n- * APIProperty: cacheSize\n- * {Number} Number of image elements to keep referenced in this instance's\n- * cache for fast reuse. Default is 256.\n- */\n- cacheSize: 256,\n+ /**\n+ * Property: namespaces\n+ * {Object} Mapping of namespace aliases to namespace URIs.\n+ */\n+ namespaces: {\n+ ows: \"http://www.opengis.net/ows/1.1\",\n+ gml: \"http://www.opengis.net/gml\",\n+ wps: \"http://www.opengis.net/wps/1.0.0\",\n+ wfs: \"http://www.opengis.net/wfs\",\n+ ogc: \"http://www.opengis.net/ogc\",\n+ wcs: \"http://www.opengis.net/wcs\",\n+ xlink: \"http://www.w3.org/1999/xlink\",\n+ xsi: \"http://www.w3.org/2001/XMLSchema-instance\"\n+ },\n \n- /**\n- * APIProperty: tilesPerFrame\n- * {Number} Number of queued tiles to load per frame (see ).\n- * Default is 2.\n- */\n- tilesPerFrame: 2,\n+ /**\n+ * Property: regExes\n+ * Compiled regular expressions for manipulating strings.\n+ */\n+ regExes: {\n+ trimSpace: (/^\\s*|\\s*$/g),\n+ removeSpace: (/\\s*/g),\n+ splitSpace: (/\\s+/),\n+ trimComma: (/\\s*,\\s*/g)\n+ },\n \n- /**\n- * APIProperty: frameDelay\n- * {Number} Delay between tile loading frames (see ) in\n- * milliseconds. Default is 16.\n- */\n- frameDelay: 16,\n+ /**\n+ * Constant: VERSION\n+ * {String} 1.0.0\n+ */\n+ VERSION: \"1.0.0\",\n \n- /**\n- * APIProperty: moveDelay\n- * {Number} Delay in milliseconds after a map's move event before loading\n- * tiles. Default is 100.\n- */\n- moveDelay: 100,\n+ /**\n+ * Property: schemaLocation\n+ * {String} Schema location\n+ */\n+ schemaLocation: \"http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd\",\n \n- /**\n- * APIProperty: zoomDelay\n- * {Number} Delay in milliseconds after a map's zoomend event before loading\n- * tiles. Default is 200.\n- */\n- zoomDelay: 200,\n+ schemaLocationAttr: function(options) {\n+ return undefined;\n+ },\n \n- /**\n- * Property: maps\n- * {Array()} The maps to manage tiles on.\n- */\n- maps: null,\n+ /**\n+ * Constructor: OpenLayers.Format.WPSExecute\n+ *\n+ * Parameters:\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n+ */\n \n- /**\n- * Property: tileQueueId\n- * {Object} The ids of the loop, keyed by map id.\n- */\n- tileQueueId: null,\n+ /**\n+ * Method: write\n+ *\n+ * Parameters:\n+ * options - {Object} Optional object.\n+ *\n+ * Returns:\n+ * {String} An WPS Execute request XML string.\n+ */\n+ write: function(options) {\n+ var doc;\n+ if (window.ActiveXObject) {\n+ doc = new ActiveXObject(\"Microsoft.XMLDOM\");\n+ this.xmldom = doc;\n+ } else {\n+ doc = document.implementation.createDocument(\"\", \"\", null);\n+ }\n+ var node = this.writeNode(\"wps:Execute\", options, doc);\n+ this.setAttributeNS(\n+ node, this.namespaces.xsi,\n+ \"xsi:schemaLocation\", this.schemaLocation\n+ );\n+ return OpenLayers.Format.XML.prototype.write.apply(this, [node]);\n+ },\n \n- /**\n- * Property: tileQueue\n- * {Object(Array())} Tiles queued for drawing, keyed by\n- * map id.\n- */\n- tileQueue: null,\n+ /**\n+ * APIMethod: read\n+ * Parse a WPS Execute and return an object with its information.\n+ * \n+ * Parameters: \n+ * data - {String} or {DOMElement} data to read/parse.\n+ *\n+ * Returns:\n+ * {Object}\n+ */\n+ read: function(data) {\n+ if (typeof data == \"string\") {\n+ data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n+ }\n+ if (data && data.nodeType == 9) {\n+ data = data.documentElement;\n+ }\n+ var info = {};\n+ this.readNode(data, info);\n+ return info;\n+ },\n \n- /**\n- * Property: tileCache\n- * {Object} Cached image elements, keyed by URL.\n- */\n- tileCache: null,\n+ /**\n+ * Property: writers\n+ * As a compliment to the readers property, this structure contains public\n+ * writing functions grouped by namespace alias and named like the\n+ * node names they produce.\n+ */\n+ writers: {\n+ \"wps\": {\n+ \"Execute\": function(options) {\n+ var node = this.createElementNSPlus(\"wps:Execute\", {\n+ attributes: {\n+ version: this.VERSION,\n+ service: 'WPS'\n+ }\n+ });\n+ this.writeNode(\"ows:Identifier\", options.identifier, node);\n+ this.writeNode(\"wps:DataInputs\", options.dataInputs, node);\n+ this.writeNode(\"wps:ResponseForm\", options.responseForm, node);\n+ return node;\n+ },\n+ \"ResponseForm\": function(responseForm) {\n+ var node = this.createElementNSPlus(\"wps:ResponseForm\", {});\n+ if (responseForm.rawDataOutput) {\n+ this.writeNode(\"wps:RawDataOutput\", responseForm.rawDataOutput, node);\n+ }\n+ if (responseForm.responseDocument) {\n+ this.writeNode(\"wps:ResponseDocument\", responseForm.responseDocument, node);\n+ }\n+ return node;\n+ },\n+ \"ResponseDocument\": function(responseDocument) {\n+ var node = this.createElementNSPlus(\"wps:ResponseDocument\", {\n+ attributes: {\n+ storeExecuteResponse: responseDocument.storeExecuteResponse,\n+ lineage: responseDocument.lineage,\n+ status: responseDocument.status\n+ }\n+ });\n+ if (responseDocument.outputs) {\n+ for (var i = 0, len = responseDocument.outputs.length; i < len; i++) {\n+ this.writeNode(\"wps:Output\", responseDocument.outputs[i], node);\n+ }\n+ }\n+ return node;\n+ },\n+ \"Output\": function(output) {\n+ var node = this.createElementNSPlus(\"wps:Output\", {\n+ attributes: {\n+ asReference: output.asReference,\n+ mimeType: output.mimeType,\n+ encoding: output.encoding,\n+ schema: output.schema\n+ }\n+ });\n+ this.writeNode(\"ows:Identifier\", output.identifier, node);\n+ this.writeNode(\"ows:Title\", output.title, node);\n+ this.writeNode(\"ows:Abstract\", output[\"abstract\"], node);\n+ return node;\n+ },\n+ \"RawDataOutput\": function(rawDataOutput) {\n+ var node = this.createElementNSPlus(\"wps:RawDataOutput\", {\n+ attributes: {\n+ mimeType: rawDataOutput.mimeType,\n+ encoding: rawDataOutput.encoding,\n+ schema: rawDataOutput.schema\n+ }\n+ });\n+ this.writeNode(\"ows:Identifier\", rawDataOutput.identifier, node);\n+ return node;\n+ },\n+ \"DataInputs\": function(dataInputs) {\n+ var node = this.createElementNSPlus(\"wps:DataInputs\", {});\n+ for (var i = 0, ii = dataInputs.length; i < ii; ++i) {\n+ this.writeNode(\"wps:Input\", dataInputs[i], node);\n+ }\n+ return node;\n+ },\n+ \"Input\": function(input) {\n+ var node = this.createElementNSPlus(\"wps:Input\", {});\n+ this.writeNode(\"ows:Identifier\", input.identifier, node);\n+ if (input.title) {\n+ this.writeNode(\"ows:Title\", input.title, node);\n+ }\n+ if (input.data) {\n+ this.writeNode(\"wps:Data\", input.data, node);\n+ }\n+ if (input.reference) {\n+ this.writeNode(\"wps:Reference\", input.reference, node);\n+ }\n+ if (input.boundingBoxData) {\n+ this.writeNode(\"wps:BoundingBoxData\", input.boundingBoxData, node);\n+ }\n+ return node;\n+ },\n+ \"Data\": function(data) {\n+ var node = this.createElementNSPlus(\"wps:Data\", {});\n+ if (data.literalData) {\n+ this.writeNode(\"wps:LiteralData\", data.literalData, node);\n+ } else if (data.complexData) {\n+ this.writeNode(\"wps:ComplexData\", data.complexData, node);\n+ } else if (data.boundingBoxData) {\n+ this.writeNode(\"ows:BoundingBox\", data.boundingBoxData, node);\n+ }\n+ return node;\n+ },\n+ \"LiteralData\": function(literalData) {\n+ var node = this.createElementNSPlus(\"wps:LiteralData\", {\n+ attributes: {\n+ uom: literalData.uom\n+ },\n+ value: literalData.value\n+ });\n+ return node;\n+ },\n+ \"ComplexData\": function(complexData) {\n+ var node = this.createElementNSPlus(\"wps:ComplexData\", {\n+ attributes: {\n+ mimeType: complexData.mimeType,\n+ encoding: complexData.encoding,\n+ schema: complexData.schema\n+ }\n+ });\n+ var data = complexData.value;\n+ if (typeof data === \"string\") {\n+ node.appendChild(\n+ this.getXMLDoc().createCDATASection(complexData.value)\n+ );\n+ } else {\n+ node.appendChild(data);\n+ }\n+ return node;\n+ },\n+ \"Reference\": function(reference) {\n+ var node = this.createElementNSPlus(\"wps:Reference\", {\n+ attributes: {\n+ mimeType: reference.mimeType,\n+ \"xlink:href\": reference.href,\n+ method: reference.method,\n+ encoding: reference.encoding,\n+ schema: reference.schema\n+ }\n+ });\n+ if (reference.body) {\n+ this.writeNode(\"wps:Body\", reference.body, node);\n+ }\n+ return node;\n+ },\n+ \"BoundingBoxData\": function(node, obj) {\n+ this.writers['ows']['BoundingBox'].apply(this, [node, obj, \"wps:BoundingBoxData\"]);\n+ },\n+ \"Body\": function(body) {\n+ var node = this.createElementNSPlus(\"wps:Body\", {});\n+ if (body.wcs) {\n+ this.writeNode(\"wcs:GetCoverage\", body.wcs, node);\n+ } else if (body.wfs) {\n+ // OpenLayers.Format.WFST expects these to be on the \n+ // instance and not in the options\n+ this.featureType = body.wfs.featureType;\n+ this.version = body.wfs.version;\n+ this.writeNode(\"wfs:GetFeature\", body.wfs, node);\n+ } else {\n+ this.writeNode(\"wps:Execute\", body, node);\n+ }\n+ return node;\n+ }\n+ },\n+ \"wcs\": OpenLayers.Format.WCSGetCoverage.prototype.writers.wcs,\n+ \"wfs\": OpenLayers.Format.WFST.v1_1_0.prototype.writers.wfs,\n+ \"ogc\": OpenLayers.Format.Filter.v1_1_0.prototype.writers.ogc,\n+ \"ows\": OpenLayers.Format.OWSCommon.v1_1_0.prototype.writers.ows\n+ },\n \n- /**\n- * Property: tileCacheIndex\n- * {Array(String)} URLs of cached tiles. First entry is the least recently\n- * used.\n- */\n- tileCacheIndex: null,\n+ /**\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n+ */\n+ readers: {\n+ \"wps\": {\n+ \"ExecuteResponse\": function(node, obj) {\n+ obj.executeResponse = {\n+ lang: node.getAttribute(\"lang\"),\n+ statusLocation: node.getAttribute(\"statusLocation\"),\n+ serviceInstance: node.getAttribute(\"serviceInstance\"),\n+ service: node.getAttribute(\"service\")\n+ };\n+ this.readChildNodes(node, obj.executeResponse);\n+ },\n+ \"Process\": function(node, obj) {\n+ obj.process = {};\n+ this.readChildNodes(node, obj.process);\n+ },\n+ \"Status\": function(node, obj) {\n+ obj.status = {\n+ creationTime: node.getAttribute(\"creationTime\")\n+ };\n+ this.readChildNodes(node, obj.status);\n+ },\n+ \"ProcessSucceeded\": function(node, obj) {\n+ obj.processSucceeded = true;\n+ },\n+ \"ProcessOutputs\": function(node, processDescription) {\n+ processDescription.processOutputs = [];\n+ this.readChildNodes(node, processDescription.processOutputs);\n+ },\n+ \"Output\": function(node, processOutputs) {\n+ var output = {};\n+ this.readChildNodes(node, output);\n+ processOutputs.push(output);\n+ },\n+ \"Reference\": function(node, output) {\n+ output.reference = {\n+ href: node.getAttribute(\"href\"),\n+ mimeType: node.getAttribute(\"mimeType\"),\n+ encoding: node.getAttribute(\"encoding\"),\n+ schema: node.getAttribute(\"schema\")\n+ };\n+ },\n+ \"Data\": function(node, output) {\n+ output.data = {};\n+ this.readChildNodes(node, output);\n+ },\n+ \"LiteralData\": function(node, output) {\n+ output.literalData = {\n+ dataType: node.getAttribute(\"dataType\"),\n+ uom: node.getAttribute(\"uom\"),\n+ value: this.getChildValue(node)\n+ };\n+ },\n+ \"ComplexData\": function(node, output) {\n+ output.complexData = {\n+ mimeType: node.getAttribute(\"mimeType\"),\n+ schema: node.getAttribute(\"schema\"),\n+ encoding: node.getAttribute(\"encoding\"),\n+ value: \"\"\n+ };\n \n- /** \n- * Constructor: OpenLayers.TileManager\n- * Constructor for a new instance.\n- * \n- * Parameters:\n- * options - {Object} Configuration for this instance.\n- */\n- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n- this.maps = [];\n- this.tileQueueId = {};\n- this.tileQueue = {};\n- this.tileCache = {};\n- this.tileCacheIndex = [];\n- },\n+ // try to get *some* value, ignore the empty text values\n+ if (this.isSimpleContent(node)) {\n+ var child;\n+ for (child = node.firstChild; child; child = child.nextSibling) {\n+ switch (child.nodeType) {\n+ case 3: // text node\n+ case 4: // cdata section\n+ output.complexData.value += child.nodeValue;\n+ }\n+ }\n+ } else {\n+ for (child = node.firstChild; child; child = child.nextSibling) {\n+ if (child.nodeType == 1) {\n+ output.complexData.value = child;\n+ }\n+ }\n+ }\n \n- /**\n- * Method: addMap\n- * Binds this instance to a map\n- *\n- * Parameters:\n- * map - {}\n- */\n- addMap: function(map) {\n- if (this._destroyed || !OpenLayers.Layer.Grid) {\n- return;\n- }\n- this.maps.push(map);\n- this.tileQueue[map.id] = [];\n- for (var i = 0, ii = map.layers.length; i < ii; ++i) {\n- this.addLayer({\n- layer: map.layers[i]\n- });\n+ },\n+ \"BoundingBox\": function(node, output) {\n+ output.boundingBoxData = {\n+ dimensions: node.getAttribute(\"dimensions\"),\n+ crs: node.getAttribute(\"crs\")\n+ };\n+ this.readChildNodes(node, output.boundingBoxData);\n+ }\n+ },\n+\n+ // TODO: we should add Exception parsing here\n+ \"ows\": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers[\"ows\"]\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Format.WPSExecute\"\n+\n+ });\n+/* ======================================================================\n+ OpenLayers/Request/XMLHttpRequest.js\n+ ====================================================================== */\n+\n+// XMLHttpRequest.js Copyright (C) 2010 Sergey Ilinsky (http://www.ilinsky.com)\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+/**\n+ * @requires OpenLayers/Request.js\n+ */\n+\n+(function() {\n+\n+ // Save reference to earlier defined object implementation (if any)\n+ var oXMLHttpRequest = window.XMLHttpRequest;\n+\n+ // Define on browser type\n+ var bGecko = !!window.controllers,\n+ bIE = window.document.all && !window.opera,\n+ bIE7 = bIE && window.navigator.userAgent.match(/MSIE 7.0/);\n+\n+ // Enables \"XMLHttpRequest()\" call next to \"new XMLHttpReques()\"\n+ function fXMLHttpRequest() {\n+ this._object = oXMLHttpRequest && !bIE7 ? new oXMLHttpRequest : new window.ActiveXObject(\"Microsoft.XMLHTTP\");\n+ this._listeners = [];\n+ };\n+\n+ // Constructor\n+ function cXMLHttpRequest() {\n+ return new fXMLHttpRequest;\n+ };\n+ cXMLHttpRequest.prototype = fXMLHttpRequest.prototype;\n+\n+ // BUGFIX: Firefox with Firebug installed would break pages if not executed\n+ if (bGecko && oXMLHttpRequest.wrapped)\n+ cXMLHttpRequest.wrapped = oXMLHttpRequest.wrapped;\n+\n+ // Constants\n+ cXMLHttpRequest.UNSENT = 0;\n+ cXMLHttpRequest.OPENED = 1;\n+ cXMLHttpRequest.HEADERS_RECEIVED = 2;\n+ cXMLHttpRequest.LOADING = 3;\n+ cXMLHttpRequest.DONE = 4;\n+\n+ // Public Properties\n+ cXMLHttpRequest.prototype.readyState = cXMLHttpRequest.UNSENT;\n+ cXMLHttpRequest.prototype.responseText = '';\n+ cXMLHttpRequest.prototype.responseXML = null;\n+ cXMLHttpRequest.prototype.status = 0;\n+ cXMLHttpRequest.prototype.statusText = '';\n+\n+ // Priority proposal\n+ cXMLHttpRequest.prototype.priority = \"NORMAL\";\n+\n+ // Instance-level Events Handlers\n+ cXMLHttpRequest.prototype.onreadystatechange = null;\n+\n+ // Class-level Events Handlers\n+ cXMLHttpRequest.onreadystatechange = null;\n+ cXMLHttpRequest.onopen = null;\n+ cXMLHttpRequest.onsend = null;\n+ cXMLHttpRequest.onabort = null;\n+\n+ // Public Methods\n+ cXMLHttpRequest.prototype.open = function(sMethod, sUrl, bAsync, sUser, sPassword) {\n+ // Delete headers, required when object is reused\n+ delete this._headers;\n+\n+ // When bAsync parameter value is omitted, use true as default\n+ if (arguments.length < 3)\n+ bAsync = true;\n+\n+ // Save async parameter for fixing Gecko bug with missing readystatechange in synchronous requests\n+ this._async = bAsync;\n+\n+ // Set the onreadystatechange handler\n+ var oRequest = this,\n+ nState = this.readyState,\n+ fOnUnload;\n+\n+ // BUGFIX: IE - memory leak on page unload (inter-page leak)\n+ if (bIE && bAsync) {\n+ fOnUnload = function() {\n+ if (nState != cXMLHttpRequest.DONE) {\n+ fCleanTransport(oRequest);\n+ // Safe to abort here since onreadystatechange handler removed\n+ oRequest.abort();\n+ }\n+ };\n+ window.attachEvent(\"onunload\", fOnUnload);\n }\n- map.events.on({\n- move: this.move,\n- zoomend: this.zoomEnd,\n- changelayer: this.changeLayer,\n- addlayer: this.addLayer,\n- preremovelayer: this.removeLayer,\n- scope: this\n- });\n- },\n \n- /**\n- * Method: removeMap\n- * Unbinds this instance from a map\n- *\n- * Parameters:\n- * map - {}\n- */\n- removeMap: function(map) {\n- if (this._destroyed || !OpenLayers.Layer.Grid) {\n- return;\n+ // Add method sniffer\n+ if (cXMLHttpRequest.onopen)\n+ cXMLHttpRequest.onopen.apply(this, arguments);\n+\n+ if (arguments.length > 4)\n+ this._object.open(sMethod, sUrl, bAsync, sUser, sPassword);\n+ else\n+ if (arguments.length > 3)\n+ this._object.open(sMethod, sUrl, bAsync, sUser);\n+ else\n+ this._object.open(sMethod, sUrl, bAsync);\n+\n+ this.readyState = cXMLHttpRequest.OPENED;\n+ fReadyStateChange(this);\n+\n+ this._object.onreadystatechange = function() {\n+ if (bGecko && !bAsync)\n+ return;\n+\n+ // Synchronize state\n+ oRequest.readyState = oRequest._object.readyState;\n+\n+ //\n+ fSynchronizeValues(oRequest);\n+\n+ // BUGFIX: Firefox fires unnecessary DONE when aborting\n+ if (oRequest._aborted) {\n+ // Reset readyState to UNSENT\n+ oRequest.readyState = cXMLHttpRequest.UNSENT;\n+\n+ // Return now\n+ return;\n+ }\n+\n+ if (oRequest.readyState == cXMLHttpRequest.DONE) {\n+ // Free up queue\n+ delete oRequest._data;\n+ /* if (bAsync)\n+ fQueue_remove(oRequest);*/\n+ //\n+ fCleanTransport(oRequest);\n+ // Uncomment this block if you need a fix for IE cache\n+ /*\n+ // BUGFIX: IE - cache issue\n+ if (!oRequest._object.getResponseHeader(\"Date\")) {\n+ // Save object to cache\n+ oRequest._cached = oRequest._object;\n+\n+ // Instantiate a new transport object\n+ cXMLHttpRequest.call(oRequest);\n+\n+ // Re-send request\n+ if (sUser) {\n+ if (sPassword)\n+ oRequest._object.open(sMethod, sUrl, bAsync, sUser, sPassword);\n+ else\n+ oRequest._object.open(sMethod, sUrl, bAsync, sUser);\n+ }\n+ else\n+ oRequest._object.open(sMethod, sUrl, bAsync);\n+ oRequest._object.setRequestHeader(\"If-Modified-Since\", oRequest._cached.getResponseHeader(\"Last-Modified\") || new window.Date(0));\n+ // Copy headers set\n+ if (oRequest._headers)\n+ for (var sHeader in oRequest._headers)\n+ if (typeof oRequest._headers[sHeader] == \"string\") // Some frameworks prototype objects with functions\n+ oRequest._object.setRequestHeader(sHeader, oRequest._headers[sHeader]);\n+\n+ oRequest._object.onreadystatechange = function() {\n+ // Synchronize state\n+ oRequest.readyState = oRequest._object.readyState;\n+\n+ if (oRequest._aborted) {\n+ //\n+ oRequest.readyState = cXMLHttpRequest.UNSENT;\n+\n+ // Return\n+ return;\n+ }\n+\n+ if (oRequest.readyState == cXMLHttpRequest.DONE) {\n+ // Clean Object\n+ fCleanTransport(oRequest);\n+\n+ // get cached request\n+ if (oRequest.status == 304)\n+ oRequest._object = oRequest._cached;\n+\n+ //\n+ delete oRequest._cached;\n+\n+ //\n+ fSynchronizeValues(oRequest);\n+\n+ //\n+ fReadyStateChange(oRequest);\n+\n+ // BUGFIX: IE - memory leak in interrupted\n+ if (bIE && bAsync)\n+ window.detachEvent(\"onunload\", fOnUnload);\n+ }\n+ };\n+ oRequest._object.send(null);\n+\n+ // Return now - wait until re-sent request is finished\n+ return;\n+ };\n+ */\n+ // BUGFIX: IE - memory leak in interrupted\n+ if (bIE && bAsync)\n+ window.detachEvent(\"onunload\", fOnUnload);\n+ }\n+\n+ // BUGFIX: Some browsers (Internet Explorer, Gecko) fire OPEN readystate twice\n+ if (nState != oRequest.readyState)\n+ fReadyStateChange(oRequest);\n+\n+ nState = oRequest.readyState;\n }\n- window.clearTimeout(this.tileQueueId[map.id]);\n- if (map.layers) {\n- for (var i = 0, ii = map.layers.length; i < ii; ++i) {\n- this.removeLayer({\n- layer: map.layers[i]\n- });\n+ };\n+\n+ function fXMLHttpRequest_send(oRequest) {\n+ oRequest._object.send(oRequest._data);\n+\n+ // BUGFIX: Gecko - missing readystatechange calls in synchronous requests\n+ if (bGecko && !oRequest._async) {\n+ oRequest.readyState = cXMLHttpRequest.OPENED;\n+\n+ // Synchronize state\n+ fSynchronizeValues(oRequest);\n+\n+ // Simulate missing states\n+ while (oRequest.readyState < cXMLHttpRequest.DONE) {\n+ oRequest.readyState++;\n+ fReadyStateChange(oRequest);\n+ // Check if we are aborted\n+ if (oRequest._aborted)\n+ return;\n }\n }\n- if (map.events) {\n- map.events.un({\n- move: this.move,\n- zoomend: this.zoomEnd,\n- changelayer: this.changeLayer,\n- addlayer: this.addLayer,\n- preremovelayer: this.removeLayer,\n- scope: this\n- });\n+ };\n+ cXMLHttpRequest.prototype.send = function(vData) {\n+ // Add method sniffer\n+ if (cXMLHttpRequest.onsend)\n+ cXMLHttpRequest.onsend.apply(this, arguments);\n+\n+ if (!arguments.length)\n+ vData = null;\n+\n+ // BUGFIX: Safari - fails sending documents created/modified dynamically, so an explicit serialization required\n+ // BUGFIX: IE - rewrites any custom mime-type to \"text/xml\" in case an XMLNode is sent\n+ // BUGFIX: Gecko - fails sending Element (this is up to the implementation either to standard)\n+ if (vData && vData.nodeType) {\n+ vData = window.XMLSerializer ? new window.XMLSerializer().serializeToString(vData) : vData.xml;\n+ if (!this._headers[\"Content-Type\"])\n+ this._object.setRequestHeader(\"Content-Type\", \"application/xml\");\n }\n- delete this.tileQueue[map.id];\n- delete this.tileQueueId[map.id];\n- OpenLayers.Util.removeItem(this.maps, map);\n- },\n \n+ this._data = vData;\n+ /*\n+ // Add to queue\n+ if (this._async)\n+ fQueue_add(this);\n+ else*/\n+ fXMLHttpRequest_send(this);\n+ };\n+ cXMLHttpRequest.prototype.abort = function() {\n+ // Add method sniffer\n+ if (cXMLHttpRequest.onabort)\n+ cXMLHttpRequest.onabort.apply(this, arguments);\n+\n+ // BUGFIX: Gecko - unnecessary DONE when aborting\n+ if (this.readyState > cXMLHttpRequest.UNSENT)\n+ this._aborted = true;\n+\n+ this._object.abort();\n+\n+ // BUGFIX: IE - memory leak\n+ fCleanTransport(this);\n+\n+ this.readyState = cXMLHttpRequest.UNSENT;\n+\n+ delete this._data;\n+ /* if (this._async)\n+ fQueue_remove(this);*/\n+ };\n+ cXMLHttpRequest.prototype.getAllResponseHeaders = function() {\n+ return this._object.getAllResponseHeaders();\n+ };\n+ cXMLHttpRequest.prototype.getResponseHeader = function(sName) {\n+ return this._object.getResponseHeader(sName);\n+ };\n+ cXMLHttpRequest.prototype.setRequestHeader = function(sName, sValue) {\n+ // BUGFIX: IE - cache issue\n+ if (!this._headers)\n+ this._headers = {};\n+ this._headers[sName] = sValue;\n+\n+ return this._object.setRequestHeader(sName, sValue);\n+ };\n+\n+ // EventTarget interface implementation\n+ cXMLHttpRequest.prototype.addEventListener = function(sName, fHandler, bUseCapture) {\n+ for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)\n+ if (oListener[0] == sName && oListener[1] == fHandler && oListener[2] == bUseCapture)\n+ return;\n+ // Add listener\n+ this._listeners.push([sName, fHandler, bUseCapture]);\n+ };\n+\n+ cXMLHttpRequest.prototype.removeEventListener = function(sName, fHandler, bUseCapture) {\n+ for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)\n+ if (oListener[0] == sName && oListener[1] == fHandler && oListener[2] == bUseCapture)\n+ break;\n+ // Remove listener\n+ if (oListener)\n+ this._listeners.splice(nIndex, 1);\n+ };\n+\n+ cXMLHttpRequest.prototype.dispatchEvent = function(oEvent) {\n+ var oEventPseudo = {\n+ 'type': oEvent.type,\n+ 'target': this,\n+ 'currentTarget': this,\n+ 'eventPhase': 2,\n+ 'bubbles': oEvent.bubbles,\n+ 'cancelable': oEvent.cancelable,\n+ 'timeStamp': oEvent.timeStamp,\n+ 'stopPropagation': function() {}, // There is no flow\n+ 'preventDefault': function() {}, // There is no default action\n+ 'initEvent': function() {} // Original event object should be initialized\n+ };\n+\n+ // Execute onreadystatechange\n+ if (oEventPseudo.type == \"readystatechange\" && this.onreadystatechange)\n+ (this.onreadystatechange.handleEvent || this.onreadystatechange).apply(this, [oEventPseudo]);\n+\n+ // Execute listeners\n+ for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)\n+ if (oListener[0] == oEventPseudo.type && !oListener[2])\n+ (oListener[1].handleEvent || oListener[1]).apply(this, [oEventPseudo]);\n+ };\n+\n+ //\n+ cXMLHttpRequest.prototype.toString = function() {\n+ return '[' + \"object\" + ' ' + \"XMLHttpRequest\" + ']';\n+ };\n+\n+ cXMLHttpRequest.toString = function() {\n+ return '[' + \"XMLHttpRequest\" + ']';\n+ };\n+\n+ // Helper function\n+ function fReadyStateChange(oRequest) {\n+ // Sniffing code\n+ if (cXMLHttpRequest.onreadystatechange)\n+ cXMLHttpRequest.onreadystatechange.apply(oRequest);\n+\n+ // Fake event\n+ oRequest.dispatchEvent({\n+ 'type': \"readystatechange\",\n+ 'bubbles': false,\n+ 'cancelable': false,\n+ 'timeStamp': new Date + 0\n+ });\n+ };\n+\n+ function fGetDocument(oRequest) {\n+ var oDocument = oRequest.responseXML,\n+ sResponse = oRequest.responseText;\n+ // Try parsing responseText\n+ if (bIE && sResponse && oDocument && !oDocument.documentElement && oRequest.getResponseHeader(\"Content-Type\").match(/[^\\/]+\\/[^\\+]+\\+xml/)) {\n+ oDocument = new window.ActiveXObject(\"Microsoft.XMLDOM\");\n+ oDocument.async = false;\n+ oDocument.validateOnParse = false;\n+ oDocument.loadXML(sResponse);\n+ }\n+ // Check if there is no error in document\n+ if (oDocument)\n+ if ((bIE && oDocument.parseError != 0) || !oDocument.documentElement || (oDocument.documentElement && oDocument.documentElement.tagName == \"parsererror\"))\n+ return null;\n+ return oDocument;\n+ };\n+\n+ function fSynchronizeValues(oRequest) {\n+ try {\n+ oRequest.responseText = oRequest._object.responseText;\n+ } catch (e) {}\n+ try {\n+ oRequest.responseXML = fGetDocument(oRequest._object);\n+ } catch (e) {}\n+ try {\n+ oRequest.status = oRequest._object.status;\n+ } catch (e) {}\n+ try {\n+ oRequest.statusText = oRequest._object.statusText;\n+ } catch (e) {}\n+ };\n+\n+ function fCleanTransport(oRequest) {\n+ // BUGFIX: IE - memory leak (on-page leak)\n+ oRequest._object.onreadystatechange = new window.Function;\n+ };\n+ /*\n+ // Queue manager\n+ var oQueuePending = {\"CRITICAL\":[],\"HIGH\":[],\"NORMAL\":[],\"LOW\":[],\"LOWEST\":[]},\n+ aQueueRunning = [];\n+ function fQueue_add(oRequest) {\n+ oQueuePending[oRequest.priority in oQueuePending ? oRequest.priority : \"NORMAL\"].push(oRequest);\n+ //\n+ setTimeout(fQueue_process);\n+ };\n+\n+ function fQueue_remove(oRequest) {\n+ for (var nIndex = 0, bFound = false; nIndex < aQueueRunning.length; nIndex++)\n+ if (bFound)\n+ aQueueRunning[nIndex - 1] = aQueueRunning[nIndex];\n+ else\n+ if (aQueueRunning[nIndex] == oRequest)\n+ bFound = true;\n+ if (bFound)\n+ aQueueRunning.length--;\n+ //\n+ setTimeout(fQueue_process);\n+ };\n+\n+ function fQueue_process() {\n+ if (aQueueRunning.length < 6) {\n+ for (var sPriority in oQueuePending) {\n+ if (oQueuePending[sPriority].length) {\n+ var oRequest = oQueuePending[sPriority][0];\n+ oQueuePending[sPriority] = oQueuePending[sPriority].slice(1);\n+ //\n+ aQueueRunning.push(oRequest);\n+ // Send request\n+ fXMLHttpRequest_send(oRequest);\n+ break;\n+ }\n+ }\n+ }\n+ };\n+ */\n+ // Internet Explorer 5.0 (missing apply)\n+ if (!window.Function.prototype.apply) {\n+ window.Function.prototype.apply = function(oRequest, oArguments) {\n+ if (!oArguments)\n+ oArguments = [];\n+ oRequest.__func = this;\n+ oRequest.__func(oArguments[0], oArguments[1], oArguments[2], oArguments[3], oArguments[4]);\n+ delete oRequest.__func;\n+ };\n+ };\n+\n+ // Register new object with window\n /**\n- * Method: move\n- * Handles the map's move event\n- *\n- * Parameters:\n- * evt - {Object} Listener argument\n+ * Class: OpenLayers.Request.XMLHttpRequest\n+ * Standard-compliant (W3C) cross-browser implementation of the\n+ * XMLHttpRequest object. From\n+ * http://code.google.com/p/xmlhttprequest/.\n */\n- move: function(evt) {\n- this.updateTimeout(evt.object, this.moveDelay, true);\n- },\n+ if (!OpenLayers.Request) {\n+ /**\n+ * This allows for OpenLayers/Request.js to be included\n+ * before or after this script.\n+ */\n+ OpenLayers.Request = {};\n+ }\n+ OpenLayers.Request.XMLHttpRequest = cXMLHttpRequest;\n+})();\n+/* ======================================================================\n+ OpenLayers/Request.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Events.js\n+ * @requires OpenLayers/Request/XMLHttpRequest.js\n+ */\n+\n+/**\n+ * TODO: deprecate me\n+ * Use OpenLayers.Request.proxy instead.\n+ */\n+OpenLayers.ProxyHost = \"\";\n \n+/**\n+ * Namespace: OpenLayers.Request\n+ * The OpenLayers.Request namespace contains convenience methods for working\n+ * with XMLHttpRequests. These methods work with a cross-browser\n+ * W3C compliant class.\n+ */\n+if (!OpenLayers.Request) {\n /**\n- * Method: zoomEnd\n- * Handles the map's zoomEnd event\n- *\n- * Parameters:\n- * evt - {Object} Listener argument\n+ * This allows for OpenLayers/Request/XMLHttpRequest.js to be included\n+ * before or after this script.\n */\n- zoomEnd: function(evt) {\n- this.updateTimeout(evt.object, this.zoomDelay);\n+ OpenLayers.Request = {};\n+}\n+OpenLayers.Util.extend(OpenLayers.Request, {\n+\n+ /**\n+ * Constant: DEFAULT_CONFIG\n+ * {Object} Default configuration for all requests.\n+ */\n+ DEFAULT_CONFIG: {\n+ method: \"GET\",\n+ url: window.location.href,\n+ async: true,\n+ user: undefined,\n+ password: undefined,\n+ params: null,\n+ proxy: OpenLayers.ProxyHost,\n+ headers: {},\n+ data: null,\n+ callback: function() {},\n+ success: null,\n+ failure: null,\n+ scope: null\n },\n \n /**\n- * Method: changeLayer\n- * Handles the map's changeLayer event\n+ * Constant: URL_SPLIT_REGEX\n+ */\n+ URL_SPLIT_REGEX: /([^:]*:)\\/\\/([^:]*:?[^@]*@)?([^:\\/\\?]*):?([^\\/\\?]*)/,\n+\n+ /**\n+ * APIProperty: events\n+ * {} An events object that handles all \n+ * events on the {} object.\n *\n- * Parameters:\n- * evt - {Object} Listener argument\n+ * All event listeners will receive an event object with three properties:\n+ * request - {} The request object.\n+ * config - {Object} The config object sent to the specific request method.\n+ * requestUrl - {String} The request url.\n+ * \n+ * Supported event types:\n+ * complete - Triggered when we have a response from the request, if a\n+ * listener returns false, no further response processing will take\n+ * place.\n+ * success - Triggered when the HTTP response has a success code (200-299).\n+ * failure - Triggered when the HTTP response does not have a success code.\n */\n- changeLayer: function(evt) {\n- if (evt.property === 'visibility' || evt.property === 'params') {\n- this.updateTimeout(evt.object, 0);\n- }\n- },\n+ events: new OpenLayers.Events(this),\n \n /**\n- * Method: addLayer\n- * Handles the map's addlayer event\n+ * Method: makeSameOrigin\n+ * Using the specified proxy, returns a same origin url of the provided url.\n *\n * Parameters:\n- * evt - {Object} The listener argument\n+ * url - {String} An arbitrary url\n+ * proxy {String|Function} The proxy to use to make the provided url a\n+ * same origin url.\n+ *\n+ * Returns\n+ * {String} the same origin url. If no proxy is provided, the returned url\n+ * will be the same as the provided url.\n */\n- addLayer: function(evt) {\n- var layer = evt.layer;\n- if (layer instanceof OpenLayers.Layer.Grid) {\n- layer.events.on({\n- addtile: this.addTile,\n- retile: this.clearTileQueue,\n- scope: this\n- });\n- var i, j, tile;\n- for (i = layer.grid.length - 1; i >= 0; --i) {\n- for (j = layer.grid[i].length - 1; j >= 0; --j) {\n- tile = layer.grid[i][j];\n- this.addTile({\n- tile: tile\n- });\n- if (tile.url && !tile.imgDiv) {\n- this.manageTileCache({\n- object: tile\n- });\n- }\n+ makeSameOrigin: function(url, proxy) {\n+ var sameOrigin = url.indexOf(\"http\") !== 0;\n+ var urlParts = !sameOrigin && url.match(this.URL_SPLIT_REGEX);\n+ if (urlParts) {\n+ var location = window.location;\n+ sameOrigin =\n+ urlParts[1] == location.protocol &&\n+ urlParts[3] == location.hostname;\n+ var uPort = urlParts[4],\n+ lPort = location.port;\n+ if (uPort != 80 && uPort != \"\" || lPort != \"80\" && lPort != \"\") {\n+ sameOrigin = sameOrigin && uPort == lPort;\n+ }\n+ }\n+ if (!sameOrigin) {\n+ if (proxy) {\n+ if (typeof proxy == \"function\") {\n+ url = proxy(url);\n+ } else {\n+ url = proxy + encodeURIComponent(url);\n }\n }\n }\n+ return url;\n },\n \n /**\n- * Method: removeLayer\n- * Handles the map's preremovelayer event\n+ * APIMethod: issue\n+ * Create a new XMLHttpRequest object, open it, set any headers, bind\n+ * a callback to done state, and send any data. It is recommended that\n+ * you use one , , , , , or .\n+ * This method is only documented to provide detail on the configuration\n+ * options available to all request methods.\n *\n * Parameters:\n- * evt - {Object} The listener argument\n+ * config - {Object} Object containing properties for configuring the\n+ * request. Allowed configuration properties are described below.\n+ * This object is modified and should not be reused.\n+ *\n+ * Allowed config properties:\n+ * method - {String} One of GET, POST, PUT, DELETE, HEAD, or\n+ * OPTIONS. Default is GET.\n+ * url - {String} URL for the request.\n+ * async - {Boolean} Open an asynchronous request. Default is true.\n+ * user - {String} User for relevant authentication scheme. Set\n+ * to null to clear current user.\n+ * password - {String} Password for relevant authentication scheme.\n+ * Set to null to clear current password.\n+ * proxy - {String} Optional proxy. Defaults to\n+ * .\n+ * params - {Object} Any key:value pairs to be appended to the\n+ * url as a query string. Assumes url doesn't already include a query\n+ * string or hash. Typically, this is only appropriate for \n+ * requests where the query string will be appended to the url.\n+ * Parameter values that are arrays will be\n+ * concatenated with a comma (note that this goes against form-encoding)\n+ * as is done with .\n+ * headers - {Object} Object with header:value pairs to be set on\n+ * the request.\n+ * data - {String | Document} Optional data to send with the request.\n+ * Typically, this is only used with and requests.\n+ * Make sure to provide the appropriate \"Content-Type\" header for your\n+ * data. For and requests, the content type defaults to\n+ * \"application-xml\". If your data is a different content type, or\n+ * if you are using a different HTTP method, set the \"Content-Type\"\n+ * header to match your data type.\n+ * callback - {Function} Function to call when request is done.\n+ * To determine if the request failed, check request.status (200\n+ * indicates success).\n+ * success - {Function} Optional function to call if request status is in\n+ * the 200s. This will be called in addition to callback above and\n+ * would typically only be used as an alternative.\n+ * failure - {Function} Optional function to call if request status is not\n+ * in the 200s. This will be called in addition to callback above and\n+ * would typically only be used as an alternative.\n+ * scope - {Object} If callback is a public method on some object,\n+ * set the scope to that object.\n+ *\n+ * Returns:\n+ * {XMLHttpRequest} Request object. To abort the request before a response\n+ * is received, call abort() on the request object.\n */\n- removeLayer: function(evt) {\n- var layer = evt.layer;\n- if (layer instanceof OpenLayers.Layer.Grid) {\n- this.clearTileQueue({\n- object: layer\n- });\n- if (layer.events) {\n- layer.events.un({\n- addtile: this.addTile,\n- retile: this.clearTileQueue,\n- scope: this\n- });\n+ issue: function(config) {\n+ // apply default config - proxy host may have changed\n+ var defaultConfig = OpenLayers.Util.extend(\n+ this.DEFAULT_CONFIG, {\n+ proxy: OpenLayers.ProxyHost\n }\n- if (layer.grid) {\n- var i, j, tile;\n- for (i = layer.grid.length - 1; i >= 0; --i) {\n- for (j = layer.grid[i].length - 1; j >= 0; --j) {\n- tile = layer.grid[i][j];\n- this.unloadTile({\n- object: tile\n- });\n- }\n+ );\n+ config = config || {};\n+ config.headers = config.headers || {};\n+ config = OpenLayers.Util.applyDefaults(config, defaultConfig);\n+ config.headers = OpenLayers.Util.applyDefaults(config.headers, defaultConfig.headers);\n+ // Always set the \"X-Requested-With\" header to signal that this request\n+ // was issued through the XHR-object. Since header keys are case \n+ // insensitive and we want to allow overriding of the \"X-Requested-With\"\n+ // header through the user we cannot use applyDefaults, but have to \n+ // check manually whether we were called with a \"X-Requested-With\"\n+ // header.\n+ var customRequestedWithHeader = false,\n+ headerKey;\n+ for (headerKey in config.headers) {\n+ if (config.headers.hasOwnProperty(headerKey)) {\n+ if (headerKey.toLowerCase() === 'x-requested-with') {\n+ customRequestedWithHeader = true;\n }\n }\n }\n- },\n+ if (customRequestedWithHeader === false) {\n+ // we did not have a custom \"X-Requested-With\" header\n+ config.headers['X-Requested-With'] = 'XMLHttpRequest';\n+ }\n \n- /**\n- * Method: updateTimeout\n- * Applies the or to the loop,\n- * and schedules more queue processing after if there are still\n- * tiles in the queue.\n- *\n- * Parameters:\n- * map - {} The map to update the timeout for\n- * delay - {Number} The delay to apply\n- * nice - {Boolean} If true, the timeout function will only be created if\n- * the tilequeue is not empty. This is used by the move handler to\n- * avoid impacts on dragging performance. For other events, the tile\n- * queue may not be populated yet, so we need to set the timer\n- * regardless of the queue size.\n- */\n- updateTimeout: function(map, delay, nice) {\n- window.clearTimeout(this.tileQueueId[map.id]);\n- var tileQueue = this.tileQueue[map.id];\n- if (!nice || tileQueue.length) {\n- this.tileQueueId[map.id] = window.setTimeout(\n- OpenLayers.Function.bind(function() {\n- this.drawTilesFromQueue(map);\n- if (tileQueue.length) {\n- this.updateTimeout(map, this.frameDelay);\n+ // create request, open, and set headers\n+ var request = new OpenLayers.Request.XMLHttpRequest();\n+ var url = OpenLayers.Util.urlAppend(config.url,\n+ OpenLayers.Util.getParameterString(config.params || {}));\n+ url = OpenLayers.Request.makeSameOrigin(url, config.proxy);\n+ request.open(\n+ config.method, url, config.async, config.user, config.password\n+ );\n+ for (var header in config.headers) {\n+ request.setRequestHeader(header, config.headers[header]);\n+ }\n+\n+ var events = this.events;\n+\n+ // we want to execute runCallbacks with \"this\" as the\n+ // execution scope\n+ var self = this;\n+\n+ request.onreadystatechange = function() {\n+ if (request.readyState == OpenLayers.Request.XMLHttpRequest.DONE) {\n+ var proceed = events.triggerEvent(\n+ \"complete\", {\n+ request: request,\n+ config: config,\n+ requestUrl: url\n }\n- }, this), delay\n- );\n+ );\n+ if (proceed !== false) {\n+ self.runCallbacks({\n+ request: request,\n+ config: config,\n+ requestUrl: url\n+ });\n+ }\n+ }\n+ };\n+\n+ // send request (optionally with data) and return\n+ // call in a timeout for asynchronous requests so the return is\n+ // available before readyState == 4 for cached docs\n+ if (config.async === false) {\n+ request.send(config.data);\n+ } else {\n+ window.setTimeout(function() {\n+ if (request.readyState !== 0) { // W3C: 0-UNSENT\n+ request.send(config.data);\n+ }\n+ }, 0);\n }\n+ return request;\n },\n \n /**\n- * Method: addTile\n- * Listener for the layer's addtile event\n+ * Method: runCallbacks\n+ * Calls the complete, success and failure callbacks. Application\n+ * can listen to the \"complete\" event, have the listener \n+ * display a confirm window and always return false, and\n+ * execute OpenLayers.Request.runCallbacks if the user\n+ * hits \"yes\" in the confirm window.\n *\n * Parameters:\n- * evt - {Object} The listener argument\n+ * options - {Object} Hash containing request, config and requestUrl keys\n */\n- addTile: function(evt) {\n- if (evt.tile instanceof OpenLayers.Tile.Image) {\n- evt.tile.events.on({\n- beforedraw: this.queueTileDraw,\n- beforeload: this.manageTileCache,\n- loadend: this.addToCache,\n- unload: this.unloadTile,\n- scope: this\n- });\n- } else {\n- // Layer has the wrong tile type, so don't handle it any longer\n- this.removeLayer({\n- layer: evt.tile.layer\n- });\n+ runCallbacks: function(options) {\n+ var request = options.request;\n+ var config = options.config;\n+\n+ // bind callbacks to readyState 4 (done)\n+ var complete = (config.scope) ?\n+ OpenLayers.Function.bind(config.callback, config.scope) :\n+ config.callback;\n+\n+ // optional success callback\n+ var success;\n+ if (config.success) {\n+ success = (config.scope) ?\n+ OpenLayers.Function.bind(config.success, config.scope) :\n+ config.success;\n+ }\n+\n+ // optional failure callback\n+ var failure;\n+ if (config.failure) {\n+ failure = (config.scope) ?\n+ OpenLayers.Function.bind(config.failure, config.scope) :\n+ config.failure;\n+ }\n+\n+ if (OpenLayers.Util.createUrlObject(config.url).protocol == \"file:\" &&\n+ request.responseText) {\n+ request.status = 200;\n+ }\n+ complete(request);\n+\n+ if (!request.status || (request.status >= 200 && request.status < 300)) {\n+ this.events.triggerEvent(\"success\", options);\n+ if (success) {\n+ success(request);\n+ }\n+ }\n+ if (request.status && (request.status < 200 || request.status >= 300)) {\n+ this.events.triggerEvent(\"failure\", options);\n+ if (failure) {\n+ failure(request);\n+ }\n }\n },\n \n /**\n- * Method: unloadTile\n- * Listener for the tile's unload event\n+ * APIMethod: GET\n+ * Send an HTTP GET request. Additional configuration properties are\n+ * documented in the method, with the method property set\n+ * to GET.\n *\n * Parameters:\n- * evt - {Object} The listener argument\n+ * config - {Object} Object with properties for configuring the request.\n+ * See the method for documentation of allowed properties.\n+ * This object is modified and should not be reused.\n+ * \n+ * Returns:\n+ * {XMLHttpRequest} Request object.\n */\n- unloadTile: function(evt) {\n- var tile = evt.object;\n- tile.events.un({\n- beforedraw: this.queueTileDraw,\n- beforeload: this.manageTileCache,\n- loadend: this.addToCache,\n- unload: this.unloadTile,\n- scope: this\n+ GET: function(config) {\n+ config = OpenLayers.Util.extend(config, {\n+ method: \"GET\"\n });\n- OpenLayers.Util.removeItem(this.tileQueue[tile.layer.map.id], tile);\n+ return OpenLayers.Request.issue(config);\n },\n \n /**\n- * Method: queueTileDraw\n- * Adds a tile to the queue that will draw it.\n+ * APIMethod: POST\n+ * Send a POST request. Additional configuration properties are\n+ * documented in the method, with the method property set\n+ * to POST and \"Content-Type\" header set to \"application/xml\".\n *\n * Parameters:\n- * evt - {Object} Listener argument of the tile's beforedraw event\n- */\n- queueTileDraw: function(evt) {\n- var tile = evt.object;\n- var queued = false;\n- var layer = tile.layer;\n- var url = layer.getURL(tile.bounds);\n- var img = this.tileCache[url];\n- if (img && img.className !== 'olTileImage') {\n- // cached image no longer valid, e.g. because we're olTileReplacing\n- delete this.tileCache[url];\n- OpenLayers.Util.removeItem(this.tileCacheIndex, url);\n- img = null;\n- }\n- // queue only if image with same url not cached already\n- if (layer.url && (layer.async || !img)) {\n- // add to queue only if not in queue already\n- var tileQueue = this.tileQueue[layer.map.id];\n- if (!~OpenLayers.Util.indexOf(tileQueue, tile)) {\n- tileQueue.push(tile);\n- }\n- queued = true;\n- }\n- return !queued;\n- },\n-\n- /**\n- * Method: drawTilesFromQueue\n- * Draws tiles from the tileQueue, and unqueues the tiles\n+ * config - {Object} Object with properties for configuring the request.\n+ * See the method for documentation of allowed properties. The\n+ * default \"Content-Type\" header will be set to \"application-xml\" if\n+ * none is provided. This object is modified and should not be reused.\n+ * \n+ * Returns:\n+ * {XMLHttpRequest} Request object.\n */\n- drawTilesFromQueue: function(map) {\n- var tileQueue = this.tileQueue[map.id];\n- var limit = this.tilesPerFrame;\n- var animating = map.zoomTween && map.zoomTween.playing;\n- while (!animating && tileQueue.length && limit) {\n- tileQueue.shift().draw(true);\n- --limit;\n+ POST: function(config) {\n+ config = OpenLayers.Util.extend(config, {\n+ method: \"POST\"\n+ });\n+ // set content type to application/xml if it isn't already set\n+ config.headers = config.headers ? config.headers : {};\n+ if (!(\"CONTENT-TYPE\" in OpenLayers.Util.upperCaseObject(config.headers))) {\n+ config.headers[\"Content-Type\"] = \"application/xml\";\n }\n+ return OpenLayers.Request.issue(config);\n },\n \n /**\n- * Method: manageTileCache\n- * Adds, updates, removes and fetches cache entries.\n+ * APIMethod: PUT\n+ * Send an HTTP PUT request. Additional configuration properties are\n+ * documented in the method, with the method property set\n+ * to PUT and \"Content-Type\" header set to \"application/xml\".\n *\n * Parameters:\n- * evt - {Object} Listener argument of the tile's beforeload event\n+ * config - {Object} Object with properties for configuring the request.\n+ * See the method for documentation of allowed properties. The\n+ * default \"Content-Type\" header will be set to \"application-xml\" if\n+ * none is provided. This object is modified and should not be reused.\n+ * \n+ * Returns:\n+ * {XMLHttpRequest} Request object.\n */\n- manageTileCache: function(evt) {\n- var tile = evt.object;\n- var img = this.tileCache[tile.url];\n- if (img) {\n- // if image is on its layer's backbuffer, remove it from backbuffer\n- if (img.parentNode &&\n- OpenLayers.Element.hasClass(img.parentNode, 'olBackBuffer')) {\n- img.parentNode.removeChild(img);\n- img.id = null;\n- }\n- // only use image from cache if it is not on a layer already\n- if (!img.parentNode) {\n- img.style.visibility = 'hidden';\n- img.style.opacity = 0;\n- tile.setImage(img);\n- // LRU - move tile to the end of the array to mark it as the most\n- // recently used\n- OpenLayers.Util.removeItem(this.tileCacheIndex, tile.url);\n- this.tileCacheIndex.push(tile.url);\n- }\n+ PUT: function(config) {\n+ config = OpenLayers.Util.extend(config, {\n+ method: \"PUT\"\n+ });\n+ // set content type to application/xml if it isn't already set\n+ config.headers = config.headers ? config.headers : {};\n+ if (!(\"CONTENT-TYPE\" in OpenLayers.Util.upperCaseObject(config.headers))) {\n+ config.headers[\"Content-Type\"] = \"application/xml\";\n }\n+ return OpenLayers.Request.issue(config);\n },\n \n /**\n- * Method: addToCache\n+ * APIMethod: DELETE\n+ * Send an HTTP DELETE request. Additional configuration properties are\n+ * documented in the method, with the method property set\n+ * to DELETE.\n *\n * Parameters:\n- * evt - {Object} Listener argument for the tile's loadend event\n+ * config - {Object} Object with properties for configuring the request.\n+ * See the method for documentation of allowed properties.\n+ * This object is modified and should not be reused.\n+ * \n+ * Returns:\n+ * {XMLHttpRequest} Request object.\n */\n- addToCache: function(evt) {\n- var tile = evt.object;\n- if (!this.tileCache[tile.url]) {\n- if (!OpenLayers.Element.hasClass(tile.imgDiv, 'olImageLoadError')) {\n- if (this.tileCacheIndex.length >= this.cacheSize) {\n- delete this.tileCache[this.tileCacheIndex[0]];\n- this.tileCacheIndex.shift();\n- }\n- this.tileCache[tile.url] = tile.imgDiv;\n- this.tileCacheIndex.push(tile.url);\n- }\n- }\n+ DELETE: function(config) {\n+ config = OpenLayers.Util.extend(config, {\n+ method: \"DELETE\"\n+ });\n+ return OpenLayers.Request.issue(config);\n },\n \n /**\n- * Method: clearTileQueue\n- * Clears the tile queue from tiles of a specific layer\n+ * APIMethod: HEAD\n+ * Send an HTTP HEAD request. Additional configuration properties are\n+ * documented in the method, with the method property set\n+ * to HEAD.\n *\n * Parameters:\n- * evt - {Object} Listener argument of the layer's retile event\n+ * config - {Object} Object with properties for configuring the request.\n+ * See the method for documentation of allowed properties.\n+ * This object is modified and should not be reused.\n+ * \n+ * Returns:\n+ * {XMLHttpRequest} Request object.\n */\n- clearTileQueue: function(evt) {\n- var layer = evt.object;\n- var tileQueue = this.tileQueue[layer.map.id];\n- for (var i = tileQueue.length - 1; i >= 0; --i) {\n- if (tileQueue[i].layer === layer) {\n- tileQueue.splice(i, 1);\n- }\n- }\n+ HEAD: function(config) {\n+ config = OpenLayers.Util.extend(config, {\n+ method: \"HEAD\"\n+ });\n+ return OpenLayers.Request.issue(config);\n },\n \n /**\n- * Method: destroy\n+ * APIMethod: OPTIONS\n+ * Send an HTTP OPTIONS request. Additional configuration properties are\n+ * documented in the method, with the method property set\n+ * to OPTIONS.\n+ *\n+ * Parameters:\n+ * config - {Object} Object with properties for configuring the request.\n+ * See the method for documentation of allowed properties.\n+ * This object is modified and should not be reused.\n+ * \n+ * Returns:\n+ * {XMLHttpRequest} Request object.\n */\n- destroy: function() {\n- for (var i = this.maps.length - 1; i >= 0; --i) {\n- this.removeMap(this.maps[i]);\n- }\n- this.maps = null;\n- this.tileQueue = null;\n- this.tileQueueId = null;\n- this.tileCache = null;\n- this.tileCacheIndex = null;\n- this._destroyed = true;\n+ OPTIONS: function(config) {\n+ config = OpenLayers.Util.extend(config, {\n+ method: \"OPTIONS\"\n+ });\n+ return OpenLayers.Request.issue(config);\n }\n \n });\n /* ======================================================================\n- OpenLayers/Marker/Box.js\n+ OpenLayers/WPSProcess.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+/**\n+ * @requires OpenLayers/SingleFile.js\n+ */\n \n /**\n- * @requires OpenLayers/Marker.js\n+ * @requires OpenLayers/Geometry.js\n+ * @requires OpenLayers/Feature/Vector.js\n+ * @requires OpenLayers/Format/WKT.js\n+ * @requires OpenLayers/Format/GeoJSON.js\n+ * @requires OpenLayers/Format/WPSExecute.js\n+ * @requires OpenLayers/Request.js\n */\n \n /**\n- * Class: OpenLayers.Marker.Box\n+ * Class: OpenLayers.WPSProcess\n+ * Representation of a WPS process. Usually instances of\n+ * are created by calling 'getProcess' on an\n+ * instance.\n *\n- * Inherits from:\n- * - \n+ * Currently supports processes that have geometries\n+ * or features as output, using WKT or GeoJSON as output format. It also\n+ * supports chaining of processes by using the method to create a\n+ * handle that is used as process input instead of a static value.\n */\n-OpenLayers.Marker.Box = OpenLayers.Class(OpenLayers.Marker, {\n+OpenLayers.WPSProcess = OpenLayers.Class({\n \n- /** \n- * Property: bounds \n- * {} \n+ /**\n+ * Property: client\n+ * {} The client that manages this process.\n */\n- bounds: null,\n+ client: null,\n \n- /** \n- * Property: div \n- * {DOMElement} \n+ /**\n+ * Property: server\n+ * {String} Local client identifier for this process's server.\n */\n- div: null,\n+ server: null,\n \n- /** \n- * Constructor: OpenLayers.Marker.Box\n- *\n- * Parameters:\n- * bounds - {} \n- * borderColor - {String} \n- * borderWidth - {int} \n+ /**\n+ * Property: identifier\n+ * {String} Process identifier known to the server.\n */\n- initialize: function(bounds, borderColor, borderWidth) {\n- this.bounds = bounds;\n- this.div = OpenLayers.Util.createDiv();\n- this.div.style.overflow = 'hidden';\n- this.events = new OpenLayers.Events(this, this.div);\n- this.setBorder(borderColor, borderWidth);\n- },\n+ identifier: null,\n \n /**\n- * Method: destroy \n+ * Property: description\n+ * {Object} DescribeProcess response for this process.\n */\n- destroy: function() {\n-\n- this.bounds = null;\n- this.div = null;\n-\n- OpenLayers.Marker.prototype.destroy.apply(this, arguments);\n- },\n+ description: null,\n \n- /** \n- * Method: setBorder\n- * Allow the user to change the box's color and border width\n- * \n- * Parameters:\n- * color - {String} Default is \"red\"\n- * width - {int} Default is 2\n+ /**\n+ * APIProperty: localWPS\n+ * {String} Service endpoint for locally chained WPS processes. Default is\n+ * 'http://geoserver/wps'.\n */\n- setBorder: function(color, width) {\n- if (!color) {\n- color = \"red\";\n- }\n- if (!width) {\n- width = 2;\n- }\n- this.div.style.border = width + \"px solid \" + color;\n- },\n+ localWPS: 'http://geoserver/wps',\n \n- /** \n- * Method: draw\n- * \n- * Parameters:\n- * px - {} \n- * sz - {} \n- * \n- * Returns: \n- * {DOMElement} A new DOM Image with this marker's icon set at the \n- * location passed-in\n+ /**\n+ * Property: formats\n+ * {Object} OpenLayers.Format instances keyed by mimetype.\n */\n- draw: function(px, sz) {\n- OpenLayers.Util.modifyDOMElement(this.div, null, px, sz);\n- return this.div;\n- },\n+ formats: null,\n \n /**\n- * Method: onScreen\n- * \n- * Rreturn:\n- * {Boolean} Whether or not the marker is currently visible on screen.\n+ * Property: chained\n+ * {Integer} Number of chained processes for pending execute requests that\n+ * don't have a full configuration yet.\n */\n- onScreen: function() {\n- var onScreen = false;\n- if (this.map) {\n- var screenBounds = this.map.getExtent();\n- onScreen = screenBounds.containsBounds(this.bounds, true, true);\n- }\n- return onScreen;\n- },\n+ chained: 0,\n \n /**\n- * Method: display\n- * Hide or show the icon\n- * \n- * Parameters:\n- * display - {Boolean} \n+ * Property: executeCallbacks\n+ * {Array} Callbacks waiting to be executed until all chained processes\n+ * are configured;\n */\n- display: function(display) {\n- this.div.style.display = (display) ? \"\" : \"none\";\n- },\n-\n- CLASS_NAME: \"OpenLayers.Marker.Box\"\n-});\n-\n-/* ======================================================================\n- OpenLayers/Strategy/Paging.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Strategy.js\n- */\n-\n-/**\n- * Class: OpenLayers.Strategy.Paging\n- * Strategy for vector feature paging\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Strategy.Paging = OpenLayers.Class(OpenLayers.Strategy, {\n+ executeCallbacks: null,\n \n /**\n- * Property: features\n- * {Array()} Cached features.\n+ * Constructor: OpenLayers.WPSProcess\n+ *\n+ * Parameters:\n+ * options - {Object} Object whose properties will be set on the instance.\n+ *\n+ * Avaliable options:\n+ * client - {} Mandatory. Client that manages this\n+ * process.\n+ * server - {String} Mandatory. Local client identifier of this process's\n+ * server.\n+ * identifier - {String} Mandatory. Process identifier known to the server.\n */\n- features: null,\n+ initialize: function(options) {\n+ OpenLayers.Util.extend(this, options);\n+ this.executeCallbacks = [];\n+ this.formats = {\n+ 'application/wkt': new OpenLayers.Format.WKT(),\n+ 'application/json': new OpenLayers.Format.GeoJSON()\n+ };\n+ },\n \n /**\n- * Property: length\n- * {Integer} Number of features per page. Default is 10.\n+ * Method: describe\n+ * Makes the client issue a DescribeProcess request asynchronously.\n+ *\n+ * Parameters:\n+ * options - {Object} Configuration for the method call\n+ *\n+ * Available options:\n+ * callback - {Function} Callback to execute when the description is\n+ * available. Will be called with the parsed description as argument.\n+ * Optional.\n+ * scope - {Object} The scope in which the callback will be executed.\n+ * Default is the global object.\n */\n- length: 10,\n+ describe: function(options) {\n+ options = options || {};\n+ if (!this.description) {\n+ this.client.describeProcess(this.server, this.identifier, function(description) {\n+ if (!this.description) {\n+ this.parseDescription(description);\n+ }\n+ if (options.callback) {\n+ options.callback.call(options.scope, this.description);\n+ }\n+ }, this);\n+ } else if (options.callback) {\n+ var description = this.description;\n+ window.setTimeout(function() {\n+ options.callback.call(options.scope, description);\n+ }, 0);\n+ }\n+ },\n \n /**\n- * Property: num\n- * {Integer} The currently displayed page number.\n+ * APIMethod: configure\n+ * Configure the process, but do not execute it. Use this for processes\n+ * that are chained as input of a different process by means of the\n+ * method.\n+ *\n+ * Parameters:\n+ * options - {Object}\n+ *\n+ * Returns:\n+ * {} this process.\n+ *\n+ * Available options:\n+ * inputs - {Object} The inputs for the process, keyed by input identifier.\n+ * For spatial data inputs, the value of an input is usually an\n+ * , an or an array of\n+ * geometries or features.\n+ * callback - {Function} Callback to call when the configuration is\n+ * complete. Optional.\n+ * scope - {Object} Optional scope for the callback.\n */\n- num: null,\n+ configure: function(options) {\n+ this.describe({\n+ callback: function() {\n+ var description = this.description,\n+ inputs = options.inputs,\n+ input, i, ii;\n+ for (i = 0, ii = description.dataInputs.length; i < ii; ++i) {\n+ input = description.dataInputs[i];\n+ this.setInputData(input, inputs[input.identifier]);\n+ }\n+ if (options.callback) {\n+ options.callback.call(options.scope);\n+ }\n+ },\n+ scope: this\n+ });\n+ return this;\n+ },\n \n /**\n- * Property: paging\n- * {Boolean} The strategy is currently changing pages.\n+ * APIMethod: execute\n+ * Configures and executes the process\n+ *\n+ * Parameters:\n+ * options - {Object}\n+ *\n+ * Available options:\n+ * inputs - {Object} The inputs for the process, keyed by input identifier.\n+ * For spatial data inputs, the value of an input is usually an\n+ * , an or an array of\n+ * geometries or features.\n+ * output - {String} The identifier of the output to request and parse.\n+ * Optional. If not provided, the first output will be requested.\n+ * success - {Function} Callback to call when the process is complete.\n+ * This function is called with an outputs object as argument, which\n+ * will have a property with the identifier of the requested output\n+ * (or 'result' if output was not configured). For processes that\n+ * generate spatial output, the value will be an array of\n+ * instances.\n+ * scope - {Object} Optional scope for the success callback.\n */\n- paging: false,\n+ execute: function(options) {\n+ this.configure({\n+ inputs: options.inputs,\n+ callback: function() {\n+ var me = this;\n+ //TODO For now we only deal with a single output\n+ var outputIndex = this.getOutputIndex(\n+ me.description.processOutputs, options.output\n+ );\n+ me.setResponseForm({\n+ outputIndex: outputIndex\n+ });\n+ (function callback() {\n+ OpenLayers.Util.removeItem(me.executeCallbacks, callback);\n+ if (me.chained !== 0) {\n+ // need to wait until chained processes have a\n+ // description and configuration - see chainProcess\n+ me.executeCallbacks.push(callback);\n+ return;\n+ }\n+ // all chained processes are added as references now, so\n+ // let's proceed.\n+ OpenLayers.Request.POST({\n+ url: me.client.servers[me.server].url,\n+ data: new OpenLayers.Format.WPSExecute().write(me.description),\n+ success: function(response) {\n+ var output = me.description.processOutputs[outputIndex];\n+ var mimeType = me.findMimeType(\n+ output.complexOutput.supported.formats\n+ );\n+ //TODO For now we assume a spatial output\n+ var features = me.formats[mimeType].read(response.responseText);\n+ if (features instanceof OpenLayers.Feature.Vector) {\n+ features = [features];\n+ }\n+ if (options.success) {\n+ var outputs = {};\n+ outputs[options.output || 'result'] = features;\n+ options.success.call(options.scope, outputs);\n+ }\n+ },\n+ scope: me\n+ });\n+ })();\n+ },\n+ scope: this\n+ });\n+ },\n \n /**\n- * Constructor: OpenLayers.Strategy.Paging\n- * Create a new paging strategy.\n+ * APIMethod: output\n+ * Chain an output of a configured process (see ) as input to\n+ * another process.\n+ *\n+ * (code)\n+ * intersect = client.getProcess('opengeo', 'JTS:intersection'); \n+ * intersect.configure({\n+ * // ...\n+ * });\n+ * buffer = client.getProcess('opengeo', 'JTS:buffer');\n+ * buffer.execute({\n+ * inputs: {\n+ * geom: intersect.output('result'), // <-- here we're chaining\n+ * distance: 1\n+ * },\n+ * // ...\n+ * });\n+ * (end)\n *\n * Parameters:\n- * options - {Object} Optional object whose properties will be set on the\n- * instance.\n+ * identifier - {String} Identifier of the output that we're chaining. If\n+ * not provided, the first output will be used.\n */\n+ output: function(identifier) {\n+ return new OpenLayers.WPSProcess.ChainLink({\n+ process: this,\n+ output: identifier\n+ });\n+ },\n \n /**\n- * APIMethod: activate\n- * Activate the strategy. Register any listeners, do appropriate setup.\n- * \n- * Returns:\n- * {Boolean} The strategy was successfully activated.\n+ * Method: parseDescription\n+ * Parses the DescribeProcess response\n+ *\n+ * Parameters:\n+ * description - {Object}\n */\n- activate: function() {\n- var activated = OpenLayers.Strategy.prototype.activate.call(this);\n- if (activated) {\n- this.layer.events.on({\n- \"beforefeaturesadded\": this.cacheFeatures,\n- scope: this\n- });\n- }\n- return activated;\n+ parseDescription: function(description) {\n+ var server = this.client.servers[this.server];\n+ this.description = new OpenLayers.Format.WPSDescribeProcess()\n+ .read(server.processDescription[this.identifier])\n+ .processDescriptions[this.identifier];\n },\n \n /**\n- * APIMethod: deactivate\n- * Deactivate the strategy. Unregister any listeners, do appropriate\n- * tear-down.\n- * \n- * Returns:\n- * {Boolean} The strategy was successfully deactivated.\n+ * Method: setInputData\n+ * Sets the data for a single input\n+ *\n+ * Parameters:\n+ * input - {Object} An entry from the dataInputs array of the process\n+ * description.\n+ * data - {Mixed} For spatial data inputs, this is usually an\n+ * , an or an array of\n+ * geometries or features.\n */\n- deactivate: function() {\n- var deactivated = OpenLayers.Strategy.prototype.deactivate.call(this);\n- if (deactivated) {\n- this.clearCache();\n- this.layer.events.un({\n- \"beforefeaturesadded\": this.cacheFeatures,\n+ setInputData: function(input, data) {\n+ // clear any previous data\n+ delete input.data;\n+ delete input.reference;\n+ if (data instanceof OpenLayers.WPSProcess.ChainLink) {\n+ ++this.chained;\n+ input.reference = {\n+ method: 'POST',\n+ href: data.process.server === this.server ?\n+ this.localWPS : this.client.servers[data.process.server].url\n+ };\n+ data.process.describe({\n+ callback: function() {\n+ --this.chained;\n+ this.chainProcess(input, data);\n+ },\n scope: this\n });\n+ } else {\n+ input.data = {};\n+ var complexData = input.complexData;\n+ if (complexData) {\n+ var format = this.findMimeType(complexData.supported.formats);\n+ input.data.complexData = {\n+ mimeType: format,\n+ value: this.formats[format].write(this.toFeatures(data))\n+ };\n+ } else {\n+ input.data.literalData = {\n+ value: data\n+ };\n+ }\n }\n- return deactivated;\n },\n \n /**\n- * Method: cacheFeatures\n- * Cache features before they are added to the layer.\n+ * Method: setResponseForm\n+ * Sets the responseForm property of the payload.\n *\n * Parameters:\n- * event - {Object} The event that this was listening for. This will come\n- * with a batch of features to be paged.\n+ * options - {Object} See below.\n+ *\n+ * Available options:\n+ * outputIndex - {Integer} The index of the output to use. Optional.\n+ * supportedFormats - {Object} Object with supported mime types as key,\n+ * and true as value for supported types. Optional.\n */\n- cacheFeatures: function(event) {\n- if (!this.paging) {\n- this.clearCache();\n- this.features = event.features;\n- this.pageNext(event);\n- }\n+ setResponseForm: function(options) {\n+ options = options || {};\n+ var output = this.description.processOutputs[options.outputIndex || 0];\n+ this.description.responseForm = {\n+ rawDataOutput: {\n+ identifier: output.identifier,\n+ mimeType: this.findMimeType(output.complexOutput.supported.formats, options.supportedFormats)\n+ }\n+ };\n },\n \n /**\n- * Method: clearCache\n- * Clear out the cached features. This destroys features, assuming\n- * nothing else has a reference.\n+ * Method: getOutputIndex\n+ * Gets the index of a processOutput by its identifier\n+ *\n+ * Parameters:\n+ * outputs - {Array} The processOutputs array to look at\n+ * identifier - {String} The identifier of the output\n+ *\n+ * Returns\n+ * {Integer} The index of the processOutput with the provided identifier\n+ * in the outputs array.\n */\n- clearCache: function() {\n- if (this.features) {\n- for (var i = 0; i < this.features.length; ++i) {\n- this.features[i].destroy();\n+ getOutputIndex: function(outputs, identifier) {\n+ var output;\n+ if (identifier) {\n+ for (var i = outputs.length - 1; i >= 0; --i) {\n+ if (outputs[i].identifier === identifier) {\n+ output = i;\n+ break;\n+ }\n }\n+ } else {\n+ output = 0;\n }\n- this.features = null;\n- this.num = null;\n+ return output;\n },\n \n /**\n- * APIMethod: pageCount\n- * Get the total count of pages given the current cache of features.\n+ * Method: chainProcess\n+ * Sets a fully configured chained process as input for this process.\n *\n- * Returns:\n- * {Integer} The page count.\n+ * Parameters:\n+ * input - {Object} The dataInput that the chained process provides.\n+ * chainLink - {} The process to chain.\n */\n- pageCount: function() {\n- var numFeatures = this.features ? this.features.length : 0;\n- return Math.ceil(numFeatures / this.length);\n+ chainProcess: function(input, chainLink) {\n+ var output = this.getOutputIndex(\n+ chainLink.process.description.processOutputs, chainLink.output\n+ );\n+ input.reference.mimeType = this.findMimeType(\n+ input.complexData.supported.formats,\n+ chainLink.process.description.processOutputs[output].complexOutput.supported.formats\n+ );\n+ var formats = {};\n+ formats[input.reference.mimeType] = true;\n+ chainLink.process.setResponseForm({\n+ outputIndex: output,\n+ supportedFormats: formats\n+ });\n+ input.reference.body = chainLink.process.description;\n+ while (this.executeCallbacks.length > 0) {\n+ this.executeCallbacks[0]();\n+ }\n },\n \n /**\n- * APIMethod: pageNum\n- * Get the zero based page number.\n+ * Method: toFeatures\n+ * Converts spatial input into features so it can be processed by\n+ * instances.\n+ *\n+ * Parameters:\n+ * source - {Mixed} An , an\n+ * , or an array of geometries or features\n *\n * Returns:\n- * {Integer} The current page number being displayed.\n+ * {Array()}\n */\n- pageNum: function() {\n- return this.num;\n+ toFeatures: function(source) {\n+ var isArray = OpenLayers.Util.isArray(source);\n+ if (!isArray) {\n+ source = [source];\n+ }\n+ var target = new Array(source.length),\n+ current;\n+ for (var i = 0, ii = source.length; i < ii; ++i) {\n+ current = source[i];\n+ target[i] = current instanceof OpenLayers.Feature.Vector ?\n+ current : new OpenLayers.Feature.Vector(current);\n+ }\n+ return isArray ? target : target[0];\n },\n \n /**\n- * APIMethod: pageLength\n- * Gets or sets page length.\n+ * Method: findMimeType\n+ * Finds a supported mime type.\n *\n * Parameters:\n- * newLength - {Integer} Optional length to be set.\n+ * sourceFormats - {Object} An object literal with mime types as key and\n+ * true as value for supported formats.\n+ * targetFormats - {Object} Like , but optional to check for\n+ * supported mime types on a different target than this process.\n+ * Default is to check against this process's supported formats.\n *\n * Returns:\n- * {Integer} The length of a page (number of features per page).\n+ * {String} A supported mime type.\n */\n- pageLength: function(newLength) {\n- if (newLength && newLength > 0) {\n- this.length = newLength;\n+ findMimeType: function(sourceFormats, targetFormats) {\n+ targetFormats = targetFormats || this.formats;\n+ for (var f in sourceFormats) {\n+ if (f in targetFormats) {\n+ return f;\n+ }\n }\n- return this.length;\n },\n \n+ CLASS_NAME: \"OpenLayers.WPSProcess\"\n+\n+});\n+\n+/**\n+ * Class: OpenLayers.WPSProcess.ChainLink\n+ * Type for chaining processes.\n+ */\n+OpenLayers.WPSProcess.ChainLink = OpenLayers.Class({\n+\n /**\n- * APIMethod: pageNext\n- * Display the next page of features.\n- *\n- * Returns:\n- * {Boolean} A new page was displayed.\n+ * Property: process\n+ * {} The process to chain\n */\n- pageNext: function(event) {\n- var changed = false;\n- if (this.features) {\n- if (this.num === null) {\n- this.num = -1;\n- }\n- var start = (this.num + 1) * this.length;\n- changed = this.page(start, event);\n- }\n- return changed;\n- },\n+ process: null,\n \n /**\n- * APIMethod: pagePrevious\n- * Display the previous page of features.\n- *\n- * Returns:\n- * {Boolean} A new page was displayed.\n+ * Property: output\n+ * {String} The output identifier of the output we are going to use as\n+ * input for another process.\n */\n- pagePrevious: function() {\n- var changed = false;\n- if (this.features) {\n- if (this.num === null) {\n- this.num = this.pageCount();\n- }\n- var start = (this.num - 1) * this.length;\n- changed = this.page(start);\n- }\n- return changed;\n- },\n+ output: null,\n \n /**\n- * Method: page\n- * Display the page starting at the given index from the cache.\n+ * Constructor: OpenLayers.WPSProcess.ChainLink\n *\n- * Returns:\n- * {Boolean} A new page was displayed.\n+ * Parameters:\n+ * options - {Object} Properties to set on the instance.\n */\n- page: function(start, event) {\n- var changed = false;\n- if (this.features) {\n- if (start >= 0 && start < this.features.length) {\n- var num = Math.floor(start / this.length);\n- if (num != this.num) {\n- this.paging = true;\n- var features = this.features.slice(start, start + this.length);\n- this.layer.removeFeatures(this.layer.features);\n- this.num = num;\n- // modify the event if any\n- if (event && event.features) {\n- // this.was called by an event listener\n- event.features = features;\n- } else {\n- // this was called directly on the strategy\n- this.layer.addFeatures(features);\n- }\n- this.paging = false;\n- changed = true;\n- }\n- }\n- }\n- return changed;\n+ initialize: function(options) {\n+ OpenLayers.Util.extend(this, options);\n },\n \n- CLASS_NAME: \"OpenLayers.Strategy.Paging\"\n+ CLASS_NAME: \"OpenLayers.WPSProcess.ChainLink\"\n+\n });\n /* ======================================================================\n- OpenLayers/Strategy/Filter.js\n+ OpenLayers/Format/WPSDescribeProcess.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Strategy.js\n- * @requires OpenLayers/Filter.js\n+ * @requires OpenLayers/Format/XML.js\n+ * @requires OpenLayers/Format/OWSCommon/v1_1_0.js\n */\n \n /**\n- * Class: OpenLayers.Strategy.Filter\n- * Strategy for limiting features that get added to a layer by \n- * evaluating a filter. The strategy maintains a cache of\n- * all features until removeFeatures is called on the layer.\n+ * Class: OpenLayers.Format.WPSDescribeProcess\n+ * Read WPS DescribeProcess responses. \n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Strategy.Filter = OpenLayers.Class(OpenLayers.Strategy, {\n+OpenLayers.Format.WPSDescribeProcess = OpenLayers.Class(\n+ OpenLayers.Format.XML, {\n \n- /**\n- * APIProperty: filter\n- * {} Filter for limiting features sent to the layer.\n- * Use the method to update this filter after construction.\n- */\n- filter: null,\n+ /**\n+ * Constant: VERSION\n+ * {String} 1.0.0\n+ */\n+ VERSION: \"1.0.0\",\n \n- /**\n- * Property: cache\n- * {Array()} List of currently cached\n- * features.\n- */\n- cache: null,\n+ /**\n+ * Property: namespaces\n+ * {Object} Mapping of namespace aliases to namespace URIs.\n+ */\n+ namespaces: {\n+ wps: \"http://www.opengis.net/wps/1.0.0\",\n+ ows: \"http://www.opengis.net/ows/1.1\",\n+ xsi: \"http://www.w3.org/2001/XMLSchema-instance\"\n+ },\n \n- /**\n- * Property: caching\n- * {Boolean} The filter is currently caching features.\n- */\n- caching: false,\n+ /**\n+ * Property: schemaLocation\n+ * {String} Schema location\n+ */\n+ schemaLocation: \"http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd\",\n \n- /**\n- * Constructor: OpenLayers.Strategy.Filter\n- * Create a new filter strategy.\n- *\n- * Parameters:\n- * options - {Object} Optional object whose properties will be set on the\n- * instance.\n- */\n+ /**\n+ * Property: defaultPrefix\n+ */\n+ defaultPrefix: \"wps\",\n \n- /**\n- * APIMethod: activate\n- * Activate the strategy. Register any listeners, do appropriate setup.\n- * By default, this strategy automatically activates itself when a layer\n- * is added to a map.\n- *\n- * Returns:\n- * {Boolean} True if the strategy was successfully activated or false if\n- * the strategy was already active.\n- */\n- activate: function() {\n- var activated = OpenLayers.Strategy.prototype.activate.apply(this, arguments);\n- if (activated) {\n- this.cache = [];\n- this.layer.events.on({\n- \"beforefeaturesadded\": this.handleAdd,\n- \"beforefeaturesremoved\": this.handleRemove,\n- scope: this\n- });\n- }\n- return activated;\n- },\n+ /**\n+ * Property: regExes\n+ * Compiled regular expressions for manipulating strings.\n+ */\n+ regExes: {\n+ trimSpace: (/^\\s*|\\s*$/g),\n+ removeSpace: (/\\s*/g),\n+ splitSpace: (/\\s+/),\n+ trimComma: (/\\s*,\\s*/g)\n+ },\n \n- /**\n- * APIMethod: deactivate\n- * Deactivate the strategy. Clear the feature cache.\n- *\n- * Returns:\n- * {Boolean} True if the strategy was successfully deactivated or false if\n- * the strategy was already inactive.\n- */\n- deactivate: function() {\n- this.cache = null;\n- if (this.layer && this.layer.events) {\n- this.layer.events.un({\n- \"beforefeaturesadded\": this.handleAdd,\n- \"beforefeaturesremoved\": this.handleRemove,\n- scope: this\n- });\n- }\n- return OpenLayers.Strategy.prototype.deactivate.apply(this, arguments);\n- },\n+ /**\n+ * Constructor: OpenLayers.Format.WPSDescribeProcess\n+ *\n+ * Parameters:\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n+ */\n \n- /**\n- * Method: handleAdd\n- */\n- handleAdd: function(event) {\n- if (!this.caching && this.filter) {\n- var features = event.features;\n- event.features = [];\n- var feature;\n- for (var i = 0, ii = features.length; i < ii; ++i) {\n- feature = features[i];\n- if (this.filter.evaluate(feature)) {\n- event.features.push(feature);\n- } else {\n- this.cache.push(feature);\n- }\n+ /**\n+ * APIMethod: read\n+ * Parse a WPS DescribeProcess and return an object with its information.\n+ * \n+ * Parameters: \n+ * data - {String} or {DOMElement} data to read/parse.\n+ *\n+ * Returns:\n+ * {Object}\n+ */\n+ read: function(data) {\n+ if (typeof data == \"string\") {\n+ data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n }\n- }\n- },\n-\n- /**\n- * Method: handleRemove\n- */\n- handleRemove: function(event) {\n- if (!this.caching) {\n- this.cache = [];\n- }\n- },\n-\n- /** \n- * APIMethod: setFilter\n- * Update the filter for this strategy. This will re-evaluate\n- * any features on the layer and in the cache. Only features\n- * for which filter.evalute(feature) returns true will be\n- * added to the layer. Others will be cached by the strategy.\n- *\n- * Parameters:\n- * filter - {} A filter for evaluating features.\n- */\n- setFilter: function(filter) {\n- this.filter = filter;\n- var previousCache = this.cache;\n- this.cache = [];\n- // look through layer for features to remove from layer\n- this.handleAdd({\n- features: this.layer.features\n- });\n- // cache now contains features to remove from layer\n- if (this.cache.length > 0) {\n- this.caching = true;\n- this.layer.removeFeatures(this.cache.slice());\n- this.caching = false;\n- }\n- // now look through previous cache for features to add to layer\n- if (previousCache.length > 0) {\n- var event = {\n- features: previousCache\n- };\n- this.handleAdd(event);\n- if (event.features.length > 0) {\n- // event has features to add to layer\n- this.caching = true;\n- this.layer.addFeatures(event.features);\n- this.caching = false;\n+ if (data && data.nodeType == 9) {\n+ data = data.documentElement;\n }\n- }\n- },\n+ var info = {};\n+ this.readNode(data, info);\n+ return info;\n+ },\n \n- CLASS_NAME: \"OpenLayers.Strategy.Filter\"\n+ /**\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n+ */\n+ readers: {\n+ \"wps\": {\n+ \"ProcessDescriptions\": function(node, obj) {\n+ obj.processDescriptions = {};\n+ this.readChildNodes(node, obj.processDescriptions);\n+ },\n+ \"ProcessDescription\": function(node, processDescriptions) {\n+ var processVersion = this.getAttributeNS(node, this.namespaces.wps, \"processVersion\");\n+ var processDescription = {\n+ processVersion: processVersion,\n+ statusSupported: (node.getAttribute(\"statusSupported\") === \"true\"),\n+ storeSupported: (node.getAttribute(\"storeSupported\") === \"true\")\n+ };\n+ this.readChildNodes(node, processDescription);\n+ processDescriptions[processDescription.identifier] = processDescription;\n+ },\n+ \"DataInputs\": function(node, processDescription) {\n+ processDescription.dataInputs = [];\n+ this.readChildNodes(node, processDescription.dataInputs);\n+ },\n+ \"ProcessOutputs\": function(node, processDescription) {\n+ processDescription.processOutputs = [];\n+ this.readChildNodes(node, processDescription.processOutputs);\n+ },\n+ \"Output\": function(node, processOutputs) {\n+ var output = {};\n+ this.readChildNodes(node, output);\n+ processOutputs.push(output);\n+ },\n+ \"ComplexOutput\": function(node, output) {\n+ output.complexOutput = {};\n+ this.readChildNodes(node, output.complexOutput);\n+ },\n+ \"LiteralOutput\": function(node, output) {\n+ output.literalOutput = {};\n+ this.readChildNodes(node, output.literalOutput);\n+ },\n+ \"Input\": function(node, dataInputs) {\n+ var input = {\n+ maxOccurs: parseInt(node.getAttribute(\"maxOccurs\")),\n+ minOccurs: parseInt(node.getAttribute(\"minOccurs\"))\n+ };\n+ this.readChildNodes(node, input);\n+ dataInputs.push(input);\n+ },\n+ \"BoundingBoxData\": function(node, input) {\n+ input.boundingBoxData = {};\n+ this.readChildNodes(node, input.boundingBoxData);\n+ },\n+ \"CRS\": function(node, obj) {\n+ if (!obj.CRSs) {\n+ obj.CRSs = {};\n+ }\n+ obj.CRSs[this.getChildValue(node)] = true;\n+ },\n+ \"LiteralData\": function(node, input) {\n+ input.literalData = {};\n+ this.readChildNodes(node, input.literalData);\n+ },\n+ \"ComplexData\": function(node, input) {\n+ input.complexData = {};\n+ this.readChildNodes(node, input.complexData);\n+ },\n+ \"Default\": function(node, complexData) {\n+ complexData[\"default\"] = {};\n+ this.readChildNodes(node, complexData[\"default\"]);\n+ },\n+ \"Supported\": function(node, complexData) {\n+ complexData[\"supported\"] = {};\n+ this.readChildNodes(node, complexData[\"supported\"]);\n+ },\n+ \"Format\": function(node, obj) {\n+ var format = {};\n+ this.readChildNodes(node, format);\n+ if (!obj.formats) {\n+ obj.formats = {};\n+ }\n+ obj.formats[format.mimeType] = true;\n+ },\n+ \"MimeType\": function(node, format) {\n+ format.mimeType = this.getChildValue(node);\n+ }\n+ },\n+ \"ows\": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers[\"ows\"]\n+ },\n \n-});\n+ CLASS_NAME: \"OpenLayers.Format.WPSDescribeProcess\"\n+\n+ });\n /* ======================================================================\n- OpenLayers/Strategy/Save.js\n+ OpenLayers/WPSClient.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Strategy.js\n+ * @requires OpenLayers/SingleFile.js\n */\n \n /**\n- * Class: OpenLayers.Strategy.Save\n- * A strategy that commits newly created or modified features. By default\n- * the strategy waits for a call to before persisting changes. By\n- * configuring the strategy with the option, changes can be saved\n- * automatically.\n- *\n- * Inherits from:\n- * - \n+ * @requires OpenLayers/Events.js\n+ * @requires OpenLayers/WPSProcess.js\n+ * @requires OpenLayers/Format/WPSDescribeProcess.js\n+ * @requires OpenLayers/Request.js\n */\n-OpenLayers.Strategy.Save = OpenLayers.Class(OpenLayers.Strategy, {\n+\n+/**\n+ * Class: OpenLayers.WPSClient\n+ * High level API for interaction with Web Processing Services (WPS).\n+ * An instance is used to create \n+ * instances for servers known to the WPSClient. The WPSClient also caches\n+ * DescribeProcess responses to reduce the number of requests sent to servers\n+ * when processes are created.\n+ */\n+OpenLayers.WPSClient = OpenLayers.Class({\n \n /**\n- * APIProperty: events\n- * {} An events object that handles all \n- * events on the strategy object.\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * strategy.events.register(type, obj, listener);\n- * (end)\n+ * Property: servers\n+ * {Object} Service metadata, keyed by a local identifier.\n *\n- * Supported event types:\n- * start - Triggered before saving\n- * success - Triggered after a successful transaction\n- * fail - Triggered after a failed transaction\n- * \n+ * Properties:\n+ * url - {String} the url of the server\n+ * version - {String} WPS version of the server\n+ * processDescription - {Object} Cache of raw DescribeProcess\n+ * responses, keyed by process identifier.\n */\n+ servers: null,\n \n- /** \n- * Property: events\n- * {} Events instance for triggering this protocol\n- * events.\n+ /**\n+ * Property: version\n+ * {String} The default WPS version to use if none is configured. Default\n+ * is '1.0.0'.\n */\n- events: null,\n+ version: '1.0.0',\n \n /**\n- * APIProperty: auto\n- * {Boolean | Number} Auto-save. Default is false. If true, features will be\n- * saved immediately after being added to the layer and with each\n- * modification or deletion. If auto is a number, features will be\n- * saved on an interval provided by the value (in seconds).\n+ * Property: lazy\n+ * {Boolean} Should the DescribeProcess be deferred until a process is\n+ * fully configured? Default is false.\n */\n- auto: false,\n+ lazy: false,\n \n /**\n- * Property: timer\n- * {Number} The id of the timer.\n+ * Property: events\n+ * {}\n+ *\n+ * Supported event types:\n+ * describeprocess - Fires when the process description is available.\n+ * Listeners receive an object with a 'raw' property holding the raw\n+ * DescribeProcess response, and an 'identifier' property holding the\n+ * process identifier of the described process.\n */\n- timer: null,\n+ events: null,\n \n /**\n- * Constructor: OpenLayers.Strategy.Save\n- * Create a new Save strategy.\n+ * Constructor: OpenLayers.WPSClient\n *\n * Parameters:\n- * options - {Object} Optional object whose properties will be set on the\n- * instance.\n+ * options - {Object} Object whose properties will be set on the instance.\n+ *\n+ * Avaliable options:\n+ * servers - {Object} Mandatory. Service metadata, keyed by a local\n+ * identifier. Can either be a string with the service url or an\n+ * object literal with additional metadata:\n+ *\n+ * (code)\n+ * servers: {\n+ * local: '/geoserver/wps'\n+ * }, {\n+ * opengeo: {\n+ * url: 'http://demo.opengeo.org/geoserver/wps',\n+ * version: '1.0.0'\n+ * }\n+ * }\n+ * (end)\n+ *\n+ * lazy - {Boolean} Optional. Set to true if DescribeProcess should not be\n+ * requested until a process is fully configured. Default is false.\n */\n initialize: function(options) {\n- OpenLayers.Strategy.prototype.initialize.apply(this, [options]);\n+ OpenLayers.Util.extend(this, options);\n this.events = new OpenLayers.Events(this);\n- },\n-\n- /**\n- * APIMethod: activate\n- * Activate the strategy. Register any listeners, do appropriate setup.\n- * \n- * Returns:\n- * {Boolean} The strategy was successfully activated.\n- */\n- activate: function() {\n- var activated = OpenLayers.Strategy.prototype.activate.call(this);\n- if (activated) {\n- if (this.auto) {\n- if (typeof this.auto === \"number\") {\n- this.timer = window.setInterval(\n- OpenLayers.Function.bind(this.save, this),\n- this.auto * 1000\n- );\n- } else {\n- this.layer.events.on({\n- \"featureadded\": this.triggerSave,\n- \"afterfeaturemodified\": this.triggerSave,\n- scope: this\n- });\n- }\n- }\n- }\n- return activated;\n- },\n-\n- /**\n- * APIMethod: deactivate\n- * Deactivate the strategy. Unregister any listeners, do appropriate\n- * tear-down.\n- * \n- * Returns:\n- * {Boolean} The strategy was successfully deactivated.\n- */\n- deactivate: function() {\n- var deactivated = OpenLayers.Strategy.prototype.deactivate.call(this);\n- if (deactivated) {\n- if (this.auto) {\n- if (typeof this.auto === \"number\") {\n- window.clearInterval(this.timer);\n- } else {\n- this.layer.events.un({\n- \"featureadded\": this.triggerSave,\n- \"afterfeaturemodified\": this.triggerSave,\n- scope: this\n- });\n- }\n- }\n+ this.servers = {};\n+ for (var s in options.servers) {\n+ this.servers[s] = typeof options.servers[s] == 'string' ? {\n+ url: options.servers[s],\n+ version: this.version,\n+ processDescription: {}\n+ } : options.servers[s];\n }\n- return deactivated;\n },\n \n /**\n- * Method: triggerSave\n- * Registered as a listener. Calls save if a feature has insert, update,\n- * or delete state.\n+ * APIMethod: execute\n+ * Shortcut to execute a process with a single function call. This is\n+ * equivalent to using and then calling execute on the\n+ * process.\n *\n * Parameters:\n- * event - {Object} The event this function is listening for.\n+ * options - {Object} Options for the execute operation.\n+ *\n+ * Available options:\n+ * server - {String} Mandatory. One of the local identifiers of the\n+ * configured servers.\n+ * process - {String} Mandatory. A process identifier known to the\n+ * server.\n+ * inputs - {Object} The inputs for the process, keyed by input identifier.\n+ * For spatial data inputs, the value of an input is usually an\n+ * , an or an array of\n+ * geometries or features.\n+ * output - {String} The identifier of an output to parse. Optional. If not\n+ * provided, the first output will be parsed.\n+ * success - {Function} Callback to call when the process is complete.\n+ * This function is called with an outputs object as argument, which\n+ * will have a property with the identifier of the requested output\n+ * (e.g. 'result'). For processes that generate spatial output, the\n+ * value will either be a single or an\n+ * array of features.\n+ * scope - {Object} Optional scope for the success callback.\n */\n- triggerSave: function(event) {\n- var feature = event.feature;\n- if (feature.state === OpenLayers.State.INSERT ||\n- feature.state === OpenLayers.State.UPDATE ||\n- feature.state === OpenLayers.State.DELETE) {\n- this.save([event.feature]);\n- }\n+ execute: function(options) {\n+ var process = this.getProcess(options.server, options.process);\n+ process.execute({\n+ inputs: options.inputs,\n+ success: options.success,\n+ scope: options.scope\n+ });\n },\n \n /**\n- * APIMethod: save\n- * Tell the layer protocol to commit unsaved features. If the layer\n- * projection differs from the map projection, features will be\n- * transformed into the layer projection before being committed.\n+ * APIMethod: getProcess\n+ * Creates an .\n *\n * Parameters:\n- * features - {Array} Features to be saved. If null, then default is all\n- * features in the layer. Features are assumed to be in the map\n- * projection.\n+ * serverID - {String} Local identifier from the servers that this instance\n+ * was constructed with.\n+ * processID - {String} Process identifier known to the server.\n+ *\n+ * Returns:\n+ * {}\n */\n- save: function(features) {\n- if (!features) {\n- features = this.layer.features;\n- }\n- this.events.triggerEvent(\"start\", {\n- features: features\n+ getProcess: function(serverID, processID) {\n+ var process = new OpenLayers.WPSProcess({\n+ client: this,\n+ server: serverID,\n+ identifier: processID\n });\n- var remote = this.layer.projection;\n- var local = this.layer.map.getProjectionObject();\n- if (!local.equals(remote)) {\n- var len = features.length;\n- var clones = new Array(len);\n- var orig, clone;\n- for (var i = 0; i < len; ++i) {\n- orig = features[i];\n- clone = orig.clone();\n- clone.fid = orig.fid;\n- clone.state = orig.state;\n- if (orig.url) {\n- clone.url = orig.url;\n- }\n- clone._original = orig;\n- clone.geometry.transform(local, remote);\n- clones[i] = clone;\n- }\n- features = clones;\n+ if (!this.lazy) {\n+ process.describe();\n }\n- this.layer.protocol.commit(features, {\n- callback: this.onCommit,\n- scope: this\n- });\n+ return process;\n },\n \n /**\n- * Method: onCommit\n- * Called after protocol commit.\n+ * Method: describeProcess\n *\n * Parameters:\n- * response - {} A response object.\n+ * serverID - {String} Identifier of the server\n+ * processID - {String} Identifier of the requested process\n+ * callback - {Function} Callback to call when the description is available\n+ * scope - {Object} Optional execution scope for the callback function\n */\n- onCommit: function(response) {\n- var evt = {\n- \"response\": response\n- };\n- if (response.success()) {\n- var features = response.reqFeatures;\n- // deal with inserts, updates, and deletes\n- var state, feature;\n- var destroys = [];\n- var insertIds = response.insertIds || [];\n- var j = 0;\n- for (var i = 0, len = features.length; i < len; ++i) {\n- feature = features[i];\n- // if projection was different, we may be dealing with clones\n- feature = feature._original || feature;\n- state = feature.state;\n- if (state) {\n- if (state == OpenLayers.State.DELETE) {\n- destroys.push(feature);\n- } else if (state == OpenLayers.State.INSERT) {\n- feature.fid = insertIds[j];\n- ++j;\n+ describeProcess: function(serverID, processID, callback, scope) {\n+ var server = this.servers[serverID];\n+ if (!server.processDescription[processID]) {\n+ if (!(processID in server.processDescription)) {\n+ // set to null so we know a describeFeature request is pending\n+ server.processDescription[processID] = null;\n+ OpenLayers.Request.GET({\n+ url: server.url,\n+ params: {\n+ SERVICE: 'WPS',\n+ VERSION: server.version,\n+ REQUEST: 'DescribeProcess',\n+ IDENTIFIER: processID\n+ },\n+ success: function(response) {\n+ server.processDescription[processID] = response.responseText;\n+ this.events.triggerEvent('describeprocess', {\n+ identifier: processID,\n+ raw: response.responseText\n+ });\n+ },\n+ scope: this\n+ });\n+ } else {\n+ // pending request\n+ this.events.register('describeprocess', this, function describe(evt) {\n+ if (evt.identifier === processID) {\n+ this.events.unregister('describeprocess', this, describe);\n+ callback.call(scope, evt.raw);\n }\n- feature.state = null;\n- }\n- }\n-\n- if (destroys.length > 0) {\n- this.layer.destroyFeatures(destroys);\n+ });\n }\n-\n- this.events.triggerEvent(\"success\", evt);\n-\n } else {\n- this.events.triggerEvent(\"fail\", evt);\n+ window.setTimeout(function() {\n+ callback.call(scope, server.processDescription[processID]);\n+ }, 0);\n }\n },\n \n- CLASS_NAME: \"OpenLayers.Strategy.Save\"\n+ /**\n+ * Method: destroy\n+ */\n+ destroy: function() {\n+ this.events.destroy();\n+ this.events = null;\n+ this.servers = null;\n+ },\n+\n+ CLASS_NAME: 'OpenLayers.WPSClient'\n+\n });\n /* ======================================================================\n- OpenLayers/Strategy/Fixed.js\n+ OpenLayers/Kinetic.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Strategy.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Animation.js\n */\n \n-/**\n- * Class: OpenLayers.Strategy.Fixed\n- * A simple strategy that requests features once and never requests new data.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Strategy.Fixed = OpenLayers.Class(OpenLayers.Strategy, {\n+OpenLayers.Kinetic = OpenLayers.Class({\n \n /**\n- * APIProperty: preload\n- * {Boolean} Load data before layer made visible. Enabling this may result\n- * in considerable overhead if your application loads many data layers\n- * that are not visible by default. Default is false.\n+ * Property: threshold\n+ * In most cases changing the threshold isn't needed.\n+ * In px/ms, default to 0.\n */\n- preload: false,\n+ threshold: 0,\n \n /**\n- * Constructor: OpenLayers.Strategy.Fixed\n- * Create a new Fixed strategy.\n- *\n- * Parameters:\n- * options - {Object} Optional object whose properties will be set on the\n- * instance.\n+ * Property: deceleration\n+ * {Float} the deseleration in px/ms\u00b2, default to 0.0035.\n */\n+ deceleration: 0.0035,\n \n /**\n- * Method: activate\n- * Activate the strategy: load data or add listener to load when visible\n+ * Property: nbPoints\n+ * {Integer} the number of points we use to calculate the kinetic\n+ * initial values.\n+ */\n+ nbPoints: 100,\n+\n+ /**\n+ * Property: delay\n+ * {Float} time to consider to calculate the kinetic initial values.\n+ * In ms, default to 200.\n+ */\n+ delay: 200,\n+\n+ /**\n+ * Property: points\n+ * List of points use to calculate the kinetic initial values.\n+ */\n+ points: undefined,\n+\n+ /**\n+ * Property: timerId\n+ * ID of the timer.\n+ */\n+ timerId: undefined,\n+\n+ /**\n+ * Constructor: OpenLayers.Kinetic\n *\n- * Returns:\n- * {Boolean} True if the strategy was successfully activated or false if\n- * the strategy was already active.\n+ * Parameters:\n+ * options - {Object}\n */\n- activate: function() {\n- var activated = OpenLayers.Strategy.prototype.activate.apply(this, arguments);\n- if (activated) {\n- this.layer.events.on({\n- \"refresh\": this.load,\n- scope: this\n- });\n- if (this.layer.visibility == true || this.preload) {\n- this.load();\n- } else {\n- this.layer.events.on({\n- \"visibilitychanged\": this.load,\n- scope: this\n- });\n- }\n- }\n- return activated;\n+ initialize: function(options) {\n+ OpenLayers.Util.extend(this, options);\n },\n \n /**\n- * Method: deactivate\n- * Deactivate the strategy. Undo what is done in .\n- * \n- * Returns:\n- * {Boolean} The strategy was successfully deactivated.\n+ * Method: begin\n+ * Begins the dragging.\n */\n- deactivate: function() {\n- var deactivated = OpenLayers.Strategy.prototype.deactivate.call(this);\n- if (deactivated) {\n- this.layer.events.un({\n- \"refresh\": this.load,\n- \"visibilitychanged\": this.load,\n- scope: this\n- });\n- }\n- return deactivated;\n+ begin: function() {\n+ OpenLayers.Animation.stop(this.timerId);\n+ this.timerId = undefined;\n+ this.points = [];\n },\n \n /**\n- * Method: load\n- * Tells protocol to load data and unhooks the visibilitychanged event\n+ * Method: update\n+ * Updates during the dragging.\n *\n * Parameters:\n- * options - {Object} options to pass to protocol read.\n+ * xy - {} The new position.\n */\n- load: function(options) {\n- var layer = this.layer;\n- layer.events.triggerEvent(\"loadstart\", {\n- filter: layer.filter\n- });\n- layer.protocol.read(OpenLayers.Util.applyDefaults({\n- callback: this.merge,\n- filter: layer.filter,\n- scope: this\n- }, options));\n- layer.events.un({\n- \"visibilitychanged\": this.load,\n- scope: this\n+ update: function(xy) {\n+ this.points.unshift({\n+ xy: xy,\n+ tick: new Date().getTime()\n });\n+ if (this.points.length > this.nbPoints) {\n+ this.points.pop();\n+ }\n },\n \n /**\n- * Method: merge\n- * Add all features to the layer.\n- * If the layer projection differs from the map projection, features\n- * will be transformed from the layer projection to the map projection.\n+ * Method: end\n+ * Ends the dragging, start the kinetic.\n *\n * Parameters:\n- * resp - {} The response object passed\n- * by the protocol.\n+ * xy - {} The last position.\n+ *\n+ * Returns:\n+ * {Object} An object with two properties: \"speed\", and \"theta\". The\n+ * \"speed\" and \"theta\" values are to be passed to the move \n+ * function when starting the animation.\n */\n- merge: function(resp) {\n- var layer = this.layer;\n- layer.destroyFeatures();\n- var features = resp.features;\n- if (features && features.length > 0) {\n- var remote = layer.projection;\n- var local = layer.map.getProjectionObject();\n- if (!local.equals(remote)) {\n- var geom;\n- for (var i = 0, len = features.length; i < len; ++i) {\n- geom = features[i].geometry;\n- if (geom) {\n- geom.transform(remote, local);\n- }\n- }\n+ end: function(xy) {\n+ var last, now = new Date().getTime();\n+ for (var i = 0, l = this.points.length, point; i < l; i++) {\n+ point = this.points[i];\n+ if (now - point.tick > this.delay) {\n+ break;\n }\n- layer.addFeatures(features);\n+ last = point;\n }\n- layer.events.triggerEvent(\"loadend\", {\n- response: resp\n- });\n+ if (!last) {\n+ return;\n+ }\n+ var time = new Date().getTime() - last.tick;\n+ var dist = Math.sqrt(Math.pow(xy.x - last.xy.x, 2) +\n+ Math.pow(xy.y - last.xy.y, 2));\n+ var speed = dist / time;\n+ if (speed == 0 || speed < this.threshold) {\n+ return;\n+ }\n+ var theta = Math.asin((xy.y - last.xy.y) / dist);\n+ if (last.xy.x <= xy.x) {\n+ theta = Math.PI - theta;\n+ }\n+ return {\n+ speed: speed,\n+ theta: theta\n+ };\n },\n \n- CLASS_NAME: \"OpenLayers.Strategy.Fixed\"\n+ /**\n+ * Method: move\n+ * Launch the kinetic move pan.\n+ *\n+ * Parameters:\n+ * info - {Object} An object with two properties, \"speed\", and \"theta\".\n+ * These values are those returned from the \"end\" call.\n+ * callback - {Function} Function called on every step of the animation,\n+ * receives x, y (values to pan), end (is the last point).\n+ */\n+ move: function(info, callback) {\n+ var v0 = info.speed;\n+ var fx = Math.cos(info.theta);\n+ var fy = -Math.sin(info.theta);\n+\n+ var initialTime = new Date().getTime();\n+\n+ var lastX = 0;\n+ var lastY = 0;\n+\n+ var timerCallback = function() {\n+ if (this.timerId == null) {\n+ return;\n+ }\n+\n+ var t = new Date().getTime() - initialTime;\n+\n+ var p = (-this.deceleration * Math.pow(t, 2)) / 2.0 + v0 * t;\n+ var x = p * fx;\n+ var y = p * fy;\n+\n+ var args = {};\n+ args.end = false;\n+ var v = -this.deceleration * t + v0;\n+\n+ if (v <= 0) {\n+ OpenLayers.Animation.stop(this.timerId);\n+ this.timerId = null;\n+ args.end = true;\n+ }\n+\n+ args.x = x - lastX;\n+ args.y = y - lastY;\n+ lastX = x;\n+ lastY = y;\n+ callback(args.x, args.y, args.end);\n+ };\n+\n+ this.timerId = OpenLayers.Animation.start(\n+ OpenLayers.Function.bind(timerCallback, this)\n+ );\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Kinetic\"\n });\n /* ======================================================================\n- OpenLayers/Strategy/BBOX.js\n+ OpenLayers/Renderer.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Strategy.js\n- * @requires OpenLayers/Filter/Spatial.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n */\n \n /**\n- * Class: OpenLayers.Strategy.BBOX\n- * A simple strategy that reads new features when the viewport invalidates\n- * some bounds.\n+ * Class: OpenLayers.Renderer \n+ * This is the base class for all renderers.\n+ *\n+ * This is based on a merger code written by Paul Spencer and Bertil Chapuis.\n+ * It is largely composed of virtual functions that are to be implemented\n+ * in technology-specific subclasses, but there is some generic code too.\n+ * \n+ * The functions that *are* implemented here merely deal with the maintenance\n+ * of the size and extent variables, as well as the cached 'resolution' \n+ * value. \n+ * \n+ * A note to the user that all subclasses should use getResolution() instead\n+ * of directly accessing this.resolution in order to correctly use the \n+ * cacheing system.\n *\n- * Inherits from:\n- * - \n */\n-OpenLayers.Strategy.BBOX = OpenLayers.Class(OpenLayers.Strategy, {\n+OpenLayers.Renderer = OpenLayers.Class({\n+\n+ /** \n+ * Property: container\n+ * {DOMElement} \n+ */\n+ container: null,\n \n /**\n- * Property: bounds\n- * {} The current data bounds (in the same projection\n- * as the layer - not always the same projection as the map).\n+ * Property: root\n+ * {DOMElement}\n */\n- bounds: null,\n+ root: null,\n \n /** \n- * Property: resolution \n- * {Float} The current data resolution. \n+ * Property: extent\n+ * {}\n */\n- resolution: null,\n+ extent: null,\n \n /**\n- * APIProperty: ratio\n- * {Float} The ratio of the data bounds to the viewport bounds (in each\n- * dimension). Default is 2.\n+ * Property: locked\n+ * {Boolean} If the renderer is currently in a state where many things\n+ * are changing, the 'locked' property is set to true. This means \n+ * that renderers can expect at least one more drawFeature event to be\n+ * called with the 'locked' property set to 'true': In some renderers,\n+ * this might make sense to use as a 'only update local information'\n+ * flag. \n */\n- ratio: 2,\n+ locked: false,\n \n /** \n- * Property: resFactor \n- * {Float} Optional factor used to determine when previously requested \n- * features are invalid. If set, the resFactor will be compared to the\n- * resolution of the previous request to the current map resolution.\n- * If resFactor > (old / new) and 1/resFactor < (old / new). If you\n- * set a resFactor of 1, data will be requested every time the\n- * resolution changes. If you set a resFactor of 3, data will be\n- * requested if the old resolution is 3 times the new, or if the new is\n- * 3 times the old. If the old bounds do not contain the new bounds\n- * new data will always be requested (with or without considering\n- * resFactor). \n+ * Property: size\n+ * {} \n */\n- resFactor: null,\n+ size: null,\n \n /**\n- * Property: response\n- * {} The protocol response object returned\n- * by the layer protocol.\n+ * Property: resolution\n+ * {Float} cache of current map resolution\n */\n- response: null,\n+ resolution: null,\n \n /**\n- * Constructor: OpenLayers.Strategy.BBOX\n- * Create a new BBOX strategy.\n+ * Property: map \n+ * {} Reference to the map -- this is set in Vector's setMap()\n+ */\n+ map: null,\n+\n+ /**\n+ * Property: featureDx\n+ * {Number} Feature offset in x direction. Will be calculated for and\n+ * applied to the current feature while rendering (see\n+ * ).\n+ */\n+ featureDx: 0,\n+\n+ /**\n+ * Constructor: OpenLayers.Renderer \n *\n * Parameters:\n- * options - {Object} Optional object whose properties will be set on the\n- * instance.\n+ * containerID - {} \n+ * options - {Object} options for this renderer. See sublcasses for\n+ * supported options.\n */\n+ initialize: function(containerID, options) {\n+ this.container = OpenLayers.Util.getElement(containerID);\n+ OpenLayers.Util.extend(this, options);\n+ },\n \n /**\n- * Method: activate\n- * Set up strategy with regard to reading new batches of remote data.\n- * \n- * Returns:\n- * {Boolean} The strategy was successfully activated.\n+ * APIMethod: destroy\n */\n- activate: function() {\n- var activated = OpenLayers.Strategy.prototype.activate.call(this);\n- if (activated) {\n- this.layer.events.on({\n- \"moveend\": this.update,\n- \"refresh\": this.update,\n- \"visibilitychanged\": this.update,\n- scope: this\n- });\n- this.update();\n- }\n- return activated;\n+ destroy: function() {\n+ this.container = null;\n+ this.extent = null;\n+ this.size = null;\n+ this.resolution = null;\n+ this.map = null;\n },\n \n /**\n- * Method: deactivate\n- * Tear down strategy with regard to reading new batches of remote data.\n+ * APIMethod: supported\n+ * This should be overridden by specific subclasses\n * \n * Returns:\n- * {Boolean} The strategy was successfully deactivated.\n+ * {Boolean} Whether or not the browser supports the renderer class\n */\n- deactivate: function() {\n- var deactivated = OpenLayers.Strategy.prototype.deactivate.call(this);\n- if (deactivated) {\n- this.layer.events.un({\n- \"moveend\": this.update,\n- \"refresh\": this.update,\n- \"visibilitychanged\": this.update,\n- scope: this\n- });\n- }\n- return deactivated;\n+ supported: function() {\n+ return false;\n },\n \n /**\n- * Method: update\n- * Callback function called on \"moveend\" or \"refresh\" layer events.\n+ * Method: setExtent\n+ * Set the visible part of the layer.\n+ *\n+ * Resolution has probably changed, so we nullify the resolution \n+ * cache (this.resolution) -- this way it will be re-computed when \n+ * next it is needed.\n+ * We nullify the resolution cache (this.resolution) if resolutionChanged\n+ * is set to true - this way it will be re-computed on the next\n+ * getResolution() request.\n *\n * Parameters:\n- * options - {Object} Optional object whose properties will determine\n- * the behaviour of this Strategy\n+ * extent - {}\n+ * resolutionChanged - {Boolean}\n *\n- * Valid options include:\n- * force - {Boolean} if true, new data must be unconditionally read.\n- * noAbort - {Boolean} if true, do not abort previous requests.\n+ * Returns:\n+ * {Boolean} true to notify the layer that the new extent does not exceed\n+ * the coordinate range, and the features will not need to be redrawn.\n+ * False otherwise.\n */\n- update: function(options) {\n- var mapBounds = this.getMapBounds();\n- if (mapBounds !== null && ((options && options.force) ||\n- (this.layer.visibility && this.layer.calculateInRange() && this.invalidBounds(mapBounds)))) {\n- this.calculateBounds(mapBounds);\n- this.resolution = this.layer.map.getResolution();\n- this.triggerRead(options);\n+ setExtent: function(extent, resolutionChanged) {\n+ this.extent = extent.clone();\n+ if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {\n+ var ratio = extent.getWidth() / this.map.getExtent().getWidth(),\n+ extent = extent.scale(1 / ratio);\n+ this.extent = extent.wrapDateLine(this.map.getMaxExtent()).scale(ratio);\n+ }\n+ if (resolutionChanged) {\n+ this.resolution = null;\n }\n+ return true;\n },\n \n /**\n- * Method: getMapBounds\n- * Get the map bounds expressed in the same projection as this layer.\n+ * Method: setSize\n+ * Sets the size of the drawing surface.\n+ * \n+ * Resolution has probably changed, so we nullify the resolution \n+ * cache (this.resolution) -- this way it will be re-computed when \n+ * next it is needed.\n *\n+ * Parameters:\n+ * size - {} \n+ */\n+ setSize: function(size) {\n+ this.size = size.clone();\n+ this.resolution = null;\n+ },\n+\n+ /** \n+ * Method: getResolution\n+ * Uses cached copy of resolution if available to minimize computing\n+ * \n * Returns:\n- * {} Map bounds in the projection of the layer.\n+ * {Float} The current map's resolution\n */\n- getMapBounds: function() {\n- if (this.layer.map === null) {\n- return null;\n- }\n- var bounds = this.layer.map.getExtent();\n- if (bounds && !this.layer.projection.equals(\n- this.layer.map.getProjectionObject())) {\n- bounds = bounds.clone().transform(\n- this.layer.map.getProjectionObject(), this.layer.projection\n- );\n- }\n- return bounds;\n+ getResolution: function() {\n+ this.resolution = this.resolution || this.map.getResolution();\n+ return this.resolution;\n },\n \n /**\n- * Method: invalidBounds\n- * Determine whether the previously requested set of features is invalid. \n- * This occurs when the new map bounds do not contain the previously \n- * requested bounds. In addition, if is set, it will be \n- * considered.\n+ * Method: drawFeature\n+ * Draw the feature. The optional style argument can be used\n+ * to override the feature's own style. This method should only\n+ * be called from layer.drawFeature().\n *\n * Parameters:\n- * mapBounds - {} the current map extent, will be\n- * retrieved from the map object if not provided\n- *\n+ * feature - {} \n+ * style - {}\n+ * \n * Returns:\n- * {Boolean} \n+ * {Boolean} true if the feature has been drawn completely, false if not,\n+ * undefined if the feature had no geometry\n */\n- invalidBounds: function(mapBounds) {\n- if (!mapBounds) {\n- mapBounds = this.getMapBounds();\n+ drawFeature: function(feature, style) {\n+ if (style == null) {\n+ style = feature.style;\n }\n- var invalid = !this.bounds || !this.bounds.containsBounds(mapBounds);\n- if (!invalid && this.resFactor) {\n- var ratio = this.resolution / this.layer.map.getResolution();\n- invalid = (ratio >= this.resFactor || ratio <= (1 / this.resFactor));\n+ if (feature.geometry) {\n+ var bounds = feature.geometry.getBounds();\n+ if (bounds) {\n+ var worldBounds;\n+ if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {\n+ worldBounds = this.map.getMaxExtent();\n+ }\n+ if (!bounds.intersectsBounds(this.extent, {\n+ worldBounds: worldBounds\n+ })) {\n+ style = {\n+ display: \"none\"\n+ };\n+ } else {\n+ this.calculateFeatureDx(bounds, worldBounds);\n+ }\n+ var rendered = this.drawGeometry(feature.geometry, style, feature.id);\n+ if (style.display != \"none\" && style.label && rendered !== false) {\n+\n+ var location = feature.geometry.getCentroid();\n+ if (style.labelXOffset || style.labelYOffset) {\n+ var xOffset = isNaN(style.labelXOffset) ? 0 : style.labelXOffset;\n+ var yOffset = isNaN(style.labelYOffset) ? 0 : style.labelYOffset;\n+ var res = this.getResolution();\n+ location.move(xOffset * res, yOffset * res);\n+ }\n+ this.drawText(feature.id, style, location);\n+ } else {\n+ this.removeText(feature.id);\n+ }\n+ return rendered;\n+ }\n }\n- return invalid;\n },\n \n /**\n- * Method: calculateBounds\n+ * Method: calculateFeatureDx\n+ * {Number} Calculates the feature offset in x direction. Looking at the\n+ * center of the feature bounds and the renderer extent, we calculate how\n+ * many world widths the two are away from each other. This distance is\n+ * used to shift the feature as close as possible to the center of the\n+ * current enderer extent, which ensures that the feature is visible in the\n+ * current viewport.\n *\n * Parameters:\n- * mapBounds - {} the current map extent, will be\n- * retrieved from the map object if not provided\n+ * bounds - {} Bounds of the feature\n+ * worldBounds - {} Bounds of the world\n */\n- calculateBounds: function(mapBounds) {\n- if (!mapBounds) {\n- mapBounds = this.getMapBounds();\n+ calculateFeatureDx: function(bounds, worldBounds) {\n+ this.featureDx = 0;\n+ if (worldBounds) {\n+ var worldWidth = worldBounds.getWidth(),\n+ rendererCenterX = (this.extent.left + this.extent.right) / 2,\n+ featureCenterX = (bounds.left + bounds.right) / 2,\n+ worldsAway = Math.round((featureCenterX - rendererCenterX) / worldWidth);\n+ this.featureDx = worldsAway * worldWidth;\n }\n- var center = mapBounds.getCenterLonLat();\n- var dataWidth = mapBounds.getWidth() * this.ratio;\n- var dataHeight = mapBounds.getHeight() * this.ratio;\n- this.bounds = new OpenLayers.Bounds(\n- center.lon - (dataWidth / 2),\n- center.lat - (dataHeight / 2),\n- center.lon + (dataWidth / 2),\n- center.lat + (dataHeight / 2)\n- );\n },\n \n- /**\n- * Method: triggerRead\n+ /** \n+ * Method: drawGeometry\n+ * \n+ * Draw a geometry. This should only be called from the renderer itself.\n+ * Use layer.drawFeature() from outside the renderer.\n+ * virtual function\n *\n * Parameters:\n- * options - {Object} Additional options for the protocol's read method \n- * (optional)\n- *\n- * Returns:\n- * {} The protocol response object\n- * returned by the layer protocol.\n+ * geometry - {} \n+ * style - {Object} \n+ * featureId - {} \n */\n- triggerRead: function(options) {\n- if (this.response && !(options && options.noAbort === true)) {\n- this.layer.protocol.abort(this.response);\n- this.layer.events.triggerEvent(\"loadend\");\n- }\n- var evt = {\n- filter: this.createFilter()\n- };\n- this.layer.events.triggerEvent(\"loadstart\", evt);\n- this.response = this.layer.protocol.read(\n- OpenLayers.Util.applyDefaults({\n- filter: evt.filter,\n- callback: this.merge,\n- scope: this\n- }, options));\n- },\n+ drawGeometry: function(geometry, style, featureId) {},\n \n /**\n- * Method: createFilter\n- * Creates a spatial BBOX filter. If the layer that this strategy belongs\n- * to has a filter property, this filter will be combined with the BBOX \n- * filter.\n+ * Method: drawText\n+ * Function for drawing text labels.\n+ * This method is only called by the renderer itself.\n * \n- * Returns\n- * {} The filter object.\n+ * Parameters: \n+ * featureId - {String}\n+ * style -\n+ * location - {}\n */\n- createFilter: function() {\n- var filter = new OpenLayers.Filter.Spatial({\n- type: OpenLayers.Filter.Spatial.BBOX,\n- value: this.bounds,\n- projection: this.layer.projection\n- });\n- if (this.layer.filter) {\n- filter = new OpenLayers.Filter.Logical({\n- type: OpenLayers.Filter.Logical.AND,\n- filters: [this.layer.filter, filter]\n- });\n- }\n- return filter;\n- },\n+ drawText: function(featureId, style, location) {},\n \n /**\n- * Method: merge\n- * Given a list of features, determine which ones to add to the layer.\n- * If the layer projection differs from the map projection, features\n- * will be transformed from the layer projection to the map projection.\n- *\n- * Parameters:\n- * resp - {} The response object passed\n- * by the protocol.\n+ * Method: removeText\n+ * Function for removing text labels.\n+ * This method is only called by the renderer itself.\n+ * \n+ * Parameters: \n+ * featureId - {String}\n */\n- merge: function(resp) {\n- this.layer.destroyFeatures();\n- if (resp.success()) {\n- var features = resp.features;\n- if (features && features.length > 0) {\n- var remote = this.layer.projection;\n- var local = this.layer.map.getProjectionObject();\n- if (!local.equals(remote)) {\n- var geom;\n- for (var i = 0, len = features.length; i < len; ++i) {\n- geom = features[i].geometry;\n- if (geom) {\n- geom.transform(remote, local);\n- }\n- }\n- }\n- this.layer.addFeatures(features);\n- }\n- } else {\n- this.bounds = null;\n+ removeText: function(featureId) {},\n+\n+ /**\n+ * Method: clear\n+ * Clear all vectors from the renderer.\n+ * virtual function.\n+ */\n+ clear: function() {},\n+\n+ /**\n+ * Method: getFeatureIdFromEvent\n+ * Returns a feature id from an event on the renderer. \n+ * How this happens is specific to the renderer. This should be\n+ * called from layer.getFeatureFromEvent().\n+ * Virtual function.\n+ * \n+ * Parameters:\n+ * evt - {} \n+ *\n+ * Returns:\n+ * {String} A feature id or undefined.\n+ */\n+ getFeatureIdFromEvent: function(evt) {},\n+\n+ /**\n+ * Method: eraseFeatures \n+ * This is called by the layer to erase features\n+ * \n+ * Parameters:\n+ * features - {Array()} \n+ */\n+ eraseFeatures: function(features) {\n+ if (!(OpenLayers.Util.isArray(features))) {\n+ features = [features];\n+ }\n+ for (var i = 0, len = features.length; i < len; ++i) {\n+ var feature = features[i];\n+ this.eraseGeometry(feature.geometry, feature.id);\n+ this.removeText(feature.id);\n }\n- this.response = null;\n- this.layer.events.triggerEvent(\"loadend\", {\n- response: resp\n- });\n },\n \n- CLASS_NAME: \"OpenLayers.Strategy.BBOX\"\n+ /**\n+ * Method: eraseGeometry\n+ * Remove a geometry from the renderer (by id).\n+ * virtual function.\n+ * \n+ * Parameters:\n+ * geometry - {} \n+ * featureId - {String}\n+ */\n+ eraseGeometry: function(geometry, featureId) {},\n+\n+ /**\n+ * Method: moveRoot\n+ * moves this renderer's root to a (different) renderer.\n+ * To be implemented by subclasses that require a common renderer root for\n+ * feature selection.\n+ * \n+ * Parameters:\n+ * renderer - {} target renderer for the moved root\n+ */\n+ moveRoot: function(renderer) {},\n+\n+ /**\n+ * Method: getRenderLayerId\n+ * Gets the layer that this renderer's output appears on. If moveRoot was\n+ * used, this will be different from the id of the layer containing the\n+ * features rendered by this renderer.\n+ * \n+ * Returns:\n+ * {String} the id of the output layer.\n+ */\n+ getRenderLayerId: function() {\n+ return this.container.id;\n+ },\n+\n+ /**\n+ * Method: applyDefaultSymbolizer\n+ * \n+ * Parameters:\n+ * symbolizer - {Object}\n+ * \n+ * Returns:\n+ * {Object}\n+ */\n+ applyDefaultSymbolizer: function(symbolizer) {\n+ var result = OpenLayers.Util.extend({},\n+ OpenLayers.Renderer.defaultSymbolizer);\n+ if (symbolizer.stroke === false) {\n+ delete result.strokeWidth;\n+ delete result.strokeColor;\n+ }\n+ if (symbolizer.fill === false) {\n+ delete result.fillColor;\n+ }\n+ OpenLayers.Util.extend(result, symbolizer);\n+ return result;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Renderer\"\n });\n+\n+/**\n+ * Constant: OpenLayers.Renderer.defaultSymbolizer\n+ * {Object} Properties from this symbolizer will be applied to symbolizers\n+ * with missing properties. This can also be used to set a global\n+ * symbolizer default in OpenLayers. To be SLD 1.x compliant, add the\n+ * following code before rendering any vector features:\n+ * (code)\n+ * OpenLayers.Renderer.defaultSymbolizer = {\n+ * fillColor: \"#808080\",\n+ * fillOpacity: 1,\n+ * strokeColor: \"#000000\",\n+ * strokeOpacity: 1,\n+ * strokeWidth: 1,\n+ * pointRadius: 3,\n+ * graphicName: \"square\"\n+ * };\n+ * (end)\n+ */\n+OpenLayers.Renderer.defaultSymbolizer = {\n+ fillColor: \"#000000\",\n+ strokeColor: \"#000000\",\n+ strokeWidth: 2,\n+ fillOpacity: 1,\n+ strokeOpacity: 1,\n+ pointRadius: 0,\n+ labelAlign: 'cm'\n+};\n+\n+\n+\n+/**\n+ * Constant: OpenLayers.Renderer.symbol\n+ * Coordinate arrays for well known (named) symbols.\n+ */\n+OpenLayers.Renderer.symbol = {\n+ \"star\": [350, 75, 379, 161, 469, 161, 397, 215, 423, 301, 350, 250, 277, 301,\n+ 303, 215, 231, 161, 321, 161, 350, 75\n+ ],\n+ \"cross\": [4, 0, 6, 0, 6, 4, 10, 4, 10, 6, 6, 6, 6, 10, 4, 10, 4, 6, 0, 6, 0, 4, 4, 4,\n+ 4, 0\n+ ],\n+ \"x\": [0, 0, 25, 0, 50, 35, 75, 0, 100, 0, 65, 50, 100, 100, 75, 100, 50, 65, 25, 100, 0, 100, 35, 50, 0, 0],\n+ \"square\": [0, 0, 0, 1, 1, 1, 1, 0, 0, 0],\n+ \"triangle\": [0, 10, 10, 10, 5, 0, 0, 10]\n+};\n /* ======================================================================\n- OpenLayers/Strategy/Cluster.js\n+ OpenLayers/Protocol.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Strategy.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n */\n \n /**\n- * Class: OpenLayers.Strategy.Cluster\n- * Strategy for vector feature clustering.\n- *\n- * Inherits from:\n- * - \n+ * Class: OpenLayers.Protocol\n+ * Abstract vector layer protocol class. Not to be instantiated directly. Use\n+ * one of the protocol subclasses instead.\n */\n-OpenLayers.Strategy.Cluster = OpenLayers.Class(OpenLayers.Strategy, {\n-\n- /**\n- * APIProperty: distance\n- * {Integer} Pixel distance between features that should be considered a\n- * single cluster. Default is 20 pixels.\n- */\n- distance: 20,\n-\n- /**\n- * APIProperty: threshold\n- * {Integer} Optional threshold below which original features will be\n- * added to the layer instead of clusters. For example, a threshold\n- * of 3 would mean that any time there are 2 or fewer features in\n- * a cluster, those features will be added directly to the layer instead\n- * of a cluster representing those features. Default is null (which is\n- * equivalent to 1 - meaning that clusters may contain just one feature).\n- */\n- threshold: null,\n+OpenLayers.Protocol = OpenLayers.Class({\n \n /**\n- * Property: features\n- * {Array()} Cached features.\n+ * Property: format\n+ * {} The format used by this protocol.\n */\n- features: null,\n+ format: null,\n \n /**\n- * Property: clusters\n- * {Array()} Calculated clusters.\n+ * Property: options\n+ * {Object} Any options sent to the constructor.\n */\n- clusters: null,\n+ options: null,\n \n /**\n- * Property: clustering\n- * {Boolean} The strategy is currently clustering features.\n+ * Property: autoDestroy\n+ * {Boolean} The creator of the protocol can set autoDestroy to false\n+ * to fully control when the protocol is destroyed. Defaults to\n+ * true.\n */\n- clustering: false,\n+ autoDestroy: true,\n \n /**\n- * Property: resolution\n- * {Float} The resolution (map units per pixel) of the current cluster set.\n+ * Property: defaultFilter\n+ * {} Optional default filter to read requests\n */\n- resolution: null,\n+ defaultFilter: null,\n \n /**\n- * Constructor: OpenLayers.Strategy.Cluster\n- * Create a new clustering strategy.\n+ * Constructor: OpenLayers.Protocol\n+ * Abstract class for vector protocols. Create instances of a subclass.\n *\n * Parameters:\n * options - {Object} Optional object whose properties will be set on the\n * instance.\n */\n+ initialize: function(options) {\n+ options = options || {};\n+ OpenLayers.Util.extend(this, options);\n+ this.options = options;\n+ },\n \n /**\n- * APIMethod: activate\n- * Activate the strategy. Register any listeners, do appropriate setup.\n- * \n- * Returns:\n- * {Boolean} The strategy was successfully activated.\n+ * Method: mergeWithDefaultFilter\n+ * Merge filter passed to the read method with the default one\n+ *\n+ * Parameters:\n+ * filter - {}\n */\n- activate: function() {\n- var activated = OpenLayers.Strategy.prototype.activate.call(this);\n- if (activated) {\n- this.layer.events.on({\n- \"beforefeaturesadded\": this.cacheFeatures,\n- \"featuresremoved\": this.clearCache,\n- \"moveend\": this.cluster,\n- scope: this\n+ mergeWithDefaultFilter: function(filter) {\n+ var merged;\n+ if (filter && this.defaultFilter) {\n+ merged = new OpenLayers.Filter.Logical({\n+ type: OpenLayers.Filter.Logical.AND,\n+ filters: [this.defaultFilter, filter]\n });\n+ } else {\n+ merged = filter || this.defaultFilter || undefined;\n }\n- return activated;\n+ return merged;\n },\n \n /**\n- * APIMethod: deactivate\n- * Deactivate the strategy. Unregister any listeners, do appropriate\n- * tear-down.\n- * \n- * Returns:\n- * {Boolean} The strategy was successfully deactivated.\n+ * APIMethod: destroy\n+ * Clean up the protocol.\n */\n- deactivate: function() {\n- var deactivated = OpenLayers.Strategy.prototype.deactivate.call(this);\n- if (deactivated) {\n- this.clearCache();\n- this.layer.events.un({\n- \"beforefeaturesadded\": this.cacheFeatures,\n- \"featuresremoved\": this.clearCache,\n- \"moveend\": this.cluster,\n- scope: this\n- });\n- }\n- return deactivated;\n+ destroy: function() {\n+ this.options = null;\n+ this.format = null;\n },\n \n /**\n- * Method: cacheFeatures\n- * Cache features before they are added to the layer.\n+ * APIMethod: read\n+ * Construct a request for reading new features.\n *\n * Parameters:\n- * event - {Object} The event that this was listening for. This will come\n- * with a batch of features to be clustered.\n- * \n+ * options - {Object} Optional object for configuring the request.\n+ *\n * Returns:\n- * {Boolean} False to stop features from being added to the layer.\n+ * {} An \n+ * object, the same object will be passed to the callback function passed\n+ * if one exists in the options object.\n */\n- cacheFeatures: function(event) {\n- var propagate = true;\n- if (!this.clustering) {\n- this.clearCache();\n- this.features = event.features;\n- this.cluster();\n- propagate = false;\n- }\n- return propagate;\n+ read: function(options) {\n+ options = options || {};\n+ options.filter = this.mergeWithDefaultFilter(options.filter);\n },\n \n+\n /**\n- * Method: clearCache\n- * Clear out the cached features.\n+ * APIMethod: create\n+ * Construct a request for writing newly created features.\n+ *\n+ * Parameters:\n+ * features - {Array({})} or\n+ * {}\n+ * options - {Object} Optional object for configuring the request.\n+ *\n+ * Returns:\n+ * {} An \n+ * object, the same object will be passed to the callback function passed\n+ * if one exists in the options object.\n */\n- clearCache: function() {\n- if (!this.clustering) {\n- this.features = null;\n- }\n- },\n+ create: function() {},\n \n /**\n- * Method: cluster\n- * Cluster features based on some threshold distance.\n+ * APIMethod: update\n+ * Construct a request updating modified features.\n *\n * Parameters:\n- * event - {Object} The event received when cluster is called as a\n- * result of a moveend event.\n+ * features - {Array({})} or\n+ * {}\n+ * options - {Object} Optional object for configuring the request.\n+ *\n+ * Returns:\n+ * {} An \n+ * object, the same object will be passed to the callback function passed\n+ * if one exists in the options object.\n */\n- cluster: function(event) {\n- if ((!event || event.zoomChanged) && this.features) {\n- var resolution = this.layer.map.getResolution();\n- if (resolution != this.resolution || !this.clustersExist()) {\n- this.resolution = resolution;\n- var clusters = [];\n- var feature, clustered, cluster;\n- for (var i = 0; i < this.features.length; ++i) {\n- feature = this.features[i];\n- if (feature.geometry) {\n- clustered = false;\n- for (var j = clusters.length - 1; j >= 0; --j) {\n- cluster = clusters[j];\n- if (this.shouldCluster(cluster, feature)) {\n- this.addToCluster(cluster, feature);\n- clustered = true;\n- break;\n- }\n- }\n- if (!clustered) {\n- clusters.push(this.createCluster(this.features[i]));\n- }\n- }\n- }\n- this.clustering = true;\n- this.layer.removeAllFeatures();\n- this.clustering = false;\n- if (clusters.length > 0) {\n- if (this.threshold > 1) {\n- var clone = clusters.slice();\n- clusters = [];\n- var candidate;\n- for (var i = 0, len = clone.length; i < len; ++i) {\n- candidate = clone[i];\n- if (candidate.attributes.count < this.threshold) {\n- Array.prototype.push.apply(clusters, candidate.cluster);\n- } else {\n- clusters.push(candidate);\n- }\n- }\n- }\n- this.clustering = true;\n- // A legitimate feature addition could occur during this\n- // addFeatures call. For clustering to behave well, features\n- // should be removed from a layer before requesting a new batch.\n- this.layer.addFeatures(clusters);\n- this.clustering = false;\n- }\n- this.clusters = clusters;\n- }\n- }\n- },\n+ update: function() {},\n \n /**\n- * Method: clustersExist\n- * Determine whether calculated clusters are already on the layer.\n+ * APIMethod: delete\n+ * Construct a request deleting a removed feature.\n+ *\n+ * Parameters:\n+ * feature - {}\n+ * options - {Object} Optional object for configuring the request.\n *\n * Returns:\n- * {Boolean} The calculated clusters are already on the layer.\n+ * {} An \n+ * object, the same object will be passed to the callback function passed\n+ * if one exists in the options object.\n */\n- clustersExist: function() {\n- var exist = false;\n- if (this.clusters && this.clusters.length > 0 &&\n- this.clusters.length == this.layer.features.length) {\n- exist = true;\n- for (var i = 0; i < this.clusters.length; ++i) {\n- if (this.clusters[i] != this.layer.features[i]) {\n- exist = false;\n- break;\n- }\n- }\n- }\n- return exist;\n- },\n+ \"delete\": function() {},\n \n /**\n- * Method: shouldCluster\n- * Determine whether to include a feature in a given cluster.\n+ * APIMethod: commit\n+ * Go over the features and for each take action\n+ * based on the feature state. Possible actions are create,\n+ * update and delete.\n *\n * Parameters:\n- * cluster - {} A cluster.\n- * feature - {} A feature.\n+ * features - {Array({})}\n+ * options - {Object} Object whose possible keys are \"create\", \"update\",\n+ * \"delete\", \"callback\" and \"scope\", the values referenced by the\n+ * first three are objects as passed to the \"create\", \"update\", and\n+ * \"delete\" methods, the value referenced by the \"callback\" key is\n+ * a function which is called when the commit operation is complete\n+ * using the scope referenced by the \"scope\" key.\n *\n * Returns:\n- * {Boolean} The feature should be included in the cluster.\n+ * {Array({})} An array of\n+ * objects.\n */\n- shouldCluster: function(cluster, feature) {\n- var cc = cluster.geometry.getBounds().getCenterLonLat();\n- var fc = feature.geometry.getBounds().getCenterLonLat();\n- var distance = (\n- Math.sqrt(\n- Math.pow((cc.lon - fc.lon), 2) + Math.pow((cc.lat - fc.lat), 2)\n- ) / this.resolution\n- );\n- return (distance <= this.distance);\n- },\n+ commit: function() {},\n \n /**\n- * Method: addToCluster\n- * Add a feature to a cluster.\n+ * Method: abort\n+ * Abort an ongoing request.\n *\n * Parameters:\n- * cluster - {} A cluster.\n- * feature - {} A feature.\n+ * response - {}\n */\n- addToCluster: function(cluster, feature) {\n- cluster.cluster.push(feature);\n- cluster.attributes.count += 1;\n- },\n+ abort: function(response) {},\n \n /**\n- * Method: createCluster\n- * Given a feature, create a cluster.\n+ * Method: createCallback\n+ * Returns a function that applies the given public method with resp and\n+ * options arguments.\n *\n * Parameters:\n- * feature - {}\n- *\n- * Returns:\n- * {} A cluster.\n+ * method - {Function} The method to be applied by the callback.\n+ * response - {} The protocol response object.\n+ * options - {Object} Options sent to the protocol method\n */\n- createCluster: function(feature) {\n- var center = feature.geometry.getBounds().getCenterLonLat();\n- var cluster = new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.Point(center.lon, center.lat), {\n- count: 1\n- }\n- );\n- cluster.cluster = [feature];\n- return cluster;\n+ createCallback: function(method, response, options) {\n+ return OpenLayers.Function.bind(function() {\n+ method.apply(this, [response, options]);\n+ }, this);\n },\n \n- CLASS_NAME: \"OpenLayers.Strategy.Cluster\"\n+ CLASS_NAME: \"OpenLayers.Protocol\"\n });\n-/* ======================================================================\n- OpenLayers/Strategy/Refresh.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Strategy.js\n- */\n \n /**\n- * Class: OpenLayers.Strategy.Refresh\n- * A strategy that refreshes the layer. By default the strategy waits for a\n- * call to before refreshing. By configuring the strategy with \n- * the option, refreshing can take place automatically.\n- *\n- * Inherits from:\n- * - \n+ * Class: OpenLayers.Protocol.Response\n+ * Protocols return Response objects to their users.\n */\n-OpenLayers.Strategy.Refresh = OpenLayers.Class(OpenLayers.Strategy, {\n-\n+OpenLayers.Protocol.Response = OpenLayers.Class({\n /**\n- * Property: force\n- * {Boolean} Force a refresh on the layer. Default is false.\n+ * Property: code\n+ * {Number} - OpenLayers.Protocol.Response.SUCCESS or\n+ * OpenLayers.Protocol.Response.FAILURE\n */\n- force: false,\n+ code: null,\n \n /**\n- * Property: interval\n- * {Number} Auto-refresh. Default is 0. If > 0, layer will be refreshed \n- * every N milliseconds.\n+ * Property: requestType\n+ * {String} The type of request this response corresponds to. Either\n+ * \"create\", \"read\", \"update\" or \"delete\".\n */\n- interval: 0,\n+ requestType: null,\n \n /**\n- * Property: timer\n- * {Number} The id of the timer.\n+ * Property: last\n+ * {Boolean} - true if this is the last response expected in a commit,\n+ * false otherwise, defaults to true.\n */\n- timer: null,\n+ last: true,\n \n /**\n- * Constructor: OpenLayers.Strategy.Refresh\n- * Create a new Refresh strategy.\n- *\n- * Parameters:\n- * options - {Object} Optional object whose properties will be set on the\n- * instance.\n+ * Property: features\n+ * {Array({})} or {}\n+ * The features returned in the response by the server. Depending on the \n+ * protocol's read payload, either features or data will be populated.\n */\n+ features: null,\n \n /**\n- * APIMethod: activate\n- * Activate the strategy. Register any listeners, do appropriate setup.\n- * \n- * Returns:\n- * {Boolean} True if the strategy was successfully activated.\n+ * Property: data\n+ * {Object}\n+ * The data returned in the response by the server. Depending on the \n+ * protocol's read payload, either features or data will be populated.\n */\n- activate: function() {\n- var activated = OpenLayers.Strategy.prototype.activate.call(this);\n- if (activated) {\n- if (this.layer.visibility === true) {\n- this.start();\n- }\n- this.layer.events.on({\n- \"visibilitychanged\": this.reset,\n- scope: this\n- });\n- }\n- return activated;\n- },\n+ data: null,\n \n /**\n- * APIMethod: deactivate\n- * Deactivate the strategy. Unregister any listeners, do appropriate\n- * tear-down.\n- * \n- * Returns:\n- * {Boolean} True if the strategy was successfully deactivated.\n+ * Property: reqFeatures\n+ * {Array({})} or {}\n+ * The features provided by the user and placed in the request by the\n+ * protocol.\n */\n- deactivate: function() {\n- var deactivated = OpenLayers.Strategy.prototype.deactivate.call(this);\n- if (deactivated) {\n- this.stop();\n- this.layer.events.un({\n- \"visibilitychanged\": this.reset,\n- scope: this\n- });\n- }\n- return deactivated;\n- },\n+ reqFeatures: null,\n \n /**\n- * Method: reset\n- * Start or cancel the refresh interval depending on the visibility of \n- * the layer.\n+ * Property: priv\n */\n- reset: function() {\n- if (this.layer.visibility === true) {\n- this.start();\n- } else {\n- this.stop();\n- }\n- },\n+ priv: null,\n \n /**\n- * Method: start\n- * Start the refresh interval. \n+ * Property: error\n+ * {Object} The error object in case a service exception was encountered.\n */\n- start: function() {\n- if (this.interval && typeof this.interval === \"number\" &&\n- this.interval > 0) {\n-\n- this.timer = window.setInterval(\n- OpenLayers.Function.bind(this.refresh, this),\n- this.interval);\n- }\n- },\n+ error: null,\n \n /**\n- * APIMethod: refresh\n- * Tell the strategy to refresh which will refresh the layer.\n+ * Constructor: OpenLayers.Protocol.Response\n+ *\n+ * Parameters:\n+ * options - {Object} Optional object whose properties will be set on the\n+ * instance.\n */\n- refresh: function() {\n- if (this.layer && this.layer.refresh &&\n- typeof this.layer.refresh == \"function\") {\n-\n- this.layer.refresh({\n- force: this.force\n- });\n- }\n+ initialize: function(options) {\n+ OpenLayers.Util.extend(this, options);\n },\n \n /**\n- * Method: stop\n- * Cancels the refresh interval. \n+ * Method: success\n+ *\n+ * Returns:\n+ * {Boolean} - true on success, false otherwise\n */\n- stop: function() {\n- if (this.timer !== null) {\n- window.clearInterval(this.timer);\n- this.timer = null;\n- }\n+ success: function() {\n+ return this.code > 0;\n },\n \n- CLASS_NAME: \"OpenLayers.Strategy.Refresh\"\n+ CLASS_NAME: \"OpenLayers.Protocol.Response\"\n });\n-/* ======================================================================\n- OpenLayers/Control/Button.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Control.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.Button \n- * The Button control is a very simple push-button, for use with \n- * .\n- * When clicked, the function trigger() is executed.\n- * \n- * Inherits from:\n- * - \n- *\n- * Use:\n- * (code)\n- * var button = new OpenLayers.Control.Button({\n- * displayClass: \"MyButton\", trigger: myFunction\n- * });\n- * panel.addControls([button]);\n- * (end)\n- * \n- * Will create a button with CSS class MyButtonItemInactive, that\n- * will call the function MyFunction() when clicked.\n- */\n-OpenLayers.Control.Button = OpenLayers.Class(OpenLayers.Control, {\n- /**\n- * Property: type\n- * {Integer} OpenLayers.Control.TYPE_BUTTON.\n- */\n- type: OpenLayers.Control.TYPE_BUTTON,\n-\n- /**\n- * Method: trigger\n- * Called by a control panel when the button is clicked.\n- */\n- trigger: function() {},\n \n- CLASS_NAME: \"OpenLayers.Control.Button\"\n-});\n+OpenLayers.Protocol.Response.SUCCESS = 1;\n+OpenLayers.Protocol.Response.FAILURE = 0;\n /* ======================================================================\n- OpenLayers/Handler/Click.js\n+ OpenLayers/Layer/HTTPRequest.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Handler.js\n+ * @requires OpenLayers/Layer.js\n */\n \n /**\n- * Class: OpenLayers.Handler.Click\n- * A handler for mouse clicks. The intention of this handler is to give\n- * controls more flexibility with handling clicks. Browsers trigger\n- * click events twice for a double-click. In addition, the mousedown,\n- * mousemove, mouseup sequence fires a click event. With this handler,\n- * controls can decide whether to ignore clicks associated with a double\n- * click. By setting a , controls can also ignore clicks\n- * that include a drag. Create a new instance with the\n- * constructor.\n+ * Class: OpenLayers.Layer.HTTPRequest\n * \n- * Inherits from:\n- * - \n+ * Inherits from: \n+ * - \n */\n-OpenLayers.Handler.Click = OpenLayers.Class(OpenLayers.Handler, {\n- /**\n- * APIProperty: delay\n- * {Number} Number of milliseconds between clicks before the event is\n- * considered a double-click.\n- */\n- delay: 300,\n-\n- /**\n- * APIProperty: single\n- * {Boolean} Handle single clicks. Default is true. If false, clicks\n- * will not be reported. If true, single-clicks will be reported.\n- */\n- single: true,\n-\n- /**\n- * APIProperty: double\n- * {Boolean} Handle double-clicks. Default is false.\n- */\n- 'double': false,\n-\n- /**\n- * APIProperty: pixelTolerance\n- * {Number} Maximum number of pixels between mouseup and mousedown for an\n- * event to be considered a click. Default is 0. If set to an\n- * integer value, clicks with a drag greater than the value will be\n- * ignored. This property can only be set when the handler is\n- * constructed.\n- */\n- pixelTolerance: 0,\n-\n- /**\n- * APIProperty: dblclickTolerance\n- * {Number} Maximum distance in pixels between clicks for a sequence of \n- * events to be considered a double click. Default is 13. If the\n- * distance between two clicks is greater than this value, a double-\n- * click will not be fired.\n- */\n- dblclickTolerance: 13,\n-\n- /**\n- * APIProperty: stopSingle\n- * {Boolean} Stop other listeners from being notified of clicks. Default\n- * is false. If true, any listeners registered before this one for \n- * click or rightclick events will not be notified.\n- */\n- stopSingle: false,\n-\n- /**\n- * APIProperty: stopDouble\n- * {Boolean} Stop other listeners from being notified of double-clicks.\n- * Default is false. If true, any click listeners registered before\n- * this one will not be notified of *any* double-click events.\n- * \n- * The one caveat with stopDouble is that given a map with two click\n- * handlers, one with stopDouble true and the other with stopSingle\n- * true, the stopSingle handler should be activated last to get\n- * uniform cross-browser performance. Since IE triggers one click\n- * with a dblclick and FF triggers two, if a stopSingle handler is\n- * activated first, all it gets in IE is a single click when the\n- * second handler stops propagation on the dblclick.\n- */\n- stopDouble: false,\n-\n- /**\n- * Property: timerId\n- * {Number} The id of the timeout waiting to clear the .\n- */\n- timerId: null,\n+OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {\n \n- /**\n- * Property: down\n- * {Object} Object that store relevant information about the last\n- * mousedown or touchstart. Its 'xy' OpenLayers.Pixel property gives\n- * the average location of the mouse/touch event. Its 'touches'\n- * property records clientX/clientY of each touches.\n+ /** \n+ * Constant: URL_HASH_FACTOR\n+ * {Float} Used to hash URL param strings for multi-WMS server selection.\n+ * Set to the Golden Ratio per Knuth's recommendation.\n */\n- down: null,\n+ URL_HASH_FACTOR: (Math.sqrt(5) - 1) / 2,\n \n- /**\n- * Property: last\n- * {Object} Object that store relevant information about the last\n- * mousemove or touchmove. Its 'xy' OpenLayers.Pixel property gives\n- * the average location of the mouse/touch event. Its 'touches'\n- * property records clientX/clientY of each touches.\n+ /** \n+ * Property: url\n+ * {Array(String) or String} This is either an array of url strings or \n+ * a single url string. \n */\n- last: null,\n+ url: null,\n \n /** \n- * Property: first\n- * {Object} When waiting for double clicks, this object will store \n- * information about the first click in a two click sequence.\n+ * Property: params\n+ * {Object} Hashtable of key/value parameters\n */\n- first: null,\n+ params: null,\n \n- /**\n- * Property: rightclickTimerId\n- * {Number} The id of the right mouse timeout waiting to clear the \n- * .\n+ /** \n+ * APIProperty: reproject\n+ * *Deprecated*. See http://docs.openlayers.org/library/spherical_mercator.html\n+ * for information on the replacement for this functionality. \n+ * {Boolean} Whether layer should reproject itself based on base layer \n+ * locations. This allows reprojection onto commercial layers. \n+ * Default is false: Most layers can't reproject, but layers \n+ * which can create non-square geographic pixels can, like WMS.\n+ * \n */\n- rightclickTimerId: null,\n+ reproject: false,\n \n /**\n- * Constructor: OpenLayers.Handler.Click\n- * Create a new click handler.\n+ * Constructor: OpenLayers.Layer.HTTPRequest\n * \n * Parameters:\n- * control - {} The control that is making use of\n- * this handler. If a handler is being used without a control, the\n- * handler's setMap method must be overridden to deal properly with\n- * the map.\n- * callbacks - {Object} An object with keys corresponding to callbacks\n- * that will be called by the handler. The callbacks should\n- * expect to recieve a single argument, the click event.\n- * Callbacks for 'click' and 'dblclick' are supported.\n- * options - {Object} Optional object whose properties will be set on the\n- * handler.\n- */\n-\n- /**\n- * Method: touchstart\n- * Handle touchstart.\n- *\n- * Returns:\n- * {Boolean} Continue propagating this event.\n- */\n- touchstart: function(evt) {\n- this.startTouch();\n- this.down = this.getEventInfo(evt);\n- this.last = this.getEventInfo(evt);\n- return true;\n- },\n-\n- /**\n- * Method: touchmove\n- * Store position of last move, because touchend event can have\n- * an empty \"touches\" property.\n- *\n- * Returns:\n- * {Boolean} Continue propagating this event.\n- */\n- touchmove: function(evt) {\n- this.last = this.getEventInfo(evt);\n- return true;\n- },\n-\n- /**\n- * Method: touchend\n- * Correctly set event xy property, and add lastTouches to have\n- * touches property from last touchstart or touchmove\n- *\n- * Returns:\n- * {Boolean} Continue propagating this event.\n+ * name - {String}\n+ * url - {Array(String) or String}\n+ * params - {Object}\n+ * options - {Object} Hashtable of extra options to tag onto the layer\n */\n- touchend: function(evt) {\n- // touchstart may not have been allowed to propagate\n- if (this.down) {\n- evt.xy = this.last.xy;\n- evt.lastTouches = this.last.touches;\n- this.handleSingle(evt);\n- this.down = null;\n+ initialize: function(name, url, params, options) {\n+ OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);\n+ this.url = url;\n+ if (!this.params) {\n+ this.params = OpenLayers.Util.extend({}, params);\n }\n- return true;\n },\n \n /**\n- * Method: mousedown\n- * Handle mousedown.\n- *\n- * Returns:\n- * {Boolean} Continue propagating this event.\n+ * APIMethod: destroy\n */\n- mousedown: function(evt) {\n- this.down = this.getEventInfo(evt);\n- this.last = this.getEventInfo(evt);\n- return true;\n+ destroy: function() {\n+ this.url = null;\n+ this.params = null;\n+ OpenLayers.Layer.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * Method: mouseup\n- * Handle mouseup. Installed to support collection of right mouse events.\n+ * APIMethod: clone\n+ * \n+ * Parameters:\n+ * obj - {Object}\n * \n * Returns:\n- * {Boolean} Continue propagating this event.\n+ * {} An exact clone of this \n+ * \n */\n- mouseup: function(evt) {\n- var propagate = true;\n+ clone: function(obj) {\n \n- // Collect right mouse clicks from the mouseup\n- // IE - ignores the second right click in mousedown so using\n- // mouseup instead\n- if (this.checkModifiers(evt) && this.control.handleRightClicks &&\n- OpenLayers.Event.isRightClick(evt)) {\n- propagate = this.rightclick(evt);\n+ if (obj == null) {\n+ obj = new OpenLayers.Layer.HTTPRequest(this.name,\n+ this.url,\n+ this.params,\n+ this.getOptions());\n }\n \n- return propagate;\n- },\n+ //get all additions from superclasses\n+ obj = OpenLayers.Layer.prototype.clone.apply(this, [obj]);\n \n- /**\n- * Method: rightclick\n- * Handle rightclick. For a dblrightclick, we get two clicks so we need \n- * to always register for dblrightclick to properly handle single \n- * clicks.\n- * \n- * Returns:\n- * {Boolean} Continue propagating this event.\n- */\n- rightclick: function(evt) {\n- if (this.passesTolerance(evt)) {\n- if (this.rightclickTimerId != null) {\n- //Second click received before timeout this must be \n- // a double click\n- this.clearTimer();\n- this.callback('dblrightclick', [evt]);\n- return !this.stopDouble;\n- } else {\n- //Set the rightclickTimerId, send evt only if double is \n- // true else trigger single\n- var clickEvent = this['double'] ?\n- OpenLayers.Util.extend({}, evt) :\n- this.callback('rightclick', [evt]);\n+ // copy/set any non-init, non-simple values here\n \n- var delayedRightCall = OpenLayers.Function.bind(\n- this.delayedRightCall,\n- this,\n- clickEvent\n- );\n- this.rightclickTimerId = window.setTimeout(\n- delayedRightCall, this.delay\n- );\n- }\n- }\n- return !this.stopSingle;\n+ return obj;\n },\n \n- /**\n- * Method: delayedRightCall\n- * Sets to null. And optionally triggers the \n- * rightclick callback if evt is set.\n+ /** \n+ * APIMethod: setUrl\n+ * \n+ * Parameters:\n+ * newUrl - {String}\n */\n- delayedRightCall: function(evt) {\n- this.rightclickTimerId = null;\n- if (evt) {\n- this.callback('rightclick', [evt]);\n- }\n+ setUrl: function(newUrl) {\n+ this.url = newUrl;\n },\n \n /**\n- * Method: click\n- * Handle click events from the browser. This is registered as a listener\n- * for click events and should not be called from other events in this\n- * handler.\n+ * APIMethod: mergeNewParams\n+ * \n+ * Parameters:\n+ * newParams - {Object}\n *\n * Returns:\n- * {Boolean} Continue propagating this event.\n+ * redrawn: {Boolean} whether the layer was actually redrawn.\n */\n- click: function(evt) {\n- if (!this.last) {\n- this.last = this.getEventInfo(evt);\n+ mergeNewParams: function(newParams) {\n+ this.params = OpenLayers.Util.extend(this.params, newParams);\n+ var ret = this.redraw();\n+ if (this.map != null) {\n+ this.map.events.triggerEvent(\"changelayer\", {\n+ layer: this,\n+ property: \"params\"\n+ });\n }\n- this.handleSingle(evt);\n- return !this.stopSingle;\n+ return ret;\n },\n \n /**\n- * Method: dblclick\n- * Handle dblclick. For a dblclick, we get two clicks in some browsers\n- * (FF) and one in others (IE). So we need to always register for\n- * dblclick to properly handle single clicks. This method is registered\n- * as a listener for the dblclick browser event. It should *not* be\n- * called by other methods in this handler.\n- * \n+ * APIMethod: redraw\n+ * Redraws the layer. Returns true if the layer was redrawn, false if not.\n+ *\n+ * Parameters:\n+ * force - {Boolean} Force redraw by adding random parameter.\n+ *\n * Returns:\n- * {Boolean} Continue propagating this event.\n- */\n- dblclick: function(evt) {\n- this.handleDouble(evt);\n- return !this.stopDouble;\n- },\n-\n- /** \n- * Method: handleDouble\n- * Handle double-click sequence.\n- */\n- handleDouble: function(evt) {\n- if (this.passesDblclickTolerance(evt)) {\n- if (this[\"double\"]) {\n- this.callback(\"dblclick\", [evt]);\n- }\n- // to prevent a dblclick from firing the click callback in IE\n- this.clearTimer();\n- }\n- },\n-\n- /** \n- * Method: handleSingle\n- * Handle single click sequence.\n+ * {Boolean} The layer was redrawn.\n */\n- handleSingle: function(evt) {\n- if (this.passesTolerance(evt)) {\n- if (this.timerId != null) {\n- // already received a click\n- if (this.last.touches && this.last.touches.length === 1) {\n- // touch device, no dblclick event - this may be a double\n- if (this[\"double\"]) {\n- // on Android don't let the browser zoom on the page\n- OpenLayers.Event.preventDefault(evt);\n- }\n- this.handleDouble(evt);\n- }\n- // if we're not in a touch environment we clear the click timer\n- // if we've got a second touch, we'll get two touchend events\n- if (!this.last.touches || this.last.touches.length !== 2) {\n- this.clearTimer();\n- }\n- } else {\n- // remember the first click info so we can compare to the second\n- this.first = this.getEventInfo(evt);\n- // set the timer, send evt only if single is true\n- //use a clone of the event object because it will no longer \n- //be a valid event object in IE in the timer callback\n- var clickEvent = this.single ?\n- OpenLayers.Util.extend({}, evt) : null;\n- this.queuePotentialClick(clickEvent);\n- }\n+ redraw: function(force) {\n+ if (force) {\n+ return this.mergeNewParams({\n+ \"_olSalt\": Math.random()\n+ });\n+ } else {\n+ return OpenLayers.Layer.prototype.redraw.apply(this, []);\n }\n },\n \n- /** \n- * Method: queuePotentialClick\n- * This method is separated out largely to make testing easier (so we\n- * don't have to override window.setTimeout)\n- */\n- queuePotentialClick: function(evt) {\n- this.timerId = window.setTimeout(\n- OpenLayers.Function.bind(this.delayedCall, this, evt),\n- this.delay\n- );\n- },\n-\n /**\n- * Method: passesTolerance\n- * Determine whether the event is within the optional pixel tolerance. Note\n- * that the pixel tolerance check only works if mousedown events get to\n- * the listeners registered here. If they are stopped by other elements,\n- * the will have no effect here (this method will always\n- * return true).\n+ * Method: selectUrl\n+ * selectUrl() implements the standard floating-point multiplicative\n+ * hash function described by Knuth, and hashes the contents of the \n+ * given param string into a float between 0 and 1. This float is then\n+ * scaled to the size of the provided urls array, and used to select\n+ * a URL.\n *\n+ * Parameters:\n+ * paramString - {String}\n+ * urls - {Array(String)}\n+ * \n * Returns:\n- * {Boolean} The click is within the pixel tolerance (if specified).\n+ * {String} An entry from the urls array, deterministically selected based\n+ * on the paramString.\n */\n- passesTolerance: function(evt) {\n- var passes = true;\n- if (this.pixelTolerance != null && this.down && this.down.xy) {\n- passes = this.pixelTolerance >= this.down.xy.distanceTo(evt.xy);\n- // for touch environments, we also enforce that all touches\n- // start and end within the given tolerance to be considered a click\n- if (passes && this.touch &&\n- this.down.touches.length === this.last.touches.length) {\n- // the touchend event doesn't come with touches, so we check\n- // down and last\n- for (var i = 0, ii = this.down.touches.length; i < ii; ++i) {\n- if (this.getTouchDistance(\n- this.down.touches[i],\n- this.last.touches[i]\n- ) > this.pixelTolerance) {\n- passes = false;\n- break;\n- }\n- }\n- }\n+ selectUrl: function(paramString, urls) {\n+ var product = 1;\n+ for (var i = 0, len = paramString.length; i < len; i++) {\n+ product *= paramString.charCodeAt(i) * this.URL_HASH_FACTOR;\n+ product -= Math.floor(product);\n }\n- return passes;\n+ return urls[Math.floor(product * urls.length)];\n },\n \n /** \n- * Method: getTouchDistance\n+ * Method: getFullRequestString\n+ * Combine url with layer's params and these newParams. \n+ * \n+ * does checking on the serverPath variable, allowing for cases when it \n+ * is supplied with trailing ? or &, as well as cases where not. \n *\n- * Returns:\n- * {Boolean} The pixel displacement between two touches.\n- */\n- getTouchDistance: function(from, to) {\n- return Math.sqrt(\n- Math.pow(from.clientX - to.clientX, 2) +\n- Math.pow(from.clientY - to.clientY, 2)\n- );\n- },\n-\n- /**\n- * Method: passesDblclickTolerance\n- * Determine whether the event is within the optional double-cick pixel \n- * tolerance.\n+ * return in formatted string like this:\n+ * \"server?key1=value1&key2=value2&key3=value3\"\n+ * \n+ * WARNING: The altUrl parameter is deprecated and will be removed in 3.0.\n *\n- * Returns:\n- * {Boolean} The click is within the double-click pixel tolerance.\n+ * Parameters:\n+ * newParams - {Object}\n+ * altUrl - {String} Use this as the url instead of the layer's url\n+ * \n+ * Returns: \n+ * {String}\n */\n- passesDblclickTolerance: function(evt) {\n- var passes = true;\n- if (this.down && this.first) {\n- passes = this.down.xy.distanceTo(this.first.xy) <= this.dblclickTolerance;\n- }\n- return passes;\n- },\n+ getFullRequestString: function(newParams, altUrl) {\n \n- /**\n- * Method: clearTimer\n- * Clear the timer and set to null.\n- */\n- clearTimer: function() {\n- if (this.timerId != null) {\n- window.clearTimeout(this.timerId);\n- this.timerId = null;\n- }\n- if (this.rightclickTimerId != null) {\n- window.clearTimeout(this.rightclickTimerId);\n- this.rightclickTimerId = null;\n- }\n- },\n+ // if not altUrl passed in, use layer's url\n+ var url = altUrl || this.url;\n \n- /**\n- * Method: delayedCall\n- * Sets to null. And optionally triggers the click callback if\n- * evt is set.\n- */\n- delayedCall: function(evt) {\n- this.timerId = null;\n- if (evt) {\n- this.callback(\"click\", [evt]);\n+ // create a new params hashtable with all the layer params and the \n+ // new params together. then convert to string\n+ var allParams = OpenLayers.Util.extend({}, this.params);\n+ allParams = OpenLayers.Util.extend(allParams, newParams);\n+ var paramsString = OpenLayers.Util.getParameterString(allParams);\n+\n+ // if url is not a string, it should be an array of strings, \n+ // in which case we will deterministically select one of them in \n+ // order to evenly distribute requests to different urls.\n+ //\n+ if (OpenLayers.Util.isArray(url)) {\n+ url = this.selectUrl(paramsString, url);\n }\n- },\n \n- /**\n- * Method: getEventInfo\n- * This method allows us to store event information without storing the\n- * actual event. In touch devices (at least), the same event is \n- * modified between touchstart, touchmove, and touchend.\n- *\n- * Returns:\n- * {Object} An object with event related info.\n- */\n- getEventInfo: function(evt) {\n- var touches;\n- if (evt.touches) {\n- var len = evt.touches.length;\n- touches = new Array(len);\n- var touch;\n- for (var i = 0; i < len; i++) {\n- touch = evt.touches[i];\n- touches[i] = {\n- clientX: touch.olClientX,\n- clientY: touch.olClientY\n- };\n+ // ignore parameters that are already in the url search string\n+ var urlParams =\n+ OpenLayers.Util.upperCaseObject(OpenLayers.Util.getParameters(url));\n+ for (var key in allParams) {\n+ if (key.toUpperCase() in urlParams) {\n+ delete allParams[key];\n }\n }\n- return {\n- xy: evt.xy,\n- touches: touches\n- };\n- },\n+ paramsString = OpenLayers.Util.getParameterString(allParams);\n \n- /**\n- * APIMethod: deactivate\n- * Deactivate the handler.\n- *\n- * Returns:\n- * {Boolean} The handler was successfully deactivated.\n- */\n- deactivate: function() {\n- var deactivated = false;\n- if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- this.clearTimer();\n- this.down = null;\n- this.first = null;\n- this.last = null;\n- deactivated = true;\n- }\n- return deactivated;\n+ return OpenLayers.Util.urlAppend(url, paramsString);\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.Click\"\n+ CLASS_NAME: \"OpenLayers.Layer.HTTPRequest\"\n });\n /* ======================================================================\n- OpenLayers/Handler/Hover.js\n+ OpenLayers/Tile/Image.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Handler.js\n+ * @requires OpenLayers/Tile.js\n+ * @requires OpenLayers/Animation.js\n+ * @requires OpenLayers/Util.js\n */\n \n /**\n- * Class: OpenLayers.Handler.Hover\n- * The hover handler is to be used to emulate mouseovers on objects\n- * on the map that aren't DOM elements. For example one can use\n- * this handler to send WMS/GetFeatureInfo requests as the user\n- * moves the mouve over the map.\n- * \n+ * Class: OpenLayers.Tile.Image\n+ * Instances of OpenLayers.Tile.Image are used to manage the image tiles\n+ * used by various layers. Create a new image tile with the\n+ * constructor.\n+ *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Handler.Hover = OpenLayers.Class(OpenLayers.Handler, {\n+OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {\n \n /**\n- * APIProperty: delay\n- * {Integer} - Number of milliseconds between mousemoves before\n- * the event is considered a hover. Default is 500.\n+ * APIProperty: events\n+ * {} An events object that handles all \n+ * events on the tile.\n+ *\n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * tile.events.register(type, obj, listener);\n+ * (end)\n+ *\n+ * Supported event types (in addition to the events):\n+ * beforeload - Triggered before an image is prepared for loading, when the\n+ * url for the image is known already. Listeners may call on\n+ * the tile instance. If they do so, that image will be used and no new\n+ * one will be created.\n */\n- delay: 500,\n \n- /**\n- * APIProperty: pixelTolerance\n- * {Integer} - Maximum number of pixels between mousemoves for\n- * an event to be considered a hover. Default is null.\n+ /** \n+ * APIProperty: url\n+ * {String} The URL of the image being requested. No default. Filled in by\n+ * layer.getURL() function. May be modified by loadstart listeners.\n */\n- pixelTolerance: null,\n+ url: null,\n+\n+ /** \n+ * Property: imgDiv\n+ * {HTMLImageElement} The image for this tile.\n+ */\n+ imgDiv: null,\n \n /**\n- * APIProperty: stopMove\n- * {Boolean} - Stop other listeners from being notified on mousemoves.\n- * Default is false.\n+ * Property: frame\n+ * {DOMElement} The image element is appended to the frame. Any gutter on\n+ * the image will be hidden behind the frame. If no gutter is set,\n+ * this will be null.\n */\n- stopMove: false,\n+ frame: null,\n+\n+ /** \n+ * Property: imageReloadAttempts\n+ * {Integer} Attempts to load the image.\n+ */\n+ imageReloadAttempts: null,\n \n /**\n- * Property: px\n- * {} - The location of the last mousemove, expressed\n- * in pixels.\n+ * Property: layerAlphaHack\n+ * {Boolean} True if the png alpha hack needs to be applied on the layer's div.\n */\n- px: null,\n+ layerAlphaHack: null,\n \n /**\n- * Property: timerId\n- * {Number} - The id of the timer.\n+ * Property: asyncRequestId\n+ * {Integer} ID of an request to see if request is still valid. This is a\n+ * number which increments by 1 for each asynchronous request.\n */\n- timerId: null,\n+ asyncRequestId: null,\n \n /**\n- * Constructor: OpenLayers.Handler.Hover\n- * Construct a hover handler.\n+ * APIProperty: maxGetUrlLength\n+ * {Number} If set, requests that would result in GET urls with more\n+ * characters than the number provided will be made using form-encoded\n+ * HTTP POST. It is good practice to avoid urls that are longer than 2048\n+ * characters.\n *\n- * Parameters:\n- * control - {} The control that initialized this\n- * handler. The control is assumed to have a valid map property; that\n- * map is used in the handler's own setMap method.\n- * callbacks - {Object} An object with keys corresponding to callbacks\n- * that will be called by the handler. The callbacks should\n- * expect to receive a single argument, the event. Callbacks for\n- * 'move', the mouse is moving, and 'pause', the mouse is pausing,\n- * are supported.\n- * options - {Object} An optional object whose properties will be set on\n- * the handler.\n+ * Caution:\n+ * Older versions of Gecko based browsers (e.g. Firefox < 3.5) and most\n+ * Opera versions do not fully support this option. On all browsers,\n+ * transition effects are not supported if POST requests are used.\n */\n+ maxGetUrlLength: null,\n \n /**\n- * Method: mousemove\n- * Called when the mouse moves on the map.\n- *\n+ * Property: canvasContext\n+ * {CanvasRenderingContext2D} A canvas context associated with\n+ * the tile image.\n+ */\n+ canvasContext: null,\n+\n+ /**\n+ * APIProperty: crossOriginKeyword\n+ * The value of the crossorigin keyword to use when loading images. This is\n+ * only relevant when using for tiles from remote\n+ * origins and should be set to either 'anonymous' or 'use-credentials'\n+ * for servers that send Access-Control-Allow-Origin headers with their\n+ * tiles.\n+ */\n+ crossOriginKeyword: null,\n+\n+ /** TBD 3.0 - reorder the parameters to the init function to remove \n+ * URL. the getUrl() function on the layer gets called on \n+ * each draw(), so no need to specify it here.\n+ */\n+\n+ /** \n+ * Constructor: OpenLayers.Tile.Image\n+ * Constructor for a new instance.\n+ * \n * Parameters:\n- * evt - {}\n- *\n- * Returns:\n- * {Boolean} Continue propagating this event.\n+ * layer - {} layer that the tile will go in.\n+ * position - {}\n+ * bounds - {}\n+ * url - {} Deprecated. Remove me in 3.0.\n+ * size - {}\n+ * options - {Object}\n */\n- mousemove: function(evt) {\n- if (this.passesTolerance(evt.xy)) {\n- this.clearTimer();\n- this.callback('move', [evt]);\n- this.px = evt.xy;\n- // clone the evt so original properties can be accessed even\n- // if the browser deletes them during the delay\n- evt = OpenLayers.Util.extend({}, evt);\n- this.timerId = window.setTimeout(\n- OpenLayers.Function.bind(this.delayedCall, this, evt),\n- this.delay\n- );\n+ initialize: function(layer, position, bounds, url, size, options) {\n+ OpenLayers.Tile.prototype.initialize.apply(this, arguments);\n+\n+ this.url = url; //deprecated remove me\n+\n+ this.layerAlphaHack = this.layer.alpha && OpenLayers.Util.alphaHack();\n+\n+ if (this.maxGetUrlLength != null || this.layer.gutter || this.layerAlphaHack) {\n+ // only create frame if it's needed\n+ this.frame = document.createElement(\"div\");\n+ this.frame.style.position = \"absolute\";\n+ this.frame.style.overflow = \"hidden\";\n+ }\n+ if (this.maxGetUrlLength != null) {\n+ OpenLayers.Util.extend(this, OpenLayers.Tile.Image.IFrame);\n }\n- return !this.stopMove;\n },\n \n- /**\n- * Method: mouseout\n- * Called when the mouse goes out of the map.\n- *\n- * Parameters:\n- * evt - {}\n- *\n- * Returns:\n- * {Boolean} Continue propagating this event.\n+ /** \n+ * APIMethod: destroy\n+ * nullify references to prevent circular references and memory leaks\n */\n- mouseout: function(evt) {\n- if (OpenLayers.Util.mouseLeft(evt, this.map.viewPortDiv)) {\n- this.clearTimer();\n- this.callback('move', [evt]);\n+ destroy: function() {\n+ if (this.imgDiv) {\n+ this.clear();\n+ this.imgDiv = null;\n+ this.frame = null;\n }\n- return true;\n+ // don't handle async requests any more\n+ this.asyncRequestId = null;\n+ OpenLayers.Tile.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * Method: passesTolerance\n- * Determine whether the mouse move is within the optional pixel tolerance.\n- *\n- * Parameters:\n- * px - {}\n- *\n+ * Method: draw\n+ * Check that a tile should be drawn, and draw it.\n+ * \n * Returns:\n- * {Boolean} The mouse move is within the pixel tolerance.\n+ * {Boolean} Was a tile drawn? Or null if a beforedraw listener returned\n+ * false.\n */\n- passesTolerance: function(px) {\n- var passes = true;\n- if (this.pixelTolerance && this.px) {\n- var dpx = Math.sqrt(\n- Math.pow(this.px.x - px.x, 2) +\n- Math.pow(this.px.y - px.y, 2)\n- );\n- if (dpx < this.pixelTolerance) {\n- passes = false;\n+ draw: function() {\n+ var shouldDraw = OpenLayers.Tile.prototype.draw.apply(this, arguments);\n+ if (shouldDraw) {\n+ // The layer's reproject option is deprecated.\n+ if (this.layer != this.layer.map.baseLayer && this.layer.reproject) {\n+ // getBoundsFromBaseLayer is defined in deprecated.js.\n+ this.bounds = this.getBoundsFromBaseLayer(this.position);\n+ }\n+ if (this.isLoading) {\n+ //if we're already loading, send 'reload' instead of 'loadstart'.\n+ this._loadEvent = \"reload\";\n+ } else {\n+ this.isLoading = true;\n+ this._loadEvent = \"loadstart\";\n }\n+ this.renderTile();\n+ this.positionTile();\n+ } else if (shouldDraw === false) {\n+ this.unload();\n }\n- return passes;\n+ return shouldDraw;\n },\n \n /**\n- * Method: clearTimer\n- * Clear the timer and set to null.\n+ * Method: renderTile\n+ * Internal function to actually initialize the image tile,\n+ * position it correctly, and set its url.\n */\n- clearTimer: function() {\n- if (this.timerId != null) {\n- window.clearTimeout(this.timerId);\n- this.timerId = null;\n+ renderTile: function() {\n+ if (this.layer.async) {\n+ // Asynchronous image requests call the asynchronous getURL method\n+ // on the layer to fetch an image that covers 'this.bounds'.\n+ var id = this.asyncRequestId = (this.asyncRequestId || 0) + 1;\n+ this.layer.getURLasync(this.bounds, function(url) {\n+ if (id == this.asyncRequestId) {\n+ this.url = url;\n+ this.initImage();\n+ }\n+ }, this);\n+ } else {\n+ // synchronous image requests get the url immediately.\n+ this.url = this.layer.getURL(this.bounds);\n+ this.initImage();\n }\n },\n \n /**\n- * Method: delayedCall\n- * Triggers pause callback.\n- *\n- * Parameters:\n- * evt - {}\n+ * Method: positionTile\n+ * Using the properties currenty set on the layer, position the tile correctly.\n+ * This method is used both by the async and non-async versions of the Tile.Image\n+ * code.\n */\n- delayedCall: function(evt) {\n- this.callback('pause', [evt]);\n+ positionTile: function() {\n+ var style = this.getTile().style,\n+ size = this.frame ? this.size :\n+ this.layer.getImageSize(this.bounds),\n+ ratio = 1;\n+ if (this.layer instanceof OpenLayers.Layer.Grid) {\n+ ratio = this.layer.getServerResolution() / this.layer.map.getResolution();\n+ }\n+ style.left = this.position.x + \"px\";\n+ style.top = this.position.y + \"px\";\n+ style.width = Math.round(ratio * size.w) + \"px\";\n+ style.height = Math.round(ratio * size.h) + \"px\";\n },\n \n- /**\n- * APIMethod: deactivate\n- * Deactivate the handler.\n- *\n- * Returns:\n- * {Boolean} The handler was successfully deactivated.\n+ /** \n+ * Method: clear\n+ * Remove the tile from the DOM, clear it of any image related data so that\n+ * it can be reused in a new location.\n */\n- deactivate: function() {\n- var deactivated = false;\n- if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- this.clearTimer();\n- deactivated = true;\n+ clear: function() {\n+ OpenLayers.Tile.prototype.clear.apply(this, arguments);\n+ var img = this.imgDiv;\n+ if (img) {\n+ var tile = this.getTile();\n+ if (tile.parentNode === this.layer.div) {\n+ this.layer.div.removeChild(tile);\n+ }\n+ this.setImgSrc();\n+ if (this.layerAlphaHack === true) {\n+ img.style.filter = \"\";\n+ }\n+ OpenLayers.Element.removeClass(img, \"olImageLoadError\");\n }\n- return deactivated;\n+ this.canvasContext = null;\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.Hover\"\n-});\n-/* ======================================================================\n- OpenLayers/Format/WMSGetFeatureInfo.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Format/XML.js\n- */\n-\n-/**\n- * Class: OpenLayers.Format.WMSGetFeatureInfo\n- * Class to read GetFeatureInfo responses from Web Mapping Services\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Format.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Format.XML, {\n-\n /**\n- * APIProperty: layerIdentifier\n- * {String} All xml nodes containing this search criteria will populate an\n- * internal array of layer nodes.\n+ * Method: getImage\n+ * Returns or creates and returns the tile image.\n */\n- layerIdentifier: '_layer',\n+ getImage: function() {\n+ if (!this.imgDiv) {\n+ this.imgDiv = OpenLayers.Tile.Image.IMAGE.cloneNode(false);\n \n- /**\n- * APIProperty: featureIdentifier\n- * {String} All xml nodes containing this search criteria will populate an \n- * internal array of feature nodes for each layer node found.\n- */\n- featureIdentifier: '_feature',\n+ var style = this.imgDiv.style;\n+ if (this.frame) {\n+ var left = 0,\n+ top = 0;\n+ if (this.layer.gutter) {\n+ left = this.layer.gutter / this.layer.tileSize.w * 100;\n+ top = this.layer.gutter / this.layer.tileSize.h * 100;\n+ }\n+ style.left = -left + \"%\";\n+ style.top = -top + \"%\";\n+ style.width = (2 * left + 100) + \"%\";\n+ style.height = (2 * top + 100) + \"%\";\n+ }\n+ style.visibility = \"hidden\";\n+ style.opacity = 0;\n+ if (this.layer.opacity < 1) {\n+ style.filter = 'alpha(opacity=' +\n+ (this.layer.opacity * 100) +\n+ ')';\n+ }\n+ style.position = \"absolute\";\n+ if (this.layerAlphaHack) {\n+ // move the image out of sight\n+ style.paddingTop = style.height;\n+ style.height = \"0\";\n+ style.width = \"100%\";\n+ }\n+ if (this.frame) {\n+ this.frame.appendChild(this.imgDiv);\n+ }\n+ }\n \n- /**\n- * Property: regExes\n- * Compiled regular expressions for manipulating strings.\n- */\n- regExes: {\n- trimSpace: (/^\\s*|\\s*$/g),\n- removeSpace: (/\\s*/g),\n- splitSpace: (/\\s+/),\n- trimComma: (/\\s*,\\s*/g)\n+ return this.imgDiv;\n },\n \n /**\n- * Property: gmlFormat\n- * {} internal GML format for parsing geometries\n- * in msGMLOutput\n- */\n- gmlFormat: null,\n-\n- /**\n- * Constructor: OpenLayers.Format.WMSGetFeatureInfo\n- * Create a new parser for WMS GetFeatureInfo responses\n+ * APIMethod: setImage\n+ * Sets the image element for this tile. This method should only be called\n+ * from beforeload listeners.\n *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ * Parameters\n+ * img - {HTMLImageElement} The image to use for this tile.\n */\n+ setImage: function(img) {\n+ this.imgDiv = img;\n+ },\n \n /**\n- * APIMethod: read\n- * Read WMS GetFeatureInfo data from a string, and return an array of features\n- *\n- * Parameters:\n- * data - {String} or {DOMElement} data to read/parse.\n- *\n- * Returns:\n- * {Array()} An array of features.\n+ * Method: initImage\n+ * Creates the content for the frame on the tile.\n */\n- read: function(data) {\n- var result;\n- if (typeof data == \"string\") {\n- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n+ initImage: function() {\n+ if (!this.url && !this.imgDiv) {\n+ // fast path out - if there is no tile url and no previous image\n+ this.isLoading = false;\n+ return;\n }\n- var root = data.documentElement;\n- if (root) {\n- var scope = this;\n- var read = this[\"read_\" + root.nodeName];\n- if (read) {\n- result = read.call(this, root);\n- } else {\n- // fall-back to GML since this is a common output format for WMS\n- // GetFeatureInfo responses\n- result = new OpenLayers.Format.GML((this.options ? this.options : {})).read(data);\n- }\n+ this.events.triggerEvent('beforeload');\n+ this.layer.div.appendChild(this.getTile());\n+ this.events.triggerEvent(this._loadEvent);\n+ var img = this.getImage();\n+ var src = img.getAttribute('src') || '';\n+ if (this.url && OpenLayers.Util.isEquivalentUrl(src, this.url)) {\n+ this._loadTimeout = window.setTimeout(\n+ OpenLayers.Function.bind(this.onImageLoad, this), 0\n+ );\n } else {\n- result = data;\n+ this.stopLoading();\n+ if (this.crossOriginKeyword) {\n+ img.removeAttribute(\"crossorigin\");\n+ }\n+ OpenLayers.Event.observe(img, \"load\",\n+ OpenLayers.Function.bind(this.onImageLoad, this)\n+ );\n+ OpenLayers.Event.observe(img, \"error\",\n+ OpenLayers.Function.bind(this.onImageError, this)\n+ );\n+ this.imageReloadAttempts = 0;\n+ this.setImgSrc(this.url);\n }\n- return result;\n },\n \n-\n /**\n- * Method: read_msGMLOutput\n- * Parse msGMLOutput nodes.\n+ * Method: setImgSrc\n+ * Sets the source for the tile image\n *\n * Parameters:\n- * data - {DOMElement}\n- *\n- * Returns:\n- * {Array}\n+ * url - {String} or undefined to hide the image\n */\n- read_msGMLOutput: function(data) {\n- var response = [];\n- var layerNodes = this.getSiblingNodesByTagCriteria(data,\n- this.layerIdentifier);\n- if (layerNodes) {\n- for (var i = 0, len = layerNodes.length; i < len; ++i) {\n- var node = layerNodes[i];\n- var layerName = node.nodeName;\n- if (node.prefix) {\n- layerName = layerName.split(':')[1];\n- }\n- var layerName = layerName.replace(this.layerIdentifier, '');\n- var featureNodes = this.getSiblingNodesByTagCriteria(node,\n- this.featureIdentifier);\n- if (featureNodes) {\n- for (var j = 0; j < featureNodes.length; j++) {\n- var featureNode = featureNodes[j];\n- var geomInfo = this.parseGeometry(featureNode);\n- var attributes = this.parseAttributes(featureNode);\n- var feature = new OpenLayers.Feature.Vector(geomInfo.geometry,\n- attributes, null);\n- feature.bounds = geomInfo.bounds;\n- feature.type = layerName;\n- response.push(feature);\n- }\n+ setImgSrc: function(url) {\n+ var img = this.imgDiv;\n+ if (url) {\n+ img.style.visibility = 'hidden';\n+ img.style.opacity = 0;\n+ // don't set crossOrigin if the url is a data URL\n+ if (this.crossOriginKeyword) {\n+ if (url.substr(0, 5) !== 'data:') {\n+ img.setAttribute(\"crossorigin\", this.crossOriginKeyword);\n+ } else {\n+ img.removeAttribute(\"crossorigin\");\n }\n }\n+ img.src = url;\n+ } else {\n+ // Remove reference to the image, and leave it to the browser's\n+ // caching and garbage collection.\n+ this.stopLoading();\n+ this.imgDiv = null;\n+ if (img.parentNode) {\n+ img.parentNode.removeChild(img);\n+ }\n }\n- return response;\n },\n \n /**\n- * Method: read_FeatureInfoResponse\n- * Parse FeatureInfoResponse nodes.\n- *\n- * Parameters:\n- * data - {DOMElement}\n+ * Method: getTile\n+ * Get the tile's markup.\n *\n * Returns:\n- * {Array}\n+ * {DOMElement} The tile's markup\n */\n- read_FeatureInfoResponse: function(data) {\n- var response = [];\n- var featureNodes = this.getElementsByTagNameNS(data, '*',\n- 'FIELDS');\n-\n- for (var i = 0, len = featureNodes.length; i < len; i++) {\n- var featureNode = featureNodes[i];\n- var geom = null;\n-\n- // attributes can be actual attributes on the FIELDS tag, \n- // or FIELD children\n- var attributes = {};\n- var j;\n- var jlen = featureNode.attributes.length;\n- if (jlen > 0) {\n- for (j = 0; j < jlen; j++) {\n- var attribute = featureNode.attributes[j];\n- attributes[attribute.nodeName] = attribute.nodeValue;\n- }\n- } else {\n- var nodes = featureNode.childNodes;\n- for (j = 0, jlen = nodes.length; j < jlen; ++j) {\n- var node = nodes[j];\n- if (node.nodeType != 3) {\n- attributes[node.getAttribute(\"name\")] =\n- node.getAttribute(\"value\");\n- }\n- }\n- }\n-\n- response.push(\n- new OpenLayers.Feature.Vector(geom, attributes, null)\n- );\n- }\n- return response;\n+ getTile: function() {\n+ return this.frame ? this.frame : this.getImage();\n },\n \n /**\n- * Method: getSiblingNodesByTagCriteria\n- * Recursively searches passed xml node and all it's descendant levels for \n- * nodes whose tagName contains the passed search string. This returns an \n- * array of all sibling nodes which match the criteria from the highest \n- * hierarchial level from which a match is found.\n- * \n- * Parameters:\n- * node - {DOMElement} An xml node\n- * criteria - {String} Search string which will match some part of a tagName \n- * \n+ * Method: createBackBuffer\n+ * Create a backbuffer for this tile. A backbuffer isn't exactly a clone\n+ * of the tile's markup, because we want to avoid the reloading of the\n+ * image. So we clone the frame, and steal the image from the tile.\n+ *\n * Returns:\n- * Array({DOMElement}) An array of sibling xml nodes\n+ * {DOMElement} The markup, or undefined if the tile has no image\n+ * or if it's currently loading.\n */\n- getSiblingNodesByTagCriteria: function(node, criteria) {\n- var nodes = [];\n- var children, tagName, n, matchNodes, child;\n- if (node && node.hasChildNodes()) {\n- children = node.childNodes;\n- n = children.length;\n-\n- for (var k = 0; k < n; k++) {\n- child = children[k];\n- while (child && child.nodeType != 1) {\n- child = child.nextSibling;\n- k++;\n- }\n- tagName = (child ? child.nodeName : '');\n- if (tagName.length > 0 && tagName.indexOf(criteria) > -1) {\n- nodes.push(child);\n- } else {\n- matchNodes = this.getSiblingNodesByTagCriteria(\n- child, criteria);\n+ createBackBuffer: function() {\n+ if (!this.imgDiv || this.isLoading) {\n+ return;\n+ }\n+ var backBuffer;\n+ if (this.frame) {\n+ backBuffer = this.frame.cloneNode(false);\n+ backBuffer.appendChild(this.imgDiv);\n+ } else {\n+ backBuffer = this.imgDiv;\n+ }\n+ this.imgDiv = null;\n+ return backBuffer;\n+ },\n \n- if (matchNodes.length > 0) {\n- (nodes.length == 0) ?\n- nodes = matchNodes: nodes.push(matchNodes);\n- }\n- }\n- }\n+ /**\n+ * Method: onImageLoad\n+ * Handler for the image onload event\n+ */\n+ onImageLoad: function() {\n+ var img = this.imgDiv;\n+ this.stopLoading();\n+ img.style.visibility = 'inherit';\n+ img.style.opacity = this.layer.opacity;\n+ this.isLoading = false;\n+ this.canvasContext = null;\n+ this.events.triggerEvent(\"loadend\");\n \n+ if (this.layerAlphaHack === true) {\n+ img.style.filter =\n+ \"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='\" +\n+ img.src + \"', sizingMethod='scale')\";\n }\n- return nodes;\n },\n \n /**\n- * Method: parseAttributes\n- *\n- * Parameters:\n- * node - {}\n- *\n- * Returns:\n- * {Object} An attributes object.\n- * \n- * Notes:\n- * Assumes that attributes are direct child xml nodes of the passed node\n- * and contain only a single text node. \n+ * Method: onImageError\n+ * Handler for the image onerror event\n */\n- parseAttributes: function(node) {\n- var attributes = {};\n- if (node.nodeType == 1) {\n- var children = node.childNodes;\n- var n = children.length;\n- for (var i = 0; i < n; ++i) {\n- var child = children[i];\n- if (child.nodeType == 1) {\n- var grandchildren = child.childNodes;\n- var name = (child.prefix) ?\n- child.nodeName.split(\":\")[1] : child.nodeName;\n- if (grandchildren.length == 0) {\n- attributes[name] = null;\n- } else if (grandchildren.length == 1) {\n- var grandchild = grandchildren[0];\n- if (grandchild.nodeType == 3 ||\n- grandchild.nodeType == 4) {\n- var value = grandchild.nodeValue.replace(\n- this.regExes.trimSpace, \"\");\n- attributes[name] = value;\n- }\n- }\n- }\n+ onImageError: function() {\n+ var img = this.imgDiv;\n+ if (img.src != null) {\n+ this.imageReloadAttempts++;\n+ if (this.imageReloadAttempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {\n+ this.setImgSrc(this.layer.getURL(this.bounds));\n+ } else {\n+ OpenLayers.Element.addClass(img, \"olImageLoadError\");\n+ this.events.triggerEvent(\"loaderror\");\n+ this.onImageLoad();\n }\n }\n- return attributes;\n },\n \n /**\n- * Method: parseGeometry\n- * Parse the geometry and the feature bounds out of the node using \n- * Format.GML\n+ * Method: stopLoading\n+ * Stops a loading sequence so won't be executed.\n+ */\n+ stopLoading: function() {\n+ OpenLayers.Event.stopObservingElement(this.imgDiv);\n+ window.clearTimeout(this._loadTimeout);\n+ delete this._loadTimeout;\n+ },\n+\n+ /**\n+ * APIMethod: getCanvasContext\n+ * Returns a canvas context associated with the tile image (with\n+ * the image drawn on it).\n+ * Returns undefined if the browser does not support canvas, if\n+ * the tile has no image or if it's currently loading.\n *\n- * Parameters:\n- * node - {}\n+ * The function returns a canvas context instance but the\n+ * underlying canvas is still available in the 'canvas' property:\n+ * (code)\n+ * var context = tile.getCanvasContext();\n+ * if (context) {\n+ * var data = context.canvas.toDataURL('image/jpeg');\n+ * }\n+ * (end)\n *\n * Returns:\n- * {Object} An object containing the geometry and the feature bounds\n+ * {Boolean}\n */\n- parseGeometry: function(node) {\n- // we need to use the old Format.GML parser since we do not know the \n- // geometry name\n- if (!this.gmlFormat) {\n- this.gmlFormat = new OpenLayers.Format.GML();\n- }\n- var feature = this.gmlFormat.parseFeature(node);\n- var geometry, bounds = null;\n- if (feature) {\n- geometry = feature.geometry && feature.geometry.clone();\n- bounds = feature.bounds && feature.bounds.clone();\n- feature.destroy();\n+ getCanvasContext: function() {\n+ if (OpenLayers.CANVAS_SUPPORTED && this.imgDiv && !this.isLoading) {\n+ if (!this.canvasContext) {\n+ var canvas = document.createElement(\"canvas\");\n+ canvas.width = this.size.w;\n+ canvas.height = this.size.h;\n+ this.canvasContext = canvas.getContext(\"2d\");\n+ this.canvasContext.drawImage(this.imgDiv, 0, 0);\n+ }\n+ return this.canvasContext;\n }\n- return {\n- geometry: geometry,\n- bounds: bounds\n- };\n },\n \n- CLASS_NAME: \"OpenLayers.Format.WMSGetFeatureInfo\"\n+ CLASS_NAME: \"OpenLayers.Tile.Image\"\n \n });\n+\n+/** \n+ * Constant: OpenLayers.Tile.Image.IMAGE\n+ * {HTMLImageElement} The image for a tile.\n+ */\n+OpenLayers.Tile.Image.IMAGE = (function() {\n+ var img = new Image();\n+ img.className = \"olTileImage\";\n+ // avoid image gallery menu in IE6\n+ img.galleryImg = \"no\";\n+ return img;\n+}());\n+\n /* ======================================================================\n- OpenLayers/Control/WMSGetFeatureInfo.js\n+ OpenLayers/Layer/Grid.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n \n /**\n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Handler/Click.js\n- * @requires OpenLayers/Handler/Hover.js\n- * @requires OpenLayers/Request.js\n- * @requires OpenLayers/Format/WMSGetFeatureInfo.js\n+ * @requires OpenLayers/Layer/HTTPRequest.js\n+ * @requires OpenLayers/Tile/Image.js\n */\n \n /**\n- * Class: OpenLayers.Control.WMSGetFeatureInfo\n- * The WMSGetFeatureInfo control uses a WMS query to get information about a point on the map. The\n- * information may be in a display-friendly format such as HTML, or a machine-friendly format such\n- * as GML, depending on the server's capabilities and the client's configuration. This control\n- * handles click or hover events, attempts to parse the results using an OpenLayers.Format, and\n- * fires a 'getfeatureinfo' event with the click position, the raw body of the response, and an\n- * array of features if it successfully read the response.\n+ * Class: OpenLayers.Layer.Grid\n+ * Base class for layers that use a lattice of tiles. Create a new grid\n+ * layer with the constructor.\n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {\n \n /**\n- * APIProperty: hover\n- * {Boolean} Send GetFeatureInfo requests when mouse stops moving.\n- * Default is false.\n+ * APIProperty: tileSize\n+ * {}\n */\n- hover: false,\n+ tileSize: null,\n \n /**\n- * APIProperty: drillDown\n- * {Boolean} Drill down over all WMS layers in the map. When\n- * using drillDown mode, hover is not possible, and an infoFormat that\n- * returns parseable features is required. Default is false.\n+ * Property: tileOriginCorner\n+ * {String} If the property is not provided, the tile origin \n+ * will be derived from the layer's . The corner of the \n+ * used is determined by this property. Acceptable values\n+ * are \"tl\" (top left), \"tr\" (top right), \"bl\" (bottom left), and \"br\"\n+ * (bottom right). Default is \"bl\".\n */\n- drillDown: false,\n+ tileOriginCorner: \"bl\",\n \n /**\n- * APIProperty: maxFeatures\n- * {Integer} Maximum number of features to return from a WMS query. This\n- * sets the feature_count parameter on WMS GetFeatureInfo\n- * requests.\n+ * APIProperty: tileOrigin\n+ * {} Optional origin for aligning the grid of tiles.\n+ * If provided, requests for tiles at all resolutions will be aligned\n+ * with this location (no tiles shall overlap this location). If\n+ * not provided, the grid of tiles will be aligned with the layer's\n+ * . Default is ``null``.\n */\n- maxFeatures: 10,\n+ tileOrigin: null,\n+\n+ /** APIProperty: tileOptions\n+ * {Object} optional configuration options for instances\n+ * created by this Layer, if supported by the tile class.\n+ */\n+ tileOptions: null,\n \n /**\n- * APIProperty: clickCallback\n- * {String} The click callback to register in the\n- * {} object created when the hover\n- * option is set to false. Default is \"click\".\n+ * APIProperty: tileClass\n+ * {} The tile class to use for this layer.\n+ * Defaults is OpenLayers.Tile.Image.\n */\n- clickCallback: \"click\",\n+ tileClass: OpenLayers.Tile.Image,\n \n /**\n- * APIProperty: output\n- * {String} Either \"features\" or \"object\". When triggering a getfeatureinfo\n- * request should we pass on an array of features or an object with with\n- * a \"features\" property and other properties (such as the url of the\n- * WMS). Default is \"features\".\n+ * Property: grid\n+ * {Array(Array())} This is an array of rows, each row is \n+ * an array of tiles.\n */\n- output: \"features\",\n+ grid: null,\n \n /**\n- * APIProperty: layers\n- * {Array()} The layers to query for feature info.\n- * If omitted, all map WMS layers with a url that matches this or\n- * will be considered.\n+ * APIProperty: singleTile\n+ * {Boolean} Moves the layer into single-tile mode, meaning that one tile \n+ * will be loaded. The tile's size will be determined by the 'ratio'\n+ * property. When the tile is dragged such that it does not cover the \n+ * entire viewport, it is reloaded.\n */\n- layers: null,\n+ singleTile: false,\n+\n+ /** APIProperty: ratio\n+ * {Float} Used only when in single-tile mode, this specifies the \n+ * ratio of the size of the single tile to the size of the map.\n+ * Default value is 1.5.\n+ */\n+ ratio: 1.5,\n \n /**\n- * APIProperty: queryVisible\n- * {Boolean} If true, filter out hidden layers when searching the map for\n- * layers to query. Default is false.\n+ * APIProperty: buffer\n+ * {Integer} Used only when in gridded mode, this specifies the number of \n+ * extra rows and colums of tiles on each side which will\n+ * surround the minimum grid tiles to cover the map.\n+ * For very slow loading layers, a larger value may increase\n+ * performance somewhat when dragging, but will increase bandwidth\n+ * use significantly. \n */\n- queryVisible: false,\n+ buffer: 0,\n \n /**\n- * APIProperty: url\n- * {String} The URL of the WMS service to use. If not provided, the url\n- * of the first eligible layer will be used.\n+ * APIProperty: transitionEffect\n+ * {String} The transition effect to use when the map is zoomed.\n+ * Two posible values:\n+ *\n+ * \"resize\" - Existing tiles are resized on zoom to provide a visual\n+ * effect of the zoom having taken place immediately. As the\n+ * new tiles become available, they are drawn on top of the\n+ * resized tiles (this is the default setting).\n+ * \"map-resize\" - Existing tiles are resized on zoom and placed below the\n+ * base layer. New tiles for the base layer will cover existing tiles.\n+ * This setting is recommended when having an overlay duplicated during\n+ * the transition is undesirable (e.g. street labels or big transparent\n+ * fills). \n+ * null - No transition effect.\n+ *\n+ * Using \"resize\" on non-opaque layers can cause undesired visual\n+ * effects. Set transitionEffect to null in this case.\n */\n- url: null,\n+ transitionEffect: \"resize\",\n \n /**\n- * APIProperty: layerUrls\n- * {Array(String)} Optional list of urls for layers that should be queried.\n- * This can be used when the layer url differs from the url used for\n- * making GetFeatureInfo requests (in the case of a layer using cached\n- * tiles).\n+ * APIProperty: numLoadingTiles\n+ * {Integer} How many tiles are still loading?\n */\n- layerUrls: null,\n+ numLoadingTiles: 0,\n \n /**\n- * APIProperty: infoFormat\n- * {String} The mimetype to request from the server. If you are using\n- * drillDown mode and have multiple servers that do not share a common\n- * infoFormat, you can override the control's infoFormat by providing an\n- * INFO_FORMAT parameter in your instance(s).\n+ * Property: serverResolutions\n+ * {Array(Number}} This property is documented in subclasses as\n+ * an API property.\n */\n- infoFormat: 'text/html',\n+ serverResolutions: null,\n \n /**\n- * APIProperty: vendorParams\n- * {Object} Additional parameters that will be added to the request, for\n- * WMS implementations that support them. This could e.g. look like\n- * (start code)\n- * {\n- * radius: 5\n- * }\n- * (end)\n+ * Property: loading\n+ * {Boolean} Indicates if tiles are being loaded.\n */\n- vendorParams: {},\n+ loading: false,\n \n /**\n- * APIProperty: format\n- * {} A format for parsing GetFeatureInfo responses.\n- * Default is .\n+ * Property: backBuffer\n+ * {DOMElement} The back buffer.\n */\n- format: null,\n+ backBuffer: null,\n \n /**\n- * APIProperty: formatOptions\n- * {Object} Optional properties to set on the format (if one is not provided\n- * in the property.\n+ * Property: gridResolution\n+ * {Number} The resolution of the current grid. Used for backbuffer and\n+ * client zoom. This property is updated every time the grid is\n+ * initialized.\n */\n- formatOptions: null,\n+ gridResolution: null,\n \n /**\n- * APIProperty: handlerOptions\n- * {Object} Additional options for the handlers used by this control, e.g.\n- * (start code)\n- * {\n- * \"click\": {delay: 100},\n- * \"hover\": {delay: 300}\n- * }\n- * (end)\n+ * Property: backBufferResolution\n+ * {Number} The resolution of the current back buffer. This property is\n+ * updated each time a back buffer is created.\n */\n+ backBufferResolution: null,\n \n /**\n- * Property: handler\n- * {Object} Reference to the for this control\n+ * Property: backBufferLonLat\n+ * {Object} The top-left corner of the current back buffer. Includes lon\n+ * and lat properties. This object is updated each time a back buffer\n+ * is created.\n */\n- handler: null,\n+ backBufferLonLat: null,\n \n /**\n- * Property: hoverRequest\n- * {} contains the currently running hover request\n- * (if any).\n+ * Property: backBufferTimerId\n+ * {Number} The id of the back buffer timer. This timer is used to\n+ * delay the removal of the back buffer, thereby preventing\n+ * flash effects caused by tile animation.\n */\n- hoverRequest: null,\n+ backBufferTimerId: null,\n \n /**\n- * APIProperty: events\n- * {} Events instance for listeners and triggering\n- * control specific events.\n+ * APIProperty: removeBackBufferDelay\n+ * {Number} Delay for removing the backbuffer when all tiles have finished\n+ * loading. Can be set to 0 when no css opacity transitions for the\n+ * olTileImage class are used. Default is 0 for layers,\n+ * 2500 for tiled layers. See for more information on\n+ * tile animation.\n+ */\n+ removeBackBufferDelay: null,\n+\n+ /**\n+ * APIProperty: className\n+ * {String} Name of the class added to the layer div. If not set in the\n+ * options passed to the constructor then className defaults to\n+ * \"olLayerGridSingleTile\" for single tile layers (see ),\n+ * and \"olLayerGrid\" for non single tile layers.\n *\n+ * Note:\n+ *\n+ * The displaying of tiles is not animated by default for single tile\n+ * layers - OpenLayers' default theme (style.css) includes this:\n+ * (code)\n+ * .olLayerGrid .olTileImage {\n+ * -webkit-transition: opacity 0.2s linear;\n+ * -moz-transition: opacity 0.2s linear;\n+ * -o-transition: opacity 0.2s linear;\n+ * transition: opacity 0.2s linear;\n+ * }\n+ * (end)\n+ * To animate tile displaying for any grid layer the following\n+ * CSS rule can be used:\n+ * (code)\n+ * .olTileImage {\n+ * -webkit-transition: opacity 0.2s linear;\n+ * -moz-transition: opacity 0.2s linear;\n+ * -o-transition: opacity 0.2s linear;\n+ * transition: opacity 0.2s linear;\n+ * }\n+ * (end)\n+ * In that case, to avoid flash effects, \n+ * should not be zero.\n+ */\n+ className: null,\n+\n+ /**\n * Register a listener for a particular event with the following syntax:\n * (code)\n- * control.events.register(type, obj, listener);\n+ * layer.events.register(type, obj, listener);\n * (end)\n *\n- * Supported event types (in addition to those from ):\n- * beforegetfeatureinfo - Triggered before the request is sent.\n- * The event object has an *xy* property with the position of the\n- * mouse click or hover event that triggers the request.\n- * nogetfeatureinfo - no queryable layers were found.\n- * getfeatureinfo - Triggered when a GetFeatureInfo response is received.\n- * The event object has a *text* property with the body of the\n- * response (String), a *features* property with an array of the\n- * parsed features, an *xy* property with the position of the mouse\n- * click or hover event that triggered the request, and a *request*\n- * property with the request itself. If drillDown is set to true and\n- * multiple requests were issued to collect feature info from all\n- * layers, *text* and *request* will only contain the response body\n- * and request object of the last request.\n+ * Listeners will be called with a reference to an event object. The\n+ * properties of this event depends on exactly what happened.\n+ *\n+ * All event objects have at least the following properties:\n+ * object - {Object} A reference to layer.events.object.\n+ * element - {DOMElement} A reference to layer.events.element.\n+ *\n+ * Supported event types:\n+ * addtile - Triggered when a tile is added to this layer. Listeners receive\n+ * an object as first argument, which has a tile property that\n+ * references the tile that has been added.\n+ * tileloadstart - Triggered when a tile starts loading. Listeners receive\n+ * an object as first argument, which has a tile property that\n+ * references the tile that starts loading.\n+ * tileloaded - Triggered when each new tile is\n+ * loaded, as a means of progress update to listeners.\n+ * listeners can access 'numLoadingTiles' if they wish to keep\n+ * track of the loading progress. Listeners are called with an object\n+ * with a 'tile' property as first argument, making the loaded tile\n+ * available to the listener, and an 'aborted' property, which will be\n+ * true when loading was aborted and no tile data is available.\n+ * tileerror - Triggered before the tileloaded event (i.e. when the tile is\n+ * still hidden) if a tile failed to load. Listeners receive an object\n+ * as first argument, which has a tile property that references the\n+ * tile that could not be loaded.\n+ * retile - Triggered when the layer recreates its tile grid.\n */\n \n /**\n- * Constructor: \n+ * Property: gridLayout\n+ * {Object} Object containing properties tilelon, tilelat, startcol,\n+ * startrow\n+ */\n+ gridLayout: null,\n+\n+ /**\n+ * Property: rowSign\n+ * {Number} 1 for grids starting at the top, -1 for grids starting at the\n+ * bottom. This is used for several grid index and offset calculations.\n+ */\n+ rowSign: null,\n+\n+ /**\n+ * Property: transitionendEvents\n+ * {Array} Event names for transitionend\n+ */\n+ transitionendEvents: [\n+ 'transitionend', 'webkitTransitionEnd', 'otransitionend',\n+ 'oTransitionEnd'\n+ ],\n+\n+ /**\n+ * Constructor: OpenLayers.Layer.Grid\n+ * Create a new grid layer\n *\n * Parameters:\n- * options - {Object}\n+ * name - {String}\n+ * url - {String}\n+ * params - {Object}\n+ * options - {Object} Hashtable of extra options to tag onto the layer\n */\n- initialize: function(options) {\n- options = options || {};\n- options.handlerOptions = options.handlerOptions || {};\n+ initialize: function(name, url, params, options) {\n+ OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this,\n+ arguments);\n+ this.grid = [];\n+ this._removeBackBuffer = OpenLayers.Function.bind(this.removeBackBuffer, this);\n \n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+ this.initProperties();\n \n- if (!this.format) {\n- this.format = new OpenLayers.Format.WMSGetFeatureInfo(\n- options.formatOptions\n- );\n- }\n+ this.rowSign = this.tileOriginCorner.substr(0, 1) === \"t\" ? 1 : -1;\n+ },\n \n- if (this.drillDown === true) {\n- this.hover = false;\n+ /**\n+ * Method: initProperties\n+ * Set any properties that depend on the value of singleTile.\n+ * Currently sets removeBackBufferDelay and className\n+ */\n+ initProperties: function() {\n+ if (this.options.removeBackBufferDelay === undefined) {\n+ this.removeBackBufferDelay = this.singleTile ? 0 : 2500;\n }\n \n- if (this.hover) {\n- this.handler = new OpenLayers.Handler.Hover(\n- this, {\n- 'move': this.cancelHover,\n- 'pause': this.getInfoForHover\n- },\n- OpenLayers.Util.extend(this.handlerOptions.hover || {}, {\n- 'delay': 250\n- }));\n- } else {\n- var callbacks = {};\n- callbacks[this.clickCallback] = this.getInfoForClick;\n- this.handler = new OpenLayers.Handler.Click(\n- this, callbacks, this.handlerOptions.click || {});\n+ if (this.options.className === undefined) {\n+ this.className = this.singleTile ? 'olLayerGridSingleTile' :\n+ 'olLayerGrid';\n }\n },\n \n /**\n- * Method: getInfoForClick\n- * Called on click\n+ * Method: setMap\n *\n * Parameters:\n- * evt - {}\n+ * map - {} The map.\n */\n- getInfoForClick: function(evt) {\n- this.events.triggerEvent(\"beforegetfeatureinfo\", {\n- xy: evt.xy\n- });\n- // Set the cursor to \"wait\" to tell the user we're working on their\n- // click.\n- OpenLayers.Element.addClass(this.map.viewPortDiv, \"olCursorWait\");\n- this.request(evt.xy, {});\n+ setMap: function(map) {\n+ OpenLayers.Layer.HTTPRequest.prototype.setMap.call(this, map);\n+ OpenLayers.Element.addClass(this.div, this.className);\n },\n \n /**\n- * Method: getInfoForHover\n- * Pause callback for the hover handler\n+ * Method: removeMap\n+ * Called when the layer is removed from the map.\n *\n * Parameters:\n- * evt - {Object}\n- */\n- getInfoForHover: function(evt) {\n- this.events.triggerEvent(\"beforegetfeatureinfo\", {\n- xy: evt.xy\n- });\n- this.request(evt.xy, {\n- hover: true\n- });\n- },\n-\n- /**\n- * Method: cancelHover\n- * Cancel callback for the hover handler\n+ * map - {} The map.\n */\n- cancelHover: function() {\n- if (this.hoverRequest) {\n- this.hoverRequest.abort();\n- this.hoverRequest = null;\n- }\n+ removeMap: function(map) {\n+ this.removeBackBuffer();\n },\n \n /**\n- * Method: findLayers\n- * Internal method to get the layers, independent of whether we are\n- * inspecting the map or using a client-provided array\n+ * APIMethod: destroy\n+ * Deconstruct the layer and clear the grid.\n */\n- findLayers: function() {\n+ destroy: function() {\n+ this.removeBackBuffer();\n+ this.clearGrid();\n \n- var candidates = this.layers || this.map.layers;\n- var layers = [];\n- var layer, url;\n- for (var i = candidates.length - 1; i >= 0; --i) {\n- layer = candidates[i];\n- if (layer instanceof OpenLayers.Layer.WMS &&\n- (!this.queryVisible || layer.getVisibility())) {\n- url = OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url;\n- // if the control was not configured with a url, set it\n- // to the first layer url\n- if (this.drillDown === false && !this.url) {\n- this.url = url;\n- }\n- if (this.drillDown === true || this.urlMatches(url)) {\n- layers.push(layer);\n- }\n- }\n- }\n- return layers;\n+ this.grid = null;\n+ this.tileSize = null;\n+ OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * Method: urlMatches\n- * Test to see if the provided url matches either the control or one\n- * of the .\n- *\n+ * APIMethod: mergeNewParams\n+ * Refetches tiles with new params merged, keeping a backbuffer. Each\n+ * loading new tile will have a css class of '.olTileReplacing'. If a\n+ * stylesheet applies a 'display: none' style to that class, any fade-in\n+ * transition will not apply, and backbuffers for each tile will be removed\n+ * as soon as the tile is loaded.\n+ * \n * Parameters:\n- * url - {String} The url to test.\n+ * newParams - {Object}\n *\n * Returns:\n- * {Boolean} The provided url matches the control or one of the\n- * .\n+ * redrawn: {Boolean} whether the layer was actually redrawn.\n */\n- urlMatches: function(url) {\n- var matches = OpenLayers.Util.isEquivalentUrl(this.url, url);\n- if (!matches && this.layerUrls) {\n- for (var i = 0, len = this.layerUrls.length; i < len; ++i) {\n- if (OpenLayers.Util.isEquivalentUrl(this.layerUrls[i], url)) {\n- matches = true;\n- break;\n- }\n- }\n- }\n- return matches;\n- },\n \n /**\n- * Method: buildWMSOptions\n- * Build an object with the relevant WMS options for the GetFeatureInfo request\n- *\n- * Parameters:\n- * url - {String} The url to be used for sending the request\n- * layers - {Array(} The position on the map where the mouse\n- * event occurred.\n- * format - {String} The format from the corresponding GetMap request\n+ * Method: clearGrid\n+ * Go through and remove all tiles from the grid, calling\n+ * destroy() on each of them to kill circular references\n */\n- buildWMSOptions: function(url, layers, clickPosition, format) {\n- var layerNames = [],\n- styleNames = [];\n- for (var i = 0, len = layers.length; i < len; i++) {\n- if (layers[i].params.LAYERS != null) {\n- layerNames = layerNames.concat(layers[i].params.LAYERS);\n- styleNames = styleNames.concat(this.getStyleNames(layers[i]));\n+ clearGrid: function() {\n+ if (this.grid) {\n+ for (var iRow = 0, len = this.grid.length; iRow < len; iRow++) {\n+ var row = this.grid[iRow];\n+ for (var iCol = 0, clen = row.length; iCol < clen; iCol++) {\n+ var tile = row[iCol];\n+ this.destroyTile(tile);\n+ }\n }\n+ this.grid = [];\n+ this.gridResolution = null;\n+ this.gridLayout = null;\n }\n- var firstLayer = layers[0];\n- // use the firstLayer's projection if it matches the map projection -\n- // this assumes that all layers will be available in this projection\n- var projection = this.map.getProjection();\n- var layerProj = firstLayer.projection;\n- if (layerProj && layerProj.equals(this.map.getProjectionObject())) {\n- projection = layerProj.getCode();\n- }\n- var params = OpenLayers.Util.extend({\n- service: \"WMS\",\n- version: firstLayer.params.VERSION,\n- request: \"GetFeatureInfo\",\n- exceptions: firstLayer.params.EXCEPTIONS,\n- bbox: this.map.getExtent().toBBOX(null,\n- firstLayer.reverseAxisOrder()),\n- feature_count: this.maxFeatures,\n- height: this.map.getSize().h,\n- width: this.map.getSize().w,\n- format: format,\n- info_format: firstLayer.params.INFO_FORMAT || this.infoFormat\n- }, (parseFloat(firstLayer.params.VERSION) >= 1.3) ? {\n- crs: projection,\n- i: parseInt(clickPosition.x),\n- j: parseInt(clickPosition.y)\n- } : {\n- srs: projection,\n- x: parseInt(clickPosition.x),\n- y: parseInt(clickPosition.y)\n- });\n- if (layerNames.length != 0) {\n- params = OpenLayers.Util.extend({\n- layers: layerNames,\n- query_layers: layerNames,\n- styles: styleNames\n- }, params);\n- }\n- OpenLayers.Util.applyDefaults(params, this.vendorParams);\n- return {\n- url: url,\n- params: OpenLayers.Util.upperCaseObject(params),\n- callback: function(request) {\n- this.handleResponse(clickPosition, request, url);\n- },\n- scope: this\n- };\n },\n \n /**\n- * Method: getStyleNames\n- * Gets the STYLES parameter for the layer. Make sure the STYLES parameter\n- * matches the LAYERS parameter\n- *\n+ * APIMethod: addOptions\n+ * \n * Parameters:\n- * layer - {}\n- *\n- * Returns:\n- * {Array(String)} The STYLES parameter\n+ * newOptions - {Object}\n+ * reinitialize - {Boolean} If set to true, and if resolution options of the\n+ * current baseLayer were changed, the map will be recentered to make\n+ * sure that it is displayed with a valid resolution, and a\n+ * changebaselayer event will be triggered.\n */\n- getStyleNames: function(layer) {\n- // in the event of a WMS layer bundling multiple layers but not\n- // specifying styles,we need the same number of commas to specify\n- // the default style for each of the layers. We can't just leave it\n- // blank as we may be including other layers that do specify styles.\n- var styleNames;\n- if (layer.params.STYLES) {\n- styleNames = layer.params.STYLES;\n- } else {\n- if (OpenLayers.Util.isArray(layer.params.LAYERS)) {\n- styleNames = new Array(layer.params.LAYERS.length);\n- } else { // Assume it's a String\n- styleNames = layer.params.LAYERS.replace(/[^,]/g, \"\");\n- }\n+ addOptions: function(newOptions, reinitialize) {\n+ var singleTileChanged = newOptions.singleTile !== undefined &&\n+ newOptions.singleTile !== this.singleTile;\n+ OpenLayers.Layer.HTTPRequest.prototype.addOptions.apply(this, arguments);\n+ if (this.map && singleTileChanged) {\n+ this.initProperties();\n+ this.clearGrid();\n+ this.tileSize = this.options.tileSize;\n+ this.setTileSize();\n+ this.moveTo(null, true);\n }\n- return styleNames;\n },\n \n /**\n- * Method: request\n- * Sends a GetFeatureInfo request to the WMS\n+ * APIMethod: clone\n+ * Create a clone of this layer\n *\n * Parameters:\n- * clickPosition - {} The position on the map where the\n- * mouse event occurred.\n- * options - {Object} additional options for this method.\n- *\n- * Valid options:\n- * - *hover* {Boolean} true if we do the request for the hover handler\n+ * obj - {Object} Is this ever used?\n+ * \n+ * Returns:\n+ * {} An exact clone of this OpenLayers.Layer.Grid\n */\n- request: function(clickPosition, options) {\n- var layers = this.findLayers();\n- if (layers.length == 0) {\n- this.events.triggerEvent(\"nogetfeatureinfo\");\n- // Reset the cursor.\n- OpenLayers.Element.removeClass(this.map.viewPortDiv, \"olCursorWait\");\n- return;\n+ clone: function(obj) {\n+\n+ if (obj == null) {\n+ obj = new OpenLayers.Layer.Grid(this.name,\n+ this.url,\n+ this.params,\n+ this.getOptions());\n }\n \n- options = options || {};\n- if (this.drillDown === false) {\n- var wmsOptions = this.buildWMSOptions(this.url, layers,\n- clickPosition, layers[0].params.FORMAT);\n- var request = OpenLayers.Request.GET(wmsOptions);\n+ //get all additions from superclasses\n+ obj = OpenLayers.Layer.HTTPRequest.prototype.clone.apply(this, [obj]);\n \n- if (options.hover === true) {\n- this.hoverRequest = request;\n- }\n- } else {\n- this._requestCount = 0;\n- this._numRequests = 0;\n- this.features = [];\n- // group according to service url to combine requests\n- var services = {},\n- url;\n- for (var i = 0, len = layers.length; i < len; i++) {\n- var layer = layers[i];\n- var service, found = false;\n- url = OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url;\n- if (url in services) {\n- services[url].push(layer);\n- } else {\n- this._numRequests++;\n- services[url] = [layer];\n- }\n- }\n- var layers;\n- for (var url in services) {\n- layers = services[url];\n- var wmsOptions = this.buildWMSOptions(url, layers,\n- clickPosition, layers[0].params.FORMAT);\n- OpenLayers.Request.GET(wmsOptions);\n- }\n+ // copy/set any non-init, non-simple values here\n+ if (this.tileSize != null) {\n+ obj.tileSize = this.tileSize.clone();\n }\n- },\n \n- /**\n- * Method: triggerGetFeatureInfo\n- * Trigger the getfeatureinfo event when all is done\n- *\n- * Parameters:\n- * request - {XMLHttpRequest} The request object\n- * xy - {} The position on the map where the\n- * mouse event occurred.\n- * features - {Array()} or\n- * {Array({Object}) when output is \"object\". The object has a url and a\n- * features property which contains an array of features.\n- */\n- triggerGetFeatureInfo: function(request, xy, features) {\n- this.events.triggerEvent(\"getfeatureinfo\", {\n- text: request.responseText,\n- features: features,\n- request: request,\n- xy: xy\n- });\n+ // we do not want to copy reference to grid, so we make a new array\n+ obj.grid = [];\n+ obj.gridResolution = null;\n+ // same for backbuffer\n+ obj.backBuffer = null;\n+ obj.backBufferTimerId = null;\n+ obj.loading = false;\n+ obj.numLoadingTiles = 0;\n \n- // Reset the cursor.\n- OpenLayers.Element.removeClass(this.map.viewPortDiv, \"olCursorWait\");\n+ return obj;\n },\n \n /**\n- * Method: handleResponse\n- * Handler for the GetFeatureInfo response.\n+ * Method: moveTo\n+ * This function is called whenever the map is moved. All the moving\n+ * of actual 'tiles' is done by the map, but moveTo's role is to accept\n+ * a bounds and make sure the data that that bounds requires is pre-loaded.\n *\n * Parameters:\n- * xy - {} The position on the map where the\n- * mouse event occurred.\n- * request - {XMLHttpRequest} The request object.\n- * url - {String} The url which was used for this request.\n+ * bounds - {}\n+ * zoomChanged - {Boolean}\n+ * dragging - {Boolean}\n */\n- handleResponse: function(xy, request, url) {\n-\n- var doc = request.responseXML;\n- if (!doc || !doc.documentElement) {\n- doc = request.responseText;\n- }\n- var features = this.format.read(doc);\n- if (this.drillDown === false) {\n- this.triggerGetFeatureInfo(request, xy, features);\n- } else {\n- this._requestCount++;\n- if (this.output === \"object\") {\n- this._features = (this._features || []).concat({\n- url: url,\n- features: features\n- });\n- } else {\n- this._features = (this._features || []).concat(features);\n- }\n- if (this._requestCount === this._numRequests) {\n- this.triggerGetFeatureInfo(request, xy, this._features.concat());\n- delete this._features;\n- delete this._requestCount;\n- delete this._numRequests;\n- }\n- }\n- },\n-\n- CLASS_NAME: \"OpenLayers.Control.WMSGetFeatureInfo\"\n-});\n-/* ======================================================================\n- OpenLayers/Handler/Drag.js\n- ====================================================================== */\n+ moveTo: function(bounds, zoomChanged, dragging) {\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ OpenLayers.Layer.HTTPRequest.prototype.moveTo.apply(this, arguments);\n \n-/**\n- * @requires OpenLayers/Handler.js\n- */\n+ bounds = bounds || this.map.getExtent();\n \n-/**\n- * Class: OpenLayers.Handler.Drag\n- * The drag handler is used to deal with sequences of browser events related\n- * to dragging. The handler is used by controls that want to know when\n- * a drag sequence begins, when a drag is happening, and when it has\n- * finished.\n- *\n- * Controls that use the drag handler typically construct it with callbacks\n- * for 'down', 'move', and 'done'. Callbacks for these keys are called\n- * when the drag begins, with each move, and when the drag is done. In\n- * addition, controls can have callbacks keyed to 'up' and 'out' if they\n- * care to differentiate between the types of events that correspond with\n- * the end of a drag sequence. If no drag actually occurs (no mouse move)\n- * the 'down' and 'up' callbacks will be called, but not the 'done'\n- * callback.\n- *\n- * Create a new drag handler with the constructor.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {\n+ if (bounds != null) {\n \n- /** \n- * Property: started\n- * {Boolean} When a mousedown or touchstart event is received, we want to\n- * record it, but not set 'dragging' until the mouse moves after starting.\n- */\n- started: false,\n+ // if grid is empty or zoom has changed, we *must* re-tile\n+ var forceReTile = !this.grid.length || zoomChanged;\n \n- /**\n- * Property: stopDown\n- * {Boolean} Stop propagation of mousedown events from getting to listeners\n- * on the same element. Default is true.\n- */\n- stopDown: true,\n+ // total bounds of the tiles\n+ var tilesBounds = this.getTilesBounds();\n \n- /** \n- * Property: dragging \n- * {Boolean} \n- */\n- dragging: false,\n+ // the new map resolution\n+ var resolution = this.map.getResolution();\n \n- /** \n- * Property: last\n- * {} The last pixel location of the drag.\n- */\n- last: null,\n+ // the server-supported resolution for the new map resolution\n+ var serverResolution = this.getServerResolution(resolution);\n \n- /** \n- * Property: start\n- * {} The first pixel location of the drag.\n- */\n- start: null,\n+ if (this.singleTile) {\n \n- /**\n- * Property: lastMoveEvt\n- * {Object} The last mousemove event that occurred. Used to\n- * position the map correctly when our \"delay drag\"\n- * timeout expired.\n- */\n- lastMoveEvt: null,\n+ // We want to redraw whenever even the slightest part of the \n+ // current bounds is not contained by our tile.\n+ // (thus, we do not specify partial -- its default is false)\n \n- /**\n- * Property: oldOnselectstart\n- * {Function}\n- */\n- oldOnselectstart: null,\n+ if (forceReTile ||\n+ (!dragging && !tilesBounds.containsBounds(bounds))) {\n \n- /**\n- * Property: interval\n- * {Integer} In order to increase performance, an interval (in \n- * milliseconds) can be set to reduce the number of drag events \n- * called. If set, a new drag event will not be set until the \n- * interval has passed. \n- * Defaults to 0, meaning no interval. \n- */\n- interval: 0,\n+ // In single tile mode with no transition effect, we insert\n+ // a non-scaled backbuffer when the layer is moved. But if\n+ // a zoom occurs right after a move, i.e. before the new\n+ // image is received, we need to remove the backbuffer, or\n+ // an ill-positioned image will be visible during the zoom\n+ // transition.\n \n- /**\n- * Property: timeoutId\n- * {String} The id of the timeout used for the mousedown interval.\n- * This is \"private\", and should be left alone.\n- */\n- timeoutId: null,\n+ if (zoomChanged && this.transitionEffect !== 'resize') {\n+ this.removeBackBuffer();\n+ }\n \n- /**\n- * APIProperty: documentDrag\n- * {Boolean} If set to true, the handler will also handle mouse moves when\n- * the cursor has moved out of the map viewport. Default is false.\n- */\n- documentDrag: false,\n+ if (!zoomChanged || this.transitionEffect === 'resize') {\n+ this.applyBackBuffer(resolution);\n+ }\n \n- /**\n- * Property: documentEvents\n- * {Boolean} Are we currently observing document events?\n- */\n- documentEvents: null,\n+ this.initSingleTile(bounds);\n+ }\n+ } else {\n \n- /**\n- * Constructor: OpenLayers.Handler.Drag\n- * Returns OpenLayers.Handler.Drag\n- * \n- * Parameters:\n- * control - {} The control that is making use of\n- * this handler. If a handler is being used without a control, the\n- * handlers setMap method must be overridden to deal properly with\n- * the map.\n- * callbacks - {Object} An object containing a single function to be\n- * called when the drag operation is finished. The callback should\n- * expect to recieve a single argument, the pixel location of the event.\n- * Callbacks for 'move' and 'done' are supported. You can also speficy\n- * callbacks for 'down', 'up', and 'out' to respond to those events.\n- * options - {Object} \n- */\n- initialize: function(control, callbacks, options) {\n- OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n+ // if the bounds have changed such that they are not even \n+ // *partially* contained by our tiles (e.g. when user has \n+ // programmatically panned to the other side of the earth on\n+ // zoom level 18), then moveGriddedTiles could potentially have\n+ // to run through thousands of cycles, so we want to reTile\n+ // instead (thus, partial true). \n+ forceReTile = forceReTile ||\n+ !tilesBounds.intersectsBounds(bounds, {\n+ worldBounds: this.map.baseLayer.wrapDateLine &&\n+ this.map.getMaxExtent()\n+ });\n \n- if (this.documentDrag === true) {\n- var me = this;\n- this._docMove = function(evt) {\n- me.mousemove({\n- xy: {\n- x: evt.clientX,\n- y: evt.clientY\n- },\n- element: document\n- });\n- };\n- this._docUp = function(evt) {\n- me.mouseup({\n- xy: {\n- x: evt.clientX,\n- y: evt.clientY\n+ if (forceReTile) {\n+ if (zoomChanged && (this.transitionEffect === 'resize' ||\n+ this.gridResolution === resolution)) {\n+ this.applyBackBuffer(resolution);\n }\n- });\n- };\n+ this.initGriddedTiles(bounds);\n+ } else {\n+ this.moveGriddedTiles();\n+ }\n+ }\n }\n },\n \n-\n /**\n- * Method: dragstart\n- * This private method is factorized from mousedown and touchstart methods\n+ * Method: getTileData\n+ * Given a map location, retrieve a tile and the pixel offset within that\n+ * tile corresponding to the location. If there is not an existing \n+ * tile in the grid that covers the given location, null will be \n+ * returned.\n *\n * Parameters:\n- * evt - {Event} The event\n+ * loc - {} map location\n *\n * Returns:\n- * {Boolean} Let the event propagate.\n+ * {Object} Object with the following properties: tile ({}),\n+ * i ({Number} x-pixel offset from top left), and j ({Integer} y-pixel\n+ * offset from top left).\n */\n- dragstart: function(evt) {\n- var propagate = true;\n- this.dragging = false;\n- if (this.checkModifiers(evt) &&\n- (OpenLayers.Event.isLeftClick(evt) ||\n- OpenLayers.Event.isSingleTouch(evt))) {\n- this.started = true;\n- this.start = evt.xy;\n- this.last = evt.xy;\n- OpenLayers.Element.addClass(\n- this.map.viewPortDiv, \"olDragDown\"\n- );\n- this.down(evt);\n- this.callback(\"down\", [evt.xy]);\n+ getTileData: function(loc) {\n+ var data = null,\n+ x = loc.lon,\n+ y = loc.lat,\n+ numRows = this.grid.length;\n \n- // prevent document dragging\n- OpenLayers.Event.preventDefault(evt);\n+ if (this.map && numRows) {\n+ var res = this.map.getResolution(),\n+ tileWidth = this.tileSize.w,\n+ tileHeight = this.tileSize.h,\n+ bounds = this.grid[0][0].bounds,\n+ left = bounds.left,\n+ top = bounds.top;\n \n- if (!this.oldOnselectstart) {\n- this.oldOnselectstart = document.onselectstart ?\n- document.onselectstart : OpenLayers.Function.True;\n+ if (x < left) {\n+ // deal with multiple worlds\n+ if (this.map.baseLayer.wrapDateLine) {\n+ var worldWidth = this.map.getMaxExtent().getWidth();\n+ var worldsAway = Math.ceil((left - x) / worldWidth);\n+ x += worldWidth * worldsAway;\n+ }\n+ }\n+ // tile distance to location (fractional number of tiles);\n+ var dtx = (x - left) / (res * tileWidth);\n+ var dty = (top - y) / (res * tileHeight);\n+ // index of tile in grid\n+ var col = Math.floor(dtx);\n+ var row = Math.floor(dty);\n+ if (row >= 0 && row < numRows) {\n+ var tile = this.grid[row][col];\n+ if (tile) {\n+ data = {\n+ tile: tile,\n+ // pixel index within tile\n+ i: Math.floor((dtx - col) * tileWidth),\n+ j: Math.floor((dty - row) * tileHeight)\n+ };\n+ }\n }\n- document.onselectstart = OpenLayers.Function.False;\n-\n- propagate = !this.stopDown;\n- } else {\n- this.started = false;\n- this.start = null;\n- this.last = null;\n }\n- return propagate;\n+ return data;\n },\n \n /**\n- * Method: dragmove\n- * This private method is factorized from mousemove and touchmove methods\n+ * Method: destroyTile\n *\n * Parameters:\n- * evt - {Event} The event\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n+ * tile - {}\n */\n- dragmove: function(evt) {\n- this.lastMoveEvt = evt;\n- if (this.started && !this.timeoutId && (evt.xy.x != this.last.x ||\n- evt.xy.y != this.last.y)) {\n- if (this.documentDrag === true && this.documentEvents) {\n- if (evt.element === document) {\n- this.adjustXY(evt);\n- // do setEvent manually because the documentEvents are not\n- // registered with the map\n- this.setEvent(evt);\n- } else {\n- this.removeDocumentEvents();\n- }\n- }\n- if (this.interval > 0) {\n- this.timeoutId = setTimeout(\n- OpenLayers.Function.bind(this.removeTimeout, this),\n- this.interval);\n- }\n- this.dragging = true;\n-\n- this.move(evt);\n- this.callback(\"move\", [evt.xy]);\n- if (!this.oldOnselectstart) {\n- this.oldOnselectstart = document.onselectstart;\n- document.onselectstart = OpenLayers.Function.False;\n- }\n- this.last = evt.xy;\n- }\n- return true;\n+ destroyTile: function(tile) {\n+ this.removeTileMonitoringHooks(tile);\n+ tile.destroy();\n },\n \n /**\n- * Method: dragend\n- * This private method is factorized from mouseup and touchend methods\n+ * Method: getServerResolution\n+ * Return the closest server-supported resolution.\n *\n * Parameters:\n- * evt - {Event} The event\n+ * resolution - {Number} The base resolution. If undefined the\n+ * map resolution is used.\n *\n * Returns:\n- * {Boolean} Let the event propagate.\n+ * {Number} The closest server resolution value.\n */\n- dragend: function(evt) {\n- if (this.started) {\n- if (this.documentDrag === true && this.documentEvents) {\n- this.adjustXY(evt);\n- this.removeDocumentEvents();\n- }\n- var dragged = (this.start != this.last);\n- this.started = false;\n- this.dragging = false;\n- OpenLayers.Element.removeClass(\n- this.map.viewPortDiv, \"olDragDown\"\n- );\n- this.up(evt);\n- this.callback(\"up\", [evt.xy]);\n- if (dragged) {\n- this.callback(\"done\", [evt.xy]);\n+ getServerResolution: function(resolution) {\n+ var distance = Number.POSITIVE_INFINITY;\n+ resolution = resolution || this.map.getResolution();\n+ if (this.serverResolutions &&\n+ OpenLayers.Util.indexOf(this.serverResolutions, resolution) === -1) {\n+ var i, newDistance, newResolution, serverResolution;\n+ for (i = this.serverResolutions.length - 1; i >= 0; i--) {\n+ newResolution = this.serverResolutions[i];\n+ newDistance = Math.abs(newResolution - resolution);\n+ if (newDistance > distance) {\n+ break;\n+ }\n+ distance = newDistance;\n+ serverResolution = newResolution;\n }\n- document.onselectstart = this.oldOnselectstart;\n+ resolution = serverResolution;\n }\n- return true;\n+ return resolution;\n },\n \n /**\n- * The four methods below (down, move, up, and out) are used by subclasses\n- * to do their own processing related to these mouse events.\n+ * Method: getServerZoom\n+ * Return the zoom value corresponding to the best matching server\n+ * resolution, taking into account and .\n+ *\n+ * Returns:\n+ * {Number} The closest server supported zoom. This is not the map zoom\n+ * level, but an index of the server's resolutions array.\n */\n+ getServerZoom: function() {\n+ var resolution = this.getServerResolution();\n+ return this.serverResolutions ?\n+ OpenLayers.Util.indexOf(this.serverResolutions, resolution) :\n+ this.map.getZoomForResolution(resolution) + (this.zoomOffset || 0);\n+ },\n \n /**\n- * Method: down\n- * This method is called during the handling of the mouse down event.\n- * Subclasses can do their own processing here.\n+ * Method: applyBackBuffer\n+ * Create, insert, scale and position a back buffer for the layer.\n *\n * Parameters:\n- * evt - {Event} The mouse down event\n+ * resolution - {Number} The resolution to transition to.\n */\n- down: function(evt) {},\n+ applyBackBuffer: function(resolution) {\n+ if (this.backBufferTimerId !== null) {\n+ this.removeBackBuffer();\n+ }\n+ var backBuffer = this.backBuffer;\n+ if (!backBuffer) {\n+ backBuffer = this.createBackBuffer();\n+ if (!backBuffer) {\n+ return;\n+ }\n+ if (resolution === this.gridResolution) {\n+ this.div.insertBefore(backBuffer, this.div.firstChild);\n+ } else {\n+ this.map.baseLayer.div.parentNode.insertBefore(backBuffer, this.map.baseLayer.div);\n+ }\n+ this.backBuffer = backBuffer;\n+\n+ // set some information in the instance for subsequent\n+ // calls to applyBackBuffer where the same back buffer\n+ // is reused\n+ var topLeftTileBounds = this.grid[0][0].bounds;\n+ this.backBufferLonLat = {\n+ lon: topLeftTileBounds.left,\n+ lat: topLeftTileBounds.top\n+ };\n+ this.backBufferResolution = this.gridResolution;\n+ }\n+\n+ var ratio = this.backBufferResolution / resolution;\n+\n+ // scale the tiles inside the back buffer\n+ var tiles = backBuffer.childNodes,\n+ tile;\n+ for (var i = tiles.length - 1; i >= 0; --i) {\n+ tile = tiles[i];\n+ tile.style.top = ((ratio * tile._i * tile._h) | 0) + 'px';\n+ tile.style.left = ((ratio * tile._j * tile._w) | 0) + 'px';\n+ tile.style.width = Math.round(ratio * tile._w) + 'px';\n+ tile.style.height = Math.round(ratio * tile._h) + 'px';\n+ }\n+\n+ // and position it (based on the grid's top-left corner)\n+ var position = this.getViewPortPxFromLonLat(\n+ this.backBufferLonLat, resolution);\n+ var leftOffset = this.map.layerContainerOriginPx.x;\n+ var topOffset = this.map.layerContainerOriginPx.y;\n+ backBuffer.style.left = Math.round(position.x - leftOffset) + 'px';\n+ backBuffer.style.top = Math.round(position.y - topOffset) + 'px';\n+ },\n \n /**\n- * Method: move\n- * This method is called during the handling of the mouse move event.\n- * Subclasses can do their own processing here.\n- *\n- * Parameters:\n- * evt - {Event} The mouse move event\n+ * Method: createBackBuffer\n+ * Create a back buffer.\n *\n+ * Returns:\n+ * {DOMElement} The DOM element for the back buffer, undefined if the\n+ * grid isn't initialized yet.\n */\n- move: function(evt) {},\n+ createBackBuffer: function() {\n+ var backBuffer;\n+ if (this.grid.length > 0) {\n+ backBuffer = document.createElement('div');\n+ backBuffer.id = this.div.id + '_bb';\n+ backBuffer.className = 'olBackBuffer';\n+ backBuffer.style.position = 'absolute';\n+ var map = this.map;\n+ backBuffer.style.zIndex = this.transitionEffect === 'resize' ?\n+ this.getZIndex() - 1 :\n+ // 'map-resize':\n+ map.Z_INDEX_BASE.BaseLayer -\n+ (map.getNumLayers() - map.getLayerIndex(this));\n+ for (var i = 0, lenI = this.grid.length; i < lenI; i++) {\n+ for (var j = 0, lenJ = this.grid[i].length; j < lenJ; j++) {\n+ var tile = this.grid[i][j],\n+ markup = this.grid[i][j].createBackBuffer();\n+ if (markup) {\n+ markup._i = i;\n+ markup._j = j;\n+ markup._w = tile.size.w;\n+ markup._h = tile.size.h;\n+ markup.id = tile.id + '_bb';\n+ backBuffer.appendChild(markup);\n+ }\n+ }\n+ }\n+ }\n+ return backBuffer;\n+ },\n \n /**\n- * Method: up\n- * This method is called during the handling of the mouse up event.\n- * Subclasses can do their own processing here.\n- *\n- * Parameters:\n- * evt - {Event} The mouse up event\n+ * Method: removeBackBuffer\n+ * Remove back buffer from DOM.\n */\n- up: function(evt) {},\n+ removeBackBuffer: function() {\n+ if (this._transitionElement) {\n+ for (var i = this.transitionendEvents.length - 1; i >= 0; --i) {\n+ OpenLayers.Event.stopObserving(this._transitionElement,\n+ this.transitionendEvents[i], this._removeBackBuffer);\n+ }\n+ delete this._transitionElement;\n+ }\n+ if (this.backBuffer) {\n+ if (this.backBuffer.parentNode) {\n+ this.backBuffer.parentNode.removeChild(this.backBuffer);\n+ }\n+ this.backBuffer = null;\n+ this.backBufferResolution = null;\n+ if (this.backBufferTimerId !== null) {\n+ window.clearTimeout(this.backBufferTimerId);\n+ this.backBufferTimerId = null;\n+ }\n+ }\n+ },\n \n /**\n- * Method: out\n- * This method is called during the handling of the mouse out event.\n- * Subclasses can do their own processing here.\n+ * Method: moveByPx\n+ * Move the layer based on pixel vector.\n *\n * Parameters:\n- * evt - {Event} The mouse out event\n+ * dx - {Number}\n+ * dy - {Number}\n */\n- out: function(evt) {},\n+ moveByPx: function(dx, dy) {\n+ if (!this.singleTile) {\n+ this.moveGriddedTiles();\n+ }\n+ },\n \n /**\n- * The methods below are part of the magic of event handling. Because\n- * they are named like browser events, they are registered as listeners\n- * for the events they represent.\n+ * APIMethod: setTileSize\n+ * Check if we are in singleTile mode and if so, set the size as a ratio\n+ * of the map size (as specified by the layer's 'ratio' property).\n+ * \n+ * Parameters:\n+ * size - {}\n */\n+ setTileSize: function(size) {\n+ if (this.singleTile) {\n+ size = this.map.getSize();\n+ size.h = parseInt(size.h * this.ratio, 10);\n+ size.w = parseInt(size.w * this.ratio, 10);\n+ }\n+ OpenLayers.Layer.HTTPRequest.prototype.setTileSize.apply(this, [size]);\n+ },\n \n /**\n- * Method: mousedown\n- * Handle mousedown events\n- *\n- * Parameters:\n- * evt - {Event}\n+ * APIMethod: getTilesBounds\n+ * Return the bounds of the tile grid.\n *\n * Returns:\n- * {Boolean} Let the event propagate.\n+ * {} A Bounds object representing the bounds of all the\n+ * currently loaded tiles (including those partially or not at all seen \n+ * onscreen).\n */\n- mousedown: function(evt) {\n- return this.dragstart(evt);\n+ getTilesBounds: function() {\n+ var bounds = null;\n+\n+ var length = this.grid.length;\n+ if (length) {\n+ var bottomLeftTileBounds = this.grid[length - 1][0].bounds,\n+ width = this.grid[0].length * bottomLeftTileBounds.getWidth(),\n+ height = this.grid.length * bottomLeftTileBounds.getHeight();\n+\n+ bounds = new OpenLayers.Bounds(bottomLeftTileBounds.left,\n+ bottomLeftTileBounds.bottom,\n+ bottomLeftTileBounds.left + width,\n+ bottomLeftTileBounds.bottom + height);\n+ }\n+ return bounds;\n },\n \n /**\n- * Method: touchstart\n- * Handle touchstart events\n+ * Method: initSingleTile\n+ * \n+ * Parameters: \n+ * bounds - {}\n+ */\n+ initSingleTile: function(bounds) {\n+ this.events.triggerEvent(\"retile\");\n+\n+ //determine new tile bounds\n+ var center = bounds.getCenterLonLat();\n+ var tileWidth = bounds.getWidth() * this.ratio;\n+ var tileHeight = bounds.getHeight() * this.ratio;\n+\n+ var tileBounds =\n+ new OpenLayers.Bounds(center.lon - (tileWidth / 2),\n+ center.lat - (tileHeight / 2),\n+ center.lon + (tileWidth / 2),\n+ center.lat + (tileHeight / 2));\n+\n+ var px = this.map.getLayerPxFromLonLat({\n+ lon: tileBounds.left,\n+ lat: tileBounds.top\n+ });\n+\n+ if (!this.grid.length) {\n+ this.grid[0] = [];\n+ }\n+\n+ var tile = this.grid[0][0];\n+ if (!tile) {\n+ tile = this.addTile(tileBounds, px);\n+\n+ this.addTileMonitoringHooks(tile);\n+ tile.draw();\n+ this.grid[0][0] = tile;\n+ } else {\n+ tile.moveTo(tileBounds, px);\n+ }\n+\n+ //remove all but our single tile\n+ this.removeExcessTiles(1, 1);\n+\n+ // store the resolution of the grid\n+ this.gridResolution = this.getServerResolution();\n+ },\n+\n+ /** \n+ * Method: calculateGridLayout\n+ * Generate parameters for the grid layout.\n *\n * Parameters:\n- * evt - {Event}\n+ * bounds - {|Object} OpenLayers.Bounds or an\n+ * object with a 'left' and 'top' properties.\n+ * origin - {|Object} OpenLayers.LonLat or an\n+ * object with a 'lon' and 'lat' properties.\n+ * resolution - {Number}\n *\n * Returns:\n- * {Boolean} Let the event propagate.\n+ * {Object} Object containing properties tilelon, tilelat, startcol,\n+ * startrow\n */\n- touchstart: function(evt) {\n- this.startTouch();\n- return this.dragstart(evt);\n+ calculateGridLayout: function(bounds, origin, resolution) {\n+ var tilelon = resolution * this.tileSize.w;\n+ var tilelat = resolution * this.tileSize.h;\n+\n+ var offsetlon = bounds.left - origin.lon;\n+ var tilecol = Math.floor(offsetlon / tilelon) - this.buffer;\n+\n+ var rowSign = this.rowSign;\n+\n+ var offsetlat = rowSign * (origin.lat - bounds.top + tilelat);\n+ var tilerow = Math[~rowSign ? 'floor' : 'ceil'](offsetlat / tilelat) - this.buffer * rowSign;\n+\n+ return {\n+ tilelon: tilelon,\n+ tilelat: tilelat,\n+ startcol: tilecol,\n+ startrow: tilerow\n+ };\n+\n },\n \n /**\n- * Method: mousemove\n- * Handle mousemove events\n- *\n- * Parameters:\n- * evt - {Event}\n+ * Method: getTileOrigin\n+ * Determine the origin for aligning the grid of tiles. If a \n+ * property is supplied, that will be returned. Otherwise, the origin\n+ * will be derived from the layer's property. In this case,\n+ * the tile origin will be the corner of the given by the \n+ * property.\n *\n * Returns:\n- * {Boolean} Let the event propagate.\n+ * {} The tile origin.\n */\n- mousemove: function(evt) {\n- return this.dragmove(evt);\n+ getTileOrigin: function() {\n+ var origin = this.tileOrigin;\n+ if (!origin) {\n+ var extent = this.getMaxExtent();\n+ var edges = ({\n+ \"tl\": [\"left\", \"top\"],\n+ \"tr\": [\"right\", \"top\"],\n+ \"bl\": [\"left\", \"bottom\"],\n+ \"br\": [\"right\", \"bottom\"]\n+ })[this.tileOriginCorner];\n+ origin = new OpenLayers.LonLat(extent[edges[0]], extent[edges[1]]);\n+ }\n+ return origin;\n },\n \n /**\n- * Method: touchmove\n- * Handle touchmove events\n+ * Method: getTileBoundsForGridIndex\n *\n * Parameters:\n- * evt - {Event}\n+ * row - {Number} The row of the grid\n+ * col - {Number} The column of the grid\n *\n * Returns:\n- * {Boolean} Let the event propagate.\n+ * {} The bounds for the tile at (row, col)\n */\n- touchmove: function(evt) {\n- return this.dragmove(evt);\n+ getTileBoundsForGridIndex: function(row, col) {\n+ var origin = this.getTileOrigin();\n+ var tileLayout = this.gridLayout;\n+ var tilelon = tileLayout.tilelon;\n+ var tilelat = tileLayout.tilelat;\n+ var startcol = tileLayout.startcol;\n+ var startrow = tileLayout.startrow;\n+ var rowSign = this.rowSign;\n+ return new OpenLayers.Bounds(\n+ origin.lon + (startcol + col) * tilelon,\n+ origin.lat - (startrow + row * rowSign) * tilelat * rowSign,\n+ origin.lon + (startcol + col + 1) * tilelon,\n+ origin.lat - (startrow + (row - 1) * rowSign) * tilelat * rowSign\n+ );\n },\n \n /**\n- * Method: removeTimeout\n- * Private. Called by mousemove() to remove the drag timeout.\n+ * Method: initGriddedTiles\n+ * \n+ * Parameters:\n+ * bounds - {}\n */\n- removeTimeout: function() {\n- this.timeoutId = null;\n- // if timeout expires while we're still dragging (mouseup\n- // hasn't occurred) then call mousemove to move to the\n- // correct position\n- if (this.dragging) {\n- this.mousemove(this.lastMoveEvt);\n+ initGriddedTiles: function(bounds) {\n+ this.events.triggerEvent(\"retile\");\n+\n+ // work out mininum number of rows and columns; this is the number of\n+ // tiles required to cover the viewport plus at least one for panning\n+\n+ var viewSize = this.map.getSize();\n+\n+ var origin = this.getTileOrigin();\n+ var resolution = this.map.getResolution(),\n+ serverResolution = this.getServerResolution(),\n+ ratio = resolution / serverResolution,\n+ tileSize = {\n+ w: this.tileSize.w / ratio,\n+ h: this.tileSize.h / ratio\n+ };\n+\n+ var minRows = Math.ceil(viewSize.h / tileSize.h) +\n+ 2 * this.buffer + 1;\n+ var minCols = Math.ceil(viewSize.w / tileSize.w) +\n+ 2 * this.buffer + 1;\n+\n+ var tileLayout = this.calculateGridLayout(bounds, origin, serverResolution);\n+ this.gridLayout = tileLayout;\n+\n+ var tilelon = tileLayout.tilelon;\n+ var tilelat = tileLayout.tilelat;\n+\n+ var layerContainerDivLeft = this.map.layerContainerOriginPx.x;\n+ var layerContainerDivTop = this.map.layerContainerOriginPx.y;\n+\n+ var tileBounds = this.getTileBoundsForGridIndex(0, 0);\n+ var startPx = this.map.getViewPortPxFromLonLat(\n+ new OpenLayers.LonLat(tileBounds.left, tileBounds.top)\n+ );\n+ startPx.x = Math.round(startPx.x) - layerContainerDivLeft;\n+ startPx.y = Math.round(startPx.y) - layerContainerDivTop;\n+\n+ var tileData = [],\n+ center = this.map.getCenter();\n+\n+ var rowidx = 0;\n+ do {\n+ var row = this.grid[rowidx];\n+ if (!row) {\n+ row = [];\n+ this.grid.push(row);\n+ }\n+\n+ var colidx = 0;\n+ do {\n+ tileBounds = this.getTileBoundsForGridIndex(rowidx, colidx);\n+ var px = startPx.clone();\n+ px.x = px.x + colidx * Math.round(tileSize.w);\n+ px.y = px.y + rowidx * Math.round(tileSize.h);\n+ var tile = row[colidx];\n+ if (!tile) {\n+ tile = this.addTile(tileBounds, px);\n+ this.addTileMonitoringHooks(tile);\n+ row.push(tile);\n+ } else {\n+ tile.moveTo(tileBounds, px, false);\n+ }\n+ var tileCenter = tileBounds.getCenterLonLat();\n+ tileData.push({\n+ tile: tile,\n+ distance: Math.pow(tileCenter.lon - center.lon, 2) +\n+ Math.pow(tileCenter.lat - center.lat, 2)\n+ });\n+\n+ colidx += 1;\n+ } while ((tileBounds.right <= bounds.right + tilelon * this.buffer) ||\n+ colidx < minCols);\n+\n+ rowidx += 1;\n+ } while ((tileBounds.bottom >= bounds.bottom - tilelat * this.buffer) ||\n+ rowidx < minRows);\n+\n+ //shave off exceess rows and colums\n+ this.removeExcessTiles(rowidx, colidx);\n+\n+ var resolution = this.getServerResolution();\n+ // store the resolution of the grid\n+ this.gridResolution = resolution;\n+\n+ //now actually draw the tiles\n+ tileData.sort(function(a, b) {\n+ return a.distance - b.distance;\n+ });\n+ for (var i = 0, ii = tileData.length; i < ii; ++i) {\n+ tileData[i].tile.draw();\n }\n },\n \n /**\n- * Method: mouseup\n- * Handle mouseup events\n- *\n- * Parameters:\n- * evt - {Event}\n+ * Method: getMaxExtent\n+ * Get this layer's maximum extent. (Implemented as a getter for\n+ * potential specific implementations in sub-classes.)\n *\n * Returns:\n- * {Boolean} Let the event propagate.\n+ * {}\n */\n- mouseup: function(evt) {\n- return this.dragend(evt);\n+ getMaxExtent: function() {\n+ return this.maxExtent;\n },\n \n /**\n- * Method: touchend\n- * Handle touchend events\n+ * APIMethod: addTile\n+ * Create a tile, initialize it, and add it to the layer div. \n *\n- * Parameters:\n- * evt - {Event}\n+ * Parameters\n+ * bounds - {}\n+ * position - {}\n *\n * Returns:\n- * {Boolean} Let the event propagate.\n+ * {} The added OpenLayers.Tile\n */\n- touchend: function(evt) {\n- // override evt.xy with last position since touchend does not have\n- // any touch position\n- evt.xy = this.last;\n- return this.dragend(evt);\n+ addTile: function(bounds, position) {\n+ var tile = new this.tileClass(\n+ this, position, bounds, null, this.tileSize, this.tileOptions\n+ );\n+ this.events.triggerEvent(\"addtile\", {\n+ tile: tile\n+ });\n+ return tile;\n },\n \n- /**\n- * Method: mouseout\n- * Handle mouseout events\n- *\n- * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n+ /** \n+ * Method: addTileMonitoringHooks\n+ * This function takes a tile as input and adds the appropriate hooks to \n+ * the tile so that the layer can keep track of the loading tiles.\n+ * \n+ * Parameters: \n+ * tile - {}\n */\n- mouseout: function(evt) {\n- if (this.started && OpenLayers.Util.mouseLeft(evt, this.map.viewPortDiv)) {\n- if (this.documentDrag === true) {\n- this.addDocumentEvents();\n- } else {\n- var dragged = (this.start != this.last);\n- this.started = false;\n- this.dragging = false;\n- OpenLayers.Element.removeClass(\n- this.map.viewPortDiv, \"olDragDown\"\n- );\n- this.out(evt);\n- this.callback(\"out\", []);\n- if (dragged) {\n- this.callback(\"done\", [evt.xy]);\n+ addTileMonitoringHooks: function(tile) {\n+\n+ var replacingCls = 'olTileReplacing';\n+\n+ tile.onLoadStart = function() {\n+ //if that was first tile then trigger a 'loadstart' on the layer\n+ if (this.loading === false) {\n+ this.loading = true;\n+ this.events.triggerEvent(\"loadstart\");\n+ }\n+ this.events.triggerEvent(\"tileloadstart\", {\n+ tile: tile\n+ });\n+ this.numLoadingTiles++;\n+ if (!this.singleTile && this.backBuffer && this.gridResolution === this.backBufferResolution) {\n+ OpenLayers.Element.addClass(tile.getTile(), replacingCls);\n+ }\n+ };\n+\n+ tile.onLoadEnd = function(evt) {\n+ this.numLoadingTiles--;\n+ var aborted = evt.type === 'unload';\n+ this.events.triggerEvent(\"tileloaded\", {\n+ tile: tile,\n+ aborted: aborted\n+ });\n+ if (!this.singleTile && !aborted && this.backBuffer && this.gridResolution === this.backBufferResolution) {\n+ var tileDiv = tile.getTile();\n+ if (OpenLayers.Element.getStyle(tileDiv, 'display') === 'none') {\n+ var bufferTile = document.getElementById(tile.id + '_bb');\n+ if (bufferTile) {\n+ bufferTile.parentNode.removeChild(bufferTile);\n+ }\n }\n- if (document.onselectstart) {\n- document.onselectstart = this.oldOnselectstart;\n+ OpenLayers.Element.removeClass(tileDiv, replacingCls);\n+ }\n+ //if that was the last tile, then trigger a 'loadend' on the layer\n+ if (this.numLoadingTiles === 0) {\n+ if (this.backBuffer) {\n+ if (this.backBuffer.childNodes.length === 0) {\n+ // no tiles transitioning, remove immediately\n+ this.removeBackBuffer();\n+ } else {\n+ // wait until transition has ended or delay has passed\n+ this._transitionElement = aborted ?\n+ this.div.lastChild : tile.imgDiv;\n+ var transitionendEvents = this.transitionendEvents;\n+ for (var i = transitionendEvents.length - 1; i >= 0; --i) {\n+ OpenLayers.Event.observe(this._transitionElement,\n+ transitionendEvents[i],\n+ this._removeBackBuffer);\n+ }\n+ // the removal of the back buffer is delayed to prevent\n+ // flash effects due to the animation of tile displaying\n+ this.backBufferTimerId = window.setTimeout(\n+ this._removeBackBuffer, this.removeBackBufferDelay\n+ );\n+ }\n }\n+ this.loading = false;\n+ this.events.triggerEvent(\"loadend\");\n }\n- }\n- return true;\n+ };\n+\n+ tile.onLoadError = function() {\n+ this.events.triggerEvent(\"tileerror\", {\n+ tile: tile\n+ });\n+ };\n+\n+ tile.events.on({\n+ \"loadstart\": tile.onLoadStart,\n+ \"loadend\": tile.onLoadEnd,\n+ \"unload\": tile.onLoadEnd,\n+ \"loaderror\": tile.onLoadError,\n+ scope: this\n+ });\n },\n \n- /**\n- * Method: click\n- * The drag handler captures the click event. If something else registers\n- * for clicks on the same element, its listener will not be called \n- * after a drag.\n+ /** \n+ * Method: removeTileMonitoringHooks\n+ * This function takes a tile as input and removes the tile hooks \n+ * that were added in addTileMonitoringHooks()\n * \n * Parameters: \n- * evt - {Event} \n- * \n- * Returns:\n- * {Boolean} Let the event propagate.\n+ * tile - {}\n */\n- click: function(evt) {\n- // let the click event propagate only if the mouse moved\n- return (this.start == this.last);\n+ removeTileMonitoringHooks: function(tile) {\n+ tile.unload();\n+ tile.events.un({\n+ \"loadstart\": tile.onLoadStart,\n+ \"loadend\": tile.onLoadEnd,\n+ \"unload\": tile.onLoadEnd,\n+ \"loaderror\": tile.onLoadError,\n+ scope: this\n+ });\n },\n \n /**\n- * Method: activate\n- * Activate the handler.\n- * \n- * Returns:\n- * {Boolean} The handler was successfully activated.\n+ * Method: moveGriddedTiles\n */\n- activate: function() {\n- var activated = false;\n- if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n- this.dragging = false;\n- activated = true;\n+ moveGriddedTiles: function() {\n+ var buffer = this.buffer + 1;\n+ while (true) {\n+ var tlTile = this.grid[0][0];\n+ var tlViewPort = {\n+ x: tlTile.position.x +\n+ this.map.layerContainerOriginPx.x,\n+ y: tlTile.position.y +\n+ this.map.layerContainerOriginPx.y\n+ };\n+ var ratio = this.getServerResolution() / this.map.getResolution();\n+ var tileSize = {\n+ w: Math.round(this.tileSize.w * ratio),\n+ h: Math.round(this.tileSize.h * ratio)\n+ };\n+ if (tlViewPort.x > -tileSize.w * (buffer - 1)) {\n+ this.shiftColumn(true, tileSize);\n+ } else if (tlViewPort.x < -tileSize.w * buffer) {\n+ this.shiftColumn(false, tileSize);\n+ } else if (tlViewPort.y > -tileSize.h * (buffer - 1)) {\n+ this.shiftRow(true, tileSize);\n+ } else if (tlViewPort.y < -tileSize.h * buffer) {\n+ this.shiftRow(false, tileSize);\n+ } else {\n+ break;\n+ }\n }\n- return activated;\n },\n \n /**\n- * Method: deactivate \n- * Deactivate the handler.\n- * \n- * Returns:\n- * {Boolean} The handler was successfully deactivated.\n+ * Method: shiftRow\n+ * Shifty grid work\n+ *\n+ * Parameters:\n+ * prepend - {Boolean} if true, prepend to beginning.\n+ * if false, then append to end\n+ * tileSize - {Object} rendered tile size; object with w and h properties\n */\n- deactivate: function() {\n- var deactivated = false;\n- if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- this.started = false;\n- this.dragging = false;\n- this.start = null;\n- this.last = null;\n- deactivated = true;\n- OpenLayers.Element.removeClass(\n- this.map.viewPortDiv, \"olDragDown\"\n- );\n+ shiftRow: function(prepend, tileSize) {\n+ var grid = this.grid;\n+ var rowIndex = prepend ? 0 : (grid.length - 1);\n+ var sign = prepend ? -1 : 1;\n+ var rowSign = this.rowSign;\n+ var tileLayout = this.gridLayout;\n+ tileLayout.startrow += sign * rowSign;\n+\n+ var modelRow = grid[rowIndex];\n+ var row = grid[prepend ? 'pop' : 'shift']();\n+ for (var i = 0, len = row.length; i < len; i++) {\n+ var tile = row[i];\n+ var position = modelRow[i].position.clone();\n+ position.y += tileSize.h * sign;\n+ tile.moveTo(this.getTileBoundsForGridIndex(rowIndex, i), position);\n }\n- return deactivated;\n+ grid[prepend ? 'unshift' : 'push'](row);\n },\n \n /**\n- * Method: adjustXY\n- * Converts event coordinates that are relative to the document body to\n- * ones that are relative to the map viewport. The latter is the default in\n- * OpenLayers.\n+ * Method: shiftColumn\n+ * Shift grid work in the other dimension\n+ *\n+ * Parameters:\n+ * prepend - {Boolean} if true, prepend to beginning.\n+ * if false, then append to end\n+ * tileSize - {Object} rendered tile size; object with w and h properties\n+ */\n+ shiftColumn: function(prepend, tileSize) {\n+ var grid = this.grid;\n+ var colIndex = prepend ? 0 : (grid[0].length - 1);\n+ var sign = prepend ? -1 : 1;\n+ var tileLayout = this.gridLayout;\n+ tileLayout.startcol += sign;\n+\n+ for (var i = 0, len = grid.length; i < len; i++) {\n+ var row = grid[i];\n+ var position = row[colIndex].position.clone();\n+ var tile = row[prepend ? 'pop' : 'shift']();\n+ position.x += tileSize.w * sign;\n+ tile.moveTo(this.getTileBoundsForGridIndex(i, colIndex), position);\n+ row[prepend ? 'unshift' : 'push'](tile);\n+ }\n+ },\n+\n+ /**\n+ * Method: removeExcessTiles\n+ * When the size of the map or the buffer changes, we may need to\n+ * remove some excess rows and columns.\n * \n * Parameters:\n- * evt - {Object}\n+ * rows - {Integer} Maximum number of rows we want our grid to have.\n+ * columns - {Integer} Maximum number of columns we want our grid to have.\n */\n- adjustXY: function(evt) {\n- var pos = OpenLayers.Util.pagePosition(this.map.viewPortDiv);\n- evt.xy.x -= pos[0];\n- evt.xy.y -= pos[1];\n+ removeExcessTiles: function(rows, columns) {\n+ var i, l;\n+\n+ // remove extra rows\n+ while (this.grid.length > rows) {\n+ var row = this.grid.pop();\n+ for (i = 0, l = row.length; i < l; i++) {\n+ var tile = row[i];\n+ this.destroyTile(tile);\n+ }\n+ }\n+\n+ // remove extra columns\n+ for (i = 0, l = this.grid.length; i < l; i++) {\n+ while (this.grid[i].length > columns) {\n+ var row = this.grid[i];\n+ var tile = row.pop();\n+ this.destroyTile(tile);\n+ }\n+ }\n },\n \n /**\n- * Method: addDocumentEvents\n- * Start observing document events when documentDrag is true and the mouse\n- * cursor leaves the map viewport while dragging.\n+ * Method: onMapResize\n+ * For singleTile layers, this will set a new tile size according to the\n+ * dimensions of the map pane.\n */\n- addDocumentEvents: function() {\n- OpenLayers.Element.addClass(document.body, \"olDragDown\");\n- this.documentEvents = true;\n- OpenLayers.Event.observe(document, \"mousemove\", this._docMove);\n- OpenLayers.Event.observe(document, \"mouseup\", this._docUp);\n+ onMapResize: function() {\n+ if (this.singleTile) {\n+ this.clearGrid();\n+ this.setTileSize();\n+ }\n },\n \n /**\n- * Method: removeDocumentEvents\n- * Stops observing document events when documentDrag is true and the mouse\n- * cursor re-enters the map viewport while dragging.\n+ * APIMethod: getTileBounds\n+ * Returns The tile bounds for a layer given a pixel location.\n+ *\n+ * Parameters:\n+ * viewPortPx - {} The location in the viewport.\n+ *\n+ * Returns:\n+ * {} Bounds of the tile at the given pixel location.\n */\n- removeDocumentEvents: function() {\n- OpenLayers.Element.removeClass(document.body, \"olDragDown\");\n- this.documentEvents = false;\n- OpenLayers.Event.stopObserving(document, \"mousemove\", this._docMove);\n- OpenLayers.Event.stopObserving(document, \"mouseup\", this._docUp);\n+ getTileBounds: function(viewPortPx) {\n+ var maxExtent = this.maxExtent;\n+ var resolution = this.getResolution();\n+ var tileMapWidth = resolution * this.tileSize.w;\n+ var tileMapHeight = resolution * this.tileSize.h;\n+ var mapPoint = this.getLonLatFromViewPortPx(viewPortPx);\n+ var tileLeft = maxExtent.left + (tileMapWidth *\n+ Math.floor((mapPoint.lon -\n+ maxExtent.left) /\n+ tileMapWidth));\n+ var tileBottom = maxExtent.bottom + (tileMapHeight *\n+ Math.floor((mapPoint.lat -\n+ maxExtent.bottom) /\n+ tileMapHeight));\n+ return new OpenLayers.Bounds(tileLeft, tileBottom,\n+ tileLeft + tileMapWidth,\n+ tileBottom + tileMapHeight);\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.Drag\"\n+ CLASS_NAME: \"OpenLayers.Layer.Grid\"\n });\n /* ======================================================================\n- OpenLayers/Handler/Box.js\n+ OpenLayers/TileManager.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Handler.js\n- * @requires OpenLayers/Handler/Drag.js\n+ * @requires OpenLayers/Util.js\n+ * @requires OpenLayers/BaseTypes.js\n+ * @requires OpenLayers/BaseTypes/Element.js\n+ * @requires OpenLayers/Layer/Grid.js\n+ * @requires OpenLayers/Tile/Image.js\n */\n \n /**\n- * Class: OpenLayers.Handler.Box\n- * Handler for dragging a rectangle across the map. Box is displayed \n- * on mouse down, moves on mouse move, and is finished on mouse up.\n+ * Class: OpenLayers.TileManager\n+ * Provides queueing of image requests and caching of image elements.\n *\n- * Inherits from:\n- * - \n+ * Queueing avoids unnecessary image requests while changing zoom levels\n+ * quickly, and helps improve dragging performance on mobile devices that show\n+ * a lag in dragging when loading of new images starts. and\n+ * are the configuration options to control this behavior.\n+ *\n+ * Caching avoids setting the src on image elements for images that have already\n+ * been used. Several maps can share a TileManager instance, in which case each\n+ * map gets its own tile queue, but all maps share the same tile cache.\n */\n-OpenLayers.Handler.Box = OpenLayers.Class(OpenLayers.Handler, {\n+OpenLayers.TileManager = OpenLayers.Class({\n \n- /** \n- * Property: dragHandler \n- * {} \n+ /**\n+ * APIProperty: cacheSize\n+ * {Number} Number of image elements to keep referenced in this instance's\n+ * cache for fast reuse. Default is 256.\n */\n- dragHandler: null,\n+ cacheSize: 256,\n \n /**\n- * APIProperty: boxDivClassName\n- * {String} The CSS class to use for drawing the box. Default is\n- * olHandlerBoxZoomBox\n+ * APIProperty: tilesPerFrame\n+ * {Number} Number of queued tiles to load per frame (see ).\n+ * Default is 2.\n */\n- boxDivClassName: 'olHandlerBoxZoomBox',\n+ tilesPerFrame: 2,\n \n /**\n- * Property: boxOffsets\n- * {Object} Caches box offsets from css. This is used by the getBoxOffsets\n- * method.\n+ * APIProperty: frameDelay\n+ * {Number} Delay between tile loading frames (see ) in\n+ * milliseconds. Default is 16.\n */\n- boxOffsets: null,\n+ frameDelay: 16,\n \n /**\n- * Constructor: OpenLayers.Handler.Box\n- *\n- * Parameters:\n- * control - {} \n- * callbacks - {Object} An object with a properties whose values are\n- * functions. Various callbacks described below.\n- * options - {Object} \n- *\n- * Named callbacks:\n- * start - Called when the box drag operation starts.\n- * done - Called when the box drag operation is finished.\n- * The callback should expect to receive a single argument, the box \n- * bounds or a pixel. If the box dragging didn't span more than a 5 \n- * pixel distance, a pixel will be returned instead of a bounds object.\n+ * APIProperty: moveDelay\n+ * {Number} Delay in milliseconds after a map's move event before loading\n+ * tiles. Default is 100.\n */\n- initialize: function(control, callbacks, options) {\n- OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n- this.dragHandler = new OpenLayers.Handler.Drag(\n- this, {\n- down: this.startBox,\n- move: this.moveBox,\n- out: this.removeBox,\n- up: this.endBox\n- }, {\n- keyMask: this.keyMask\n- }\n- );\n- },\n+ moveDelay: 100,\n \n /**\n- * Method: destroy\n+ * APIProperty: zoomDelay\n+ * {Number} Delay in milliseconds after a map's zoomend event before loading\n+ * tiles. Default is 200.\n */\n- destroy: function() {\n- OpenLayers.Handler.prototype.destroy.apply(this, arguments);\n- if (this.dragHandler) {\n- this.dragHandler.destroy();\n- this.dragHandler = null;\n- }\n- },\n+ zoomDelay: 200,\n \n /**\n- * Method: setMap\n+ * Property: maps\n+ * {Array()} The maps to manage tiles on.\n */\n- setMap: function(map) {\n- OpenLayers.Handler.prototype.setMap.apply(this, arguments);\n- if (this.dragHandler) {\n- this.dragHandler.setMap(map);\n- }\n- },\n+ maps: null,\n \n /**\n- * Method: startBox\n- *\n- * Parameters:\n- * xy - {}\n+ * Property: tileQueueId\n+ * {Object} The ids of the loop, keyed by map id.\n */\n- startBox: function(xy) {\n- this.callback(\"start\", []);\n- this.zoomBox = OpenLayers.Util.createDiv('zoomBox', {\n- x: -9999,\n- y: -9999\n- });\n- this.zoomBox.className = this.boxDivClassName;\n- this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE[\"Popup\"] - 1;\n-\n- this.map.viewPortDiv.appendChild(this.zoomBox);\n-\n- OpenLayers.Element.addClass(\n- this.map.viewPortDiv, \"olDrawBox\"\n- );\n- },\n+ tileQueueId: null,\n \n /**\n- * Method: moveBox\n+ * Property: tileQueue\n+ * {Object(Array())} Tiles queued for drawing, keyed by\n+ * map id.\n */\n- moveBox: function(xy) {\n- var startX = this.dragHandler.start.x;\n- var startY = this.dragHandler.start.y;\n- var deltaX = Math.abs(startX - xy.x);\n- var deltaY = Math.abs(startY - xy.y);\n-\n- var offset = this.getBoxOffsets();\n- this.zoomBox.style.width = (deltaX + offset.width + 1) + \"px\";\n- this.zoomBox.style.height = (deltaY + offset.height + 1) + \"px\";\n- this.zoomBox.style.left = (xy.x < startX ?\n- startX - deltaX - offset.left : startX - offset.left) + \"px\";\n- this.zoomBox.style.top = (xy.y < startY ?\n- startY - deltaY - offset.top : startY - offset.top) + \"px\";\n- },\n+ tileQueue: null,\n \n /**\n- * Method: endBox\n+ * Property: tileCache\n+ * {Object} Cached image elements, keyed by URL.\n */\n- endBox: function(end) {\n- var result;\n- if (Math.abs(this.dragHandler.start.x - end.x) > 5 ||\n- Math.abs(this.dragHandler.start.y - end.y) > 5) {\n- var start = this.dragHandler.start;\n- var top = Math.min(start.y, end.y);\n- var bottom = Math.max(start.y, end.y);\n- var left = Math.min(start.x, end.x);\n- var right = Math.max(start.x, end.x);\n- result = new OpenLayers.Bounds(left, bottom, right, top);\n- } else {\n- result = this.dragHandler.start.clone(); // i.e. OL.Pixel\n- }\n- this.removeBox();\n-\n- this.callback(\"done\", [result]);\n- },\n+ tileCache: null,\n \n /**\n- * Method: removeBox\n- * Remove the zoombox from the screen and nullify our reference to it.\n+ * Property: tileCacheIndex\n+ * {Array(String)} URLs of cached tiles. First entry is the least recently\n+ * used.\n */\n- removeBox: function() {\n- this.map.viewPortDiv.removeChild(this.zoomBox);\n- this.zoomBox = null;\n- this.boxOffsets = null;\n- OpenLayers.Element.removeClass(\n- this.map.viewPortDiv, \"olDrawBox\"\n- );\n+ tileCacheIndex: null,\n \n- },\n+ /** \n+ * Constructor: OpenLayers.TileManager\n+ * Constructor for a new instance.\n+ * \n+ * Parameters:\n+ * options - {Object} Configuration for this instance.\n+ */\n+ initialize: function(options) {\n+ OpenLayers.Util.extend(this, options);\n+ this.maps = [];\n+ this.tileQueueId = {};\n+ this.tileQueue = {};\n+ this.tileCache = {};\n+ this.tileCacheIndex = [];\n+ },\n \n /**\n- * Method: activate\n+ * Method: addMap\n+ * Binds this instance to a map\n+ *\n+ * Parameters:\n+ * map - {}\n */\n- activate: function() {\n- if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n- this.dragHandler.activate();\n- return true;\n- } else {\n- return false;\n+ addMap: function(map) {\n+ if (this._destroyed || !OpenLayers.Layer.Grid) {\n+ return;\n+ }\n+ this.maps.push(map);\n+ this.tileQueue[map.id] = [];\n+ for (var i = 0, ii = map.layers.length; i < ii; ++i) {\n+ this.addLayer({\n+ layer: map.layers[i]\n+ });\n }\n+ map.events.on({\n+ move: this.move,\n+ zoomend: this.zoomEnd,\n+ changelayer: this.changeLayer,\n+ addlayer: this.addLayer,\n+ preremovelayer: this.removeLayer,\n+ scope: this\n+ });\n },\n \n /**\n- * Method: deactivate\n+ * Method: removeMap\n+ * Unbinds this instance from a map\n+ *\n+ * Parameters:\n+ * map - {}\n */\n- deactivate: function() {\n- if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- if (this.dragHandler.deactivate()) {\n- if (this.zoomBox) {\n- this.removeBox();\n+ removeMap: function(map) {\n+ if (this._destroyed || !OpenLayers.Layer.Grid) {\n+ return;\n+ }\n+ window.clearTimeout(this.tileQueueId[map.id]);\n+ if (map.layers) {\n+ for (var i = 0, ii = map.layers.length; i < ii; ++i) {\n+ this.removeLayer({\n+ layer: map.layers[i]\n+ });\n+ }\n+ }\n+ if (map.events) {\n+ map.events.un({\n+ move: this.move,\n+ zoomend: this.zoomEnd,\n+ changelayer: this.changeLayer,\n+ addlayer: this.addLayer,\n+ preremovelayer: this.removeLayer,\n+ scope: this\n+ });\n+ }\n+ delete this.tileQueue[map.id];\n+ delete this.tileQueueId[map.id];\n+ OpenLayers.Util.removeItem(this.maps, map);\n+ },\n+\n+ /**\n+ * Method: move\n+ * Handles the map's move event\n+ *\n+ * Parameters:\n+ * evt - {Object} Listener argument\n+ */\n+ move: function(evt) {\n+ this.updateTimeout(evt.object, this.moveDelay, true);\n+ },\n+\n+ /**\n+ * Method: zoomEnd\n+ * Handles the map's zoomEnd event\n+ *\n+ * Parameters:\n+ * evt - {Object} Listener argument\n+ */\n+ zoomEnd: function(evt) {\n+ this.updateTimeout(evt.object, this.zoomDelay);\n+ },\n+\n+ /**\n+ * Method: changeLayer\n+ * Handles the map's changeLayer event\n+ *\n+ * Parameters:\n+ * evt - {Object} Listener argument\n+ */\n+ changeLayer: function(evt) {\n+ if (evt.property === 'visibility' || evt.property === 'params') {\n+ this.updateTimeout(evt.object, 0);\n+ }\n+ },\n+\n+ /**\n+ * Method: addLayer\n+ * Handles the map's addlayer event\n+ *\n+ * Parameters:\n+ * evt - {Object} The listener argument\n+ */\n+ addLayer: function(evt) {\n+ var layer = evt.layer;\n+ if (layer instanceof OpenLayers.Layer.Grid) {\n+ layer.events.on({\n+ addtile: this.addTile,\n+ retile: this.clearTileQueue,\n+ scope: this\n+ });\n+ var i, j, tile;\n+ for (i = layer.grid.length - 1; i >= 0; --i) {\n+ for (j = layer.grid[i].length - 1; j >= 0; --j) {\n+ tile = layer.grid[i][j];\n+ this.addTile({\n+ tile: tile\n+ });\n+ if (tile.url && !tile.imgDiv) {\n+ this.manageTileCache({\n+ object: tile\n+ });\n+ }\n }\n }\n- return true;\n+ }\n+ },\n+\n+ /**\n+ * Method: removeLayer\n+ * Handles the map's preremovelayer event\n+ *\n+ * Parameters:\n+ * evt - {Object} The listener argument\n+ */\n+ removeLayer: function(evt) {\n+ var layer = evt.layer;\n+ if (layer instanceof OpenLayers.Layer.Grid) {\n+ this.clearTileQueue({\n+ object: layer\n+ });\n+ if (layer.events) {\n+ layer.events.un({\n+ addtile: this.addTile,\n+ retile: this.clearTileQueue,\n+ scope: this\n+ });\n+ }\n+ if (layer.grid) {\n+ var i, j, tile;\n+ for (i = layer.grid.length - 1; i >= 0; --i) {\n+ for (j = layer.grid[i].length - 1; j >= 0; --j) {\n+ tile = layer.grid[i][j];\n+ this.unloadTile({\n+ object: tile\n+ });\n+ }\n+ }\n+ }\n+ }\n+ },\n+\n+ /**\n+ * Method: updateTimeout\n+ * Applies the or to the loop,\n+ * and schedules more queue processing after if there are still\n+ * tiles in the queue.\n+ *\n+ * Parameters:\n+ * map - {} The map to update the timeout for\n+ * delay - {Number} The delay to apply\n+ * nice - {Boolean} If true, the timeout function will only be created if\n+ * the tilequeue is not empty. This is used by the move handler to\n+ * avoid impacts on dragging performance. For other events, the tile\n+ * queue may not be populated yet, so we need to set the timer\n+ * regardless of the queue size.\n+ */\n+ updateTimeout: function(map, delay, nice) {\n+ window.clearTimeout(this.tileQueueId[map.id]);\n+ var tileQueue = this.tileQueue[map.id];\n+ if (!nice || tileQueue.length) {\n+ this.tileQueueId[map.id] = window.setTimeout(\n+ OpenLayers.Function.bind(function() {\n+ this.drawTilesFromQueue(map);\n+ if (tileQueue.length) {\n+ this.updateTimeout(map, this.frameDelay);\n+ }\n+ }, this), delay\n+ );\n+ }\n+ },\n+\n+ /**\n+ * Method: addTile\n+ * Listener for the layer's addtile event\n+ *\n+ * Parameters:\n+ * evt - {Object} The listener argument\n+ */\n+ addTile: function(evt) {\n+ if (evt.tile instanceof OpenLayers.Tile.Image) {\n+ evt.tile.events.on({\n+ beforedraw: this.queueTileDraw,\n+ beforeload: this.manageTileCache,\n+ loadend: this.addToCache,\n+ unload: this.unloadTile,\n+ scope: this\n+ });\n } else {\n- return false;\n+ // Layer has the wrong tile type, so don't handle it any longer\n+ this.removeLayer({\n+ layer: evt.tile.layer\n+ });\n }\n },\n \n /**\n- * Method: getBoxOffsets\n- * Determines border offsets for a box, according to the box model.\n- * \n- * Returns:\n- * {Object} an object with the following offsets:\n- * - left\n- * - right\n- * - top\n- * - bottom\n- * - width\n- * - height\n+ * Method: unloadTile\n+ * Listener for the tile's unload event\n+ *\n+ * Parameters:\n+ * evt - {Object} The listener argument\n */\n- getBoxOffsets: function() {\n- if (!this.boxOffsets) {\n- // Determine the box model. If the testDiv's clientWidth is 3, then\n- // the borders are outside and we are dealing with the w3c box\n- // model. Otherwise, the browser uses the traditional box model and\n- // the borders are inside the box bounds, leaving us with a\n- // clientWidth of 1.\n- var testDiv = document.createElement(\"div\");\n- //testDiv.style.visibility = \"hidden\";\n- testDiv.style.position = \"absolute\";\n- testDiv.style.border = \"1px solid black\";\n- testDiv.style.width = \"3px\";\n- document.body.appendChild(testDiv);\n- var w3cBoxModel = testDiv.clientWidth == 3;\n- document.body.removeChild(testDiv);\n+ unloadTile: function(evt) {\n+ var tile = evt.object;\n+ tile.events.un({\n+ beforedraw: this.queueTileDraw,\n+ beforeload: this.manageTileCache,\n+ loadend: this.addToCache,\n+ unload: this.unloadTile,\n+ scope: this\n+ });\n+ OpenLayers.Util.removeItem(this.tileQueue[tile.layer.map.id], tile);\n+ },\n \n- var left = parseInt(OpenLayers.Element.getStyle(this.zoomBox,\n- \"border-left-width\"));\n- var right = parseInt(OpenLayers.Element.getStyle(\n- this.zoomBox, \"border-right-width\"));\n- var top = parseInt(OpenLayers.Element.getStyle(this.zoomBox,\n- \"border-top-width\"));\n- var bottom = parseInt(OpenLayers.Element.getStyle(\n- this.zoomBox, \"border-bottom-width\"));\n- this.boxOffsets = {\n- left: left,\n- right: right,\n- top: top,\n- bottom: bottom,\n- width: w3cBoxModel === false ? left + right : 0,\n- height: w3cBoxModel === false ? top + bottom : 0\n- };\n+ /**\n+ * Method: queueTileDraw\n+ * Adds a tile to the queue that will draw it.\n+ *\n+ * Parameters:\n+ * evt - {Object} Listener argument of the tile's beforedraw event\n+ */\n+ queueTileDraw: function(evt) {\n+ var tile = evt.object;\n+ var queued = false;\n+ var layer = tile.layer;\n+ var url = layer.getURL(tile.bounds);\n+ var img = this.tileCache[url];\n+ if (img && img.className !== 'olTileImage') {\n+ // cached image no longer valid, e.g. because we're olTileReplacing\n+ delete this.tileCache[url];\n+ OpenLayers.Util.removeItem(this.tileCacheIndex, url);\n+ img = null;\n }\n- return this.boxOffsets;\n+ // queue only if image with same url not cached already\n+ if (layer.url && (layer.async || !img)) {\n+ // add to queue only if not in queue already\n+ var tileQueue = this.tileQueue[layer.map.id];\n+ if (!~OpenLayers.Util.indexOf(tileQueue, tile)) {\n+ tileQueue.push(tile);\n+ }\n+ queued = true;\n+ }\n+ return !queued;\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.Box\"\n+ /**\n+ * Method: drawTilesFromQueue\n+ * Draws tiles from the tileQueue, and unqueues the tiles\n+ */\n+ drawTilesFromQueue: function(map) {\n+ var tileQueue = this.tileQueue[map.id];\n+ var limit = this.tilesPerFrame;\n+ var animating = map.zoomTween && map.zoomTween.playing;\n+ while (!animating && tileQueue.length && limit) {\n+ tileQueue.shift().draw(true);\n+ --limit;\n+ }\n+ },\n+\n+ /**\n+ * Method: manageTileCache\n+ * Adds, updates, removes and fetches cache entries.\n+ *\n+ * Parameters:\n+ * evt - {Object} Listener argument of the tile's beforeload event\n+ */\n+ manageTileCache: function(evt) {\n+ var tile = evt.object;\n+ var img = this.tileCache[tile.url];\n+ if (img) {\n+ // if image is on its layer's backbuffer, remove it from backbuffer\n+ if (img.parentNode &&\n+ OpenLayers.Element.hasClass(img.parentNode, 'olBackBuffer')) {\n+ img.parentNode.removeChild(img);\n+ img.id = null;\n+ }\n+ // only use image from cache if it is not on a layer already\n+ if (!img.parentNode) {\n+ img.style.visibility = 'hidden';\n+ img.style.opacity = 0;\n+ tile.setImage(img);\n+ // LRU - move tile to the end of the array to mark it as the most\n+ // recently used\n+ OpenLayers.Util.removeItem(this.tileCacheIndex, tile.url);\n+ this.tileCacheIndex.push(tile.url);\n+ }\n+ }\n+ },\n+\n+ /**\n+ * Method: addToCache\n+ *\n+ * Parameters:\n+ * evt - {Object} Listener argument for the tile's loadend event\n+ */\n+ addToCache: function(evt) {\n+ var tile = evt.object;\n+ if (!this.tileCache[tile.url]) {\n+ if (!OpenLayers.Element.hasClass(tile.imgDiv, 'olImageLoadError')) {\n+ if (this.tileCacheIndex.length >= this.cacheSize) {\n+ delete this.tileCache[this.tileCacheIndex[0]];\n+ this.tileCacheIndex.shift();\n+ }\n+ this.tileCache[tile.url] = tile.imgDiv;\n+ this.tileCacheIndex.push(tile.url);\n+ }\n+ }\n+ },\n+\n+ /**\n+ * Method: clearTileQueue\n+ * Clears the tile queue from tiles of a specific layer\n+ *\n+ * Parameters:\n+ * evt - {Object} Listener argument of the layer's retile event\n+ */\n+ clearTileQueue: function(evt) {\n+ var layer = evt.object;\n+ var tileQueue = this.tileQueue[layer.map.id];\n+ for (var i = tileQueue.length - 1; i >= 0; --i) {\n+ if (tileQueue[i].layer === layer) {\n+ tileQueue.splice(i, 1);\n+ }\n+ }\n+ },\n+\n+ /**\n+ * Method: destroy\n+ */\n+ destroy: function() {\n+ for (var i = this.maps.length - 1; i >= 0; --i) {\n+ this.removeMap(this.maps[i]);\n+ }\n+ this.maps = null;\n+ this.tileQueue = null;\n+ this.tileQueueId = null;\n+ this.tileCache = null;\n+ this.tileCacheIndex = null;\n+ this._destroyed = true;\n+ }\n+\n });\n /* ======================================================================\n- OpenLayers/Control/ZoomBox.js\n+ OpenLayers/Control/Button.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Handler/Box.js\n */\n \n /**\n- * Class: OpenLayers.Control.ZoomBox\n- * The ZoomBox control enables zooming directly to a given extent, by drawing \n- * a box on the map. The box is drawn by holding down shift, whilst dragging \n- * the mouse.\n- *\n+ * Class: OpenLayers.Control.Button \n+ * The Button control is a very simple push-button, for use with \n+ * .\n+ * When clicked, the function trigger() is executed.\n+ * \n * Inherits from:\n * - \n+ *\n+ * Use:\n+ * (code)\n+ * var button = new OpenLayers.Control.Button({\n+ * displayClass: \"MyButton\", trigger: myFunction\n+ * });\n+ * panel.addControls([button]);\n+ * (end)\n+ * \n+ * Will create a button with CSS class MyButtonItemInactive, that\n+ * will call the function MyFunction() when clicked.\n */\n-OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Control.Button = OpenLayers.Class(OpenLayers.Control, {\n /**\n * Property: type\n- * {OpenLayers.Control.TYPE}\n+ * {Integer} OpenLayers.Control.TYPE_BUTTON.\n */\n- type: OpenLayers.Control.TYPE_TOOL,\n+ type: OpenLayers.Control.TYPE_BUTTON,\n \n /**\n- * Property: out\n- * {Boolean} Should the control be used for zooming out?\n+ * Method: trigger\n+ * Called by a control panel when the button is clicked.\n */\n- out: false,\n+ trigger: function() {},\n+\n+ CLASS_NAME: \"OpenLayers.Control.Button\"\n+});\n+/* ======================================================================\n+ OpenLayers/Control/ZoomIn.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Control/Button.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Control.ZoomIn\n+ * The ZoomIn control is a button to increase the zoom level of a map.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Control.ZoomIn = OpenLayers.Class(OpenLayers.Control.Button, {\n \n /**\n- * APIProperty: keyMask\n- * {Integer} Zoom only occurs if the keyMask matches the combination of \n- * keys down. Use bitwise operators and one or more of the\n- * constants to construct a keyMask. Leave null if \n- * not used mask. Default is null.\n+ * Method: trigger\n */\n- keyMask: null,\n+ trigger: function() {\n+ if (this.map) {\n+ this.map.zoomIn();\n+ }\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Control.ZoomIn\"\n+});\n+/* ======================================================================\n+ OpenLayers/Handler/Keyboard.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Handler.js\n+ * @requires OpenLayers/Events.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.handler.Keyboard\n+ * A handler for keyboard events. Create a new instance with the\n+ * constructor.\n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Handler.Keyboard = OpenLayers.Class(OpenLayers.Handler, {\n+\n+ /* http://www.quirksmode.org/js/keys.html explains key x-browser\n+ key handling quirks in pretty nice detail */\n+\n+ /** \n+ * Constant: KEY_EVENTS\n+ * keydown, keypress, keyup\n+ */\n+ KEY_EVENTS: [\"keydown\", \"keyup\"],\n+\n+ /** \n+ * Property: eventListener\n+ * {Function}\n+ */\n+ eventListener: null,\n \n /**\n- * APIProperty: alwaysZoom\n- * {Boolean} Always zoom in/out when box drawn, even if the zoom level does\n- * not change.\n+ * Property: observeElement\n+ * {DOMElement|String} The DOM element on which we listen for\n+ * key events. Default to the document.\n */\n- alwaysZoom: false,\n+ observeElement: null,\n \n /**\n- * APIProperty: zoomOnClick\n- * {Boolean} Should we zoom when no box was dragged, i.e. the user only\n- * clicked? Default is true.\n+ * Constructor: OpenLayers.Handler.Keyboard\n+ * Returns a new keyboard handler.\n+ * \n+ * Parameters:\n+ * control - {} The control that is making use of\n+ * this handler. If a handler is being used without a control, the\n+ * handlers setMap method must be overridden to deal properly with\n+ * the map.\n+ * callbacks - {Object} An object containing a single function to be\n+ * called when the drag operation is finished. The callback should\n+ * expect to recieve a single argument, the pixel location of the event.\n+ * Callbacks for 'keydown', 'keypress', and 'keyup' are supported.\n+ * options - {Object} Optional object whose properties will be set on the\n+ * handler.\n */\n- zoomOnClick: true,\n+ initialize: function(control, callbacks, options) {\n+ OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n+ // cache the bound event listener method so it can be unobserved later\n+ this.eventListener = OpenLayers.Function.bindAsEventListener(\n+ this.handleKeyEvent, this\n+ );\n+ },\n \n /**\n- * Method: draw\n+ * Method: destroy\n */\n- draw: function() {\n- this.handler = new OpenLayers.Handler.Box(this, {\n- done: this.zoomBox\n- }, {\n- keyMask: this.keyMask\n- });\n+ destroy: function() {\n+ this.deactivate();\n+ this.eventListener = null;\n+ OpenLayers.Handler.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * Method: zoomBox\n- *\n- * Parameters:\n- * position - {} or {}\n+ * Method: activate\n */\n- zoomBox: function(position) {\n- if (position instanceof OpenLayers.Bounds) {\n- var bounds,\n- targetCenterPx = position.getCenterPixel();\n- if (!this.out) {\n- var minXY = this.map.getLonLatFromPixel({\n- x: position.left,\n- y: position.bottom\n- });\n- var maxXY = this.map.getLonLatFromPixel({\n- x: position.right,\n- y: position.top\n- });\n- bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat,\n- maxXY.lon, maxXY.lat);\n- } else {\n- var pixWidth = position.right - position.left;\n- var pixHeight = position.bottom - position.top;\n- var zoomFactor = Math.min((this.map.size.h / pixHeight),\n- (this.map.size.w / pixWidth));\n- var extent = this.map.getExtent();\n- var center = this.map.getLonLatFromPixel(targetCenterPx);\n- var xmin = center.lon - (extent.getWidth() / 2) * zoomFactor;\n- var xmax = center.lon + (extent.getWidth() / 2) * zoomFactor;\n- var ymin = center.lat - (extent.getHeight() / 2) * zoomFactor;\n- var ymax = center.lat + (extent.getHeight() / 2) * zoomFactor;\n- bounds = new OpenLayers.Bounds(xmin, ymin, xmax, ymax);\n- }\n- // always zoom in/out \n- var lastZoom = this.map.getZoom(),\n- size = this.map.getSize(),\n- centerPx = {\n- x: size.w / 2,\n- y: size.h / 2\n- },\n- zoom = this.map.getZoomForExtent(bounds),\n- oldRes = this.map.getResolution(),\n- newRes = this.map.getResolutionForZoom(zoom);\n- if (oldRes == newRes) {\n- this.map.setCenter(this.map.getLonLatFromPixel(targetCenterPx));\n- } else {\n- var zoomOriginPx = {\n- x: (oldRes * targetCenterPx.x - newRes * centerPx.x) /\n- (oldRes - newRes),\n- y: (oldRes * targetCenterPx.y - newRes * centerPx.y) /\n- (oldRes - newRes)\n- };\n- this.map.zoomTo(zoom, zoomOriginPx);\n- }\n- if (lastZoom == this.map.getZoom() && this.alwaysZoom == true) {\n- this.map.zoomTo(lastZoom + (this.out ? -1 : 1));\n+ activate: function() {\n+ if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n+ this.observeElement = this.observeElement || document;\n+ for (var i = 0, len = this.KEY_EVENTS.length; i < len; i++) {\n+ OpenLayers.Event.observe(\n+ this.observeElement, this.KEY_EVENTS[i], this.eventListener);\n }\n- } else if (this.zoomOnClick) { // it's a pixel\n- if (!this.out) {\n- this.map.zoomTo(this.map.getZoom() + 1, position);\n- } else {\n- this.map.zoomTo(this.map.getZoom() - 1, position);\n+ return true;\n+ } else {\n+ return false;\n+ }\n+ },\n+\n+ /**\n+ * Method: deactivate\n+ */\n+ deactivate: function() {\n+ var deactivated = false;\n+ if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n+ for (var i = 0, len = this.KEY_EVENTS.length; i < len; i++) {\n+ OpenLayers.Event.stopObserving(\n+ this.observeElement, this.KEY_EVENTS[i], this.eventListener);\n }\n+ deactivated = true;\n }\n+ return deactivated;\n },\n \n- CLASS_NAME: \"OpenLayers.Control.ZoomBox\"\n+ /**\n+ * Method: handleKeyEvent \n+ */\n+ handleKeyEvent: function(evt) {\n+ if (this.checkModifiers(evt)) {\n+ this.callback(evt.type, [evt]);\n+ }\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Handler.Keyboard\"\n });\n /* ======================================================================\n- OpenLayers/Control/NavigationHistory.js\n+ OpenLayers/Control/KeyboardDefaults.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Control/Button.js\n+ * @requires OpenLayers/Handler/Keyboard.js\n+ * @requires OpenLayers/Events.js\n */\n \n /**\n- * Class: OpenLayers.Control.NavigationHistory\n- * A navigation history control. This is a meta-control, that creates two\n- * dependent controls: and . Call the trigger method\n- * on the and controls to restore previous and next\n- * history states. The previous and next controls will become active\n- * when there are available states to restore and will become deactive\n- * when there are no states to restore.\n+ * Class: OpenLayers.Control.KeyboardDefaults\n+ * The KeyboardDefaults control adds panning and zooming functions, controlled\n+ * with the keyboard. By default arrow keys pan, +/- keys zoom & Page Up/Page\n+ * Down/Home/End scroll by three quarters of a page.\n+ * \n+ * This control has no visible appearance.\n *\n * Inherits from:\n * - \n */\n-OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * Property: type\n- * {String} Note that this control is not intended to be added directly\n- * to a control panel. Instead, add the sub-controls previous and\n- * next. These sub-controls are button type controls that activate\n- * and deactivate themselves. If this parent control is added to\n- * a panel, it will act as a toggle.\n+ * APIProperty: autoActivate\n+ * {Boolean} Activate the control when it is added to a map. Default is\n+ * true.\n */\n- type: OpenLayers.Control.TYPE_TOGGLE,\n+ autoActivate: true,\n \n /**\n- * APIProperty: previous\n- * {} A button type control whose trigger method restores\n- * the previous state managed by this control.\n+ * APIProperty: slideFactor\n+ * Pixels to slide by.\n */\n- previous: null,\n+ slideFactor: 75,\n \n /**\n- * APIProperty: previousOptions\n- * {Object} Set this property on the options argument of the constructor\n- * to set optional properties on the control.\n+ * APIProperty: observeElement\n+ * {DOMelement|String} The DOM element to handle keys for. You\n+ * can use the map div here, to have the navigation keys\n+ * work when the map div has the focus. If undefined the\n+ * document is used.\n */\n- previousOptions: null,\n+ observeElement: null,\n \n /**\n- * APIProperty: next\n- * {} A button type control whose trigger method restores\n- * the next state managed by this control.\n+ * Constructor: OpenLayers.Control.KeyboardDefaults\n */\n- next: null,\n \n /**\n- * APIProperty: nextOptions\n- * {Object} Set this property on the options argument of the constructor\n- * to set optional properties on the control.\n+ * Method: draw\n+ * Create handler.\n */\n- nextOptions: null,\n+ draw: function() {\n+ var observeElement = this.observeElement || document;\n+ this.handler = new OpenLayers.Handler.Keyboard(this, {\n+ \"keydown\": this.defaultKeyPress\n+ }, {\n+ observeElement: observeElement\n+ });\n+ },\n \n /**\n- * APIProperty: limit\n- * {Integer} Optional limit on the number of history items to retain. If\n- * null, there is no limit. Default is 50.\n+ * Method: defaultKeyPress\n+ * When handling the key event, we only use evt.keyCode. This holds \n+ * some drawbacks, though we get around them below. When interpretting\n+ * the keycodes below (including the comments associated with them),\n+ * consult the URL below. For instance, the Safari browser returns\n+ * \"IE keycodes\", and so is supported by any keycode labeled \"IE\".\n+ * \n+ * Very informative URL:\n+ * http://unixpapa.com/js/key.html\n+ *\n+ * Parameters:\n+ * evt - {Event} \n */\n- limit: 50,\n+ defaultKeyPress: function(evt) {\n+ var size, handled = true;\n+\n+ var target = OpenLayers.Event.element(evt);\n+ if (target &&\n+ (target.tagName == 'INPUT' ||\n+ target.tagName == 'TEXTAREA' ||\n+ target.tagName == 'SELECT')) {\n+ return;\n+ }\n+\n+ switch (evt.keyCode) {\n+ case OpenLayers.Event.KEY_LEFT:\n+ this.map.pan(-this.slideFactor, 0);\n+ break;\n+ case OpenLayers.Event.KEY_RIGHT:\n+ this.map.pan(this.slideFactor, 0);\n+ break;\n+ case OpenLayers.Event.KEY_UP:\n+ this.map.pan(0, -this.slideFactor);\n+ break;\n+ case OpenLayers.Event.KEY_DOWN:\n+ this.map.pan(0, this.slideFactor);\n+ break;\n+\n+ case 33: // Page Up. Same in all browsers.\n+ size = this.map.getSize();\n+ this.map.pan(0, -0.75 * size.h);\n+ break;\n+ case 34: // Page Down. Same in all browsers.\n+ size = this.map.getSize();\n+ this.map.pan(0, 0.75 * size.h);\n+ break;\n+ case 35: // End. Same in all browsers.\n+ size = this.map.getSize();\n+ this.map.pan(0.75 * size.w, 0);\n+ break;\n+ case 36: // Home. Same in all browsers.\n+ size = this.map.getSize();\n+ this.map.pan(-0.75 * size.w, 0);\n+ break;\n+\n+ case 43: // +/= (ASCII), keypad + (ASCII, Opera)\n+ case 61: // +/= (Mozilla, Opera, some ASCII)\n+ case 187: // +/= (IE)\n+ case 107: // keypad + (IE, Mozilla)\n+ this.map.zoomIn();\n+ break;\n+ case 45: // -/_ (ASCII, Opera), keypad - (ASCII, Opera)\n+ case 109: // -/_ (Mozilla), keypad - (Mozilla, IE)\n+ case 189: // -/_ (IE)\n+ case 95: // -/_ (some ASCII)\n+ this.map.zoomOut();\n+ break;\n+ default:\n+ handled = false;\n+ }\n+ if (handled) {\n+ // prevent browser default not to move the page\n+ // when moving the page with the keyboard\n+ OpenLayers.Event.stop(evt);\n+ }\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Control.KeyboardDefaults\"\n+});\n+/* ======================================================================\n+ OpenLayers/Handler/Drag.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Handler.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Handler.Drag\n+ * The drag handler is used to deal with sequences of browser events related\n+ * to dragging. The handler is used by controls that want to know when\n+ * a drag sequence begins, when a drag is happening, and when it has\n+ * finished.\n+ *\n+ * Controls that use the drag handler typically construct it with callbacks\n+ * for 'down', 'move', and 'done'. Callbacks for these keys are called\n+ * when the drag begins, with each move, and when the drag is done. In\n+ * addition, controls can have callbacks keyed to 'up' and 'out' if they\n+ * care to differentiate between the types of events that correspond with\n+ * the end of a drag sequence. If no drag actually occurs (no mouse move)\n+ * the 'down' and 'up' callbacks will be called, but not the 'done'\n+ * callback.\n+ *\n+ * Create a new drag handler with the constructor.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {\n+\n+ /** \n+ * Property: started\n+ * {Boolean} When a mousedown or touchstart event is received, we want to\n+ * record it, but not set 'dragging' until the mouse moves after starting.\n+ */\n+ started: false,\n \n /**\n- * APIProperty: autoActivate\n- * {Boolean} Activate the control when it is added to a map. Default is\n- * true.\n+ * Property: stopDown\n+ * {Boolean} Stop propagation of mousedown events from getting to listeners\n+ * on the same element. Default is true.\n */\n- autoActivate: true,\n+ stopDown: true,\n+\n+ /** \n+ * Property: dragging \n+ * {Boolean} \n+ */\n+ dragging: false,\n+\n+ /** \n+ * Property: last\n+ * {} The last pixel location of the drag.\n+ */\n+ last: null,\n+\n+ /** \n+ * Property: start\n+ * {} The first pixel location of the drag.\n+ */\n+ start: null,\n \n /**\n- * Property: clearOnDeactivate\n- * {Boolean} Clear the history when the control is deactivated. Default\n- * is false.\n+ * Property: lastMoveEvt\n+ * {Object} The last mousemove event that occurred. Used to\n+ * position the map correctly when our \"delay drag\"\n+ * timeout expired.\n */\n- clearOnDeactivate: false,\n+ lastMoveEvt: null,\n \n /**\n- * Property: registry\n- * {Object} An object with keys corresponding to event types. Values\n- * are functions that return an object representing the current state.\n+ * Property: oldOnselectstart\n+ * {Function}\n */\n- registry: null,\n+ oldOnselectstart: null,\n \n /**\n- * Property: nextStack\n- * {Array} Array of items in the history.\n+ * Property: interval\n+ * {Integer} In order to increase performance, an interval (in \n+ * milliseconds) can be set to reduce the number of drag events \n+ * called. If set, a new drag event will not be set until the \n+ * interval has passed. \n+ * Defaults to 0, meaning no interval. \n */\n- nextStack: null,\n+ interval: 0,\n \n /**\n- * Property: previousStack\n- * {Array} List of items in the history. First item represents the current\n- * state.\n+ * Property: timeoutId\n+ * {String} The id of the timeout used for the mousedown interval.\n+ * This is \"private\", and should be left alone.\n */\n- previousStack: null,\n+ timeoutId: null,\n \n /**\n- * Property: listeners\n- * {Object} An object containing properties corresponding to event types.\n- * This object is used to configure the control and is modified on\n- * construction.\n+ * APIProperty: documentDrag\n+ * {Boolean} If set to true, the handler will also handle mouse moves when\n+ * the cursor has moved out of the map viewport. Default is false.\n */\n- listeners: null,\n+ documentDrag: false,\n \n /**\n- * Property: restoring\n- * {Boolean} Currently restoring a history state. This is set to true\n- * before calling restore and set to false after restore returns.\n+ * Property: documentEvents\n+ * {Boolean} Are we currently observing document events?\n */\n- restoring: false,\n+ documentEvents: null,\n \n /**\n- * Constructor: OpenLayers.Control.NavigationHistory \n+ * Constructor: OpenLayers.Handler.Drag\n+ * Returns OpenLayers.Handler.Drag\n * \n * Parameters:\n- * options - {Object} An optional object whose properties will be used\n- * to extend the control.\n+ * control - {} The control that is making use of\n+ * this handler. If a handler is being used without a control, the\n+ * handlers setMap method must be overridden to deal properly with\n+ * the map.\n+ * callbacks - {Object} An object containing a single function to be\n+ * called when the drag operation is finished. The callback should\n+ * expect to recieve a single argument, the pixel location of the event.\n+ * Callbacks for 'move' and 'done' are supported. You can also speficy\n+ * callbacks for 'down', 'up', and 'out' to respond to those events.\n+ * options - {Object} \n */\n- initialize: function(options) {\n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+ initialize: function(control, callbacks, options) {\n+ OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n \n- this.registry = OpenLayers.Util.extend({\n- \"moveend\": this.getState\n- }, this.registry);\n+ if (this.documentDrag === true) {\n+ var me = this;\n+ this._docMove = function(evt) {\n+ me.mousemove({\n+ xy: {\n+ x: evt.clientX,\n+ y: evt.clientY\n+ },\n+ element: document\n+ });\n+ };\n+ this._docUp = function(evt) {\n+ me.mouseup({\n+ xy: {\n+ x: evt.clientX,\n+ y: evt.clientY\n+ }\n+ });\n+ };\n+ }\n+ },\n \n- var previousOptions = {\n- trigger: OpenLayers.Function.bind(this.previousTrigger, this),\n- displayClass: this.displayClass + \" \" + this.displayClass + \"Previous\"\n- };\n- OpenLayers.Util.extend(previousOptions, this.previousOptions);\n- this.previous = new OpenLayers.Control.Button(previousOptions);\n \n- var nextOptions = {\n- trigger: OpenLayers.Function.bind(this.nextTrigger, this),\n- displayClass: this.displayClass + \" \" + this.displayClass + \"Next\"\n- };\n- OpenLayers.Util.extend(nextOptions, this.nextOptions);\n- this.next = new OpenLayers.Control.Button(nextOptions);\n+ /**\n+ * Method: dragstart\n+ * This private method is factorized from mousedown and touchstart methods\n+ *\n+ * Parameters:\n+ * evt - {Event} The event\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n+ */\n+ dragstart: function(evt) {\n+ var propagate = true;\n+ this.dragging = false;\n+ if (this.checkModifiers(evt) &&\n+ (OpenLayers.Event.isLeftClick(evt) ||\n+ OpenLayers.Event.isSingleTouch(evt))) {\n+ this.started = true;\n+ this.start = evt.xy;\n+ this.last = evt.xy;\n+ OpenLayers.Element.addClass(\n+ this.map.viewPortDiv, \"olDragDown\"\n+ );\n+ this.down(evt);\n+ this.callback(\"down\", [evt.xy]);\n \n- this.clear();\n+ // prevent document dragging\n+ OpenLayers.Event.preventDefault(evt);\n+\n+ if (!this.oldOnselectstart) {\n+ this.oldOnselectstart = document.onselectstart ?\n+ document.onselectstart : OpenLayers.Function.True;\n+ }\n+ document.onselectstart = OpenLayers.Function.False;\n+\n+ propagate = !this.stopDown;\n+ } else {\n+ this.started = false;\n+ this.start = null;\n+ this.last = null;\n+ }\n+ return propagate;\n },\n \n /**\n- * Method: onPreviousChange\n- * Called when the previous history stack changes.\n+ * Method: dragmove\n+ * This private method is factorized from mousemove and touchmove methods\n *\n * Parameters:\n- * state - {Object} An object representing the state to be restored\n- * if previous is triggered again or null if no previous states remain.\n- * length - {Integer} The number of remaining previous states that can\n- * be restored.\n+ * evt - {Event} The event\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n */\n- onPreviousChange: function(state, length) {\n- if (state && !this.previous.active) {\n- this.previous.activate();\n- } else if (!state && this.previous.active) {\n- this.previous.deactivate();\n+ dragmove: function(evt) {\n+ this.lastMoveEvt = evt;\n+ if (this.started && !this.timeoutId && (evt.xy.x != this.last.x ||\n+ evt.xy.y != this.last.y)) {\n+ if (this.documentDrag === true && this.documentEvents) {\n+ if (evt.element === document) {\n+ this.adjustXY(evt);\n+ // do setEvent manually because the documentEvents are not\n+ // registered with the map\n+ this.setEvent(evt);\n+ } else {\n+ this.removeDocumentEvents();\n+ }\n+ }\n+ if (this.interval > 0) {\n+ this.timeoutId = setTimeout(\n+ OpenLayers.Function.bind(this.removeTimeout, this),\n+ this.interval);\n+ }\n+ this.dragging = true;\n+\n+ this.move(evt);\n+ this.callback(\"move\", [evt.xy]);\n+ if (!this.oldOnselectstart) {\n+ this.oldOnselectstart = document.onselectstart;\n+ document.onselectstart = OpenLayers.Function.False;\n+ }\n+ this.last = evt.xy;\n }\n+ return true;\n },\n \n /**\n- * Method: onNextChange\n- * Called when the next history stack changes.\n+ * Method: dragend\n+ * This private method is factorized from mouseup and touchend methods\n *\n * Parameters:\n- * state - {Object} An object representing the state to be restored\n- * if next is triggered again or null if no next states remain.\n- * length - {Integer} The number of remaining next states that can\n- * be restored.\n+ * evt - {Event} The event\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n */\n- onNextChange: function(state, length) {\n- if (state && !this.next.active) {\n- this.next.activate();\n- } else if (!state && this.next.active) {\n- this.next.deactivate();\n+ dragend: function(evt) {\n+ if (this.started) {\n+ if (this.documentDrag === true && this.documentEvents) {\n+ this.adjustXY(evt);\n+ this.removeDocumentEvents();\n+ }\n+ var dragged = (this.start != this.last);\n+ this.started = false;\n+ this.dragging = false;\n+ OpenLayers.Element.removeClass(\n+ this.map.viewPortDiv, \"olDragDown\"\n+ );\n+ this.up(evt);\n+ this.callback(\"up\", [evt.xy]);\n+ if (dragged) {\n+ this.callback(\"done\", [evt.xy]);\n+ }\n+ document.onselectstart = this.oldOnselectstart;\n }\n+ return true;\n },\n \n /**\n- * APIMethod: destroy\n- * Destroy the control.\n+ * The four methods below (down, move, up, and out) are used by subclasses\n+ * to do their own processing related to these mouse events.\n */\n- destroy: function() {\n- OpenLayers.Control.prototype.destroy.apply(this);\n- this.previous.destroy();\n- this.next.destroy();\n- this.deactivate();\n- for (var prop in this) {\n- this[prop] = null;\n- }\n- },\n \n- /** \n- * Method: setMap\n- * Set the map property for the control and and child\n- * controls.\n+ /**\n+ * Method: down\n+ * This method is called during the handling of the mouse down event.\n+ * Subclasses can do their own processing here.\n *\n * Parameters:\n- * map - {} \n+ * evt - {Event} The mouse down event\n */\n- setMap: function(map) {\n- this.map = map;\n- this.next.setMap(map);\n- this.previous.setMap(map);\n+ down: function(evt) {},\n+\n+ /**\n+ * Method: move\n+ * This method is called during the handling of the mouse move event.\n+ * Subclasses can do their own processing here.\n+ *\n+ * Parameters:\n+ * evt - {Event} The mouse move event\n+ *\n+ */\n+ move: function(evt) {},\n+\n+ /**\n+ * Method: up\n+ * This method is called during the handling of the mouse up event.\n+ * Subclasses can do their own processing here.\n+ *\n+ * Parameters:\n+ * evt - {Event} The mouse up event\n+ */\n+ up: function(evt) {},\n+\n+ /**\n+ * Method: out\n+ * This method is called during the handling of the mouse out event.\n+ * Subclasses can do their own processing here.\n+ *\n+ * Parameters:\n+ * evt - {Event} The mouse out event\n+ */\n+ out: function(evt) {},\n+\n+ /**\n+ * The methods below are part of the magic of event handling. Because\n+ * they are named like browser events, they are registered as listeners\n+ * for the events they represent.\n+ */\n+\n+ /**\n+ * Method: mousedown\n+ * Handle mousedown events\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n+ */\n+ mousedown: function(evt) {\n+ return this.dragstart(evt);\n },\n \n /**\n- * Method: draw\n- * Called when the control is added to the map.\n+ * Method: touchstart\n+ * Handle touchstart events\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n */\n- draw: function() {\n- OpenLayers.Control.prototype.draw.apply(this, arguments);\n- this.next.draw();\n- this.previous.draw();\n+ touchstart: function(evt) {\n+ this.startTouch();\n+ return this.dragstart(evt);\n },\n \n /**\n- * Method: previousTrigger\n- * Restore the previous state. If no items are in the previous history\n- * stack, this has no effect.\n+ * Method: mousemove\n+ * Handle mousemove events\n+ *\n+ * Parameters:\n+ * evt - {Event}\n *\n * Returns:\n- * {Object} Item representing state that was restored. Undefined if no\n- * items are in the previous history stack.\n+ * {Boolean} Let the event propagate.\n */\n- previousTrigger: function() {\n- var current = this.previousStack.shift();\n- var state = this.previousStack.shift();\n- if (state != undefined) {\n- this.nextStack.unshift(current);\n- this.previousStack.unshift(state);\n- this.restoring = true;\n- this.restore(state);\n- this.restoring = false;\n- this.onNextChange(this.nextStack[0], this.nextStack.length);\n- this.onPreviousChange(\n- this.previousStack[1], this.previousStack.length - 1\n- );\n- } else {\n- this.previousStack.unshift(current);\n- }\n- return state;\n+ mousemove: function(evt) {\n+ return this.dragmove(evt);\n },\n \n /**\n- * APIMethod: nextTrigger\n- * Restore the next state. If no items are in the next history\n- * stack, this has no effect. The next history stack is populated\n- * as states are restored from the previous history stack.\n+ * Method: touchmove\n+ * Handle touchmove events\n+ *\n+ * Parameters:\n+ * evt - {Event}\n *\n * Returns:\n- * {Object} Item representing state that was restored. Undefined if no\n- * items are in the next history stack.\n+ * {Boolean} Let the event propagate.\n */\n- nextTrigger: function() {\n- var state = this.nextStack.shift();\n- if (state != undefined) {\n- this.previousStack.unshift(state);\n- this.restoring = true;\n- this.restore(state);\n- this.restoring = false;\n- this.onNextChange(this.nextStack[0], this.nextStack.length);\n- this.onPreviousChange(\n- this.previousStack[1], this.previousStack.length - 1\n- );\n- }\n- return state;\n+ touchmove: function(evt) {\n+ return this.dragmove(evt);\n },\n \n /**\n- * APIMethod: clear\n- * Clear history.\n+ * Method: removeTimeout\n+ * Private. Called by mousemove() to remove the drag timeout.\n */\n- clear: function() {\n- this.previousStack = [];\n- this.previous.deactivate();\n- this.nextStack = [];\n- this.next.deactivate();\n+ removeTimeout: function() {\n+ this.timeoutId = null;\n+ // if timeout expires while we're still dragging (mouseup\n+ // hasn't occurred) then call mousemove to move to the\n+ // correct position\n+ if (this.dragging) {\n+ this.mousemove(this.lastMoveEvt);\n+ }\n },\n \n /**\n- * Method: getState\n- * Get the current state and return it.\n+ * Method: mouseup\n+ * Handle mouseup events\n+ *\n+ * Parameters:\n+ * evt - {Event}\n *\n * Returns:\n- * {Object} An object representing the current state.\n+ * {Boolean} Let the event propagate.\n */\n- getState: function() {\n- return {\n- center: this.map.getCenter(),\n- resolution: this.map.getResolution(),\n- projection: this.map.getProjectionObject(),\n- units: this.map.getProjectionObject().getUnits() ||\n- this.map.units || this.map.baseLayer.units\n- };\n+ mouseup: function(evt) {\n+ return this.dragend(evt);\n },\n \n /**\n- * Method: restore\n- * Update the state with the given object.\n+ * Method: touchend\n+ * Handle touchend events\n *\n * Parameters:\n- * state - {Object} An object representing the state to restore.\n+ * evt - {Event}\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n */\n- restore: function(state) {\n- var center, zoom;\n- if (this.map.getProjectionObject() == state.projection) {\n- zoom = this.map.getZoomForResolution(state.resolution);\n- center = state.center;\n- } else {\n- center = state.center.clone();\n- center.transform(state.projection, this.map.getProjectionObject());\n- var sourceUnits = state.units;\n- var targetUnits = this.map.getProjectionObject().getUnits() ||\n- this.map.units || this.map.baseLayer.units;\n- var resolutionFactor = sourceUnits && targetUnits ?\n- OpenLayers.INCHES_PER_UNIT[sourceUnits] / OpenLayers.INCHES_PER_UNIT[targetUnits] : 1;\n- zoom = this.map.getZoomForResolution(resolutionFactor * state.resolution);\n- }\n- this.map.setCenter(center, zoom);\n+ touchend: function(evt) {\n+ // override evt.xy with last position since touchend does not have\n+ // any touch position\n+ evt.xy = this.last;\n+ return this.dragend(evt);\n },\n \n /**\n- * Method: setListeners\n- * Sets functions to be registered in the listeners object.\n+ * Method: mouseout\n+ * Handle mouseout events\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n */\n- setListeners: function() {\n- this.listeners = {};\n- for (var type in this.registry) {\n- this.listeners[type] = OpenLayers.Function.bind(function() {\n- if (!this.restoring) {\n- var state = this.registry[type].apply(this, arguments);\n- this.previousStack.unshift(state);\n- if (this.previousStack.length > 1) {\n- this.onPreviousChange(\n- this.previousStack[1], this.previousStack.length - 1\n- );\n- }\n- if (this.previousStack.length > (this.limit + 1)) {\n- this.previousStack.pop();\n- }\n- if (this.nextStack.length > 0) {\n- this.nextStack = [];\n- this.onNextChange(null, 0);\n- }\n+ mouseout: function(evt) {\n+ if (this.started && OpenLayers.Util.mouseLeft(evt, this.map.viewPortDiv)) {\n+ if (this.documentDrag === true) {\n+ this.addDocumentEvents();\n+ } else {\n+ var dragged = (this.start != this.last);\n+ this.started = false;\n+ this.dragging = false;\n+ OpenLayers.Element.removeClass(\n+ this.map.viewPortDiv, \"olDragDown\"\n+ );\n+ this.out(evt);\n+ this.callback(\"out\", []);\n+ if (dragged) {\n+ this.callback(\"done\", [evt.xy]);\n }\n- return true;\n- }, this);\n+ if (document.onselectstart) {\n+ document.onselectstart = this.oldOnselectstart;\n+ }\n+ }\n }\n+ return true;\n },\n \n /**\n- * APIMethod: activate\n- * Activate the control. This registers any listeners.\n- *\n+ * Method: click\n+ * The drag handler captures the click event. If something else registers\n+ * for clicks on the same element, its listener will not be called \n+ * after a drag.\n+ * \n+ * Parameters: \n+ * evt - {Event} \n+ * \n * Returns:\n- * {Boolean} Control successfully activated.\n+ * {Boolean} Let the event propagate.\n+ */\n+ click: function(evt) {\n+ // let the click event propagate only if the mouse moved\n+ return (this.start == this.last);\n+ },\n+\n+ /**\n+ * Method: activate\n+ * Activate the handler.\n+ * \n+ * Returns:\n+ * {Boolean} The handler was successfully activated.\n */\n activate: function() {\n var activated = false;\n- if (this.map) {\n- if (OpenLayers.Control.prototype.activate.apply(this)) {\n- if (this.listeners == null) {\n- this.setListeners();\n- }\n- for (var type in this.listeners) {\n- this.map.events.register(type, this, this.listeners[type]);\n- }\n- activated = true;\n- if (this.previousStack.length == 0) {\n- this.initStack();\n- }\n- }\n+ if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n+ this.dragging = false;\n+ activated = true;\n }\n return activated;\n },\n \n /**\n- * Method: initStack\n- * Called after the control is activated if the previous history stack is\n- * empty.\n+ * Method: deactivate \n+ * Deactivate the handler.\n+ * \n+ * Returns:\n+ * {Boolean} The handler was successfully deactivated.\n */\n- initStack: function() {\n- if (this.map.getCenter()) {\n- this.listeners.moveend();\n+ deactivate: function() {\n+ var deactivated = false;\n+ if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n+ this.started = false;\n+ this.dragging = false;\n+ this.start = null;\n+ this.last = null;\n+ deactivated = true;\n+ OpenLayers.Element.removeClass(\n+ this.map.viewPortDiv, \"olDragDown\"\n+ );\n }\n+ return deactivated;\n },\n \n /**\n- * APIMethod: deactivate\n- * Deactivate the control. This unregisters any listeners.\n+ * Method: adjustXY\n+ * Converts event coordinates that are relative to the document body to\n+ * ones that are relative to the map viewport. The latter is the default in\n+ * OpenLayers.\n+ * \n+ * Parameters:\n+ * evt - {Object}\n+ */\n+ adjustXY: function(evt) {\n+ var pos = OpenLayers.Util.pagePosition(this.map.viewPortDiv);\n+ evt.xy.x -= pos[0];\n+ evt.xy.y -= pos[1];\n+ },\n+\n+ /**\n+ * Method: addDocumentEvents\n+ * Start observing document events when documentDrag is true and the mouse\n+ * cursor leaves the map viewport while dragging.\n+ */\n+ addDocumentEvents: function() {\n+ OpenLayers.Element.addClass(document.body, \"olDragDown\");\n+ this.documentEvents = true;\n+ OpenLayers.Event.observe(document, \"mousemove\", this._docMove);\n+ OpenLayers.Event.observe(document, \"mouseup\", this._docUp);\n+ },\n+\n+ /**\n+ * Method: removeDocumentEvents\n+ * Stops observing document events when documentDrag is true and the mouse\n+ * cursor re-enters the map viewport while dragging.\n+ */\n+ removeDocumentEvents: function() {\n+ OpenLayers.Element.removeClass(document.body, \"olDragDown\");\n+ this.documentEvents = false;\n+ OpenLayers.Event.stopObserving(document, \"mousemove\", this._docMove);\n+ OpenLayers.Event.stopObserving(document, \"mouseup\", this._docUp);\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Handler.Drag\"\n+});\n+/* ======================================================================\n+ OpenLayers/Control/DragPan.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Handler/Drag.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Control.DragPan\n+ * The DragPan control pans the map with a drag of the mouse.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {\n+\n+ /** \n+ * Property: type\n+ * {OpenLayers.Control.TYPES}\n+ */\n+ type: OpenLayers.Control.TYPE_TOOL,\n+\n+ /**\n+ * Property: panned\n+ * {Boolean} The map moved.\n+ */\n+ panned: false,\n+\n+ /**\n+ * Property: interval\n+ * {Integer} The number of milliseconds that should ellapse before\n+ * panning the map again. Defaults to 0 milliseconds, which means that\n+ * no separate cycle is used for panning. In most cases you won't want\n+ * to change this value. For slow machines/devices larger values can be\n+ * tried out.\n+ */\n+ interval: 0,\n+\n+ /**\n+ * APIProperty: documentDrag\n+ * {Boolean} If set to true, mouse dragging will continue even if the\n+ * mouse cursor leaves the map viewport. Default is false.\n+ */\n+ documentDrag: false,\n+\n+ /**\n+ * Property: kinetic\n+ * {} The OpenLayers.Kinetic object.\n+ */\n+ kinetic: null,\n+\n+ /**\n+ * APIProperty: enableKinetic\n+ * {Boolean} Set this option to enable \"kinetic dragging\". Can be\n+ * set to true or to an object. If set to an object this\n+ * object will be passed to the {}\n+ * constructor. Defaults to true.\n+ * To get kinetic dragging, ensure that OpenLayers/Kinetic.js is\n+ * included in your build config.\n+ */\n+ enableKinetic: true,\n+\n+ /**\n+ * APIProperty: kineticInterval\n+ * {Integer} Interval in milliseconds between 2 steps in the \"kinetic\n+ * scrolling\". Applies only if enableKinetic is set. Defaults\n+ * to 10 milliseconds.\n+ */\n+ kineticInterval: 10,\n+\n+\n+ /**\n+ * Method: draw\n+ * Creates a Drag handler, using and\n+ * as callbacks.\n+ */\n+ draw: function() {\n+ if (this.enableKinetic && OpenLayers.Kinetic) {\n+ var config = {\n+ interval: this.kineticInterval\n+ };\n+ if (typeof this.enableKinetic === \"object\") {\n+ config = OpenLayers.Util.extend(config, this.enableKinetic);\n+ }\n+ this.kinetic = new OpenLayers.Kinetic(config);\n+ }\n+ this.handler = new OpenLayers.Handler.Drag(this, {\n+ \"move\": this.panMap,\n+ \"done\": this.panMapDone,\n+ \"down\": this.panMapStart\n+ }, {\n+ interval: this.interval,\n+ documentDrag: this.documentDrag\n+ });\n+ },\n+\n+ /**\n+ * Method: panMapStart\n+ */\n+ panMapStart: function() {\n+ if (this.kinetic) {\n+ this.kinetic.begin();\n+ }\n+ },\n+\n+ /**\n+ * Method: panMap\n *\n- * Returns:\n- * {Boolean} Control successfully deactivated.\n+ * Parameters:\n+ * xy - {} Pixel of the mouse position\n */\n- deactivate: function() {\n- var deactivated = false;\n- if (this.map) {\n- if (OpenLayers.Control.prototype.deactivate.apply(this)) {\n- for (var type in this.listeners) {\n- this.map.events.unregister(\n- type, this, this.listeners[type]\n- );\n- }\n- if (this.clearOnDeactivate) {\n- this.clear();\n+ panMap: function(xy) {\n+ if (this.kinetic) {\n+ this.kinetic.update(xy);\n+ }\n+ this.panned = true;\n+ this.map.pan(\n+ this.handler.last.x - xy.x,\n+ this.handler.last.y - xy.y, {\n+ dragging: true,\n+ animate: false\n+ }\n+ );\n+ },\n+\n+ /**\n+ * Method: panMapDone\n+ * Finish the panning operation. Only call setCenter (through )\n+ * if the map has actually been moved.\n+ *\n+ * Parameters:\n+ * xy - {} Pixel of the mouse position\n+ */\n+ panMapDone: function(xy) {\n+ if (this.panned) {\n+ var res = null;\n+ if (this.kinetic) {\n+ res = this.kinetic.end(xy);\n+ }\n+ this.map.pan(\n+ this.handler.last.x - xy.x,\n+ this.handler.last.y - xy.y, {\n+ dragging: !!res,\n+ animate: false\n }\n- deactivated = true;\n+ );\n+ if (res) {\n+ var self = this;\n+ this.kinetic.move(res, function(x, y, end) {\n+ self.map.pan(x, y, {\n+ dragging: !end,\n+ animate: false\n+ });\n+ });\n }\n+ this.panned = false;\n }\n- return deactivated;\n },\n \n- CLASS_NAME: \"OpenLayers.Control.NavigationHistory\"\n+ CLASS_NAME: \"OpenLayers.Control.DragPan\"\n });\n-\n /* ======================================================================\n OpenLayers/Handler/Point.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n@@ -40858,618 +36674,1375 @@\n }\n OpenLayers.Control.prototype.destroy.call(this);\n },\n \n CLASS_NAME: \"OpenLayers.Control.Split\"\n });\n /* ======================================================================\n- OpenLayers/Handler/Pinch.js\n+ OpenLayers/Control/Measure.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Handler.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Feature/Vector.js\n */\n \n /**\n- * Class: OpenLayers.Handler.Pinch\n- * The pinch handler is used to deal with sequences of browser events related\n- * to pinch gestures. The handler is used by controls that want to know\n- * when a pinch sequence begins, when a pinch is happening, and when it has\n- * finished.\n- *\n- * Controls that use the pinch handler typically construct it with callbacks\n- * for 'start', 'move', and 'done'. Callbacks for these keys are\n- * called when the pinch begins, with each change, and when the pinch is\n- * done.\n- *\n- * Create a new pinch handler with the constructor.\n+ * Class: OpenLayers.Control.Measure\n+ * Allows for drawing of features for measurements.\n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Handler.Pinch = OpenLayers.Class(OpenLayers.Handler, {\n+OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * Property: started\n- * {Boolean} When a touchstart event is received, we want to record it,\n- * but not set 'pinching' until the touchmove get started after\n- * starting.\n+ * APIProperty: events\n+ * {} Events instance for listeners and triggering\n+ * control specific events.\n+ *\n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * control.events.register(type, obj, listener);\n+ * (end)\n+ *\n+ * Supported event types (in addition to those from ):\n+ * measure - Triggered when a measurement sketch is complete. Listeners\n+ * will receive an event with measure, units, order, and geometry\n+ * properties.\n+ * measurepartial - Triggered when a new point is added to the\n+ * measurement sketch or if the property is true and the\n+ * measurement sketch is modified. Listeners receive an event with measure,\n+ * units, order, and geometry.\n */\n- started: false,\n \n /**\n- * Property: stopDown\n- * {Boolean} Stop propagation of touchstart events from getting to\n- * listeners on the same element. Default is false.\n+ * APIProperty: handlerOptions\n+ * {Object} Used to set non-default properties on the control's handler\n */\n- stopDown: false,\n \n /**\n- * Property: pinching\n- * {Boolean}\n+ * Property: callbacks\n+ * {Object} The functions that are sent to the handler for callback\n */\n- pinching: false,\n+ callbacks: null,\n \n /**\n- * Property: last\n- * {Object} Object that store informations related to pinch last touch.\n+ * APIProperty: displaySystem\n+ * {String} Display system for output measurements. Supported values\n+ * are 'english', 'metric', and 'geographic'. Default is 'metric'.\n */\n- last: null,\n+ displaySystem: 'metric',\n \n /**\n- * Property: start\n- * {Object} Object that store informations related to pinch touchstart.\n+ * APIProperty: geodesic\n+ * {Boolean} Calculate geodesic metrics instead of planar metrics. This\n+ * requires that geometries can be transformed into Geographic/WGS84\n+ * (if that is not already the map projection). Default is false.\n */\n- start: null,\n+ geodesic: false,\n \n /**\n- * Constructor: OpenLayers.Handler.Pinch\n- * Returns OpenLayers.Handler.Pinch\n+ * Property: displaySystemUnits\n+ * {Object} Units for various measurement systems. Values are arrays\n+ * of unit abbreviations (from OpenLayers.INCHES_PER_UNIT) in decreasing\n+ * order of length.\n+ */\n+ displaySystemUnits: {\n+ geographic: ['dd'],\n+ english: ['mi', 'ft', 'in'],\n+ metric: ['km', 'm']\n+ },\n+\n+ /**\n+ * Property: delay\n+ * {Number} Number of milliseconds between clicks before the event is\n+ * considered a double-click. The \"measurepartial\" event will not\n+ * be triggered if the sketch is completed within this time. This\n+ * is required for IE where creating a browser reflow (if a listener\n+ * is modifying the DOM by displaying the measurement values) messes\n+ * with the dblclick listener in the sketch handler.\n+ */\n+ partialDelay: 300,\n+\n+ /**\n+ * Property: delayedTrigger\n+ * {Number} Timeout id of trigger for measurepartial.\n+ */\n+ delayedTrigger: null,\n+\n+ /**\n+ * APIProperty: persist\n+ * {Boolean} Keep the temporary measurement sketch drawn after the\n+ * measurement is complete. The geometry will persist until a new\n+ * measurement is started, the control is deactivated, or is\n+ * called.\n+ */\n+ persist: false,\n+\n+ /**\n+ * APIProperty: immediate\n+ * {Boolean} Activates the immediate measurement so that the \"measurepartial\"\n+ * event is also fired once the measurement sketch is modified.\n+ * Default is false.\n+ */\n+ immediate: false,\n+\n+ /**\n+ * Constructor: OpenLayers.Control.Measure\n *\n * Parameters:\n- * control - {} The control that is making use of\n- * this handler. If a handler is being used without a control, the\n- * handlers setMap method must be overridden to deal properly with\n- * the map.\n- * callbacks - {Object} An object containing functions to be called when\n- * the pinch operation start, change, or is finished. The callbacks\n- * should expect to receive an object argument, which contains\n- * information about scale, distance, and position of touch points.\n+ * handler - {}\n * options - {Object}\n */\n+ initialize: function(handler, options) {\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+ var callbacks = {\n+ done: this.measureComplete,\n+ point: this.measurePartial\n+ };\n+ if (this.immediate) {\n+ callbacks.modify = this.measureImmediate;\n+ }\n+ this.callbacks = OpenLayers.Util.extend(callbacks, this.callbacks);\n+\n+ // let the handler options override, so old code that passes 'persist'\n+ // directly to the handler does not need an update\n+ this.handlerOptions = OpenLayers.Util.extend({\n+ persist: this.persist\n+ }, this.handlerOptions);\n+ this.handler = new handler(this, this.callbacks, this.handlerOptions);\n+ },\n \n /**\n- * Method: touchstart\n- * Handle touchstart events\n+ * APIMethod: deactivate\n+ */\n+ deactivate: function() {\n+ this.cancelDelay();\n+ return OpenLayers.Control.prototype.deactivate.apply(this, arguments);\n+ },\n+\n+ /**\n+ * APIMethod: cancel\n+ * Stop the control from measuring. If is true, the temporary\n+ * sketch will be erased.\n+ */\n+ cancel: function() {\n+ this.cancelDelay();\n+ this.handler.cancel();\n+ },\n+\n+ /**\n+ * APIMethod: setImmediate\n+ * Sets the property. Changes the activity of immediate\n+ * measurement.\n+ */\n+ setImmediate: function(immediate) {\n+ this.immediate = immediate;\n+ if (this.immediate) {\n+ this.callbacks.modify = this.measureImmediate;\n+ } else {\n+ delete this.callbacks.modify;\n+ }\n+ },\n+\n+ /**\n+ * Method: updateHandler\n *\n * Parameters:\n- * evt - {Event}\n+ * handler - {Function} One of the sketch handler constructors.\n+ * options - {Object} Options for the handler.\n+ */\n+ updateHandler: function(handler, options) {\n+ var active = this.active;\n+ if (active) {\n+ this.deactivate();\n+ }\n+ this.handler = new handler(this, this.callbacks, options);\n+ if (active) {\n+ this.activate();\n+ }\n+ },\n+\n+ /**\n+ * Method: measureComplete\n+ * Called when the measurement sketch is done.\n *\n- * Returns:\n- * {Boolean} Let the event propagate.\n+ * Parameters:\n+ * geometry - {}\n */\n- touchstart: function(evt) {\n- var propagate = true;\n- this.pinching = false;\n- if (OpenLayers.Event.isMultiTouch(evt)) {\n- this.started = true;\n- this.last = this.start = {\n- distance: this.getDistance(evt.touches),\n- delta: 0,\n- scale: 1\n- };\n- this.callback(\"start\", [evt, this.start]);\n- propagate = !this.stopDown;\n- } else if (this.started) {\n- // Some webkit versions send fake single-touch events during\n- // multitouch, which cause the drag handler to trigger\n- return false;\n+ measureComplete: function(geometry) {\n+ this.cancelDelay();\n+ this.measure(geometry, \"measure\");\n+ },\n+\n+ /**\n+ * Method: measurePartial\n+ * Called each time a new point is added to the measurement sketch.\n+ *\n+ * Parameters:\n+ * point - {} The last point added.\n+ * geometry - {} The sketch geometry.\n+ */\n+ measurePartial: function(point, geometry) {\n+ this.cancelDelay();\n+ geometry = geometry.clone();\n+ // when we're wating for a dblclick, we have to trigger measurepartial\n+ // after some delay to deal with reflow issues in IE\n+ if (this.handler.freehandMode(this.handler.evt)) {\n+ // no dblclick in freehand mode\n+ this.measure(geometry, \"measurepartial\");\n } else {\n- this.started = false;\n- this.start = null;\n- this.last = null;\n+ this.delayedTrigger = window.setTimeout(\n+ OpenLayers.Function.bind(function() {\n+ this.delayedTrigger = null;\n+ this.measure(geometry, \"measurepartial\");\n+ }, this),\n+ this.partialDelay\n+ );\n }\n- // prevent document dragging\n- OpenLayers.Event.preventDefault(evt);\n- return propagate;\n },\n \n /**\n- * Method: touchmove\n- * Handle touchmove events\n+ * Method: measureImmediate\n+ * Called each time the measurement sketch is modified.\n *\n * Parameters:\n- * evt - {Event}\n+ * point - {} The point at the mouse position.\n+ * feature - {} The sketch feature.\n+ * drawing - {Boolean} Indicates whether we're currently drawing.\n+ */\n+ measureImmediate: function(point, feature, drawing) {\n+ if (drawing && !this.handler.freehandMode(this.handler.evt)) {\n+ this.cancelDelay();\n+ this.measure(feature.geometry, \"measurepartial\");\n+ }\n+ },\n+\n+ /**\n+ * Method: cancelDelay\n+ * Cancels the delay measurement that measurePartial began.\n+ */\n+ cancelDelay: function() {\n+ if (this.delayedTrigger !== null) {\n+ window.clearTimeout(this.delayedTrigger);\n+ this.delayedTrigger = null;\n+ }\n+ },\n+\n+ /**\n+ * Method: measure\n *\n- * Returns:\n- * {Boolean} Let the event propagate.\n+ * Parameters:\n+ * geometry - {}\n+ * eventType - {String}\n */\n- touchmove: function(evt) {\n- if (this.started && OpenLayers.Event.isMultiTouch(evt)) {\n- this.pinching = true;\n- var current = this.getPinchData(evt);\n- this.callback(\"move\", [evt, current]);\n- this.last = current;\n- // prevent document dragging\n- OpenLayers.Event.stop(evt);\n- } else if (this.started) {\n- // Some webkit versions send fake single-touch events during\n- // multitouch, which cause the drag handler to trigger\n- return false;\n+ measure: function(geometry, eventType) {\n+ var stat, order;\n+ if (geometry.CLASS_NAME.indexOf('LineString') > -1) {\n+ stat = this.getBestLength(geometry);\n+ order = 1;\n+ } else {\n+ stat = this.getBestArea(geometry);\n+ order = 2;\n }\n- return true;\n+ this.events.triggerEvent(eventType, {\n+ measure: stat[0],\n+ units: stat[1],\n+ order: order,\n+ geometry: geometry\n+ });\n },\n \n /**\n- * Method: touchend\n- * Handle touchend events\n+ * Method: getBestArea\n+ * Based on the returns the area of a geometry.\n *\n * Parameters:\n- * evt - {Event}\n+ * geometry - {}\n *\n * Returns:\n- * {Boolean} Let the event propagate.\n+ * {Array([Float, String])} Returns a two item array containing the\n+ * area and the units abbreviation.\n */\n- touchend: function(evt) {\n- if (this.started && !OpenLayers.Event.isMultiTouch(evt)) {\n- this.started = false;\n- this.pinching = false;\n- this.callback(\"done\", [evt, this.start, this.last]);\n- this.start = null;\n- this.last = null;\n- return false;\n+ getBestArea: function(geometry) {\n+ var units = this.displaySystemUnits[this.displaySystem];\n+ var unit, area;\n+ for (var i = 0, len = units.length; i < len; ++i) {\n+ unit = units[i];\n+ area = this.getArea(geometry, unit);\n+ if (area > 1) {\n+ break;\n+ }\n }\n- return true;\n+ return [area, unit];\n },\n \n /**\n- * Method: activate\n- * Activate the handler.\n+ * Method: getArea\n+ *\n+ * Parameters:\n+ * geometry - {}\n+ * units - {String} Unit abbreviation\n *\n * Returns:\n- * {Boolean} The handler was successfully activated.\n+ * {Float} The geometry area in the given units.\n */\n- activate: function() {\n- var activated = false;\n- if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n- this.pinching = false;\n- activated = true;\n+ getArea: function(geometry, units) {\n+ var area, geomUnits;\n+ if (this.geodesic) {\n+ area = geometry.getGeodesicArea(this.map.getProjectionObject());\n+ geomUnits = \"m\";\n+ } else {\n+ area = geometry.getArea();\n+ geomUnits = this.map.getUnits();\n }\n- return activated;\n+ var inPerDisplayUnit = OpenLayers.INCHES_PER_UNIT[units];\n+ if (inPerDisplayUnit) {\n+ var inPerMapUnit = OpenLayers.INCHES_PER_UNIT[geomUnits];\n+ area *= Math.pow((inPerMapUnit / inPerDisplayUnit), 2);\n+ }\n+ return area;\n },\n \n /**\n- * Method: deactivate\n- * Deactivate the handler.\n+ * Method: getBestLength\n+ * Based on the returns the length of a geometry.\n+ *\n+ * Parameters:\n+ * geometry - {}\n *\n * Returns:\n- * {Boolean} The handler was successfully deactivated.\n+ * {Array([Float, String])} Returns a two item array containing the\n+ * length and the units abbreviation.\n */\n- deactivate: function() {\n- var deactivated = false;\n- if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- this.started = false;\n- this.pinching = false;\n- this.start = null;\n- this.last = null;\n- deactivated = true;\n+ getBestLength: function(geometry) {\n+ var units = this.displaySystemUnits[this.displaySystem];\n+ var unit, length;\n+ for (var i = 0, len = units.length; i < len; ++i) {\n+ unit = units[i];\n+ length = this.getLength(geometry, unit);\n+ if (length > 1) {\n+ break;\n+ }\n }\n- return deactivated;\n+ return [length, unit];\n },\n \n /**\n- * Method: getDistance\n- * Get the distance in pixels between two touches.\n+ * Method: getLength\n *\n * Parameters:\n- * touches - {Array(Object)}\n+ * geometry - {}\n+ * units - {String} Unit abbreviation\n *\n * Returns:\n- * {Number} The distance in pixels.\n+ * {Float} The geometry length in the given units.\n */\n- getDistance: function(touches) {\n- var t0 = touches[0];\n- var t1 = touches[1];\n- return Math.sqrt(\n- Math.pow(t0.olClientX - t1.olClientX, 2) +\n- Math.pow(t0.olClientY - t1.olClientY, 2)\n- );\n+ getLength: function(geometry, units) {\n+ var length, geomUnits;\n+ if (this.geodesic) {\n+ length = geometry.getGeodesicLength(this.map.getProjectionObject());\n+ geomUnits = \"m\";\n+ } else {\n+ length = geometry.getLength();\n+ geomUnits = this.map.getUnits();\n+ }\n+ var inPerDisplayUnit = OpenLayers.INCHES_PER_UNIT[units];\n+ if (inPerDisplayUnit) {\n+ var inPerMapUnit = OpenLayers.INCHES_PER_UNIT[geomUnits];\n+ length *= (inPerMapUnit / inPerDisplayUnit);\n+ }\n+ return length;\n },\n \n+ CLASS_NAME: \"OpenLayers.Control.Measure\"\n+});\n+/* ======================================================================\n+ OpenLayers/Control/Pan.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Control/Button.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Control.Pan\n+ * The Pan control is a single button to pan the map in one direction. For\n+ * a more complete control see .\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control.Button, {\n+\n+ /** \n+ * APIProperty: slideFactor\n+ * {Integer} Number of pixels by which we'll pan the map in any direction \n+ * on clicking the arrow buttons, defaults to 50. If you want to pan\n+ * by some ratio of the map dimensions, use instead.\n+ */\n+ slideFactor: 50,\n+\n+ /** \n+ * APIProperty: slideRatio\n+ * {Number} The fraction of map width/height by which we'll pan the map \n+ * on clicking the arrow buttons. Default is null. If set, will\n+ * override . E.g. if slideRatio is .5, then Pan Up will\n+ * pan up half the map height. \n+ */\n+ slideRatio: null,\n+\n+ /** \n+ * Property: direction\n+ * {String} in {'North', 'South', 'East', 'West'}\n+ */\n+ direction: null,\n \n /**\n- * Method: getPinchData\n- * Get informations about the pinch event.\n+ * Constructor: OpenLayers.Control.Pan \n+ * Control which handles the panning (in any of the cardinal directions)\n+ * of the map by a set px distance. \n *\n * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Object} Object that contains data about the current pinch.\n+ * direction - {String} The direction this button should pan.\n+ * options - {Object} An optional object whose properties will be used\n+ * to extend the control.\n */\n- getPinchData: function(evt) {\n- var distance = this.getDistance(evt.touches);\n- var scale = distance / this.start.distance;\n- return {\n- distance: distance,\n- delta: this.last.distance - distance,\n- scale: scale\n- };\n+ initialize: function(direction, options) {\n+\n+ this.direction = direction;\n+ this.CLASS_NAME += this.direction;\n+\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.Pinch\"\n+ /**\n+ * Method: trigger\n+ */\n+ trigger: function() {\n+ if (this.map) {\n+ var getSlideFactor = OpenLayers.Function.bind(function(dim) {\n+ return this.slideRatio ?\n+ this.map.getSize()[dim] * this.slideRatio :\n+ this.slideFactor;\n+ }, this);\n+\n+ switch (this.direction) {\n+ case OpenLayers.Control.Pan.NORTH:\n+ this.map.pan(0, -getSlideFactor(\"h\"));\n+ break;\n+ case OpenLayers.Control.Pan.SOUTH:\n+ this.map.pan(0, getSlideFactor(\"h\"));\n+ break;\n+ case OpenLayers.Control.Pan.WEST:\n+ this.map.pan(-getSlideFactor(\"w\"), 0);\n+ break;\n+ case OpenLayers.Control.Pan.EAST:\n+ this.map.pan(getSlideFactor(\"w\"), 0);\n+ break;\n+ }\n+ }\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Control.Pan\"\n });\n \n+OpenLayers.Control.Pan.NORTH = \"North\";\n+OpenLayers.Control.Pan.SOUTH = \"South\";\n+OpenLayers.Control.Pan.EAST = \"East\";\n+OpenLayers.Control.Pan.WEST = \"West\";\n /* ======================================================================\n- OpenLayers/Control/PinchZoom.js\n+ OpenLayers/Control/ModifyFeature.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Handler/Pinch.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Handler/Drag.js\n+ * @requires OpenLayers/Handler/Keyboard.js\n */\n \n /**\n- * Class: OpenLayers.Control.PinchZoom\n+ * Class: OpenLayers.Control.ModifyFeature\n+ * Control to modify features. When activated, a click renders the vertices\n+ * of a feature - these vertices can then be dragged. By default, the\n+ * delete key will delete the vertex under the mouse. New features are\n+ * added by dragging \"virtual vertices\" between vertices. Create a new\n+ * control with the constructor.\n *\n- * Inherits:\n+ * Inherits From:\n * - \n */\n-OpenLayers.Control.PinchZoom = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {\n \n- /** \n- * Property: type\n- * {OpenLayers.Control.TYPES}\n+ /**\n+ * APIProperty: documentDrag\n+ * {Boolean} If set to true, dragging vertices will continue even if the\n+ * mouse cursor leaves the map viewport. Default is false.\n */\n- type: OpenLayers.Control.TYPE_TOOL,\n+ documentDrag: false,\n \n /**\n- * Property: pinchOrigin\n- * {Object} Cached object representing the pinch start (in pixels).\n+ * APIProperty: geometryTypes\n+ * {Array(String)} To restrict modification to a limited set of geometry\n+ * types, send a list of strings corresponding to the geometry class\n+ * names.\n */\n- pinchOrigin: null,\n+ geometryTypes: null,\n \n /**\n- * Property: currentCenter\n- * {Object} Cached object representing the latest pinch center (in pixels).\n+ * APIProperty: clickout\n+ * {Boolean} Unselect features when clicking outside any feature.\n+ * Default is true.\n */\n- currentCenter: null,\n+ clickout: true,\n \n /**\n- * APIProperty: autoActivate\n- * {Boolean} Activate the control when it is added to a map. Default is\n- * true.\n+ * APIProperty: toggle\n+ * {Boolean} Unselect a selected feature on click.\n+ * Default is true.\n */\n- autoActivate: true,\n+ toggle: true,\n \n /**\n- * APIProperty: preserveCenter\n- * {Boolean} Set this to true if you don't want the map center to change\n- * while pinching. For example you may want to set preserveCenter to\n- * true when the user location is being watched and you want to preserve\n- * the user location at the center of the map even if he zooms in or\n- * out using pinch. This property's value can be changed any time on an\n- * existing instance. Default is false.\n+ * APIProperty: standalone\n+ * {Boolean} Set to true to create a control without SelectFeature\n+ * capabilities. Default is false. If standalone is true, to modify\n+ * a feature, call the method with the target feature.\n+ * Note that you must call the method to finish\n+ * feature modification in standalone mode (before starting to modify\n+ * another feature).\n */\n- preserveCenter: false,\n+ standalone: false,\n \n /**\n- * APIProperty: handlerOptions\n- * {Object} Used to set non-default properties on the pinch handler\n+ * Property: layer\n+ * {}\n */\n+ layer: null,\n \n /**\n- * Constructor: OpenLayers.Control.PinchZoom\n- * Create a control for zooming with pinch gestures. This works on devices\n- * with multi-touch support.\n- *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * the control\n+ * Property: feature\n+ * {} Feature currently available for modification.\n */\n- initialize: function(options) {\n- OpenLayers.Control.prototype.initialize.apply(this, arguments);\n- this.handler = new OpenLayers.Handler.Pinch(this, {\n- start: this.pinchStart,\n- move: this.pinchMove,\n- done: this.pinchDone\n- }, this.handlerOptions);\n- },\n+ feature: null,\n \n /**\n- * Method: pinchStart\n- *\n- * Parameters:\n- * evt - {Event}\n- * pinchData - {Object} pinch data object related to the current touchmove\n- * of the pinch gesture. This give us the current scale of the pinch.\n+ * Property: vertex\n+ * {} Vertex currently being modified.\n */\n- pinchStart: function(evt, pinchData) {\n- var xy = (this.preserveCenter) ?\n- this.map.getPixelFromLonLat(this.map.getCenter()) : evt.xy;\n- this.pinchOrigin = xy;\n- this.currentCenter = xy;\n- },\n+ vertex: null,\n \n /**\n- * Method: pinchMove\n- *\n- * Parameters:\n- * evt - {Event}\n- * pinchData - {Object} pinch data object related to the current touchmove\n- * of the pinch gesture. This give us the current scale of the pinch.\n+ * Property: vertices\n+ * {Array()} Verticies currently available\n+ * for dragging.\n */\n- pinchMove: function(evt, pinchData) {\n- var scale = pinchData.scale;\n- var containerOrigin = this.map.layerContainerOriginPx;\n- var pinchOrigin = this.pinchOrigin;\n- var current = (this.preserveCenter) ?\n- this.map.getPixelFromLonLat(this.map.getCenter()) : evt.xy;\n+ vertices: null,\n \n- var dx = Math.round((containerOrigin.x + current.x - pinchOrigin.x) + (scale - 1) * (containerOrigin.x - pinchOrigin.x));\n- var dy = Math.round((containerOrigin.y + current.y - pinchOrigin.y) + (scale - 1) * (containerOrigin.y - pinchOrigin.y));\n+ /**\n+ * Property: virtualVertices\n+ * {Array()} Virtual vertices in the middle\n+ * of each edge.\n+ */\n+ virtualVertices: null,\n \n- this.map.applyTransform(dx, dy, scale);\n- this.currentCenter = current;\n- },\n+ /**\n+ * Property: handlers\n+ * {Object}\n+ */\n+ handlers: null,\n \n /**\n- * Method: pinchDone\n- *\n- * Parameters:\n- * evt - {Event}\n- * start - {Object} pinch data object related to the touchstart event that\n- * started the pinch gesture.\n- * last - {Object} pinch data object related to the last touchmove event\n- * of the pinch gesture. This give us the final scale of the pinch.\n+ * APIProperty: deleteCodes\n+ * {Array(Integer)} Keycodes for deleting verticies. Set to null to disable\n+ * vertex deltion by keypress. If non-null, keypresses with codes\n+ * in this array will delete vertices under the mouse. Default\n+ * is 46 and 68, the 'delete' and lowercase 'd' keys.\n */\n- pinchDone: function(evt, start, last) {\n- this.map.applyTransform();\n- var zoom = this.map.getZoomForResolution(this.map.getResolution() / last.scale, true);\n- if (zoom !== this.map.getZoom() || !this.currentCenter.equals(this.pinchOrigin)) {\n- var resolution = this.map.getResolutionForZoom(zoom);\n+ deleteCodes: null,\n \n- var location = this.map.getLonLatFromPixel(this.pinchOrigin);\n- var zoomPixel = this.currentCenter;\n- var size = this.map.getSize();\n+ /**\n+ * APIProperty: virtualStyle\n+ * {Object} A symbolizer to be used for virtual vertices.\n+ */\n+ virtualStyle: null,\n \n- location.lon += resolution * ((size.w / 2) - zoomPixel.x);\n- location.lat -= resolution * ((size.h / 2) - zoomPixel.y);\n+ /**\n+ * APIProperty: vertexRenderIntent\n+ * {String} The renderIntent to use for vertices. If no is\n+ * provided, this renderIntent will also be used for virtual vertices, with\n+ * a fillOpacity and strokeOpacity of 0.3. Default is null, which means\n+ * that the layer's default style will be used for vertices.\n+ */\n+ vertexRenderIntent: null,\n \n- // Force a reflow before calling setCenter. This is to work\n- // around an issue occuring in iOS.\n- //\n- // See https://github.com/openlayers/openlayers/pull/351.\n- //\n- // Without a reflow setting the layer container div's top left\n- // style properties to \"0px\" - as done in Map.moveTo when zoom\n- // is changed - won't actually correctly reposition the layer\n- // container div.\n- //\n- // Also, we need to use a statement that the Google Closure\n- // compiler won't optimize away.\n- this.map.div.clientWidth = this.map.div.clientWidth;\n+ /**\n+ * APIProperty: mode\n+ * {Integer} Bitfields specifying the modification mode. Defaults to\n+ * OpenLayers.Control.ModifyFeature.RESHAPE. To set the mode to a\n+ * combination of options, use the | operator. For example, to allow\n+ * the control to both resize and rotate features, use the following\n+ * syntax\n+ * (code)\n+ * control.mode = OpenLayers.Control.ModifyFeature.RESIZE |\n+ * OpenLayers.Control.ModifyFeature.ROTATE;\n+ * (end)\n+ */\n+ mode: null,\n \n- this.map.setCenter(location, zoom);\n- }\n- },\n+ /**\n+ * APIProperty: createVertices\n+ * {Boolean} Create new vertices by dragging the virtual vertices\n+ * in the middle of each edge. Default is true.\n+ */\n+ createVertices: true,\n \n- CLASS_NAME: \"OpenLayers.Control.PinchZoom\"\n+ /**\n+ * Property: modified\n+ * {Boolean} The currently selected feature has been modified.\n+ */\n+ modified: false,\n \n-});\n-/* ======================================================================\n- OpenLayers/Control/ZoomIn.js\n- ====================================================================== */\n+ /**\n+ * Property: radiusHandle\n+ * {} A handle for rotating/resizing a feature.\n+ */\n+ radiusHandle: null,\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ /**\n+ * Property: dragHandle\n+ * {} A handle for dragging a feature.\n+ */\n+ dragHandle: null,\n \n-/**\n- * @requires OpenLayers/Control/Button.js\n- */\n+ /**\n+ * APIProperty: onModificationStart \n+ * {Function} *Deprecated*. Register for \"beforefeaturemodified\" instead.\n+ * The \"beforefeaturemodified\" event is triggered on the layer before\n+ * any modification begins.\n+ *\n+ * Optional function to be called when a feature is selected\n+ * to be modified. The function should expect to be called with a\n+ * feature. This could be used for example to allow to lock the\n+ * feature on server-side.\n+ */\n+ onModificationStart: function() {},\n \n-/**\n- * Class: OpenLayers.Control.ZoomIn\n- * The ZoomIn control is a button to increase the zoom level of a map.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.ZoomIn = OpenLayers.Class(OpenLayers.Control.Button, {\n+ /**\n+ * APIProperty: onModification\n+ * {Function} *Deprecated*. Register for \"featuremodified\" instead.\n+ * The \"featuremodified\" event is triggered on the layer with each\n+ * feature modification.\n+ *\n+ * Optional function to be called when a feature has been\n+ * modified. The function should expect to be called with a feature.\n+ */\n+ onModification: function() {},\n \n /**\n- * Method: trigger\n+ * APIProperty: onModificationEnd\n+ * {Function} *Deprecated*. Register for \"afterfeaturemodified\" instead.\n+ * The \"afterfeaturemodified\" event is triggered on the layer after\n+ * a feature has been modified.\n+ *\n+ * Optional function to be called when a feature is finished \n+ * being modified. The function should expect to be called with a\n+ * feature.\n */\n- trigger: function() {\n- if (this.map) {\n- this.map.zoomIn();\n- }\n- },\n+ onModificationEnd: function() {},\n \n- CLASS_NAME: \"OpenLayers.Control.ZoomIn\"\n-});\n-/* ======================================================================\n- OpenLayers/Control/DragPan.js\n- ====================================================================== */\n+ /**\n+ * Constructor: OpenLayers.Control.ModifyFeature\n+ * Create a new modify feature control.\n+ *\n+ * Parameters:\n+ * layer - {} Layer that contains features that\n+ * will be modified.\n+ * options - {Object} Optional object whose properties will be set on the\n+ * control.\n+ */\n+ initialize: function(layer, options) {\n+ options = options || {};\n+ this.layer = layer;\n+ this.vertices = [];\n+ this.virtualVertices = [];\n+ this.virtualStyle = OpenLayers.Util.extend({},\n+ this.layer.style ||\n+ this.layer.styleMap.createSymbolizer(null, options.vertexRenderIntent)\n+ );\n+ this.virtualStyle.fillOpacity = 0.3;\n+ this.virtualStyle.strokeOpacity = 0.3;\n+ this.deleteCodes = [46, 68];\n+ this.mode = OpenLayers.Control.ModifyFeature.RESHAPE;\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+ if (!(OpenLayers.Util.isArray(this.deleteCodes))) {\n+ this.deleteCodes = [this.deleteCodes];\n+ }\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ // configure the drag handler\n+ var dragCallbacks = {\n+ down: function(pixel) {\n+ this.vertex = null;\n+ var feature = this.layer.getFeatureFromEvent(\n+ this.handlers.drag.evt);\n+ if (feature) {\n+ this.dragStart(feature);\n+ } else if (this.clickout) {\n+ this._unselect = this.feature;\n+ }\n+ },\n+ move: function(pixel) {\n+ delete this._unselect;\n+ if (this.vertex) {\n+ this.dragVertex(this.vertex, pixel);\n+ }\n+ },\n+ up: function() {\n+ this.handlers.drag.stopDown = false;\n+ if (this._unselect) {\n+ this.unselectFeature(this._unselect);\n+ delete this._unselect;\n+ }\n+ },\n+ done: function(pixel) {\n+ if (this.vertex) {\n+ this.dragComplete(this.vertex);\n+ }\n+ }\n+ };\n+ var dragOptions = {\n+ documentDrag: this.documentDrag,\n+ stopDown: false\n+ };\n \n-/**\n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Handler/Drag.js\n- */\n+ // configure the keyboard handler\n+ var keyboardOptions = {\n+ keydown: this.handleKeypress\n+ };\n+ this.handlers = {\n+ keyboard: new OpenLayers.Handler.Keyboard(this, keyboardOptions),\n+ drag: new OpenLayers.Handler.Drag(this, dragCallbacks, dragOptions)\n+ };\n+ },\n \n-/**\n- * Class: OpenLayers.Control.DragPan\n- * The DragPan control pans the map with a drag of the mouse.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {\n+ /**\n+ * APIMethod: destroy\n+ * Take care of things that are not handled in superclass.\n+ */\n+ destroy: function() {\n+ if (this.map) {\n+ this.map.events.un({\n+ \"removelayer\": this.handleMapEvents,\n+ \"changelayer\": this.handleMapEvents,\n+ scope: this\n+ });\n+ }\n+ this.layer = null;\n+ OpenLayers.Control.prototype.destroy.apply(this, []);\n+ },\n \n- /** \n- * Property: type\n- * {OpenLayers.Control.TYPES}\n+ /**\n+ * APIMethod: activate\n+ * Activate the control.\n+ * \n+ * Returns:\n+ * {Boolean} Successfully activated the control.\n */\n- type: OpenLayers.Control.TYPE_TOOL,\n+ activate: function() {\n+ this.moveLayerToTop();\n+ this.map.events.on({\n+ \"removelayer\": this.handleMapEvents,\n+ \"changelayer\": this.handleMapEvents,\n+ scope: this\n+ });\n+ return (this.handlers.keyboard.activate() &&\n+ this.handlers.drag.activate() &&\n+ OpenLayers.Control.prototype.activate.apply(this, arguments));\n+ },\n \n /**\n- * Property: panned\n- * {Boolean} The map moved.\n+ * APIMethod: deactivate\n+ * Deactivate the control.\n+ *\n+ * Returns: \n+ * {Boolean} Successfully deactivated the control.\n */\n- panned: false,\n+ deactivate: function() {\n+ var deactivated = false;\n+ // the return from the controls is unimportant in this case\n+ if (OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {\n+ this.moveLayerBack();\n+ this.map.events.un({\n+ \"removelayer\": this.handleMapEvents,\n+ \"changelayer\": this.handleMapEvents,\n+ scope: this\n+ });\n+ this.layer.removeFeatures(this.vertices, {\n+ silent: true\n+ });\n+ this.layer.removeFeatures(this.virtualVertices, {\n+ silent: true\n+ });\n+ this.vertices = [];\n+ this.handlers.drag.deactivate();\n+ this.handlers.keyboard.deactivate();\n+ var feature = this.feature;\n+ if (feature && feature.geometry && feature.layer) {\n+ this.unselectFeature(feature);\n+ }\n+ deactivated = true;\n+ }\n+ return deactivated;\n+ },\n \n /**\n- * Property: interval\n- * {Integer} The number of milliseconds that should ellapse before\n- * panning the map again. Defaults to 0 milliseconds, which means that\n- * no separate cycle is used for panning. In most cases you won't want\n- * to change this value. For slow machines/devices larger values can be\n- * tried out.\n+ * Method: beforeSelectFeature\n+ * Called before a feature is selected.\n+ *\n+ * Parameters:\n+ * feature - {} The feature about to be selected.\n */\n- interval: 0,\n+ beforeSelectFeature: function(feature) {\n+ return this.layer.events.triggerEvent(\n+ \"beforefeaturemodified\", {\n+ feature: feature\n+ }\n+ );\n+ },\n \n /**\n- * APIProperty: documentDrag\n- * {Boolean} If set to true, mouse dragging will continue even if the\n- * mouse cursor leaves the map viewport. Default is false.\n+ * APIMethod: selectFeature\n+ * Select a feature for modification in standalone mode. In non-standalone\n+ * mode, this method is called when a feature is selected by clicking.\n+ * Register a listener to the beforefeaturemodified event and return false\n+ * to prevent feature modification.\n+ *\n+ * Parameters:\n+ * feature - {} the selected feature.\n */\n- documentDrag: false,\n+ selectFeature: function(feature) {\n+ if (this.feature === feature ||\n+ (this.geometryTypes && OpenLayers.Util.indexOf(this.geometryTypes,\n+ feature.geometry.CLASS_NAME) == -1)) {\n+ return;\n+ }\n+ if (this.beforeSelectFeature(feature) !== false) {\n+ if (this.feature) {\n+ this.unselectFeature(this.feature);\n+ }\n+ this.feature = feature;\n+ this.layer.selectedFeatures.push(feature);\n+ this.layer.drawFeature(feature, 'select');\n+ this.modified = false;\n+ this.resetVertices();\n+ this.onModificationStart(this.feature);\n+ }\n+ // keep track of geometry modifications\n+ var modified = feature.modified;\n+ if (feature.geometry && !(modified && modified.geometry)) {\n+ this._originalGeometry = feature.geometry.clone();\n+ }\n+ },\n \n /**\n- * Property: kinetic\n- * {} The OpenLayers.Kinetic object.\n+ * APIMethod: unselectFeature\n+ * Called when the select feature control unselects a feature.\n+ *\n+ * Parameters:\n+ * feature - {} The unselected feature.\n */\n- kinetic: null,\n+ unselectFeature: function(feature) {\n+ this.layer.removeFeatures(this.vertices, {\n+ silent: true\n+ });\n+ this.vertices = [];\n+ this.layer.destroyFeatures(this.virtualVertices, {\n+ silent: true\n+ });\n+ this.virtualVertices = [];\n+ if (this.dragHandle) {\n+ this.layer.destroyFeatures([this.dragHandle], {\n+ silent: true\n+ });\n+ delete this.dragHandle;\n+ }\n+ if (this.radiusHandle) {\n+ this.layer.destroyFeatures([this.radiusHandle], {\n+ silent: true\n+ });\n+ delete this.radiusHandle;\n+ }\n+ this.layer.drawFeature(this.feature, 'default');\n+ this.feature = null;\n+ OpenLayers.Util.removeItem(this.layer.selectedFeatures, feature);\n+ this.onModificationEnd(feature);\n+ this.layer.events.triggerEvent(\"afterfeaturemodified\", {\n+ feature: feature,\n+ modified: this.modified\n+ });\n+ this.modified = false;\n+ },\n+\n \n /**\n- * APIProperty: enableKinetic\n- * {Boolean} Set this option to enable \"kinetic dragging\". Can be\n- * set to true or to an object. If set to an object this\n- * object will be passed to the {}\n- * constructor. Defaults to true.\n- * To get kinetic dragging, ensure that OpenLayers/Kinetic.js is\n- * included in your build config.\n+ * Method: dragStart\n+ * Called by the drag handler before a feature is dragged. This method is\n+ * used to differentiate between points and vertices\n+ * of higher order geometries.\n+ *\n+ * Parameters:\n+ * feature - {} The point or vertex about to be\n+ * dragged.\n */\n- enableKinetic: true,\n+ dragStart: function(feature) {\n+ var isPoint = feature.geometry.CLASS_NAME ==\n+ 'OpenLayers.Geometry.Point';\n+ if (!this.standalone &&\n+ ((!feature._sketch && isPoint) || !feature._sketch)) {\n+ if (this.toggle && this.feature === feature) {\n+ // mark feature for unselection\n+ this._unselect = feature;\n+ }\n+ this.selectFeature(feature);\n+ }\n+ if (feature._sketch || isPoint) {\n+ // feature is a drag or virtual handle or point\n+ this.vertex = feature;\n+ this.handlers.drag.stopDown = true;\n+ }\n+ },\n \n /**\n- * APIProperty: kineticInterval\n- * {Integer} Interval in milliseconds between 2 steps in the \"kinetic\n- * scrolling\". Applies only if enableKinetic is set. Defaults\n- * to 10 milliseconds.\n+ * Method: dragVertex\n+ * Called by the drag handler with each drag move of a vertex.\n+ *\n+ * Parameters:\n+ * vertex - {} The vertex being dragged.\n+ * pixel - {} Pixel location of the mouse event.\n */\n- kineticInterval: 10,\n+ dragVertex: function(vertex, pixel) {\n+ var pos = this.map.getLonLatFromViewPortPx(pixel);\n+ var geom = vertex.geometry;\n+ geom.move(pos.lon - geom.x, pos.lat - geom.y);\n+ this.modified = true;\n+ /**\n+ * Five cases:\n+ * 1) dragging a simple point\n+ * 2) dragging a virtual vertex\n+ * 3) dragging a drag handle\n+ * 4) dragging a real vertex\n+ * 5) dragging a radius handle\n+ */\n+ if (this.feature.geometry.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n+ // dragging a simple point\n+ this.layer.events.triggerEvent(\"vertexmodified\", {\n+ vertex: vertex.geometry,\n+ feature: this.feature,\n+ pixel: pixel\n+ });\n+ } else {\n+ if (vertex._index) {\n+ // dragging a virtual vertex\n+ vertex.geometry.parent.addComponent(vertex.geometry,\n+ vertex._index);\n+ // move from virtual to real vertex\n+ delete vertex._index;\n+ OpenLayers.Util.removeItem(this.virtualVertices, vertex);\n+ this.vertices.push(vertex);\n+ } else if (vertex == this.dragHandle) {\n+ // dragging a drag handle\n+ this.layer.removeFeatures(this.vertices, {\n+ silent: true\n+ });\n+ this.vertices = [];\n+ if (this.radiusHandle) {\n+ this.layer.destroyFeatures([this.radiusHandle], {\n+ silent: true\n+ });\n+ this.radiusHandle = null;\n+ }\n+ } else if (vertex !== this.radiusHandle) {\n+ // dragging a real vertex\n+ this.layer.events.triggerEvent(\"vertexmodified\", {\n+ vertex: vertex.geometry,\n+ feature: this.feature,\n+ pixel: pixel\n+ });\n+ }\n+ // dragging a radius handle - no special treatment\n+ if (this.virtualVertices.length > 0) {\n+ this.layer.destroyFeatures(this.virtualVertices, {\n+ silent: true\n+ });\n+ this.virtualVertices = [];\n+ }\n+ this.layer.drawFeature(this.feature, this.standalone ? undefined :\n+ 'select');\n+ }\n+ // keep the vertex on top so it gets the mouseout after dragging\n+ // this should be removed in favor of an option to draw under or\n+ // maintain node z-index\n+ this.layer.drawFeature(vertex);\n+ },\n \n+ /**\n+ * Method: dragComplete\n+ * Called by the drag handler when the feature dragging is complete.\n+ *\n+ * Parameters:\n+ * vertex - {} The vertex being dragged.\n+ */\n+ dragComplete: function(vertex) {\n+ this.resetVertices();\n+ this.setFeatureState();\n+ this.onModification(this.feature);\n+ this.layer.events.triggerEvent(\"featuremodified\", {\n+ feature: this.feature\n+ });\n+ },\n \n /**\n- * Method: draw\n- * Creates a Drag handler, using and\n- * as callbacks.\n+ * Method: setFeatureState\n+ * Called when the feature is modified. If the current state is not\n+ * INSERT or DELETE, the state is set to UPDATE.\n */\n- draw: function() {\n- if (this.enableKinetic && OpenLayers.Kinetic) {\n- var config = {\n- interval: this.kineticInterval\n- };\n- if (typeof this.enableKinetic === \"object\") {\n- config = OpenLayers.Util.extend(config, this.enableKinetic);\n+ setFeatureState: function() {\n+ if (this.feature.state != OpenLayers.State.INSERT &&\n+ this.feature.state != OpenLayers.State.DELETE) {\n+ this.feature.state = OpenLayers.State.UPDATE;\n+ if (this.modified && this._originalGeometry) {\n+ var feature = this.feature;\n+ feature.modified = OpenLayers.Util.extend(feature.modified, {\n+ geometry: this._originalGeometry\n+ });\n+ delete this._originalGeometry;\n }\n- this.kinetic = new OpenLayers.Kinetic(config);\n }\n- this.handler = new OpenLayers.Handler.Drag(this, {\n- \"move\": this.panMap,\n- \"done\": this.panMapDone,\n- \"down\": this.panMapStart\n- }, {\n- interval: this.interval,\n- documentDrag: this.documentDrag\n- });\n },\n \n /**\n- * Method: panMapStart\n+ * Method: resetVertices\n */\n- panMapStart: function() {\n- if (this.kinetic) {\n- this.kinetic.begin();\n+ resetVertices: function() {\n+ if (this.vertices.length > 0) {\n+ this.layer.removeFeatures(this.vertices, {\n+ silent: true\n+ });\n+ this.vertices = [];\n+ }\n+ if (this.virtualVertices.length > 0) {\n+ this.layer.removeFeatures(this.virtualVertices, {\n+ silent: true\n+ });\n+ this.virtualVertices = [];\n+ }\n+ if (this.dragHandle) {\n+ this.layer.destroyFeatures([this.dragHandle], {\n+ silent: true\n+ });\n+ this.dragHandle = null;\n+ }\n+ if (this.radiusHandle) {\n+ this.layer.destroyFeatures([this.radiusHandle], {\n+ silent: true\n+ });\n+ this.radiusHandle = null;\n+ }\n+ if (this.feature &&\n+ this.feature.geometry.CLASS_NAME != \"OpenLayers.Geometry.Point\") {\n+ if ((this.mode & OpenLayers.Control.ModifyFeature.DRAG)) {\n+ this.collectDragHandle();\n+ }\n+ if ((this.mode & (OpenLayers.Control.ModifyFeature.ROTATE |\n+ OpenLayers.Control.ModifyFeature.RESIZE))) {\n+ this.collectRadiusHandle();\n+ }\n+ if (this.mode & OpenLayers.Control.ModifyFeature.RESHAPE) {\n+ // Don't collect vertices when we're resizing\n+ if (!(this.mode & OpenLayers.Control.ModifyFeature.RESIZE)) {\n+ this.collectVertices();\n+ }\n+ }\n }\n },\n \n /**\n- * Method: panMap\n+ * Method: handleKeypress\n+ * Called by the feature handler on keypress. This is used to delete\n+ * vertices. If the property is set, vertices will\n+ * be deleted when a feature is selected for modification and\n+ * the mouse is over a vertex.\n *\n * Parameters:\n- * xy - {} Pixel of the mouse position\n+ * evt - {Event} Keypress event.\n */\n- panMap: function(xy) {\n- if (this.kinetic) {\n- this.kinetic.update(xy);\n+ handleKeypress: function(evt) {\n+ var code = evt.keyCode;\n+\n+ // check for delete key\n+ if (this.feature &&\n+ OpenLayers.Util.indexOf(this.deleteCodes, code) != -1) {\n+ var vertex = this.layer.getFeatureFromEvent(this.handlers.drag.evt);\n+ if (vertex &&\n+ OpenLayers.Util.indexOf(this.vertices, vertex) != -1 &&\n+ !this.handlers.drag.dragging && vertex.geometry.parent) {\n+ // remove the vertex\n+ vertex.geometry.parent.removeComponent(vertex.geometry);\n+ this.layer.events.triggerEvent(\"vertexremoved\", {\n+ vertex: vertex.geometry,\n+ feature: this.feature,\n+ pixel: evt.xy\n+ });\n+ this.layer.drawFeature(this.feature, this.standalone ?\n+ undefined : 'select');\n+ this.modified = true;\n+ this.resetVertices();\n+ this.setFeatureState();\n+ this.onModification(this.feature);\n+ this.layer.events.triggerEvent(\"featuremodified\", {\n+ feature: this.feature\n+ });\n+ }\n }\n- this.panned = true;\n- this.map.pan(\n- this.handler.last.x - xy.x,\n- this.handler.last.y - xy.y, {\n- dragging: true,\n- animate: false\n+ },\n+\n+ /**\n+ * Method: collectVertices\n+ * Collect the vertices from the modifiable feature's geometry and push\n+ * them on to the control's vertices array.\n+ */\n+ collectVertices: function() {\n+ this.vertices = [];\n+ this.virtualVertices = [];\n+ var control = this;\n+\n+ function collectComponentVertices(geometry) {\n+ var i, vertex, component, len;\n+ if (geometry.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n+ vertex = new OpenLayers.Feature.Vector(geometry);\n+ vertex._sketch = true;\n+ vertex.renderIntent = control.vertexRenderIntent;\n+ control.vertices.push(vertex);\n+ } else {\n+ var numVert = geometry.components.length;\n+ if (geometry.CLASS_NAME == \"OpenLayers.Geometry.LinearRing\") {\n+ numVert -= 1;\n+ }\n+ for (i = 0; i < numVert; ++i) {\n+ component = geometry.components[i];\n+ if (component.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n+ vertex = new OpenLayers.Feature.Vector(component);\n+ vertex._sketch = true;\n+ vertex.renderIntent = control.vertexRenderIntent;\n+ control.vertices.push(vertex);\n+ } else {\n+ collectComponentVertices(component);\n+ }\n+ }\n+\n+ // add virtual vertices in the middle of each edge\n+ if (control.createVertices && geometry.CLASS_NAME != \"OpenLayers.Geometry.MultiPoint\") {\n+ for (i = 0, len = geometry.components.length; i < len - 1; ++i) {\n+ var prevVertex = geometry.components[i];\n+ var nextVertex = geometry.components[i + 1];\n+ if (prevVertex.CLASS_NAME == \"OpenLayers.Geometry.Point\" &&\n+ nextVertex.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n+ var x = (prevVertex.x + nextVertex.x) / 2;\n+ var y = (prevVertex.y + nextVertex.y) / 2;\n+ var point = new OpenLayers.Feature.Vector(\n+ new OpenLayers.Geometry.Point(x, y),\n+ null, control.virtualStyle\n+ );\n+ // set the virtual parent and intended index\n+ point.geometry.parent = geometry;\n+ point._index = i + 1;\n+ point._sketch = true;\n+ control.virtualVertices.push(point);\n+ }\n+ }\n+ }\n }\n+ }\n+ collectComponentVertices.call(this, this.feature.geometry);\n+ this.layer.addFeatures(this.virtualVertices, {\n+ silent: true\n+ });\n+ this.layer.addFeatures(this.vertices, {\n+ silent: true\n+ });\n+ },\n+\n+ /**\n+ * Method: collectDragHandle\n+ * Collect the drag handle for the selected geometry.\n+ */\n+ collectDragHandle: function() {\n+ var geometry = this.feature.geometry;\n+ var center = geometry.getBounds().getCenterLonLat();\n+ var originGeometry = new OpenLayers.Geometry.Point(\n+ center.lon, center.lat\n );\n+ var origin = new OpenLayers.Feature.Vector(originGeometry);\n+ originGeometry.move = function(x, y) {\n+ OpenLayers.Geometry.Point.prototype.move.call(this, x, y);\n+ geometry.move(x, y);\n+ };\n+ origin._sketch = true;\n+ this.dragHandle = origin;\n+ this.dragHandle.renderIntent = this.vertexRenderIntent;\n+ this.layer.addFeatures([this.dragHandle], {\n+ silent: true\n+ });\n },\n \n /**\n- * Method: panMapDone\n- * Finish the panning operation. Only call setCenter (through )\n- * if the map has actually been moved.\n- *\n- * Parameters:\n- * xy - {} Pixel of the mouse position\n+ * Method: collectRadiusHandle\n+ * Collect the radius handle for the selected geometry.\n */\n- panMapDone: function(xy) {\n- if (this.panned) {\n- var res = null;\n- if (this.kinetic) {\n- res = this.kinetic.end(xy);\n+ collectRadiusHandle: function() {\n+ var geometry = this.feature.geometry;\n+ var bounds = geometry.getBounds();\n+ var center = bounds.getCenterLonLat();\n+ var originGeometry = new OpenLayers.Geometry.Point(\n+ center.lon, center.lat\n+ );\n+ var radiusGeometry = new OpenLayers.Geometry.Point(\n+ bounds.right, bounds.bottom\n+ );\n+ var radius = new OpenLayers.Feature.Vector(radiusGeometry);\n+ var resize = (this.mode & OpenLayers.Control.ModifyFeature.RESIZE);\n+ var reshape = (this.mode & OpenLayers.Control.ModifyFeature.RESHAPE);\n+ var rotate = (this.mode & OpenLayers.Control.ModifyFeature.ROTATE);\n+\n+ radiusGeometry.move = function(x, y) {\n+ OpenLayers.Geometry.Point.prototype.move.call(this, x, y);\n+ var dx1 = this.x - originGeometry.x;\n+ var dy1 = this.y - originGeometry.y;\n+ var dx0 = dx1 - x;\n+ var dy0 = dy1 - y;\n+ if (rotate) {\n+ var a0 = Math.atan2(dy0, dx0);\n+ var a1 = Math.atan2(dy1, dx1);\n+ var angle = a1 - a0;\n+ angle *= 180 / Math.PI;\n+ geometry.rotate(angle, originGeometry);\n }\n- this.map.pan(\n- this.handler.last.x - xy.x,\n- this.handler.last.y - xy.y, {\n- dragging: !!res,\n- animate: false\n+ if (resize) {\n+ var scale, ratio;\n+ // 'resize' together with 'reshape' implies that the aspect \n+ // ratio of the geometry will not be preserved whilst resizing \n+ if (reshape) {\n+ scale = dy1 / dy0;\n+ ratio = (dx1 / dx0) / scale;\n+ } else {\n+ var l0 = Math.sqrt((dx0 * dx0) + (dy0 * dy0));\n+ var l1 = Math.sqrt((dx1 * dx1) + (dy1 * dy1));\n+ scale = l1 / l0;\n }\n- );\n- if (res) {\n- var self = this;\n- this.kinetic.move(res, function(x, y, end) {\n- self.map.pan(x, y, {\n- dragging: !end,\n- animate: false\n- });\n- });\n+ geometry.resize(scale, originGeometry, ratio);\n }\n- this.panned = false;\n+ };\n+ radius._sketch = true;\n+ this.radiusHandle = radius;\n+ this.radiusHandle.renderIntent = this.vertexRenderIntent;\n+ this.layer.addFeatures([this.radiusHandle], {\n+ silent: true\n+ });\n+ },\n+\n+ /**\n+ * Method: setMap\n+ * Set the map property for the control and all handlers.\n+ *\n+ * Parameters:\n+ * map - {} The control's map.\n+ */\n+ setMap: function(map) {\n+ this.handlers.drag.setMap(map);\n+ OpenLayers.Control.prototype.setMap.apply(this, arguments);\n+ },\n+\n+ /**\n+ * Method: handleMapEvents\n+ * \n+ * Parameters:\n+ * evt - {Object}\n+ */\n+ handleMapEvents: function(evt) {\n+ if (evt.type == \"removelayer\" || evt.property == \"order\") {\n+ this.moveLayerToTop();\n }\n },\n \n- CLASS_NAME: \"OpenLayers.Control.DragPan\"\n+ /**\n+ * Method: moveLayerToTop\n+ * Moves the layer for this handler to the top, so mouse events can reach\n+ * it.\n+ */\n+ moveLayerToTop: function() {\n+ var index = Math.max(this.map.Z_INDEX_BASE['Feature'] - 1,\n+ this.layer.getZIndex()) + 1;\n+ this.layer.setZIndex(index);\n+\n+ },\n+\n+ /**\n+ * Method: moveLayerBack\n+ * Moves the layer back to the position determined by the map's layers\n+ * array.\n+ */\n+ moveLayerBack: function() {\n+ var index = this.layer.getZIndex() - 1;\n+ if (index >= this.map.Z_INDEX_BASE['Feature']) {\n+ this.layer.setZIndex(index);\n+ } else {\n+ this.map.setLayerZIndex(this.layer,\n+ this.map.getLayerIndex(this.layer));\n+ }\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Control.ModifyFeature\"\n });\n+\n+/**\n+ * Constant: RESHAPE\n+ * {Integer} Constant used to make the control work in reshape mode\n+ */\n+OpenLayers.Control.ModifyFeature.RESHAPE = 1;\n+/**\n+ * Constant: RESIZE\n+ * {Integer} Constant used to make the control work in resize mode\n+ */\n+OpenLayers.Control.ModifyFeature.RESIZE = 2;\n+/**\n+ * Constant: ROTATE\n+ * {Integer} Constant used to make the control work in rotate mode\n+ */\n+OpenLayers.Control.ModifyFeature.ROTATE = 4;\n+/**\n+ * Constant: DRAG\n+ * {Integer} Constant used to make the control work in drag mode\n+ */\n+OpenLayers.Control.ModifyFeature.DRAG = 8;\n /* ======================================================================\n OpenLayers/Events/buttonclick.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n@@ -42110,113 +38683,14 @@\n return this.getControlsBy(\"CLASS_NAME\", match);\n },\n \n CLASS_NAME: \"OpenLayers.Control.Panel\"\n });\n \n /* ======================================================================\n- OpenLayers/Control/Pan.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Control/Button.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.Pan\n- * The Pan control is a single button to pan the map in one direction. For\n- * a more complete control see .\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control.Button, {\n-\n- /** \n- * APIProperty: slideFactor\n- * {Integer} Number of pixels by which we'll pan the map in any direction \n- * on clicking the arrow buttons, defaults to 50. If you want to pan\n- * by some ratio of the map dimensions, use instead.\n- */\n- slideFactor: 50,\n-\n- /** \n- * APIProperty: slideRatio\n- * {Number} The fraction of map width/height by which we'll pan the map \n- * on clicking the arrow buttons. Default is null. If set, will\n- * override . E.g. if slideRatio is .5, then Pan Up will\n- * pan up half the map height. \n- */\n- slideRatio: null,\n-\n- /** \n- * Property: direction\n- * {String} in {'North', 'South', 'East', 'West'}\n- */\n- direction: null,\n-\n- /**\n- * Constructor: OpenLayers.Control.Pan \n- * Control which handles the panning (in any of the cardinal directions)\n- * of the map by a set px distance. \n- *\n- * Parameters:\n- * direction - {String} The direction this button should pan.\n- * options - {Object} An optional object whose properties will be used\n- * to extend the control.\n- */\n- initialize: function(direction, options) {\n-\n- this.direction = direction;\n- this.CLASS_NAME += this.direction;\n-\n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n- },\n-\n- /**\n- * Method: trigger\n- */\n- trigger: function() {\n- if (this.map) {\n- var getSlideFactor = OpenLayers.Function.bind(function(dim) {\n- return this.slideRatio ?\n- this.map.getSize()[dim] * this.slideRatio :\n- this.slideFactor;\n- }, this);\n-\n- switch (this.direction) {\n- case OpenLayers.Control.Pan.NORTH:\n- this.map.pan(0, -getSlideFactor(\"h\"));\n- break;\n- case OpenLayers.Control.Pan.SOUTH:\n- this.map.pan(0, getSlideFactor(\"h\"));\n- break;\n- case OpenLayers.Control.Pan.WEST:\n- this.map.pan(-getSlideFactor(\"w\"), 0);\n- break;\n- case OpenLayers.Control.Pan.EAST:\n- this.map.pan(getSlideFactor(\"w\"), 0);\n- break;\n- }\n- }\n- },\n-\n- CLASS_NAME: \"OpenLayers.Control.Pan\"\n-});\n-\n-OpenLayers.Control.Pan.NORTH = \"North\";\n-OpenLayers.Control.Pan.SOUTH = \"South\";\n-OpenLayers.Control.Pan.EAST = \"East\";\n-OpenLayers.Control.Pan.WEST = \"West\";\n-/* ======================================================================\n OpenLayers/Control/PanPanel.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -42286,6768 +38760,3458 @@\n new OpenLayers.Control.Pan(OpenLayers.Control.Pan.WEST, options)\n ]);\n },\n \n CLASS_NAME: \"OpenLayers.Control.PanPanel\"\n });\n /* ======================================================================\n- OpenLayers/Control/ZoomOut.js\n+ OpenLayers/Handler/Feature.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Control/Button.js\n+ * @requires OpenLayers/Handler.js\n */\n \n /**\n- * Class: OpenLayers.Control.ZoomOut\n- * The ZoomOut control is a button to decrease the zoom level of a map.\n+ * Class: OpenLayers.Handler.Feature \n+ * Handler to respond to mouse events related to a drawn feature. Callbacks\n+ * with the following keys will be notified of the following events\n+ * associated with features: click, clickout, over, out, and dblclick.\n+ *\n+ * This handler stops event propagation for mousedown and mouseup if those\n+ * browser events target features that can be selected.\n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Control.ZoomOut = OpenLayers.Class(OpenLayers.Control.Button, {\n+OpenLayers.Handler.Feature = OpenLayers.Class(OpenLayers.Handler, {\n \n /**\n- * Method: trigger\n+ * Property: EVENTMAP\n+ * {Object} A object mapping the browser events to objects with callback\n+ * keys for in and out.\n */\n- trigger: function() {\n- if (this.map) {\n- this.map.zoomOut();\n+ EVENTMAP: {\n+ 'click': {\n+ 'in': 'click',\n+ 'out': 'clickout'\n+ },\n+ 'mousemove': {\n+ 'in': 'over',\n+ 'out': 'out'\n+ },\n+ 'dblclick': {\n+ 'in': 'dblclick',\n+ 'out': null\n+ },\n+ 'mousedown': {\n+ 'in': null,\n+ 'out': null\n+ },\n+ 'mouseup': {\n+ 'in': null,\n+ 'out': null\n+ },\n+ 'touchstart': {\n+ 'in': 'click',\n+ 'out': 'clickout'\n }\n },\n \n- CLASS_NAME: \"OpenLayers.Control.ZoomOut\"\n-});\n-/* ======================================================================\n- OpenLayers/Control/ZoomToMaxExtent.js\n- ====================================================================== */\n+ /**\n+ * Property: feature\n+ * {} The last feature that was hovered.\n+ */\n+ feature: null,\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ /**\n+ * Property: lastFeature\n+ * {} The last feature that was handled.\n+ */\n+ lastFeature: null,\n \n-/**\n- * @requires OpenLayers/Control/Button.js\n- */\n+ /**\n+ * Property: down\n+ * {} The location of the last mousedown.\n+ */\n+ down: null,\n \n-/**\n- * Class: OpenLayers.Control.ZoomToMaxExtent \n- * The ZoomToMaxExtent control is a button that zooms out to the maximum\n- * extent of the map. It is designed to be used with a \n- * .\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.ZoomToMaxExtent = OpenLayers.Class(OpenLayers.Control.Button, {\n+ /**\n+ * Property: up\n+ * {} The location of the last mouseup.\n+ */\n+ up: null,\n \n /**\n- * Method: trigger\n- * \n- * Called whenever this control is being rendered inside of a panel and a \n- * click occurs on this controls element. Actually zooms to the maximum\n- * extent of this controls map.\n+ * Property: clickTolerance\n+ * {Number} The number of pixels the mouse can move between mousedown\n+ * and mouseup for the event to still be considered a click.\n+ * Dragging the map should not trigger the click and clickout callbacks\n+ * unless the map is moved by less than this tolerance. Defaults to 4.\n */\n- trigger: function() {\n- if (this.map) {\n- this.map.zoomToMaxExtent();\n- }\n- },\n+ clickTolerance: 4,\n \n- CLASS_NAME: \"OpenLayers.Control.ZoomToMaxExtent\"\n-});\n-/* ======================================================================\n- OpenLayers/Control/ZoomPanel.js\n- ====================================================================== */\n+ /**\n+ * Property: geometryTypes\n+ * To restrict dragging to a limited set of geometry types, send a list\n+ * of strings corresponding to the geometry class names.\n+ * \n+ * @type Array(String)\n+ */\n+ geometryTypes: null,\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ /**\n+ * Property: stopClick\n+ * {Boolean} If stopClick is set to true, handled clicks do not\n+ * propagate to other click listeners. Otherwise, handled clicks\n+ * do propagate. Unhandled clicks always propagate, whatever the\n+ * value of stopClick. Defaults to true.\n+ */\n+ stopClick: true,\n \n-/**\n- * @requires OpenLayers/Control/Panel.js\n- * @requires OpenLayers/Control/ZoomIn.js\n- * @requires OpenLayers/Control/ZoomOut.js\n- * @requires OpenLayers/Control/ZoomToMaxExtent.js\n- */\n+ /**\n+ * Property: stopDown\n+ * {Boolean} If stopDown is set to true, handled mousedowns do not\n+ * propagate to other mousedown listeners. Otherwise, handled\n+ * mousedowns do propagate. Unhandled mousedowns always propagate,\n+ * whatever the value of stopDown. Defaults to true.\n+ */\n+ stopDown: true,\n \n-/**\n- * Class: OpenLayers.Control.ZoomPanel\n- * The ZoomPanel control is a compact collecton of 3 zoom controls: a \n- * , a , and a\n- * . By default it is drawn in the upper left \n- * corner of the map.\n- *\n- * Note: \n- * If you wish to use this class with the default images and you want \n- * it to look nice in ie6, you should add the following, conditionally\n- * added css stylesheet to your HTML file:\n- * \n- * (code)\n- * \n- * (end)\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.ZoomPanel = OpenLayers.Class(OpenLayers.Control.Panel, {\n+ /**\n+ * Property: stopUp\n+ * {Boolean} If stopUp is set to true, handled mouseups do not\n+ * propagate to other mouseup listeners. Otherwise, handled mouseups\n+ * do propagate. Unhandled mouseups always propagate, whatever the\n+ * value of stopUp. Defaults to false.\n+ */\n+ stopUp: false,\n \n /**\n- * Constructor: OpenLayers.Control.ZoomPanel \n- * Add the three zooming controls.\n+ * Constructor: OpenLayers.Handler.Feature\n *\n * Parameters:\n- * options - {Object} An optional object whose properties will be used\n- * to extend the control.\n+ * control - {} \n+ * layer - {}\n+ * callbacks - {Object} An object with a 'over' property whos value is\n+ * a function to be called when the mouse is over a feature. The \n+ * callback should expect to recieve a single argument, the feature.\n+ * options - {Object} \n */\n- initialize: function(options) {\n- OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);\n- this.addControls([\n- new OpenLayers.Control.ZoomIn(),\n- new OpenLayers.Control.ZoomToMaxExtent(),\n- new OpenLayers.Control.ZoomOut()\n- ]);\n+ initialize: function(control, layer, callbacks, options) {\n+ OpenLayers.Handler.prototype.initialize.apply(this, [control, callbacks, options]);\n+ this.layer = layer;\n },\n \n- CLASS_NAME: \"OpenLayers.Control.ZoomPanel\"\n-});\n-/* ======================================================================\n- OpenLayers/Control/Zoom.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Events/buttonclick.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.Zoom\n- * The Zoom control is a pair of +/- links for zooming in and out.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.Zoom = OpenLayers.Class(OpenLayers.Control, {\n-\n /**\n- * APIProperty: zoomInText\n- * {String}\n- * Text for zoom-in link. Default is \"+\".\n+ * Method: touchstart\n+ * Handle touchstart events\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n */\n- zoomInText: \"+\",\n+ touchstart: function(evt) {\n+ this.startTouch();\n+ return OpenLayers.Event.isMultiTouch(evt) ?\n+ true : this.mousedown(evt);\n+ },\n \n /**\n- * APIProperty: zoomInId\n- * {String}\n- * Instead of having the control create a zoom in link, you can provide \n- * the identifier for an anchor element already added to the document.\n- * By default, an element with id \"olZoomInLink\" will be searched for\n- * and used if it exists.\n+ * Method: touchmove\n+ * Handle touchmove events. We just prevent the browser default behavior,\n+ * for Android Webkit not to select text when moving the finger after\n+ * selecting a feature.\n+ *\n+ * Parameters:\n+ * evt - {Event}\n */\n- zoomInId: \"olZoomInLink\",\n+ touchmove: function(evt) {\n+ OpenLayers.Event.preventDefault(evt);\n+ },\n \n /**\n- * APIProperty: zoomOutText\n- * {String}\n- * Text for zoom-out link. Default is \"\\u2212\".\n+ * Method: mousedown\n+ * Handle mouse down. Stop propagation if a feature is targeted by this\n+ * event (stops map dragging during feature selection).\n+ * \n+ * Parameters:\n+ * evt - {Event} \n */\n- zoomOutText: \"\\u2212\",\n+ mousedown: function(evt) {\n+ // Feature selection is only done with a left click. Other handlers may stop the\n+ // propagation of left-click mousedown events but not right-click mousedown events.\n+ // This mismatch causes problems when comparing the location of the down and up\n+ // events in the click function so it is important ignore right-clicks.\n+ if (OpenLayers.Event.isLeftClick(evt) || OpenLayers.Event.isSingleTouch(evt)) {\n+ this.down = evt.xy;\n+ }\n+ return this.handle(evt) ? !this.stopDown : true;\n+ },\n \n /**\n- * APIProperty: zoomOutId\n- * {String}\n- * Instead of having the control create a zoom out link, you can provide \n- * the identifier for an anchor element already added to the document.\n- * By default, an element with id \"olZoomOutLink\" will be searched for\n- * and used if it exists.\n+ * Method: mouseup\n+ * Handle mouse up. Stop propagation if a feature is targeted by this\n+ * event.\n+ * \n+ * Parameters:\n+ * evt - {Event} \n */\n- zoomOutId: \"olZoomOutLink\",\n+ mouseup: function(evt) {\n+ this.up = evt.xy;\n+ return this.handle(evt) ? !this.stopUp : true;\n+ },\n \n /**\n- * Method: draw\n+ * Method: click\n+ * Handle click. Call the \"click\" callback if click on a feature,\n+ * or the \"clickout\" callback if click outside any feature.\n+ * \n+ * Parameters:\n+ * evt - {Event} \n *\n * Returns:\n- * {DOMElement} A reference to the DOMElement containing the zoom links.\n+ * {Boolean}\n */\n- draw: function() {\n- var div = OpenLayers.Control.prototype.draw.apply(this),\n- links = this.getOrCreateLinks(div),\n- zoomIn = links.zoomIn,\n- zoomOut = links.zoomOut,\n- eventsInstance = this.map.events;\n+ click: function(evt) {\n+ return this.handle(evt) ? !this.stopClick : true;\n+ },\n \n- if (zoomOut.parentNode !== div) {\n- eventsInstance = this.events;\n- eventsInstance.attachToElement(zoomOut.parentNode);\n+ /**\n+ * Method: mousemove\n+ * Handle mouse moves. Call the \"over\" callback if moving in to a feature,\n+ * or the \"out\" callback if moving out of a feature.\n+ * \n+ * Parameters:\n+ * evt - {Event} \n+ *\n+ * Returns:\n+ * {Boolean}\n+ */\n+ mousemove: function(evt) {\n+ if (!this.callbacks['over'] && !this.callbacks['out']) {\n+ return true;\n }\n- eventsInstance.register(\"buttonclick\", this, this.onZoomClick);\n+ this.handle(evt);\n+ return true;\n+ },\n \n- this.zoomInLink = zoomIn;\n- this.zoomOutLink = zoomOut;\n- return div;\n+ /**\n+ * Method: dblclick\n+ * Handle dblclick. Call the \"dblclick\" callback if dblclick on a feature.\n+ *\n+ * Parameters:\n+ * evt - {Event} \n+ *\n+ * Returns:\n+ * {Boolean}\n+ */\n+ dblclick: function(evt) {\n+ return !this.handle(evt);\n },\n \n /**\n- * Method: getOrCreateLinks\n- * \n+ * Method: geometryTypeMatches\n+ * Return true if the geometry type of the passed feature matches\n+ * one of the geometry types in the geometryTypes array.\n+ *\n * Parameters:\n- * el - {DOMElement}\n+ * feature - {}\n *\n- * Return: \n- * {Object} Object with zoomIn and zoomOut properties referencing links.\n+ * Returns:\n+ * {Boolean}\n */\n- getOrCreateLinks: function(el) {\n- var zoomIn = document.getElementById(this.zoomInId),\n- zoomOut = document.getElementById(this.zoomOutId);\n- if (!zoomIn) {\n- zoomIn = document.createElement(\"a\");\n- zoomIn.href = \"#zoomIn\";\n- zoomIn.appendChild(document.createTextNode(this.zoomInText));\n- zoomIn.className = \"olControlZoomIn\";\n- el.appendChild(zoomIn);\n+ geometryTypeMatches: function(feature) {\n+ return this.geometryTypes == null ||\n+ OpenLayers.Util.indexOf(this.geometryTypes,\n+ feature.geometry.CLASS_NAME) > -1;\n+ },\n+\n+ /**\n+ * Method: handle\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ *\n+ * Returns:\n+ * {Boolean} The event occurred over a relevant feature.\n+ */\n+ handle: function(evt) {\n+ if (this.feature && !this.feature.layer) {\n+ // feature has been destroyed\n+ this.feature = null;\n }\n- OpenLayers.Element.addClass(zoomIn, \"olButton\");\n- if (!zoomOut) {\n- zoomOut = document.createElement(\"a\");\n- zoomOut.href = \"#zoomOut\";\n- zoomOut.appendChild(document.createTextNode(this.zoomOutText));\n- zoomOut.className = \"olControlZoomOut\";\n- el.appendChild(zoomOut);\n+ var type = evt.type;\n+ var handled = false;\n+ var previouslyIn = !!(this.feature); // previously in a feature\n+ var click = (type == \"click\" || type == \"dblclick\" || type == \"touchstart\");\n+ this.feature = this.layer.getFeatureFromEvent(evt);\n+ if (this.feature && !this.feature.layer) {\n+ // feature has been destroyed\n+ this.feature = null;\n }\n- OpenLayers.Element.addClass(zoomOut, \"olButton\");\n- return {\n- zoomIn: zoomIn,\n- zoomOut: zoomOut\n- };\n+ if (this.lastFeature && !this.lastFeature.layer) {\n+ // last feature has been destroyed\n+ this.lastFeature = null;\n+ }\n+ if (this.feature) {\n+ if (type === \"touchstart\") {\n+ // stop the event to prevent Android Webkit from\n+ // \"flashing\" the map div\n+ OpenLayers.Event.preventDefault(evt);\n+ }\n+ var inNew = (this.feature != this.lastFeature);\n+ if (this.geometryTypeMatches(this.feature)) {\n+ // in to a feature\n+ if (previouslyIn && inNew) {\n+ // out of last feature and in to another\n+ if (this.lastFeature) {\n+ this.triggerCallback(type, 'out', [this.lastFeature]);\n+ }\n+ this.triggerCallback(type, 'in', [this.feature]);\n+ } else if (!previouslyIn || click) {\n+ // in feature for the first time\n+ this.triggerCallback(type, 'in', [this.feature]);\n+ }\n+ this.lastFeature = this.feature;\n+ handled = true;\n+ } else {\n+ // not in to a feature\n+ if (this.lastFeature && (previouslyIn && inNew || click)) {\n+ // out of last feature for the first time\n+ this.triggerCallback(type, 'out', [this.lastFeature]);\n+ }\n+ // next time the mouse goes in a feature whose geometry type\n+ // doesn't match we don't want to call the 'out' callback\n+ // again, so let's set this.feature to null so that\n+ // previouslyIn will evaluate to false the next time\n+ // we enter handle. Yes, a bit hackish...\n+ this.feature = null;\n+ }\n+ } else if (this.lastFeature && (previouslyIn || click)) {\n+ this.triggerCallback(type, 'out', [this.lastFeature]);\n+ }\n+ return handled;\n },\n \n /**\n- * Method: onZoomClick\n- * Called when zoomin/out link is clicked.\n+ * Method: triggerCallback\n+ * Call the callback keyed in the event map with the supplied arguments.\n+ * For click and clickout, the is checked first.\n+ *\n+ * Parameters:\n+ * type - {String}\n */\n- onZoomClick: function(evt) {\n- var button = evt.buttonElement;\n- if (button === this.zoomInLink) {\n- this.map.zoomIn();\n- } else if (button === this.zoomOutLink) {\n- this.map.zoomOut();\n+ triggerCallback: function(type, mode, args) {\n+ var key = this.EVENTMAP[type][mode];\n+ if (key) {\n+ if (type == 'click' && this.up && this.down) {\n+ // for click/clickout, only trigger callback if tolerance is met\n+ var dpx = Math.sqrt(\n+ Math.pow(this.up.x - this.down.x, 2) +\n+ Math.pow(this.up.y - this.down.y, 2)\n+ );\n+ if (dpx <= this.clickTolerance) {\n+ this.callback(key, args);\n+ }\n+ // we're done with this set of events now: clear the cached\n+ // positions so we can't trip over them later (this can occur\n+ // if one of the up/down events gets eaten before it gets to us\n+ // but we still get the click)\n+ this.up = this.down = null;\n+ } else {\n+ this.callback(key, args);\n+ }\n }\n },\n \n- /** \n- * Method: destroy\n- * Clean up.\n+ /**\n+ * Method: activate \n+ * Turn on the handler. Returns false if the handler was already active.\n+ *\n+ * Returns:\n+ * {Boolean}\n */\n- destroy: function() {\n- if (this.map) {\n- this.map.events.unregister(\"buttonclick\", this, this.onZoomClick);\n+ activate: function() {\n+ var activated = false;\n+ if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n+ this.moveLayerToTop();\n+ this.map.events.on({\n+ \"removelayer\": this.handleMapEvents,\n+ \"changelayer\": this.handleMapEvents,\n+ scope: this\n+ });\n+ activated = true;\n }\n- delete this.zoomInLink;\n- delete this.zoomOutLink;\n- OpenLayers.Control.prototype.destroy.apply(this);\n+ return activated;\n },\n \n- CLASS_NAME: \"OpenLayers.Control.Zoom\"\n-});\n-/* ======================================================================\n- OpenLayers/Control/Attribution.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Control.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.Attribution\n- * The attribution control adds attribution from layers to the map display. \n- * It uses 'attribution' property of each layer.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.Attribution =\n- OpenLayers.Class(OpenLayers.Control, {\n-\n- /**\n- * APIProperty: separator\n- * {String} String used to separate layers.\n- */\n- separator: \", \",\n-\n- /**\n- * APIProperty: template\n- * {String} Template for the attribution. This has to include the substring\n- * \"${layers}\", which will be replaced by the layer specific\n- * attributions, separated by . The default is \"${layers}\".\n- */\n- template: \"${layers}\",\n-\n- /**\n- * Constructor: OpenLayers.Control.Attribution \n- * \n- * Parameters:\n- * options - {Object} Options for control.\n- */\n-\n- /** \n- * Method: destroy\n- * Destroy control.\n- */\n- destroy: function() {\n+ /**\n+ * Method: deactivate \n+ * Turn off the handler. Returns false if the handler was already active.\n+ *\n+ * Returns: \n+ * {Boolean}\n+ */\n+ deactivate: function() {\n+ var deactivated = false;\n+ if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n+ this.moveLayerBack();\n+ this.feature = null;\n+ this.lastFeature = null;\n+ this.down = null;\n+ this.up = null;\n this.map.events.un({\n- \"removelayer\": this.updateAttribution,\n- \"addlayer\": this.updateAttribution,\n- \"changelayer\": this.updateAttribution,\n- \"changebaselayer\": this.updateAttribution,\n+ \"removelayer\": this.handleMapEvents,\n+ \"changelayer\": this.handleMapEvents,\n scope: this\n });\n+ deactivated = true;\n+ }\n+ return deactivated;\n+ },\n \n- OpenLayers.Control.prototype.destroy.apply(this, arguments);\n- },\n-\n- /**\n- * Method: draw\n- * Initialize control.\n- * \n- * Returns: \n- * {DOMElement} A reference to the DIV DOMElement containing the control\n- */\n- draw: function() {\n- OpenLayers.Control.prototype.draw.apply(this, arguments);\n+ /**\n+ * Method: handleMapEvents\n+ * \n+ * Parameters:\n+ * evt - {Object}\n+ */\n+ handleMapEvents: function(evt) {\n+ if (evt.type == \"removelayer\" || evt.property == \"order\") {\n+ this.moveLayerToTop();\n+ }\n+ },\n \n- this.map.events.on({\n- 'changebaselayer': this.updateAttribution,\n- 'changelayer': this.updateAttribution,\n- 'addlayer': this.updateAttribution,\n- 'removelayer': this.updateAttribution,\n- scope: this\n- });\n- this.updateAttribution();\n+ /**\n+ * Method: moveLayerToTop\n+ * Moves the layer for this handler to the top, so mouse events can reach\n+ * it.\n+ */\n+ moveLayerToTop: function() {\n+ var index = Math.max(this.map.Z_INDEX_BASE['Feature'] - 1,\n+ this.layer.getZIndex()) + 1;\n+ this.layer.setZIndex(index);\n \n- return this.div;\n- },\n+ },\n \n- /**\n- * Method: updateAttribution\n- * Update attribution string.\n- */\n- updateAttribution: function() {\n- var attributions = [];\n- if (this.map && this.map.layers) {\n- for (var i = 0, len = this.map.layers.length; i < len; i++) {\n- var layer = this.map.layers[i];\n- if (layer.attribution && layer.getVisibility()) {\n- // add attribution only if attribution text is unique\n- if (OpenLayers.Util.indexOf(\n- attributions, layer.attribution) === -1) {\n- attributions.push(layer.attribution);\n- }\n- }\n- }\n- this.div.innerHTML = OpenLayers.String.format(this.template, {\n- layers: attributions.join(this.separator)\n- });\n- }\n- },\n+ /**\n+ * Method: moveLayerBack\n+ * Moves the layer back to the position determined by the map's layers\n+ * array.\n+ */\n+ moveLayerBack: function() {\n+ var index = this.layer.getZIndex() - 1;\n+ if (index >= this.map.Z_INDEX_BASE['Feature']) {\n+ this.layer.setZIndex(index);\n+ } else {\n+ this.map.setLayerZIndex(this.layer,\n+ this.map.getLayerIndex(this.layer));\n+ }\n+ },\n \n- CLASS_NAME: \"OpenLayers.Control.Attribution\"\n- });\n+ CLASS_NAME: \"OpenLayers.Handler.Feature\"\n+});\n /* ======================================================================\n- OpenLayers/Control/TouchNavigation.js\n+ OpenLayers/Control/DragFeature.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Control/DragPan.js\n- * @requires OpenLayers/Control/PinchZoom.js\n- * @requires OpenLayers/Handler/Click.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Handler/Drag.js\n+ * @requires OpenLayers/Handler/Feature.js\n */\n \n /**\n- * Class: OpenLayers.Control.TouchNavigation\n- * The navigation control handles map browsing with touch events (dragging,\n- * double-tapping, tap with two fingers, and pinch zoom). Create a new \n- * control with the constructor.\n- *\n- * If you\u2019re only targeting touch enabled devices with your mapping application,\n- * you can create a map with only a TouchNavigation control. The \n- * control is mobile ready by default, but \n- * you can generate a smaller build of the library by only including this\n- * touch navigation control if you aren't concerned about mouse interaction.\n+ * Class: OpenLayers.Control.DragFeature\n+ * The DragFeature control moves a feature with a drag of the mouse. Create a\n+ * new control with the constructor.\n *\n- * Inherits:\n+ * Inherits From:\n * - \n */\n-OpenLayers.Control.TouchNavigation = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * Property: dragPan\n- * {}\n+ * APIProperty: geometryTypes\n+ * {Array(String)} To restrict dragging to a limited set of geometry types,\n+ * send a list of strings corresponding to the geometry class names.\n */\n- dragPan: null,\n+ geometryTypes: null,\n \n /**\n- * APIProperty: dragPanOptions\n- * {Object} Options passed to the DragPan control.\n+ * APIProperty: onStart\n+ * {Function} Define this function if you want to know when a drag starts.\n+ * The function should expect to receive two arguments: the feature\n+ * that is about to be dragged and the pixel location of the mouse.\n+ *\n+ * Parameters:\n+ * feature - {} The feature that is about to be\n+ * dragged.\n+ * pixel - {} The pixel location of the mouse.\n */\n- dragPanOptions: null,\n+ onStart: function(feature, pixel) {},\n \n /**\n- * Property: pinchZoom\n- * {}\n+ * APIProperty: onDrag\n+ * {Function} Define this function if you want to know about each move of a\n+ * feature. The function should expect to receive two arguments: the\n+ * feature that is being dragged and the pixel location of the mouse.\n+ *\n+ * Parameters:\n+ * feature - {} The feature that was dragged.\n+ * pixel - {} The pixel location of the mouse.\n */\n- pinchZoom: null,\n+ onDrag: function(feature, pixel) {},\n \n /**\n- * APIProperty: pinchZoomOptions\n- * {Object} Options passed to the PinchZoom control.\n+ * APIProperty: onComplete\n+ * {Function} Define this function if you want to know when a feature is\n+ * done dragging. The function should expect to receive two arguments:\n+ * the feature that is being dragged and the pixel location of the\n+ * mouse.\n+ *\n+ * Parameters:\n+ * feature - {} The feature that was dragged.\n+ * pixel - {} The pixel location of the mouse.\n */\n- pinchZoomOptions: null,\n+ onComplete: function(feature, pixel) {},\n \n /**\n- * APIProperty: clickHandlerOptions\n- * {Object} Options passed to the Click handler.\n+ * APIProperty: onEnter\n+ * {Function} Define this function if you want to know when the mouse\n+ * goes over a feature and thereby makes this feature a candidate\n+ * for dragging.\n+ *\n+ * Parameters:\n+ * feature - {} The feature that is ready\n+ * to be dragged.\n */\n- clickHandlerOptions: null,\n+ onEnter: function(feature) {},\n+\n+ /**\n+ * APIProperty: onLeave\n+ * {Function} Define this function if you want to know when the mouse\n+ * goes out of the feature that was dragged.\n+ *\n+ * Parameters:\n+ * feature - {} The feature that was dragged.\n+ */\n+ onLeave: function(feature) {},\n \n /**\n * APIProperty: documentDrag\n- * {Boolean} Allow panning of the map by dragging outside map viewport.\n- * Default is false.\n+ * {Boolean} If set to true, mouse dragging will continue even if the\n+ * mouse cursor leaves the map viewport. Default is false.\n */\n documentDrag: false,\n \n /**\n- * APIProperty: autoActivate\n- * {Boolean} Activate the control when it is added to a map. Default is\n- * true.\n+ * Property: layer\n+ * {}\n */\n- autoActivate: true,\n+ layer: null,\n \n /**\n- * Constructor: OpenLayers.Control.TouchNavigation\n- * Create a new navigation control\n- *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * the control\n+ * Property: feature\n+ * {}\n */\n- initialize: function(options) {\n- this.handlers = {};\n- OpenLayers.Control.prototype.initialize.apply(this, arguments);\n- },\n+ feature: null,\n \n /**\n- * Method: destroy\n- * The destroy method is used to perform any clean up before the control\n- * is dereferenced. Typically this is where event listeners are removed\n- * to prevent memory leaks.\n+ * Property: dragCallbacks\n+ * {Object} The functions that are sent to the drag handler for callback.\n */\n- destroy: function() {\n- this.deactivate();\n- if (this.dragPan) {\n- this.dragPan.destroy();\n- }\n- this.dragPan = null;\n- if (this.pinchZoom) {\n- this.pinchZoom.destroy();\n- delete this.pinchZoom;\n- }\n- OpenLayers.Control.prototype.destroy.apply(this, arguments);\n- },\n+ dragCallbacks: {},\n \n /**\n- * Method: activate\n+ * Property: featureCallbacks\n+ * {Object} The functions that are sent to the feature handler for callback.\n */\n- activate: function() {\n- if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {\n- this.dragPan.activate();\n- this.handlers.click.activate();\n- this.pinchZoom.activate();\n- return true;\n- }\n- return false;\n- },\n+ featureCallbacks: {},\n \n /**\n- * Method: deactivate\n+ * Property: lastPixel\n+ * {}\n */\n- deactivate: function() {\n- if (OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {\n- this.dragPan.deactivate();\n- this.handlers.click.deactivate();\n- this.pinchZoom.deactivate();\n- return true;\n- }\n- return false;\n- },\n+ lastPixel: null,\n \n /**\n- * Method: draw\n+ * Constructor: OpenLayers.Control.DragFeature\n+ * Create a new control to drag features.\n+ *\n+ * Parameters:\n+ * layer - {} The layer containing features to be\n+ * dragged.\n+ * options - {Object} Optional object whose properties will be set on the\n+ * control.\n */\n- draw: function() {\n- var clickCallbacks = {\n- click: this.defaultClick,\n- dblclick: this.defaultDblClick\n+ initialize: function(layer, options) {\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+ this.layer = layer;\n+ this.handlers = {\n+ drag: new OpenLayers.Handler.Drag(\n+ this, OpenLayers.Util.extend({\n+ down: this.downFeature,\n+ move: this.moveFeature,\n+ up: this.upFeature,\n+ out: this.cancel,\n+ done: this.doneDragging\n+ }, this.dragCallbacks), {\n+ documentDrag: this.documentDrag\n+ }\n+ ),\n+ feature: new OpenLayers.Handler.Feature(\n+ this, this.layer, OpenLayers.Util.extend({\n+ // 'click' and 'clickout' callback are for the mobile\n+ // support: no 'over' or 'out' in touch based browsers.\n+ click: this.clickFeature,\n+ clickout: this.clickoutFeature,\n+ over: this.overFeature,\n+ out: this.outFeature\n+ }, this.featureCallbacks), {\n+ geometryTypes: this.geometryTypes\n+ }\n+ )\n };\n- var clickOptions = OpenLayers.Util.extend({\n- \"double\": true,\n- stopDouble: true,\n- pixelTolerance: 2\n- }, this.clickHandlerOptions);\n- this.handlers.click = new OpenLayers.Handler.Click(\n- this, clickCallbacks, clickOptions\n- );\n- this.dragPan = new OpenLayers.Control.DragPan(\n- OpenLayers.Util.extend({\n- map: this.map,\n- documentDrag: this.documentDrag\n- }, this.dragPanOptions)\n- );\n- this.dragPan.draw();\n- this.pinchZoom = new OpenLayers.Control.PinchZoom(\n- OpenLayers.Util.extend({\n- map: this.map\n- }, this.pinchZoomOptions)\n- );\n },\n \n /**\n- * Method: defaultClick\n+ * Method: clickFeature\n+ * Called when the feature handler detects a click-in on a feature.\n *\n * Parameters:\n- * evt - {Event}\n+ * feature - {}\n */\n- defaultClick: function(evt) {\n- if (evt.lastTouches && evt.lastTouches.length == 2) {\n- this.map.zoomOut();\n+ clickFeature: function(feature) {\n+ if (this.handlers.feature.touch && !this.over && this.overFeature(feature)) {\n+ this.handlers.drag.dragstart(this.handlers.feature.evt);\n+ // to let the events propagate to the feature handler (click callback)\n+ this.handlers.drag.stopDown = false;\n }\n },\n \n /**\n- * Method: defaultDblClick\n+ * Method: clickoutFeature\n+ * Called when the feature handler detects a click-out on a feature.\n *\n * Parameters:\n- * evt - {Event}\n+ * feature - {}\n */\n- defaultDblClick: function(evt) {\n- this.map.zoomTo(this.map.zoom + 1, evt.xy);\n+ clickoutFeature: function(feature) {\n+ if (this.handlers.feature.touch && this.over) {\n+ this.outFeature(feature);\n+ this.handlers.drag.stopDown = true;\n+ }\n },\n \n- CLASS_NAME: \"OpenLayers.Control.TouchNavigation\"\n-});\n-/* ======================================================================\n- OpenLayers/Control/DrawFeature.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Feature/Vector.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.DrawFeature\n- * The DrawFeature control draws point, line or polygon features on a vector\n- * layer when active.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, {\n-\n- /**\n- * Property: layer\n- * {}\n- */\n- layer: null,\n-\n- /**\n- * Property: callbacks\n- * {Object} The functions that are sent to the handler for callback\n- */\n- callbacks: null,\n-\n- /** \n- * APIProperty: events\n- * {} Events instance for listeners and triggering\n- * control specific events.\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * control.events.register(type, obj, listener);\n- * (end)\n- *\n- * Supported event types (in addition to those from ):\n- * featureadded - Triggered when a feature is added\n- */\n-\n- /**\n- * APIProperty: multi\n- * {Boolean} Cast features to multi-part geometries before passing to the\n- * layer. Default is false.\n- */\n- multi: false,\n-\n /**\n- * APIProperty: featureAdded\n- * {Function} Called after each feature is added\n- */\n- featureAdded: function() {},\n-\n- /**\n- * APIProperty: handlerOptions\n- * {Object} Used to set non-default properties on the control's handler\n+ * APIMethod: destroy\n+ * Take care of things that are not handled in superclass\n */\n+ destroy: function() {\n+ this.layer = null;\n+ OpenLayers.Control.prototype.destroy.apply(this, []);\n+ },\n \n /**\n- * Constructor: OpenLayers.Control.DrawFeature\n+ * APIMethod: activate\n+ * Activate the control and the feature handler.\n * \n- * Parameters:\n- * layer - {} \n- * handler - {} \n- * options - {Object} \n+ * Returns:\n+ * {Boolean} Successfully activated the control and feature handler.\n */\n- initialize: function(layer, handler, options) {\n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n- this.callbacks = OpenLayers.Util.extend({\n- done: this.drawFeature,\n- modify: function(vertex, feature) {\n- this.layer.events.triggerEvent(\n- \"sketchmodified\", {\n- vertex: vertex,\n- feature: feature\n- }\n- );\n- },\n- create: function(vertex, feature) {\n- this.layer.events.triggerEvent(\n- \"sketchstarted\", {\n- vertex: vertex,\n- feature: feature\n- }\n- );\n- }\n- },\n- this.callbacks\n- );\n- this.layer = layer;\n- this.handlerOptions = this.handlerOptions || {};\n- this.handlerOptions.layerOptions = OpenLayers.Util.applyDefaults(\n- this.handlerOptions.layerOptions, {\n- renderers: layer.renderers,\n- rendererOptions: layer.rendererOptions\n- }\n- );\n- if (!(\"multi\" in this.handlerOptions)) {\n- this.handlerOptions.multi = this.multi;\n- }\n- var sketchStyle = this.layer.styleMap && this.layer.styleMap.styles.temporary;\n- if (sketchStyle) {\n- this.handlerOptions.layerOptions = OpenLayers.Util.applyDefaults(\n- this.handlerOptions.layerOptions, {\n- styleMap: new OpenLayers.StyleMap({\n- \"default\": sketchStyle\n- })\n- }\n- );\n- }\n- this.handler = new handler(this, this.callbacks, this.handlerOptions);\n+ activate: function() {\n+ return (this.handlers.feature.activate() &&\n+ OpenLayers.Control.prototype.activate.apply(this, arguments));\n },\n \n /**\n- * Method: drawFeature\n+ * APIMethod: deactivate\n+ * Deactivate the control and all handlers.\n+ * \n+ * Returns:\n+ * {Boolean} Successfully deactivated the control.\n */\n- drawFeature: function(geometry) {\n- var feature = new OpenLayers.Feature.Vector(geometry);\n- var proceed = this.layer.events.triggerEvent(\n- \"sketchcomplete\", {\n- feature: feature\n- }\n+ deactivate: function() {\n+ // the return from the handlers is unimportant in this case\n+ this.handlers.drag.deactivate();\n+ this.handlers.feature.deactivate();\n+ this.feature = null;\n+ this.dragging = false;\n+ this.lastPixel = null;\n+ OpenLayers.Element.removeClass(\n+ this.map.viewPortDiv, this.displayClass + \"Over\"\n );\n- if (proceed !== false) {\n- feature.state = OpenLayers.State.INSERT;\n- this.layer.addFeatures([feature]);\n- this.featureAdded(feature);\n- this.events.triggerEvent(\"featureadded\", {\n- feature: feature\n- });\n- }\n+ return OpenLayers.Control.prototype.deactivate.apply(this, arguments);\n },\n \n /**\n- * APIMethod: insertXY\n- * Insert a point in the current sketch given x & y coordinates.\n+ * Method: overFeature\n+ * Called when the feature handler detects a mouse-over on a feature.\n+ * This activates the drag handler.\n *\n * Parameters:\n- * x - {Number} The x-coordinate of the point.\n- * y - {Number} The y-coordinate of the point.\n+ * feature - {} The selected feature.\n+ *\n+ * Returns:\n+ * {Boolean} Successfully activated the drag handler.\n */\n- insertXY: function(x, y) {\n- if (this.handler && this.handler.line) {\n- this.handler.insertXY(x, y);\n+ overFeature: function(feature) {\n+ var activated = false;\n+ if (!this.handlers.drag.dragging) {\n+ this.feature = feature;\n+ this.handlers.drag.activate();\n+ activated = true;\n+ this.over = true;\n+ OpenLayers.Element.addClass(this.map.viewPortDiv, this.displayClass + \"Over\");\n+ this.onEnter(feature);\n+ } else {\n+ if (this.feature.id == feature.id) {\n+ this.over = true;\n+ } else {\n+ this.over = false;\n+ }\n }\n+ return activated;\n },\n \n /**\n- * APIMethod: insertDeltaXY\n- * Insert a point given offsets from the previously inserted point.\n+ * Method: downFeature\n+ * Called when the drag handler detects a mouse-down.\n *\n * Parameters:\n- * dx - {Number} The x-coordinate offset of the point.\n- * dy - {Number} The y-coordinate offset of the point.\n+ * pixel - {} Location of the mouse event.\n */\n- insertDeltaXY: function(dx, dy) {\n- if (this.handler && this.handler.line) {\n- this.handler.insertDeltaXY(dx, dy);\n- }\n+ downFeature: function(pixel) {\n+ this.lastPixel = pixel;\n+ this.onStart(this.feature, pixel);\n },\n \n /**\n- * APIMethod: insertDirectionLength\n- * Insert a point in the current sketch given a direction and a length.\n- *\n+ * Method: moveFeature\n+ * Called when the drag handler detects a mouse-move. Also calls the\n+ * optional onDrag method.\n+ * \n * Parameters:\n- * direction - {Number} Degrees clockwise from the positive x-axis.\n- * length - {Number} Distance from the previously drawn point.\n+ * pixel - {} Location of the mouse event.\n */\n- insertDirectionLength: function(direction, length) {\n- if (this.handler && this.handler.line) {\n- this.handler.insertDirectionLength(direction, length);\n- }\n+ moveFeature: function(pixel) {\n+ var res = this.map.getResolution();\n+ this.feature.geometry.move(res * (pixel.x - this.lastPixel.x),\n+ res * (this.lastPixel.y - pixel.y));\n+ this.layer.drawFeature(this.feature);\n+ this.lastPixel = pixel;\n+ this.onDrag(this.feature, pixel);\n },\n \n /**\n- * APIMethod: insertDeflectionLength\n- * Insert a point in the current sketch given a deflection and a length.\n- * The deflection should be degrees clockwise from the previously \n- * digitized segment.\n- *\n+ * Method: upFeature\n+ * Called when the drag handler detects a mouse-up.\n+ * \n * Parameters:\n- * deflection - {Number} Degrees clockwise from the previous segment.\n- * length - {Number} Distance from the previously drawn point.\n+ * pixel - {} Location of the mouse event.\n */\n- insertDeflectionLength: function(deflection, length) {\n- if (this.handler && this.handler.line) {\n- this.handler.insertDeflectionLength(deflection, length);\n+ upFeature: function(pixel) {\n+ if (!this.over) {\n+ this.handlers.drag.deactivate();\n }\n },\n \n /**\n- * APIMethod: undo\n- * Remove the most recently added point in the current sketch geometry.\n+ * Method: doneDragging\n+ * Called when the drag handler is done dragging.\n *\n- * Returns: \n- * {Boolean} An edit was undone.\n+ * Parameters:\n+ * pixel - {} The last event pixel location. If this event\n+ * came from a mouseout, this may not be in the map viewport.\n */\n- undo: function() {\n- return this.handler.undo && this.handler.undo();\n+ doneDragging: function(pixel) {\n+ this.onComplete(this.feature, pixel);\n },\n \n /**\n- * APIMethod: redo\n- * Reinsert the most recently removed point resulting from an call.\n- * The undo stack is deleted whenever a point is added by other means.\n+ * Method: outFeature\n+ * Called when the feature handler detects a mouse-out on a feature.\n *\n- * Returns: \n- * {Boolean} An edit was redone.\n+ * Parameters:\n+ * feature - {} The feature that the mouse left.\n */\n- redo: function() {\n- return this.handler.redo && this.handler.redo();\n+ outFeature: function(feature) {\n+ if (!this.handlers.drag.dragging) {\n+ this.over = false;\n+ this.handlers.drag.deactivate();\n+ OpenLayers.Element.removeClass(\n+ this.map.viewPortDiv, this.displayClass + \"Over\"\n+ );\n+ this.onLeave(feature);\n+ this.feature = null;\n+ } else {\n+ if (this.feature.id == feature.id) {\n+ this.over = false;\n+ }\n+ }\n },\n \n /**\n- * APIMethod: finishSketch\n- * Finishes the sketch without including the currently drawn point.\n- * This method can be called to terminate drawing programmatically\n- * instead of waiting for the user to end the sketch.\n+ * Method: cancel\n+ * Called when the drag handler detects a mouse-out (from the map viewport).\n */\n- finishSketch: function() {\n- this.handler.finishGeometry();\n+ cancel: function() {\n+ this.handlers.drag.deactivate();\n+ this.over = false;\n },\n \n /**\n- * APIMethod: cancel\n- * Cancel the current sketch. This removes the current sketch and keeps\n- * the drawing control active.\n+ * Method: setMap\n+ * Set the map property for the control and all handlers.\n+ *\n+ * Parameters: \n+ * map - {} The control's map.\n */\n- cancel: function() {\n- this.handler.cancel();\n+ setMap: function(map) {\n+ this.handlers.drag.setMap(map);\n+ this.handlers.feature.setMap(map);\n+ OpenLayers.Control.prototype.setMap.apply(this, arguments);\n },\n \n- CLASS_NAME: \"OpenLayers.Control.DrawFeature\"\n+ CLASS_NAME: \"OpenLayers.Control.DragFeature\"\n });\n /* ======================================================================\n- OpenLayers/Control/Snapping.js\n+ OpenLayers/Control/TransformFeature.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Layer/Vector.js\n+ * @requires OpenLayers/Control/DragFeature.js\n+ * @requires OpenLayers/Feature/Vector.js\n+ * @requires OpenLayers/Geometry/LineString.js\n+ * @requires OpenLayers/Geometry/Point.js\n */\n \n /**\n- * Class: OpenLayers.Control.Snapping\n- * Acts as a snapping agent while editing vector features.\n+ * Class: OpenLayers.Control.TransformFeature\n+ * Control to transform features with a standard transformation box.\n *\n- * Inherits from:\n+ * Inherits From:\n * - \n */\n-OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {\n \n /** \n * APIProperty: events\n * {} Events instance for listeners and triggering\n * control specific events.\n *\n * Register a listener for a particular event with the following syntax:\n * (code)\n * control.events.register(type, obj, listener);\n * (end)\n *\n * Supported event types (in addition to those from ):\n- * beforesnap - Triggered before a snap occurs. Listeners receive an\n- * event object with *point*, *x*, *y*, *distance*, *layer*, and\n- * *snapType* properties. The point property will be original point\n- * geometry considered for snapping. The x and y properties represent\n- * coordinates the point will receive. The distance is the distance\n- * of the snap. The layer is the target layer. The snapType property\n- * will be one of \"node\", \"vertex\", or \"edge\". Return false to stop\n- * snapping from occurring.\n- * snap - Triggered when a snap occurs. Listeners receive an event with\n- * *point*, *snapType*, *layer*, and *distance* properties. The point\n- * will be the location snapped to. The snapType will be one of \"node\",\n- * \"vertex\", or \"edge\". The layer will be the target layer. The\n- * distance will be the distance of the snap in map units.\n- * unsnap - Triggered when a vertex is unsnapped. Listeners receive an\n- * event with a *point* property.\n+ * beforesetfeature - Triggered before a feature is set for\n+ * tranformation. The feature will not be set if a listener returns\n+ * false. Listeners receive a *feature* property, with the feature\n+ * that will be set for transformation. Listeners are allowed to\n+ * set the control's *scale*, *ratio* and *rotation* properties,\n+ * which will set the initial scale, ratio and rotation of the\n+ * feature, like the method's initialParams argument.\n+ * setfeature - Triggered when a feature is set for tranformation.\n+ * Listeners receive a *feature* property, with the feature that\n+ * is now set for transformation.\n+ * beforetransform - Triggered while dragging, before a feature is\n+ * transformed. The feature will not be transformed if a listener\n+ * returns false (but the box still will). Listeners receive one or\n+ * more of *center*, *scale*, *ratio* and *rotation*. The *center*\n+ * property is an object with the new\n+ * center of the transformed feature, the others are Floats with the\n+ * scale, ratio or rotation change since the last transformation.\n+ * transform - Triggered while dragging, when a feature is transformed.\n+ * Listeners receive an event object with one or more of *center*,\n+ * scale*, *ratio* and *rotation*. The *center* property is an\n+ * object with the new center of the\n+ * transformed feature, the others are Floats with the scale, ratio\n+ * or rotation change of the feature since the last transformation.\n+ * transformcomplete - Triggered after dragging. Listeners receive\n+ * an event object with the transformed *feature*.\n */\n \n /**\n- * CONSTANT: DEFAULTS\n- * Default target properties.\n+ * APIProperty: geometryTypes\n+ * {Array(String)} To restrict transformation to a limited set of geometry\n+ * types, send a list of strings corresponding to the geometry class\n+ * names.\n */\n- DEFAULTS: {\n- tolerance: 10,\n- node: true,\n- edge: true,\n- vertex: true\n- },\n+ geometryTypes: null,\n \n /**\n- * Property: greedy\n- * {Boolean} Snap to closest feature in first layer with an eligible\n- * feature. Default is true.\n+ * Property: layer\n+ * {}\n */\n- greedy: true,\n+ layer: null,\n \n /**\n- * Property: precedence\n- * {Array} List representing precedence of different snapping types.\n- * Default is \"node\", \"vertex\", \"edge\".\n+ * APIProperty: preserveAspectRatio\n+ * {Boolean} set to true to not change the feature's aspect ratio.\n */\n- precedence: [\"node\", \"vertex\", \"edge\"],\n+ preserveAspectRatio: false,\n \n /**\n- * Property: resolution\n- * {Float} The map resolution for the previously considered snap.\n+ * APIProperty: rotate\n+ * {Boolean} set to false if rotation should be disabled. Default is true.\n+ * To be passed with the constructor or set when the control is not\n+ * active.\n */\n- resolution: null,\n+ rotate: true,\n \n /**\n- * Property: geoToleranceCache\n- * {Object} A cache of geo-tolerances. Tolerance values (in map units) are\n- * calculated when the map resolution changes.\n+ * APIProperty: feature\n+ * {} Feature currently available for\n+ * transformation. Read-only, use to set it manually.\n */\n- geoToleranceCache: null,\n+ feature: null,\n \n /**\n- * Property: layer\n- * {} The current editable layer. Set at\n- * construction or after construction with .\n+ * APIProperty: renderIntent\n+ * {String|Object} Render intent for the transformation box and\n+ * handles. A symbolizer object can also be provided here.\n */\n- layer: null,\n+ renderIntent: \"temporary\",\n \n /**\n- * Property: feature\n- * {} The current editable feature.\n+ * APIProperty: rotationHandleSymbolizer\n+ * {Object|String} Optional. A custom symbolizer for the rotation handles.\n+ * A render intent can also be provided here. Defaults to\n+ * (code)\n+ * {\n+ * stroke: false,\n+ * pointRadius: 10,\n+ * fillOpacity: 0,\n+ * cursor: \"pointer\"\n+ * }\n+ * (end)\n */\n- feature: null,\n+ rotationHandleSymbolizer: null,\n \n /**\n- * Property: point\n- * {} The currently snapped vertex.\n+ * APIProperty: box\n+ * {} The transformation box rectangle.\n+ * Read-only.\n */\n- point: null,\n+ box: null,\n \n /**\n- * Constructor: OpenLayers.Control.Snapping\n- * Creates a new snapping control. A control is constructed with an editable\n- * layer and a set of configuration objects for target layers. While the\n- * control is active, dragging vertices while drawing new features or\n- * modifying existing features on the editable layer will engage\n- * snapping to features on the target layers. Whether a vertex snaps to\n- * a feature on a target layer depends on the target layer configuration.\n- *\n- * Parameters:\n- * options - {Object} An object containing all configuration properties for\n- * the control.\n- *\n- * Valid options:\n- * layer - {} The editable layer. Features from this\n- * layer that are digitized or modified may have vertices snapped to\n- * features from any of the target layers.\n- * targets - {Array(Object | OpenLayers.Layer.Vector)} A list of objects for\n- * configuring target layers. See valid properties of the target\n- * objects below. If the items in the targets list are vector layers\n- * (instead of configuration objects), the defaults from the \n- * property will apply. The editable layer itself may be a target\n- * layer, allowing newly created or edited features to be snapped to\n- * existing features from the same layer. If no targets are provided\n- * the layer given in the constructor (as ) will become the\n- * initial target.\n- * defaults - {Object} An object with default properties to be applied\n- * to all target objects.\n- * greedy - {Boolean} Snap to closest feature in first target layer that\n- * applies. Default is true. If false, all features in all target\n- * layers will be checked and the closest feature in all target layers\n- * will be chosen. The greedy property determines if the order of the\n- * target layers is significant. By default, the order of the target\n- * layers is significant where layers earlier in the target layer list\n- * have precedence over layers later in the list. Within a single\n- * layer, the closest feature is always chosen for snapping. This\n- * property only determines whether the search for a closer feature\n- * continues after an eligible feature is found in a target layer.\n- *\n- * Valid target properties:\n- * layer - {} A target layer. Features from this\n- * layer will be eligible to act as snapping target for the editable\n- * layer.\n- * tolerance - {Float} The distance (in pixels) at which snapping may occur.\n- * Default is 10.\n- * node - {Boolean} Snap to nodes (first or last point in a geometry) in\n- * target layer. Default is true.\n- * nodeTolerance - {Float} Optional distance at which snapping may occur\n- * for nodes specifically. If none is provided, will be\n- * used.\n- * vertex - {Boolean} Snap to vertices in target layer. Default is true.\n- * vertexTolerance - {Float} Optional distance at which snapping may occur\n- * for vertices specifically. If none is provided, will be\n- * used.\n- * edge - {Boolean} Snap to edges in target layer. Default is true.\n- * edgeTolerance - {Float} Optional distance at which snapping may occur\n- * for edges specifically. If none is provided, will be\n- * used.\n- * filter - {} Optional filter to evaluate to determine if\n- * feature is eligible for snapping. If filter evaluates to true for a\n- * target feature a vertex may be snapped to the feature. \n- * minResolution - {Number} If a minResolution is provided, snapping to this\n- * target will only be considered if the map resolution is greater than\n- * or equal to this value (the minResolution is inclusive). Default is\n- * no minimum resolution limit.\n- * maxResolution - {Number} If a maxResolution is provided, snapping to this\n- * target will only be considered if the map resolution is strictly\n- * less than this value (the maxResolution is exclusive). Default is\n- * no maximum resolution limit.\n+ * APIProperty: center\n+ * {} The center of the feature bounds.\n+ * Read-only.\n */\n- initialize: function(options) {\n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n- this.options = options || {}; // TODO: this could be done by the super\n+ center: null,\n \n- // set the editable layer if provided\n- if (this.options.layer) {\n- this.setLayer(this.options.layer);\n- }\n- // configure target layers\n- var defaults = OpenLayers.Util.extend({}, this.options.defaults);\n- this.defaults = OpenLayers.Util.applyDefaults(defaults, this.DEFAULTS);\n- this.setTargets(this.options.targets);\n- if (this.targets.length === 0 && this.layer) {\n- this.addTargetLayer(this.layer);\n- }\n+ /**\n+ * APIProperty: scale\n+ * {Float} The scale of the feature, relative to the scale the time the\n+ * feature was set. Read-only, except for *beforesetfeature*\n+ * listeners.\n+ */\n+ scale: 1,\n \n- this.geoToleranceCache = {};\n- },\n+ /**\n+ * APIProperty: ratio\n+ * {Float} The ratio of the feature relative to the ratio the time the\n+ * feature was set. Read-only, except for *beforesetfeature*\n+ * listeners.\n+ */\n+ ratio: 1,\n \n /**\n- * APIMethod: setLayer\n- * Set the editable layer. Call the setLayer method if the editable layer\n- * changes and the same control should be used on a new editable layer.\n- * If the control is already active, it will be active after the new\n- * layer is set.\n- *\n- * Parameters:\n- * layer - {} The new editable layer.\n+ * Property: rotation\n+ * {Integer} the current rotation angle of the box. Read-only, except for\n+ * *beforesetfeature* listeners.\n */\n- setLayer: function(layer) {\n- if (this.active) {\n- this.deactivate();\n- this.layer = layer;\n- this.activate();\n- } else {\n- this.layer = layer;\n- }\n- },\n+ rotation: 0,\n \n /**\n- * Method: setTargets\n- * Set the targets for the snapping agent.\n- *\n- * Parameters:\n- * targets - {Array} An array of target configs or target layers.\n+ * APIProperty: handles\n+ * {Array()} The 8 handles currently available\n+ * for scaling/resizing. Numbered counterclockwise, starting from the\n+ * southwest corner. Read-only.\n */\n- setTargets: function(targets) {\n- this.targets = [];\n- if (targets && targets.length) {\n- var target;\n- for (var i = 0, len = targets.length; i < len; ++i) {\n- target = targets[i];\n- if (target instanceof OpenLayers.Layer.Vector) {\n- this.addTargetLayer(target);\n- } else {\n- this.addTarget(target);\n- }\n- }\n- }\n- },\n+ handles: null,\n \n /**\n- * Method: addTargetLayer\n- * Add a target layer with the default target config.\n- *\n- * Parameters:\n- * layer - {} A target layer.\n+ * APIProperty: rotationHandles\n+ * {Array()} The 4 rotation handles currently\n+ * available for rotating. Numbered counterclockwise, starting from\n+ * the southwest corner. Read-only.\n */\n- addTargetLayer: function(layer) {\n- this.addTarget({\n- layer: layer\n- });\n- },\n+ rotationHandles: null,\n \n /**\n- * Method: addTarget\n- * Add a configured target layer.\n- *\n- * Parameters:\n- * target - {Object} A target config.\n+ * Property: dragControl\n+ * {}\n */\n- addTarget: function(target) {\n- target = OpenLayers.Util.applyDefaults(target, this.defaults);\n- target.nodeTolerance = target.nodeTolerance || target.tolerance;\n- target.vertexTolerance = target.vertexTolerance || target.tolerance;\n- target.edgeTolerance = target.edgeTolerance || target.tolerance;\n- this.targets.push(target);\n- },\n+ dragControl: null,\n \n /**\n- * Method: removeTargetLayer\n- * Remove a target layer.\n- *\n- * Parameters:\n- * layer - {} The target layer to remove.\n+ * APIProperty: irregular\n+ * {Boolean} Make scaling/resizing work irregularly. If true then\n+ * dragging a handle causes the feature to resize in the direction\n+ * of movement. If false then the feature resizes symetrically\n+ * about it's center.\n */\n- removeTargetLayer: function(layer) {\n- var target;\n- for (var i = this.targets.length - 1; i >= 0; --i) {\n- target = this.targets[i];\n- if (target.layer === layer) {\n- this.removeTarget(target);\n- }\n- }\n- },\n+ irregular: false,\n \n /**\n- * Method: removeTarget\n- * Remove a target.\n+ * Constructor: OpenLayers.Control.TransformFeature\n+ * Create a new transform feature control.\n *\n * Parameters:\n- * target - {Object} A target config.\n- *\n- * Returns:\n- * {Array} The targets array.\n+ * layer - {} Layer that contains features that\n+ * will be transformed.\n+ * options - {Object} Optional object whose properties will be set on the\n+ * control.\n */\n- removeTarget: function(target) {\n- return OpenLayers.Util.removeItem(this.targets, target);\n+ initialize: function(layer, options) {\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+\n+ this.layer = layer;\n+\n+ if (!this.rotationHandleSymbolizer) {\n+ this.rotationHandleSymbolizer = {\n+ stroke: false,\n+ pointRadius: 10,\n+ fillOpacity: 0,\n+ cursor: \"pointer\"\n+ };\n+ }\n+\n+ this.createBox();\n+ this.createControl();\n },\n \n /**\n * APIMethod: activate\n- * Activate the control. Activating the control registers listeners for\n- * editing related events so that during feature creation and\n- * modification, moving vertices will trigger snapping.\n+ * Activates the control.\n */\n activate: function() {\n- var activated = OpenLayers.Control.prototype.activate.call(this);\n- if (activated) {\n- if (this.layer && this.layer.events) {\n- this.layer.events.on({\n- sketchstarted: this.onSketchModified,\n- sketchmodified: this.onSketchModified,\n- vertexmodified: this.onVertexModified,\n- scope: this\n- });\n- }\n+ var activated = false;\n+ if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {\n+ this.dragControl.activate();\n+ this.layer.addFeatures([this.box]);\n+ this.rotate && this.layer.addFeatures(this.rotationHandles);\n+ this.layer.addFeatures(this.handles);\n+ activated = true;\n }\n return activated;\n },\n \n /**\n * APIMethod: deactivate\n- * Deactivate the control. Deactivating the control unregisters listeners\n- * so feature editing may proceed without engaging the snapping agent.\n+ * Deactivates the control.\n */\n deactivate: function() {\n- var deactivated = OpenLayers.Control.prototype.deactivate.call(this);\n- if (deactivated) {\n- if (this.layer && this.layer.events) {\n- this.layer.events.un({\n- sketchstarted: this.onSketchModified,\n- sketchmodified: this.onSketchModified,\n- vertexmodified: this.onVertexModified,\n- scope: this\n- });\n- }\n+ var deactivated = false;\n+ if (OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {\n+ this.layer.removeFeatures(this.handles);\n+ this.rotate && this.layer.removeFeatures(this.rotationHandles);\n+ this.layer.removeFeatures([this.box]);\n+ this.dragControl.deactivate();\n+ deactivated = true;\n }\n- this.feature = null;\n- this.point = null;\n return deactivated;\n },\n \n /**\n- * Method: onSketchModified\n- * Registered as a listener for the sketchmodified event on the editable\n- * layer.\n- *\n+ * Method: setMap\n+ * \n * Parameters:\n- * event - {Object} The sketch modified event.\n+ * map - {}\n */\n- onSketchModified: function(event) {\n- this.feature = event.feature;\n- this.considerSnapping(event.vertex, event.vertex);\n+ setMap: function(map) {\n+ this.dragControl.setMap(map);\n+ OpenLayers.Control.prototype.setMap.apply(this, arguments);\n },\n \n /**\n- * Method: onVertexModified\n- * Registered as a listener for the vertexmodified event on the editable\n- * layer.\n- *\n+ * APIMethod: setFeature\n+ * Place the transformation box on a feature and start transforming it.\n+ * If the control is not active, it will be activated.\n+ * \n * Parameters:\n- * event - {Object} The vertex modified event.\n+ * feature - {}\n+ * initialParams - {Object} Initial values for rotation, scale or ratio.\n+ * Setting a rotation value here will cause the transformation box to\n+ * start rotated. Setting a scale or ratio will not affect the\n+ * transormation box, but applications may use this to keep track of\n+ * scale and ratio of a feature across multiple transforms.\n */\n- onVertexModified: function(event) {\n- this.feature = event.feature;\n- var loc = this.layer.map.getLonLatFromViewPortPx(event.pixel);\n- this.considerSnapping(\n- event.vertex, new OpenLayers.Geometry.Point(loc.lon, loc.lat)\n- );\n+ setFeature: function(feature, initialParams) {\n+ initialParams = OpenLayers.Util.applyDefaults(initialParams, {\n+ rotation: 0,\n+ scale: 1,\n+ ratio: 1\n+ });\n+\n+ var oldRotation = this.rotation;\n+ var oldCenter = this.center;\n+ OpenLayers.Util.extend(this, initialParams);\n+\n+ var cont = this.events.triggerEvent(\"beforesetfeature\", {\n+ feature: feature\n+ });\n+ if (cont === false) {\n+ return;\n+ }\n+\n+ this.feature = feature;\n+ this.activate();\n+\n+ this._setfeature = true;\n+\n+ var featureBounds = this.feature.geometry.getBounds();\n+ this.box.move(featureBounds.getCenterLonLat());\n+ this.box.geometry.rotate(-oldRotation, oldCenter);\n+ this._angle = 0;\n+\n+ var ll;\n+ if (this.rotation) {\n+ var geom = feature.geometry.clone();\n+ geom.rotate(-this.rotation, this.center);\n+ var box = new OpenLayers.Feature.Vector(\n+ geom.getBounds().toGeometry());\n+ box.geometry.rotate(this.rotation, this.center);\n+ this.box.geometry.rotate(this.rotation, this.center);\n+ this.box.move(box.geometry.getBounds().getCenterLonLat());\n+ var llGeom = box.geometry.components[0].components[0];\n+ ll = llGeom.getBounds().getCenterLonLat();\n+ } else {\n+ ll = new OpenLayers.LonLat(featureBounds.left, featureBounds.bottom);\n+ }\n+ this.handles[0].move(ll);\n+\n+ delete this._setfeature;\n+\n+ this.events.triggerEvent(\"setfeature\", {\n+ feature: feature\n+ });\n },\n \n /**\n- * Method: considerSnapping\n- *\n- * Parameters:\n- * point - {} The vertex to be snapped (or\n- * unsnapped).\n- * loc - {} The location of the mouse in map\n- * coords.\n+ * APIMethod: unsetFeature\n+ * Remove the transformation box off any feature.\n+ * If the control is active, it will be deactivated first.\n */\n- considerSnapping: function(point, loc) {\n- var best = {\n- rank: Number.POSITIVE_INFINITY,\n- dist: Number.POSITIVE_INFINITY,\n- x: null,\n- y: null\n+ unsetFeature: function() {\n+ if (this.active) {\n+ this.deactivate();\n+ } else {\n+ this.feature = null;\n+ this.rotation = 0;\n+ this.scale = 1;\n+ this.ratio = 1;\n+ }\n+ },\n+\n+ /**\n+ * Method: createBox\n+ * Creates the box with all handles and transformation handles.\n+ */\n+ createBox: function() {\n+ var control = this;\n+\n+ this.center = new OpenLayers.Geometry.Point(0, 0);\n+ this.box = new OpenLayers.Feature.Vector(\n+ new OpenLayers.Geometry.LineString([\n+ new OpenLayers.Geometry.Point(-1, -1),\n+ new OpenLayers.Geometry.Point(0, -1),\n+ new OpenLayers.Geometry.Point(1, -1),\n+ new OpenLayers.Geometry.Point(1, 0),\n+ new OpenLayers.Geometry.Point(1, 1),\n+ new OpenLayers.Geometry.Point(0, 1),\n+ new OpenLayers.Geometry.Point(-1, 1),\n+ new OpenLayers.Geometry.Point(-1, 0),\n+ new OpenLayers.Geometry.Point(-1, -1)\n+ ]), null,\n+ typeof this.renderIntent == \"string\" ? null : this.renderIntent\n+ );\n+\n+ // Override for box move - make sure that the center gets updated\n+ this.box.geometry.move = function(x, y) {\n+ control._moving = true;\n+ OpenLayers.Geometry.LineString.prototype.move.apply(this, arguments);\n+ control.center.move(x, y);\n+ delete control._moving;\n };\n- var snapped = false;\n- var result, target;\n- for (var i = 0, len = this.targets.length; i < len; ++i) {\n- target = this.targets[i];\n- result = this.testTarget(target, loc);\n- if (result) {\n- if (this.greedy) {\n- best = result;\n- best.target = target;\n- snapped = true;\n- break;\n- } else {\n- if ((result.rank < best.rank) ||\n- (result.rank === best.rank && result.dist < best.dist)) {\n- best = result;\n- best.target = target;\n- snapped = true;\n- }\n- }\n+\n+ // Overrides for vertex move, resize and rotate - make sure that\n+ // handle and rotationHandle geometries are also moved, resized and\n+ // rotated.\n+ var vertexMoveFn = function(x, y) {\n+ OpenLayers.Geometry.Point.prototype.move.apply(this, arguments);\n+ this._rotationHandle && this._rotationHandle.geometry.move(x, y);\n+ this._handle.geometry.move(x, y);\n+ };\n+ var vertexResizeFn = function(scale, center, ratio) {\n+ OpenLayers.Geometry.Point.prototype.resize.apply(this, arguments);\n+ this._rotationHandle && this._rotationHandle.geometry.resize(\n+ scale, center, ratio);\n+ this._handle.geometry.resize(scale, center, ratio);\n+ };\n+ var vertexRotateFn = function(angle, center) {\n+ OpenLayers.Geometry.Point.prototype.rotate.apply(this, arguments);\n+ this._rotationHandle && this._rotationHandle.geometry.rotate(\n+ angle, center);\n+ this._handle.geometry.rotate(angle, center);\n+ };\n+\n+ // Override for handle move - make sure that the box and other handles\n+ // are updated, and finally transform the feature.\n+ var handleMoveFn = function(x, y) {\n+ var oldX = this.x,\n+ oldY = this.y;\n+ OpenLayers.Geometry.Point.prototype.move.call(this, x, y);\n+ if (control._moving) {\n+ return;\n }\n- }\n- if (snapped) {\n- var proceed = this.events.triggerEvent(\"beforesnap\", {\n- point: point,\n- x: best.x,\n- y: best.y,\n- distance: best.dist,\n- layer: best.target.layer,\n- snapType: this.precedence[best.rank]\n- });\n- if (proceed !== false) {\n- point.x = best.x;\n- point.y = best.y;\n- this.point = point;\n- this.events.triggerEvent(\"snap\", {\n- point: point,\n- snapType: this.precedence[best.rank],\n- layer: best.target.layer,\n- distance: best.dist\n- });\n+ var evt = control.dragControl.handlers.drag.evt;\n+ var preserveAspectRatio = !control._setfeature &&\n+ control.preserveAspectRatio;\n+ var reshape = !preserveAspectRatio && !(evt && evt.shiftKey);\n+ var oldGeom = new OpenLayers.Geometry.Point(oldX, oldY);\n+ var centerGeometry = control.center;\n+ this.rotate(-control.rotation, centerGeometry);\n+ oldGeom.rotate(-control.rotation, centerGeometry);\n+ var dx1 = this.x - centerGeometry.x;\n+ var dy1 = this.y - centerGeometry.y;\n+ var dx0 = dx1 - (this.x - oldGeom.x);\n+ var dy0 = dy1 - (this.y - oldGeom.y);\n+ if (control.irregular && !control._setfeature) {\n+ dx1 -= (this.x - oldGeom.x) / 2;\n+ dy1 -= (this.y - oldGeom.y) / 2;\n+ }\n+ this.x = oldX;\n+ this.y = oldY;\n+ var scale, ratio = 1;\n+ if (reshape) {\n+ scale = Math.abs(dy0) < 0.00001 ? 1 : dy1 / dy0;\n+ ratio = (Math.abs(dx0) < 0.00001 ? 1 : (dx1 / dx0)) / scale;\n } else {\n- snapped = false;\n+ var l0 = Math.sqrt((dx0 * dx0) + (dy0 * dy0));\n+ var l1 = Math.sqrt((dx1 * dx1) + (dy1 * dy1));\n+ scale = l1 / l0;\n }\n- }\n- if (this.point && !snapped) {\n- point.x = loc.x;\n- point.y = loc.y;\n- this.point = null;\n- this.events.triggerEvent(\"unsnap\", {\n- point: point\n+\n+ // rotate the box to 0 before resizing - saves us some\n+ // calculations and is inexpensive because we don't drawFeature.\n+ control._moving = true;\n+ control.box.geometry.rotate(-control.rotation, centerGeometry);\n+ delete control._moving;\n+\n+ control.box.geometry.resize(scale, centerGeometry, ratio);\n+ control.box.geometry.rotate(control.rotation, centerGeometry);\n+ control.transformFeature({\n+ scale: scale,\n+ ratio: ratio\n });\n+ if (control.irregular && !control._setfeature) {\n+ var newCenter = centerGeometry.clone();\n+ newCenter.x += Math.abs(oldX - centerGeometry.x) < 0.00001 ? 0 : (this.x - oldX);\n+ newCenter.y += Math.abs(oldY - centerGeometry.y) < 0.00001 ? 0 : (this.y - oldY);\n+ control.box.geometry.move(this.x - oldX, this.y - oldY);\n+ control.transformFeature({\n+ center: newCenter\n+ });\n+ }\n+ };\n+\n+ // Override for rotation handle move - make sure that the box and\n+ // other handles are updated, and finally transform the feature.\n+ var rotationHandleMoveFn = function(x, y) {\n+ var oldX = this.x,\n+ oldY = this.y;\n+ OpenLayers.Geometry.Point.prototype.move.call(this, x, y);\n+ if (control._moving) {\n+ return;\n+ }\n+ var evt = control.dragControl.handlers.drag.evt;\n+ var constrain = (evt && evt.shiftKey) ? 45 : 1;\n+ var centerGeometry = control.center;\n+ var dx1 = this.x - centerGeometry.x;\n+ var dy1 = this.y - centerGeometry.y;\n+ var dx0 = dx1 - x;\n+ var dy0 = dy1 - y;\n+ this.x = oldX;\n+ this.y = oldY;\n+ var a0 = Math.atan2(dy0, dx0);\n+ var a1 = Math.atan2(dy1, dx1);\n+ var angle = a1 - a0;\n+ angle *= 180 / Math.PI;\n+ control._angle = (control._angle + angle) % 360;\n+ var diff = control.rotation % constrain;\n+ if (Math.abs(control._angle) >= constrain || diff !== 0) {\n+ angle = Math.round(control._angle / constrain) * constrain -\n+ diff;\n+ control._angle = 0;\n+ control.box.geometry.rotate(angle, centerGeometry);\n+ control.transformFeature({\n+ rotation: angle\n+ });\n+ }\n+ };\n+\n+ var handles = new Array(8);\n+ var rotationHandles = new Array(4);\n+ var geom, handle, rotationHandle;\n+ var positions = [\"sw\", \"s\", \"se\", \"e\", \"ne\", \"n\", \"nw\", \"w\"];\n+ for (var i = 0; i < 8; ++i) {\n+ geom = this.box.geometry.components[i];\n+ handle = new OpenLayers.Feature.Vector(geom.clone(), {\n+ role: positions[i] + \"-resize\"\n+ }, typeof this.renderIntent == \"string\" ? null :\n+ this.renderIntent);\n+ if (i % 2 == 0) {\n+ rotationHandle = new OpenLayers.Feature.Vector(geom.clone(), {\n+ role: positions[i] + \"-rotate\"\n+ }, typeof this.rotationHandleSymbolizer == \"string\" ?\n+ null : this.rotationHandleSymbolizer);\n+ rotationHandle.geometry.move = rotationHandleMoveFn;\n+ geom._rotationHandle = rotationHandle;\n+ rotationHandles[i / 2] = rotationHandle;\n+ }\n+ geom.move = vertexMoveFn;\n+ geom.resize = vertexResizeFn;\n+ geom.rotate = vertexRotateFn;\n+ handle.geometry.move = handleMoveFn;\n+ geom._handle = handle;\n+ handles[i] = handle;\n }\n+\n+ this.rotationHandles = rotationHandles;\n+ this.handles = handles;\n },\n \n /**\n- * Method: testTarget\n- *\n- * Parameters:\n- * target - {Object} Object with target layer configuration.\n- * loc - {} The location of the mouse in map\n- * coords.\n- *\n- * Returns:\n- * {Object} A result object with rank, dist, x, and y properties.\n- * Returns null if candidate is not eligible for snapping.\n+ * Method: createControl\n+ * Creates a DragFeature control for this control.\n */\n- testTarget: function(target, loc) {\n- var resolution = this.layer.map.getResolution();\n- if (\"minResolution\" in target) {\n- if (resolution < target.minResolution) {\n- return null;\n- }\n- }\n- if (\"maxResolution\" in target) {\n- if (resolution >= target.maxResolution) {\n- return null;\n- }\n- }\n- var tolerance = {\n- node: this.getGeoTolerance(target.nodeTolerance, resolution),\n- vertex: this.getGeoTolerance(target.vertexTolerance, resolution),\n- edge: this.getGeoTolerance(target.edgeTolerance, resolution)\n- };\n- // this could be cached if we don't support setting tolerance values directly\n- var maxTolerance = Math.max(\n- tolerance.node, tolerance.vertex, tolerance.edge\n- );\n- var result = {\n- rank: Number.POSITIVE_INFINITY,\n- dist: Number.POSITIVE_INFINITY\n- };\n- var eligible = false;\n- var features = target.layer.features;\n- var feature, type, vertices, vertex, closest, dist, found;\n- var numTypes = this.precedence.length;\n- var ll = new OpenLayers.LonLat(loc.x, loc.y);\n- for (var i = 0, len = features.length; i < len; ++i) {\n- feature = features[i];\n- if (feature !== this.feature && !feature._sketch &&\n- feature.state !== OpenLayers.State.DELETE &&\n- (!target.filter || target.filter.evaluate(feature))) {\n- if (feature.atPoint(ll, maxTolerance, maxTolerance)) {\n- for (var j = 0, stop = Math.min(result.rank + 1, numTypes); j < stop; ++j) {\n- type = this.precedence[j];\n- if (target[type]) {\n- if (type === \"edge\") {\n- closest = feature.geometry.distanceTo(loc, {\n- details: true\n- });\n- dist = closest.distance;\n- if (dist <= tolerance[type] && dist < result.dist) {\n- result = {\n- rank: j,\n- dist: dist,\n- x: closest.x0,\n- y: closest.y0 // closest coords on feature\n- };\n- eligible = true;\n- // don't look for lower precedence types for this feature\n- break;\n- }\n- } else {\n- // look for nodes or vertices\n- vertices = feature.geometry.getVertices(type === \"node\");\n- found = false;\n- for (var k = 0, klen = vertices.length; k < klen; ++k) {\n- vertex = vertices[k];\n- dist = vertex.distanceTo(loc);\n- if (dist <= tolerance[type] &&\n- (j < result.rank || (j === result.rank && dist < result.dist))) {\n- result = {\n- rank: j,\n- dist: dist,\n- x: vertex.x,\n- y: vertex.y\n- };\n- eligible = true;\n- found = true;\n- }\n- }\n- if (found) {\n- // don't look for lower precedence types for this feature\n- break;\n- }\n- }\n- }\n- }\n+ createControl: function() {\n+ var control = this;\n+ this.dragControl = new OpenLayers.Control.DragFeature(this.layer, {\n+ documentDrag: true,\n+ // avoid moving the feature itself - move the box instead\n+ moveFeature: function(pixel) {\n+ if (this.feature === control.feature) {\n+ this.feature = control.box;\n+ }\n+ OpenLayers.Control.DragFeature.prototype.moveFeature.apply(this,\n+ arguments);\n+ },\n+ // transform while dragging\n+ onDrag: function(feature, pixel) {\n+ if (feature === control.box) {\n+ control.transformFeature({\n+ center: control.center\n+ });\n+ }\n+ },\n+ // set a new feature\n+ onStart: function(feature, pixel) {\n+ var eligible = !control.geometryTypes ||\n+ OpenLayers.Util.indexOf(control.geometryTypes,\n+ feature.geometry.CLASS_NAME) !== -1;\n+ var i = OpenLayers.Util.indexOf(control.handles, feature);\n+ i += OpenLayers.Util.indexOf(control.rotationHandles,\n+ feature);\n+ if (feature !== control.feature && feature !== control.box &&\n+ i == -2 && eligible) {\n+ control.setFeature(feature);\n }\n+ },\n+ onComplete: function(feature, pixel) {\n+ control.events.triggerEvent(\"transformcomplete\", {\n+ feature: control.feature\n+ });\n+ }\n+ });\n+ },\n+\n+ /**\n+ * Method: drawHandles\n+ * Draws the handles to match the box.\n+ */\n+ drawHandles: function() {\n+ var layer = this.layer;\n+ for (var i = 0; i < 8; ++i) {\n+ if (this.rotate && i % 2 === 0) {\n+ layer.drawFeature(this.rotationHandles[i / 2],\n+ this.rotationHandleSymbolizer);\n }\n+ layer.drawFeature(this.handles[i], this.renderIntent);\n }\n- return eligible ? result : null;\n },\n \n /**\n- * Method: getGeoTolerance\n- * Calculate a tolerance in map units given a tolerance in pixels. This\n- * takes advantage of the when the map resolution\n- * has not changed.\n- * \n+ * Method: transformFeature\n+ * Transforms the feature.\n+ * \n * Parameters:\n- * tolerance - {Number} A tolerance value in pixels.\n- * resolution - {Number} Map resolution.\n- *\n- * Returns:\n- * {Number} A tolerance value in map units.\n+ * mods - {Object} An object with optional scale, ratio, rotation and\n+ * center properties.\n */\n- getGeoTolerance: function(tolerance, resolution) {\n- if (resolution !== this.resolution) {\n- this.resolution = resolution;\n- this.geoToleranceCache = {};\n- }\n- var geoTolerance = this.geoToleranceCache[tolerance];\n- if (geoTolerance === undefined) {\n- geoTolerance = tolerance * resolution;\n- this.geoToleranceCache[tolerance] = geoTolerance;\n+ transformFeature: function(mods) {\n+ if (!this._setfeature) {\n+ this.scale *= (mods.scale || 1);\n+ this.ratio *= (mods.ratio || 1);\n+ var oldRotation = this.rotation;\n+ this.rotation = (this.rotation + (mods.rotation || 0)) % 360;\n+\n+ if (this.events.triggerEvent(\"beforetransform\", mods) !== false) {\n+ var feature = this.feature;\n+ var geom = feature.geometry;\n+ var center = this.center;\n+ geom.rotate(-oldRotation, center);\n+ if (mods.scale || mods.ratio) {\n+ geom.resize(mods.scale, center, mods.ratio);\n+ } else if (mods.center) {\n+ feature.move(mods.center.getBounds().getCenterLonLat());\n+ }\n+ geom.rotate(this.rotation, center);\n+ this.layer.drawFeature(feature);\n+ feature.toState(OpenLayers.State.UPDATE);\n+ this.events.triggerEvent(\"transform\", mods);\n+ }\n }\n- return geoTolerance;\n+ this.layer.drawFeature(this.box, this.renderIntent);\n+ this.drawHandles();\n },\n \n /**\n- * Method: destroy\n- * Clean up the control.\n+ * APIMethod: destroy\n+ * Take care of things that are not handled in superclass.\n */\n destroy: function() {\n- if (this.active) {\n- this.deactivate(); // TODO: this should be handled by the super\n+ var geom;\n+ for (var i = 0; i < 8; ++i) {\n+ geom = this.box.geometry.components[i];\n+ geom._handle.destroy();\n+ geom._handle = null;\n+ geom._rotationHandle && geom._rotationHandle.destroy();\n+ geom._rotationHandle = null;\n }\n- delete this.layer;\n- delete this.targets;\n- OpenLayers.Control.prototype.destroy.call(this);\n+ this.center = null;\n+ this.feature = null;\n+ this.handles = null;\n+ this.rotationHandleSymbolizer = null;\n+ this.rotationHandles = null;\n+ this.box.destroy();\n+ this.box = null;\n+ this.layer = null;\n+ this.dragControl.destroy();\n+ this.dragControl = null;\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n },\n \n- CLASS_NAME: \"OpenLayers.Control.Snapping\"\n+ CLASS_NAME: \"OpenLayers.Control.TransformFeature\"\n });\n /* ======================================================================\n- OpenLayers/Control/LayerSwitcher.js\n+ OpenLayers/Control/Scale.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n * @requires OpenLayers/Control.js\n * @requires OpenLayers/Lang.js\n- * @requires OpenLayers/Util.js\n- * @requires OpenLayers/Events/buttonclick.js\n */\n \n /**\n- * Class: OpenLayers.Control.LayerSwitcher\n- * The LayerSwitcher control displays a table of contents for the map. This\n- * allows the user interface to switch between BaseLasyers and to show or hide\n- * Overlays. By default the switcher is shown minimized on the right edge of\n- * the map, the user may expand it by clicking on the handle.\n- *\n- * To create the LayerSwitcher outside of the map, pass the Id of a html div\n- * as the first argument to the constructor.\n+ * Class: OpenLayers.Control.Scale\n+ * The Scale control displays the current map scale as a ratio (e.g. Scale = \n+ * 1:1M). By default it is displayed in the lower right corner of the map.\n *\n * Inherits from:\n * - \n */\n-OpenLayers.Control.LayerSwitcher = OpenLayers.Class(OpenLayers.Control, {\n-\n- /** \n- * Property: layerStates \n- * {Array(Object)} Basically a copy of the \"state\" of the map's layers \n- * the last time the control was drawn. We have this in order to avoid\n- * unnecessarily redrawing the control.\n- */\n- layerStates: null,\n-\n- // DOM Elements\n-\n- /**\n- * Property: layersDiv\n- * {DOMElement}\n- */\n- layersDiv: null,\n-\n- /**\n- * Property: baseLayersDiv\n- * {DOMElement}\n- */\n- baseLayersDiv: null,\n-\n- /**\n- * Property: baseLayers\n- * {Array(Object)}\n- */\n- baseLayers: null,\n-\n-\n- /**\n- * Property: dataLbl\n- * {DOMElement}\n- */\n- dataLbl: null,\n-\n- /**\n- * Property: dataLayersDiv\n- * {DOMElement}\n- */\n- dataLayersDiv: null,\n-\n- /**\n- * Property: dataLayers\n- * {Array(Object)}\n- */\n- dataLayers: null,\n-\n-\n- /**\n- * Property: minimizeDiv\n- * {DOMElement}\n- */\n- minimizeDiv: null,\n+OpenLayers.Control.Scale = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * Property: maximizeDiv\n+ * Property: element\n * {DOMElement}\n */\n- maximizeDiv: null,\n+ element: null,\n \n /**\n- * APIProperty: ascending\n- * {Boolean}\n+ * APIProperty: geodesic\n+ * {Boolean} Use geodesic measurement. Default is false. The recommended\n+ * setting for maps in EPSG:4326 is false, and true EPSG:900913. If set to\n+ * true, the scale will be calculated based on the horizontal size of the\n+ * pixel in the center of the map viewport.\n */\n- ascending: true,\n+ geodesic: false,\n \n /**\n- * Constructor: OpenLayers.Control.LayerSwitcher\n- *\n+ * Constructor: OpenLayers.Control.Scale\n+ * \n * Parameters:\n- * options - {Object}\n- */\n- initialize: function(options) {\n- OpenLayers.Control.prototype.initialize.apply(this, arguments);\n- this.layerStates = [];\n- },\n-\n- /**\n- * APIMethod: destroy\n- */\n- destroy: function() {\n-\n- //clear out layers info and unregister their events\n- this.clearLayersArray(\"base\");\n- this.clearLayersArray(\"data\");\n-\n- this.map.events.un({\n- buttonclick: this.onButtonClick,\n- addlayer: this.redraw,\n- changelayer: this.redraw,\n- removelayer: this.redraw,\n- changebaselayer: this.redraw,\n- scope: this\n- });\n- this.events.unregister(\"buttonclick\", this, this.onButtonClick);\n-\n- OpenLayers.Control.prototype.destroy.apply(this, arguments);\n- },\n-\n- /**\n- * Method: setMap\n- *\n- * Properties:\n- * map - {}\n+ * element - {DOMElement} \n+ * options - {Object} \n */\n- setMap: function(map) {\n- OpenLayers.Control.prototype.setMap.apply(this, arguments);\n-\n- this.map.events.on({\n- addlayer: this.redraw,\n- changelayer: this.redraw,\n- removelayer: this.redraw,\n- changebaselayer: this.redraw,\n- scope: this\n- });\n- if (this.outsideViewport) {\n- this.events.attachToElement(this.div);\n- this.events.register(\"buttonclick\", this, this.onButtonClick);\n- } else {\n- this.map.events.register(\"buttonclick\", this, this.onButtonClick);\n- }\n+ initialize: function(element, options) {\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+ this.element = OpenLayers.Util.getElement(element);\n },\n \n /**\n * Method: draw\n- *\n+ * \n * Returns:\n- * {DOMElement} A reference to the DIV DOMElement containing the\n- * switcher tabs.\n+ * {DOMElement}\n */\n draw: function() {\n- OpenLayers.Control.prototype.draw.apply(this);\n-\n- // create layout divs\n- this.loadContents();\n-\n- // set mode to minimize\n- if (!this.outsideViewport) {\n- this.minimizeControl();\n+ OpenLayers.Control.prototype.draw.apply(this, arguments);\n+ if (!this.element) {\n+ this.element = document.createElement(\"div\");\n+ this.div.appendChild(this.element);\n }\n-\n- // populate div with current info\n- this.redraw();\n-\n+ this.map.events.register('moveend', this, this.updateScale);\n+ this.updateScale();\n return this.div;\n },\n \n /**\n- * Method: onButtonClick\n- *\n- * Parameters:\n- * evt - {Event}\n+ * Method: updateScale\n */\n- onButtonClick: function(evt) {\n- var button = evt.buttonElement;\n- if (button === this.minimizeDiv) {\n- this.minimizeControl();\n- } else if (button === this.maximizeDiv) {\n- this.maximizeControl();\n- } else if (button._layerSwitcher === this.id) {\n- if (button[\"for\"]) {\n- button = document.getElementById(button[\"for\"]);\n- }\n- if (!button.disabled) {\n- if (button.type == \"radio\") {\n- button.checked = true;\n- this.map.setBaseLayer(this.map.getLayer(button._layer));\n- } else {\n- button.checked = !button.checked;\n- this.updateMap();\n- }\n+ updateScale: function() {\n+ var scale;\n+ if (this.geodesic === true) {\n+ var units = this.map.getUnits();\n+ if (!units) {\n+ return;\n }\n+ var inches = OpenLayers.INCHES_PER_UNIT;\n+ scale = (this.map.getGeodesicPixelSize().w || 0.000001) *\n+ inches[\"km\"] * OpenLayers.DOTS_PER_INCH;\n+ } else {\n+ scale = this.map.getScale();\n }\n- },\n \n- /**\n- * Method: clearLayersArray\n- * User specifies either \"base\" or \"data\". we then clear all the\n- * corresponding listeners, the div, and reinitialize a new array.\n- *\n- * Parameters:\n- * layersType - {String}\n- */\n- clearLayersArray: function(layersType) {\n- this[layersType + \"LayersDiv\"].innerHTML = \"\";\n- this[layersType + \"Layers\"] = [];\n- },\n-\n-\n- /**\n- * Method: checkRedraw\n- * Checks if the layer state has changed since the last redraw() call.\n- *\n- * Returns:\n- * {Boolean} The layer state changed since the last redraw() call.\n- */\n- checkRedraw: function() {\n- if (!this.layerStates.length ||\n- (this.map.layers.length != this.layerStates.length)) {\n- return true;\n+ if (!scale) {\n+ return;\n }\n \n- for (var i = 0, len = this.layerStates.length; i < len; i++) {\n- var layerState = this.layerStates[i];\n- var layer = this.map.layers[i];\n- if ((layerState.name != layer.name) ||\n- (layerState.inRange != layer.inRange) ||\n- (layerState.id != layer.id) ||\n- (layerState.visibility != layer.visibility)) {\n- return true;\n- }\n+ if (scale >= 9500 && scale <= 950000) {\n+ scale = Math.round(scale / 1000) + \"K\";\n+ } else if (scale >= 950000) {\n+ scale = Math.round(scale / 1000000) + \"M\";\n+ } else {\n+ scale = Math.round(scale);\n }\n \n- return false;\n+ this.element.innerHTML = OpenLayers.i18n(\"Scale = 1 : ${scaleDenom}\", {\n+ 'scaleDenom': scale\n+ });\n },\n \n- /**\n- * Method: redraw\n- * Goes through and takes the current state of the Map and rebuilds the\n- * control to display that state. Groups base layers into a\n- * radio-button group and lists each data layer with a checkbox.\n- *\n- * Returns:\n- * {DOMElement} A reference to the DIV DOMElement containing the control\n- */\n- redraw: function() {\n- //if the state hasn't changed since last redraw, no need\n- // to do anything. Just return the existing div.\n- if (!this.checkRedraw()) {\n- return this.div;\n- }\n+ CLASS_NAME: \"OpenLayers.Control.Scale\"\n+});\n \n- //clear out previous layers\n- this.clearLayersArray(\"base\");\n- this.clearLayersArray(\"data\");\n+/* ======================================================================\n+ OpenLayers/Control/Attribution.js\n+ ====================================================================== */\n \n- var containsOverlays = false;\n- var containsBaseLayers = false;\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- // Save state -- for checking layer if the map state changed.\n- // We save this before redrawing, because in the process of redrawing\n- // we will trigger more visibility changes, and we want to not redraw\n- // and enter an infinite loop.\n- var len = this.map.layers.length;\n- this.layerStates = new Array(len);\n- for (var i = 0; i < len; i++) {\n- var layer = this.map.layers[i];\n- this.layerStates[i] = {\n- 'name': layer.name,\n- 'visibility': layer.visibility,\n- 'inRange': layer.inRange,\n- 'id': layer.id\n- };\n- }\n+/**\n+ * @requires OpenLayers/Control.js\n+ */\n \n- var layers = this.map.layers.slice();\n- if (!this.ascending) {\n- layers.reverse();\n- }\n- for (var i = 0, len = layers.length; i < len; i++) {\n- var layer = layers[i];\n- var baseLayer = layer.isBaseLayer;\n+/**\n+ * Class: OpenLayers.Control.Attribution\n+ * The attribution control adds attribution from layers to the map display. \n+ * It uses 'attribution' property of each layer.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Control.Attribution =\n+ OpenLayers.Class(OpenLayers.Control, {\n \n- if (layer.displayInLayerSwitcher) {\n+ /**\n+ * APIProperty: separator\n+ * {String} String used to separate layers.\n+ */\n+ separator: \", \",\n \n- if (baseLayer) {\n- containsBaseLayers = true;\n- } else {\n- containsOverlays = true;\n- }\n+ /**\n+ * APIProperty: template\n+ * {String} Template for the attribution. This has to include the substring\n+ * \"${layers}\", which will be replaced by the layer specific\n+ * attributions, separated by . The default is \"${layers}\".\n+ */\n+ template: \"${layers}\",\n \n- // only check a baselayer if it is *the* baselayer, check data\n- // layers if they are visible\n- var checked = (baseLayer) ? (layer == this.map.baseLayer) :\n- layer.getVisibility();\n+ /**\n+ * Constructor: OpenLayers.Control.Attribution \n+ * \n+ * Parameters:\n+ * options - {Object} Options for control.\n+ */\n \n- // create input element\n- var inputElem = document.createElement(\"input\"),\n- // The input shall have an id attribute so we can use\n- // labels to interact with them.\n- inputId = OpenLayers.Util.createUniqueID(\n- this.id + \"_input_\"\n- );\n+ /** \n+ * Method: destroy\n+ * Destroy control.\n+ */\n+ destroy: function() {\n+ this.map.events.un({\n+ \"removelayer\": this.updateAttribution,\n+ \"addlayer\": this.updateAttribution,\n+ \"changelayer\": this.updateAttribution,\n+ \"changebaselayer\": this.updateAttribution,\n+ scope: this\n+ });\n \n- inputElem.id = inputId;\n- inputElem.name = (baseLayer) ? this.id + \"_baseLayers\" : layer.name;\n- inputElem.type = (baseLayer) ? \"radio\" : \"checkbox\";\n- inputElem.value = layer.name;\n- inputElem.checked = checked;\n- inputElem.defaultChecked = checked;\n- inputElem.className = \"olButton\";\n- inputElem._layer = layer.id;\n- inputElem._layerSwitcher = this.id;\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n+ },\n \n- if (!baseLayer && !layer.inRange) {\n- inputElem.disabled = true;\n- }\n+ /**\n+ * Method: draw\n+ * Initialize control.\n+ * \n+ * Returns: \n+ * {DOMElement} A reference to the DIV DOMElement containing the control\n+ */\n+ draw: function() {\n+ OpenLayers.Control.prototype.draw.apply(this, arguments);\n \n- // create span\n- var labelSpan = document.createElement(\"label\");\n- // this isn't the DOM attribute 'for', but an arbitrary name we\n- // use to find the appropriate input element in \n- labelSpan[\"for\"] = inputElem.id;\n- OpenLayers.Element.addClass(labelSpan, \"labelSpan olButton\");\n- labelSpan._layer = layer.id;\n- labelSpan._layerSwitcher = this.id;\n- if (!baseLayer && !layer.inRange) {\n- labelSpan.style.color = \"gray\";\n- }\n- labelSpan.innerHTML = layer.name;\n- labelSpan.style.verticalAlign = (baseLayer) ? \"bottom\" :\n- \"baseline\";\n- // create line break\n- var br = document.createElement(\"br\");\n+ this.map.events.on({\n+ 'changebaselayer': this.updateAttribution,\n+ 'changelayer': this.updateAttribution,\n+ 'addlayer': this.updateAttribution,\n+ 'removelayer': this.updateAttribution,\n+ scope: this\n+ });\n+ this.updateAttribution();\n \n+ return this.div;\n+ },\n \n- var groupArray = (baseLayer) ? this.baseLayers :\n- this.dataLayers;\n- groupArray.push({\n- 'layer': layer,\n- 'inputElem': inputElem,\n- 'labelSpan': labelSpan\n+ /**\n+ * Method: updateAttribution\n+ * Update attribution string.\n+ */\n+ updateAttribution: function() {\n+ var attributions = [];\n+ if (this.map && this.map.layers) {\n+ for (var i = 0, len = this.map.layers.length; i < len; i++) {\n+ var layer = this.map.layers[i];\n+ if (layer.attribution && layer.getVisibility()) {\n+ // add attribution only if attribution text is unique\n+ if (OpenLayers.Util.indexOf(\n+ attributions, layer.attribution) === -1) {\n+ attributions.push(layer.attribution);\n+ }\n+ }\n+ }\n+ this.div.innerHTML = OpenLayers.String.format(this.template, {\n+ layers: attributions.join(this.separator)\n });\n-\n-\n- var groupDiv = (baseLayer) ? this.baseLayersDiv :\n- this.dataLayersDiv;\n- groupDiv.appendChild(inputElem);\n- groupDiv.appendChild(labelSpan);\n- groupDiv.appendChild(br);\n }\n- }\n+ },\n \n- // if no overlays, dont display the overlay label\n- this.dataLbl.style.display = (containsOverlays) ? \"\" : \"none\";\n+ CLASS_NAME: \"OpenLayers.Control.Attribution\"\n+ });\n+/* ======================================================================\n+ OpenLayers/Control/ZoomOut.js\n+ ====================================================================== */\n \n- // if no baselayers, dont display the baselayer label\n- this.baseLbl.style.display = (containsBaseLayers) ? \"\" : \"none\";\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- return this.div;\n- },\n+/**\n+ * @requires OpenLayers/Control/Button.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Control.ZoomOut\n+ * The ZoomOut control is a button to decrease the zoom level of a map.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Control.ZoomOut = OpenLayers.Class(OpenLayers.Control.Button, {\n \n /**\n- * Method: updateMap\n- * Cycles through the loaded data and base layer input arrays and makes\n- * the necessary calls to the Map object such that that the map's\n- * visual state corresponds to what the user has selected in\n- * the control.\n+ * Method: trigger\n */\n- updateMap: function() {\n-\n- // set the newly selected base layer\n- for (var i = 0, len = this.baseLayers.length; i < len; i++) {\n- var layerEntry = this.baseLayers[i];\n- if (layerEntry.inputElem.checked) {\n- this.map.setBaseLayer(layerEntry.layer, false);\n- }\n+ trigger: function() {\n+ if (this.map) {\n+ this.map.zoomOut();\n }\n+ },\n \n- // set the correct visibilities for the overlays\n- for (var i = 0, len = this.dataLayers.length; i < len; i++) {\n- var layerEntry = this.dataLayers[i];\n- layerEntry.layer.setVisibility(layerEntry.inputElem.checked);\n- }\n+ CLASS_NAME: \"OpenLayers.Control.ZoomOut\"\n+});\n+/* ======================================================================\n+ OpenLayers/Control/Zoom.js\n+ ====================================================================== */\n \n- },\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Events/buttonclick.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Control.Zoom\n+ * The Zoom control is a pair of +/- links for zooming in and out.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Control.Zoom = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * Method: maximizeControl\n- * Set up the labels and divs for the control\n- *\n- * Parameters:\n- * e - {Event}\n+ * APIProperty: zoomInText\n+ * {String}\n+ * Text for zoom-in link. Default is \"+\".\n */\n- maximizeControl: function(e) {\n+ zoomInText: \"+\",\n \n- // set the div's width and height to empty values, so\n- // the div dimensions can be controlled by CSS\n- this.div.style.width = \"\";\n- this.div.style.height = \"\";\n+ /**\n+ * APIProperty: zoomInId\n+ * {String}\n+ * Instead of having the control create a zoom in link, you can provide \n+ * the identifier for an anchor element already added to the document.\n+ * By default, an element with id \"olZoomInLink\" will be searched for\n+ * and used if it exists.\n+ */\n+ zoomInId: \"olZoomInLink\",\n \n- this.showControls(false);\n+ /**\n+ * APIProperty: zoomOutText\n+ * {String}\n+ * Text for zoom-out link. Default is \"\\u2212\".\n+ */\n+ zoomOutText: \"\\u2212\",\n \n- if (e != null) {\n- OpenLayers.Event.stop(e);\n- }\n- },\n+ /**\n+ * APIProperty: zoomOutId\n+ * {String}\n+ * Instead of having the control create a zoom out link, you can provide \n+ * the identifier for an anchor element already added to the document.\n+ * By default, an element with id \"olZoomOutLink\" will be searched for\n+ * and used if it exists.\n+ */\n+ zoomOutId: \"olZoomOutLink\",\n \n /**\n- * Method: minimizeControl\n- * Hide all the contents of the control, shrink the size,\n- * add the maximize icon\n+ * Method: draw\n *\n- * Parameters:\n- * e - {Event}\n+ * Returns:\n+ * {DOMElement} A reference to the DOMElement containing the zoom links.\n */\n- minimizeControl: function(e) {\n-\n- // to minimize the control we set its div's width\n- // and height to 0px, we cannot just set \"display\"\n- // to \"none\" because it would hide the maximize\n- // div\n- this.div.style.width = \"0px\";\n- this.div.style.height = \"0px\";\n-\n- this.showControls(true);\n+ draw: function() {\n+ var div = OpenLayers.Control.prototype.draw.apply(this),\n+ links = this.getOrCreateLinks(div),\n+ zoomIn = links.zoomIn,\n+ zoomOut = links.zoomOut,\n+ eventsInstance = this.map.events;\n \n- if (e != null) {\n- OpenLayers.Event.stop(e);\n+ if (zoomOut.parentNode !== div) {\n+ eventsInstance = this.events;\n+ eventsInstance.attachToElement(zoomOut.parentNode);\n }\n+ eventsInstance.register(\"buttonclick\", this, this.onZoomClick);\n+\n+ this.zoomInLink = zoomIn;\n+ this.zoomOutLink = zoomOut;\n+ return div;\n },\n \n /**\n- * Method: showControls\n- * Hide/Show all LayerSwitcher controls depending on whether we are\n- * minimized or not\n- *\n+ * Method: getOrCreateLinks\n+ * \n * Parameters:\n- * minimize - {Boolean}\n+ * el - {DOMElement}\n+ *\n+ * Return: \n+ * {Object} Object with zoomIn and zoomOut properties referencing links.\n */\n- showControls: function(minimize) {\n-\n- this.maximizeDiv.style.display = minimize ? \"\" : \"none\";\n- this.minimizeDiv.style.display = minimize ? \"none\" : \"\";\n-\n- this.layersDiv.style.display = minimize ? \"none\" : \"\";\n+ getOrCreateLinks: function(el) {\n+ var zoomIn = document.getElementById(this.zoomInId),\n+ zoomOut = document.getElementById(this.zoomOutId);\n+ if (!zoomIn) {\n+ zoomIn = document.createElement(\"a\");\n+ zoomIn.href = \"#zoomIn\";\n+ zoomIn.appendChild(document.createTextNode(this.zoomInText));\n+ zoomIn.className = \"olControlZoomIn\";\n+ el.appendChild(zoomIn);\n+ }\n+ OpenLayers.Element.addClass(zoomIn, \"olButton\");\n+ if (!zoomOut) {\n+ zoomOut = document.createElement(\"a\");\n+ zoomOut.href = \"#zoomOut\";\n+ zoomOut.appendChild(document.createTextNode(this.zoomOutText));\n+ zoomOut.className = \"olControlZoomOut\";\n+ el.appendChild(zoomOut);\n+ }\n+ OpenLayers.Element.addClass(zoomOut, \"olButton\");\n+ return {\n+ zoomIn: zoomIn,\n+ zoomOut: zoomOut\n+ };\n },\n \n /**\n- * Method: loadContents\n- * Set up the labels and divs for the control\n+ * Method: onZoomClick\n+ * Called when zoomin/out link is clicked.\n */\n- loadContents: function() {\n-\n- // layers list div\n- this.layersDiv = document.createElement(\"div\");\n- this.layersDiv.id = this.id + \"_layersDiv\";\n- OpenLayers.Element.addClass(this.layersDiv, \"layersDiv\");\n-\n- this.baseLbl = document.createElement(\"div\");\n- this.baseLbl.innerHTML = OpenLayers.i18n(\"Base Layer\");\n- OpenLayers.Element.addClass(this.baseLbl, \"baseLbl\");\n-\n- this.baseLayersDiv = document.createElement(\"div\");\n- OpenLayers.Element.addClass(this.baseLayersDiv, \"baseLayersDiv\");\n-\n- this.dataLbl = document.createElement(\"div\");\n- this.dataLbl.innerHTML = OpenLayers.i18n(\"Overlays\");\n- OpenLayers.Element.addClass(this.dataLbl, \"dataLbl\");\n-\n- this.dataLayersDiv = document.createElement(\"div\");\n- OpenLayers.Element.addClass(this.dataLayersDiv, \"dataLayersDiv\");\n-\n- if (this.ascending) {\n- this.layersDiv.appendChild(this.baseLbl);\n- this.layersDiv.appendChild(this.baseLayersDiv);\n- this.layersDiv.appendChild(this.dataLbl);\n- this.layersDiv.appendChild(this.dataLayersDiv);\n- } else {\n- this.layersDiv.appendChild(this.dataLbl);\n- this.layersDiv.appendChild(this.dataLayersDiv);\n- this.layersDiv.appendChild(this.baseLbl);\n- this.layersDiv.appendChild(this.baseLayersDiv);\n+ onZoomClick: function(evt) {\n+ var button = evt.buttonElement;\n+ if (button === this.zoomInLink) {\n+ this.map.zoomIn();\n+ } else if (button === this.zoomOutLink) {\n+ this.map.zoomOut();\n }\n+ },\n \n- this.div.appendChild(this.layersDiv);\n-\n- // maximize button div\n- var img = OpenLayers.Util.getImageLocation('layer-switcher-maximize.png');\n- this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(\n- \"OpenLayers_Control_MaximizeDiv\",\n- null,\n- null,\n- img,\n- \"absolute\");\n- OpenLayers.Element.addClass(this.maximizeDiv, \"maximizeDiv olButton\");\n- this.maximizeDiv.style.display = \"none\";\n-\n- this.div.appendChild(this.maximizeDiv);\n-\n- // minimize button div\n- var img = OpenLayers.Util.getImageLocation('layer-switcher-minimize.png');\n- this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv(\n- \"OpenLayers_Control_MinimizeDiv\",\n- null,\n- null,\n- img,\n- \"absolute\");\n- OpenLayers.Element.addClass(this.minimizeDiv, \"minimizeDiv olButton\");\n- this.minimizeDiv.style.display = \"none\";\n-\n- this.div.appendChild(this.minimizeDiv);\n+ /** \n+ * Method: destroy\n+ * Clean up.\n+ */\n+ destroy: function() {\n+ if (this.map) {\n+ this.map.events.unregister(\"buttonclick\", this, this.onZoomClick);\n+ }\n+ delete this.zoomInLink;\n+ delete this.zoomOutLink;\n+ OpenLayers.Control.prototype.destroy.apply(this);\n },\n \n- CLASS_NAME: \"OpenLayers.Control.LayerSwitcher\"\n+ CLASS_NAME: \"OpenLayers.Control.Zoom\"\n });\n /* ======================================================================\n- OpenLayers/Control/ArgParser.js\n+ OpenLayers/Handler/Click.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Handler.js\n */\n \n /**\n- * Class: OpenLayers.Control.ArgParser\n- * The ArgParser control adds location bar query string parsing functionality \n- * to an OpenLayers Map.\n- * When added to a Map control, on a page load/refresh, the Map will \n- * automatically take the href string and parse it for lon, lat, zoom, and \n- * layers information. \n- *\n+ * Class: OpenLayers.Handler.Click\n+ * A handler for mouse clicks. The intention of this handler is to give\n+ * controls more flexibility with handling clicks. Browsers trigger\n+ * click events twice for a double-click. In addition, the mousedown,\n+ * mousemove, mouseup sequence fires a click event. With this handler,\n+ * controls can decide whether to ignore clicks associated with a double\n+ * click. By setting a , controls can also ignore clicks\n+ * that include a drag. Create a new instance with the\n+ * constructor.\n+ * \n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Control.ArgParser = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Handler.Click = OpenLayers.Class(OpenLayers.Handler, {\n+ /**\n+ * APIProperty: delay\n+ * {Number} Number of milliseconds between clicks before the event is\n+ * considered a double-click.\n+ */\n+ delay: 300,\n \n /**\n- * Property: center\n- * {}\n+ * APIProperty: single\n+ * {Boolean} Handle single clicks. Default is true. If false, clicks\n+ * will not be reported. If true, single-clicks will be reported.\n */\n- center: null,\n+ single: true,\n \n /**\n- * Property: zoom\n- * {int}\n+ * APIProperty: double\n+ * {Boolean} Handle double-clicks. Default is false.\n */\n- zoom: null,\n+ 'double': false,\n \n /**\n- * Property: layers\n- * {String} Each character represents the state of the corresponding layer \n- * on the map.\n+ * APIProperty: pixelTolerance\n+ * {Number} Maximum number of pixels between mouseup and mousedown for an\n+ * event to be considered a click. Default is 0. If set to an\n+ * integer value, clicks with a drag greater than the value will be\n+ * ignored. This property can only be set when the handler is\n+ * constructed.\n */\n- layers: null,\n+ pixelTolerance: 0,\n+\n+ /**\n+ * APIProperty: dblclickTolerance\n+ * {Number} Maximum distance in pixels between clicks for a sequence of \n+ * events to be considered a double click. Default is 13. If the\n+ * distance between two clicks is greater than this value, a double-\n+ * click will not be fired.\n+ */\n+ dblclickTolerance: 13,\n+\n+ /**\n+ * APIProperty: stopSingle\n+ * {Boolean} Stop other listeners from being notified of clicks. Default\n+ * is false. If true, any listeners registered before this one for \n+ * click or rightclick events will not be notified.\n+ */\n+ stopSingle: false,\n+\n+ /**\n+ * APIProperty: stopDouble\n+ * {Boolean} Stop other listeners from being notified of double-clicks.\n+ * Default is false. If true, any click listeners registered before\n+ * this one will not be notified of *any* double-click events.\n+ * \n+ * The one caveat with stopDouble is that given a map with two click\n+ * handlers, one with stopDouble true and the other with stopSingle\n+ * true, the stopSingle handler should be activated last to get\n+ * uniform cross-browser performance. Since IE triggers one click\n+ * with a dblclick and FF triggers two, if a stopSingle handler is\n+ * activated first, all it gets in IE is a single click when the\n+ * second handler stops propagation on the dblclick.\n+ */\n+ stopDouble: false,\n+\n+ /**\n+ * Property: timerId\n+ * {Number} The id of the timeout waiting to clear the .\n+ */\n+ timerId: null,\n+\n+ /**\n+ * Property: down\n+ * {Object} Object that store relevant information about the last\n+ * mousedown or touchstart. Its 'xy' OpenLayers.Pixel property gives\n+ * the average location of the mouse/touch event. Its 'touches'\n+ * property records clientX/clientY of each touches.\n+ */\n+ down: null,\n+\n+ /**\n+ * Property: last\n+ * {Object} Object that store relevant information about the last\n+ * mousemove or touchmove. Its 'xy' OpenLayers.Pixel property gives\n+ * the average location of the mouse/touch event. Its 'touches'\n+ * property records clientX/clientY of each touches.\n+ */\n+ last: null,\n \n /** \n- * APIProperty: displayProjection\n- * {} Requires proj4js support. \n- * Projection used when reading the coordinates from the URL. This will\n- * reproject the map coordinates from the URL into the map's\n- * projection.\n- *\n- * If you are using this functionality, be aware that any permalink\n- * which is added to the map will determine the coordinate type which\n- * is read from the URL, which means you should not add permalinks with\n- * different displayProjections to the same map. \n+ * Property: first\n+ * {Object} When waiting for double clicks, this object will store \n+ * information about the first click in a two click sequence.\n */\n- displayProjection: null,\n+ first: null,\n \n /**\n- * Constructor: OpenLayers.Control.ArgParser\n- *\n+ * Property: rightclickTimerId\n+ * {Number} The id of the right mouse timeout waiting to clear the \n+ * .\n+ */\n+ rightclickTimerId: null,\n+\n+ /**\n+ * Constructor: OpenLayers.Handler.Click\n+ * Create a new click handler.\n+ * \n * Parameters:\n- * options - {Object}\n+ * control - {} The control that is making use of\n+ * this handler. If a handler is being used without a control, the\n+ * handler's setMap method must be overridden to deal properly with\n+ * the map.\n+ * callbacks - {Object} An object with keys corresponding to callbacks\n+ * that will be called by the handler. The callbacks should\n+ * expect to recieve a single argument, the click event.\n+ * Callbacks for 'click' and 'dblclick' are supported.\n+ * options - {Object} Optional object whose properties will be set on the\n+ * handler.\n */\n \n /**\n- * Method: getParameters\n+ * Method: touchstart\n+ * Handle touchstart.\n+ *\n+ * Returns:\n+ * {Boolean} Continue propagating this event.\n */\n- getParameters: function(url) {\n- url = url || window.location.href;\n- var parameters = OpenLayers.Util.getParameters(url);\n+ touchstart: function(evt) {\n+ this.startTouch();\n+ this.down = this.getEventInfo(evt);\n+ this.last = this.getEventInfo(evt);\n+ return true;\n+ },\n \n- // If we have an anchor in the url use it to split the url\n- var index = url.indexOf('#');\n- if (index > 0) {\n- // create an url to parse on the getParameters\n- url = '?' + url.substring(index + 1, url.length);\n+ /**\n+ * Method: touchmove\n+ * Store position of last move, because touchend event can have\n+ * an empty \"touches\" property.\n+ *\n+ * Returns:\n+ * {Boolean} Continue propagating this event.\n+ */\n+ touchmove: function(evt) {\n+ this.last = this.getEventInfo(evt);\n+ return true;\n+ },\n \n- OpenLayers.Util.extend(parameters,\n- OpenLayers.Util.getParameters(url));\n+ /**\n+ * Method: touchend\n+ * Correctly set event xy property, and add lastTouches to have\n+ * touches property from last touchstart or touchmove\n+ *\n+ * Returns:\n+ * {Boolean} Continue propagating this event.\n+ */\n+ touchend: function(evt) {\n+ // touchstart may not have been allowed to propagate\n+ if (this.down) {\n+ evt.xy = this.last.xy;\n+ evt.lastTouches = this.last.touches;\n+ this.handleSingle(evt);\n+ this.down = null;\n }\n- return parameters;\n+ return true;\n },\n \n /**\n- * Method: setMap\n- * Set the map property for the control. \n+ * Method: mousedown\n+ * Handle mousedown.\n+ *\n+ * Returns:\n+ * {Boolean} Continue propagating this event.\n+ */\n+ mousedown: function(evt) {\n+ this.down = this.getEventInfo(evt);\n+ this.last = this.getEventInfo(evt);\n+ return true;\n+ },\n+\n+ /**\n+ * Method: mouseup\n+ * Handle mouseup. Installed to support collection of right mouse events.\n * \n- * Parameters:\n- * map - {} \n+ * Returns:\n+ * {Boolean} Continue propagating this event.\n */\n- setMap: function(map) {\n- OpenLayers.Control.prototype.setMap.apply(this, arguments);\n+ mouseup: function(evt) {\n+ var propagate = true;\n \n- //make sure we dont already have an arg parser attached\n- for (var i = 0, len = this.map.controls.length; i < len; i++) {\n- var control = this.map.controls[i];\n- if ((control != this) &&\n- (control.CLASS_NAME == \"OpenLayers.Control.ArgParser\")) {\n+ // Collect right mouse clicks from the mouseup\n+ // IE - ignores the second right click in mousedown so using\n+ // mouseup instead\n+ if (this.checkModifiers(evt) && this.control.handleRightClicks &&\n+ OpenLayers.Event.isRightClick(evt)) {\n+ propagate = this.rightclick(evt);\n+ }\n \n- // If a second argparser is added to the map, then we \n- // override the displayProjection to be the one added to the\n- // map. \n- if (control.displayProjection != this.displayProjection) {\n- this.displayProjection = control.displayProjection;\n- }\n+ return propagate;\n+ },\n \n- break;\n+ /**\n+ * Method: rightclick\n+ * Handle rightclick. For a dblrightclick, we get two clicks so we need \n+ * to always register for dblrightclick to properly handle single \n+ * clicks.\n+ * \n+ * Returns:\n+ * {Boolean} Continue propagating this event.\n+ */\n+ rightclick: function(evt) {\n+ if (this.passesTolerance(evt)) {\n+ if (this.rightclickTimerId != null) {\n+ //Second click received before timeout this must be \n+ // a double click\n+ this.clearTimer();\n+ this.callback('dblrightclick', [evt]);\n+ return !this.stopDouble;\n+ } else {\n+ //Set the rightclickTimerId, send evt only if double is \n+ // true else trigger single\n+ var clickEvent = this['double'] ?\n+ OpenLayers.Util.extend({}, evt) :\n+ this.callback('rightclick', [evt]);\n+\n+ var delayedRightCall = OpenLayers.Function.bind(\n+ this.delayedRightCall,\n+ this,\n+ clickEvent\n+ );\n+ this.rightclickTimerId = window.setTimeout(\n+ delayedRightCall, this.delay\n+ );\n }\n }\n- if (i == this.map.controls.length) {\n+ return !this.stopSingle;\n+ },\n \n- var args = this.getParameters();\n- // Be careful to set layer first, to not trigger unnecessary layer loads\n- if (args.layers) {\n- this.layers = args.layers;\n+ /**\n+ * Method: delayedRightCall\n+ * Sets to null. And optionally triggers the \n+ * rightclick callback if evt is set.\n+ */\n+ delayedRightCall: function(evt) {\n+ this.rightclickTimerId = null;\n+ if (evt) {\n+ this.callback('rightclick', [evt]);\n+ }\n+ },\n \n- // when we add a new layer, set its visibility \n- this.map.events.register('addlayer', this,\n- this.configureLayers);\n- this.configureLayers();\n- }\n- if (args.lat && args.lon) {\n- this.center = new OpenLayers.LonLat(parseFloat(args.lon),\n- parseFloat(args.lat));\n- if (args.zoom) {\n- this.zoom = parseFloat(args.zoom);\n- }\n+ /**\n+ * Method: click\n+ * Handle click events from the browser. This is registered as a listener\n+ * for click events and should not be called from other events in this\n+ * handler.\n+ *\n+ * Returns:\n+ * {Boolean} Continue propagating this event.\n+ */\n+ click: function(evt) {\n+ if (!this.last) {\n+ this.last = this.getEventInfo(evt);\n+ }\n+ this.handleSingle(evt);\n+ return !this.stopSingle;\n+ },\n \n- // when we add a new baselayer to see when we can set the center\n- this.map.events.register('changebaselayer', this,\n- this.setCenter);\n- this.setCenter();\n+ /**\n+ * Method: dblclick\n+ * Handle dblclick. For a dblclick, we get two clicks in some browsers\n+ * (FF) and one in others (IE). So we need to always register for\n+ * dblclick to properly handle single clicks. This method is registered\n+ * as a listener for the dblclick browser event. It should *not* be\n+ * called by other methods in this handler.\n+ * \n+ * Returns:\n+ * {Boolean} Continue propagating this event.\n+ */\n+ dblclick: function(evt) {\n+ this.handleDouble(evt);\n+ return !this.stopDouble;\n+ },\n+\n+ /** \n+ * Method: handleDouble\n+ * Handle double-click sequence.\n+ */\n+ handleDouble: function(evt) {\n+ if (this.passesDblclickTolerance(evt)) {\n+ if (this[\"double\"]) {\n+ this.callback(\"dblclick\", [evt]);\n }\n+ // to prevent a dblclick from firing the click callback in IE\n+ this.clearTimer();\n }\n },\n \n /** \n- * Method: setCenter\n- * As soon as a baseLayer has been loaded, we center and zoom\n- * ...and remove the handler.\n+ * Method: handleSingle\n+ * Handle single click sequence.\n */\n- setCenter: function() {\n+ handleSingle: function(evt) {\n+ if (this.passesTolerance(evt)) {\n+ if (this.timerId != null) {\n+ // already received a click\n+ if (this.last.touches && this.last.touches.length === 1) {\n+ // touch device, no dblclick event - this may be a double\n+ if (this[\"double\"]) {\n+ // on Android don't let the browser zoom on the page\n+ OpenLayers.Event.preventDefault(evt);\n+ }\n+ this.handleDouble(evt);\n+ }\n+ // if we're not in a touch environment we clear the click timer\n+ // if we've got a second touch, we'll get two touchend events\n+ if (!this.last.touches || this.last.touches.length !== 2) {\n+ this.clearTimer();\n+ }\n+ } else {\n+ // remember the first click info so we can compare to the second\n+ this.first = this.getEventInfo(evt);\n+ // set the timer, send evt only if single is true\n+ //use a clone of the event object because it will no longer \n+ //be a valid event object in IE in the timer callback\n+ var clickEvent = this.single ?\n+ OpenLayers.Util.extend({}, evt) : null;\n+ this.queuePotentialClick(clickEvent);\n+ }\n+ }\n+ },\n \n- if (this.map.baseLayer) {\n- //dont need to listen for this one anymore\n- this.map.events.unregister('changebaselayer', this,\n- this.setCenter);\n+ /** \n+ * Method: queuePotentialClick\n+ * This method is separated out largely to make testing easier (so we\n+ * don't have to override window.setTimeout)\n+ */\n+ queuePotentialClick: function(evt) {\n+ this.timerId = window.setTimeout(\n+ OpenLayers.Function.bind(this.delayedCall, this, evt),\n+ this.delay\n+ );\n+ },\n \n- if (this.displayProjection) {\n- this.center.transform(this.displayProjection,\n- this.map.getProjectionObject());\n+ /**\n+ * Method: passesTolerance\n+ * Determine whether the event is within the optional pixel tolerance. Note\n+ * that the pixel tolerance check only works if mousedown events get to\n+ * the listeners registered here. If they are stopped by other elements,\n+ * the will have no effect here (this method will always\n+ * return true).\n+ *\n+ * Returns:\n+ * {Boolean} The click is within the pixel tolerance (if specified).\n+ */\n+ passesTolerance: function(evt) {\n+ var passes = true;\n+ if (this.pixelTolerance != null && this.down && this.down.xy) {\n+ passes = this.pixelTolerance >= this.down.xy.distanceTo(evt.xy);\n+ // for touch environments, we also enforce that all touches\n+ // start and end within the given tolerance to be considered a click\n+ if (passes && this.touch &&\n+ this.down.touches.length === this.last.touches.length) {\n+ // the touchend event doesn't come with touches, so we check\n+ // down and last\n+ for (var i = 0, ii = this.down.touches.length; i < ii; ++i) {\n+ if (this.getTouchDistance(\n+ this.down.touches[i],\n+ this.last.touches[i]\n+ ) > this.pixelTolerance) {\n+ passes = false;\n+ break;\n+ }\n+ }\n }\n-\n- this.map.setCenter(this.center, this.zoom);\n }\n+ return passes;\n },\n \n /** \n- * Method: configureLayers\n- * As soon as all the layers are loaded, cycle through them and \n- * hide or show them. \n+ * Method: getTouchDistance\n+ *\n+ * Returns:\n+ * {Boolean} The pixel displacement between two touches.\n */\n- configureLayers: function() {\n+ getTouchDistance: function(from, to) {\n+ return Math.sqrt(\n+ Math.pow(from.clientX - to.clientX, 2) +\n+ Math.pow(from.clientY - to.clientY, 2)\n+ );\n+ },\n \n- if (this.layers.length == this.map.layers.length) {\n- this.map.events.unregister('addlayer', this, this.configureLayers);\n+ /**\n+ * Method: passesDblclickTolerance\n+ * Determine whether the event is within the optional double-cick pixel \n+ * tolerance.\n+ *\n+ * Returns:\n+ * {Boolean} The click is within the double-click pixel tolerance.\n+ */\n+ passesDblclickTolerance: function(evt) {\n+ var passes = true;\n+ if (this.down && this.first) {\n+ passes = this.down.xy.distanceTo(this.first.xy) <= this.dblclickTolerance;\n+ }\n+ return passes;\n+ },\n \n- for (var i = 0, len = this.layers.length; i < len; i++) {\n+ /**\n+ * Method: clearTimer\n+ * Clear the timer and set to null.\n+ */\n+ clearTimer: function() {\n+ if (this.timerId != null) {\n+ window.clearTimeout(this.timerId);\n+ this.timerId = null;\n+ }\n+ if (this.rightclickTimerId != null) {\n+ window.clearTimeout(this.rightclickTimerId);\n+ this.rightclickTimerId = null;\n+ }\n+ },\n \n- var layer = this.map.layers[i];\n- var c = this.layers.charAt(i);\n+ /**\n+ * Method: delayedCall\n+ * Sets to null. And optionally triggers the click callback if\n+ * evt is set.\n+ */\n+ delayedCall: function(evt) {\n+ this.timerId = null;\n+ if (evt) {\n+ this.callback(\"click\", [evt]);\n+ }\n+ },\n \n- if (c == \"B\") {\n- this.map.setBaseLayer(layer);\n- } else if ((c == \"T\") || (c == \"F\")) {\n- layer.setVisibility(c == \"T\");\n- }\n+ /**\n+ * Method: getEventInfo\n+ * This method allows us to store event information without storing the\n+ * actual event. In touch devices (at least), the same event is \n+ * modified between touchstart, touchmove, and touchend.\n+ *\n+ * Returns:\n+ * {Object} An object with event related info.\n+ */\n+ getEventInfo: function(evt) {\n+ var touches;\n+ if (evt.touches) {\n+ var len = evt.touches.length;\n+ touches = new Array(len);\n+ var touch;\n+ for (var i = 0; i < len; i++) {\n+ touch = evt.touches[i];\n+ touches[i] = {\n+ clientX: touch.olClientX,\n+ clientY: touch.olClientY\n+ };\n }\n }\n+ return {\n+ xy: evt.xy,\n+ touches: touches\n+ };\n },\n \n- CLASS_NAME: \"OpenLayers.Control.ArgParser\"\n+ /**\n+ * APIMethod: deactivate\n+ * Deactivate the handler.\n+ *\n+ * Returns:\n+ * {Boolean} The handler was successfully deactivated.\n+ */\n+ deactivate: function() {\n+ var deactivated = false;\n+ if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n+ this.clearTimer();\n+ this.down = null;\n+ this.first = null;\n+ this.last = null;\n+ deactivated = true;\n+ }\n+ return deactivated;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Handler.Click\"\n });\n /* ======================================================================\n- OpenLayers/Control/Permalink.js\n+ OpenLayers/Handler/Box.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Control/ArgParser.js\n- * @requires OpenLayers/Lang.js\n+ * @requires OpenLayers/Handler.js\n+ * @requires OpenLayers/Handler/Drag.js\n */\n \n /**\n- * Class: OpenLayers.Control.Permalink\n- * The Permalink control is hyperlink that will return the user to the \n- * current map view. By default it is drawn in the lower right corner of the\n- * map. The href is updated as the map is zoomed, panned and whilst layers\n- * are switched.\n- * \n+ * Class: OpenLayers.Handler.Box\n+ * Handler for dragging a rectangle across the map. Box is displayed \n+ * on mouse down, moves on mouse move, and is finished on mouse up.\n+ *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, {\n-\n- /**\n- * APIProperty: argParserClass\n- * {Class} The ArgParser control class (not instance) to use with this\n- * control.\n- */\n- argParserClass: OpenLayers.Control.ArgParser,\n-\n- /** \n- * Property: element \n- * {DOMElement}\n- */\n- element: null,\n+OpenLayers.Handler.Box = OpenLayers.Class(OpenLayers.Handler, {\n \n /** \n- * APIProperty: anchor\n- * {Boolean} This option changes 3 things:\n- * the character '#' is used in place of the character '?',\n- * the window.href is updated if no element is provided.\n- * When this option is set to true it's not recommend to provide\n- * a base without provide an element.\n+ * Property: dragHandler \n+ * {} \n */\n- anchor: false,\n+ dragHandler: null,\n \n- /** \n- * APIProperty: base\n- * {String}\n+ /**\n+ * APIProperty: boxDivClassName\n+ * {String} The CSS class to use for drawing the box. Default is\n+ * olHandlerBoxZoomBox\n */\n- base: '',\n+ boxDivClassName: 'olHandlerBoxZoomBox',\n \n- /** \n- * APIProperty: displayProjection\n- * {} Requires proj4js support. Projection used\n- * when creating the coordinates in the link. This will reproject the\n- * map coordinates into display coordinates. If you are using this\n- * functionality, the permalink which is last added to the map will\n- * determine the coordinate type which is read from the URL, which\n- * means you should not add permalinks with different\n- * displayProjections to the same map. \n+ /**\n+ * Property: boxOffsets\n+ * {Object} Caches box offsets from css. This is used by the getBoxOffsets\n+ * method.\n */\n- displayProjection: null,\n+ boxOffsets: null,\n \n /**\n- * Constructor: OpenLayers.Control.Permalink\n+ * Constructor: OpenLayers.Handler.Box\n *\n- * Parameters: \n- * element - {DOMElement} \n- * base - {String} \n- * options - {Object} options to the control.\n+ * Parameters:\n+ * control - {} \n+ * callbacks - {Object} An object with a properties whose values are\n+ * functions. Various callbacks described below.\n+ * options - {Object} \n *\n- * Or for anchor:\n- * options - {Object} options to the control.\n+ * Named callbacks:\n+ * start - Called when the box drag operation starts.\n+ * done - Called when the box drag operation is finished.\n+ * The callback should expect to receive a single argument, the box \n+ * bounds or a pixel. If the box dragging didn't span more than a 5 \n+ * pixel distance, a pixel will be returned instead of a bounds object.\n */\n- initialize: function(element, base, options) {\n- if (element !== null && typeof element == 'object' && !OpenLayers.Util.isElement(element)) {\n- options = element;\n- this.base = document.location.href;\n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n- if (this.element != null) {\n- this.element = OpenLayers.Util.getElement(this.element);\n+ initialize: function(control, callbacks, options) {\n+ OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n+ this.dragHandler = new OpenLayers.Handler.Drag(\n+ this, {\n+ down: this.startBox,\n+ move: this.moveBox,\n+ out: this.removeBox,\n+ up: this.endBox\n+ }, {\n+ keyMask: this.keyMask\n }\n- } else {\n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n- this.element = OpenLayers.Util.getElement(element);\n- this.base = base || document.location.href;\n- }\n+ );\n },\n \n /**\n- * APIMethod: destroy\n+ * Method: destroy\n */\n destroy: function() {\n- if (this.element && this.element.parentNode == this.div) {\n- this.div.removeChild(this.element);\n- this.element = null;\n- }\n- if (this.map) {\n- this.map.events.unregister('moveend', this, this.updateLink);\n+ OpenLayers.Handler.prototype.destroy.apply(this, arguments);\n+ if (this.dragHandler) {\n+ this.dragHandler.destroy();\n+ this.dragHandler = null;\n }\n-\n- OpenLayers.Control.prototype.destroy.apply(this, arguments);\n },\n \n /**\n * Method: setMap\n- * Set the map property for the control. \n- * \n- * Parameters:\n- * map - {} \n */\n setMap: function(map) {\n- OpenLayers.Control.prototype.setMap.apply(this, arguments);\n-\n- //make sure we have an arg parser attached\n- for (var i = 0, len = this.map.controls.length; i < len; i++) {\n- var control = this.map.controls[i];\n- if (control.CLASS_NAME == this.argParserClass.CLASS_NAME) {\n-\n- // If a permalink is added to the map, and an ArgParser already\n- // exists, we override the displayProjection to be the one\n- // on the permalink. \n- if (control.displayProjection != this.displayProjection) {\n- this.displayProjection = control.displayProjection;\n- }\n-\n- break;\n- }\n- }\n- if (i == this.map.controls.length) {\n- this.map.addControl(new this.argParserClass({\n- 'displayProjection': this.displayProjection\n- }));\n+ OpenLayers.Handler.prototype.setMap.apply(this, arguments);\n+ if (this.dragHandler) {\n+ this.dragHandler.setMap(map);\n }\n-\n },\n \n /**\n- * Method: draw\n+ * Method: startBox\n *\n- * Returns:\n- * {DOMElement}\n+ * Parameters:\n+ * xy - {}\n */\n- draw: function() {\n- OpenLayers.Control.prototype.draw.apply(this, arguments);\n-\n- if (!this.element && !this.anchor) {\n- this.element = document.createElement(\"a\");\n- this.element.innerHTML = OpenLayers.i18n(\"Permalink\");\n- this.element.href = \"\";\n- this.div.appendChild(this.element);\n- }\n- this.map.events.on({\n- 'moveend': this.updateLink,\n- 'changelayer': this.updateLink,\n- 'changebaselayer': this.updateLink,\n- scope: this\n+ startBox: function(xy) {\n+ this.callback(\"start\", []);\n+ this.zoomBox = OpenLayers.Util.createDiv('zoomBox', {\n+ x: -9999,\n+ y: -9999\n });\n+ this.zoomBox.className = this.boxDivClassName;\n+ this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE[\"Popup\"] - 1;\n \n- // Make it so there is at least a link even though the map may not have\n- // moved yet.\n- this.updateLink();\n+ this.map.viewPortDiv.appendChild(this.zoomBox);\n \n- return this.div;\n+ OpenLayers.Element.addClass(\n+ this.map.viewPortDiv, \"olDrawBox\"\n+ );\n },\n \n /**\n- * Method: updateLink \n+ * Method: moveBox\n */\n- updateLink: function() {\n- var separator = this.anchor ? '#' : '?';\n- var href = this.base;\n- var anchor = null;\n- if (href.indexOf(\"#\") != -1 && this.anchor == false) {\n- anchor = href.substring(href.indexOf(\"#\"), href.length);\n- }\n- if (href.indexOf(separator) != -1) {\n- href = href.substring(0, href.indexOf(separator));\n- }\n- var splits = href.split(\"#\");\n- href = splits[0] + separator + OpenLayers.Util.getParameterString(this.createParams());\n- if (anchor) {\n- href += anchor;\n- }\n- if (this.anchor && !this.element) {\n- window.location.href = href;\n- } else {\n- this.element.href = href;\n- }\n+ moveBox: function(xy) {\n+ var startX = this.dragHandler.start.x;\n+ var startY = this.dragHandler.start.y;\n+ var deltaX = Math.abs(startX - xy.x);\n+ var deltaY = Math.abs(startY - xy.y);\n+\n+ var offset = this.getBoxOffsets();\n+ this.zoomBox.style.width = (deltaX + offset.width + 1) + \"px\";\n+ this.zoomBox.style.height = (deltaY + offset.height + 1) + \"px\";\n+ this.zoomBox.style.left = (xy.x < startX ?\n+ startX - deltaX - offset.left : startX - offset.left) + \"px\";\n+ this.zoomBox.style.top = (xy.y < startY ?\n+ startY - deltaY - offset.top : startY - offset.top) + \"px\";\n },\n \n /**\n- * APIMethod: createParams\n- * Creates the parameters that need to be encoded into the permalink url.\n- * \n- * Parameters:\n- * center - {} center to encode in the permalink.\n- * Defaults to the current map center.\n- * zoom - {Integer} zoom level to encode in the permalink. Defaults to the\n- * current map zoom level.\n- * layers - {Array()} layers to encode in the permalink.\n- * Defaults to the current map layers.\n- * \n- * Returns:\n- * {Object} Hash of parameters that will be url-encoded into the\n- * permalink.\n+ * Method: endBox\n */\n- createParams: function(center, zoom, layers) {\n- center = center || this.map.getCenter();\n-\n- var params = OpenLayers.Util.getParameters(this.base);\n-\n- // If there's still no center, map is not initialized yet. \n- // Break out of this function, and simply return the params from the\n- // base link.\n- if (center) {\n+ endBox: function(end) {\n+ var result;\n+ if (Math.abs(this.dragHandler.start.x - end.x) > 5 ||\n+ Math.abs(this.dragHandler.start.y - end.y) > 5) {\n+ var start = this.dragHandler.start;\n+ var top = Math.min(start.y, end.y);\n+ var bottom = Math.max(start.y, end.y);\n+ var left = Math.min(start.x, end.x);\n+ var right = Math.max(start.x, end.x);\n+ result = new OpenLayers.Bounds(left, bottom, right, top);\n+ } else {\n+ result = this.dragHandler.start.clone(); // i.e. OL.Pixel\n+ }\n+ this.removeBox();\n \n- //zoom\n- params.zoom = zoom || this.map.getZoom();\n+ this.callback(\"done\", [result]);\n+ },\n \n- //lon,lat\n- var lat = center.lat;\n- var lon = center.lon;\n+ /**\n+ * Method: removeBox\n+ * Remove the zoombox from the screen and nullify our reference to it.\n+ */\n+ removeBox: function() {\n+ this.map.viewPortDiv.removeChild(this.zoomBox);\n+ this.zoomBox = null;\n+ this.boxOffsets = null;\n+ OpenLayers.Element.removeClass(\n+ this.map.viewPortDiv, \"olDrawBox\"\n+ );\n \n- if (this.displayProjection) {\n- var mapPosition = OpenLayers.Projection.transform({\n- x: lon,\n- y: lat\n- },\n- this.map.getProjectionObject(),\n- this.displayProjection);\n- lon = mapPosition.x;\n- lat = mapPosition.y;\n- }\n- params.lat = Math.round(lat * 100000) / 100000;\n- params.lon = Math.round(lon * 100000) / 100000;\n+ },\n \n- //layers \n- layers = layers || this.map.layers;\n- params.layers = '';\n- for (var i = 0, len = layers.length; i < len; i++) {\n- var layer = layers[i];\n+ /**\n+ * Method: activate\n+ */\n+ activate: function() {\n+ if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n+ this.dragHandler.activate();\n+ return true;\n+ } else {\n+ return false;\n+ }\n+ },\n \n- if (layer.isBaseLayer) {\n- params.layers += (layer == this.map.baseLayer) ? \"B\" : \"0\";\n- } else {\n- params.layers += (layer.getVisibility()) ? \"T\" : \"F\";\n+ /**\n+ * Method: deactivate\n+ */\n+ deactivate: function() {\n+ if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n+ if (this.dragHandler.deactivate()) {\n+ if (this.zoomBox) {\n+ this.removeBox();\n }\n }\n+ return true;\n+ } else {\n+ return false;\n }\n+ },\n \n- return params;\n+ /**\n+ * Method: getBoxOffsets\n+ * Determines border offsets for a box, according to the box model.\n+ * \n+ * Returns:\n+ * {Object} an object with the following offsets:\n+ * - left\n+ * - right\n+ * - top\n+ * - bottom\n+ * - width\n+ * - height\n+ */\n+ getBoxOffsets: function() {\n+ if (!this.boxOffsets) {\n+ // Determine the box model. If the testDiv's clientWidth is 3, then\n+ // the borders are outside and we are dealing with the w3c box\n+ // model. Otherwise, the browser uses the traditional box model and\n+ // the borders are inside the box bounds, leaving us with a\n+ // clientWidth of 1.\n+ var testDiv = document.createElement(\"div\");\n+ //testDiv.style.visibility = \"hidden\";\n+ testDiv.style.position = \"absolute\";\n+ testDiv.style.border = \"1px solid black\";\n+ testDiv.style.width = \"3px\";\n+ document.body.appendChild(testDiv);\n+ var w3cBoxModel = testDiv.clientWidth == 3;\n+ document.body.removeChild(testDiv);\n+\n+ var left = parseInt(OpenLayers.Element.getStyle(this.zoomBox,\n+ \"border-left-width\"));\n+ var right = parseInt(OpenLayers.Element.getStyle(\n+ this.zoomBox, \"border-right-width\"));\n+ var top = parseInt(OpenLayers.Element.getStyle(this.zoomBox,\n+ \"border-top-width\"));\n+ var bottom = parseInt(OpenLayers.Element.getStyle(\n+ this.zoomBox, \"border-bottom-width\"));\n+ this.boxOffsets = {\n+ left: left,\n+ right: right,\n+ top: top,\n+ bottom: bottom,\n+ width: w3cBoxModel === false ? left + right : 0,\n+ height: w3cBoxModel === false ? top + bottom : 0\n+ };\n+ }\n+ return this.boxOffsets;\n },\n \n- CLASS_NAME: \"OpenLayers.Control.Permalink\"\n+ CLASS_NAME: \"OpenLayers.Handler.Box\"\n });\n /* ======================================================================\n- OpenLayers/Handler/MouseWheel.js\n+ OpenLayers/Handler/Hover.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n * @requires OpenLayers/Handler.js\n */\n \n /**\n- * Class: OpenLayers.Handler.MouseWheel\n- * Handler for wheel up/down events.\n+ * Class: OpenLayers.Handler.Hover\n+ * The hover handler is to be used to emulate mouseovers on objects\n+ * on the map that aren't DOM elements. For example one can use\n+ * this handler to send WMS/GetFeatureInfo requests as the user\n+ * moves the mouve over the map.\n * \n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {\n- /** \n- * Property: wheelListener \n- * {function} \n+OpenLayers.Handler.Hover = OpenLayers.Class(OpenLayers.Handler, {\n+\n+ /**\n+ * APIProperty: delay\n+ * {Integer} - Number of milliseconds between mousemoves before\n+ * the event is considered a hover. Default is 500.\n */\n- wheelListener: null,\n+ delay: 500,\n \n /**\n- * Property: interval\n- * {Integer} In order to increase server performance, an interval (in \n- * milliseconds) can be set to reduce the number of up/down events \n- * called. If set, a new up/down event will not be set until the \n- * interval has passed. \n- * Defaults to 0, meaning no interval. \n+ * APIProperty: pixelTolerance\n+ * {Integer} - Maximum number of pixels between mousemoves for\n+ * an event to be considered a hover. Default is null.\n */\n- interval: 0,\n+ pixelTolerance: null,\n \n /**\n- * Property: maxDelta\n- * {Integer} Maximum delta to collect before breaking from the current\n- * interval. In cumulative mode, this also limits the maximum delta\n- * returned from the handler. Default is Number.POSITIVE_INFINITY.\n+ * APIProperty: stopMove\n+ * {Boolean} - Stop other listeners from being notified on mousemoves.\n+ * Default is false.\n */\n- maxDelta: Number.POSITIVE_INFINITY,\n+ stopMove: false,\n \n /**\n- * Property: delta\n- * {Integer} When interval is set, delta collects the mousewheel z-deltas\n- * of the events that occur within the interval.\n- * See also the cumulative option\n+ * Property: px\n+ * {} - The location of the last mousemove, expressed\n+ * in pixels.\n */\n- delta: 0,\n+ px: null,\n \n /**\n- * Property: cumulative\n- * {Boolean} When interval is set: true to collect all the mousewheel \n- * z-deltas, false to only record the delta direction (positive or\n- * negative)\n+ * Property: timerId\n+ * {Number} - The id of the timer.\n */\n- cumulative: true,\n+ timerId: null,\n \n /**\n- * Constructor: OpenLayers.Handler.MouseWheel\n+ * Constructor: OpenLayers.Handler.Hover\n+ * Construct a hover handler.\n *\n * Parameters:\n- * control - {} \n- * callbacks - {Object} An object containing a single function to be\n- * called when the drag operation is finished.\n- * The callback should expect to recieve a single\n- * argument, the point geometry.\n- * options - {Object} \n+ * control - {} The control that initialized this\n+ * handler. The control is assumed to have a valid map property; that\n+ * map is used in the handler's own setMap method.\n+ * callbacks - {Object} An object with keys corresponding to callbacks\n+ * that will be called by the handler. The callbacks should\n+ * expect to receive a single argument, the event. Callbacks for\n+ * 'move', the mouse is moving, and 'pause', the mouse is pausing,\n+ * are supported.\n+ * options - {Object} An optional object whose properties will be set on\n+ * the handler.\n */\n- initialize: function(control, callbacks, options) {\n- OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n- this.wheelListener = OpenLayers.Function.bindAsEventListener(\n- this.onWheelEvent, this\n- );\n- },\n \n /**\n- * Method: destroy\n+ * Method: mousemove\n+ * Called when the mouse moves on the map.\n+ *\n+ * Parameters:\n+ * evt - {}\n+ *\n+ * Returns:\n+ * {Boolean} Continue propagating this event.\n */\n- destroy: function() {\n- OpenLayers.Handler.prototype.destroy.apply(this, arguments);\n- this.wheelListener = null;\n+ mousemove: function(evt) {\n+ if (this.passesTolerance(evt.xy)) {\n+ this.clearTimer();\n+ this.callback('move', [evt]);\n+ this.px = evt.xy;\n+ // clone the evt so original properties can be accessed even\n+ // if the browser deletes them during the delay\n+ evt = OpenLayers.Util.extend({}, evt);\n+ this.timerId = window.setTimeout(\n+ OpenLayers.Function.bind(this.delayedCall, this, evt),\n+ this.delay\n+ );\n+ }\n+ return !this.stopMove;\n },\n \n /**\n- * Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/\n- */\n-\n- /** \n- * Method: onWheelEvent\n- * Catch the wheel event and handle it xbrowserly\n- * \n+ * Method: mouseout\n+ * Called when the mouse goes out of the map.\n+ *\n * Parameters:\n- * e - {Event} \n+ * evt - {}\n+ *\n+ * Returns:\n+ * {Boolean} Continue propagating this event.\n */\n- onWheelEvent: function(e) {\n-\n- // make sure we have a map and check keyboard modifiers\n- if (!this.map || !this.checkModifiers(e)) {\n- return;\n- }\n-\n- // Ride up the element's DOM hierarchy to determine if it or any of \n- // its ancestors was: \n- // * specifically marked as scrollable (CSS overflow property)\n- // * one of our layer divs or a div marked as scrollable\n- // ('olScrollable' CSS class)\n- // * the map div\n- //\n- var overScrollableDiv = false;\n- var allowScroll = false;\n- var overMapDiv = false;\n-\n- var elem = OpenLayers.Event.element(e);\n- while ((elem != null) && !overMapDiv && !overScrollableDiv) {\n-\n- if (!overScrollableDiv) {\n- try {\n- var overflow;\n- if (elem.currentStyle) {\n- overflow = elem.currentStyle[\"overflow\"];\n- } else {\n- var style =\n- document.defaultView.getComputedStyle(elem, null);\n- overflow = style.getPropertyValue(\"overflow\");\n- }\n- overScrollableDiv = (overflow &&\n- (overflow == \"auto\") || (overflow == \"scroll\"));\n- } catch (err) {\n- //sometimes when scrolling in a popup, this causes \n- // obscure browser error\n- }\n- }\n-\n- if (!allowScroll) {\n- allowScroll = OpenLayers.Element.hasClass(elem, 'olScrollable');\n- if (!allowScroll) {\n- for (var i = 0, len = this.map.layers.length; i < len; i++) {\n- // Are we in the layer div? Note that we have two cases\n- // here: one is to catch EventPane layers, which have a\n- // pane above the layer (layer.pane)\n- var layer = this.map.layers[i];\n- if (elem == layer.div || elem == layer.pane) {\n- allowScroll = true;\n- break;\n- }\n- }\n- }\n- }\n- overMapDiv = (elem == this.map.div);\n-\n- elem = elem.parentNode;\n- }\n-\n- // Logic below is the following:\n- //\n- // If we are over a scrollable div or not over the map div:\n- // * do nothing (let the browser handle scrolling)\n- //\n- // otherwise \n- // \n- // If we are over the layer div or a 'olScrollable' div:\n- // * zoom/in out\n- // then\n- // * kill event (so as not to also scroll the page after zooming)\n- //\n- // otherwise\n- //\n- // Kill the event (dont scroll the page if we wheel over the \n- // layerswitcher or the pan/zoom control)\n- //\n- if (!overScrollableDiv && overMapDiv) {\n- if (allowScroll) {\n- var delta = 0;\n-\n- if (e.wheelDelta) {\n- delta = e.wheelDelta;\n- if (delta % 160 === 0) {\n- // opera have steps of 160 instead of 120\n- delta = delta * 0.75;\n- }\n- delta = delta / 120;\n- } else if (e.detail) {\n- // detail in Firefox on OS X is 1/3 of Windows\n- // so force delta 1 / -1\n- delta = -(e.detail / Math.abs(e.detail));\n- }\n- this.delta += delta;\n-\n- window.clearTimeout(this._timeoutId);\n- if (this.interval && Math.abs(this.delta) < this.maxDelta) {\n- // store e because window.event might change during delay\n- var evt = OpenLayers.Util.extend({}, e);\n- this._timeoutId = window.setTimeout(\n- OpenLayers.Function.bind(function() {\n- this.wheelZoom(evt);\n- }, this),\n- this.interval\n- );\n- } else {\n- this.wheelZoom(e);\n- }\n- }\n- OpenLayers.Event.stop(e);\n+ mouseout: function(evt) {\n+ if (OpenLayers.Util.mouseLeft(evt, this.map.viewPortDiv)) {\n+ this.clearTimer();\n+ this.callback('move', [evt]);\n }\n+ return true;\n },\n \n /**\n- * Method: wheelZoom\n- * Given the wheel event, we carry out the appropriate zooming in or out,\n- * based on the 'wheelDelta' or 'detail' property of the event.\n- * \n+ * Method: passesTolerance\n+ * Determine whether the mouse move is within the optional pixel tolerance.\n+ *\n * Parameters:\n- * e - {Event}\n+ * px - {}\n+ *\n+ * Returns:\n+ * {Boolean} The mouse move is within the pixel tolerance.\n */\n- wheelZoom: function(e) {\n- var delta = this.delta;\n- this.delta = 0;\n-\n- if (delta) {\n- e.xy = this.map.events.getMousePosition(e);\n- if (delta < 0) {\n- this.callback(\"down\",\n- [e, this.cumulative ? Math.max(-this.maxDelta, delta) : -1]);\n- } else {\n- this.callback(\"up\",\n- [e, this.cumulative ? Math.min(this.maxDelta, delta) : 1]);\n+ passesTolerance: function(px) {\n+ var passes = true;\n+ if (this.pixelTolerance && this.px) {\n+ var dpx = Math.sqrt(\n+ Math.pow(this.px.x - px.x, 2) +\n+ Math.pow(this.px.y - px.y, 2)\n+ );\n+ if (dpx < this.pixelTolerance) {\n+ passes = false;\n }\n }\n+ return passes;\n },\n \n /**\n- * Method: activate \n+ * Method: clearTimer\n+ * Clear the timer and set to null.\n */\n- activate: function(evt) {\n- if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n- //register mousewheel events specifically on the window and document\n- var wheelListener = this.wheelListener;\n- OpenLayers.Event.observe(window, \"DOMMouseScroll\", wheelListener);\n- OpenLayers.Event.observe(window, \"mousewheel\", wheelListener);\n- OpenLayers.Event.observe(document, \"mousewheel\", wheelListener);\n- return true;\n- } else {\n- return false;\n+ clearTimer: function() {\n+ if (this.timerId != null) {\n+ window.clearTimeout(this.timerId);\n+ this.timerId = null;\n }\n },\n \n /**\n- * Method: deactivate \n+ * Method: delayedCall\n+ * Triggers pause callback.\n+ *\n+ * Parameters:\n+ * evt - {}\n */\n- deactivate: function(evt) {\n+ delayedCall: function(evt) {\n+ this.callback('pause', [evt]);\n+ },\n+\n+ /**\n+ * APIMethod: deactivate\n+ * Deactivate the handler.\n+ *\n+ * Returns:\n+ * {Boolean} The handler was successfully deactivated.\n+ */\n+ deactivate: function() {\n+ var deactivated = false;\n if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- // unregister mousewheel events specifically on the window and document\n- var wheelListener = this.wheelListener;\n- OpenLayers.Event.stopObserving(window, \"DOMMouseScroll\", wheelListener);\n- OpenLayers.Event.stopObserving(window, \"mousewheel\", wheelListener);\n- OpenLayers.Event.stopObserving(document, \"mousewheel\", wheelListener);\n- return true;\n- } else {\n- return false;\n+ this.clearTimer();\n+ deactivated = true;\n }\n+ return deactivated;\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.MouseWheel\"\n+ CLASS_NAME: \"OpenLayers.Handler.Hover\"\n });\n /* ======================================================================\n- OpenLayers/Control/Navigation.js\n+ OpenLayers/Control/GetFeature.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Control/ZoomBox.js\n- * @requires OpenLayers/Control/DragPan.js\n- * @requires OpenLayers/Handler/MouseWheel.js\n+ * @requires OpenLayers/Control.js\n * @requires OpenLayers/Handler/Click.js\n+ * @requires OpenLayers/Handler/Box.js\n+ * @requires OpenLayers/Handler/Hover.js\n+ * @requires OpenLayers/Filter/Spatial.js\n */\n \n /**\n- * Class: OpenLayers.Control.Navigation\n- * The navigation control handles map browsing with mouse events (dragging,\n- * double-clicking, and scrolling the wheel). Create a new navigation \n- * control with the control. \n- * \n- * Note that this control is added to the map by default (if no controls \n- * array is sent in the options object to the \n- * constructor).\n- * \n- * Inherits:\n+ * Class: OpenLayers.Control.GetFeature\n+ * Gets vector features for locations underneath the mouse cursor. Can be\n+ * configured to act on click, hover or dragged boxes. Uses an\n+ * that supports spatial filters to retrieve\n+ * features from a server and fires events that notify applications of the\n+ * selected features. \n+ *\n+ * Inherits from:\n * - \n */\n-OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {\n \n- /** \n- * Property: dragPan\n- * {} \n+ /**\n+ * APIProperty: protocol\n+ * {} Required. The protocol used for fetching\n+ * features.\n */\n- dragPan: null,\n+ protocol: null,\n \n /**\n- * APIProperty: dragPanOptions\n- * {Object} Options passed to the DragPan control.\n+ * APIProperty: multipleKey\n+ * {String} An event modifier ('altKey' or 'shiftKey') that temporarily sets\n+ * the property to true. Default is null.\n */\n- dragPanOptions: null,\n+ multipleKey: null,\n \n /**\n- * Property: pinchZoom\n- * {}\n+ * APIProperty: toggleKey\n+ * {String} An event modifier ('altKey' or 'shiftKey') that temporarily sets\n+ * the property to true. Default is null.\n */\n- pinchZoom: null,\n+ toggleKey: null,\n \n /**\n- * APIProperty: pinchZoomOptions\n- * {Object} Options passed to the PinchZoom control.\n+ * Property: modifiers\n+ * {Object} The event modifiers to use, according to the current event\n+ * being handled by this control's handlers\n */\n- pinchZoomOptions: null,\n+ modifiers: null,\n \n /**\n- * APIProperty: documentDrag\n- * {Boolean} Allow panning of the map by dragging outside map viewport.\n- * Default is false.\n+ * APIProperty: multiple\n+ * {Boolean} Allow selection of multiple geometries. Default is false.\n */\n- documentDrag: false,\n+ multiple: false,\n \n- /** \n- * Property: zoomBox\n- * {}\n+ /**\n+ * APIProperty: click\n+ * {Boolean} Use a click handler for selecting/unselecting features. If\n+ * both and are set to true, the click handler takes\n+ * precedence over the box handler if a box with zero extent was\n+ * selected. Default is true.\n */\n- zoomBox: null,\n+ click: true,\n \n /**\n- * APIProperty: zoomBoxEnabled\n- * {Boolean} Whether the user can draw a box to zoom\n+ * APIProperty: single\n+ * {Boolean} Tells whether select by click should select a single\n+ * feature. If set to false, all matching features are selected.\n+ * If set to true, only the best matching feature is selected.\n+ * This option has an effect only of the option is set\n+ * to true. Default is true.\n */\n- zoomBoxEnabled: true,\n+ single: true,\n \n /**\n- * APIProperty: zoomWheelEnabled\n- * {Boolean} Whether the mousewheel should zoom the map\n+ * APIProperty: clickout\n+ * {Boolean} Unselect features when clicking outside any feature.\n+ * Applies only if is true. Default is true.\n */\n- zoomWheelEnabled: true,\n+ clickout: true,\n \n /**\n- * Property: mouseWheelOptions\n- * {Object} Options passed to the MouseWheel control (only useful if\n- * is set to true). Default is no options for maps\n- * with fractionalZoom set to true, otherwise\n- * {cumulative: false, interval: 50, maxDelta: 6} \n+ * APIProperty: toggle\n+ * {Boolean} Unselect a selected feature on click. Applies only if\n+ * is true. Default is false.\n */\n- mouseWheelOptions: null,\n+ toggle: false,\n \n /**\n- * APIProperty: handleRightClicks\n- * {Boolean} Whether or not to handle right clicks. Default is false.\n+ * APIProperty: clickTolerance\n+ * {Integer} Tolerance for the filter query in pixels. This has the\n+ * same effect as the tolerance parameter on WMS GetFeatureInfo\n+ * requests. Will be ignored for box selections. Applies only if\n+ * or is true. Default is 5. Note that this not\n+ * only affects requests on click, but also on hover.\n */\n- handleRightClicks: false,\n+ clickTolerance: 5,\n \n /**\n- * APIProperty: zoomBoxKeyMask\n- * {Integer} key code of the key, which has to be\n- * pressed, while drawing the zoom box with the mouse on the screen. \n- * You should probably set handleRightClicks to true if you use this\n- * with MOD_CTRL, to disable the context menu for machines which use\n- * CTRL-Click as a right click.\n- * Default: \n+ * APIProperty: hover\n+ * {Boolean} Send feature requests on mouse moves. Default is false.\n */\n- zoomBoxKeyMask: OpenLayers.Handler.MOD_SHIFT,\n+ hover: false,\n \n /**\n- * APIProperty: autoActivate\n- * {Boolean} Activate the control when it is added to a map. Default is\n- * true.\n+ * APIProperty: box\n+ * {Boolean} Allow feature selection by drawing a box. If set to\n+ * true set to false to disable the click handler and\n+ * rely on the box handler only, even for \"zero extent\" boxes.\n+ * See the description of the option for additional\n+ * information. Default is false.\n */\n- autoActivate: true,\n+ box: false,\n \n /**\n- * Constructor: OpenLayers.Control.Navigation\n- * Create a new navigation control\n- * \n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * the control\n+ * APIProperty: maxFeatures\n+ * {Integer} Maximum number of features to return from a query in single mode\n+ * if supported by the . This set of features is then used to\n+ * determine the best match client-side. Default is 10.\n */\n- initialize: function(options) {\n- this.handlers = {};\n- OpenLayers.Control.prototype.initialize.apply(this, arguments);\n- },\n+ maxFeatures: 10,\n \n /**\n- * Method: destroy\n- * The destroy method is used to perform any clean up before the control\n- * is dereferenced. Typically this is where event listeners are removed\n- * to prevent memory leaks.\n+ * Property: features\n+ * {Object} Hash of {}, keyed by fid, holding\n+ * the currently selected features\n */\n- destroy: function() {\n- this.deactivate();\n+ features: null,\n \n- if (this.dragPan) {\n- this.dragPan.destroy();\n- }\n- this.dragPan = null;\n+ /**\n+ * Proeprty: hoverFeature\n+ * {} The feature currently selected by the\n+ * hover handler\n+ */\n+ hoverFeature: null,\n \n- if (this.zoomBox) {\n- this.zoomBox.destroy();\n+ /**\n+ * APIProperty: handlerOptions\n+ * {Object} Additional options for the handlers used by this control. This\n+ * is a hash with the keys \"click\", \"box\" and \"hover\".\n+ */\n+\n+ /**\n+ * Property: handlers\n+ * {Object} Object with references to multiple \n+ * instances.\n+ */\n+ handlers: null,\n+\n+ /**\n+ * Property: hoverResponse\n+ * {} The response object associated with\n+ * the currently running hover request (if any).\n+ */\n+ hoverResponse: null,\n+\n+ /**\n+ * Property: filterType\n+ * {} The type of filter to use when sending off a request. \n+ * Possible values: \n+ * OpenLayers.Filter.Spatial.\n+ * Defaults to: OpenLayers.Filter.Spatial.BBOX\n+ */\n+ filterType: OpenLayers.Filter.Spatial.BBOX,\n+\n+ /** \n+ * APIProperty: events\n+ * {} Events instance for listeners and triggering\n+ * control specific events.\n+ *\n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * control.events.register(type, obj, listener);\n+ * (end)\n+ *\n+ * Supported event types (in addition to those from ):\n+ * beforefeatureselected - Triggered when is true before a\n+ * feature is selected. The event object has a feature property with\n+ * the feature about to select\n+ * featureselected - Triggered when is true and a feature is\n+ * selected. The event object has a feature property with the\n+ * selected feature\n+ * beforefeaturesselected - Triggered when is true before a\n+ * set of features is selected. The event object is an array of\n+ * feature properties with the features about to be selected. \n+ * Return false after receiving this event to discontinue processing\n+ * of all featureselected events and the featuresselected event.\n+ * featuresselected - Triggered when is true and a set of\n+ * features is selected. The event object is an array of feature\n+ * properties of the selected features\n+ * featureunselected - Triggered when is true and a feature is\n+ * unselected. The event object has a feature property with the\n+ * unselected feature\n+ * clickout - Triggered when when is true and no feature was\n+ * selected.\n+ * hoverfeature - Triggered when is true and the mouse has\n+ * stopped over a feature\n+ * outfeature - Triggered when is true and the mouse moves\n+ * moved away from a hover-selected feature\n+ */\n+\n+ /**\n+ * Constructor: OpenLayers.Control.GetFeature\n+ * Create a new control for fetching remote features.\n+ *\n+ * Parameters:\n+ * options - {Object} A configuration object which at least has to contain\n+ * a property (if not, it has to be set before a request is\n+ * made)\n+ */\n+ initialize: function(options) {\n+ options.handlerOptions = options.handlerOptions || {};\n+\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+\n+ this.features = {};\n+\n+ this.handlers = {};\n+\n+ if (this.click) {\n+ this.handlers.click = new OpenLayers.Handler.Click(this, {\n+ click: this.selectClick\n+ }, this.handlerOptions.click || {});\n }\n- this.zoomBox = null;\n \n- if (this.pinchZoom) {\n- this.pinchZoom.destroy();\n+ if (this.box) {\n+ this.handlers.box = new OpenLayers.Handler.Box(\n+ this, {\n+ done: this.selectBox\n+ },\n+ OpenLayers.Util.extend(this.handlerOptions.box, {\n+ boxDivClassName: \"olHandlerBoxSelectFeature\"\n+ })\n+ );\n }\n- this.pinchZoom = null;\n \n- OpenLayers.Control.prototype.destroy.apply(this, arguments);\n+ if (this.hover) {\n+ this.handlers.hover = new OpenLayers.Handler.Hover(\n+ this, {\n+ 'move': this.cancelHover,\n+ 'pause': this.selectHover\n+ },\n+ OpenLayers.Util.extend(this.handlerOptions.hover, {\n+ 'delay': 250,\n+ 'pixelTolerance': 2\n+ })\n+ );\n+ }\n },\n \n /**\n * Method: activate\n+ * Activates the control.\n+ * \n+ * Returns:\n+ * {Boolean} The control was effectively activated.\n */\n activate: function() {\n- this.dragPan.activate();\n- if (this.zoomWheelEnabled) {\n- this.handlers.wheel.activate();\n- }\n- this.handlers.click.activate();\n- if (this.zoomBoxEnabled) {\n- this.zoomBox.activate();\n- }\n- if (this.pinchZoom) {\n- this.pinchZoom.activate();\n+ if (!this.active) {\n+ for (var i in this.handlers) {\n+ this.handlers[i].activate();\n+ }\n }\n- return OpenLayers.Control.prototype.activate.apply(this, arguments);\n+ return OpenLayers.Control.prototype.activate.apply(\n+ this, arguments\n+ );\n },\n \n /**\n * Method: deactivate\n+ * Deactivates the control.\n+ * \n+ * Returns:\n+ * {Boolean} The control was effectively deactivated.\n */\n deactivate: function() {\n- if (this.pinchZoom) {\n- this.pinchZoom.deactivate();\n+ if (this.active) {\n+ for (var i in this.handlers) {\n+ this.handlers[i].deactivate();\n+ }\n }\n- this.zoomBox.deactivate();\n- this.dragPan.deactivate();\n- this.handlers.click.deactivate();\n- this.handlers.wheel.deactivate();\n- return OpenLayers.Control.prototype.deactivate.apply(this, arguments);\n+ return OpenLayers.Control.prototype.deactivate.apply(\n+ this, arguments\n+ );\n },\n \n /**\n- * Method: draw\n+ * Method: selectClick\n+ * Called on click\n+ *\n+ * Parameters:\n+ * evt - {} \n */\n- draw: function() {\n- // disable right mouse context menu for support of right click events\n- if (this.handleRightClicks) {\n- this.map.viewPortDiv.oncontextmenu = OpenLayers.Function.False;\n- }\n+ selectClick: function(evt) {\n+ var bounds = this.pixelToBounds(evt.xy);\n \n- var clickCallbacks = {\n- 'click': this.defaultClick,\n- 'dblclick': this.defaultDblClick,\n- 'dblrightclick': this.defaultDblRightClick\n- };\n- var clickOptions = {\n- 'double': true,\n- 'stopDouble': true\n- };\n- this.handlers.click = new OpenLayers.Handler.Click(\n- this, clickCallbacks, clickOptions\n- );\n- this.dragPan = new OpenLayers.Control.DragPan(\n- OpenLayers.Util.extend({\n- map: this.map,\n- documentDrag: this.documentDrag\n- }, this.dragPanOptions)\n- );\n- this.zoomBox = new OpenLayers.Control.ZoomBox({\n- map: this.map,\n- keyMask: this.zoomBoxKeyMask\n+ this.setModifiers(evt);\n+ this.request(bounds, {\n+ single: this.single\n });\n- this.dragPan.draw();\n- this.zoomBox.draw();\n- var wheelOptions = this.map.fractionalZoom ? {} : {\n- cumulative: false,\n- interval: 50,\n- maxDelta: 6\n- };\n- this.handlers.wheel = new OpenLayers.Handler.MouseWheel(\n- this, {\n- up: this.wheelUp,\n- down: this.wheelDown\n- },\n- OpenLayers.Util.extend(wheelOptions, this.mouseWheelOptions)\n- );\n- if (OpenLayers.Control.PinchZoom) {\n- this.pinchZoom = new OpenLayers.Control.PinchZoom(\n- OpenLayers.Util.extend({\n- map: this.map\n- }, this.pinchZoomOptions));\n- }\n },\n \n /**\n- * Method: defaultClick\n+ * Method: selectBox\n+ * Callback from the handlers.box set up when selection is on\n *\n * Parameters:\n- * evt - {Event}\n+ * position - {|Object} An OpenLayers.Bounds or\n+ * an object with a 'left', 'bottom', 'right' and 'top' properties.\n */\n- defaultClick: function(evt) {\n- if (evt.lastTouches && evt.lastTouches.length == 2) {\n- this.map.zoomOut();\n+ selectBox: function(position) {\n+ var bounds;\n+ if (position instanceof OpenLayers.Bounds) {\n+ var minXY = this.map.getLonLatFromPixel({\n+ x: position.left,\n+ y: position.bottom\n+ });\n+ var maxXY = this.map.getLonLatFromPixel({\n+ x: position.right,\n+ y: position.top\n+ });\n+ bounds = new OpenLayers.Bounds(\n+ minXY.lon, minXY.lat, maxXY.lon, maxXY.lat\n+ );\n+\n+ } else {\n+ if (this.click) {\n+ // box without extent - let the click handler take care of it\n+ return;\n+ }\n+ bounds = this.pixelToBounds(position);\n }\n+ this.setModifiers(this.handlers.box.dragHandler.evt);\n+ this.request(bounds);\n },\n \n /**\n- * Method: defaultDblClick \n- * \n+ * Method: selectHover\n+ * Callback from the handlers.hover set up when selection is on\n+ *\n * Parameters:\n- * evt - {Event} \n+ * evt - {Object} event object with an xy property\n */\n- defaultDblClick: function(evt) {\n- this.map.zoomTo(this.map.zoom + 1, evt.xy);\n+ selectHover: function(evt) {\n+ var bounds = this.pixelToBounds(evt.xy);\n+ this.request(bounds, {\n+ single: true,\n+ hover: true\n+ });\n },\n \n /**\n- * Method: defaultDblRightClick \n- * \n- * Parameters:\n- * evt - {Event} \n+ * Method: cancelHover\n+ * Callback from the handlers.hover set up when selection is on\n */\n- defaultDblRightClick: function(evt) {\n- this.map.zoomTo(this.map.zoom - 1, evt.xy);\n+ cancelHover: function() {\n+ if (this.hoverResponse) {\n+ this.protocol.abort(this.hoverResponse);\n+ this.hoverResponse = null;\n+\n+ OpenLayers.Element.removeClass(this.map.viewPortDiv, \"olCursorWait\");\n+ }\n },\n \n /**\n- * Method: wheelChange \n- *\n+ * Method: request\n+ * Sends a GetFeature request to the WFS\n+ * \n * Parameters:\n- * evt - {Event}\n- * deltaZ - {Integer}\n+ * bounds - {} bounds for the request's BBOX filter\n+ * options - {Object} additional options for this method.\n+ * \n+ * Supported options include:\n+ * single - {Boolean} A single feature should be returned.\n+ * Note that this will be ignored if the protocol does not\n+ * return the geometries of the features.\n+ * hover - {Boolean} Do the request for the hover handler.\n */\n- wheelChange: function(evt, deltaZ) {\n- if (!this.map.fractionalZoom) {\n- deltaZ = Math.round(deltaZ);\n- }\n- var currentZoom = this.map.getZoom(),\n- newZoom = currentZoom + deltaZ;\n- newZoom = Math.max(newZoom, 0);\n- newZoom = Math.min(newZoom, this.map.getNumZoomLevels());\n- if (newZoom === currentZoom) {\n- return;\n+ request: function(bounds, options) {\n+ options = options || {};\n+ var filter = new OpenLayers.Filter.Spatial({\n+ type: this.filterType,\n+ value: bounds\n+ });\n+\n+ // Set the cursor to \"wait\" to tell the user we're working.\n+ OpenLayers.Element.addClass(this.map.viewPortDiv, \"olCursorWait\");\n+\n+ var response = this.protocol.read({\n+ maxFeatures: options.single == true ? this.maxFeatures : undefined,\n+ filter: filter,\n+ callback: function(result) {\n+ if (result.success()) {\n+ if (result.features.length) {\n+ if (options.single == true) {\n+ this.selectBestFeature(result.features,\n+ bounds.getCenterLonLat(), options);\n+ } else {\n+ this.select(result.features);\n+ }\n+ } else if (options.hover) {\n+ this.hoverSelect();\n+ } else {\n+ this.events.triggerEvent(\"clickout\");\n+ if (this.clickout) {\n+ this.unselectAll();\n+ }\n+ }\n+ }\n+ // Reset the cursor.\n+ OpenLayers.Element.removeClass(this.map.viewPortDiv, \"olCursorWait\");\n+ },\n+ scope: this\n+ });\n+ if (options.hover == true) {\n+ this.hoverResponse = response;\n }\n- this.map.zoomTo(newZoom, evt.xy);\n },\n \n- /** \n- * Method: wheelUp\n- * User spun scroll wheel up\n+ /**\n+ * Method: selectBestFeature\n+ * Selects the feature from an array of features that is the best match\n+ * for the click position.\n * \n * Parameters:\n- * evt - {Event}\n- * delta - {Integer}\n+ * features - {Array()}\n+ * clickPosition - {}\n+ * options - {Object} additional options for this method\n+ * \n+ * Supported options include:\n+ * hover - {Boolean} Do the selection for the hover handler.\n */\n- wheelUp: function(evt, delta) {\n- this.wheelChange(evt, delta || 1);\n+ selectBestFeature: function(features, clickPosition, options) {\n+ options = options || {};\n+ if (features.length) {\n+ var point = new OpenLayers.Geometry.Point(clickPosition.lon,\n+ clickPosition.lat);\n+ var feature, resultFeature, dist;\n+ var minDist = Number.MAX_VALUE;\n+ for (var i = 0; i < features.length; ++i) {\n+ feature = features[i];\n+ if (feature.geometry) {\n+ dist = point.distanceTo(feature.geometry, {\n+ edge: false\n+ });\n+ if (dist < minDist) {\n+ minDist = dist;\n+ resultFeature = feature;\n+ if (minDist == 0) {\n+ break;\n+ }\n+ }\n+ }\n+ }\n+\n+ if (options.hover == true) {\n+ this.hoverSelect(resultFeature);\n+ } else {\n+ this.select(resultFeature || features);\n+ }\n+ }\n },\n \n- /** \n- * Method: wheelDown\n- * User spun scroll wheel down\n+ /**\n+ * Method: setModifiers\n+ * Sets the multiple and toggle modifiers according to the current event\n * \n * Parameters:\n- * evt - {Event}\n- * delta - {Integer}\n+ * evt - {}\n */\n- wheelDown: function(evt, delta) {\n- this.wheelChange(evt, delta || -1);\n+ setModifiers: function(evt) {\n+ this.modifiers = {\n+ multiple: this.multiple || (this.multipleKey && evt[this.multipleKey]),\n+ toggle: this.toggle || (this.toggleKey && evt[this.toggleKey])\n+ };\n },\n \n /**\n- * Method: disableZoomBox\n+ * Method: select\n+ * Add feature to the hash of selected features and trigger the\n+ * featureselected and featuresselected events.\n+ * \n+ * Parameters:\n+ * features - {} or an array of features\n */\n- disableZoomBox: function() {\n- this.zoomBoxEnabled = false;\n- this.zoomBox.deactivate();\n+ select: function(features) {\n+ if (!this.modifiers.multiple && !this.modifiers.toggle) {\n+ this.unselectAll();\n+ }\n+ if (!(OpenLayers.Util.isArray(features))) {\n+ features = [features];\n+ }\n+\n+ var cont = this.events.triggerEvent(\"beforefeaturesselected\", {\n+ features: features\n+ });\n+ if (cont !== false) {\n+ var selectedFeatures = [];\n+ var feature;\n+ for (var i = 0, len = features.length; i < len; ++i) {\n+ feature = features[i];\n+ if (this.features[feature.fid || feature.id]) {\n+ if (this.modifiers.toggle) {\n+ this.unselect(this.features[feature.fid || feature.id]);\n+ }\n+ } else {\n+ cont = this.events.triggerEvent(\"beforefeatureselected\", {\n+ feature: feature\n+ });\n+ if (cont !== false) {\n+ this.features[feature.fid || feature.id] = feature;\n+ selectedFeatures.push(feature);\n+\n+ this.events.triggerEvent(\"featureselected\", {\n+ feature: feature\n+ });\n+ }\n+ }\n+ }\n+ this.events.triggerEvent(\"featuresselected\", {\n+ features: selectedFeatures\n+ });\n+ }\n },\n \n /**\n- * Method: enableZoomBox\n+ * Method: hoverSelect\n+ * Sets/unsets the \n+ * \n+ * Parameters:\n+ * feature - {} the feature to hover-select.\n+ * If none is provided, the current will be nulled and\n+ * the outfeature event will be triggered.\n */\n- enableZoomBox: function() {\n- this.zoomBoxEnabled = true;\n- if (this.active) {\n- this.zoomBox.activate();\n+ hoverSelect: function(feature) {\n+ var fid = feature ? feature.fid || feature.id : null;\n+ var hfid = this.hoverFeature ?\n+ this.hoverFeature.fid || this.hoverFeature.id : null;\n+\n+ if (hfid && hfid != fid) {\n+ this.events.triggerEvent(\"outfeature\", {\n+ feature: this.hoverFeature\n+ });\n+ this.hoverFeature = null;\n+ }\n+ if (fid && fid != hfid) {\n+ this.events.triggerEvent(\"hoverfeature\", {\n+ feature: feature\n+ });\n+ this.hoverFeature = feature;\n }\n },\n \n /**\n- * Method: disableZoomWheel\n+ * Method: unselect\n+ * Remove feature from the hash of selected features and trigger the\n+ * featureunselected event.\n+ *\n+ * Parameters:\n+ * feature - {}\n */\n-\n- disableZoomWheel: function() {\n- this.zoomWheelEnabled = false;\n- this.handlers.wheel.deactivate();\n+ unselect: function(feature) {\n+ delete this.features[feature.fid || feature.id];\n+ this.events.triggerEvent(\"featureunselected\", {\n+ feature: feature\n+ });\n },\n \n /**\n- * Method: enableZoomWheel\n+ * Method: unselectAll\n+ * Unselect all selected features.\n */\n+ unselectAll: function() {\n+ // we'll want an option to supress notification here\n+ for (var fid in this.features) {\n+ this.unselect(this.features[fid]);\n+ }\n+ },\n \n- enableZoomWheel: function() {\n- this.zoomWheelEnabled = true;\n- if (this.active) {\n- this.handlers.wheel.activate();\n+ /** \n+ * Method: setMap\n+ * Set the map property for the control. \n+ * \n+ * Parameters:\n+ * map - {} \n+ */\n+ setMap: function(map) {\n+ for (var i in this.handlers) {\n+ this.handlers[i].setMap(map);\n }\n+ OpenLayers.Control.prototype.setMap.apply(this, arguments);\n },\n \n- CLASS_NAME: \"OpenLayers.Control.Navigation\"\n+ /**\n+ * Method: pixelToBounds\n+ * Takes a pixel as argument and creates bounds after adding the\n+ * .\n+ * \n+ * Parameters:\n+ * pixel - {}\n+ */\n+ pixelToBounds: function(pixel) {\n+ var llPx = pixel.add(-this.clickTolerance / 2, this.clickTolerance / 2);\n+ var urPx = pixel.add(this.clickTolerance / 2, -this.clickTolerance / 2);\n+ var ll = this.map.getLonLatFromPixel(llPx);\n+ var ur = this.map.getLonLatFromPixel(urPx);\n+ return new OpenLayers.Bounds(ll.lon, ll.lat, ur.lon, ur.lat);\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Control.GetFeature\"\n });\n /* ======================================================================\n- OpenLayers/Handler/Polygon.js\n+ OpenLayers/Layer/WMS.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n \n /**\n- * @requires OpenLayers/Handler/Path.js\n- * @requires OpenLayers/Geometry/Polygon.js\n+ * @requires OpenLayers/Layer/Grid.js\n */\n \n /**\n- * Class: OpenLayers.Handler.Polygon\n- * Handler to draw a polygon on the map. Polygon is displayed on mouse down,\n- * moves on mouse move, and is finished on mouse up.\n- *\n+ * Class: OpenLayers.Layer.WMS\n+ * Instances of OpenLayers.Layer.WMS are used to display data from OGC Web\n+ * Mapping Services. Create a new WMS layer with the \n+ * constructor.\n+ * \n * Inherits from:\n- * - \n- * - \n+ * - \n */\n-OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {\n-\n- /** \n- * APIProperty: holeModifier\n- * {String} Key modifier to trigger hole digitizing. Acceptable values are\n- * \"altKey\", \"shiftKey\", or \"ctrlKey\". If not set, no hole digitizing\n- * will take place. Default is null.\n- */\n- holeModifier: null,\n-\n- /**\n- * Property: drawingHole\n- * {Boolean} Currently drawing an interior ring.\n- */\n- drawingHole: false,\n-\n- /**\n- * Property: polygon\n- * {}\n- */\n- polygon: null,\n-\n- /**\n- * Constructor: OpenLayers.Handler.Polygon\n- * Create a Polygon Handler.\n- *\n- * Parameters:\n- * control - {} The control that owns this handler\n- * callbacks - {Object} An object with a properties whose values are\n- * functions. Various callbacks described below.\n- * options - {Object} An optional object with properties to be set on the\n- * handler\n- *\n- * Named callbacks:\n- * create - Called when a sketch is first created. Callback called with\n- * the creation point geometry and sketch feature.\n- * modify - Called with each move of a vertex with the vertex (point)\n- * geometry and the sketch feature.\n- * point - Called as each point is added. Receives the new point geometry.\n- * done - Called when the point drawing is finished. The callback will\n- * recieve a single argument, the polygon geometry.\n- * cancel - Called when the handler is deactivated while drawing. The\n- * cancel callback will receive a geometry.\n- */\n-\n- /**\n- * Method: createFeature\n- * Add temporary geometries\n- *\n- * Parameters:\n- * pixel - {} The initial pixel location for the new\n- * feature.\n- */\n- createFeature: function(pixel) {\n- var lonlat = this.layer.getLonLatFromViewPortPx(pixel);\n- var geometry = new OpenLayers.Geometry.Point(\n- lonlat.lon, lonlat.lat\n- );\n- this.point = new OpenLayers.Feature.Vector(geometry);\n- this.line = new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.LinearRing([this.point.geometry])\n- );\n- this.polygon = new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.Polygon([this.line.geometry])\n- );\n- this.callback(\"create\", [this.point.geometry, this.getSketch()]);\n- this.point.geometry.clearBounds();\n- this.layer.addFeatures([this.polygon, this.point], {\n- silent: true\n- });\n- },\n-\n- /**\n- * Method: addPoint\n- * Add point to geometry.\n- *\n- * Parameters:\n- * pixel - {} The pixel location for the new point.\n- */\n- addPoint: function(pixel) {\n- if (!this.drawingHole && this.holeModifier &&\n- this.evt && this.evt[this.holeModifier]) {\n- var geometry = this.point.geometry;\n- var features = this.control.layer.features;\n- var candidate, polygon;\n- // look for intersections, last drawn gets priority\n- for (var i = features.length - 1; i >= 0; --i) {\n- candidate = features[i].geometry;\n- if ((candidate instanceof OpenLayers.Geometry.Polygon ||\n- candidate instanceof OpenLayers.Geometry.MultiPolygon) &&\n- candidate.intersects(geometry)) {\n- polygon = features[i];\n- this.control.layer.removeFeatures([polygon], {\n- silent: true\n- });\n- this.control.layer.events.registerPriority(\n- \"sketchcomplete\", this, this.finalizeInteriorRing\n- );\n- this.control.layer.events.registerPriority(\n- \"sketchmodified\", this, this.enforceTopology\n- );\n- polygon.geometry.addComponent(this.line.geometry);\n- this.polygon = polygon;\n- this.drawingHole = true;\n- break;\n- }\n- }\n- }\n- OpenLayers.Handler.Path.prototype.addPoint.apply(this, arguments);\n- },\n-\n- /**\n- * Method: getCurrentPointIndex\n- * \n- * Returns:\n- * {Number} The index of the most recently drawn point.\n- */\n- getCurrentPointIndex: function() {\n- return this.line.geometry.components.length - 2;\n- },\n-\n- /**\n- * Method: enforceTopology\n- * Simple topology enforcement for drawing interior rings. Ensures vertices\n- * of interior rings are contained by exterior ring. Other topology \n- * rules are enforced in to allow drawing of \n- * rings that intersect only during the sketch (e.g. a \"C\" shaped ring\n- * that nearly encloses another ring).\n- */\n- enforceTopology: function(event) {\n- var point = event.vertex;\n- var components = this.line.geometry.components;\n- // ensure that vertices of interior ring are contained by exterior ring\n- if (!this.polygon.geometry.intersects(point)) {\n- var last = components[components.length - 3];\n- point.x = last.x;\n- point.y = last.y;\n- }\n- },\n-\n- /**\n- * Method: finishGeometry\n- * Finish the geometry and send it back to the control.\n- */\n- finishGeometry: function() {\n- var index = this.line.geometry.components.length - 2;\n- this.line.geometry.removeComponent(this.line.geometry.components[index]);\n- this.removePoint();\n- this.finalize();\n- },\n-\n- /**\n- * Method: finalizeInteriorRing\n- * Enforces that new ring has some area and doesn't contain vertices of any\n- * other rings.\n- */\n- finalizeInteriorRing: function() {\n- var ring = this.line.geometry;\n- // ensure that ring has some area\n- var modified = (ring.getArea() !== 0);\n- if (modified) {\n- // ensure that new ring doesn't intersect any other rings\n- var rings = this.polygon.geometry.components;\n- for (var i = rings.length - 2; i >= 0; --i) {\n- if (ring.intersects(rings[i])) {\n- modified = false;\n- break;\n- }\n- }\n- if (modified) {\n- // ensure that new ring doesn't contain any other rings\n- var target;\n- outer: for (var i = rings.length - 2; i > 0; --i) {\n- var points = rings[i].components;\n- for (var j = 0, jj = points.length; j < jj; ++j) {\n- if (ring.containsPoint(points[j])) {\n- modified = false;\n- break outer;\n- }\n- }\n- }\n- }\n- }\n- if (modified) {\n- if (this.polygon.state !== OpenLayers.State.INSERT) {\n- this.polygon.state = OpenLayers.State.UPDATE;\n- }\n- } else {\n- this.polygon.geometry.removeComponent(ring);\n- }\n- this.restoreFeature();\n- return false;\n- },\n-\n- /**\n- * APIMethod: cancel\n- * Finish the geometry and call the \"cancel\" callback.\n- */\n- cancel: function() {\n- if (this.drawingHole) {\n- this.polygon.geometry.removeComponent(this.line.geometry);\n- this.restoreFeature(true);\n- }\n- return OpenLayers.Handler.Path.prototype.cancel.apply(this, arguments);\n- },\n-\n- /**\n- * Method: restoreFeature\n- * Move the feature from the sketch layer to the target layer.\n- *\n- * Properties: \n- * cancel - {Boolean} Cancel drawing. If falsey, the \"sketchcomplete\" event\n- * will be fired.\n- */\n- restoreFeature: function(cancel) {\n- this.control.layer.events.unregister(\n- \"sketchcomplete\", this, this.finalizeInteriorRing\n- );\n- this.control.layer.events.unregister(\n- \"sketchmodified\", this, this.enforceTopology\n- );\n- this.layer.removeFeatures([this.polygon], {\n- silent: true\n- });\n- this.control.layer.addFeatures([this.polygon], {\n- silent: true\n- });\n- this.drawingHole = false;\n- if (!cancel) {\n- // Re-trigger \"sketchcomplete\" so other listeners can do their\n- // business. While this is somewhat sloppy (if a listener is \n- // registered with registerPriority - not common - between the start\n- // and end of a single ring drawing - very uncommon - it will be \n- // called twice).\n- // TODO: In 3.0, collapse sketch handlers into geometry specific\n- // drawing controls.\n- this.control.layer.events.triggerEvent(\n- \"sketchcomplete\", {\n- feature: this.polygon\n- }\n- );\n- }\n- },\n-\n- /**\n- * Method: destroyFeature\n- * Destroy temporary geometries\n- *\n- * Parameters:\n- * force - {Boolean} Destroy even if persist is true.\n- */\n- destroyFeature: function(force) {\n- OpenLayers.Handler.Path.prototype.destroyFeature.call(\n- this, force);\n- this.polygon = null;\n- },\n-\n- /**\n- * Method: drawFeature\n- * Render geometries on the temporary layer.\n- */\n- drawFeature: function() {\n- this.layer.drawFeature(this.polygon, this.style);\n- this.layer.drawFeature(this.point, this.style);\n- },\n-\n- /**\n- * Method: getSketch\n- * Return the sketch feature.\n- *\n- * Returns:\n- * {}\n- */\n- getSketch: function() {\n- return this.polygon;\n- },\n-\n- /**\n- * Method: getGeometry\n- * Return the sketch geometry. If is true, this will return\n- * a multi-part geometry.\n- *\n- * Returns:\n- * {}\n- */\n- getGeometry: function() {\n- var geometry = this.polygon && this.polygon.geometry;\n- if (geometry && this.multi) {\n- geometry = new OpenLayers.Geometry.MultiPolygon([geometry]);\n- }\n- return geometry;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Handler.Polygon\"\n-});\n-/* ======================================================================\n- OpenLayers/Control/EditingToolbar.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Control/Panel.js\n- * @requires OpenLayers/Control/Navigation.js\n- * @requires OpenLayers/Control/DrawFeature.js\n- * @requires OpenLayers/Handler/Point.js\n- * @requires OpenLayers/Handler/Path.js\n- * @requires OpenLayers/Handler/Polygon.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.EditingToolbar \n- * The EditingToolbar is a panel of 4 controls to draw polygons, lines, \n- * points, or to navigate the map by panning. By default it appears in the \n- * upper right corner of the map.\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.EditingToolbar = OpenLayers.Class(\n- OpenLayers.Control.Panel, {\n-\n- /**\n- * APIProperty: citeCompliant\n- * {Boolean} If set to true, coordinates of features drawn in a map extent\n- * crossing the date line won't exceed the world bounds. Default is false.\n- */\n- citeCompliant: false,\n-\n- /**\n- * Constructor: OpenLayers.Control.EditingToolbar\n- * Create an editing toolbar for a given layer. \n- *\n- * Parameters:\n- * layer - {} \n- * options - {Object} \n- */\n- initialize: function(layer, options) {\n- OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);\n-\n- this.addControls(\n- [new OpenLayers.Control.Navigation()]\n- );\n- var controls = [\n- new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point, {\n- displayClass: 'olControlDrawFeaturePoint',\n- handlerOptions: {\n- citeCompliant: this.citeCompliant\n- }\n- }),\n- new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path, {\n- displayClass: 'olControlDrawFeaturePath',\n- handlerOptions: {\n- citeCompliant: this.citeCompliant\n- }\n- }),\n- new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Polygon, {\n- displayClass: 'olControlDrawFeaturePolygon',\n- handlerOptions: {\n- citeCompliant: this.citeCompliant\n- }\n- })\n- ];\n- this.addControls(controls);\n- },\n-\n- /**\n- * Method: draw\n- * calls the default draw, and then activates mouse defaults.\n- *\n- * Returns:\n- * {DOMElement}\n- */\n- draw: function() {\n- var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);\n- if (this.defaultControl === null) {\n- this.defaultControl = this.controls[0];\n- }\n- return div;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Control.EditingToolbar\"\n- });\n-/* ======================================================================\n- OpenLayers/Control/OverviewMap.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/** \n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/BaseTypes.js\n- * @requires OpenLayers/Events/buttonclick.js\n- * @requires OpenLayers/Map.js\n- * @requires OpenLayers/Handler/Click.js\n- * @requires OpenLayers/Handler/Drag.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.OverviewMap\n- * The OverMap control creates a small overview map, useful to display the \n- * extent of a zoomed map and your main map and provide additional \n- * navigation options to the User. By default the overview map is drawn in\n- * the lower right corner of the main map. Create a new overview map with the\n- * constructor.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {\n-\n- /**\n- * Property: element\n- * {DOMElement} The DOM element that contains the overview map\n- */\n- element: null,\n-\n- /**\n- * APIProperty: ovmap\n- * {} A reference to the overview map itself.\n- */\n- ovmap: null,\n-\n- /**\n- * APIProperty: size\n- * {} The overvew map size in pixels. Note that this is\n- * the size of the map itself - the element that contains the map (default\n- * class name olControlOverviewMapElement) may have padding or other style\n- * attributes added via CSS.\n- */\n- size: {\n- w: 180,\n- h: 90\n- },\n-\n- /**\n- * APIProperty: layers\n- * {Array()} Ordered list of layers in the overview map.\n- * If none are sent at construction, the base layer for the main map is used.\n- */\n- layers: null,\n-\n- /**\n- * APIProperty: minRectSize\n- * {Integer} The minimum width or height (in pixels) of the extent\n- * rectangle on the overview map. When the extent rectangle reaches\n- * this size, it will be replaced depending on the value of the\n- * property. Default is 15 pixels.\n- */\n- minRectSize: 15,\n-\n- /**\n- * APIProperty: minRectDisplayClass\n- * {String} Replacement style class name for the extent rectangle when\n- * is reached. This string will be suffixed on to the\n- * displayClass. Default is \"RectReplacement\".\n- *\n- * Example CSS declaration:\n- * (code)\n- * .olControlOverviewMapRectReplacement {\n- * overflow: hidden;\n- * cursor: move;\n- * background-image: url(\"img/overview_replacement.gif\");\n- * background-repeat: no-repeat;\n- * background-position: center;\n- * }\n- * (end)\n- */\n- minRectDisplayClass: \"RectReplacement\",\n-\n- /**\n- * APIProperty: minRatio\n- * {Float} The ratio of the overview map resolution to the main map\n- * resolution at which to zoom farther out on the overview map.\n- */\n- minRatio: 8,\n-\n- /**\n- * APIProperty: maxRatio\n- * {Float} The ratio of the overview map resolution to the main map\n- * resolution at which to zoom farther in on the overview map.\n- */\n- maxRatio: 32,\n-\n- /**\n- * APIProperty: mapOptions\n- * {Object} An object containing any non-default properties to be sent to\n- * the overview map's map constructor. These should include any\n- * non-default options that the main map was constructed with.\n- */\n- mapOptions: null,\n-\n- /**\n- * APIProperty: autoPan\n- * {Boolean} Always pan the overview map, so the extent marker remains in\n- * the center. Default is false. If true, when you drag the extent\n- * marker, the overview map will update itself so the marker returns\n- * to the center.\n- */\n- autoPan: false,\n-\n- /**\n- * Property: handlers\n- * {Object}\n- */\n- handlers: null,\n-\n- /**\n- * Property: resolutionFactor\n- * {Object}\n- */\n- resolutionFactor: 1,\n-\n- /**\n- * APIProperty: maximized\n- * {Boolean} Start as maximized (visible). Defaults to false.\n- */\n- maximized: false,\n-\n- /**\n- * APIProperty: maximizeTitle\n- * {String} This property is used for showing a tooltip over the \n- * maximize div. Defaults to \"\" (no title).\n- */\n- maximizeTitle: \"\",\n-\n- /**\n- * APIProperty: minimizeTitle\n- * {String} This property is used for showing a tooltip over the \n- * minimize div. Defaults to \"\" (no title).\n- */\n- minimizeTitle: \"\",\n-\n- /**\n- * Constructor: OpenLayers.Control.OverviewMap\n- * Create a new overview map\n- *\n- * Parameters:\n- * options - {Object} Properties of this object will be set on the overview\n- * map object. Note, to set options on the map object contained in this\n- * control, set as one of the options properties.\n- */\n- initialize: function(options) {\n- this.layers = [];\n- this.handlers = {};\n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n- },\n-\n- /**\n- * APIMethod: destroy\n- * Deconstruct the control\n- */\n- destroy: function() {\n- if (!this.mapDiv) { // we've already been destroyed\n- return;\n- }\n- if (this.handlers.click) {\n- this.handlers.click.destroy();\n- }\n- if (this.handlers.drag) {\n- this.handlers.drag.destroy();\n- }\n-\n- this.ovmap && this.ovmap.viewPortDiv.removeChild(this.extentRectangle);\n- this.extentRectangle = null;\n-\n- if (this.rectEvents) {\n- this.rectEvents.destroy();\n- this.rectEvents = null;\n- }\n-\n- if (this.ovmap) {\n- this.ovmap.destroy();\n- this.ovmap = null;\n- }\n-\n- this.element.removeChild(this.mapDiv);\n- this.mapDiv = null;\n-\n- this.div.removeChild(this.element);\n- this.element = null;\n-\n- if (this.maximizeDiv) {\n- this.div.removeChild(this.maximizeDiv);\n- this.maximizeDiv = null;\n- }\n-\n- if (this.minimizeDiv) {\n- this.div.removeChild(this.minimizeDiv);\n- this.minimizeDiv = null;\n- }\n-\n- this.map.events.un({\n- buttonclick: this.onButtonClick,\n- moveend: this.update,\n- changebaselayer: this.baseLayerDraw,\n- scope: this\n- });\n-\n- OpenLayers.Control.prototype.destroy.apply(this, arguments);\n- },\n-\n- /**\n- * Method: draw\n- * Render the control in the browser.\n- */\n- draw: function() {\n- OpenLayers.Control.prototype.draw.apply(this, arguments);\n- if (this.layers.length === 0) {\n- if (this.map.baseLayer) {\n- var layer = this.map.baseLayer.clone();\n- this.layers = [layer];\n- } else {\n- this.map.events.register(\"changebaselayer\", this, this.baseLayerDraw);\n- return this.div;\n- }\n- }\n-\n- // create overview map DOM elements\n- this.element = document.createElement('div');\n- this.element.className = this.displayClass + 'Element';\n- this.element.style.display = 'none';\n-\n- this.mapDiv = document.createElement('div');\n- this.mapDiv.style.width = this.size.w + 'px';\n- this.mapDiv.style.height = this.size.h + 'px';\n- this.mapDiv.style.position = 'relative';\n- this.mapDiv.style.overflow = 'hidden';\n- this.mapDiv.id = OpenLayers.Util.createUniqueID('overviewMap');\n-\n- this.extentRectangle = document.createElement('div');\n- this.extentRectangle.style.position = 'absolute';\n- this.extentRectangle.style.zIndex = 1000; //HACK\n- this.extentRectangle.className = this.displayClass + 'ExtentRectangle';\n-\n- this.element.appendChild(this.mapDiv);\n-\n- this.div.appendChild(this.element);\n-\n- // Optionally add min/max buttons if the control will go in the\n- // map viewport.\n- if (!this.outsideViewport) {\n- this.div.className += \" \" + this.displayClass + 'Container';\n- // maximize button div\n- var img = OpenLayers.Util.getImageLocation('layer-switcher-maximize.png');\n- this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(\n- this.displayClass + 'MaximizeButton',\n- null,\n- null,\n- img,\n- 'absolute');\n- this.maximizeDiv.style.display = 'none';\n- this.maximizeDiv.className = this.displayClass + 'MaximizeButton olButton';\n- if (this.maximizeTitle) {\n- this.maximizeDiv.title = this.maximizeTitle;\n- }\n- this.div.appendChild(this.maximizeDiv);\n-\n- // minimize button div\n- var img = OpenLayers.Util.getImageLocation('layer-switcher-minimize.png');\n- this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv(\n- 'OpenLayers_Control_minimizeDiv',\n- null,\n- null,\n- img,\n- 'absolute');\n- this.minimizeDiv.style.display = 'none';\n- this.minimizeDiv.className = this.displayClass + 'MinimizeButton olButton';\n- if (this.minimizeTitle) {\n- this.minimizeDiv.title = this.minimizeTitle;\n- }\n- this.div.appendChild(this.minimizeDiv);\n- this.minimizeControl();\n- } else {\n- // show the overview map\n- this.element.style.display = '';\n- }\n- if (this.map.getExtent()) {\n- this.update();\n- }\n-\n- this.map.events.on({\n- buttonclick: this.onButtonClick,\n- moveend: this.update,\n- scope: this\n- });\n-\n- if (this.maximized) {\n- this.maximizeControl();\n- }\n- return this.div;\n- },\n-\n- /**\n- * Method: baseLayerDraw\n- * Draw the base layer - called if unable to complete in the initial draw\n- */\n- baseLayerDraw: function() {\n- this.draw();\n- this.map.events.unregister(\"changebaselayer\", this, this.baseLayerDraw);\n- },\n-\n- /**\n- * Method: rectDrag\n- * Handle extent rectangle drag\n- *\n- * Parameters:\n- * px - {} The pixel location of the drag.\n- */\n- rectDrag: function(px) {\n- var deltaX = this.handlers.drag.last.x - px.x;\n- var deltaY = this.handlers.drag.last.y - px.y;\n- if (deltaX != 0 || deltaY != 0) {\n- var rectTop = this.rectPxBounds.top;\n- var rectLeft = this.rectPxBounds.left;\n- var rectHeight = Math.abs(this.rectPxBounds.getHeight());\n- var rectWidth = this.rectPxBounds.getWidth();\n- // don't allow dragging off of parent element\n- var newTop = Math.max(0, (rectTop - deltaY));\n- newTop = Math.min(newTop,\n- this.ovmap.size.h - this.hComp - rectHeight);\n- var newLeft = Math.max(0, (rectLeft - deltaX));\n- newLeft = Math.min(newLeft,\n- this.ovmap.size.w - this.wComp - rectWidth);\n- this.setRectPxBounds(new OpenLayers.Bounds(newLeft,\n- newTop + rectHeight,\n- newLeft + rectWidth,\n- newTop));\n- }\n- },\n-\n- /**\n- * Method: mapDivClick\n- * Handle browser events\n- *\n- * Parameters:\n- * evt - {} evt\n- */\n- mapDivClick: function(evt) {\n- var pxCenter = this.rectPxBounds.getCenterPixel();\n- var deltaX = evt.xy.x - pxCenter.x;\n- var deltaY = evt.xy.y - pxCenter.y;\n- var top = this.rectPxBounds.top;\n- var left = this.rectPxBounds.left;\n- var height = Math.abs(this.rectPxBounds.getHeight());\n- var width = this.rectPxBounds.getWidth();\n- var newTop = Math.max(0, (top + deltaY));\n- newTop = Math.min(newTop, this.ovmap.size.h - height);\n- var newLeft = Math.max(0, (left + deltaX));\n- newLeft = Math.min(newLeft, this.ovmap.size.w - width);\n- this.setRectPxBounds(new OpenLayers.Bounds(newLeft,\n- newTop + height,\n- newLeft + width,\n- newTop));\n- this.updateMapToRect();\n- },\n-\n- /**\n- * Method: onButtonClick\n- *\n- * Parameters:\n- * evt - {Event}\n- */\n- onButtonClick: function(evt) {\n- if (evt.buttonElement === this.minimizeDiv) {\n- this.minimizeControl();\n- } else if (evt.buttonElement === this.maximizeDiv) {\n- this.maximizeControl();\n- }\n- },\n-\n- /**\n- * Method: maximizeControl\n- * Unhide the control. Called when the control is in the map viewport.\n- *\n- * Parameters:\n- * e - {}\n- */\n- maximizeControl: function(e) {\n- this.element.style.display = '';\n- this.showToggle(false);\n- if (e != null) {\n- OpenLayers.Event.stop(e);\n- }\n- },\n-\n- /**\n- * Method: minimizeControl\n- * Hide all the contents of the control, shrink the size, \n- * add the maximize icon\n- * \n- * Parameters:\n- * e - {}\n- */\n- minimizeControl: function(e) {\n- this.element.style.display = 'none';\n- this.showToggle(true);\n- if (e != null) {\n- OpenLayers.Event.stop(e);\n- }\n- },\n-\n- /**\n- * Method: showToggle\n- * Hide/Show the toggle depending on whether the control is minimized\n- *\n- * Parameters:\n- * minimize - {Boolean} \n- */\n- showToggle: function(minimize) {\n- if (this.maximizeDiv) {\n- this.maximizeDiv.style.display = minimize ? '' : 'none';\n- }\n- if (this.minimizeDiv) {\n- this.minimizeDiv.style.display = minimize ? 'none' : '';\n- }\n- },\n-\n- /**\n- * Method: update\n- * Update the overview map after layers move.\n- */\n- update: function() {\n- if (this.ovmap == null) {\n- this.createMap();\n- }\n-\n- if (this.autoPan || !this.isSuitableOverview()) {\n- this.updateOverview();\n- }\n-\n- // update extent rectangle\n- this.updateRectToMap();\n- },\n-\n- /**\n- * Method: isSuitableOverview\n- * Determines if the overview map is suitable given the extent and\n- * resolution of the main map.\n- */\n- isSuitableOverview: function() {\n- var mapExtent = this.map.getExtent();\n- var maxExtent = this.map.getMaxExtent();\n- var testExtent = new OpenLayers.Bounds(\n- Math.max(mapExtent.left, maxExtent.left),\n- Math.max(mapExtent.bottom, maxExtent.bottom),\n- Math.min(mapExtent.right, maxExtent.right),\n- Math.min(mapExtent.top, maxExtent.top));\n-\n- if (this.ovmap.getProjection() != this.map.getProjection()) {\n- testExtent = testExtent.transform(\n- this.map.getProjectionObject(),\n- this.ovmap.getProjectionObject());\n- }\n-\n- var resRatio = this.ovmap.getResolution() / this.map.getResolution();\n- return ((resRatio > this.minRatio) &&\n- (resRatio <= this.maxRatio) &&\n- (this.ovmap.getExtent().containsBounds(testExtent)));\n- },\n-\n- /**\n- * Method updateOverview\n- * Called by if returns true\n- */\n- updateOverview: function() {\n- var mapRes = this.map.getResolution();\n- var targetRes = this.ovmap.getResolution();\n- var resRatio = targetRes / mapRes;\n- if (resRatio > this.maxRatio) {\n- // zoom in overview map\n- targetRes = this.minRatio * mapRes;\n- } else if (resRatio <= this.minRatio) {\n- // zoom out overview map\n- targetRes = this.maxRatio * mapRes;\n- }\n- var center;\n- if (this.ovmap.getProjection() != this.map.getProjection()) {\n- center = this.map.center.clone();\n- center.transform(this.map.getProjectionObject(),\n- this.ovmap.getProjectionObject());\n- } else {\n- center = this.map.center;\n- }\n- this.ovmap.setCenter(center, this.ovmap.getZoomForResolution(\n- targetRes * this.resolutionFactor));\n- this.updateRectToMap();\n- },\n-\n- /**\n- * Method: createMap\n- * Construct the map that this control contains\n- */\n- createMap: function() {\n- // create the overview map\n- var options = OpenLayers.Util.extend({\n- controls: [],\n- maxResolution: 'auto',\n- fallThrough: false\n- }, this.mapOptions);\n- this.ovmap = new OpenLayers.Map(this.mapDiv, options);\n- this.ovmap.viewPortDiv.appendChild(this.extentRectangle);\n-\n- // prevent ovmap from being destroyed when the page unloads, because\n- // the OverviewMap control has to do this (and does it).\n- OpenLayers.Event.stopObserving(window, 'unload', this.ovmap.unloadDestroy);\n-\n- this.ovmap.addLayers(this.layers);\n- this.ovmap.zoomToMaxExtent();\n- // check extent rectangle border width\n- this.wComp = parseInt(OpenLayers.Element.getStyle(this.extentRectangle,\n- 'border-left-width')) +\n- parseInt(OpenLayers.Element.getStyle(this.extentRectangle,\n- 'border-right-width'));\n- this.wComp = (this.wComp) ? this.wComp : 2;\n- this.hComp = parseInt(OpenLayers.Element.getStyle(this.extentRectangle,\n- 'border-top-width')) +\n- parseInt(OpenLayers.Element.getStyle(this.extentRectangle,\n- 'border-bottom-width'));\n- this.hComp = (this.hComp) ? this.hComp : 2;\n-\n- this.handlers.drag = new OpenLayers.Handler.Drag(\n- this, {\n- move: this.rectDrag,\n- done: this.updateMapToRect\n- }, {\n- map: this.ovmap\n- }\n- );\n- this.handlers.click = new OpenLayers.Handler.Click(\n- this, {\n- \"click\": this.mapDivClick\n- }, {\n- \"single\": true,\n- \"double\": false,\n- \"stopSingle\": true,\n- \"stopDouble\": true,\n- \"pixelTolerance\": 1,\n- map: this.ovmap\n- }\n- );\n- this.handlers.click.activate();\n-\n- this.rectEvents = new OpenLayers.Events(this, this.extentRectangle,\n- null, true);\n- this.rectEvents.register(\"mouseover\", this, function(e) {\n- if (!this.handlers.drag.active && !this.map.dragging) {\n- this.handlers.drag.activate();\n- }\n- });\n- this.rectEvents.register(\"mouseout\", this, function(e) {\n- if (!this.handlers.drag.dragging) {\n- this.handlers.drag.deactivate();\n- }\n- });\n-\n- if (this.ovmap.getProjection() != this.map.getProjection()) {\n- var sourceUnits = this.map.getProjectionObject().getUnits() ||\n- this.map.units || this.map.baseLayer.units;\n- var targetUnits = this.ovmap.getProjectionObject().getUnits() ||\n- this.ovmap.units || this.ovmap.baseLayer.units;\n- this.resolutionFactor = sourceUnits && targetUnits ?\n- OpenLayers.INCHES_PER_UNIT[sourceUnits] /\n- OpenLayers.INCHES_PER_UNIT[targetUnits] : 1;\n- }\n- },\n-\n- /**\n- * Method: updateRectToMap\n- * Updates the extent rectangle position and size to match the map extent\n- */\n- updateRectToMap: function() {\n- // If the projections differ we need to reproject\n- var bounds;\n- if (this.ovmap.getProjection() != this.map.getProjection()) {\n- bounds = this.map.getExtent().transform(\n- this.map.getProjectionObject(),\n- this.ovmap.getProjectionObject());\n- } else {\n- bounds = this.map.getExtent();\n- }\n- var pxBounds = this.getRectBoundsFromMapBounds(bounds);\n- if (pxBounds) {\n- this.setRectPxBounds(pxBounds);\n- }\n- },\n-\n- /**\n- * Method: updateMapToRect\n- * Updates the map extent to match the extent rectangle position and size\n- */\n- updateMapToRect: function() {\n- var lonLatBounds = this.getMapBoundsFromRectBounds(this.rectPxBounds);\n- if (this.ovmap.getProjection() != this.map.getProjection()) {\n- lonLatBounds = lonLatBounds.transform(\n- this.ovmap.getProjectionObject(),\n- this.map.getProjectionObject());\n- }\n- this.map.panTo(lonLatBounds.getCenterLonLat());\n- },\n-\n- /**\n- * Method: setRectPxBounds\n- * Set extent rectangle pixel bounds.\n- *\n- * Parameters:\n- * pxBounds - {}\n- */\n- setRectPxBounds: function(pxBounds) {\n- var top = Math.max(pxBounds.top, 0);\n- var left = Math.max(pxBounds.left, 0);\n- var bottom = Math.min(pxBounds.top + Math.abs(pxBounds.getHeight()),\n- this.ovmap.size.h - this.hComp);\n- var right = Math.min(pxBounds.left + pxBounds.getWidth(),\n- this.ovmap.size.w - this.wComp);\n- var width = Math.max(right - left, 0);\n- var height = Math.max(bottom - top, 0);\n- if (width < this.minRectSize || height < this.minRectSize) {\n- this.extentRectangle.className = this.displayClass +\n- this.minRectDisplayClass;\n- var rLeft = left + (width / 2) - (this.minRectSize / 2);\n- var rTop = top + (height / 2) - (this.minRectSize / 2);\n- this.extentRectangle.style.top = Math.round(rTop) + 'px';\n- this.extentRectangle.style.left = Math.round(rLeft) + 'px';\n- this.extentRectangle.style.height = this.minRectSize + 'px';\n- this.extentRectangle.style.width = this.minRectSize + 'px';\n- } else {\n- this.extentRectangle.className = this.displayClass +\n- 'ExtentRectangle';\n- this.extentRectangle.style.top = Math.round(top) + 'px';\n- this.extentRectangle.style.left = Math.round(left) + 'px';\n- this.extentRectangle.style.height = Math.round(height) + 'px';\n- this.extentRectangle.style.width = Math.round(width) + 'px';\n- }\n- this.rectPxBounds = new OpenLayers.Bounds(\n- Math.round(left), Math.round(bottom),\n- Math.round(right), Math.round(top)\n- );\n- },\n-\n- /**\n- * Method: getRectBoundsFromMapBounds\n- * Get the rect bounds from the map bounds.\n- *\n- * Parameters:\n- * lonLatBounds - {}\n- *\n- * Returns:\n- * {}A bounds which is the passed-in map lon/lat extent\n- * translated into pixel bounds for the overview map\n- */\n- getRectBoundsFromMapBounds: function(lonLatBounds) {\n- var leftBottomPx = this.getOverviewPxFromLonLat({\n- lon: lonLatBounds.left,\n- lat: lonLatBounds.bottom\n- });\n- var rightTopPx = this.getOverviewPxFromLonLat({\n- lon: lonLatBounds.right,\n- lat: lonLatBounds.top\n- });\n- var bounds = null;\n- if (leftBottomPx && rightTopPx) {\n- bounds = new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y,\n- rightTopPx.x, rightTopPx.y);\n- }\n- return bounds;\n- },\n-\n- /**\n- * Method: getMapBoundsFromRectBounds\n- * Get the map bounds from the rect bounds.\n- *\n- * Parameters:\n- * pxBounds - {}\n- *\n- * Returns:\n- * {} Bounds which is the passed-in overview rect bounds\n- * translated into lon/lat bounds for the overview map\n- */\n- getMapBoundsFromRectBounds: function(pxBounds) {\n- var leftBottomLonLat = this.getLonLatFromOverviewPx({\n- x: pxBounds.left,\n- y: pxBounds.bottom\n- });\n- var rightTopLonLat = this.getLonLatFromOverviewPx({\n- x: pxBounds.right,\n- y: pxBounds.top\n- });\n- return new OpenLayers.Bounds(leftBottomLonLat.lon, leftBottomLonLat.lat,\n- rightTopLonLat.lon, rightTopLonLat.lat);\n- },\n-\n- /**\n- * Method: getLonLatFromOverviewPx\n- * Get a map location from a pixel location\n- *\n- * Parameters:\n- * overviewMapPx - {|Object} OpenLayers.Pixel or\n- * an object with a\n- * 'x' and 'y' properties.\n- *\n- * Returns:\n- * {Object} Location which is the passed-in overview map\n- * OpenLayers.Pixel, translated into lon/lat by the overview\n- * map. An object with a 'lon' and 'lat' properties.\n- */\n- getLonLatFromOverviewPx: function(overviewMapPx) {\n- var size = this.ovmap.size;\n- var res = this.ovmap.getResolution();\n- var center = this.ovmap.getExtent().getCenterLonLat();\n-\n- var deltaX = overviewMapPx.x - (size.w / 2);\n- var deltaY = overviewMapPx.y - (size.h / 2);\n-\n- return {\n- lon: center.lon + deltaX * res,\n- lat: center.lat - deltaY * res\n- };\n- },\n-\n- /**\n- * Method: getOverviewPxFromLonLat\n- * Get a pixel location from a map location\n- *\n- * Parameters:\n- * lonlat - {|Object} OpenLayers.LonLat or an\n- * object with a 'lon' and 'lat' properties.\n- *\n- * Returns:\n- * {Object} Location which is the passed-in OpenLayers.LonLat, \n- * translated into overview map pixels\n- */\n- getOverviewPxFromLonLat: function(lonlat) {\n- var res = this.ovmap.getResolution();\n- var extent = this.ovmap.getExtent();\n- if (extent) {\n- return {\n- x: Math.round(1 / res * (lonlat.lon - extent.left)),\n- y: Math.round(1 / res * (extent.top - lonlat.lat))\n- };\n- }\n- },\n-\n- CLASS_NAME: 'OpenLayers.Control.OverviewMap'\n-});\n-/* ======================================================================\n- OpenLayers/Control/CacheWrite.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Request.js\n- * @requires OpenLayers/Console.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.CacheWrite\n- * A control for caching image tiles in the browser's local storage. The\n- * control is used to fetch and use the cached\n- * tile images.\n- *\n- * Note: Before using this control on any layer that is not your own, make sure\n- * that the terms of service of the tile provider allow local storage of tiles.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.CacheWrite = OpenLayers.Class(OpenLayers.Control, {\n-\n- /** \n- * APIProperty: events\n- * {} Events instance for listeners and triggering\n- * control specific events.\n- *\n- * To register events in the constructor, configure .\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * control.events.register(type, obj, listener);\n- * (end)\n- *\n- * Supported event types (in addition to those from ):\n- * cachefull - Triggered when the cache is full. Listeners receive an\n- * object with a tile property as first argument. The tile references\n- * the tile that couldn't be cached.\n- */\n-\n- /**\n- * APIProperty: eventListeners\n- * {Object} Object with event listeners, keyed by event name. An optional\n- * scope property defines the scope that listeners will be executed in.\n- */\n-\n- /**\n- * APIProperty: layers\n- * {Array()}. Optional. If provided, caching\n- * will be enabled for these layers only, otherwise for all cacheable\n- * layers.\n- */\n- layers: null,\n-\n- /**\n- * APIProperty: imageFormat\n- * {String} The image format used for caching. The default is \"image/png\".\n- * Supported formats depend on the user agent. If an unsupported\n- * is provided, \"image/png\" will be used. For aerial\n- * imagery, \"image/jpeg\" is recommended.\n- */\n- imageFormat: \"image/png\",\n-\n- /**\n- * Property: quotaRegEx\n- * {RegExp}\n- */\n- quotaRegEx: (/quota/i),\n-\n- /**\n- * Constructor: OpenLayers.Control.CacheWrite\n- *\n- * Parameters:\n- * options - {Object} Object with API properties for this control.\n- */\n-\n- /** \n- * Method: setMap\n- * Set the map property for the control. \n- * \n- * Parameters:\n- * map - {} \n- */\n- setMap: function(map) {\n- OpenLayers.Control.prototype.setMap.apply(this, arguments);\n- var i, layers = this.layers || map.layers;\n- for (i = layers.length - 1; i >= 0; --i) {\n- this.addLayer({\n- layer: layers[i]\n- });\n- }\n- if (!this.layers) {\n- map.events.on({\n- addlayer: this.addLayer,\n- removeLayer: this.removeLayer,\n- scope: this\n- });\n- }\n- },\n-\n- /**\n- * Method: addLayer\n- * Adds a layer to the control. Once added, tiles requested for this layer\n- * will be cached.\n- *\n- * Parameters:\n- * evt - {Object} Object with a layer property referencing an\n- * instance\n- */\n- addLayer: function(evt) {\n- evt.layer.events.on({\n- tileloadstart: this.makeSameOrigin,\n- tileloaded: this.onTileLoaded,\n- scope: this\n- });\n- },\n-\n- /**\n- * Method: removeLayer\n- * Removes a layer from the control. Once removed, tiles requested for this\n- * layer will no longer be cached.\n- *\n- * Parameters:\n- * evt - {Object} Object with a layer property referencing an\n- * instance\n- */\n- removeLayer: function(evt) {\n- evt.layer.events.un({\n- tileloadstart: this.makeSameOrigin,\n- tileloaded: this.onTileLoaded,\n- scope: this\n- });\n- },\n-\n- /**\n- * Method: makeSameOrigin\n- * If the tile does not have CORS image loading enabled and is from a\n- * different origin, use OpenLayers.ProxyHost to make it a same origin url.\n- *\n- * Parameters:\n- * evt - {}\n- */\n- makeSameOrigin: function(evt) {\n- if (this.active) {\n- var tile = evt.tile;\n- if (tile instanceof OpenLayers.Tile.Image &&\n- !tile.crossOriginKeyword &&\n- tile.url.substr(0, 5) !== \"data:\") {\n- var sameOriginUrl = OpenLayers.Request.makeSameOrigin(\n- tile.url, OpenLayers.ProxyHost\n- );\n- OpenLayers.Control.CacheWrite.urlMap[sameOriginUrl] = tile.url;\n- tile.url = sameOriginUrl;\n- }\n- }\n- },\n-\n- /**\n- * Method: onTileLoaded\n- * Decides whether a tile can be cached and calls the cache method.\n- *\n- * Parameters:\n- * evt - {Event}\n- */\n- onTileLoaded: function(evt) {\n- if (this.active && !evt.aborted &&\n- evt.tile instanceof OpenLayers.Tile.Image &&\n- evt.tile.url.substr(0, 5) !== 'data:') {\n- this.cache({\n- tile: evt.tile\n- });\n- delete OpenLayers.Control.CacheWrite.urlMap[evt.tile.url];\n- }\n- },\n-\n- /**\n- * Method: cache\n- * Adds a tile to the cache. When the cache is full, the \"cachefull\" event\n- * is triggered.\n- *\n- * Parameters:\n- * obj - {Object} Object with a tile property, tile being the\n- * with the data to add to the cache\n- */\n- cache: function(obj) {\n- if (window.localStorage) {\n- var tile = obj.tile;\n- try {\n- var canvasContext = tile.getCanvasContext();\n- if (canvasContext) {\n- var urlMap = OpenLayers.Control.CacheWrite.urlMap;\n- var url = urlMap[tile.url] || tile.url;\n- window.localStorage.setItem(\n- \"olCache_\" + url,\n- canvasContext.canvas.toDataURL(this.imageFormat)\n- );\n- }\n- } catch (e) {\n- // local storage full or CORS violation\n- var reason = e.name || e.message;\n- if (reason && this.quotaRegEx.test(reason)) {\n- this.events.triggerEvent(\"cachefull\", {\n- tile: tile\n- });\n- } else {\n- OpenLayers.Console.error(e.toString());\n- }\n- }\n- }\n- },\n-\n- /**\n- * Method: destroy\n- * The destroy method is used to perform any clean up before the control\n- * is dereferenced. Typically this is where event listeners are removed\n- * to prevent memory leaks.\n- */\n- destroy: function() {\n- if (this.layers || this.map) {\n- var i, layers = this.layers || this.map.layers;\n- for (i = layers.length - 1; i >= 0; --i) {\n- this.removeLayer({\n- layer: layers[i]\n- });\n- }\n- }\n- if (this.map) {\n- this.map.events.un({\n- addlayer: this.addLayer,\n- removeLayer: this.removeLayer,\n- scope: this\n- });\n- }\n- OpenLayers.Control.prototype.destroy.apply(this, arguments);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Control.CacheWrite\"\n-});\n-\n-/**\n- * APIFunction: OpenLayers.Control.CacheWrite.clearCache\n- * Clears all tiles cached with from the cache.\n- */\n-OpenLayers.Control.CacheWrite.clearCache = function() {\n- if (!window.localStorage) {\n- return;\n- }\n- var i, key;\n- for (i = window.localStorage.length - 1; i >= 0; --i) {\n- key = window.localStorage.key(i);\n- if (key.substr(0, 8) === \"olCache_\") {\n- window.localStorage.removeItem(key);\n- }\n- }\n-};\n-\n-/**\n- * Property: OpenLayers.Control.CacheWrite.urlMap\n- * {Object} Mapping of same origin urls to cache url keys. Entries will be\n- * deleted as soon as a tile was cached.\n- */\n-OpenLayers.Control.CacheWrite.urlMap = {};\n-\n-\n-/* ======================================================================\n- OpenLayers/Handler/Feature.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/Handler.js\n- */\n-\n-/**\n- * Class: OpenLayers.Handler.Feature \n- * Handler to respond to mouse events related to a drawn feature. Callbacks\n- * with the following keys will be notified of the following events\n- * associated with features: click, clickout, over, out, and dblclick.\n- *\n- * This handler stops event propagation for mousedown and mouseup if those\n- * browser events target features that can be selected.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Handler.Feature = OpenLayers.Class(OpenLayers.Handler, {\n-\n- /**\n- * Property: EVENTMAP\n- * {Object} A object mapping the browser events to objects with callback\n- * keys for in and out.\n- */\n- EVENTMAP: {\n- 'click': {\n- 'in': 'click',\n- 'out': 'clickout'\n- },\n- 'mousemove': {\n- 'in': 'over',\n- 'out': 'out'\n- },\n- 'dblclick': {\n- 'in': 'dblclick',\n- 'out': null\n- },\n- 'mousedown': {\n- 'in': null,\n- 'out': null\n- },\n- 'mouseup': {\n- 'in': null,\n- 'out': null\n- },\n- 'touchstart': {\n- 'in': 'click',\n- 'out': 'clickout'\n- }\n- },\n-\n- /**\n- * Property: feature\n- * {} The last feature that was hovered.\n- */\n- feature: null,\n-\n- /**\n- * Property: lastFeature\n- * {} The last feature that was handled.\n- */\n- lastFeature: null,\n-\n- /**\n- * Property: down\n- * {} The location of the last mousedown.\n- */\n- down: null,\n-\n- /**\n- * Property: up\n- * {} The location of the last mouseup.\n- */\n- up: null,\n-\n- /**\n- * Property: clickTolerance\n- * {Number} The number of pixels the mouse can move between mousedown\n- * and mouseup for the event to still be considered a click.\n- * Dragging the map should not trigger the click and clickout callbacks\n- * unless the map is moved by less than this tolerance. Defaults to 4.\n- */\n- clickTolerance: 4,\n-\n- /**\n- * Property: geometryTypes\n- * To restrict dragging to a limited set of geometry types, send a list\n- * of strings corresponding to the geometry class names.\n- * \n- * @type Array(String)\n- */\n- geometryTypes: null,\n-\n- /**\n- * Property: stopClick\n- * {Boolean} If stopClick is set to true, handled clicks do not\n- * propagate to other click listeners. Otherwise, handled clicks\n- * do propagate. Unhandled clicks always propagate, whatever the\n- * value of stopClick. Defaults to true.\n- */\n- stopClick: true,\n-\n- /**\n- * Property: stopDown\n- * {Boolean} If stopDown is set to true, handled mousedowns do not\n- * propagate to other mousedown listeners. Otherwise, handled\n- * mousedowns do propagate. Unhandled mousedowns always propagate,\n- * whatever the value of stopDown. Defaults to true.\n- */\n- stopDown: true,\n-\n- /**\n- * Property: stopUp\n- * {Boolean} If stopUp is set to true, handled mouseups do not\n- * propagate to other mouseup listeners. Otherwise, handled mouseups\n- * do propagate. Unhandled mouseups always propagate, whatever the\n- * value of stopUp. Defaults to false.\n- */\n- stopUp: false,\n-\n- /**\n- * Constructor: OpenLayers.Handler.Feature\n- *\n- * Parameters:\n- * control - {} \n- * layer - {}\n- * callbacks - {Object} An object with a 'over' property whos value is\n- * a function to be called when the mouse is over a feature. The \n- * callback should expect to recieve a single argument, the feature.\n- * options - {Object} \n- */\n- initialize: function(control, layer, callbacks, options) {\n- OpenLayers.Handler.prototype.initialize.apply(this, [control, callbacks, options]);\n- this.layer = layer;\n- },\n-\n- /**\n- * Method: touchstart\n- * Handle touchstart events\n- *\n- * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n- */\n- touchstart: function(evt) {\n- this.startTouch();\n- return OpenLayers.Event.isMultiTouch(evt) ?\n- true : this.mousedown(evt);\n- },\n-\n- /**\n- * Method: touchmove\n- * Handle touchmove events. We just prevent the browser default behavior,\n- * for Android Webkit not to select text when moving the finger after\n- * selecting a feature.\n- *\n- * Parameters:\n- * evt - {Event}\n- */\n- touchmove: function(evt) {\n- OpenLayers.Event.preventDefault(evt);\n- },\n-\n- /**\n- * Method: mousedown\n- * Handle mouse down. Stop propagation if a feature is targeted by this\n- * event (stops map dragging during feature selection).\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- mousedown: function(evt) {\n- // Feature selection is only done with a left click. Other handlers may stop the\n- // propagation of left-click mousedown events but not right-click mousedown events.\n- // This mismatch causes problems when comparing the location of the down and up\n- // events in the click function so it is important ignore right-clicks.\n- if (OpenLayers.Event.isLeftClick(evt) || OpenLayers.Event.isSingleTouch(evt)) {\n- this.down = evt.xy;\n- }\n- return this.handle(evt) ? !this.stopDown : true;\n- },\n-\n- /**\n- * Method: mouseup\n- * Handle mouse up. Stop propagation if a feature is targeted by this\n- * event.\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- mouseup: function(evt) {\n- this.up = evt.xy;\n- return this.handle(evt) ? !this.stopUp : true;\n- },\n-\n- /**\n- * Method: click\n- * Handle click. Call the \"click\" callback if click on a feature,\n- * or the \"clickout\" callback if click outside any feature.\n- * \n- * Parameters:\n- * evt - {Event} \n- *\n- * Returns:\n- * {Boolean}\n- */\n- click: function(evt) {\n- return this.handle(evt) ? !this.stopClick : true;\n- },\n-\n- /**\n- * Method: mousemove\n- * Handle mouse moves. Call the \"over\" callback if moving in to a feature,\n- * or the \"out\" callback if moving out of a feature.\n- * \n- * Parameters:\n- * evt - {Event} \n- *\n- * Returns:\n- * {Boolean}\n- */\n- mousemove: function(evt) {\n- if (!this.callbacks['over'] && !this.callbacks['out']) {\n- return true;\n- }\n- this.handle(evt);\n- return true;\n- },\n-\n- /**\n- * Method: dblclick\n- * Handle dblclick. Call the \"dblclick\" callback if dblclick on a feature.\n- *\n- * Parameters:\n- * evt - {Event} \n- *\n- * Returns:\n- * {Boolean}\n- */\n- dblclick: function(evt) {\n- return !this.handle(evt);\n- },\n-\n- /**\n- * Method: geometryTypeMatches\n- * Return true if the geometry type of the passed feature matches\n- * one of the geometry types in the geometryTypes array.\n- *\n- * Parameters:\n- * feature - {}\n- *\n- * Returns:\n- * {Boolean}\n- */\n- geometryTypeMatches: function(feature) {\n- return this.geometryTypes == null ||\n- OpenLayers.Util.indexOf(this.geometryTypes,\n- feature.geometry.CLASS_NAME) > -1;\n- },\n-\n- /**\n- * Method: handle\n- *\n- * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} The event occurred over a relevant feature.\n- */\n- handle: function(evt) {\n- if (this.feature && !this.feature.layer) {\n- // feature has been destroyed\n- this.feature = null;\n- }\n- var type = evt.type;\n- var handled = false;\n- var previouslyIn = !!(this.feature); // previously in a feature\n- var click = (type == \"click\" || type == \"dblclick\" || type == \"touchstart\");\n- this.feature = this.layer.getFeatureFromEvent(evt);\n- if (this.feature && !this.feature.layer) {\n- // feature has been destroyed\n- this.feature = null;\n- }\n- if (this.lastFeature && !this.lastFeature.layer) {\n- // last feature has been destroyed\n- this.lastFeature = null;\n- }\n- if (this.feature) {\n- if (type === \"touchstart\") {\n- // stop the event to prevent Android Webkit from\n- // \"flashing\" the map div\n- OpenLayers.Event.preventDefault(evt);\n- }\n- var inNew = (this.feature != this.lastFeature);\n- if (this.geometryTypeMatches(this.feature)) {\n- // in to a feature\n- if (previouslyIn && inNew) {\n- // out of last feature and in to another\n- if (this.lastFeature) {\n- this.triggerCallback(type, 'out', [this.lastFeature]);\n- }\n- this.triggerCallback(type, 'in', [this.feature]);\n- } else if (!previouslyIn || click) {\n- // in feature for the first time\n- this.triggerCallback(type, 'in', [this.feature]);\n- }\n- this.lastFeature = this.feature;\n- handled = true;\n- } else {\n- // not in to a feature\n- if (this.lastFeature && (previouslyIn && inNew || click)) {\n- // out of last feature for the first time\n- this.triggerCallback(type, 'out', [this.lastFeature]);\n- }\n- // next time the mouse goes in a feature whose geometry type\n- // doesn't match we don't want to call the 'out' callback\n- // again, so let's set this.feature to null so that\n- // previouslyIn will evaluate to false the next time\n- // we enter handle. Yes, a bit hackish...\n- this.feature = null;\n- }\n- } else if (this.lastFeature && (previouslyIn || click)) {\n- this.triggerCallback(type, 'out', [this.lastFeature]);\n- }\n- return handled;\n- },\n-\n- /**\n- * Method: triggerCallback\n- * Call the callback keyed in the event map with the supplied arguments.\n- * For click and clickout, the is checked first.\n- *\n- * Parameters:\n- * type - {String}\n- */\n- triggerCallback: function(type, mode, args) {\n- var key = this.EVENTMAP[type][mode];\n- if (key) {\n- if (type == 'click' && this.up && this.down) {\n- // for click/clickout, only trigger callback if tolerance is met\n- var dpx = Math.sqrt(\n- Math.pow(this.up.x - this.down.x, 2) +\n- Math.pow(this.up.y - this.down.y, 2)\n- );\n- if (dpx <= this.clickTolerance) {\n- this.callback(key, args);\n- }\n- // we're done with this set of events now: clear the cached\n- // positions so we can't trip over them later (this can occur\n- // if one of the up/down events gets eaten before it gets to us\n- // but we still get the click)\n- this.up = this.down = null;\n- } else {\n- this.callback(key, args);\n- }\n- }\n- },\n-\n- /**\n- * Method: activate \n- * Turn on the handler. Returns false if the handler was already active.\n- *\n- * Returns:\n- * {Boolean}\n- */\n- activate: function() {\n- var activated = false;\n- if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n- this.moveLayerToTop();\n- this.map.events.on({\n- \"removelayer\": this.handleMapEvents,\n- \"changelayer\": this.handleMapEvents,\n- scope: this\n- });\n- activated = true;\n- }\n- return activated;\n- },\n-\n- /**\n- * Method: deactivate \n- * Turn off the handler. Returns false if the handler was already active.\n- *\n- * Returns: \n- * {Boolean}\n- */\n- deactivate: function() {\n- var deactivated = false;\n- if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- this.moveLayerBack();\n- this.feature = null;\n- this.lastFeature = null;\n- this.down = null;\n- this.up = null;\n- this.map.events.un({\n- \"removelayer\": this.handleMapEvents,\n- \"changelayer\": this.handleMapEvents,\n- scope: this\n- });\n- deactivated = true;\n- }\n- return deactivated;\n- },\n-\n- /**\n- * Method: handleMapEvents\n- * \n- * Parameters:\n- * evt - {Object}\n- */\n- handleMapEvents: function(evt) {\n- if (evt.type == \"removelayer\" || evt.property == \"order\") {\n- this.moveLayerToTop();\n- }\n- },\n-\n- /**\n- * Method: moveLayerToTop\n- * Moves the layer for this handler to the top, so mouse events can reach\n- * it.\n- */\n- moveLayerToTop: function() {\n- var index = Math.max(this.map.Z_INDEX_BASE['Feature'] - 1,\n- this.layer.getZIndex()) + 1;\n- this.layer.setZIndex(index);\n-\n- },\n-\n- /**\n- * Method: moveLayerBack\n- * Moves the layer back to the position determined by the map's layers\n- * array.\n- */\n- moveLayerBack: function() {\n- var index = this.layer.getZIndex() - 1;\n- if (index >= this.map.Z_INDEX_BASE['Feature']) {\n- this.layer.setZIndex(index);\n- } else {\n- this.map.setLayerZIndex(this.layer,\n- this.map.getLayerIndex(this.layer));\n- }\n- },\n-\n- CLASS_NAME: \"OpenLayers.Handler.Feature\"\n-});\n-/* ======================================================================\n- OpenLayers/Control/DragFeature.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Handler/Drag.js\n- * @requires OpenLayers/Handler/Feature.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.DragFeature\n- * The DragFeature control moves a feature with a drag of the mouse. Create a\n- * new control with the constructor.\n- *\n- * Inherits From:\n- * - \n- */\n-OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {\n-\n- /**\n- * APIProperty: geometryTypes\n- * {Array(String)} To restrict dragging to a limited set of geometry types,\n- * send a list of strings corresponding to the geometry class names.\n- */\n- geometryTypes: null,\n-\n- /**\n- * APIProperty: onStart\n- * {Function} Define this function if you want to know when a drag starts.\n- * The function should expect to receive two arguments: the feature\n- * that is about to be dragged and the pixel location of the mouse.\n- *\n- * Parameters:\n- * feature - {} The feature that is about to be\n- * dragged.\n- * pixel - {} The pixel location of the mouse.\n- */\n- onStart: function(feature, pixel) {},\n-\n- /**\n- * APIProperty: onDrag\n- * {Function} Define this function if you want to know about each move of a\n- * feature. The function should expect to receive two arguments: the\n- * feature that is being dragged and the pixel location of the mouse.\n- *\n- * Parameters:\n- * feature - {} The feature that was dragged.\n- * pixel - {} The pixel location of the mouse.\n- */\n- onDrag: function(feature, pixel) {},\n-\n- /**\n- * APIProperty: onComplete\n- * {Function} Define this function if you want to know when a feature is\n- * done dragging. The function should expect to receive two arguments:\n- * the feature that is being dragged and the pixel location of the\n- * mouse.\n- *\n- * Parameters:\n- * feature - {} The feature that was dragged.\n- * pixel - {} The pixel location of the mouse.\n- */\n- onComplete: function(feature, pixel) {},\n-\n- /**\n- * APIProperty: onEnter\n- * {Function} Define this function if you want to know when the mouse\n- * goes over a feature and thereby makes this feature a candidate\n- * for dragging.\n- *\n- * Parameters:\n- * feature - {} The feature that is ready\n- * to be dragged.\n- */\n- onEnter: function(feature) {},\n-\n- /**\n- * APIProperty: onLeave\n- * {Function} Define this function if you want to know when the mouse\n- * goes out of the feature that was dragged.\n- *\n- * Parameters:\n- * feature - {} The feature that was dragged.\n- */\n- onLeave: function(feature) {},\n-\n- /**\n- * APIProperty: documentDrag\n- * {Boolean} If set to true, mouse dragging will continue even if the\n- * mouse cursor leaves the map viewport. Default is false.\n- */\n- documentDrag: false,\n-\n- /**\n- * Property: layer\n- * {}\n- */\n- layer: null,\n-\n- /**\n- * Property: feature\n- * {}\n- */\n- feature: null,\n-\n- /**\n- * Property: dragCallbacks\n- * {Object} The functions that are sent to the drag handler for callback.\n- */\n- dragCallbacks: {},\n-\n- /**\n- * Property: featureCallbacks\n- * {Object} The functions that are sent to the feature handler for callback.\n- */\n- featureCallbacks: {},\n-\n- /**\n- * Property: lastPixel\n- * {}\n- */\n- lastPixel: null,\n-\n- /**\n- * Constructor: OpenLayers.Control.DragFeature\n- * Create a new control to drag features.\n- *\n- * Parameters:\n- * layer - {} The layer containing features to be\n- * dragged.\n- * options - {Object} Optional object whose properties will be set on the\n- * control.\n- */\n- initialize: function(layer, options) {\n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n- this.layer = layer;\n- this.handlers = {\n- drag: new OpenLayers.Handler.Drag(\n- this, OpenLayers.Util.extend({\n- down: this.downFeature,\n- move: this.moveFeature,\n- up: this.upFeature,\n- out: this.cancel,\n- done: this.doneDragging\n- }, this.dragCallbacks), {\n- documentDrag: this.documentDrag\n- }\n- ),\n- feature: new OpenLayers.Handler.Feature(\n- this, this.layer, OpenLayers.Util.extend({\n- // 'click' and 'clickout' callback are for the mobile\n- // support: no 'over' or 'out' in touch based browsers.\n- click: this.clickFeature,\n- clickout: this.clickoutFeature,\n- over: this.overFeature,\n- out: this.outFeature\n- }, this.featureCallbacks), {\n- geometryTypes: this.geometryTypes\n- }\n- )\n- };\n- },\n-\n- /**\n- * Method: clickFeature\n- * Called when the feature handler detects a click-in on a feature.\n- *\n- * Parameters:\n- * feature - {}\n- */\n- clickFeature: function(feature) {\n- if (this.handlers.feature.touch && !this.over && this.overFeature(feature)) {\n- this.handlers.drag.dragstart(this.handlers.feature.evt);\n- // to let the events propagate to the feature handler (click callback)\n- this.handlers.drag.stopDown = false;\n- }\n- },\n-\n- /**\n- * Method: clickoutFeature\n- * Called when the feature handler detects a click-out on a feature.\n- *\n- * Parameters:\n- * feature - {}\n- */\n- clickoutFeature: function(feature) {\n- if (this.handlers.feature.touch && this.over) {\n- this.outFeature(feature);\n- this.handlers.drag.stopDown = true;\n- }\n- },\n-\n- /**\n- * APIMethod: destroy\n- * Take care of things that are not handled in superclass\n- */\n- destroy: function() {\n- this.layer = null;\n- OpenLayers.Control.prototype.destroy.apply(this, []);\n- },\n-\n- /**\n- * APIMethod: activate\n- * Activate the control and the feature handler.\n- * \n- * Returns:\n- * {Boolean} Successfully activated the control and feature handler.\n- */\n- activate: function() {\n- return (this.handlers.feature.activate() &&\n- OpenLayers.Control.prototype.activate.apply(this, arguments));\n- },\n-\n- /**\n- * APIMethod: deactivate\n- * Deactivate the control and all handlers.\n- * \n- * Returns:\n- * {Boolean} Successfully deactivated the control.\n- */\n- deactivate: function() {\n- // the return from the handlers is unimportant in this case\n- this.handlers.drag.deactivate();\n- this.handlers.feature.deactivate();\n- this.feature = null;\n- this.dragging = false;\n- this.lastPixel = null;\n- OpenLayers.Element.removeClass(\n- this.map.viewPortDiv, this.displayClass + \"Over\"\n- );\n- return OpenLayers.Control.prototype.deactivate.apply(this, arguments);\n- },\n-\n- /**\n- * Method: overFeature\n- * Called when the feature handler detects a mouse-over on a feature.\n- * This activates the drag handler.\n- *\n- * Parameters:\n- * feature - {} The selected feature.\n- *\n- * Returns:\n- * {Boolean} Successfully activated the drag handler.\n- */\n- overFeature: function(feature) {\n- var activated = false;\n- if (!this.handlers.drag.dragging) {\n- this.feature = feature;\n- this.handlers.drag.activate();\n- activated = true;\n- this.over = true;\n- OpenLayers.Element.addClass(this.map.viewPortDiv, this.displayClass + \"Over\");\n- this.onEnter(feature);\n- } else {\n- if (this.feature.id == feature.id) {\n- this.over = true;\n- } else {\n- this.over = false;\n- }\n- }\n- return activated;\n- },\n-\n- /**\n- * Method: downFeature\n- * Called when the drag handler detects a mouse-down.\n- *\n- * Parameters:\n- * pixel - {} Location of the mouse event.\n- */\n- downFeature: function(pixel) {\n- this.lastPixel = pixel;\n- this.onStart(this.feature, pixel);\n- },\n-\n- /**\n- * Method: moveFeature\n- * Called when the drag handler detects a mouse-move. Also calls the\n- * optional onDrag method.\n- * \n- * Parameters:\n- * pixel - {} Location of the mouse event.\n- */\n- moveFeature: function(pixel) {\n- var res = this.map.getResolution();\n- this.feature.geometry.move(res * (pixel.x - this.lastPixel.x),\n- res * (this.lastPixel.y - pixel.y));\n- this.layer.drawFeature(this.feature);\n- this.lastPixel = pixel;\n- this.onDrag(this.feature, pixel);\n- },\n-\n- /**\n- * Method: upFeature\n- * Called when the drag handler detects a mouse-up.\n- * \n- * Parameters:\n- * pixel - {} Location of the mouse event.\n- */\n- upFeature: function(pixel) {\n- if (!this.over) {\n- this.handlers.drag.deactivate();\n- }\n- },\n-\n- /**\n- * Method: doneDragging\n- * Called when the drag handler is done dragging.\n- *\n- * Parameters:\n- * pixel - {} The last event pixel location. If this event\n- * came from a mouseout, this may not be in the map viewport.\n- */\n- doneDragging: function(pixel) {\n- this.onComplete(this.feature, pixel);\n- },\n-\n- /**\n- * Method: outFeature\n- * Called when the feature handler detects a mouse-out on a feature.\n- *\n- * Parameters:\n- * feature - {} The feature that the mouse left.\n- */\n- outFeature: function(feature) {\n- if (!this.handlers.drag.dragging) {\n- this.over = false;\n- this.handlers.drag.deactivate();\n- OpenLayers.Element.removeClass(\n- this.map.viewPortDiv, this.displayClass + \"Over\"\n- );\n- this.onLeave(feature);\n- this.feature = null;\n- } else {\n- if (this.feature.id == feature.id) {\n- this.over = false;\n- }\n- }\n- },\n-\n- /**\n- * Method: cancel\n- * Called when the drag handler detects a mouse-out (from the map viewport).\n- */\n- cancel: function() {\n- this.handlers.drag.deactivate();\n- this.over = false;\n- },\n-\n- /**\n- * Method: setMap\n- * Set the map property for the control and all handlers.\n- *\n- * Parameters: \n- * map - {} The control's map.\n- */\n- setMap: function(map) {\n- this.handlers.drag.setMap(map);\n- this.handlers.feature.setMap(map);\n- OpenLayers.Control.prototype.setMap.apply(this, arguments);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Control.DragFeature\"\n-});\n-/* ======================================================================\n- OpenLayers/Control/TransformFeature.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Control/DragFeature.js\n- * @requires OpenLayers/Feature/Vector.js\n- * @requires OpenLayers/Geometry/LineString.js\n- * @requires OpenLayers/Geometry/Point.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.TransformFeature\n- * Control to transform features with a standard transformation box.\n- *\n- * Inherits From:\n- * - \n- */\n-OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {\n-\n- /** \n- * APIProperty: events\n- * {} Events instance for listeners and triggering\n- * control specific events.\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * control.events.register(type, obj, listener);\n- * (end)\n- *\n- * Supported event types (in addition to those from ):\n- * beforesetfeature - Triggered before a feature is set for\n- * tranformation. The feature will not be set if a listener returns\n- * false. Listeners receive a *feature* property, with the feature\n- * that will be set for transformation. Listeners are allowed to\n- * set the control's *scale*, *ratio* and *rotation* properties,\n- * which will set the initial scale, ratio and rotation of the\n- * feature, like the method's initialParams argument.\n- * setfeature - Triggered when a feature is set for tranformation.\n- * Listeners receive a *feature* property, with the feature that\n- * is now set for transformation.\n- * beforetransform - Triggered while dragging, before a feature is\n- * transformed. The feature will not be transformed if a listener\n- * returns false (but the box still will). Listeners receive one or\n- * more of *center*, *scale*, *ratio* and *rotation*. The *center*\n- * property is an object with the new\n- * center of the transformed feature, the others are Floats with the\n- * scale, ratio or rotation change since the last transformation.\n- * transform - Triggered while dragging, when a feature is transformed.\n- * Listeners receive an event object with one or more of *center*,\n- * scale*, *ratio* and *rotation*. The *center* property is an\n- * object with the new center of the\n- * transformed feature, the others are Floats with the scale, ratio\n- * or rotation change of the feature since the last transformation.\n- * transformcomplete - Triggered after dragging. Listeners receive\n- * an event object with the transformed *feature*.\n- */\n-\n- /**\n- * APIProperty: geometryTypes\n- * {Array(String)} To restrict transformation to a limited set of geometry\n- * types, send a list of strings corresponding to the geometry class\n- * names.\n- */\n- geometryTypes: null,\n-\n- /**\n- * Property: layer\n- * {}\n- */\n- layer: null,\n-\n- /**\n- * APIProperty: preserveAspectRatio\n- * {Boolean} set to true to not change the feature's aspect ratio.\n- */\n- preserveAspectRatio: false,\n-\n- /**\n- * APIProperty: rotate\n- * {Boolean} set to false if rotation should be disabled. Default is true.\n- * To be passed with the constructor or set when the control is not\n- * active.\n- */\n- rotate: true,\n-\n- /**\n- * APIProperty: feature\n- * {} Feature currently available for\n- * transformation. Read-only, use to set it manually.\n- */\n- feature: null,\n-\n- /**\n- * APIProperty: renderIntent\n- * {String|Object} Render intent for the transformation box and\n- * handles. A symbolizer object can also be provided here.\n- */\n- renderIntent: \"temporary\",\n-\n- /**\n- * APIProperty: rotationHandleSymbolizer\n- * {Object|String} Optional. A custom symbolizer for the rotation handles.\n- * A render intent can also be provided here. Defaults to\n- * (code)\n- * {\n- * stroke: false,\n- * pointRadius: 10,\n- * fillOpacity: 0,\n- * cursor: \"pointer\"\n- * }\n- * (end)\n- */\n- rotationHandleSymbolizer: null,\n-\n- /**\n- * APIProperty: box\n- * {} The transformation box rectangle.\n- * Read-only.\n- */\n- box: null,\n-\n- /**\n- * APIProperty: center\n- * {} The center of the feature bounds.\n- * Read-only.\n- */\n- center: null,\n-\n- /**\n- * APIProperty: scale\n- * {Float} The scale of the feature, relative to the scale the time the\n- * feature was set. Read-only, except for *beforesetfeature*\n- * listeners.\n- */\n- scale: 1,\n-\n- /**\n- * APIProperty: ratio\n- * {Float} The ratio of the feature relative to the ratio the time the\n- * feature was set. Read-only, except for *beforesetfeature*\n- * listeners.\n- */\n- ratio: 1,\n-\n- /**\n- * Property: rotation\n- * {Integer} the current rotation angle of the box. Read-only, except for\n- * *beforesetfeature* listeners.\n- */\n- rotation: 0,\n-\n- /**\n- * APIProperty: handles\n- * {Array()} The 8 handles currently available\n- * for scaling/resizing. Numbered counterclockwise, starting from the\n- * southwest corner. Read-only.\n- */\n- handles: null,\n-\n- /**\n- * APIProperty: rotationHandles\n- * {Array()} The 4 rotation handles currently\n- * available for rotating. Numbered counterclockwise, starting from\n- * the southwest corner. Read-only.\n- */\n- rotationHandles: null,\n-\n- /**\n- * Property: dragControl\n- * {}\n- */\n- dragControl: null,\n-\n- /**\n- * APIProperty: irregular\n- * {Boolean} Make scaling/resizing work irregularly. If true then\n- * dragging a handle causes the feature to resize in the direction\n- * of movement. If false then the feature resizes symetrically\n- * about it's center.\n- */\n- irregular: false,\n-\n- /**\n- * Constructor: OpenLayers.Control.TransformFeature\n- * Create a new transform feature control.\n- *\n- * Parameters:\n- * layer - {} Layer that contains features that\n- * will be transformed.\n- * options - {Object} Optional object whose properties will be set on the\n- * control.\n- */\n- initialize: function(layer, options) {\n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n-\n- this.layer = layer;\n-\n- if (!this.rotationHandleSymbolizer) {\n- this.rotationHandleSymbolizer = {\n- stroke: false,\n- pointRadius: 10,\n- fillOpacity: 0,\n- cursor: \"pointer\"\n- };\n- }\n-\n- this.createBox();\n- this.createControl();\n- },\n-\n- /**\n- * APIMethod: activate\n- * Activates the control.\n- */\n- activate: function() {\n- var activated = false;\n- if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {\n- this.dragControl.activate();\n- this.layer.addFeatures([this.box]);\n- this.rotate && this.layer.addFeatures(this.rotationHandles);\n- this.layer.addFeatures(this.handles);\n- activated = true;\n- }\n- return activated;\n- },\n-\n- /**\n- * APIMethod: deactivate\n- * Deactivates the control.\n- */\n- deactivate: function() {\n- var deactivated = false;\n- if (OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {\n- this.layer.removeFeatures(this.handles);\n- this.rotate && this.layer.removeFeatures(this.rotationHandles);\n- this.layer.removeFeatures([this.box]);\n- this.dragControl.deactivate();\n- deactivated = true;\n- }\n- return deactivated;\n- },\n-\n- /**\n- * Method: setMap\n- * \n- * Parameters:\n- * map - {}\n- */\n- setMap: function(map) {\n- this.dragControl.setMap(map);\n- OpenLayers.Control.prototype.setMap.apply(this, arguments);\n- },\n-\n- /**\n- * APIMethod: setFeature\n- * Place the transformation box on a feature and start transforming it.\n- * If the control is not active, it will be activated.\n- * \n- * Parameters:\n- * feature - {}\n- * initialParams - {Object} Initial values for rotation, scale or ratio.\n- * Setting a rotation value here will cause the transformation box to\n- * start rotated. Setting a scale or ratio will not affect the\n- * transormation box, but applications may use this to keep track of\n- * scale and ratio of a feature across multiple transforms.\n- */\n- setFeature: function(feature, initialParams) {\n- initialParams = OpenLayers.Util.applyDefaults(initialParams, {\n- rotation: 0,\n- scale: 1,\n- ratio: 1\n- });\n-\n- var oldRotation = this.rotation;\n- var oldCenter = this.center;\n- OpenLayers.Util.extend(this, initialParams);\n-\n- var cont = this.events.triggerEvent(\"beforesetfeature\", {\n- feature: feature\n- });\n- if (cont === false) {\n- return;\n- }\n-\n- this.feature = feature;\n- this.activate();\n-\n- this._setfeature = true;\n-\n- var featureBounds = this.feature.geometry.getBounds();\n- this.box.move(featureBounds.getCenterLonLat());\n- this.box.geometry.rotate(-oldRotation, oldCenter);\n- this._angle = 0;\n-\n- var ll;\n- if (this.rotation) {\n- var geom = feature.geometry.clone();\n- geom.rotate(-this.rotation, this.center);\n- var box = new OpenLayers.Feature.Vector(\n- geom.getBounds().toGeometry());\n- box.geometry.rotate(this.rotation, this.center);\n- this.box.geometry.rotate(this.rotation, this.center);\n- this.box.move(box.geometry.getBounds().getCenterLonLat());\n- var llGeom = box.geometry.components[0].components[0];\n- ll = llGeom.getBounds().getCenterLonLat();\n- } else {\n- ll = new OpenLayers.LonLat(featureBounds.left, featureBounds.bottom);\n- }\n- this.handles[0].move(ll);\n-\n- delete this._setfeature;\n-\n- this.events.triggerEvent(\"setfeature\", {\n- feature: feature\n- });\n- },\n-\n- /**\n- * APIMethod: unsetFeature\n- * Remove the transformation box off any feature.\n- * If the control is active, it will be deactivated first.\n- */\n- unsetFeature: function() {\n- if (this.active) {\n- this.deactivate();\n- } else {\n- this.feature = null;\n- this.rotation = 0;\n- this.scale = 1;\n- this.ratio = 1;\n- }\n- },\n-\n- /**\n- * Method: createBox\n- * Creates the box with all handles and transformation handles.\n- */\n- createBox: function() {\n- var control = this;\n-\n- this.center = new OpenLayers.Geometry.Point(0, 0);\n- this.box = new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.LineString([\n- new OpenLayers.Geometry.Point(-1, -1),\n- new OpenLayers.Geometry.Point(0, -1),\n- new OpenLayers.Geometry.Point(1, -1),\n- new OpenLayers.Geometry.Point(1, 0),\n- new OpenLayers.Geometry.Point(1, 1),\n- new OpenLayers.Geometry.Point(0, 1),\n- new OpenLayers.Geometry.Point(-1, 1),\n- new OpenLayers.Geometry.Point(-1, 0),\n- new OpenLayers.Geometry.Point(-1, -1)\n- ]), null,\n- typeof this.renderIntent == \"string\" ? null : this.renderIntent\n- );\n-\n- // Override for box move - make sure that the center gets updated\n- this.box.geometry.move = function(x, y) {\n- control._moving = true;\n- OpenLayers.Geometry.LineString.prototype.move.apply(this, arguments);\n- control.center.move(x, y);\n- delete control._moving;\n- };\n-\n- // Overrides for vertex move, resize and rotate - make sure that\n- // handle and rotationHandle geometries are also moved, resized and\n- // rotated.\n- var vertexMoveFn = function(x, y) {\n- OpenLayers.Geometry.Point.prototype.move.apply(this, arguments);\n- this._rotationHandle && this._rotationHandle.geometry.move(x, y);\n- this._handle.geometry.move(x, y);\n- };\n- var vertexResizeFn = function(scale, center, ratio) {\n- OpenLayers.Geometry.Point.prototype.resize.apply(this, arguments);\n- this._rotationHandle && this._rotationHandle.geometry.resize(\n- scale, center, ratio);\n- this._handle.geometry.resize(scale, center, ratio);\n- };\n- var vertexRotateFn = function(angle, center) {\n- OpenLayers.Geometry.Point.prototype.rotate.apply(this, arguments);\n- this._rotationHandle && this._rotationHandle.geometry.rotate(\n- angle, center);\n- this._handle.geometry.rotate(angle, center);\n- };\n-\n- // Override for handle move - make sure that the box and other handles\n- // are updated, and finally transform the feature.\n- var handleMoveFn = function(x, y) {\n- var oldX = this.x,\n- oldY = this.y;\n- OpenLayers.Geometry.Point.prototype.move.call(this, x, y);\n- if (control._moving) {\n- return;\n- }\n- var evt = control.dragControl.handlers.drag.evt;\n- var preserveAspectRatio = !control._setfeature &&\n- control.preserveAspectRatio;\n- var reshape = !preserveAspectRatio && !(evt && evt.shiftKey);\n- var oldGeom = new OpenLayers.Geometry.Point(oldX, oldY);\n- var centerGeometry = control.center;\n- this.rotate(-control.rotation, centerGeometry);\n- oldGeom.rotate(-control.rotation, centerGeometry);\n- var dx1 = this.x - centerGeometry.x;\n- var dy1 = this.y - centerGeometry.y;\n- var dx0 = dx1 - (this.x - oldGeom.x);\n- var dy0 = dy1 - (this.y - oldGeom.y);\n- if (control.irregular && !control._setfeature) {\n- dx1 -= (this.x - oldGeom.x) / 2;\n- dy1 -= (this.y - oldGeom.y) / 2;\n- }\n- this.x = oldX;\n- this.y = oldY;\n- var scale, ratio = 1;\n- if (reshape) {\n- scale = Math.abs(dy0) < 0.00001 ? 1 : dy1 / dy0;\n- ratio = (Math.abs(dx0) < 0.00001 ? 1 : (dx1 / dx0)) / scale;\n- } else {\n- var l0 = Math.sqrt((dx0 * dx0) + (dy0 * dy0));\n- var l1 = Math.sqrt((dx1 * dx1) + (dy1 * dy1));\n- scale = l1 / l0;\n- }\n-\n- // rotate the box to 0 before resizing - saves us some\n- // calculations and is inexpensive because we don't drawFeature.\n- control._moving = true;\n- control.box.geometry.rotate(-control.rotation, centerGeometry);\n- delete control._moving;\n-\n- control.box.geometry.resize(scale, centerGeometry, ratio);\n- control.box.geometry.rotate(control.rotation, centerGeometry);\n- control.transformFeature({\n- scale: scale,\n- ratio: ratio\n- });\n- if (control.irregular && !control._setfeature) {\n- var newCenter = centerGeometry.clone();\n- newCenter.x += Math.abs(oldX - centerGeometry.x) < 0.00001 ? 0 : (this.x - oldX);\n- newCenter.y += Math.abs(oldY - centerGeometry.y) < 0.00001 ? 0 : (this.y - oldY);\n- control.box.geometry.move(this.x - oldX, this.y - oldY);\n- control.transformFeature({\n- center: newCenter\n- });\n- }\n- };\n-\n- // Override for rotation handle move - make sure that the box and\n- // other handles are updated, and finally transform the feature.\n- var rotationHandleMoveFn = function(x, y) {\n- var oldX = this.x,\n- oldY = this.y;\n- OpenLayers.Geometry.Point.prototype.move.call(this, x, y);\n- if (control._moving) {\n- return;\n- }\n- var evt = control.dragControl.handlers.drag.evt;\n- var constrain = (evt && evt.shiftKey) ? 45 : 1;\n- var centerGeometry = control.center;\n- var dx1 = this.x - centerGeometry.x;\n- var dy1 = this.y - centerGeometry.y;\n- var dx0 = dx1 - x;\n- var dy0 = dy1 - y;\n- this.x = oldX;\n- this.y = oldY;\n- var a0 = Math.atan2(dy0, dx0);\n- var a1 = Math.atan2(dy1, dx1);\n- var angle = a1 - a0;\n- angle *= 180 / Math.PI;\n- control._angle = (control._angle + angle) % 360;\n- var diff = control.rotation % constrain;\n- if (Math.abs(control._angle) >= constrain || diff !== 0) {\n- angle = Math.round(control._angle / constrain) * constrain -\n- diff;\n- control._angle = 0;\n- control.box.geometry.rotate(angle, centerGeometry);\n- control.transformFeature({\n- rotation: angle\n- });\n- }\n- };\n-\n- var handles = new Array(8);\n- var rotationHandles = new Array(4);\n- var geom, handle, rotationHandle;\n- var positions = [\"sw\", \"s\", \"se\", \"e\", \"ne\", \"n\", \"nw\", \"w\"];\n- for (var i = 0; i < 8; ++i) {\n- geom = this.box.geometry.components[i];\n- handle = new OpenLayers.Feature.Vector(geom.clone(), {\n- role: positions[i] + \"-resize\"\n- }, typeof this.renderIntent == \"string\" ? null :\n- this.renderIntent);\n- if (i % 2 == 0) {\n- rotationHandle = new OpenLayers.Feature.Vector(geom.clone(), {\n- role: positions[i] + \"-rotate\"\n- }, typeof this.rotationHandleSymbolizer == \"string\" ?\n- null : this.rotationHandleSymbolizer);\n- rotationHandle.geometry.move = rotationHandleMoveFn;\n- geom._rotationHandle = rotationHandle;\n- rotationHandles[i / 2] = rotationHandle;\n- }\n- geom.move = vertexMoveFn;\n- geom.resize = vertexResizeFn;\n- geom.rotate = vertexRotateFn;\n- handle.geometry.move = handleMoveFn;\n- geom._handle = handle;\n- handles[i] = handle;\n- }\n-\n- this.rotationHandles = rotationHandles;\n- this.handles = handles;\n- },\n-\n- /**\n- * Method: createControl\n- * Creates a DragFeature control for this control.\n- */\n- createControl: function() {\n- var control = this;\n- this.dragControl = new OpenLayers.Control.DragFeature(this.layer, {\n- documentDrag: true,\n- // avoid moving the feature itself - move the box instead\n- moveFeature: function(pixel) {\n- if (this.feature === control.feature) {\n- this.feature = control.box;\n- }\n- OpenLayers.Control.DragFeature.prototype.moveFeature.apply(this,\n- arguments);\n- },\n- // transform while dragging\n- onDrag: function(feature, pixel) {\n- if (feature === control.box) {\n- control.transformFeature({\n- center: control.center\n- });\n- }\n- },\n- // set a new feature\n- onStart: function(feature, pixel) {\n- var eligible = !control.geometryTypes ||\n- OpenLayers.Util.indexOf(control.geometryTypes,\n- feature.geometry.CLASS_NAME) !== -1;\n- var i = OpenLayers.Util.indexOf(control.handles, feature);\n- i += OpenLayers.Util.indexOf(control.rotationHandles,\n- feature);\n- if (feature !== control.feature && feature !== control.box &&\n- i == -2 && eligible) {\n- control.setFeature(feature);\n- }\n- },\n- onComplete: function(feature, pixel) {\n- control.events.triggerEvent(\"transformcomplete\", {\n- feature: control.feature\n- });\n- }\n- });\n- },\n-\n- /**\n- * Method: drawHandles\n- * Draws the handles to match the box.\n- */\n- drawHandles: function() {\n- var layer = this.layer;\n- for (var i = 0; i < 8; ++i) {\n- if (this.rotate && i % 2 === 0) {\n- layer.drawFeature(this.rotationHandles[i / 2],\n- this.rotationHandleSymbolizer);\n- }\n- layer.drawFeature(this.handles[i], this.renderIntent);\n- }\n- },\n-\n- /**\n- * Method: transformFeature\n- * Transforms the feature.\n- * \n- * Parameters:\n- * mods - {Object} An object with optional scale, ratio, rotation and\n- * center properties.\n- */\n- transformFeature: function(mods) {\n- if (!this._setfeature) {\n- this.scale *= (mods.scale || 1);\n- this.ratio *= (mods.ratio || 1);\n- var oldRotation = this.rotation;\n- this.rotation = (this.rotation + (mods.rotation || 0)) % 360;\n-\n- if (this.events.triggerEvent(\"beforetransform\", mods) !== false) {\n- var feature = this.feature;\n- var geom = feature.geometry;\n- var center = this.center;\n- geom.rotate(-oldRotation, center);\n- if (mods.scale || mods.ratio) {\n- geom.resize(mods.scale, center, mods.ratio);\n- } else if (mods.center) {\n- feature.move(mods.center.getBounds().getCenterLonLat());\n- }\n- geom.rotate(this.rotation, center);\n- this.layer.drawFeature(feature);\n- feature.toState(OpenLayers.State.UPDATE);\n- this.events.triggerEvent(\"transform\", mods);\n- }\n- }\n- this.layer.drawFeature(this.box, this.renderIntent);\n- this.drawHandles();\n- },\n-\n- /**\n- * APIMethod: destroy\n- * Take care of things that are not handled in superclass.\n- */\n- destroy: function() {\n- var geom;\n- for (var i = 0; i < 8; ++i) {\n- geom = this.box.geometry.components[i];\n- geom._handle.destroy();\n- geom._handle = null;\n- geom._rotationHandle && geom._rotationHandle.destroy();\n- geom._rotationHandle = null;\n- }\n- this.center = null;\n- this.feature = null;\n- this.handles = null;\n- this.rotationHandleSymbolizer = null;\n- this.rotationHandles = null;\n- this.box.destroy();\n- this.box = null;\n- this.layer = null;\n- this.dragControl.destroy();\n- this.dragControl = null;\n- OpenLayers.Control.prototype.destroy.apply(this, arguments);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Control.TransformFeature\"\n-});\n-/* ======================================================================\n- OpenLayers/Control/CacheRead.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Control.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.CacheRead\n- * A control for using image tiles cached with \n- * from the browser's local storage.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.CacheRead = OpenLayers.Class(OpenLayers.Control, {\n-\n- /**\n- * APIProperty: fetchEvent\n- * {String} The layer event to listen to for replacing remote resource tile\n- * URLs with cached data URIs. Supported values are \"tileerror\" (try\n- * remote first, fall back to cached) and \"tileloadstart\" (try cache\n- * first, fall back to remote). Default is \"tileloadstart\".\n- *\n- * Note that \"tileerror\" will not work for CORS enabled images (see\n- * https://developer.mozilla.org/en/CORS_Enabled_Image), i.e. layers\n- * configured with a in\n- * .\n- */\n- fetchEvent: \"tileloadstart\",\n-\n- /**\n- * APIProperty: layers\n- * {Array()}. Optional. If provided, only these\n- * layers will receive tiles from the cache.\n- */\n- layers: null,\n-\n- /**\n- * APIProperty: autoActivate\n- * {Boolean} Activate the control when it is added to a map. Default is\n- * true.\n- */\n- autoActivate: true,\n-\n- /**\n- * Constructor: OpenLayers.Control.CacheRead\n- *\n- * Parameters:\n- * options - {Object} Object with API properties for this control\n- */\n-\n- /** \n- * Method: setMap\n- * Set the map property for the control. \n- * \n- * Parameters:\n- * map - {} \n- */\n- setMap: function(map) {\n- OpenLayers.Control.prototype.setMap.apply(this, arguments);\n- var i, layers = this.layers || map.layers;\n- for (i = layers.length - 1; i >= 0; --i) {\n- this.addLayer({\n- layer: layers[i]\n- });\n- }\n- if (!this.layers) {\n- map.events.on({\n- addlayer: this.addLayer,\n- removeLayer: this.removeLayer,\n- scope: this\n- });\n- }\n- },\n-\n- /**\n- * Method: addLayer\n- * Adds a layer to the control. Once added, tiles requested for this layer\n- * will be cached.\n- *\n- * Parameters:\n- * evt - {Object} Object with a layer property referencing an\n- * instance\n- */\n- addLayer: function(evt) {\n- evt.layer.events.register(this.fetchEvent, this, this.fetch);\n- },\n-\n- /**\n- * Method: removeLayer\n- * Removes a layer from the control. Once removed, tiles requested for this\n- * layer will no longer be cached.\n- *\n- * Parameters:\n- * evt - {Object} Object with a layer property referencing an\n- * instance\n- */\n- removeLayer: function(evt) {\n- evt.layer.events.unregister(this.fetchEvent, this, this.fetch);\n- },\n-\n- /**\n- * Method: fetch\n- * Listener to the event. Replaces a tile's url with a data\n- * URI from the cache.\n- *\n- * Parameters:\n- * evt - {Object} Event object with a tile property.\n- */\n- fetch: function(evt) {\n- if (this.active && window.localStorage &&\n- evt.tile instanceof OpenLayers.Tile.Image) {\n- var tile = evt.tile,\n- url = tile.url;\n- // deal with modified tile urls when both CacheWrite and CacheRead\n- // are active\n- if (!tile.layer.crossOriginKeyword && OpenLayers.ProxyHost &&\n- url.indexOf(OpenLayers.ProxyHost) === 0) {\n- url = OpenLayers.Control.CacheWrite.urlMap[url];\n- }\n- var dataURI = window.localStorage.getItem(\"olCache_\" + url);\n- if (dataURI) {\n- tile.url = dataURI;\n- if (evt.type === \"tileerror\") {\n- tile.setImgSrc(dataURI);\n- }\n- }\n- }\n- },\n-\n- /**\n- * Method: destroy\n- * The destroy method is used to perform any clean up before the control\n- * is dereferenced. Typically this is where event listeners are removed\n- * to prevent memory leaks.\n- */\n- destroy: function() {\n- if (this.layers || this.map) {\n- var i, layers = this.layers || this.map.layers;\n- for (i = layers.length - 1; i >= 0; --i) {\n- this.removeLayer({\n- layer: layers[i]\n- });\n- }\n- }\n- if (this.map) {\n- this.map.events.un({\n- addlayer: this.addLayer,\n- removeLayer: this.removeLayer,\n- scope: this\n- });\n- }\n- OpenLayers.Control.prototype.destroy.apply(this, arguments);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Control.CacheRead\"\n-});\n-/* ======================================================================\n- OpenLayers/Control/PanZoom.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Events/buttonclick.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.PanZoom\n- * The PanZoom is a visible control, composed of a\n- * and a . By\n- * default it is drawn in the upper left corner of the map.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {\n-\n- /** \n- * APIProperty: slideFactor\n- * {Integer} Number of pixels by which we'll pan the map in any direction \n- * on clicking the arrow buttons. If you want to pan by some ratio\n- * of the map dimensions, use instead.\n- */\n- slideFactor: 50,\n-\n- /** \n- * APIProperty: slideRatio\n- * {Number} The fraction of map width/height by which we'll pan the map \n- * on clicking the arrow buttons. Default is null. If set, will\n- * override . E.g. if slideRatio is .5, then the Pan Up\n- * button will pan up half the map height. \n- */\n- slideRatio: null,\n-\n- /** \n- * Property: buttons\n- * {Array(DOMElement)} Array of Button Divs \n- */\n- buttons: null,\n-\n- /** \n- * Property: position\n- * {} \n- */\n- position: null,\n-\n- /**\n- * Constructor: OpenLayers.Control.PanZoom\n- * \n- * Parameters:\n- * options - {Object}\n- */\n- initialize: function(options) {\n- this.position = new OpenLayers.Pixel(OpenLayers.Control.PanZoom.X,\n- OpenLayers.Control.PanZoom.Y);\n- OpenLayers.Control.prototype.initialize.apply(this, arguments);\n- },\n-\n- /**\n- * APIMethod: destroy\n- */\n- destroy: function() {\n- if (this.map) {\n- this.map.events.unregister(\"buttonclick\", this, this.onButtonClick);\n- }\n- this.removeButtons();\n- this.buttons = null;\n- this.position = null;\n- OpenLayers.Control.prototype.destroy.apply(this, arguments);\n- },\n-\n- /** \n- * Method: setMap\n- *\n- * Properties:\n- * map - {} \n- */\n- setMap: function(map) {\n- OpenLayers.Control.prototype.setMap.apply(this, arguments);\n- this.map.events.register(\"buttonclick\", this, this.onButtonClick);\n- },\n-\n- /**\n- * Method: draw\n- *\n- * Parameters:\n- * px - {} \n- * \n- * Returns:\n- * {DOMElement} A reference to the container div for the PanZoom control.\n- */\n- draw: function(px) {\n- // initialize our internal div\n- OpenLayers.Control.prototype.draw.apply(this, arguments);\n- px = this.position;\n-\n- // place the controls\n- this.buttons = [];\n-\n- var sz = {\n- w: 18,\n- h: 18\n- };\n- var centered = new OpenLayers.Pixel(px.x + sz.w / 2, px.y);\n-\n- this._addButton(\"panup\", \"north-mini.png\", centered, sz);\n- px.y = centered.y + sz.h;\n- this._addButton(\"panleft\", \"west-mini.png\", px, sz);\n- this._addButton(\"panright\", \"east-mini.png\", px.add(sz.w, 0), sz);\n- this._addButton(\"pandown\", \"south-mini.png\",\n- centered.add(0, sz.h * 2), sz);\n- this._addButton(\"zoomin\", \"zoom-plus-mini.png\",\n- centered.add(0, sz.h * 3 + 5), sz);\n- this._addButton(\"zoomworld\", \"zoom-world-mini.png\",\n- centered.add(0, sz.h * 4 + 5), sz);\n- this._addButton(\"zoomout\", \"zoom-minus-mini.png\",\n- centered.add(0, sz.h * 5 + 5), sz);\n- return this.div;\n- },\n-\n- /**\n- * Method: _addButton\n- * \n- * Parameters:\n- * id - {String} \n- * img - {String} \n- * xy - {} \n- * sz - {} \n- * \n- * Returns:\n- * {DOMElement} A Div (an alphaImageDiv, to be precise) that contains the\n- * image of the button, and has all the proper event handlers set.\n- */\n- _addButton: function(id, img, xy, sz) {\n- var imgLocation = OpenLayers.Util.getImageLocation(img);\n- var btn = OpenLayers.Util.createAlphaImageDiv(\n- this.id + \"_\" + id,\n- xy, sz, imgLocation, \"absolute\");\n- btn.style.cursor = \"pointer\";\n- //we want to add the outer div\n- this.div.appendChild(btn);\n- btn.action = id;\n- btn.className = \"olButton\";\n-\n- //we want to remember/reference the outer div\n- this.buttons.push(btn);\n- return btn;\n- },\n-\n- /**\n- * Method: _removeButton\n- * \n- * Parameters:\n- * btn - {Object}\n- */\n- _removeButton: function(btn) {\n- this.div.removeChild(btn);\n- OpenLayers.Util.removeItem(this.buttons, btn);\n- },\n-\n- /**\n- * Method: removeButtons\n- */\n- removeButtons: function() {\n- for (var i = this.buttons.length - 1; i >= 0; --i) {\n- this._removeButton(this.buttons[i]);\n- }\n- },\n-\n- /**\n- * Method: onButtonClick\n- *\n- * Parameters:\n- * evt - {Event}\n- */\n- onButtonClick: function(evt) {\n- var btn = evt.buttonElement;\n- switch (btn.action) {\n- case \"panup\":\n- this.map.pan(0, -this.getSlideFactor(\"h\"));\n- break;\n- case \"pandown\":\n- this.map.pan(0, this.getSlideFactor(\"h\"));\n- break;\n- case \"panleft\":\n- this.map.pan(-this.getSlideFactor(\"w\"), 0);\n- break;\n- case \"panright\":\n- this.map.pan(this.getSlideFactor(\"w\"), 0);\n- break;\n- case \"zoomin\":\n- this.map.zoomIn();\n- break;\n- case \"zoomout\":\n- this.map.zoomOut();\n- break;\n- case \"zoomworld\":\n- this.map.zoomToMaxExtent();\n- break;\n- }\n- },\n-\n- /**\n- * Method: getSlideFactor\n- *\n- * Parameters:\n- * dim - {String} \"w\" or \"h\" (for width or height).\n- *\n- * Returns:\n- * {Number} The slide factor for panning in the requested direction.\n- */\n- getSlideFactor: function(dim) {\n- return this.slideRatio ?\n- this.map.getSize()[dim] * this.slideRatio :\n- this.slideFactor;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Control.PanZoom\"\n-});\n-\n-/**\n- * Constant: X\n- * {Integer}\n- */\n-OpenLayers.Control.PanZoom.X = 4;\n-\n-/**\n- * Constant: Y\n- * {Integer}\n- */\n-OpenLayers.Control.PanZoom.Y = 4;\n-/* ======================================================================\n- OpenLayers/Control/PanZoomBar.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/Control/PanZoom.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.PanZoomBar\n- * The PanZoomBar is a visible control composed of a\n- * and a . \n- * By default it is displayed in the upper left corner of the map as 4\n- * directional arrows above a vertical slider.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {\n-\n- /** \n- * APIProperty: zoomStopWidth\n- */\n- zoomStopWidth: 18,\n-\n- /** \n- * APIProperty: zoomStopHeight\n- */\n- zoomStopHeight: 11,\n-\n- /** \n- * Property: slider\n- */\n- slider: null,\n-\n- /** \n- * Property: sliderEvents\n- * {}\n- */\n- sliderEvents: null,\n-\n- /** \n- * Property: zoombarDiv\n- * {DOMElement}\n- */\n- zoombarDiv: null,\n-\n- /** \n- * APIProperty: zoomWorldIcon\n- * {Boolean}\n- */\n- zoomWorldIcon: false,\n-\n- /**\n- * APIProperty: panIcons\n- * {Boolean} Set this property to false not to display the pan icons. If\n- * false the zoom world icon is placed under the zoom bar. Defaults to\n- * true.\n- */\n- panIcons: true,\n-\n- /**\n- * APIProperty: forceFixedZoomLevel\n- * {Boolean} Force a fixed zoom level even though the map has \n- * fractionalZoom\n- */\n- forceFixedZoomLevel: false,\n-\n- /**\n- * Property: mouseDragStart\n- * {}\n- */\n- mouseDragStart: null,\n-\n- /**\n- * Property: deltaY\n- * {Number} The cumulative vertical pixel offset during a zoom bar drag.\n- */\n- deltaY: null,\n-\n- /**\n- * Property: zoomStart\n- * {}\n- */\n- zoomStart: null,\n-\n- /**\n- * Constructor: OpenLayers.Control.PanZoomBar\n- */\n-\n- /**\n- * APIMethod: destroy\n- */\n- destroy: function() {\n-\n- this._removeZoomBar();\n-\n- this.map.events.un({\n- \"changebaselayer\": this.redraw,\n- \"updatesize\": this.redraw,\n- scope: this\n- });\n-\n- OpenLayers.Control.PanZoom.prototype.destroy.apply(this, arguments);\n-\n- delete this.mouseDragStart;\n- delete this.zoomStart;\n- },\n-\n- /**\n- * Method: setMap\n- * \n- * Parameters:\n- * map - {} \n- */\n- setMap: function(map) {\n- OpenLayers.Control.PanZoom.prototype.setMap.apply(this, arguments);\n- this.map.events.on({\n- \"changebaselayer\": this.redraw,\n- \"updatesize\": this.redraw,\n- scope: this\n- });\n- },\n-\n- /** \n- * Method: redraw\n- * clear the div and start over.\n- */\n- redraw: function() {\n- if (this.div != null) {\n- this.removeButtons();\n- this._removeZoomBar();\n- }\n- this.draw();\n- },\n-\n- /**\n- * Method: draw \n- *\n- * Parameters:\n- * px - {} \n- */\n- draw: function(px) {\n- // initialize our internal div\n- OpenLayers.Control.prototype.draw.apply(this, arguments);\n- px = this.position.clone();\n-\n- // place the controls\n- this.buttons = [];\n-\n- var sz = {\n- w: 18,\n- h: 18\n- };\n- if (this.panIcons) {\n- var centered = new OpenLayers.Pixel(px.x + sz.w / 2, px.y);\n- var wposition = sz.w;\n-\n- if (this.zoomWorldIcon) {\n- centered = new OpenLayers.Pixel(px.x + sz.w, px.y);\n- }\n-\n- this._addButton(\"panup\", \"north-mini.png\", centered, sz);\n- px.y = centered.y + sz.h;\n- this._addButton(\"panleft\", \"west-mini.png\", px, sz);\n- if (this.zoomWorldIcon) {\n- this._addButton(\"zoomworld\", \"zoom-world-mini.png\", px.add(sz.w, 0), sz);\n-\n- wposition *= 2;\n- }\n- this._addButton(\"panright\", \"east-mini.png\", px.add(wposition, 0), sz);\n- this._addButton(\"pandown\", \"south-mini.png\", centered.add(0, sz.h * 2), sz);\n- this._addButton(\"zoomin\", \"zoom-plus-mini.png\", centered.add(0, sz.h * 3 + 5), sz);\n- centered = this._addZoomBar(centered.add(0, sz.h * 4 + 5));\n- this._addButton(\"zoomout\", \"zoom-minus-mini.png\", centered, sz);\n- } else {\n- this._addButton(\"zoomin\", \"zoom-plus-mini.png\", px, sz);\n- centered = this._addZoomBar(px.add(0, sz.h));\n- this._addButton(\"zoomout\", \"zoom-minus-mini.png\", centered, sz);\n- if (this.zoomWorldIcon) {\n- centered = centered.add(0, sz.h + 3);\n- this._addButton(\"zoomworld\", \"zoom-world-mini.png\", centered, sz);\n- }\n- }\n- return this.div;\n- },\n-\n- /** \n- * Method: _addZoomBar\n- * \n- * Parameters:\n- * centered - {} where zoombar drawing is to start.\n- */\n- _addZoomBar: function(centered) {\n- var imgLocation = OpenLayers.Util.getImageLocation(\"slider.png\");\n- var id = this.id + \"_\" + this.map.id;\n- var minZoom = this.map.getMinZoom();\n- var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom();\n- var slider = OpenLayers.Util.createAlphaImageDiv(id,\n- centered.add(-1, zoomsToEnd * this.zoomStopHeight), {\n- w: 20,\n- h: 9\n- },\n- imgLocation,\n- \"absolute\");\n- slider.style.cursor = \"move\";\n- this.slider = slider;\n-\n- this.sliderEvents = new OpenLayers.Events(this, slider, null, true, {\n- includeXY: true\n- });\n- this.sliderEvents.on({\n- \"touchstart\": this.zoomBarDown,\n- \"touchmove\": this.zoomBarDrag,\n- \"touchend\": this.zoomBarUp,\n- \"mousedown\": this.zoomBarDown,\n- \"mousemove\": this.zoomBarDrag,\n- \"mouseup\": this.zoomBarUp\n- });\n-\n- var sz = {\n- w: this.zoomStopWidth,\n- h: this.zoomStopHeight * (this.map.getNumZoomLevels() - minZoom)\n- };\n- var imgLocation = OpenLayers.Util.getImageLocation(\"zoombar.png\");\n- var div = null;\n-\n- if (OpenLayers.Util.alphaHack()) {\n- var id = this.id + \"_\" + this.map.id;\n- div = OpenLayers.Util.createAlphaImageDiv(id, centered, {\n- w: sz.w,\n- h: this.zoomStopHeight\n- },\n- imgLocation,\n- \"absolute\", null, \"crop\");\n- div.style.height = sz.h + \"px\";\n- } else {\n- div = OpenLayers.Util.createDiv(\n- 'OpenLayers_Control_PanZoomBar_Zoombar' + this.map.id,\n- centered,\n- sz,\n- imgLocation);\n- }\n- div.style.cursor = \"pointer\";\n- div.className = \"olButton\";\n- this.zoombarDiv = div;\n-\n- this.div.appendChild(div);\n-\n- this.startTop = parseInt(div.style.top);\n- this.div.appendChild(slider);\n-\n- this.map.events.register(\"zoomend\", this, this.moveZoomBar);\n-\n- centered = centered.add(0,\n- this.zoomStopHeight * (this.map.getNumZoomLevels() - minZoom));\n- return centered;\n- },\n-\n- /**\n- * Method: _removeZoomBar\n- */\n- _removeZoomBar: function() {\n- this.sliderEvents.un({\n- \"touchstart\": this.zoomBarDown,\n- \"touchmove\": this.zoomBarDrag,\n- \"touchend\": this.zoomBarUp,\n- \"mousedown\": this.zoomBarDown,\n- \"mousemove\": this.zoomBarDrag,\n- \"mouseup\": this.zoomBarUp\n- });\n- this.sliderEvents.destroy();\n-\n- this.div.removeChild(this.zoombarDiv);\n- this.zoombarDiv = null;\n- this.div.removeChild(this.slider);\n- this.slider = null;\n-\n- this.map.events.unregister(\"zoomend\", this, this.moveZoomBar);\n- },\n-\n- /**\n- * Method: onButtonClick\n- *\n- * Parameters:\n- * evt - {Event}\n- */\n- onButtonClick: function(evt) {\n- OpenLayers.Control.PanZoom.prototype.onButtonClick.apply(this, arguments);\n- if (evt.buttonElement === this.zoombarDiv) {\n- var levels = evt.buttonXY.y / this.zoomStopHeight;\n- if (this.forceFixedZoomLevel || !this.map.fractionalZoom) {\n- levels = Math.floor(levels);\n- }\n- var zoom = (this.map.getNumZoomLevels() - 1) - levels;\n- zoom = Math.min(Math.max(zoom, 0), this.map.getNumZoomLevels() - 1);\n- this.map.zoomTo(zoom);\n- }\n- },\n-\n- /**\n- * Method: passEventToSlider\n- * This function is used to pass events that happen on the div, or the map,\n- * through to the slider, which then does its moving thing.\n- *\n- * Parameters:\n- * evt - {} \n- */\n- passEventToSlider: function(evt) {\n- this.sliderEvents.handleBrowserEvent(evt);\n- },\n-\n- /*\n- * Method: zoomBarDown\n- * event listener for clicks on the slider\n- *\n- * Parameters:\n- * evt - {} \n- */\n- zoomBarDown: function(evt) {\n- if (!OpenLayers.Event.isLeftClick(evt) && !OpenLayers.Event.isSingleTouch(evt)) {\n- return;\n- }\n- this.map.events.on({\n- \"touchmove\": this.passEventToSlider,\n- \"mousemove\": this.passEventToSlider,\n- \"mouseup\": this.passEventToSlider,\n- scope: this\n- });\n- this.mouseDragStart = evt.xy.clone();\n- this.zoomStart = evt.xy.clone();\n- this.div.style.cursor = \"move\";\n- // reset the div offsets just in case the div moved\n- this.zoombarDiv.offsets = null;\n- OpenLayers.Event.stop(evt);\n- },\n-\n- /*\n- * Method: zoomBarDrag\n- * This is what happens when a click has occurred, and the client is\n- * dragging. Here we must ensure that the slider doesn't go beyond the\n- * bottom/top of the zoombar div, as well as moving the slider to its new\n- * visual location\n- *\n- * Parameters:\n- * evt - {} \n- */\n- zoomBarDrag: function(evt) {\n- if (this.mouseDragStart != null) {\n- var deltaY = this.mouseDragStart.y - evt.xy.y;\n- var offsets = OpenLayers.Util.pagePosition(this.zoombarDiv);\n- if ((evt.clientY - offsets[1]) > 0 &&\n- (evt.clientY - offsets[1]) < parseInt(this.zoombarDiv.style.height) - 2) {\n- var newTop = parseInt(this.slider.style.top) - deltaY;\n- this.slider.style.top = newTop + \"px\";\n- this.mouseDragStart = evt.xy.clone();\n- }\n- // set cumulative displacement\n- this.deltaY = this.zoomStart.y - evt.xy.y;\n- OpenLayers.Event.stop(evt);\n- }\n- },\n-\n- /*\n- * Method: zoomBarUp\n- * Perform cleanup when a mouseup event is received -- discover new zoom\n- * level and switch to it.\n- *\n- * Parameters:\n- * evt - {} \n- */\n- zoomBarUp: function(evt) {\n- if (!OpenLayers.Event.isLeftClick(evt) && evt.type !== \"touchend\") {\n- return;\n- }\n- if (this.mouseDragStart) {\n- this.div.style.cursor = \"\";\n- this.map.events.un({\n- \"touchmove\": this.passEventToSlider,\n- \"mouseup\": this.passEventToSlider,\n- \"mousemove\": this.passEventToSlider,\n- scope: this\n- });\n- var zoomLevel = this.map.zoom;\n- if (!this.forceFixedZoomLevel && this.map.fractionalZoom) {\n- zoomLevel += this.deltaY / this.zoomStopHeight;\n- zoomLevel = Math.min(Math.max(zoomLevel, 0),\n- this.map.getNumZoomLevels() - 1);\n- } else {\n- zoomLevel += this.deltaY / this.zoomStopHeight;\n- zoomLevel = Math.max(Math.round(zoomLevel), 0);\n- }\n- this.map.zoomTo(zoomLevel);\n- this.mouseDragStart = null;\n- this.zoomStart = null;\n- this.deltaY = 0;\n- OpenLayers.Event.stop(evt);\n- }\n- },\n-\n- /*\n- * Method: moveZoomBar\n- * Change the location of the slider to match the current zoom level.\n- */\n- moveZoomBar: function() {\n- var newTop =\n- ((this.map.getNumZoomLevels() - 1) - this.map.getZoom()) *\n- this.zoomStopHeight + this.startTop + 1;\n- this.slider.style.top = newTop + \"px\";\n- },\n-\n- CLASS_NAME: \"OpenLayers.Control.PanZoomBar\"\n-});\n-/* ======================================================================\n- OpenLayers/Layer/WMS.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/Layer/Grid.js\n- */\n-\n-/**\n- * Class: OpenLayers.Layer.WMS\n- * Instances of OpenLayers.Layer.WMS are used to display data from OGC Web\n- * Mapping Services. Create a new WMS layer with the \n- * constructor.\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {\n+OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {\n \n /**\n * Constant: DEFAULT_PARAMS\n * {Object} Hashtable of default parameter key/value pairs \n */\n DEFAULT_PARAMS: {\n service: \"WMS\",\n@@ -49724,14 +42888,333 @@\n this.clear();\n }\n },\n \n CLASS_NAME: \"OpenLayers.Handler.RegularPolygon\"\n });\n /* ======================================================================\n+ OpenLayers/Handler/Polygon.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+\n+/**\n+ * @requires OpenLayers/Handler/Path.js\n+ * @requires OpenLayers/Geometry/Polygon.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Handler.Polygon\n+ * Handler to draw a polygon on the map. Polygon is displayed on mouse down,\n+ * moves on mouse move, and is finished on mouse up.\n+ *\n+ * Inherits from:\n+ * - \n+ * - \n+ */\n+OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {\n+\n+ /** \n+ * APIProperty: holeModifier\n+ * {String} Key modifier to trigger hole digitizing. Acceptable values are\n+ * \"altKey\", \"shiftKey\", or \"ctrlKey\". If not set, no hole digitizing\n+ * will take place. Default is null.\n+ */\n+ holeModifier: null,\n+\n+ /**\n+ * Property: drawingHole\n+ * {Boolean} Currently drawing an interior ring.\n+ */\n+ drawingHole: false,\n+\n+ /**\n+ * Property: polygon\n+ * {}\n+ */\n+ polygon: null,\n+\n+ /**\n+ * Constructor: OpenLayers.Handler.Polygon\n+ * Create a Polygon Handler.\n+ *\n+ * Parameters:\n+ * control - {} The control that owns this handler\n+ * callbacks - {Object} An object with a properties whose values are\n+ * functions. Various callbacks described below.\n+ * options - {Object} An optional object with properties to be set on the\n+ * handler\n+ *\n+ * Named callbacks:\n+ * create - Called when a sketch is first created. Callback called with\n+ * the creation point geometry and sketch feature.\n+ * modify - Called with each move of a vertex with the vertex (point)\n+ * geometry and the sketch feature.\n+ * point - Called as each point is added. Receives the new point geometry.\n+ * done - Called when the point drawing is finished. The callback will\n+ * recieve a single argument, the polygon geometry.\n+ * cancel - Called when the handler is deactivated while drawing. The\n+ * cancel callback will receive a geometry.\n+ */\n+\n+ /**\n+ * Method: createFeature\n+ * Add temporary geometries\n+ *\n+ * Parameters:\n+ * pixel - {} The initial pixel location for the new\n+ * feature.\n+ */\n+ createFeature: function(pixel) {\n+ var lonlat = this.layer.getLonLatFromViewPortPx(pixel);\n+ var geometry = new OpenLayers.Geometry.Point(\n+ lonlat.lon, lonlat.lat\n+ );\n+ this.point = new OpenLayers.Feature.Vector(geometry);\n+ this.line = new OpenLayers.Feature.Vector(\n+ new OpenLayers.Geometry.LinearRing([this.point.geometry])\n+ );\n+ this.polygon = new OpenLayers.Feature.Vector(\n+ new OpenLayers.Geometry.Polygon([this.line.geometry])\n+ );\n+ this.callback(\"create\", [this.point.geometry, this.getSketch()]);\n+ this.point.geometry.clearBounds();\n+ this.layer.addFeatures([this.polygon, this.point], {\n+ silent: true\n+ });\n+ },\n+\n+ /**\n+ * Method: addPoint\n+ * Add point to geometry.\n+ *\n+ * Parameters:\n+ * pixel - {} The pixel location for the new point.\n+ */\n+ addPoint: function(pixel) {\n+ if (!this.drawingHole && this.holeModifier &&\n+ this.evt && this.evt[this.holeModifier]) {\n+ var geometry = this.point.geometry;\n+ var features = this.control.layer.features;\n+ var candidate, polygon;\n+ // look for intersections, last drawn gets priority\n+ for (var i = features.length - 1; i >= 0; --i) {\n+ candidate = features[i].geometry;\n+ if ((candidate instanceof OpenLayers.Geometry.Polygon ||\n+ candidate instanceof OpenLayers.Geometry.MultiPolygon) &&\n+ candidate.intersects(geometry)) {\n+ polygon = features[i];\n+ this.control.layer.removeFeatures([polygon], {\n+ silent: true\n+ });\n+ this.control.layer.events.registerPriority(\n+ \"sketchcomplete\", this, this.finalizeInteriorRing\n+ );\n+ this.control.layer.events.registerPriority(\n+ \"sketchmodified\", this, this.enforceTopology\n+ );\n+ polygon.geometry.addComponent(this.line.geometry);\n+ this.polygon = polygon;\n+ this.drawingHole = true;\n+ break;\n+ }\n+ }\n+ }\n+ OpenLayers.Handler.Path.prototype.addPoint.apply(this, arguments);\n+ },\n+\n+ /**\n+ * Method: getCurrentPointIndex\n+ * \n+ * Returns:\n+ * {Number} The index of the most recently drawn point.\n+ */\n+ getCurrentPointIndex: function() {\n+ return this.line.geometry.components.length - 2;\n+ },\n+\n+ /**\n+ * Method: enforceTopology\n+ * Simple topology enforcement for drawing interior rings. Ensures vertices\n+ * of interior rings are contained by exterior ring. Other topology \n+ * rules are enforced in to allow drawing of \n+ * rings that intersect only during the sketch (e.g. a \"C\" shaped ring\n+ * that nearly encloses another ring).\n+ */\n+ enforceTopology: function(event) {\n+ var point = event.vertex;\n+ var components = this.line.geometry.components;\n+ // ensure that vertices of interior ring are contained by exterior ring\n+ if (!this.polygon.geometry.intersects(point)) {\n+ var last = components[components.length - 3];\n+ point.x = last.x;\n+ point.y = last.y;\n+ }\n+ },\n+\n+ /**\n+ * Method: finishGeometry\n+ * Finish the geometry and send it back to the control.\n+ */\n+ finishGeometry: function() {\n+ var index = this.line.geometry.components.length - 2;\n+ this.line.geometry.removeComponent(this.line.geometry.components[index]);\n+ this.removePoint();\n+ this.finalize();\n+ },\n+\n+ /**\n+ * Method: finalizeInteriorRing\n+ * Enforces that new ring has some area and doesn't contain vertices of any\n+ * other rings.\n+ */\n+ finalizeInteriorRing: function() {\n+ var ring = this.line.geometry;\n+ // ensure that ring has some area\n+ var modified = (ring.getArea() !== 0);\n+ if (modified) {\n+ // ensure that new ring doesn't intersect any other rings\n+ var rings = this.polygon.geometry.components;\n+ for (var i = rings.length - 2; i >= 0; --i) {\n+ if (ring.intersects(rings[i])) {\n+ modified = false;\n+ break;\n+ }\n+ }\n+ if (modified) {\n+ // ensure that new ring doesn't contain any other rings\n+ var target;\n+ outer: for (var i = rings.length - 2; i > 0; --i) {\n+ var points = rings[i].components;\n+ for (var j = 0, jj = points.length; j < jj; ++j) {\n+ if (ring.containsPoint(points[j])) {\n+ modified = false;\n+ break outer;\n+ }\n+ }\n+ }\n+ }\n+ }\n+ if (modified) {\n+ if (this.polygon.state !== OpenLayers.State.INSERT) {\n+ this.polygon.state = OpenLayers.State.UPDATE;\n+ }\n+ } else {\n+ this.polygon.geometry.removeComponent(ring);\n+ }\n+ this.restoreFeature();\n+ return false;\n+ },\n+\n+ /**\n+ * APIMethod: cancel\n+ * Finish the geometry and call the \"cancel\" callback.\n+ */\n+ cancel: function() {\n+ if (this.drawingHole) {\n+ this.polygon.geometry.removeComponent(this.line.geometry);\n+ this.restoreFeature(true);\n+ }\n+ return OpenLayers.Handler.Path.prototype.cancel.apply(this, arguments);\n+ },\n+\n+ /**\n+ * Method: restoreFeature\n+ * Move the feature from the sketch layer to the target layer.\n+ *\n+ * Properties: \n+ * cancel - {Boolean} Cancel drawing. If falsey, the \"sketchcomplete\" event\n+ * will be fired.\n+ */\n+ restoreFeature: function(cancel) {\n+ this.control.layer.events.unregister(\n+ \"sketchcomplete\", this, this.finalizeInteriorRing\n+ );\n+ this.control.layer.events.unregister(\n+ \"sketchmodified\", this, this.enforceTopology\n+ );\n+ this.layer.removeFeatures([this.polygon], {\n+ silent: true\n+ });\n+ this.control.layer.addFeatures([this.polygon], {\n+ silent: true\n+ });\n+ this.drawingHole = false;\n+ if (!cancel) {\n+ // Re-trigger \"sketchcomplete\" so other listeners can do their\n+ // business. While this is somewhat sloppy (if a listener is \n+ // registered with registerPriority - not common - between the start\n+ // and end of a single ring drawing - very uncommon - it will be \n+ // called twice).\n+ // TODO: In 3.0, collapse sketch handlers into geometry specific\n+ // drawing controls.\n+ this.control.layer.events.triggerEvent(\n+ \"sketchcomplete\", {\n+ feature: this.polygon\n+ }\n+ );\n+ }\n+ },\n+\n+ /**\n+ * Method: destroyFeature\n+ * Destroy temporary geometries\n+ *\n+ * Parameters:\n+ * force - {Boolean} Destroy even if persist is true.\n+ */\n+ destroyFeature: function(force) {\n+ OpenLayers.Handler.Path.prototype.destroyFeature.call(\n+ this, force);\n+ this.polygon = null;\n+ },\n+\n+ /**\n+ * Method: drawFeature\n+ * Render geometries on the temporary layer.\n+ */\n+ drawFeature: function() {\n+ this.layer.drawFeature(this.polygon, this.style);\n+ this.layer.drawFeature(this.point, this.style);\n+ },\n+\n+ /**\n+ * Method: getSketch\n+ * Return the sketch feature.\n+ *\n+ * Returns:\n+ * {}\n+ */\n+ getSketch: function() {\n+ return this.polygon;\n+ },\n+\n+ /**\n+ * Method: getGeometry\n+ * Return the sketch geometry. If is true, this will return\n+ * a multi-part geometry.\n+ *\n+ * Returns:\n+ * {}\n+ */\n+ getGeometry: function() {\n+ var geometry = this.polygon && this.polygon.geometry;\n+ if (geometry && this.multi) {\n+ geometry = new OpenLayers.Geometry.MultiPolygon([geometry]);\n+ }\n+ return geometry;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Handler.Polygon\"\n+});\n+/* ======================================================================\n OpenLayers/Format/SLD.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -52220,2645 +45703,1674 @@\n }\n canApply && this._queue.call(this);\n },\n \n CLASS_NAME: \"OpenLayers.Control.SLDSelect\"\n });\n /* ======================================================================\n- OpenLayers/Control/Geolocate.js\n+ OpenLayers/Control/ZoomToMaxExtent.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Geometry/Point.js\n- * @requires OpenLayers/Projection.js\n+ * @requires OpenLayers/Control/Button.js\n */\n \n /**\n- * Class: OpenLayers.Control.Geolocate\n- * The Geolocate control wraps w3c geolocation API into control that can be\n- * bound to a map, and generate events on location update\n- *\n- * To use this control requires to load the proj4js library if the projection\n- * of the map is not EPSG:4326 or EPSG:900913.\n- *\n+ * Class: OpenLayers.Control.ZoomToMaxExtent \n+ * The ZoomToMaxExtent control is a button that zooms out to the maximum\n+ * extent of the map. It is designed to be used with a \n+ * .\n+ * \n * Inherits from:\n * - \n */\n-OpenLayers.Control.Geolocate = OpenLayers.Class(OpenLayers.Control, {\n-\n- /** \n- * APIProperty: events\n- * {} Events instance for listeners and triggering\n- * control specific events.\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * control.events.register(type, obj, listener);\n- * (end)\n- *\n- * Supported event types (in addition to those from ):\n- * locationupdated - Triggered when browser return a new position. Listeners will \n- * receive an object with a 'position' property which is the browser.geolocation.position\n- * native object, as well as a 'point' property which is the location transformed in the \n- * current map projection.\n- * locationfailed - Triggered when geolocation has failed\n- * locationuncapable - Triggered when control is activated on a browser\n- * which doesn't support geolocation\n- */\n+OpenLayers.Control.ZoomToMaxExtent = OpenLayers.Class(OpenLayers.Control.Button, {\n \n /**\n- * Property: geolocation\n- * {Object} The geolocation engine, as a property to be possibly mocked.\n- * This is set lazily to avoid a memory leak in IE9.\n+ * Method: trigger\n+ * \n+ * Called whenever this control is being rendered inside of a panel and a \n+ * click occurs on this controls element. Actually zooms to the maximum\n+ * extent of this controls map.\n */\n- geolocation: null,\n-\n- /**\n- * Property: available\n- * {Boolean} The navigator.geolocation object is available.\n- */\n- available: ('geolocation' in navigator),\n-\n- /**\n- * APIProperty: bind\n- * {Boolean} If true, map center will be set on location update.\n- */\n- bind: true,\n-\n- /**\n- * APIProperty: watch\n- * {Boolean} If true, position will be update regularly.\n- */\n- watch: false,\n-\n- /**\n- * APIProperty: geolocationOptions\n- * {Object} Options to pass to the navigator's geolocation API. See\n- * . No specific\n- * option is passed to the geolocation API by default.\n- */\n- geolocationOptions: null,\n-\n- /**\n- * Constructor: OpenLayers.Control.Geolocate\n- * Create a new control to deal with browser geolocation API\n- *\n- */\n-\n- /**\n- * Method: destroy\n- */\n- destroy: function() {\n- this.deactivate();\n- OpenLayers.Control.prototype.destroy.apply(this, arguments);\n- },\n-\n- /**\n- * Method: activate\n- * Activates the control.\n- *\n- * Returns:\n- * {Boolean} The control was effectively activated.\n- */\n- activate: function() {\n- if (this.available && !this.geolocation) {\n- // set lazily to avoid IE9 memory leak\n- this.geolocation = navigator.geolocation;\n- }\n- if (!this.geolocation) {\n- this.events.triggerEvent(\"locationuncapable\");\n- return false;\n- }\n- if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {\n- if (this.watch) {\n- this.watchId = this.geolocation.watchPosition(\n- OpenLayers.Function.bind(this.geolocate, this),\n- OpenLayers.Function.bind(this.failure, this),\n- this.geolocationOptions\n- );\n- } else {\n- this.getCurrentLocation();\n- }\n- return true;\n- }\n- return false;\n- },\n-\n- /**\n- * Method: deactivate\n- * Deactivates the control.\n- *\n- * Returns:\n- * {Boolean} The control was effectively deactivated.\n- */\n- deactivate: function() {\n- if (this.active && this.watchId !== null) {\n- this.geolocation.clearWatch(this.watchId);\n- }\n- return OpenLayers.Control.prototype.deactivate.apply(\n- this, arguments\n- );\n- },\n-\n- /**\n- * Method: geolocate\n- * Activates the control.\n- *\n- */\n- geolocate: function(position) {\n- var center = new OpenLayers.LonLat(\n- position.coords.longitude,\n- position.coords.latitude\n- ).transform(\n- new OpenLayers.Projection(\"EPSG:4326\"),\n- this.map.getProjectionObject()\n- );\n- if (this.bind) {\n- this.map.setCenter(center);\n- }\n- this.events.triggerEvent(\"locationupdated\", {\n- position: position,\n- point: new OpenLayers.Geometry.Point(\n- center.lon, center.lat\n- )\n- });\n- },\n-\n- /**\n- * APIMethod: getCurrentLocation\n- *\n- * Returns:\n- * {Boolean} Returns true if a event will be fired (successfull\n- * registration)\n- */\n- getCurrentLocation: function() {\n- if (!this.active || this.watch) {\n- return false;\n- }\n- this.geolocation.getCurrentPosition(\n- OpenLayers.Function.bind(this.geolocate, this),\n- OpenLayers.Function.bind(this.failure, this),\n- this.geolocationOptions\n- );\n- return true;\n- },\n-\n- /**\n- * Method: failure\n- * method called on browser's geolocation failure\n- *\n- */\n- failure: function(error) {\n- this.events.triggerEvent(\"locationfailed\", {\n- error: error\n- });\n- },\n-\n- CLASS_NAME: \"OpenLayers.Control.Geolocate\"\n-});\n-/* ======================================================================\n- OpenLayers/Control/Scale.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Lang.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.Scale\n- * The Scale control displays the current map scale as a ratio (e.g. Scale = \n- * 1:1M). By default it is displayed in the lower right corner of the map.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.Scale = OpenLayers.Class(OpenLayers.Control, {\n-\n- /**\n- * Property: element\n- * {DOMElement}\n- */\n- element: null,\n-\n- /**\n- * APIProperty: geodesic\n- * {Boolean} Use geodesic measurement. Default is false. The recommended\n- * setting for maps in EPSG:4326 is false, and true EPSG:900913. If set to\n- * true, the scale will be calculated based on the horizontal size of the\n- * pixel in the center of the map viewport.\n- */\n- geodesic: false,\n-\n- /**\n- * Constructor: OpenLayers.Control.Scale\n- * \n- * Parameters:\n- * element - {DOMElement} \n- * options - {Object} \n- */\n- initialize: function(element, options) {\n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n- this.element = OpenLayers.Util.getElement(element);\n- },\n-\n- /**\n- * Method: draw\n- * \n- * Returns:\n- * {DOMElement}\n- */\n- draw: function() {\n- OpenLayers.Control.prototype.draw.apply(this, arguments);\n- if (!this.element) {\n- this.element = document.createElement(\"div\");\n- this.div.appendChild(this.element);\n- }\n- this.map.events.register('moveend', this, this.updateScale);\n- this.updateScale();\n- return this.div;\n- },\n-\n- /**\n- * Method: updateScale\n- */\n- updateScale: function() {\n- var scale;\n- if (this.geodesic === true) {\n- var units = this.map.getUnits();\n- if (!units) {\n- return;\n- }\n- var inches = OpenLayers.INCHES_PER_UNIT;\n- scale = (this.map.getGeodesicPixelSize().w || 0.000001) *\n- inches[\"km\"] * OpenLayers.DOTS_PER_INCH;\n- } else {\n- scale = this.map.getScale();\n- }\n-\n- if (!scale) {\n- return;\n- }\n-\n- if (scale >= 9500 && scale <= 950000) {\n- scale = Math.round(scale / 1000) + \"K\";\n- } else if (scale >= 950000) {\n- scale = Math.round(scale / 1000000) + \"M\";\n- } else {\n- scale = Math.round(scale);\n- }\n-\n- this.element.innerHTML = OpenLayers.i18n(\"Scale = 1 : ${scaleDenom}\", {\n- 'scaleDenom': scale\n- });\n- },\n-\n- CLASS_NAME: \"OpenLayers.Control.Scale\"\n-});\n-\n-/* ======================================================================\n- OpenLayers/Control/NavToolbar.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Control/Panel.js\n- * @requires OpenLayers/Control/Navigation.js\n- * @requires OpenLayers/Control/ZoomBox.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control.NavToolbar\n- * This Toolbar is an alternative to the Navigation control that displays\n- * the state of the control, and provides a UI for changing state to\n- * use the zoomBox via a Panel control.\n- *\n- * If you wish to change the properties of the Navigation control used\n- * in the NavToolbar, see: \n- * http://trac.openlayers.org/wiki/Toolbars#SubclassingNavToolbar \n- * \n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Control.NavToolbar = OpenLayers.Class(OpenLayers.Control.Panel, {\n-\n- /**\n- * Constructor: OpenLayers.Control.NavToolbar \n- * Add our two mousedefaults controls.\n- *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be used\n- * to extend the control.\n- */\n- initialize: function(options) {\n- OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);\n- this.addControls([\n- new OpenLayers.Control.Navigation(),\n- new OpenLayers.Control.ZoomBox()\n- ]);\n- },\n-\n- /**\n- * Method: draw \n- * calls the default draw, and then activates mouse defaults.\n- */\n- draw: function() {\n- var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);\n- if (this.defaultControl === null) {\n- this.defaultControl = this.controls[0];\n+ trigger: function() {\n+ if (this.map) {\n+ this.map.zoomToMaxExtent();\n }\n- return div;\n },\n \n- CLASS_NAME: \"OpenLayers.Control.NavToolbar\"\n+ CLASS_NAME: \"OpenLayers.Control.ZoomToMaxExtent\"\n });\n /* ======================================================================\n- OpenLayers/Control/Measure.js\n+ OpenLayers/Control/Snapping.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Feature/Vector.js\n+ * @requires OpenLayers/Layer/Vector.js\n */\n \n /**\n- * Class: OpenLayers.Control.Measure\n- * Allows for drawing of features for measurements.\n+ * Class: OpenLayers.Control.Snapping\n+ * Acts as a snapping agent while editing vector features.\n *\n * Inherits from:\n * - \n */\n-OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {\n \n- /**\n+ /** \n * APIProperty: events\n * {} Events instance for listeners and triggering\n * control specific events.\n *\n * Register a listener for a particular event with the following syntax:\n * (code)\n * control.events.register(type, obj, listener);\n * (end)\n *\n * Supported event types (in addition to those from ):\n- * measure - Triggered when a measurement sketch is complete. Listeners\n- * will receive an event with measure, units, order, and geometry\n- * properties.\n- * measurepartial - Triggered when a new point is added to the\n- * measurement sketch or if the property is true and the\n- * measurement sketch is modified. Listeners receive an event with measure,\n- * units, order, and geometry.\n- */\n-\n- /**\n- * APIProperty: handlerOptions\n- * {Object} Used to set non-default properties on the control's handler\n+ * beforesnap - Triggered before a snap occurs. Listeners receive an\n+ * event object with *point*, *x*, *y*, *distance*, *layer*, and\n+ * *snapType* properties. The point property will be original point\n+ * geometry considered for snapping. The x and y properties represent\n+ * coordinates the point will receive. The distance is the distance\n+ * of the snap. The layer is the target layer. The snapType property\n+ * will be one of \"node\", \"vertex\", or \"edge\". Return false to stop\n+ * snapping from occurring.\n+ * snap - Triggered when a snap occurs. Listeners receive an event with\n+ * *point*, *snapType*, *layer*, and *distance* properties. The point\n+ * will be the location snapped to. The snapType will be one of \"node\",\n+ * \"vertex\", or \"edge\". The layer will be the target layer. The\n+ * distance will be the distance of the snap in map units.\n+ * unsnap - Triggered when a vertex is unsnapped. Listeners receive an\n+ * event with a *point* property.\n */\n \n /**\n- * Property: callbacks\n- * {Object} The functions that are sent to the handler for callback\n+ * CONSTANT: DEFAULTS\n+ * Default target properties.\n */\n- callbacks: null,\n+ DEFAULTS: {\n+ tolerance: 10,\n+ node: true,\n+ edge: true,\n+ vertex: true\n+ },\n \n /**\n- * APIProperty: displaySystem\n- * {String} Display system for output measurements. Supported values\n- * are 'english', 'metric', and 'geographic'. Default is 'metric'.\n+ * Property: greedy\n+ * {Boolean} Snap to closest feature in first layer with an eligible\n+ * feature. Default is true.\n */\n- displaySystem: 'metric',\n+ greedy: true,\n \n /**\n- * APIProperty: geodesic\n- * {Boolean} Calculate geodesic metrics instead of planar metrics. This\n- * requires that geometries can be transformed into Geographic/WGS84\n- * (if that is not already the map projection). Default is false.\n+ * Property: precedence\n+ * {Array} List representing precedence of different snapping types.\n+ * Default is \"node\", \"vertex\", \"edge\".\n */\n- geodesic: false,\n+ precedence: [\"node\", \"vertex\", \"edge\"],\n \n /**\n- * Property: displaySystemUnits\n- * {Object} Units for various measurement systems. Values are arrays\n- * of unit abbreviations (from OpenLayers.INCHES_PER_UNIT) in decreasing\n- * order of length.\n+ * Property: resolution\n+ * {Float} The map resolution for the previously considered snap.\n */\n- displaySystemUnits: {\n- geographic: ['dd'],\n- english: ['mi', 'ft', 'in'],\n- metric: ['km', 'm']\n- },\n+ resolution: null,\n \n /**\n- * Property: delay\n- * {Number} Number of milliseconds between clicks before the event is\n- * considered a double-click. The \"measurepartial\" event will not\n- * be triggered if the sketch is completed within this time. This\n- * is required for IE where creating a browser reflow (if a listener\n- * is modifying the DOM by displaying the measurement values) messes\n- * with the dblclick listener in the sketch handler.\n+ * Property: geoToleranceCache\n+ * {Object} A cache of geo-tolerances. Tolerance values (in map units) are\n+ * calculated when the map resolution changes.\n */\n- partialDelay: 300,\n+ geoToleranceCache: null,\n \n /**\n- * Property: delayedTrigger\n- * {Number} Timeout id of trigger for measurepartial.\n+ * Property: layer\n+ * {} The current editable layer. Set at\n+ * construction or after construction with .\n */\n- delayedTrigger: null,\n+ layer: null,\n \n /**\n- * APIProperty: persist\n- * {Boolean} Keep the temporary measurement sketch drawn after the\n- * measurement is complete. The geometry will persist until a new\n- * measurement is started, the control is deactivated, or is\n- * called.\n+ * Property: feature\n+ * {} The current editable feature.\n */\n- persist: false,\n+ feature: null,\n \n /**\n- * APIProperty: immediate\n- * {Boolean} Activates the immediate measurement so that the \"measurepartial\"\n- * event is also fired once the measurement sketch is modified.\n- * Default is false.\n+ * Property: point\n+ * {} The currently snapped vertex.\n */\n- immediate: false,\n+ point: null,\n \n /**\n- * Constructor: OpenLayers.Control.Measure\n+ * Constructor: OpenLayers.Control.Snapping\n+ * Creates a new snapping control. A control is constructed with an editable\n+ * layer and a set of configuration objects for target layers. While the\n+ * control is active, dragging vertices while drawing new features or\n+ * modifying existing features on the editable layer will engage\n+ * snapping to features on the target layers. Whether a vertex snaps to\n+ * a feature on a target layer depends on the target layer configuration.\n *\n * Parameters:\n- * handler - {}\n- * options - {Object}\n+ * options - {Object} An object containing all configuration properties for\n+ * the control.\n+ *\n+ * Valid options:\n+ * layer - {} The editable layer. Features from this\n+ * layer that are digitized or modified may have vertices snapped to\n+ * features from any of the target layers.\n+ * targets - {Array(Object | OpenLayers.Layer.Vector)} A list of objects for\n+ * configuring target layers. See valid properties of the target\n+ * objects below. If the items in the targets list are vector layers\n+ * (instead of configuration objects), the defaults from the \n+ * property will apply. The editable layer itself may be a target\n+ * layer, allowing newly created or edited features to be snapped to\n+ * existing features from the same layer. If no targets are provided\n+ * the layer given in the constructor (as ) will become the\n+ * initial target.\n+ * defaults - {Object} An object with default properties to be applied\n+ * to all target objects.\n+ * greedy - {Boolean} Snap to closest feature in first target layer that\n+ * applies. Default is true. If false, all features in all target\n+ * layers will be checked and the closest feature in all target layers\n+ * will be chosen. The greedy property determines if the order of the\n+ * target layers is significant. By default, the order of the target\n+ * layers is significant where layers earlier in the target layer list\n+ * have precedence over layers later in the list. Within a single\n+ * layer, the closest feature is always chosen for snapping. This\n+ * property only determines whether the search for a closer feature\n+ * continues after an eligible feature is found in a target layer.\n+ *\n+ * Valid target properties:\n+ * layer - {} A target layer. Features from this\n+ * layer will be eligible to act as snapping target for the editable\n+ * layer.\n+ * tolerance - {Float} The distance (in pixels) at which snapping may occur.\n+ * Default is 10.\n+ * node - {Boolean} Snap to nodes (first or last point in a geometry) in\n+ * target layer. Default is true.\n+ * nodeTolerance - {Float} Optional distance at which snapping may occur\n+ * for nodes specifically. If none is provided, will be\n+ * used.\n+ * vertex - {Boolean} Snap to vertices in target layer. Default is true.\n+ * vertexTolerance - {Float} Optional distance at which snapping may occur\n+ * for vertices specifically. If none is provided, will be\n+ * used.\n+ * edge - {Boolean} Snap to edges in target layer. Default is true.\n+ * edgeTolerance - {Float} Optional distance at which snapping may occur\n+ * for edges specifically. If none is provided, will be\n+ * used.\n+ * filter - {} Optional filter to evaluate to determine if\n+ * feature is eligible for snapping. If filter evaluates to true for a\n+ * target feature a vertex may be snapped to the feature. \n+ * minResolution - {Number} If a minResolution is provided, snapping to this\n+ * target will only be considered if the map resolution is greater than\n+ * or equal to this value (the minResolution is inclusive). Default is\n+ * no minimum resolution limit.\n+ * maxResolution - {Number} If a maxResolution is provided, snapping to this\n+ * target will only be considered if the map resolution is strictly\n+ * less than this value (the maxResolution is exclusive). Default is\n+ * no maximum resolution limit.\n */\n- initialize: function(handler, options) {\n+ initialize: function(options) {\n OpenLayers.Control.prototype.initialize.apply(this, [options]);\n- var callbacks = {\n- done: this.measureComplete,\n- point: this.measurePartial\n- };\n- if (this.immediate) {\n- callbacks.modify = this.measureImmediate;\n- }\n- this.callbacks = OpenLayers.Util.extend(callbacks, this.callbacks);\n+ this.options = options || {}; // TODO: this could be done by the super\n \n- // let the handler options override, so old code that passes 'persist'\n- // directly to the handler does not need an update\n- this.handlerOptions = OpenLayers.Util.extend({\n- persist: this.persist\n- }, this.handlerOptions);\n- this.handler = new handler(this, this.callbacks, this.handlerOptions);\n- },\n+ // set the editable layer if provided\n+ if (this.options.layer) {\n+ this.setLayer(this.options.layer);\n+ }\n+ // configure target layers\n+ var defaults = OpenLayers.Util.extend({}, this.options.defaults);\n+ this.defaults = OpenLayers.Util.applyDefaults(defaults, this.DEFAULTS);\n+ this.setTargets(this.options.targets);\n+ if (this.targets.length === 0 && this.layer) {\n+ this.addTargetLayer(this.layer);\n+ }\n \n- /**\n- * APIMethod: deactivate\n- */\n- deactivate: function() {\n- this.cancelDelay();\n- return OpenLayers.Control.prototype.deactivate.apply(this, arguments);\n+ this.geoToleranceCache = {};\n },\n \n /**\n- * APIMethod: cancel\n- * Stop the control from measuring. If is true, the temporary\n- * sketch will be erased.\n+ * APIMethod: setLayer\n+ * Set the editable layer. Call the setLayer method if the editable layer\n+ * changes and the same control should be used on a new editable layer.\n+ * If the control is already active, it will be active after the new\n+ * layer is set.\n+ *\n+ * Parameters:\n+ * layer - {} The new editable layer.\n */\n- cancel: function() {\n- this.cancelDelay();\n- this.handler.cancel();\n+ setLayer: function(layer) {\n+ if (this.active) {\n+ this.deactivate();\n+ this.layer = layer;\n+ this.activate();\n+ } else {\n+ this.layer = layer;\n+ }\n },\n \n /**\n- * APIMethod: setImmediate\n- * Sets the property. Changes the activity of immediate\n- * measurement.\n+ * Method: setTargets\n+ * Set the targets for the snapping agent.\n+ *\n+ * Parameters:\n+ * targets - {Array} An array of target configs or target layers.\n */\n- setImmediate: function(immediate) {\n- this.immediate = immediate;\n- if (this.immediate) {\n- this.callbacks.modify = this.measureImmediate;\n- } else {\n- delete this.callbacks.modify;\n+ setTargets: function(targets) {\n+ this.targets = [];\n+ if (targets && targets.length) {\n+ var target;\n+ for (var i = 0, len = targets.length; i < len; ++i) {\n+ target = targets[i];\n+ if (target instanceof OpenLayers.Layer.Vector) {\n+ this.addTargetLayer(target);\n+ } else {\n+ this.addTarget(target);\n+ }\n+ }\n }\n },\n \n /**\n- * Method: updateHandler\n+ * Method: addTargetLayer\n+ * Add a target layer with the default target config.\n *\n * Parameters:\n- * handler - {Function} One of the sketch handler constructors.\n- * options - {Object} Options for the handler.\n+ * layer - {} A target layer.\n */\n- updateHandler: function(handler, options) {\n- var active = this.active;\n- if (active) {\n- this.deactivate();\n- }\n- this.handler = new handler(this, this.callbacks, options);\n- if (active) {\n- this.activate();\n- }\n+ addTargetLayer: function(layer) {\n+ this.addTarget({\n+ layer: layer\n+ });\n },\n \n /**\n- * Method: measureComplete\n- * Called when the measurement sketch is done.\n+ * Method: addTarget\n+ * Add a configured target layer.\n *\n * Parameters:\n- * geometry - {}\n+ * target - {Object} A target config.\n */\n- measureComplete: function(geometry) {\n- this.cancelDelay();\n- this.measure(geometry, \"measure\");\n+ addTarget: function(target) {\n+ target = OpenLayers.Util.applyDefaults(target, this.defaults);\n+ target.nodeTolerance = target.nodeTolerance || target.tolerance;\n+ target.vertexTolerance = target.vertexTolerance || target.tolerance;\n+ target.edgeTolerance = target.edgeTolerance || target.tolerance;\n+ this.targets.push(target);\n },\n \n /**\n- * Method: measurePartial\n- * Called each time a new point is added to the measurement sketch.\n+ * Method: removeTargetLayer\n+ * Remove a target layer.\n *\n * Parameters:\n- * point - {} The last point added.\n- * geometry - {} The sketch geometry.\n+ * layer - {} The target layer to remove.\n */\n- measurePartial: function(point, geometry) {\n- this.cancelDelay();\n- geometry = geometry.clone();\n- // when we're wating for a dblclick, we have to trigger measurepartial\n- // after some delay to deal with reflow issues in IE\n- if (this.handler.freehandMode(this.handler.evt)) {\n- // no dblclick in freehand mode\n- this.measure(geometry, \"measurepartial\");\n- } else {\n- this.delayedTrigger = window.setTimeout(\n- OpenLayers.Function.bind(function() {\n- this.delayedTrigger = null;\n- this.measure(geometry, \"measurepartial\");\n- }, this),\n- this.partialDelay\n- );\n+ removeTargetLayer: function(layer) {\n+ var target;\n+ for (var i = this.targets.length - 1; i >= 0; --i) {\n+ target = this.targets[i];\n+ if (target.layer === layer) {\n+ this.removeTarget(target);\n+ }\n }\n },\n \n /**\n- * Method: measureImmediate\n- * Called each time the measurement sketch is modified.\n+ * Method: removeTarget\n+ * Remove a target.\n *\n * Parameters:\n- * point - {} The point at the mouse position.\n- * feature - {} The sketch feature.\n- * drawing - {Boolean} Indicates whether we're currently drawing.\n+ * target - {Object} A target config.\n+ *\n+ * Returns:\n+ * {Array} The targets array.\n */\n- measureImmediate: function(point, feature, drawing) {\n- if (drawing && !this.handler.freehandMode(this.handler.evt)) {\n- this.cancelDelay();\n- this.measure(feature.geometry, \"measurepartial\");\n- }\n+ removeTarget: function(target) {\n+ return OpenLayers.Util.removeItem(this.targets, target);\n },\n \n /**\n- * Method: cancelDelay\n- * Cancels the delay measurement that measurePartial began.\n+ * APIMethod: activate\n+ * Activate the control. Activating the control registers listeners for\n+ * editing related events so that during feature creation and\n+ * modification, moving vertices will trigger snapping.\n */\n- cancelDelay: function() {\n- if (this.delayedTrigger !== null) {\n- window.clearTimeout(this.delayedTrigger);\n- this.delayedTrigger = null;\n+ activate: function() {\n+ var activated = OpenLayers.Control.prototype.activate.call(this);\n+ if (activated) {\n+ if (this.layer && this.layer.events) {\n+ this.layer.events.on({\n+ sketchstarted: this.onSketchModified,\n+ sketchmodified: this.onSketchModified,\n+ vertexmodified: this.onVertexModified,\n+ scope: this\n+ });\n+ }\n }\n+ return activated;\n },\n \n /**\n- * Method: measure\n- *\n- * Parameters:\n- * geometry - {}\n- * eventType - {String}\n+ * APIMethod: deactivate\n+ * Deactivate the control. Deactivating the control unregisters listeners\n+ * so feature editing may proceed without engaging the snapping agent.\n */\n- measure: function(geometry, eventType) {\n- var stat, order;\n- if (geometry.CLASS_NAME.indexOf('LineString') > -1) {\n- stat = this.getBestLength(geometry);\n- order = 1;\n- } else {\n- stat = this.getBestArea(geometry);\n- order = 2;\n+ deactivate: function() {\n+ var deactivated = OpenLayers.Control.prototype.deactivate.call(this);\n+ if (deactivated) {\n+ if (this.layer && this.layer.events) {\n+ this.layer.events.un({\n+ sketchstarted: this.onSketchModified,\n+ sketchmodified: this.onSketchModified,\n+ vertexmodified: this.onVertexModified,\n+ scope: this\n+ });\n+ }\n }\n- this.events.triggerEvent(eventType, {\n- measure: stat[0],\n- units: stat[1],\n- order: order,\n- geometry: geometry\n- });\n+ this.feature = null;\n+ this.point = null;\n+ return deactivated;\n },\n \n /**\n- * Method: getBestArea\n- * Based on the returns the area of a geometry.\n+ * Method: onSketchModified\n+ * Registered as a listener for the sketchmodified event on the editable\n+ * layer.\n *\n * Parameters:\n- * geometry - {}\n- *\n- * Returns:\n- * {Array([Float, String])} Returns a two item array containing the\n- * area and the units abbreviation.\n+ * event - {Object} The sketch modified event.\n */\n- getBestArea: function(geometry) {\n- var units = this.displaySystemUnits[this.displaySystem];\n- var unit, area;\n- for (var i = 0, len = units.length; i < len; ++i) {\n- unit = units[i];\n- area = this.getArea(geometry, unit);\n- if (area > 1) {\n- break;\n- }\n- }\n- return [area, unit];\n+ onSketchModified: function(event) {\n+ this.feature = event.feature;\n+ this.considerSnapping(event.vertex, event.vertex);\n },\n \n /**\n- * Method: getArea\n+ * Method: onVertexModified\n+ * Registered as a listener for the vertexmodified event on the editable\n+ * layer.\n *\n * Parameters:\n- * geometry - {}\n- * units - {String} Unit abbreviation\n- *\n- * Returns:\n- * {Float} The geometry area in the given units.\n+ * event - {Object} The vertex modified event.\n */\n- getArea: function(geometry, units) {\n- var area, geomUnits;\n- if (this.geodesic) {\n- area = geometry.getGeodesicArea(this.map.getProjectionObject());\n- geomUnits = \"m\";\n- } else {\n- area = geometry.getArea();\n- geomUnits = this.map.getUnits();\n- }\n- var inPerDisplayUnit = OpenLayers.INCHES_PER_UNIT[units];\n- if (inPerDisplayUnit) {\n- var inPerMapUnit = OpenLayers.INCHES_PER_UNIT[geomUnits];\n- area *= Math.pow((inPerMapUnit / inPerDisplayUnit), 2);\n- }\n- return area;\n+ onVertexModified: function(event) {\n+ this.feature = event.feature;\n+ var loc = this.layer.map.getLonLatFromViewPortPx(event.pixel);\n+ this.considerSnapping(\n+ event.vertex, new OpenLayers.Geometry.Point(loc.lon, loc.lat)\n+ );\n },\n \n /**\n- * Method: getBestLength\n- * Based on the returns the length of a geometry.\n+ * Method: considerSnapping\n *\n * Parameters:\n- * geometry - {}\n- *\n- * Returns:\n- * {Array([Float, String])} Returns a two item array containing the\n- * length and the units abbreviation.\n+ * point - {} The vertex to be snapped (or\n+ * unsnapped).\n+ * loc - {} The location of the mouse in map\n+ * coords.\n */\n- getBestLength: function(geometry) {\n- var units = this.displaySystemUnits[this.displaySystem];\n- var unit, length;\n- for (var i = 0, len = units.length; i < len; ++i) {\n- unit = units[i];\n- length = this.getLength(geometry, unit);\n- if (length > 1) {\n- break;\n+ considerSnapping: function(point, loc) {\n+ var best = {\n+ rank: Number.POSITIVE_INFINITY,\n+ dist: Number.POSITIVE_INFINITY,\n+ x: null,\n+ y: null\n+ };\n+ var snapped = false;\n+ var result, target;\n+ for (var i = 0, len = this.targets.length; i < len; ++i) {\n+ target = this.targets[i];\n+ result = this.testTarget(target, loc);\n+ if (result) {\n+ if (this.greedy) {\n+ best = result;\n+ best.target = target;\n+ snapped = true;\n+ break;\n+ } else {\n+ if ((result.rank < best.rank) ||\n+ (result.rank === best.rank && result.dist < best.dist)) {\n+ best = result;\n+ best.target = target;\n+ snapped = true;\n+ }\n+ }\n }\n }\n- return [length, unit];\n+ if (snapped) {\n+ var proceed = this.events.triggerEvent(\"beforesnap\", {\n+ point: point,\n+ x: best.x,\n+ y: best.y,\n+ distance: best.dist,\n+ layer: best.target.layer,\n+ snapType: this.precedence[best.rank]\n+ });\n+ if (proceed !== false) {\n+ point.x = best.x;\n+ point.y = best.y;\n+ this.point = point;\n+ this.events.triggerEvent(\"snap\", {\n+ point: point,\n+ snapType: this.precedence[best.rank],\n+ layer: best.target.layer,\n+ distance: best.dist\n+ });\n+ } else {\n+ snapped = false;\n+ }\n+ }\n+ if (this.point && !snapped) {\n+ point.x = loc.x;\n+ point.y = loc.y;\n+ this.point = null;\n+ this.events.triggerEvent(\"unsnap\", {\n+ point: point\n+ });\n+ }\n },\n \n /**\n- * Method: getLength\n+ * Method: testTarget\n *\n * Parameters:\n- * geometry - {}\n- * units - {String} Unit abbreviation\n+ * target - {Object} Object with target layer configuration.\n+ * loc - {} The location of the mouse in map\n+ * coords.\n *\n * Returns:\n- * {Float} The geometry length in the given units.\n+ * {Object} A result object with rank, dist, x, and y properties.\n+ * Returns null if candidate is not eligible for snapping.\n */\n- getLength: function(geometry, units) {\n- var length, geomUnits;\n- if (this.geodesic) {\n- length = geometry.getGeodesicLength(this.map.getProjectionObject());\n- geomUnits = \"m\";\n- } else {\n- length = geometry.getLength();\n- geomUnits = this.map.getUnits();\n+ testTarget: function(target, loc) {\n+ var resolution = this.layer.map.getResolution();\n+ if (\"minResolution\" in target) {\n+ if (resolution < target.minResolution) {\n+ return null;\n+ }\n }\n- var inPerDisplayUnit = OpenLayers.INCHES_PER_UNIT[units];\n- if (inPerDisplayUnit) {\n- var inPerMapUnit = OpenLayers.INCHES_PER_UNIT[geomUnits];\n- length *= (inPerMapUnit / inPerDisplayUnit);\n+ if (\"maxResolution\" in target) {\n+ if (resolution >= target.maxResolution) {\n+ return null;\n+ }\n }\n- return length;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Control.Measure\"\n-});\n-/* ======================================================================\n- OpenLayers/Handler/Keyboard.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Handler.js\n- * @requires OpenLayers/Events.js\n- */\n-\n-/**\n- * Class: OpenLayers.handler.Keyboard\n- * A handler for keyboard events. Create a new instance with the\n- * constructor.\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Handler.Keyboard = OpenLayers.Class(OpenLayers.Handler, {\n-\n- /* http://www.quirksmode.org/js/keys.html explains key x-browser\n- key handling quirks in pretty nice detail */\n-\n- /** \n- * Constant: KEY_EVENTS\n- * keydown, keypress, keyup\n- */\n- KEY_EVENTS: [\"keydown\", \"keyup\"],\n-\n- /** \n- * Property: eventListener\n- * {Function}\n- */\n- eventListener: null,\n-\n- /**\n- * Property: observeElement\n- * {DOMElement|String} The DOM element on which we listen for\n- * key events. Default to the document.\n- */\n- observeElement: null,\n-\n- /**\n- * Constructor: OpenLayers.Handler.Keyboard\n- * Returns a new keyboard handler.\n- * \n- * Parameters:\n- * control - {} The control that is making use of\n- * this handler. If a handler is being used without a control, the\n- * handlers setMap method must be overridden to deal properly with\n- * the map.\n- * callbacks - {Object} An object containing a single function to be\n- * called when the drag operation is finished. The callback should\n- * expect to recieve a single argument, the pixel location of the event.\n- * Callbacks for 'keydown', 'keypress', and 'keyup' are supported.\n- * options - {Object} Optional object whose properties will be set on the\n- * handler.\n- */\n- initialize: function(control, callbacks, options) {\n- OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n- // cache the bound event listener method so it can be unobserved later\n- this.eventListener = OpenLayers.Function.bindAsEventListener(\n- this.handleKeyEvent, this\n+ var tolerance = {\n+ node: this.getGeoTolerance(target.nodeTolerance, resolution),\n+ vertex: this.getGeoTolerance(target.vertexTolerance, resolution),\n+ edge: this.getGeoTolerance(target.edgeTolerance, resolution)\n+ };\n+ // this could be cached if we don't support setting tolerance values directly\n+ var maxTolerance = Math.max(\n+ tolerance.node, tolerance.vertex, tolerance.edge\n );\n- },\n-\n- /**\n- * Method: destroy\n- */\n- destroy: function() {\n- this.deactivate();\n- this.eventListener = null;\n- OpenLayers.Handler.prototype.destroy.apply(this, arguments);\n- },\n-\n- /**\n- * Method: activate\n- */\n- activate: function() {\n- if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n- this.observeElement = this.observeElement || document;\n- for (var i = 0, len = this.KEY_EVENTS.length; i < len; i++) {\n- OpenLayers.Event.observe(\n- this.observeElement, this.KEY_EVENTS[i], this.eventListener);\n+ var result = {\n+ rank: Number.POSITIVE_INFINITY,\n+ dist: Number.POSITIVE_INFINITY\n+ };\n+ var eligible = false;\n+ var features = target.layer.features;\n+ var feature, type, vertices, vertex, closest, dist, found;\n+ var numTypes = this.precedence.length;\n+ var ll = new OpenLayers.LonLat(loc.x, loc.y);\n+ for (var i = 0, len = features.length; i < len; ++i) {\n+ feature = features[i];\n+ if (feature !== this.feature && !feature._sketch &&\n+ feature.state !== OpenLayers.State.DELETE &&\n+ (!target.filter || target.filter.evaluate(feature))) {\n+ if (feature.atPoint(ll, maxTolerance, maxTolerance)) {\n+ for (var j = 0, stop = Math.min(result.rank + 1, numTypes); j < stop; ++j) {\n+ type = this.precedence[j];\n+ if (target[type]) {\n+ if (type === \"edge\") {\n+ closest = feature.geometry.distanceTo(loc, {\n+ details: true\n+ });\n+ dist = closest.distance;\n+ if (dist <= tolerance[type] && dist < result.dist) {\n+ result = {\n+ rank: j,\n+ dist: dist,\n+ x: closest.x0,\n+ y: closest.y0 // closest coords on feature\n+ };\n+ eligible = true;\n+ // don't look for lower precedence types for this feature\n+ break;\n+ }\n+ } else {\n+ // look for nodes or vertices\n+ vertices = feature.geometry.getVertices(type === \"node\");\n+ found = false;\n+ for (var k = 0, klen = vertices.length; k < klen; ++k) {\n+ vertex = vertices[k];\n+ dist = vertex.distanceTo(loc);\n+ if (dist <= tolerance[type] &&\n+ (j < result.rank || (j === result.rank && dist < result.dist))) {\n+ result = {\n+ rank: j,\n+ dist: dist,\n+ x: vertex.x,\n+ y: vertex.y\n+ };\n+ eligible = true;\n+ found = true;\n+ }\n+ }\n+ if (found) {\n+ // don't look for lower precedence types for this feature\n+ break;\n+ }\n+ }\n+ }\n+ }\n+ }\n }\n- return true;\n- } else {\n- return false;\n }\n+ return eligible ? result : null;\n },\n \n /**\n- * Method: deactivate\n+ * Method: getGeoTolerance\n+ * Calculate a tolerance in map units given a tolerance in pixels. This\n+ * takes advantage of the when the map resolution\n+ * has not changed.\n+ * \n+ * Parameters:\n+ * tolerance - {Number} A tolerance value in pixels.\n+ * resolution - {Number} Map resolution.\n+ *\n+ * Returns:\n+ * {Number} A tolerance value in map units.\n */\n- deactivate: function() {\n- var deactivated = false;\n- if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- for (var i = 0, len = this.KEY_EVENTS.length; i < len; i++) {\n- OpenLayers.Event.stopObserving(\n- this.observeElement, this.KEY_EVENTS[i], this.eventListener);\n- }\n- deactivated = true;\n+ getGeoTolerance: function(tolerance, resolution) {\n+ if (resolution !== this.resolution) {\n+ this.resolution = resolution;\n+ this.geoToleranceCache = {};\n }\n- return deactivated;\n+ var geoTolerance = this.geoToleranceCache[tolerance];\n+ if (geoTolerance === undefined) {\n+ geoTolerance = tolerance * resolution;\n+ this.geoToleranceCache[tolerance] = geoTolerance;\n+ }\n+ return geoTolerance;\n },\n \n /**\n- * Method: handleKeyEvent \n+ * Method: destroy\n+ * Clean up the control.\n */\n- handleKeyEvent: function(evt) {\n- if (this.checkModifiers(evt)) {\n- this.callback(evt.type, [evt]);\n+ destroy: function() {\n+ if (this.active) {\n+ this.deactivate(); // TODO: this should be handled by the super\n }\n+ delete this.layer;\n+ delete this.targets;\n+ OpenLayers.Control.prototype.destroy.call(this);\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.Keyboard\"\n+ CLASS_NAME: \"OpenLayers.Control.Snapping\"\n });\n /* ======================================================================\n- OpenLayers/Control/ModifyFeature.js\n+ OpenLayers/Control/ArgParser.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Handler/Drag.js\n- * @requires OpenLayers/Handler/Keyboard.js\n */\n \n /**\n- * Class: OpenLayers.Control.ModifyFeature\n- * Control to modify features. When activated, a click renders the vertices\n- * of a feature - these vertices can then be dragged. By default, the\n- * delete key will delete the vertex under the mouse. New features are\n- * added by dragging \"virtual vertices\" between vertices. Create a new\n- * control with the constructor.\n+ * Class: OpenLayers.Control.ArgParser\n+ * The ArgParser control adds location bar query string parsing functionality \n+ * to an OpenLayers Map.\n+ * When added to a Map control, on a page load/refresh, the Map will \n+ * automatically take the href string and parse it for lon, lat, zoom, and \n+ * layers information. \n *\n- * Inherits From:\n+ * Inherits from:\n * - \n */\n-OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Control.ArgParser = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * APIProperty: documentDrag\n- * {Boolean} If set to true, dragging vertices will continue even if the\n- * mouse cursor leaves the map viewport. Default is false.\n+ * Property: center\n+ * {}\n */\n- documentDrag: false,\n+ center: null,\n \n /**\n- * APIProperty: geometryTypes\n- * {Array(String)} To restrict modification to a limited set of geometry\n- * types, send a list of strings corresponding to the geometry class\n- * names.\n+ * Property: zoom\n+ * {int}\n */\n- geometryTypes: null,\n+ zoom: null,\n \n /**\n- * APIProperty: clickout\n- * {Boolean} Unselect features when clicking outside any feature.\n- * Default is true.\n+ * Property: layers\n+ * {String} Each character represents the state of the corresponding layer \n+ * on the map.\n */\n- clickout: true,\n+ layers: null,\n \n- /**\n- * APIProperty: toggle\n- * {Boolean} Unselect a selected feature on click.\n- * Default is true.\n+ /** \n+ * APIProperty: displayProjection\n+ * {} Requires proj4js support. \n+ * Projection used when reading the coordinates from the URL. This will\n+ * reproject the map coordinates from the URL into the map's\n+ * projection.\n+ *\n+ * If you are using this functionality, be aware that any permalink\n+ * which is added to the map will determine the coordinate type which\n+ * is read from the URL, which means you should not add permalinks with\n+ * different displayProjections to the same map. \n */\n- toggle: true,\n+ displayProjection: null,\n \n /**\n- * APIProperty: standalone\n- * {Boolean} Set to true to create a control without SelectFeature\n- * capabilities. Default is false. If standalone is true, to modify\n- * a feature, call the method with the target feature.\n- * Note that you must call the method to finish\n- * feature modification in standalone mode (before starting to modify\n- * another feature).\n+ * Constructor: OpenLayers.Control.ArgParser\n+ *\n+ * Parameters:\n+ * options - {Object}\n */\n- standalone: false,\n \n /**\n- * Property: layer\n- * {}\n+ * Method: getParameters\n */\n- layer: null,\n+ getParameters: function(url) {\n+ url = url || window.location.href;\n+ var parameters = OpenLayers.Util.getParameters(url);\n \n- /**\n- * Property: feature\n- * {} Feature currently available for modification.\n- */\n- feature: null,\n+ // If we have an anchor in the url use it to split the url\n+ var index = url.indexOf('#');\n+ if (index > 0) {\n+ // create an url to parse on the getParameters\n+ url = '?' + url.substring(index + 1, url.length);\n \n- /**\n- * Property: vertex\n- * {} Vertex currently being modified.\n- */\n- vertex: null,\n+ OpenLayers.Util.extend(parameters,\n+ OpenLayers.Util.getParameters(url));\n+ }\n+ return parameters;\n+ },\n \n /**\n- * Property: vertices\n- * {Array()} Verticies currently available\n- * for dragging.\n+ * Method: setMap\n+ * Set the map property for the control. \n+ * \n+ * Parameters:\n+ * map - {} \n */\n- vertices: null,\n+ setMap: function(map) {\n+ OpenLayers.Control.prototype.setMap.apply(this, arguments);\n \n- /**\n- * Property: virtualVertices\n- * {Array()} Virtual vertices in the middle\n- * of each edge.\n- */\n- virtualVertices: null,\n+ //make sure we dont already have an arg parser attached\n+ for (var i = 0, len = this.map.controls.length; i < len; i++) {\n+ var control = this.map.controls[i];\n+ if ((control != this) &&\n+ (control.CLASS_NAME == \"OpenLayers.Control.ArgParser\")) {\n \n- /**\n- * Property: handlers\n- * {Object}\n- */\n- handlers: null,\n+ // If a second argparser is added to the map, then we \n+ // override the displayProjection to be the one added to the\n+ // map. \n+ if (control.displayProjection != this.displayProjection) {\n+ this.displayProjection = control.displayProjection;\n+ }\n \n- /**\n- * APIProperty: deleteCodes\n- * {Array(Integer)} Keycodes for deleting verticies. Set to null to disable\n- * vertex deltion by keypress. If non-null, keypresses with codes\n- * in this array will delete vertices under the mouse. Default\n- * is 46 and 68, the 'delete' and lowercase 'd' keys.\n- */\n- deleteCodes: null,\n+ break;\n+ }\n+ }\n+ if (i == this.map.controls.length) {\n \n- /**\n- * APIProperty: virtualStyle\n- * {Object} A symbolizer to be used for virtual vertices.\n- */\n- virtualStyle: null,\n+ var args = this.getParameters();\n+ // Be careful to set layer first, to not trigger unnecessary layer loads\n+ if (args.layers) {\n+ this.layers = args.layers;\n \n- /**\n- * APIProperty: vertexRenderIntent\n- * {String} The renderIntent to use for vertices. If no is\n- * provided, this renderIntent will also be used for virtual vertices, with\n- * a fillOpacity and strokeOpacity of 0.3. Default is null, which means\n- * that the layer's default style will be used for vertices.\n- */\n- vertexRenderIntent: null,\n+ // when we add a new layer, set its visibility \n+ this.map.events.register('addlayer', this,\n+ this.configureLayers);\n+ this.configureLayers();\n+ }\n+ if (args.lat && args.lon) {\n+ this.center = new OpenLayers.LonLat(parseFloat(args.lon),\n+ parseFloat(args.lat));\n+ if (args.zoom) {\n+ this.zoom = parseFloat(args.zoom);\n+ }\n \n- /**\n- * APIProperty: mode\n- * {Integer} Bitfields specifying the modification mode. Defaults to\n- * OpenLayers.Control.ModifyFeature.RESHAPE. To set the mode to a\n- * combination of options, use the | operator. For example, to allow\n- * the control to both resize and rotate features, use the following\n- * syntax\n- * (code)\n- * control.mode = OpenLayers.Control.ModifyFeature.RESIZE |\n- * OpenLayers.Control.ModifyFeature.ROTATE;\n- * (end)\n- */\n- mode: null,\n+ // when we add a new baselayer to see when we can set the center\n+ this.map.events.register('changebaselayer', this,\n+ this.setCenter);\n+ this.setCenter();\n+ }\n+ }\n+ },\n \n- /**\n- * APIProperty: createVertices\n- * {Boolean} Create new vertices by dragging the virtual vertices\n- * in the middle of each edge. Default is true.\n+ /** \n+ * Method: setCenter\n+ * As soon as a baseLayer has been loaded, we center and zoom\n+ * ...and remove the handler.\n */\n- createVertices: true,\n+ setCenter: function() {\n \n- /**\n- * Property: modified\n- * {Boolean} The currently selected feature has been modified.\n- */\n- modified: false,\n+ if (this.map.baseLayer) {\n+ //dont need to listen for this one anymore\n+ this.map.events.unregister('changebaselayer', this,\n+ this.setCenter);\n \n- /**\n- * Property: radiusHandle\n- * {} A handle for rotating/resizing a feature.\n- */\n- radiusHandle: null,\n+ if (this.displayProjection) {\n+ this.center.transform(this.displayProjection,\n+ this.map.getProjectionObject());\n+ }\n \n- /**\n- * Property: dragHandle\n- * {} A handle for dragging a feature.\n- */\n- dragHandle: null,\n+ this.map.setCenter(this.center, this.zoom);\n+ }\n+ },\n \n- /**\n- * APIProperty: onModificationStart \n- * {Function} *Deprecated*. Register for \"beforefeaturemodified\" instead.\n- * The \"beforefeaturemodified\" event is triggered on the layer before\n- * any modification begins.\n- *\n- * Optional function to be called when a feature is selected\n- * to be modified. The function should expect to be called with a\n- * feature. This could be used for example to allow to lock the\n- * feature on server-side.\n+ /** \n+ * Method: configureLayers\n+ * As soon as all the layers are loaded, cycle through them and \n+ * hide or show them. \n */\n- onModificationStart: function() {},\n+ configureLayers: function() {\n \n- /**\n- * APIProperty: onModification\n- * {Function} *Deprecated*. Register for \"featuremodified\" instead.\n- * The \"featuremodified\" event is triggered on the layer with each\n- * feature modification.\n- *\n- * Optional function to be called when a feature has been\n- * modified. The function should expect to be called with a feature.\n- */\n- onModification: function() {},\n+ if (this.layers.length == this.map.layers.length) {\n+ this.map.events.unregister('addlayer', this, this.configureLayers);\n \n- /**\n- * APIProperty: onModificationEnd\n- * {Function} *Deprecated*. Register for \"afterfeaturemodified\" instead.\n- * The \"afterfeaturemodified\" event is triggered on the layer after\n- * a feature has been modified.\n- *\n- * Optional function to be called when a feature is finished \n- * being modified. The function should expect to be called with a\n- * feature.\n- */\n- onModificationEnd: function() {},\n+ for (var i = 0, len = this.layers.length; i < len; i++) {\n \n- /**\n- * Constructor: OpenLayers.Control.ModifyFeature\n- * Create a new modify feature control.\n- *\n- * Parameters:\n- * layer - {} Layer that contains features that\n- * will be modified.\n- * options - {Object} Optional object whose properties will be set on the\n- * control.\n- */\n- initialize: function(layer, options) {\n- options = options || {};\n- this.layer = layer;\n- this.vertices = [];\n- this.virtualVertices = [];\n- this.virtualStyle = OpenLayers.Util.extend({},\n- this.layer.style ||\n- this.layer.styleMap.createSymbolizer(null, options.vertexRenderIntent)\n- );\n- this.virtualStyle.fillOpacity = 0.3;\n- this.virtualStyle.strokeOpacity = 0.3;\n- this.deleteCodes = [46, 68];\n- this.mode = OpenLayers.Control.ModifyFeature.RESHAPE;\n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n- if (!(OpenLayers.Util.isArray(this.deleteCodes))) {\n- this.deleteCodes = [this.deleteCodes];\n- }\n+ var layer = this.map.layers[i];\n+ var c = this.layers.charAt(i);\n \n- // configure the drag handler\n- var dragCallbacks = {\n- down: function(pixel) {\n- this.vertex = null;\n- var feature = this.layer.getFeatureFromEvent(\n- this.handlers.drag.evt);\n- if (feature) {\n- this.dragStart(feature);\n- } else if (this.clickout) {\n- this._unselect = this.feature;\n- }\n- },\n- move: function(pixel) {\n- delete this._unselect;\n- if (this.vertex) {\n- this.dragVertex(this.vertex, pixel);\n- }\n- },\n- up: function() {\n- this.handlers.drag.stopDown = false;\n- if (this._unselect) {\n- this.unselectFeature(this._unselect);\n- delete this._unselect;\n- }\n- },\n- done: function(pixel) {\n- if (this.vertex) {\n- this.dragComplete(this.vertex);\n+ if (c == \"B\") {\n+ this.map.setBaseLayer(layer);\n+ } else if ((c == \"T\") || (c == \"F\")) {\n+ layer.setVisibility(c == \"T\");\n }\n }\n- };\n- var dragOptions = {\n- documentDrag: this.documentDrag,\n- stopDown: false\n- };\n-\n- // configure the keyboard handler\n- var keyboardOptions = {\n- keydown: this.handleKeypress\n- };\n- this.handlers = {\n- keyboard: new OpenLayers.Handler.Keyboard(this, keyboardOptions),\n- drag: new OpenLayers.Handler.Drag(this, dragCallbacks, dragOptions)\n- };\n- },\n-\n- /**\n- * APIMethod: destroy\n- * Take care of things that are not handled in superclass.\n- */\n- destroy: function() {\n- if (this.map) {\n- this.map.events.un({\n- \"removelayer\": this.handleMapEvents,\n- \"changelayer\": this.handleMapEvents,\n- scope: this\n- });\n }\n- this.layer = null;\n- OpenLayers.Control.prototype.destroy.apply(this, []);\n- },\n-\n- /**\n- * APIMethod: activate\n- * Activate the control.\n- * \n- * Returns:\n- * {Boolean} Successfully activated the control.\n- */\n- activate: function() {\n- this.moveLayerToTop();\n- this.map.events.on({\n- \"removelayer\": this.handleMapEvents,\n- \"changelayer\": this.handleMapEvents,\n- scope: this\n- });\n- return (this.handlers.keyboard.activate() &&\n- this.handlers.drag.activate() &&\n- OpenLayers.Control.prototype.activate.apply(this, arguments));\n },\n \n- /**\n- * APIMethod: deactivate\n- * Deactivate the control.\n- *\n- * Returns: \n- * {Boolean} Successfully deactivated the control.\n- */\n- deactivate: function() {\n- var deactivated = false;\n- // the return from the controls is unimportant in this case\n- if (OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {\n- this.moveLayerBack();\n- this.map.events.un({\n- \"removelayer\": this.handleMapEvents,\n- \"changelayer\": this.handleMapEvents,\n- scope: this\n- });\n- this.layer.removeFeatures(this.vertices, {\n- silent: true\n- });\n- this.layer.removeFeatures(this.virtualVertices, {\n- silent: true\n- });\n- this.vertices = [];\n- this.handlers.drag.deactivate();\n- this.handlers.keyboard.deactivate();\n- var feature = this.feature;\n- if (feature && feature.geometry && feature.layer) {\n- this.unselectFeature(feature);\n- }\n- deactivated = true;\n- }\n- return deactivated;\n- },\n+ CLASS_NAME: \"OpenLayers.Control.ArgParser\"\n+});\n+/* ======================================================================\n+ OpenLayers/Control/ZoomBox.js\n+ ====================================================================== */\n \n- /**\n- * Method: beforeSelectFeature\n- * Called before a feature is selected.\n- *\n- * Parameters:\n- * feature - {} The feature about to be selected.\n- */\n- beforeSelectFeature: function(feature) {\n- return this.layer.events.triggerEvent(\n- \"beforefeaturemodified\", {\n- feature: feature\n- }\n- );\n- },\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- /**\n- * APIMethod: selectFeature\n- * Select a feature for modification in standalone mode. In non-standalone\n- * mode, this method is called when a feature is selected by clicking.\n- * Register a listener to the beforefeaturemodified event and return false\n- * to prevent feature modification.\n- *\n- * Parameters:\n- * feature - {} the selected feature.\n- */\n- selectFeature: function(feature) {\n- if (this.feature === feature ||\n- (this.geometryTypes && OpenLayers.Util.indexOf(this.geometryTypes,\n- feature.geometry.CLASS_NAME) == -1)) {\n- return;\n- }\n- if (this.beforeSelectFeature(feature) !== false) {\n- if (this.feature) {\n- this.unselectFeature(this.feature);\n- }\n- this.feature = feature;\n- this.layer.selectedFeatures.push(feature);\n- this.layer.drawFeature(feature, 'select');\n- this.modified = false;\n- this.resetVertices();\n- this.onModificationStart(this.feature);\n- }\n- // keep track of geometry modifications\n- var modified = feature.modified;\n- if (feature.geometry && !(modified && modified.geometry)) {\n- this._originalGeometry = feature.geometry.clone();\n- }\n- },\n+/**\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Handler/Box.js\n+ */\n \n+/**\n+ * Class: OpenLayers.Control.ZoomBox\n+ * The ZoomBox control enables zooming directly to a given extent, by drawing \n+ * a box on the map. The box is drawn by holding down shift, whilst dragging \n+ * the mouse.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {\n /**\n- * APIMethod: unselectFeature\n- * Called when the select feature control unselects a feature.\n- *\n- * Parameters:\n- * feature - {} The unselected feature.\n+ * Property: type\n+ * {OpenLayers.Control.TYPE}\n */\n- unselectFeature: function(feature) {\n- this.layer.removeFeatures(this.vertices, {\n- silent: true\n- });\n- this.vertices = [];\n- this.layer.destroyFeatures(this.virtualVertices, {\n- silent: true\n- });\n- this.virtualVertices = [];\n- if (this.dragHandle) {\n- this.layer.destroyFeatures([this.dragHandle], {\n- silent: true\n- });\n- delete this.dragHandle;\n- }\n- if (this.radiusHandle) {\n- this.layer.destroyFeatures([this.radiusHandle], {\n- silent: true\n- });\n- delete this.radiusHandle;\n- }\n- this.layer.drawFeature(this.feature, 'default');\n- this.feature = null;\n- OpenLayers.Util.removeItem(this.layer.selectedFeatures, feature);\n- this.onModificationEnd(feature);\n- this.layer.events.triggerEvent(\"afterfeaturemodified\", {\n- feature: feature,\n- modified: this.modified\n- });\n- this.modified = false;\n- },\n-\n+ type: OpenLayers.Control.TYPE_TOOL,\n \n /**\n- * Method: dragStart\n- * Called by the drag handler before a feature is dragged. This method is\n- * used to differentiate between points and vertices\n- * of higher order geometries.\n- *\n- * Parameters:\n- * feature - {} The point or vertex about to be\n- * dragged.\n+ * Property: out\n+ * {Boolean} Should the control be used for zooming out?\n */\n- dragStart: function(feature) {\n- var isPoint = feature.geometry.CLASS_NAME ==\n- 'OpenLayers.Geometry.Point';\n- if (!this.standalone &&\n- ((!feature._sketch && isPoint) || !feature._sketch)) {\n- if (this.toggle && this.feature === feature) {\n- // mark feature for unselection\n- this._unselect = feature;\n- }\n- this.selectFeature(feature);\n- }\n- if (feature._sketch || isPoint) {\n- // feature is a drag or virtual handle or point\n- this.vertex = feature;\n- this.handlers.drag.stopDown = true;\n- }\n- },\n+ out: false,\n \n /**\n- * Method: dragVertex\n- * Called by the drag handler with each drag move of a vertex.\n- *\n- * Parameters:\n- * vertex - {} The vertex being dragged.\n- * pixel - {} Pixel location of the mouse event.\n+ * APIProperty: keyMask\n+ * {Integer} Zoom only occurs if the keyMask matches the combination of \n+ * keys down. Use bitwise operators and one or more of the\n+ * constants to construct a keyMask. Leave null if \n+ * not used mask. Default is null.\n */\n- dragVertex: function(vertex, pixel) {\n- var pos = this.map.getLonLatFromViewPortPx(pixel);\n- var geom = vertex.geometry;\n- geom.move(pos.lon - geom.x, pos.lat - geom.y);\n- this.modified = true;\n- /**\n- * Five cases:\n- * 1) dragging a simple point\n- * 2) dragging a virtual vertex\n- * 3) dragging a drag handle\n- * 4) dragging a real vertex\n- * 5) dragging a radius handle\n- */\n- if (this.feature.geometry.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n- // dragging a simple point\n- this.layer.events.triggerEvent(\"vertexmodified\", {\n- vertex: vertex.geometry,\n- feature: this.feature,\n- pixel: pixel\n- });\n- } else {\n- if (vertex._index) {\n- // dragging a virtual vertex\n- vertex.geometry.parent.addComponent(vertex.geometry,\n- vertex._index);\n- // move from virtual to real vertex\n- delete vertex._index;\n- OpenLayers.Util.removeItem(this.virtualVertices, vertex);\n- this.vertices.push(vertex);\n- } else if (vertex == this.dragHandle) {\n- // dragging a drag handle\n- this.layer.removeFeatures(this.vertices, {\n- silent: true\n- });\n- this.vertices = [];\n- if (this.radiusHandle) {\n- this.layer.destroyFeatures([this.radiusHandle], {\n- silent: true\n- });\n- this.radiusHandle = null;\n- }\n- } else if (vertex !== this.radiusHandle) {\n- // dragging a real vertex\n- this.layer.events.triggerEvent(\"vertexmodified\", {\n- vertex: vertex.geometry,\n- feature: this.feature,\n- pixel: pixel\n- });\n- }\n- // dragging a radius handle - no special treatment\n- if (this.virtualVertices.length > 0) {\n- this.layer.destroyFeatures(this.virtualVertices, {\n- silent: true\n- });\n- this.virtualVertices = [];\n- }\n- this.layer.drawFeature(this.feature, this.standalone ? undefined :\n- 'select');\n- }\n- // keep the vertex on top so it gets the mouseout after dragging\n- // this should be removed in favor of an option to draw under or\n- // maintain node z-index\n- this.layer.drawFeature(vertex);\n- },\n+ keyMask: null,\n \n /**\n- * Method: dragComplete\n- * Called by the drag handler when the feature dragging is complete.\n- *\n- * Parameters:\n- * vertex - {} The vertex being dragged.\n+ * APIProperty: alwaysZoom\n+ * {Boolean} Always zoom in/out when box drawn, even if the zoom level does\n+ * not change.\n */\n- dragComplete: function(vertex) {\n- this.resetVertices();\n- this.setFeatureState();\n- this.onModification(this.feature);\n- this.layer.events.triggerEvent(\"featuremodified\", {\n- feature: this.feature\n- });\n- },\n+ alwaysZoom: false,\n \n /**\n- * Method: setFeatureState\n- * Called when the feature is modified. If the current state is not\n- * INSERT or DELETE, the state is set to UPDATE.\n+ * APIProperty: zoomOnClick\n+ * {Boolean} Should we zoom when no box was dragged, i.e. the user only\n+ * clicked? Default is true.\n */\n- setFeatureState: function() {\n- if (this.feature.state != OpenLayers.State.INSERT &&\n- this.feature.state != OpenLayers.State.DELETE) {\n- this.feature.state = OpenLayers.State.UPDATE;\n- if (this.modified && this._originalGeometry) {\n- var feature = this.feature;\n- feature.modified = OpenLayers.Util.extend(feature.modified, {\n- geometry: this._originalGeometry\n- });\n- delete this._originalGeometry;\n- }\n- }\n- },\n+ zoomOnClick: true,\n \n /**\n- * Method: resetVertices\n+ * Method: draw\n */\n- resetVertices: function() {\n- if (this.vertices.length > 0) {\n- this.layer.removeFeatures(this.vertices, {\n- silent: true\n- });\n- this.vertices = [];\n- }\n- if (this.virtualVertices.length > 0) {\n- this.layer.removeFeatures(this.virtualVertices, {\n- silent: true\n- });\n- this.virtualVertices = [];\n- }\n- if (this.dragHandle) {\n- this.layer.destroyFeatures([this.dragHandle], {\n- silent: true\n- });\n- this.dragHandle = null;\n- }\n- if (this.radiusHandle) {\n- this.layer.destroyFeatures([this.radiusHandle], {\n- silent: true\n- });\n- this.radiusHandle = null;\n- }\n- if (this.feature &&\n- this.feature.geometry.CLASS_NAME != \"OpenLayers.Geometry.Point\") {\n- if ((this.mode & OpenLayers.Control.ModifyFeature.DRAG)) {\n- this.collectDragHandle();\n- }\n- if ((this.mode & (OpenLayers.Control.ModifyFeature.ROTATE |\n- OpenLayers.Control.ModifyFeature.RESIZE))) {\n- this.collectRadiusHandle();\n- }\n- if (this.mode & OpenLayers.Control.ModifyFeature.RESHAPE) {\n- // Don't collect vertices when we're resizing\n- if (!(this.mode & OpenLayers.Control.ModifyFeature.RESIZE)) {\n- this.collectVertices();\n- }\n- }\n- }\n+ draw: function() {\n+ this.handler = new OpenLayers.Handler.Box(this, {\n+ done: this.zoomBox\n+ }, {\n+ keyMask: this.keyMask\n+ });\n },\n \n /**\n- * Method: handleKeypress\n- * Called by the feature handler on keypress. This is used to delete\n- * vertices. If the property is set, vertices will\n- * be deleted when a feature is selected for modification and\n- * the mouse is over a vertex.\n+ * Method: zoomBox\n *\n * Parameters:\n- * evt - {Event} Keypress event.\n+ * position - {} or {}\n */\n- handleKeypress: function(evt) {\n- var code = evt.keyCode;\n-\n- // check for delete key\n- if (this.feature &&\n- OpenLayers.Util.indexOf(this.deleteCodes, code) != -1) {\n- var vertex = this.layer.getFeatureFromEvent(this.handlers.drag.evt);\n- if (vertex &&\n- OpenLayers.Util.indexOf(this.vertices, vertex) != -1 &&\n- !this.handlers.drag.dragging && vertex.geometry.parent) {\n- // remove the vertex\n- vertex.geometry.parent.removeComponent(vertex.geometry);\n- this.layer.events.triggerEvent(\"vertexremoved\", {\n- vertex: vertex.geometry,\n- feature: this.feature,\n- pixel: evt.xy\n+ zoomBox: function(position) {\n+ if (position instanceof OpenLayers.Bounds) {\n+ var bounds,\n+ targetCenterPx = position.getCenterPixel();\n+ if (!this.out) {\n+ var minXY = this.map.getLonLatFromPixel({\n+ x: position.left,\n+ y: position.bottom\n });\n- this.layer.drawFeature(this.feature, this.standalone ?\n- undefined : 'select');\n- this.modified = true;\n- this.resetVertices();\n- this.setFeatureState();\n- this.onModification(this.feature);\n- this.layer.events.triggerEvent(\"featuremodified\", {\n- feature: this.feature\n+ var maxXY = this.map.getLonLatFromPixel({\n+ x: position.right,\n+ y: position.top\n });\n+ bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat,\n+ maxXY.lon, maxXY.lat);\n+ } else {\n+ var pixWidth = position.right - position.left;\n+ var pixHeight = position.bottom - position.top;\n+ var zoomFactor = Math.min((this.map.size.h / pixHeight),\n+ (this.map.size.w / pixWidth));\n+ var extent = this.map.getExtent();\n+ var center = this.map.getLonLatFromPixel(targetCenterPx);\n+ var xmin = center.lon - (extent.getWidth() / 2) * zoomFactor;\n+ var xmax = center.lon + (extent.getWidth() / 2) * zoomFactor;\n+ var ymin = center.lat - (extent.getHeight() / 2) * zoomFactor;\n+ var ymax = center.lat + (extent.getHeight() / 2) * zoomFactor;\n+ bounds = new OpenLayers.Bounds(xmin, ymin, xmax, ymax);\n }\n- }\n- },\n-\n- /**\n- * Method: collectVertices\n- * Collect the vertices from the modifiable feature's geometry and push\n- * them on to the control's vertices array.\n- */\n- collectVertices: function() {\n- this.vertices = [];\n- this.virtualVertices = [];\n- var control = this;\n-\n- function collectComponentVertices(geometry) {\n- var i, vertex, component, len;\n- if (geometry.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n- vertex = new OpenLayers.Feature.Vector(geometry);\n- vertex._sketch = true;\n- vertex.renderIntent = control.vertexRenderIntent;\n- control.vertices.push(vertex);\n+ // always zoom in/out \n+ var lastZoom = this.map.getZoom(),\n+ size = this.map.getSize(),\n+ centerPx = {\n+ x: size.w / 2,\n+ y: size.h / 2\n+ },\n+ zoom = this.map.getZoomForExtent(bounds),\n+ oldRes = this.map.getResolution(),\n+ newRes = this.map.getResolutionForZoom(zoom);\n+ if (oldRes == newRes) {\n+ this.map.setCenter(this.map.getLonLatFromPixel(targetCenterPx));\n } else {\n- var numVert = geometry.components.length;\n- if (geometry.CLASS_NAME == \"OpenLayers.Geometry.LinearRing\") {\n- numVert -= 1;\n- }\n- for (i = 0; i < numVert; ++i) {\n- component = geometry.components[i];\n- if (component.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n- vertex = new OpenLayers.Feature.Vector(component);\n- vertex._sketch = true;\n- vertex.renderIntent = control.vertexRenderIntent;\n- control.vertices.push(vertex);\n- } else {\n- collectComponentVertices(component);\n- }\n- }\n-\n- // add virtual vertices in the middle of each edge\n- if (control.createVertices && geometry.CLASS_NAME != \"OpenLayers.Geometry.MultiPoint\") {\n- for (i = 0, len = geometry.components.length; i < len - 1; ++i) {\n- var prevVertex = geometry.components[i];\n- var nextVertex = geometry.components[i + 1];\n- if (prevVertex.CLASS_NAME == \"OpenLayers.Geometry.Point\" &&\n- nextVertex.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n- var x = (prevVertex.x + nextVertex.x) / 2;\n- var y = (prevVertex.y + nextVertex.y) / 2;\n- var point = new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.Point(x, y),\n- null, control.virtualStyle\n- );\n- // set the virtual parent and intended index\n- point.geometry.parent = geometry;\n- point._index = i + 1;\n- point._sketch = true;\n- control.virtualVertices.push(point);\n- }\n- }\n- }\n+ var zoomOriginPx = {\n+ x: (oldRes * targetCenterPx.x - newRes * centerPx.x) /\n+ (oldRes - newRes),\n+ y: (oldRes * targetCenterPx.y - newRes * centerPx.y) /\n+ (oldRes - newRes)\n+ };\n+ this.map.zoomTo(zoom, zoomOriginPx);\n }\n- }\n- collectComponentVertices.call(this, this.feature.geometry);\n- this.layer.addFeatures(this.virtualVertices, {\n- silent: true\n- });\n- this.layer.addFeatures(this.vertices, {\n- silent: true\n- });\n- },\n-\n- /**\n- * Method: collectDragHandle\n- * Collect the drag handle for the selected geometry.\n- */\n- collectDragHandle: function() {\n- var geometry = this.feature.geometry;\n- var center = geometry.getBounds().getCenterLonLat();\n- var originGeometry = new OpenLayers.Geometry.Point(\n- center.lon, center.lat\n- );\n- var origin = new OpenLayers.Feature.Vector(originGeometry);\n- originGeometry.move = function(x, y) {\n- OpenLayers.Geometry.Point.prototype.move.call(this, x, y);\n- geometry.move(x, y);\n- };\n- origin._sketch = true;\n- this.dragHandle = origin;\n- this.dragHandle.renderIntent = this.vertexRenderIntent;\n- this.layer.addFeatures([this.dragHandle], {\n- silent: true\n- });\n- },\n-\n- /**\n- * Method: collectRadiusHandle\n- * Collect the radius handle for the selected geometry.\n- */\n- collectRadiusHandle: function() {\n- var geometry = this.feature.geometry;\n- var bounds = geometry.getBounds();\n- var center = bounds.getCenterLonLat();\n- var originGeometry = new OpenLayers.Geometry.Point(\n- center.lon, center.lat\n- );\n- var radiusGeometry = new OpenLayers.Geometry.Point(\n- bounds.right, bounds.bottom\n- );\n- var radius = new OpenLayers.Feature.Vector(radiusGeometry);\n- var resize = (this.mode & OpenLayers.Control.ModifyFeature.RESIZE);\n- var reshape = (this.mode & OpenLayers.Control.ModifyFeature.RESHAPE);\n- var rotate = (this.mode & OpenLayers.Control.ModifyFeature.ROTATE);\n-\n- radiusGeometry.move = function(x, y) {\n- OpenLayers.Geometry.Point.prototype.move.call(this, x, y);\n- var dx1 = this.x - originGeometry.x;\n- var dy1 = this.y - originGeometry.y;\n- var dx0 = dx1 - x;\n- var dy0 = dy1 - y;\n- if (rotate) {\n- var a0 = Math.atan2(dy0, dx0);\n- var a1 = Math.atan2(dy1, dx1);\n- var angle = a1 - a0;\n- angle *= 180 / Math.PI;\n- geometry.rotate(angle, originGeometry);\n+ if (lastZoom == this.map.getZoom() && this.alwaysZoom == true) {\n+ this.map.zoomTo(lastZoom + (this.out ? -1 : 1));\n }\n- if (resize) {\n- var scale, ratio;\n- // 'resize' together with 'reshape' implies that the aspect \n- // ratio of the geometry will not be preserved whilst resizing \n- if (reshape) {\n- scale = dy1 / dy0;\n- ratio = (dx1 / dx0) / scale;\n- } else {\n- var l0 = Math.sqrt((dx0 * dx0) + (dy0 * dy0));\n- var l1 = Math.sqrt((dx1 * dx1) + (dy1 * dy1));\n- scale = l1 / l0;\n- }\n- geometry.resize(scale, originGeometry, ratio);\n+ } else if (this.zoomOnClick) { // it's a pixel\n+ if (!this.out) {\n+ this.map.zoomTo(this.map.getZoom() + 1, position);\n+ } else {\n+ this.map.zoomTo(this.map.getZoom() - 1, position);\n }\n- };\n- radius._sketch = true;\n- this.radiusHandle = radius;\n- this.radiusHandle.renderIntent = this.vertexRenderIntent;\n- this.layer.addFeatures([this.radiusHandle], {\n- silent: true\n- });\n+ }\n },\n \n- /**\n- * Method: setMap\n- * Set the map property for the control and all handlers.\n- *\n- * Parameters:\n- * map - {} The control's map.\n- */\n- setMap: function(map) {\n- this.handlers.drag.setMap(map);\n- OpenLayers.Control.prototype.setMap.apply(this, arguments);\n- },\n+ CLASS_NAME: \"OpenLayers.Control.ZoomBox\"\n+});\n+/* ======================================================================\n+ OpenLayers/Control/ZoomPanel.js\n+ ====================================================================== */\n \n- /**\n- * Method: handleMapEvents\n- * \n- * Parameters:\n- * evt - {Object}\n- */\n- handleMapEvents: function(evt) {\n- if (evt.type == \"removelayer\" || evt.property == \"order\") {\n- this.moveLayerToTop();\n- }\n- },\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- /**\n- * Method: moveLayerToTop\n- * Moves the layer for this handler to the top, so mouse events can reach\n- * it.\n- */\n- moveLayerToTop: function() {\n- var index = Math.max(this.map.Z_INDEX_BASE['Feature'] - 1,\n- this.layer.getZIndex()) + 1;\n- this.layer.setZIndex(index);\n+/**\n+ * @requires OpenLayers/Control/Panel.js\n+ * @requires OpenLayers/Control/ZoomIn.js\n+ * @requires OpenLayers/Control/ZoomOut.js\n+ * @requires OpenLayers/Control/ZoomToMaxExtent.js\n+ */\n \n- },\n+/**\n+ * Class: OpenLayers.Control.ZoomPanel\n+ * The ZoomPanel control is a compact collecton of 3 zoom controls: a \n+ * , a , and a\n+ * . By default it is drawn in the upper left \n+ * corner of the map.\n+ *\n+ * Note: \n+ * If you wish to use this class with the default images and you want \n+ * it to look nice in ie6, you should add the following, conditionally\n+ * added css stylesheet to your HTML file:\n+ * \n+ * (code)\n+ * \n+ * (end)\n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Control.ZoomPanel = OpenLayers.Class(OpenLayers.Control.Panel, {\n \n /**\n- * Method: moveLayerBack\n- * Moves the layer back to the position determined by the map's layers\n- * array.\n+ * Constructor: OpenLayers.Control.ZoomPanel \n+ * Add the three zooming controls.\n+ *\n+ * Parameters:\n+ * options - {Object} An optional object whose properties will be used\n+ * to extend the control.\n */\n- moveLayerBack: function() {\n- var index = this.layer.getZIndex() - 1;\n- if (index >= this.map.Z_INDEX_BASE['Feature']) {\n- this.layer.setZIndex(index);\n- } else {\n- this.map.setLayerZIndex(this.layer,\n- this.map.getLayerIndex(this.layer));\n- }\n+ initialize: function(options) {\n+ OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);\n+ this.addControls([\n+ new OpenLayers.Control.ZoomIn(),\n+ new OpenLayers.Control.ZoomToMaxExtent(),\n+ new OpenLayers.Control.ZoomOut()\n+ ]);\n },\n \n- CLASS_NAME: \"OpenLayers.Control.ModifyFeature\"\n+ CLASS_NAME: \"OpenLayers.Control.ZoomPanel\"\n });\n-\n-/**\n- * Constant: RESHAPE\n- * {Integer} Constant used to make the control work in reshape mode\n- */\n-OpenLayers.Control.ModifyFeature.RESHAPE = 1;\n-/**\n- * Constant: RESIZE\n- * {Integer} Constant used to make the control work in resize mode\n- */\n-OpenLayers.Control.ModifyFeature.RESIZE = 2;\n-/**\n- * Constant: ROTATE\n- * {Integer} Constant used to make the control work in rotate mode\n- */\n-OpenLayers.Control.ModifyFeature.ROTATE = 4;\n-/**\n- * Constant: DRAG\n- * {Integer} Constant used to make the control work in drag mode\n- */\n-OpenLayers.Control.ModifyFeature.DRAG = 8;\n /* ======================================================================\n- OpenLayers/Control/UTFGrid.js\n+ OpenLayers/Control/PanZoom.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Handler/Hover.js\n- * @requires OpenLayers/Handler/Click.js\n+ * @requires OpenLayers/Events/buttonclick.js\n */\n \n /**\n- * Class: OpenLayers.Control.UTFGrid\n- *\n- * This Control provides behavior associated with UTFGrid Layers.\n- * These 'hit grids' provide underlying feature attributes without\n- * calling the server (again). This control allows Mousemove, Hovering \n- * and Click events to trigger callbacks that use the attributes in \n- * whatever way you need. \n- *\n- * The most common example may be a UTFGrid layer containing feature\n- * attributes that are displayed in a div as you mouseover.\n- *\n- * Example Code:\n- *\n- * (start code)\n- * var world_utfgrid = new OpenLayers.Layer.UTFGrid( \n- * 'UTFGrid Layer', \n- * \"http://tiles/world_utfgrid/${z}/${x}/${y}.json\"\n- * );\n- * map.addLayer(world_utfgrid);\n- * \n- * var control = new OpenLayers.Control.UTFGrid({\n- * layers: [world_utfgrid],\n- * handlerMode: 'move',\n- * callback: function(infoLookup) {\n- * // do something with returned data\n- *\n- * }\n- * })\n- * (end code)\n- *\n+ * Class: OpenLayers.Control.PanZoom\n+ * The PanZoom is a visible control, composed of a\n+ * and a . By\n+ * default it is drawn in the upper left corner of the map.\n *\n * Inherits from:\n * - \n */\n-OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {\n \n- /**\n- * APIProperty: autoActivate\n- * {Boolean} Activate the control when it is added to a map. Default is\n- * true.\n+ /** \n+ * APIProperty: slideFactor\n+ * {Integer} Number of pixels by which we'll pan the map in any direction \n+ * on clicking the arrow buttons. If you want to pan by some ratio\n+ * of the map dimensions, use instead.\n */\n- autoActivate: true,\n+ slideFactor: 50,\n \n /** \n- * APIProperty: Layers\n- * List of layers to consider. Must be Layer.UTFGrids\n- * `null` is the default indicating all UTFGrid Layers are queried.\n- * {Array} \n+ * APIProperty: slideRatio\n+ * {Number} The fraction of map width/height by which we'll pan the map \n+ * on clicking the arrow buttons. Default is null. If set, will\n+ * override . E.g. if slideRatio is .5, then the Pan Up\n+ * button will pan up half the map height. \n */\n- layers: null,\n+ slideRatio: null,\n \n- /* Property: defaultHandlerOptions\n- * The default opts passed to the handler constructors\n+ /** \n+ * Property: buttons\n+ * {Array(DOMElement)} Array of Button Divs \n */\n- defaultHandlerOptions: {\n- 'delay': 300,\n- 'pixelTolerance': 4,\n- 'stopMove': false,\n- 'single': true,\n- 'double': false,\n- 'stopSingle': false,\n- 'stopDouble': false\n- },\n+ buttons: null,\n \n- /* APIProperty: handlerMode\n- * Defaults to 'click'. Can be 'hover' or 'move'.\n+ /** \n+ * Property: position\n+ * {} \n */\n- handlerMode: 'click',\n+ position: null,\n \n /**\n- * APIMethod: setHandler\n- * sets this.handlerMode and calls resetHandler()\n- *\n+ * Constructor: OpenLayers.Control.PanZoom\n+ * \n * Parameters:\n- * hm - {String} Handler Mode string; 'click', 'hover' or 'move'.\n+ * options - {Object}\n */\n- setHandler: function(hm) {\n- this.handlerMode = hm;\n- this.resetHandler();\n+ initialize: function(options) {\n+ this.position = new OpenLayers.Pixel(OpenLayers.Control.PanZoom.X,\n+ OpenLayers.Control.PanZoom.Y);\n+ OpenLayers.Control.prototype.initialize.apply(this, arguments);\n },\n \n /**\n- * Method: resetHandler\n- * Deactivates the old hanlder and creates a new\n- * based on the mode specified in\n- * this.handlerMode\n- *\n+ * APIMethod: destroy\n */\n- resetHandler: function() {\n- if (this.handler) {\n- this.handler.deactivate();\n- this.handler.destroy();\n- this.handler = null;\n+ destroy: function() {\n+ if (this.map) {\n+ this.map.events.unregister(\"buttonclick\", this, this.onButtonClick);\n }\n+ this.removeButtons();\n+ this.buttons = null;\n+ this.position = null;\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n+ },\n \n- if (this.handlerMode == 'hover') {\n- // Handle this event on hover\n- this.handler = new OpenLayers.Handler.Hover(\n- this, {\n- 'pause': this.handleEvent,\n- 'move': this.reset\n- },\n- this.handlerOptions\n- );\n- } else if (this.handlerMode == 'click') {\n- // Handle this event on click\n- this.handler = new OpenLayers.Handler.Click(\n- this, {\n- 'click': this.handleEvent\n- }, this.handlerOptions\n- );\n- } else if (this.handlerMode == 'move') {\n- this.handler = new OpenLayers.Handler.Hover(\n- this,\n- // Handle this event while hovering OR moving\n- {\n- 'pause': this.handleEvent,\n- 'move': this.handleEvent\n- },\n- this.handlerOptions\n- );\n- }\n- if (this.handler) {\n- return true;\n- } else {\n- return false;\n- }\n+ /** \n+ * Method: setMap\n+ *\n+ * Properties:\n+ * map - {} \n+ */\n+ setMap: function(map) {\n+ OpenLayers.Control.prototype.setMap.apply(this, arguments);\n+ this.map.events.register(\"buttonclick\", this, this.onButtonClick);\n },\n \n /**\n- * Constructor: \n+ * Method: draw\n *\n * Parameters:\n- * options - {Object} \n+ * px - {} \n+ * \n+ * Returns:\n+ * {DOMElement} A reference to the container div for the PanZoom control.\n */\n- initialize: function(options) {\n- options = options || {};\n- options.handlerOptions = options.handlerOptions || this.defaultHandlerOptions;\n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n- this.resetHandler();\n+ draw: function(px) {\n+ // initialize our internal div\n+ OpenLayers.Control.prototype.draw.apply(this, arguments);\n+ px = this.position;\n+\n+ // place the controls\n+ this.buttons = [];\n+\n+ var sz = {\n+ w: 18,\n+ h: 18\n+ };\n+ var centered = new OpenLayers.Pixel(px.x + sz.w / 2, px.y);\n+\n+ this._addButton(\"panup\", \"north-mini.png\", centered, sz);\n+ px.y = centered.y + sz.h;\n+ this._addButton(\"panleft\", \"west-mini.png\", px, sz);\n+ this._addButton(\"panright\", \"east-mini.png\", px.add(sz.w, 0), sz);\n+ this._addButton(\"pandown\", \"south-mini.png\",\n+ centered.add(0, sz.h * 2), sz);\n+ this._addButton(\"zoomin\", \"zoom-plus-mini.png\",\n+ centered.add(0, sz.h * 3 + 5), sz);\n+ this._addButton(\"zoomworld\", \"zoom-world-mini.png\",\n+ centered.add(0, sz.h * 4 + 5), sz);\n+ this._addButton(\"zoomout\", \"zoom-minus-mini.png\",\n+ centered.add(0, sz.h * 5 + 5), sz);\n+ return this.div;\n },\n \n /**\n- * Method: handleEvent\n- * Internal method called when specified event is triggered.\n+ * Method: _addButton\n * \n- * This method does several things:\n- *\n- * Gets the lonLat of the event.\n- *\n- * Loops through the appropriate hit grid layers and gathers the attributes.\n- *\n- * Passes the attributes to the callback\n- *\n * Parameters:\n- * evt - {} \n+ * id - {String} \n+ * img - {String} \n+ * xy - {} \n+ * sz - {} \n+ * \n+ * Returns:\n+ * {DOMElement} A Div (an alphaImageDiv, to be precise) that contains the\n+ * image of the button, and has all the proper event handlers set.\n */\n- handleEvent: function(evt) {\n- if (evt == null) {\n- this.reset();\n- return;\n- }\n-\n- var lonLat = this.map.getLonLatFromPixel(evt.xy);\n- if (!lonLat) {\n- return;\n- }\n+ _addButton: function(id, img, xy, sz) {\n+ var imgLocation = OpenLayers.Util.getImageLocation(img);\n+ var btn = OpenLayers.Util.createAlphaImageDiv(\n+ this.id + \"_\" + id,\n+ xy, sz, imgLocation, \"absolute\");\n+ btn.style.cursor = \"pointer\";\n+ //we want to add the outer div\n+ this.div.appendChild(btn);\n+ btn.action = id;\n+ btn.className = \"olButton\";\n \n- var layers = this.findLayers();\n- if (layers.length > 0) {\n- var infoLookup = {};\n- var layer, idx;\n- for (var i = 0, len = layers.length; i < len; i++) {\n- layer = layers[i];\n- idx = OpenLayers.Util.indexOf(this.map.layers, layer);\n- infoLookup[idx] = layer.getFeatureInfo(lonLat);\n- }\n- this.callback(infoLookup, lonLat, evt.xy);\n- }\n+ //we want to remember/reference the outer div\n+ this.buttons.push(btn);\n+ return btn;\n },\n \n /**\n- * APIMethod: callback\n- * Function to be called when a mouse event corresponds with a location that\n- * includes data in one of the configured UTFGrid layers.\n- *\n+ * Method: _removeButton\n+ * \n * Parameters:\n- * infoLookup - {Object} Keys of this object are layer indexes and can be\n- * used to resolve a layer in the map.layers array. The structure of\n- * the property values depend on the data included in the underlying\n- * UTFGrid and may be any valid JSON type. \n+ * btn - {Object}\n */\n- callback: function(infoLookup) {\n- // to be provided in the constructor\n+ _removeButton: function(btn) {\n+ this.div.removeChild(btn);\n+ OpenLayers.Util.removeItem(this.buttons, btn);\n },\n \n /**\n- * Method: reset\n- * Calls the callback with null.\n+ * Method: removeButtons\n */\n- reset: function(evt) {\n- this.callback(null);\n+ removeButtons: function() {\n+ for (var i = this.buttons.length - 1; i >= 0; --i) {\n+ this._removeButton(this.buttons[i]);\n+ }\n },\n \n /**\n- * Method: findLayers\n- * Internal method to get the layers, independent of whether we are\n- * inspecting the map or using a client-provided array\n+ * Method: onButtonClick\n *\n- * The default value of this.layers is null; this causes the \n- * findLayers method to return ALL UTFGrid layers encountered.\n+ * Parameters:\n+ * evt - {Event}\n+ */\n+ onButtonClick: function(evt) {\n+ var btn = evt.buttonElement;\n+ switch (btn.action) {\n+ case \"panup\":\n+ this.map.pan(0, -this.getSlideFactor(\"h\"));\n+ break;\n+ case \"pandown\":\n+ this.map.pan(0, this.getSlideFactor(\"h\"));\n+ break;\n+ case \"panleft\":\n+ this.map.pan(-this.getSlideFactor(\"w\"), 0);\n+ break;\n+ case \"panright\":\n+ this.map.pan(this.getSlideFactor(\"w\"), 0);\n+ break;\n+ case \"zoomin\":\n+ this.map.zoomIn();\n+ break;\n+ case \"zoomout\":\n+ this.map.zoomOut();\n+ break;\n+ case \"zoomworld\":\n+ this.map.zoomToMaxExtent();\n+ break;\n+ }\n+ },\n+\n+ /**\n+ * Method: getSlideFactor\n *\n * Parameters:\n- * None\n+ * dim - {String} \"w\" or \"h\" (for width or height).\n *\n * Returns:\n- * {Array} Layers to handle on each event\n+ * {Number} The slide factor for panning in the requested direction.\n */\n- findLayers: function() {\n- var candidates = this.layers || this.map.layers;\n- var layers = [];\n- var layer;\n- for (var i = candidates.length - 1; i >= 0; --i) {\n- layer = candidates[i];\n- if (layer instanceof OpenLayers.Layer.UTFGrid) {\n- layers.push(layer);\n- }\n- }\n- return layers;\n+ getSlideFactor: function(dim) {\n+ return this.slideRatio ?\n+ this.map.getSize()[dim] * this.slideRatio :\n+ this.slideFactor;\n },\n \n- CLASS_NAME: \"OpenLayers.Control.UTFGrid\"\n+ CLASS_NAME: \"OpenLayers.Control.PanZoom\"\n });\n+\n+/**\n+ * Constant: X\n+ * {Integer}\n+ */\n+OpenLayers.Control.PanZoom.X = 4;\n+\n+/**\n+ * Constant: Y\n+ * {Integer}\n+ */\n+OpenLayers.Control.PanZoom.Y = 4;\n /* ======================================================================\n- OpenLayers/Control/MousePosition.js\n+ OpenLayers/Control/PanZoomBar.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n \n /**\n- * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Control/PanZoom.js\n */\n \n /**\n- * Class: OpenLayers.Control.MousePosition\n- * The MousePosition control displays geographic coordinates of the mouse\n- * pointer, as it is moved about the map.\n- *\n- * You can use the - or -properties to provide more information\n- * about the displayed coordinates to the user:\n- *\n- * (code)\n- * var mousePositionCtrl = new OpenLayers.Control.MousePosition({\n- * prefix: '' +\n- * 'EPSG:4326 coordinates: '\n- * }\n- * );\n- * (end code)\n+ * Class: OpenLayers.Control.PanZoomBar\n+ * The PanZoomBar is a visible control composed of a\n+ * and a . \n+ * By default it is displayed in the upper left corner of the map as 4\n+ * directional arrows above a vertical slider.\n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {\n \n- /**\n- * APIProperty: autoActivate\n- * {Boolean} Activate the control when it is added to a map. Default is\n- * true.\n+ /** \n+ * APIProperty: zoomStopWidth\n */\n- autoActivate: true,\n+ zoomStopWidth: 18,\n \n- /**\n- * Property: element\n- * {DOMElement}\n+ /** \n+ * APIProperty: zoomStopHeight\n */\n- element: null,\n+ zoomStopHeight: 11,\n \n- /**\n- * APIProperty: prefix\n- * {String} A string to be prepended to the current pointers coordinates\n- * when it is rendered. Defaults to the empty string ''.\n+ /** \n+ * Property: slider\n */\n- prefix: '',\n+ slider: null,\n \n- /**\n- * APIProperty: separator\n- * {String} A string to be used to seperate the two coordinates from each\n- * other. Defaults to the string ', ', which will result in a\n- * rendered coordinate of e.g. '42.12, 21.22'.\n+ /** \n+ * Property: sliderEvents\n+ * {}\n */\n- separator: ', ',\n+ sliderEvents: null,\n \n- /**\n- * APIProperty: suffix\n- * {String} A string to be appended to the current pointers coordinates\n- * when it is rendered. Defaults to the empty string ''.\n+ /** \n+ * Property: zoombarDiv\n+ * {DOMElement}\n */\n- suffix: '',\n+ zoombarDiv: null,\n \n- /**\n- * APIProperty: numDigits\n- * {Integer} The number of digits each coordinate shall have when being\n- * rendered, Defaults to 5.\n+ /** \n+ * APIProperty: zoomWorldIcon\n+ * {Boolean}\n */\n- numDigits: 5,\n+ zoomWorldIcon: false,\n \n /**\n- * APIProperty: granularity\n- * {Integer}\n+ * APIProperty: panIcons\n+ * {Boolean} Set this property to false not to display the pan icons. If\n+ * false the zoom world icon is placed under the zoom bar. Defaults to\n+ * true.\n */\n- granularity: 10,\n+ panIcons: true,\n \n /**\n- * APIProperty: emptyString\n- * {String} Set this to some value to set when the mouse is outside the\n- * map.\n+ * APIProperty: forceFixedZoomLevel\n+ * {Boolean} Force a fixed zoom level even though the map has \n+ * fractionalZoom\n */\n- emptyString: null,\n+ forceFixedZoomLevel: false,\n \n /**\n- * Property: lastXy\n+ * Property: mouseDragStart\n * {}\n */\n- lastXy: null,\n+ mouseDragStart: null,\n \n /**\n- * APIProperty: displayProjection\n- * {} The projection in which the mouse position is\n- * displayed.\n+ * Property: deltaY\n+ * {Number} The cumulative vertical pixel offset during a zoom bar drag.\n */\n- displayProjection: null,\n+ deltaY: null,\n \n /**\n- * Constructor: OpenLayers.Control.MousePosition\n- *\n- * Parameters:\n- * options - {Object} Options for control.\n+ * Property: zoomStart\n+ * {}\n */\n+ zoomStart: null,\n \n /**\n- * Method: destroy\n+ * Constructor: OpenLayers.Control.PanZoomBar\n */\n- destroy: function() {\n- this.deactivate();\n- OpenLayers.Control.prototype.destroy.apply(this, arguments);\n- },\n \n /**\n- * APIMethod: activate\n+ * APIMethod: destroy\n */\n- activate: function() {\n- if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {\n- this.map.events.register('mousemove', this, this.redraw);\n- this.map.events.register('mouseout', this, this.reset);\n- this.redraw();\n- return true;\n- } else {\n- return false;\n- }\n- },\n+ destroy: function() {\n \n- /**\n- * APIMethod: deactivate\n- */\n- deactivate: function() {\n- if (OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {\n- this.map.events.unregister('mousemove', this, this.redraw);\n- this.map.events.unregister('mouseout', this, this.reset);\n- this.element.innerHTML = \"\";\n- return true;\n- } else {\n- return false;\n- }\n- },\n+ this._removeZoomBar();\n \n- /**\n- * Method: draw\n- * {DOMElement}\n- */\n- draw: function() {\n- OpenLayers.Control.prototype.draw.apply(this, arguments);\n+ this.map.events.un({\n+ \"changebaselayer\": this.redraw,\n+ \"updatesize\": this.redraw,\n+ scope: this\n+ });\n \n- if (!this.element) {\n- this.div.left = \"\";\n- this.div.top = \"\";\n- this.element = this.div;\n- }\n+ OpenLayers.Control.PanZoom.prototype.destroy.apply(this, arguments);\n \n- return this.div;\n+ delete this.mouseDragStart;\n+ delete this.zoomStart;\n },\n \n /**\n- * Method: redraw\n+ * Method: setMap\n+ * \n+ * Parameters:\n+ * map - {} \n */\n- redraw: function(evt) {\n-\n- var lonLat;\n-\n- if (evt == null) {\n- this.reset();\n- return;\n- } else {\n- if (this.lastXy == null ||\n- Math.abs(evt.xy.x - this.lastXy.x) > this.granularity ||\n- Math.abs(evt.xy.y - this.lastXy.y) > this.granularity) {\n- this.lastXy = evt.xy;\n- return;\n- }\n-\n- lonLat = this.map.getLonLatFromPixel(evt.xy);\n- if (!lonLat) {\n- // map has not yet been properly initialized\n- return;\n- }\n- if (this.displayProjection) {\n- lonLat.transform(this.map.getProjectionObject(),\n- this.displayProjection);\n- }\n- this.lastXy = evt.xy;\n-\n- }\n-\n- var newHtml = this.formatOutput(lonLat);\n-\n- if (newHtml != this.element.innerHTML) {\n- this.element.innerHTML = newHtml;\n- }\n+ setMap: function(map) {\n+ OpenLayers.Control.PanZoom.prototype.setMap.apply(this, arguments);\n+ this.map.events.on({\n+ \"changebaselayer\": this.redraw,\n+ \"updatesize\": this.redraw,\n+ scope: this\n+ });\n },\n \n- /**\n- * Method: reset\n+ /** \n+ * Method: redraw\n+ * clear the div and start over.\n */\n- reset: function(evt) {\n- if (this.emptyString != null) {\n- this.element.innerHTML = this.emptyString;\n+ redraw: function() {\n+ if (this.div != null) {\n+ this.removeButtons();\n+ this._removeZoomBar();\n }\n+ this.draw();\n },\n \n /**\n- * Method: formatOutput\n- * Override to provide custom display output\n+ * Method: draw \n *\n * Parameters:\n- * lonLat - {} Location to display\n+ * px - {} \n */\n- formatOutput: function(lonLat) {\n- var digits = parseInt(this.numDigits);\n- var newHtml =\n- this.prefix +\n- lonLat.lon.toFixed(digits) +\n- this.separator +\n- lonLat.lat.toFixed(digits) +\n- this.suffix;\n- return newHtml;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Control.MousePosition\"\n-});\n-/* ======================================================================\n- OpenLayers/Control/Graticule.js\n- ====================================================================== */\n+ draw: function(px) {\n+ // initialize our internal div\n+ OpenLayers.Control.prototype.draw.apply(this, arguments);\n+ px = this.position.clone();\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ // place the controls\n+ this.buttons = [];\n \n-/**\n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Lang.js\n- * @requires OpenLayers/Rule.js\n- * @requires OpenLayers/StyleMap.js\n- * @requires OpenLayers/Layer/Vector.js\n- */\n+ var sz = {\n+ w: 18,\n+ h: 18\n+ };\n+ if (this.panIcons) {\n+ var centered = new OpenLayers.Pixel(px.x + sz.w / 2, px.y);\n+ var wposition = sz.w;\n \n-/**\n- * Class: OpenLayers.Control.Graticule\n- * The Graticule displays a grid of latitude/longitude lines reprojected on\n- * the map. \n- * \n- * Inherits from:\n- * - \n- * \n- */\n-OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {\n+ if (this.zoomWorldIcon) {\n+ centered = new OpenLayers.Pixel(px.x + sz.w, px.y);\n+ }\n \n- /**\n- * APIProperty: autoActivate\n- * {Boolean} Activate the control when it is added to a map. Default is\n- * true. \n- */\n- autoActivate: true,\n+ this._addButton(\"panup\", \"north-mini.png\", centered, sz);\n+ px.y = centered.y + sz.h;\n+ this._addButton(\"panleft\", \"west-mini.png\", px, sz);\n+ if (this.zoomWorldIcon) {\n+ this._addButton(\"zoomworld\", \"zoom-world-mini.png\", px.add(sz.w, 0), sz);\n \n- /**\n- * APIProperty: intervals\n- * {Array(Float)} A list of possible graticule widths in degrees.\n- */\n- intervals: [45, 30, 20, 10, 5, 2, 1,\n- 0.5, 0.2, 0.1, 0.05, 0.01,\n- 0.005, 0.002, 0.001\n- ],\n+ wposition *= 2;\n+ }\n+ this._addButton(\"panright\", \"east-mini.png\", px.add(wposition, 0), sz);\n+ this._addButton(\"pandown\", \"south-mini.png\", centered.add(0, sz.h * 2), sz);\n+ this._addButton(\"zoomin\", \"zoom-plus-mini.png\", centered.add(0, sz.h * 3 + 5), sz);\n+ centered = this._addZoomBar(centered.add(0, sz.h * 4 + 5));\n+ this._addButton(\"zoomout\", \"zoom-minus-mini.png\", centered, sz);\n+ } else {\n+ this._addButton(\"zoomin\", \"zoom-plus-mini.png\", px, sz);\n+ centered = this._addZoomBar(px.add(0, sz.h));\n+ this._addButton(\"zoomout\", \"zoom-minus-mini.png\", centered, sz);\n+ if (this.zoomWorldIcon) {\n+ centered = centered.add(0, sz.h + 3);\n+ this._addButton(\"zoomworld\", \"zoom-world-mini.png\", centered, sz);\n+ }\n+ }\n+ return this.div;\n+ },\n \n- /**\n- * APIProperty: displayInLayerSwitcher\n- * {Boolean} Allows the Graticule control to be switched on and off by \n- * LayerSwitcher control. Defaults is true.\n+ /** \n+ * Method: _addZoomBar\n+ * \n+ * Parameters:\n+ * centered - {} where zoombar drawing is to start.\n */\n- displayInLayerSwitcher: true,\n+ _addZoomBar: function(centered) {\n+ var imgLocation = OpenLayers.Util.getImageLocation(\"slider.png\");\n+ var id = this.id + \"_\" + this.map.id;\n+ var minZoom = this.map.getMinZoom();\n+ var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom();\n+ var slider = OpenLayers.Util.createAlphaImageDiv(id,\n+ centered.add(-1, zoomsToEnd * this.zoomStopHeight), {\n+ w: 20,\n+ h: 9\n+ },\n+ imgLocation,\n+ \"absolute\");\n+ slider.style.cursor = \"move\";\n+ this.slider = slider;\n \n- /**\n- * APIProperty: visible\n- * {Boolean} should the graticule be initially visible (default=true)\n- */\n- visible: true,\n+ this.sliderEvents = new OpenLayers.Events(this, slider, null, true, {\n+ includeXY: true\n+ });\n+ this.sliderEvents.on({\n+ \"touchstart\": this.zoomBarDown,\n+ \"touchmove\": this.zoomBarDrag,\n+ \"touchend\": this.zoomBarUp,\n+ \"mousedown\": this.zoomBarDown,\n+ \"mousemove\": this.zoomBarDrag,\n+ \"mouseup\": this.zoomBarUp\n+ });\n \n- /**\n- * APIProperty: numPoints\n- * {Integer} The number of points to use in each graticule line. Higher\n- * numbers result in a smoother curve for projected maps \n- */\n- numPoints: 50,\n+ var sz = {\n+ w: this.zoomStopWidth,\n+ h: this.zoomStopHeight * (this.map.getNumZoomLevels() - minZoom)\n+ };\n+ var imgLocation = OpenLayers.Util.getImageLocation(\"zoombar.png\");\n+ var div = null;\n \n- /**\n- * APIProperty: targetSize\n- * {Integer} The maximum size of the grid in pixels on the map\n- */\n- targetSize: 200,\n+ if (OpenLayers.Util.alphaHack()) {\n+ var id = this.id + \"_\" + this.map.id;\n+ div = OpenLayers.Util.createAlphaImageDiv(id, centered, {\n+ w: sz.w,\n+ h: this.zoomStopHeight\n+ },\n+ imgLocation,\n+ \"absolute\", null, \"crop\");\n+ div.style.height = sz.h + \"px\";\n+ } else {\n+ div = OpenLayers.Util.createDiv(\n+ 'OpenLayers_Control_PanZoomBar_Zoombar' + this.map.id,\n+ centered,\n+ sz,\n+ imgLocation);\n+ }\n+ div.style.cursor = \"pointer\";\n+ div.className = \"olButton\";\n+ this.zoombarDiv = div;\n \n- /**\n- * APIProperty: layerName\n- * {String} The name to be displayed in the layer switcher, default is set \n- * by {}.\n- */\n- layerName: null,\n+ this.div.appendChild(div);\n \n- /**\n- * APIProperty: labelled\n- * {Boolean} Should the graticule lines be labelled?. default=true\n- */\n- labelled: true,\n+ this.startTop = parseInt(div.style.top);\n+ this.div.appendChild(slider);\n \n- /**\n- * APIProperty: labelFormat\n- * {String} the format of the labels, default = 'dm'. See\n- * for other options.\n- */\n- labelFormat: 'dm',\n+ this.map.events.register(\"zoomend\", this, this.moveZoomBar);\n \n- /**\n- * APIProperty: lineSymbolizer\n- * {symbolizer} the symbolizer used to render lines\n- */\n- lineSymbolizer: {\n- strokeColor: \"#333\",\n- strokeWidth: 1,\n- strokeOpacity: 0.5\n+ centered = centered.add(0,\n+ this.zoomStopHeight * (this.map.getNumZoomLevels() - minZoom));\n+ return centered;\n },\n \n /**\n- * APIProperty: labelSymbolizer\n- * {symbolizer} the symbolizer used to render labels\n- */\n- labelSymbolizer: {},\n-\n- /**\n- * Property: gratLayer\n- * {} vector layer used to draw the graticule on\n+ * Method: _removeZoomBar\n */\n- gratLayer: null,\n+ _removeZoomBar: function() {\n+ this.sliderEvents.un({\n+ \"touchstart\": this.zoomBarDown,\n+ \"touchmove\": this.zoomBarDrag,\n+ \"touchend\": this.zoomBarUp,\n+ \"mousedown\": this.zoomBarDown,\n+ \"mousemove\": this.zoomBarDrag,\n+ \"mouseup\": this.zoomBarUp\n+ });\n+ this.sliderEvents.destroy();\n \n- /**\n- * Constructor: OpenLayers.Control.Graticule\n- * Create a new graticule control to display a grid of latitude longitude\n- * lines.\n- * \n- * Parameters:\n- * options - {Object} An optional object whose properties will be used\n- * to extend the control.\n- */\n- initialize: function(options) {\n- options = options || {};\n- options.layerName = options.layerName || OpenLayers.i18n(\"Graticule\");\n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+ this.div.removeChild(this.zoombarDiv);\n+ this.zoombarDiv = null;\n+ this.div.removeChild(this.slider);\n+ this.slider = null;\n \n- this.labelSymbolizer.stroke = false;\n- this.labelSymbolizer.fill = false;\n- this.labelSymbolizer.label = \"${label}\";\n- this.labelSymbolizer.labelAlign = \"${labelAlign}\";\n- this.labelSymbolizer.labelXOffset = \"${xOffset}\";\n- this.labelSymbolizer.labelYOffset = \"${yOffset}\";\n+ this.map.events.unregister(\"zoomend\", this, this.moveZoomBar);\n },\n \n /**\n- * APIMethod: destroy\n+ * Method: onButtonClick\n+ *\n+ * Parameters:\n+ * evt - {Event}\n */\n- destroy: function() {\n- this.deactivate();\n- OpenLayers.Control.prototype.destroy.apply(this, arguments);\n- if (this.gratLayer) {\n- this.gratLayer.destroy();\n- this.gratLayer = null;\n+ onButtonClick: function(evt) {\n+ OpenLayers.Control.PanZoom.prototype.onButtonClick.apply(this, arguments);\n+ if (evt.buttonElement === this.zoombarDiv) {\n+ var levels = evt.buttonXY.y / this.zoomStopHeight;\n+ if (this.forceFixedZoomLevel || !this.map.fractionalZoom) {\n+ levels = Math.floor(levels);\n+ }\n+ var zoom = (this.map.getNumZoomLevels() - 1) - levels;\n+ zoom = Math.min(Math.max(zoom, 0), this.map.getNumZoomLevels() - 1);\n+ this.map.zoomTo(zoom);\n }\n },\n \n /**\n- * Method: draw\n+ * Method: passEventToSlider\n+ * This function is used to pass events that happen on the div, or the map,\n+ * through to the slider, which then does its moving thing.\n *\n- * initializes the graticule layer and does the initial update\n- * \n- * Returns:\n- * {DOMElement}\n+ * Parameters:\n+ * evt - {} \n */\n- draw: function() {\n- OpenLayers.Control.prototype.draw.apply(this, arguments);\n- if (!this.gratLayer) {\n- var gratStyle = new OpenLayers.Style({}, {\n- rules: [new OpenLayers.Rule({\n- 'symbolizer': {\n- \"Point\": this.labelSymbolizer,\n- \"Line\": this.lineSymbolizer\n- }\n- })]\n- });\n- this.gratLayer = new OpenLayers.Layer.Vector(this.layerName, {\n- styleMap: new OpenLayers.StyleMap({\n- 'default': gratStyle\n- }),\n- visibility: this.visible,\n- displayInLayerSwitcher: this.displayInLayerSwitcher\n- });\n- }\n- return this.div;\n+ passEventToSlider: function(evt) {\n+ this.sliderEvents.handleBrowserEvent(evt);\n },\n \n- /**\n- * APIMethod: activate\n+ /*\n+ * Method: zoomBarDown\n+ * event listener for clicks on the slider\n+ *\n+ * Parameters:\n+ * evt - {} \n */\n- activate: function() {\n- if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {\n- this.map.addLayer(this.gratLayer);\n- this.map.events.register('moveend', this, this.update);\n- this.update();\n- return true;\n- } else {\n- return false;\n+ zoomBarDown: function(evt) {\n+ if (!OpenLayers.Event.isLeftClick(evt) && !OpenLayers.Event.isSingleTouch(evt)) {\n+ return;\n }\n+ this.map.events.on({\n+ \"touchmove\": this.passEventToSlider,\n+ \"mousemove\": this.passEventToSlider,\n+ \"mouseup\": this.passEventToSlider,\n+ scope: this\n+ });\n+ this.mouseDragStart = evt.xy.clone();\n+ this.zoomStart = evt.xy.clone();\n+ this.div.style.cursor = \"move\";\n+ // reset the div offsets just in case the div moved\n+ this.zoombarDiv.offsets = null;\n+ OpenLayers.Event.stop(evt);\n },\n \n- /**\n- * APIMethod: deactivate\n+ /*\n+ * Method: zoomBarDrag\n+ * This is what happens when a click has occurred, and the client is\n+ * dragging. Here we must ensure that the slider doesn't go beyond the\n+ * bottom/top of the zoombar div, as well as moving the slider to its new\n+ * visual location\n+ *\n+ * Parameters:\n+ * evt - {} \n */\n- deactivate: function() {\n- if (OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {\n- this.map.events.unregister('moveend', this, this.update);\n- this.map.removeLayer(this.gratLayer);\n- return true;\n- } else {\n- return false;\n+ zoomBarDrag: function(evt) {\n+ if (this.mouseDragStart != null) {\n+ var deltaY = this.mouseDragStart.y - evt.xy.y;\n+ var offsets = OpenLayers.Util.pagePosition(this.zoombarDiv);\n+ if ((evt.clientY - offsets[1]) > 0 &&\n+ (evt.clientY - offsets[1]) < parseInt(this.zoombarDiv.style.height) - 2) {\n+ var newTop = parseInt(this.slider.style.top) - deltaY;\n+ this.slider.style.top = newTop + \"px\";\n+ this.mouseDragStart = evt.xy.clone();\n+ }\n+ // set cumulative displacement\n+ this.deltaY = this.zoomStart.y - evt.xy.y;\n+ OpenLayers.Event.stop(evt);\n }\n },\n- /**\n- * Method: update\n+\n+ /*\n+ * Method: zoomBarUp\n+ * Perform cleanup when a mouseup event is received -- discover new zoom\n+ * level and switch to it.\n *\n- * calculates the grid to be displayed and actually draws it\n- * \n- * Returns:\n- * {DOMElement}\n+ * Parameters:\n+ * evt - {} \n */\n- update: function() {\n- //wait for the map to be initialized before proceeding\n- var mapBounds = this.map.getExtent();\n- if (!mapBounds) {\n+ zoomBarUp: function(evt) {\n+ if (!OpenLayers.Event.isLeftClick(evt) && evt.type !== \"touchend\") {\n return;\n }\n-\n- //clear out the old grid\n- this.gratLayer.destroyFeatures();\n-\n- //get the projection objects required\n- var llProj = new OpenLayers.Projection(\"EPSG:4326\");\n- var mapProj = this.map.getProjectionObject();\n- var mapRes = this.map.getResolution();\n-\n- //if the map is in lon/lat, then the lines are straight and only one\n- //point is required\n- if (mapProj.proj && mapProj.proj.projName == \"longlat\") {\n- this.numPoints = 1;\n- }\n-\n- //get the map center in EPSG:4326\n- var mapCenter = this.map.getCenter(); //lon and lat here are really map x and y\n- var mapCenterLL = new OpenLayers.Pixel(mapCenter.lon, mapCenter.lat);\n- OpenLayers.Projection.transform(mapCenterLL, mapProj, llProj);\n-\n- /* This block of code determines the lon/lat interval to use for the\n- * grid by calculating the diagonal size of one grid cell at the map\n- * center. Iterates through the intervals array until the diagonal\n- * length is less than the targetSize option.\n- */\n- //find lat/lon interval that results in a grid of less than the target size\n- var testSq = this.targetSize * mapRes;\n- testSq *= testSq; //compare squares rather than doing a square root to save time\n- var llInterval;\n- for (var i = 0; i < this.intervals.length; ++i) {\n- llInterval = this.intervals[i]; //could do this for both x and y??\n- var delta = llInterval / 2;\n- var p1 = mapCenterLL.offset({\n- x: -delta,\n- y: -delta\n- }); //test coords in EPSG:4326 space\n- var p2 = mapCenterLL.offset({\n- x: delta,\n- y: delta\n- });\n- OpenLayers.Projection.transform(p1, llProj, mapProj); // convert them back to map projection\n- OpenLayers.Projection.transform(p2, llProj, mapProj);\n- var distSq = (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y);\n- if (distSq <= testSq) {\n- break;\n- }\n- }\n- //alert(llInterval);\n-\n- //round the LL center to an even number based on the interval\n- mapCenterLL.x = Math.floor(mapCenterLL.x / llInterval) * llInterval;\n- mapCenterLL.y = Math.floor(mapCenterLL.y / llInterval) * llInterval;\n- //TODO adjust for minutses/seconds?\n-\n- /* The following 2 blocks calculate the nodes of the grid along a \n- * line of constant longitude (then latitiude) running through the\n- * center of the map until it reaches the map edge. The calculation\n- * goes from the center in both directions to the edge.\n- */\n- //get the central longitude line, increment the latitude\n- var iter = 0;\n- var centerLonPoints = [mapCenterLL.clone()];\n- var newPoint = mapCenterLL.clone();\n- var mapXY;\n- do {\n- newPoint = newPoint.offset({\n- x: 0,\n- y: llInterval\n- });\n- mapXY = OpenLayers.Projection.transform(newPoint.clone(), llProj, mapProj);\n- centerLonPoints.unshift(newPoint);\n- } while (mapBounds.containsPixel(mapXY) && ++iter < 1000);\n- newPoint = mapCenterLL.clone();\n- do {\n- newPoint = newPoint.offset({\n- x: 0,\n- y: -llInterval\n- });\n- mapXY = OpenLayers.Projection.transform(newPoint.clone(), llProj, mapProj);\n- centerLonPoints.push(newPoint);\n- } while (mapBounds.containsPixel(mapXY) && ++iter < 1000);\n-\n- //get the central latitude line, increment the longitude\n- iter = 0;\n- var centerLatPoints = [mapCenterLL.clone()];\n- newPoint = mapCenterLL.clone();\n- do {\n- newPoint = newPoint.offset({\n- x: -llInterval,\n- y: 0\n- });\n- mapXY = OpenLayers.Projection.transform(newPoint.clone(), llProj, mapProj);\n- centerLatPoints.unshift(newPoint);\n- } while (mapBounds.containsPixel(mapXY) && ++iter < 1000);\n- newPoint = mapCenterLL.clone();\n- do {\n- newPoint = newPoint.offset({\n- x: llInterval,\n- y: 0\n+ if (this.mouseDragStart) {\n+ this.div.style.cursor = \"\";\n+ this.map.events.un({\n+ \"touchmove\": this.passEventToSlider,\n+ \"mouseup\": this.passEventToSlider,\n+ \"mousemove\": this.passEventToSlider,\n+ scope: this\n });\n- mapXY = OpenLayers.Projection.transform(newPoint.clone(), llProj, mapProj);\n- centerLatPoints.push(newPoint);\n- } while (mapBounds.containsPixel(mapXY) && ++iter < 1000);\n-\n- //now generate a line for each node in the central lat and lon lines\n- //first loop over constant longitude\n- var lines = [];\n- for (var i = 0; i < centerLatPoints.length; ++i) {\n- var lon = centerLatPoints[i].x;\n- var pointList = [];\n- var labelPoint = null;\n- var latEnd = Math.min(centerLonPoints[0].y, 90);\n- var latStart = Math.max(centerLonPoints[centerLonPoints.length - 1].y, -90);\n- var latDelta = (latEnd - latStart) / this.numPoints;\n- var lat = latStart;\n- for (var j = 0; j <= this.numPoints; ++j) {\n- var gridPoint = new OpenLayers.Geometry.Point(lon, lat);\n- gridPoint.transform(llProj, mapProj);\n- pointList.push(gridPoint);\n- lat += latDelta;\n- if (gridPoint.y >= mapBounds.bottom && !labelPoint) {\n- labelPoint = gridPoint;\n- }\n- }\n- if (this.labelled) {\n- //keep track of when this grid line crosses the map bounds to set\n- //the label position\n- //labels along the bottom, add 10 pixel offset up into the map\n- //TODO add option for labels on top\n- var labelPos = new OpenLayers.Geometry.Point(labelPoint.x, mapBounds.bottom);\n- var labelAttrs = {\n- value: lon,\n- label: this.labelled ? OpenLayers.Util.getFormattedLonLat(lon, \"lon\", this.labelFormat) : \"\",\n- labelAlign: \"cb\",\n- xOffset: 0,\n- yOffset: 2\n- };\n- this.gratLayer.addFeatures(new OpenLayers.Feature.Vector(labelPos, labelAttrs));\n+ var zoomLevel = this.map.zoom;\n+ if (!this.forceFixedZoomLevel && this.map.fractionalZoom) {\n+ zoomLevel += this.deltaY / this.zoomStopHeight;\n+ zoomLevel = Math.min(Math.max(zoomLevel, 0),\n+ this.map.getNumZoomLevels() - 1);\n+ } else {\n+ zoomLevel += this.deltaY / this.zoomStopHeight;\n+ zoomLevel = Math.max(Math.round(zoomLevel), 0);\n }\n- var geom = new OpenLayers.Geometry.LineString(pointList);\n- lines.push(new OpenLayers.Feature.Vector(geom));\n+ this.map.zoomTo(zoomLevel);\n+ this.mouseDragStart = null;\n+ this.zoomStart = null;\n+ this.deltaY = 0;\n+ OpenLayers.Event.stop(evt);\n }\n+ },\n \n- //now draw the lines of constant latitude\n- for (var j = 0; j < centerLonPoints.length; ++j) {\n- lat = centerLonPoints[j].y;\n- if (lat < -90 || lat > 90) { //latitudes only valid between -90 and 90\n- continue;\n- }\n- var pointList = [];\n- var lonStart = centerLatPoints[0].x;\n- var lonEnd = centerLatPoints[centerLatPoints.length - 1].x;\n- var lonDelta = (lonEnd - lonStart) / this.numPoints;\n- var lon = lonStart;\n- var labelPoint = null;\n- for (var i = 0; i <= this.numPoints; ++i) {\n- var gridPoint = new OpenLayers.Geometry.Point(lon, lat);\n- gridPoint.transform(llProj, mapProj);\n- pointList.push(gridPoint);\n- lon += lonDelta;\n- if (gridPoint.x < mapBounds.right) {\n- labelPoint = gridPoint;\n- }\n- }\n- if (this.labelled) {\n- //keep track of when this grid line crosses the map bounds to set\n- //the label position\n- //labels along the right, 30 pixel offset left into the map\n- //TODO add option for labels on left\n- var labelPos = new OpenLayers.Geometry.Point(mapBounds.right, labelPoint.y);\n- var labelAttrs = {\n- value: lat,\n- label: this.labelled ? OpenLayers.Util.getFormattedLonLat(lat, \"lat\", this.labelFormat) : \"\",\n- labelAlign: \"rb\",\n- xOffset: -2,\n- yOffset: 2\n- };\n- this.gratLayer.addFeatures(new OpenLayers.Feature.Vector(labelPos, labelAttrs));\n- }\n- var geom = new OpenLayers.Geometry.LineString(pointList);\n- lines.push(new OpenLayers.Feature.Vector(geom));\n- }\n- this.gratLayer.addFeatures(lines);\n+ /*\n+ * Method: moveZoomBar\n+ * Change the location of the slider to match the current zoom level.\n+ */\n+ moveZoomBar: function() {\n+ var newTop =\n+ ((this.map.getNumZoomLevels() - 1) - this.map.getZoom()) *\n+ this.zoomStopHeight + this.startTop + 1;\n+ this.slider.style.top = newTop + \"px\";\n },\n \n- CLASS_NAME: \"OpenLayers.Control.Graticule\"\n+ CLASS_NAME: \"OpenLayers.Control.PanZoomBar\"\n });\n-\n /* ======================================================================\n OpenLayers/Layer/Vector/RootContainer.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n@@ -55677,10744 +48189,11219 @@\n this.activate();\n }\n },\n \n CLASS_NAME: \"OpenLayers.Control.SelectFeature\"\n });\n /* ======================================================================\n- OpenLayers/Control/KeyboardDefaults.js\n+ OpenLayers/Handler/Pinch.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Control.js\n- * @requires OpenLayers/Handler/Keyboard.js\n- * @requires OpenLayers/Events.js\n+ * @requires OpenLayers/Handler.js\n */\n \n /**\n- * Class: OpenLayers.Control.KeyboardDefaults\n- * The KeyboardDefaults control adds panning and zooming functions, controlled\n- * with the keyboard. By default arrow keys pan, +/- keys zoom & Page Up/Page\n- * Down/Home/End scroll by three quarters of a page.\n- * \n- * This control has no visible appearance.\n+ * Class: OpenLayers.Handler.Pinch\n+ * The pinch handler is used to deal with sequences of browser events related\n+ * to pinch gestures. The handler is used by controls that want to know\n+ * when a pinch sequence begins, when a pinch is happening, and when it has\n+ * finished.\n+ *\n+ * Controls that use the pinch handler typically construct it with callbacks\n+ * for 'start', 'move', and 'done'. Callbacks for these keys are\n+ * called when the pinch begins, with each change, and when the pinch is\n+ * done.\n+ *\n+ * Create a new pinch handler with the constructor.\n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Handler.Pinch = OpenLayers.Class(OpenLayers.Handler, {\n \n /**\n- * APIProperty: autoActivate\n- * {Boolean} Activate the control when it is added to a map. Default is\n- * true.\n+ * Property: started\n+ * {Boolean} When a touchstart event is received, we want to record it,\n+ * but not set 'pinching' until the touchmove get started after\n+ * starting.\n */\n- autoActivate: true,\n+ started: false,\n \n /**\n- * APIProperty: slideFactor\n- * Pixels to slide by.\n+ * Property: stopDown\n+ * {Boolean} Stop propagation of touchstart events from getting to\n+ * listeners on the same element. Default is false.\n */\n- slideFactor: 75,\n+ stopDown: false,\n \n /**\n- * APIProperty: observeElement\n- * {DOMelement|String} The DOM element to handle keys for. You\n- * can use the map div here, to have the navigation keys\n- * work when the map div has the focus. If undefined the\n- * document is used.\n+ * Property: pinching\n+ * {Boolean}\n */\n- observeElement: null,\n+ pinching: false,\n \n /**\n- * Constructor: OpenLayers.Control.KeyboardDefaults\n+ * Property: last\n+ * {Object} Object that store informations related to pinch last touch.\n */\n+ last: null,\n \n /**\n- * Method: draw\n- * Create handler.\n+ * Property: start\n+ * {Object} Object that store informations related to pinch touchstart.\n */\n- draw: function() {\n- var observeElement = this.observeElement || document;\n- this.handler = new OpenLayers.Handler.Keyboard(this, {\n- \"keydown\": this.defaultKeyPress\n- }, {\n- observeElement: observeElement\n- });\n- },\n+ start: null,\n \n /**\n- * Method: defaultKeyPress\n- * When handling the key event, we only use evt.keyCode. This holds \n- * some drawbacks, though we get around them below. When interpretting\n- * the keycodes below (including the comments associated with them),\n- * consult the URL below. For instance, the Safari browser returns\n- * \"IE keycodes\", and so is supported by any keycode labeled \"IE\".\n- * \n- * Very informative URL:\n- * http://unixpapa.com/js/key.html\n+ * Constructor: OpenLayers.Handler.Pinch\n+ * Returns OpenLayers.Handler.Pinch\n *\n * Parameters:\n- * evt - {Event} \n+ * control - {} The control that is making use of\n+ * this handler. If a handler is being used without a control, the\n+ * handlers setMap method must be overridden to deal properly with\n+ * the map.\n+ * callbacks - {Object} An object containing functions to be called when\n+ * the pinch operation start, change, or is finished. The callbacks\n+ * should expect to receive an object argument, which contains\n+ * information about scale, distance, and position of touch points.\n+ * options - {Object}\n */\n- defaultKeyPress: function(evt) {\n- var size, handled = true;\n \n- var target = OpenLayers.Event.element(evt);\n- if (target &&\n- (target.tagName == 'INPUT' ||\n- target.tagName == 'TEXTAREA' ||\n- target.tagName == 'SELECT')) {\n- return;\n+ /**\n+ * Method: touchstart\n+ * Handle touchstart events\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n+ */\n+ touchstart: function(evt) {\n+ var propagate = true;\n+ this.pinching = false;\n+ if (OpenLayers.Event.isMultiTouch(evt)) {\n+ this.started = true;\n+ this.last = this.start = {\n+ distance: this.getDistance(evt.touches),\n+ delta: 0,\n+ scale: 1\n+ };\n+ this.callback(\"start\", [evt, this.start]);\n+ propagate = !this.stopDown;\n+ } else if (this.started) {\n+ // Some webkit versions send fake single-touch events during\n+ // multitouch, which cause the drag handler to trigger\n+ return false;\n+ } else {\n+ this.started = false;\n+ this.start = null;\n+ this.last = null;\n }\n+ // prevent document dragging\n+ OpenLayers.Event.preventDefault(evt);\n+ return propagate;\n+ },\n \n- switch (evt.keyCode) {\n- case OpenLayers.Event.KEY_LEFT:\n- this.map.pan(-this.slideFactor, 0);\n- break;\n- case OpenLayers.Event.KEY_RIGHT:\n- this.map.pan(this.slideFactor, 0);\n- break;\n- case OpenLayers.Event.KEY_UP:\n- this.map.pan(0, -this.slideFactor);\n- break;\n- case OpenLayers.Event.KEY_DOWN:\n- this.map.pan(0, this.slideFactor);\n- break;\n+ /**\n+ * Method: touchmove\n+ * Handle touchmove events\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n+ */\n+ touchmove: function(evt) {\n+ if (this.started && OpenLayers.Event.isMultiTouch(evt)) {\n+ this.pinching = true;\n+ var current = this.getPinchData(evt);\n+ this.callback(\"move\", [evt, current]);\n+ this.last = current;\n+ // prevent document dragging\n+ OpenLayers.Event.stop(evt);\n+ } else if (this.started) {\n+ // Some webkit versions send fake single-touch events during\n+ // multitouch, which cause the drag handler to trigger\n+ return false;\n+ }\n+ return true;\n+ },\n \n- case 33: // Page Up. Same in all browsers.\n- size = this.map.getSize();\n- this.map.pan(0, -0.75 * size.h);\n- break;\n- case 34: // Page Down. Same in all browsers.\n- size = this.map.getSize();\n- this.map.pan(0, 0.75 * size.h);\n- break;\n- case 35: // End. Same in all browsers.\n- size = this.map.getSize();\n- this.map.pan(0.75 * size.w, 0);\n- break;\n- case 36: // Home. Same in all browsers.\n- size = this.map.getSize();\n- this.map.pan(-0.75 * size.w, 0);\n- break;\n+ /**\n+ * Method: touchend\n+ * Handle touchend events\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n+ */\n+ touchend: function(evt) {\n+ if (this.started && !OpenLayers.Event.isMultiTouch(evt)) {\n+ this.started = false;\n+ this.pinching = false;\n+ this.callback(\"done\", [evt, this.start, this.last]);\n+ this.start = null;\n+ this.last = null;\n+ return false;\n+ }\n+ return true;\n+ },\n \n- case 43: // +/= (ASCII), keypad + (ASCII, Opera)\n- case 61: // +/= (Mozilla, Opera, some ASCII)\n- case 187: // +/= (IE)\n- case 107: // keypad + (IE, Mozilla)\n- this.map.zoomIn();\n- break;\n- case 45: // -/_ (ASCII, Opera), keypad - (ASCII, Opera)\n- case 109: // -/_ (Mozilla), keypad - (Mozilla, IE)\n- case 189: // -/_ (IE)\n- case 95: // -/_ (some ASCII)\n- this.map.zoomOut();\n- break;\n- default:\n- handled = false;\n+ /**\n+ * Method: activate\n+ * Activate the handler.\n+ *\n+ * Returns:\n+ * {Boolean} The handler was successfully activated.\n+ */\n+ activate: function() {\n+ var activated = false;\n+ if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n+ this.pinching = false;\n+ activated = true;\n }\n- if (handled) {\n- // prevent browser default not to move the page\n- // when moving the page with the keyboard\n- OpenLayers.Event.stop(evt);\n+ return activated;\n+ },\n+\n+ /**\n+ * Method: deactivate\n+ * Deactivate the handler.\n+ *\n+ * Returns:\n+ * {Boolean} The handler was successfully deactivated.\n+ */\n+ deactivate: function() {\n+ var deactivated = false;\n+ if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n+ this.started = false;\n+ this.pinching = false;\n+ this.start = null;\n+ this.last = null;\n+ deactivated = true;\n }\n+ return deactivated;\n },\n \n- CLASS_NAME: \"OpenLayers.Control.KeyboardDefaults\"\n+ /**\n+ * Method: getDistance\n+ * Get the distance in pixels between two touches.\n+ *\n+ * Parameters:\n+ * touches - {Array(Object)}\n+ *\n+ * Returns:\n+ * {Number} The distance in pixels.\n+ */\n+ getDistance: function(touches) {\n+ var t0 = touches[0];\n+ var t1 = touches[1];\n+ return Math.sqrt(\n+ Math.pow(t0.olClientX - t1.olClientX, 2) +\n+ Math.pow(t0.olClientY - t1.olClientY, 2)\n+ );\n+ },\n+\n+\n+ /**\n+ * Method: getPinchData\n+ * Get informations about the pinch event.\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ *\n+ * Returns:\n+ * {Object} Object that contains data about the current pinch.\n+ */\n+ getPinchData: function(evt) {\n+ var distance = this.getDistance(evt.touches);\n+ var scale = distance / this.start.distance;\n+ return {\n+ distance: distance,\n+ delta: this.last.distance - distance,\n+ scale: scale\n+ };\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Handler.Pinch\"\n });\n+\n /* ======================================================================\n- OpenLayers/Control/ScaleLine.js\n+ OpenLayers/Control/PinchZoom.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Handler/Pinch.js\n */\n \n /**\n- * Class: OpenLayers.Control.ScaleLine\n- * The ScaleLine displays a small line indicator representing the current \n- * map scale on the map. By default it is drawn in the lower left corner of\n- * the map.\n- * \n- * Inherits from:\n+ * Class: OpenLayers.Control.PinchZoom\n+ *\n+ * Inherits:\n * - \n- * \n- * Is a very close copy of:\n- * - \n */\n-OpenLayers.Control.ScaleLine = OpenLayers.Class(OpenLayers.Control, {\n-\n- /**\n- * Property: maxWidth\n- * {Integer} Maximum width of the scale line in pixels. Default is 100.\n- */\n- maxWidth: 100,\n-\n- /**\n- * Property: topOutUnits\n- * {String} Units for zoomed out on top bar. Default is km.\n- */\n- topOutUnits: \"km\",\n+OpenLayers.Control.PinchZoom = OpenLayers.Class(OpenLayers.Control, {\n \n- /**\n- * Property: topInUnits\n- * {String} Units for zoomed in on top bar. Default is m.\n+ /** \n+ * Property: type\n+ * {OpenLayers.Control.TYPES}\n */\n- topInUnits: \"m\",\n+ type: OpenLayers.Control.TYPE_TOOL,\n \n /**\n- * Property: bottomOutUnits\n- * {String} Units for zoomed out on bottom bar. Default is mi.\n+ * Property: pinchOrigin\n+ * {Object} Cached object representing the pinch start (in pixels).\n */\n- bottomOutUnits: \"mi\",\n+ pinchOrigin: null,\n \n /**\n- * Property: bottomInUnits\n- * {String} Units for zoomed in on bottom bar. Default is ft.\n+ * Property: currentCenter\n+ * {Object} Cached object representing the latest pinch center (in pixels).\n */\n- bottomInUnits: \"ft\",\n+ currentCenter: null,\n \n /**\n- * Property: eTop\n- * {DOMElement}\n+ * APIProperty: autoActivate\n+ * {Boolean} Activate the control when it is added to a map. Default is\n+ * true.\n */\n- eTop: null,\n+ autoActivate: true,\n \n /**\n- * Property: eBottom\n- * {DOMElement}\n+ * APIProperty: preserveCenter\n+ * {Boolean} Set this to true if you don't want the map center to change\n+ * while pinching. For example you may want to set preserveCenter to\n+ * true when the user location is being watched and you want to preserve\n+ * the user location at the center of the map even if he zooms in or\n+ * out using pinch. This property's value can be changed any time on an\n+ * existing instance. Default is false.\n */\n- eBottom: null,\n+ preserveCenter: false,\n \n /**\n- * APIProperty: geodesic\n- * {Boolean} Use geodesic measurement. Default is false. The recommended\n- * setting for maps in EPSG:4326 is false, and true EPSG:900913. If set to\n- * true, the scale will be calculated based on the horizontal size of the\n- * pixel in the center of the map viewport.\n+ * APIProperty: handlerOptions\n+ * {Object} Used to set non-default properties on the pinch handler\n */\n- geodesic: false,\n \n /**\n- * Constructor: OpenLayers.Control.ScaleLine\n- * Create a new scale line control.\n- * \n+ * Constructor: OpenLayers.Control.PinchZoom\n+ * Create a control for zooming with pinch gestures. This works on devices\n+ * with multi-touch support.\n+ *\n * Parameters:\n- * options - {Object} An optional object whose properties will be used\n- * to extend the control.\n+ * options - {Object} An optional object whose properties will be set on\n+ * the control\n */\n+ initialize: function(options) {\n+ OpenLayers.Control.prototype.initialize.apply(this, arguments);\n+ this.handler = new OpenLayers.Handler.Pinch(this, {\n+ start: this.pinchStart,\n+ move: this.pinchMove,\n+ done: this.pinchDone\n+ }, this.handlerOptions);\n+ },\n \n /**\n- * Method: draw\n- * \n- * Returns:\n- * {DOMElement}\n+ * Method: pinchStart\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ * pinchData - {Object} pinch data object related to the current touchmove\n+ * of the pinch gesture. This give us the current scale of the pinch.\n */\n- draw: function() {\n- OpenLayers.Control.prototype.draw.apply(this, arguments);\n- if (!this.eTop) {\n- // stick in the top bar\n- this.eTop = document.createElement(\"div\");\n- this.eTop.className = this.displayClass + \"Top\";\n- var theLen = this.topInUnits.length;\n- this.div.appendChild(this.eTop);\n- if ((this.topOutUnits == \"\") || (this.topInUnits == \"\")) {\n- this.eTop.style.visibility = \"hidden\";\n- } else {\n- this.eTop.style.visibility = \"visible\";\n- }\n-\n- // and the bottom bar\n- this.eBottom = document.createElement(\"div\");\n- this.eBottom.className = this.displayClass + \"Bottom\";\n- this.div.appendChild(this.eBottom);\n- if ((this.bottomOutUnits == \"\") || (this.bottomInUnits == \"\")) {\n- this.eBottom.style.visibility = \"hidden\";\n- } else {\n- this.eBottom.style.visibility = \"visible\";\n- }\n- }\n- this.map.events.register('moveend', this, this.update);\n- this.update();\n- return this.div;\n+ pinchStart: function(evt, pinchData) {\n+ var xy = (this.preserveCenter) ?\n+ this.map.getPixelFromLonLat(this.map.getCenter()) : evt.xy;\n+ this.pinchOrigin = xy;\n+ this.currentCenter = xy;\n },\n \n- /** \n- * Method: getBarLen\n- * Given a number, round it down to the nearest 1,2,5 times a power of 10.\n- * That seems a fairly useful set of number groups to use.\n- * \n+ /**\n+ * Method: pinchMove\n+ *\n * Parameters:\n- * maxLen - {float} the number we're rounding down from\n- * \n- * Returns:\n- * {Float} the rounded number (less than or equal to maxLen)\n+ * evt - {Event}\n+ * pinchData - {Object} pinch data object related to the current touchmove\n+ * of the pinch gesture. This give us the current scale of the pinch.\n */\n- getBarLen: function(maxLen) {\n- // nearest power of 10 lower than maxLen\n- var digits = parseInt(Math.log(maxLen) / Math.log(10));\n- var pow10 = Math.pow(10, digits);\n-\n- // ok, find first character\n- var firstChar = parseInt(maxLen / pow10);\n+ pinchMove: function(evt, pinchData) {\n+ var scale = pinchData.scale;\n+ var containerOrigin = this.map.layerContainerOriginPx;\n+ var pinchOrigin = this.pinchOrigin;\n+ var current = (this.preserveCenter) ?\n+ this.map.getPixelFromLonLat(this.map.getCenter()) : evt.xy;\n \n- // right, put it into the correct bracket\n- var barLen;\n- if (firstChar > 5) {\n- barLen = 5;\n- } else if (firstChar > 2) {\n- barLen = 2;\n- } else {\n- barLen = 1;\n- }\n+ var dx = Math.round((containerOrigin.x + current.x - pinchOrigin.x) + (scale - 1) * (containerOrigin.x - pinchOrigin.x));\n+ var dy = Math.round((containerOrigin.y + current.y - pinchOrigin.y) + (scale - 1) * (containerOrigin.y - pinchOrigin.y));\n \n- // scale it up the correct power of 10\n- return barLen * pow10;\n+ this.map.applyTransform(dx, dy, scale);\n+ this.currentCenter = current;\n },\n \n /**\n- * Method: update\n- * Update the size of the bars, and the labels they contain.\n+ * Method: pinchDone\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ * start - {Object} pinch data object related to the touchstart event that\n+ * started the pinch gesture.\n+ * last - {Object} pinch data object related to the last touchmove event\n+ * of the pinch gesture. This give us the final scale of the pinch.\n */\n- update: function() {\n- var res = this.map.getResolution();\n- if (!res) {\n- return;\n- }\n-\n- var curMapUnits = this.map.getUnits();\n- var inches = OpenLayers.INCHES_PER_UNIT;\n-\n- // convert maxWidth to map units\n- var maxSizeData = this.maxWidth * res * inches[curMapUnits];\n- var geodesicRatio = 1;\n- if (this.geodesic === true) {\n- var maxSizeGeodesic = (this.map.getGeodesicPixelSize().w ||\n- 0.000001) * this.maxWidth;\n- var maxSizeKilometers = maxSizeData / inches[\"km\"];\n- geodesicRatio = maxSizeGeodesic / maxSizeKilometers;\n- maxSizeData *= geodesicRatio;\n- }\n-\n- // decide whether to use large or small scale units \n- var topUnits;\n- var bottomUnits;\n- if (maxSizeData > 100000) {\n- topUnits = this.topOutUnits;\n- bottomUnits = this.bottomOutUnits;\n- } else {\n- topUnits = this.topInUnits;\n- bottomUnits = this.bottomInUnits;\n- }\n-\n- // and to map units units\n- var topMax = maxSizeData / inches[topUnits];\n- var bottomMax = maxSizeData / inches[bottomUnits];\n-\n- // now trim this down to useful block length\n- var topRounded = this.getBarLen(topMax);\n- var bottomRounded = this.getBarLen(bottomMax);\n-\n- // and back to display units\n- topMax = topRounded / inches[curMapUnits] * inches[topUnits];\n- bottomMax = bottomRounded / inches[curMapUnits] * inches[bottomUnits];\n+ pinchDone: function(evt, start, last) {\n+ this.map.applyTransform();\n+ var zoom = this.map.getZoomForResolution(this.map.getResolution() / last.scale, true);\n+ if (zoom !== this.map.getZoom() || !this.currentCenter.equals(this.pinchOrigin)) {\n+ var resolution = this.map.getResolutionForZoom(zoom);\n \n- // and to pixel units\n- var topPx = topMax / res / geodesicRatio;\n- var bottomPx = bottomMax / res / geodesicRatio;\n+ var location = this.map.getLonLatFromPixel(this.pinchOrigin);\n+ var zoomPixel = this.currentCenter;\n+ var size = this.map.getSize();\n \n- // now set the pixel widths\n- // and the values inside them\n+ location.lon += resolution * ((size.w / 2) - zoomPixel.x);\n+ location.lat -= resolution * ((size.h / 2) - zoomPixel.y);\n \n- if (this.eBottom.style.visibility == \"visible\") {\n- this.eBottom.style.width = Math.round(bottomPx) + \"px\";\n- this.eBottom.innerHTML = bottomRounded + \" \" + bottomUnits;\n- }\n+ // Force a reflow before calling setCenter. This is to work\n+ // around an issue occuring in iOS.\n+ //\n+ // See https://github.com/openlayers/openlayers/pull/351.\n+ //\n+ // Without a reflow setting the layer container div's top left\n+ // style properties to \"0px\" - as done in Map.moveTo when zoom\n+ // is changed - won't actually correctly reposition the layer\n+ // container div.\n+ //\n+ // Also, we need to use a statement that the Google Closure\n+ // compiler won't optimize away.\n+ this.map.div.clientWidth = this.map.div.clientWidth;\n \n- if (this.eTop.style.visibility == \"visible\") {\n- this.eTop.style.width = Math.round(topPx) + \"px\";\n- this.eTop.innerHTML = topRounded + \" \" + topUnits;\n+ this.map.setCenter(location, zoom);\n }\n-\n },\n \n- CLASS_NAME: \"OpenLayers.Control.ScaleLine\"\n-});\n+ CLASS_NAME: \"OpenLayers.Control.PinchZoom\"\n \n+});\n /* ======================================================================\n- OpenLayers/Control/WMTSGetFeatureInfo.js\n+ OpenLayers/Control/TouchNavigation.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Control/DragPan.js\n+ * @requires OpenLayers/Control/PinchZoom.js\n * @requires OpenLayers/Handler/Click.js\n- * @requires OpenLayers/Handler/Hover.js\n- * @requires OpenLayers/Request.js\n- * @requires OpenLayers/Format/WMSGetFeatureInfo.js\n */\n \n /**\n- * Class: OpenLayers.Control.WMTSGetFeatureInfo\n- * The WMTSGetFeatureInfo control uses a WMTS query to get information about a \n- * point on the map. The information may be in a display-friendly format \n- * such as HTML, or a machine-friendly format such as GML, depending on the \n- * server's capabilities and the client's configuration. This control \n- * handles click or hover events, attempts to parse the results using an \n- * OpenLayers.Format, and fires a 'getfeatureinfo' event for each layer\n- * queried.\n+ * Class: OpenLayers.Control.TouchNavigation\n+ * The navigation control handles map browsing with touch events (dragging,\n+ * double-tapping, tap with two fingers, and pinch zoom). Create a new \n+ * control with the constructor.\n *\n- * Inherits from:\n+ * If you\u2019re only targeting touch enabled devices with your mapping application,\n+ * you can create a map with only a TouchNavigation control. The \n+ * control is mobile ready by default, but \n+ * you can generate a smaller build of the library by only including this\n+ * touch navigation control if you aren't concerned about mouse interaction.\n+ *\n+ * Inherits:\n * - \n */\n-OpenLayers.Control.WMTSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {\n+OpenLayers.Control.TouchNavigation = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * APIProperty: hover\n- * {Boolean} Send GetFeatureInfo requests when mouse stops moving.\n- * Default is false.\n+ * Property: dragPan\n+ * {}\n */\n- hover: false,\n+ dragPan: null,\n \n /**\n- * Property: requestEncoding\n- * {String} One of \"KVP\" or \"REST\". Only KVP encoding is supported at this \n- * time.\n+ * APIProperty: dragPanOptions\n+ * {Object} Options passed to the DragPan control.\n */\n- requestEncoding: \"KVP\",\n+ dragPanOptions: null,\n \n /**\n- * APIProperty: drillDown\n- * {Boolean} Drill down over all WMTS layers in the map. When\n- * using drillDown mode, hover is not possible. A getfeatureinfo event\n- * will be fired for each layer queried.\n+ * Property: pinchZoom\n+ * {}\n */\n- drillDown: false,\n+ pinchZoom: null,\n \n /**\n- * APIProperty: maxFeatures\n- * {Integer} Maximum number of features to return from a WMTS query. This\n- * sets the feature_count parameter on WMTS GetFeatureInfo\n- * requests.\n+ * APIProperty: pinchZoomOptions\n+ * {Object} Options passed to the PinchZoom control.\n */\n- maxFeatures: 10,\n+ pinchZoomOptions: null,\n \n- /** APIProperty: clickCallback\n- * {String} The click callback to register in the\n- * {} object created when the hover\n- * option is set to false. Default is \"click\".\n+ /**\n+ * APIProperty: clickHandlerOptions\n+ * {Object} Options passed to the Click handler.\n */\n- clickCallback: \"click\",\n+ clickHandlerOptions: null,\n \n /**\n- * Property: layers\n- * {Array()} The layers to query for feature info.\n- * If omitted, all map WMTS layers will be considered.\n+ * APIProperty: documentDrag\n+ * {Boolean} Allow panning of the map by dragging outside map viewport.\n+ * Default is false.\n */\n- layers: null,\n+ documentDrag: false,\n \n /**\n- * APIProperty: queryVisible\n- * {Boolean} Filter out hidden layers when searching the map for layers to \n- * query. Default is true.\n+ * APIProperty: autoActivate\n+ * {Boolean} Activate the control when it is added to a map. Default is\n+ * true.\n */\n- queryVisible: true,\n+ autoActivate: true,\n \n /**\n- * Property: infoFormat\n- * {String} The mimetype to request from the server\n+ * Constructor: OpenLayers.Control.TouchNavigation\n+ * Create a new navigation control\n+ *\n+ * Parameters:\n+ * options - {Object} An optional object whose properties will be set on\n+ * the control\n */\n- infoFormat: 'text/html',\n+ initialize: function(options) {\n+ this.handlers = {};\n+ OpenLayers.Control.prototype.initialize.apply(this, arguments);\n+ },\n \n /**\n- * Property: vendorParams\n- * {Object} Additional parameters that will be added to the request, for\n- * WMTS implementations that support them. This could e.g. look like\n- * (start code)\n- * {\n- * radius: 5\n- * }\n- * (end)\n+ * Method: destroy\n+ * The destroy method is used to perform any clean up before the control\n+ * is dereferenced. Typically this is where event listeners are removed\n+ * to prevent memory leaks.\n */\n- vendorParams: {},\n+ destroy: function() {\n+ this.deactivate();\n+ if (this.dragPan) {\n+ this.dragPan.destroy();\n+ }\n+ this.dragPan = null;\n+ if (this.pinchZoom) {\n+ this.pinchZoom.destroy();\n+ delete this.pinchZoom;\n+ }\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n+ },\n \n /**\n- * Property: format\n- * {} A format for parsing GetFeatureInfo responses.\n- * Default is .\n+ * Method: activate\n */\n- format: null,\n+ activate: function() {\n+ if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {\n+ this.dragPan.activate();\n+ this.handlers.click.activate();\n+ this.pinchZoom.activate();\n+ return true;\n+ }\n+ return false;\n+ },\n \n /**\n- * Property: formatOptions\n- * {Object} Optional properties to set on the format (if one is not provided\n- * in the property.\n+ * Method: deactivate\n */\n- formatOptions: null,\n+ deactivate: function() {\n+ if (OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {\n+ this.dragPan.deactivate();\n+ this.handlers.click.deactivate();\n+ this.pinchZoom.deactivate();\n+ return true;\n+ }\n+ return false;\n+ },\n \n /**\n- * APIProperty: handlerOptions\n- * {Object} Additional options for the handlers used by this control, e.g.\n- * (start code)\n- * {\n- * \"click\": {delay: 100},\n- * \"hover\": {delay: 300}\n- * }\n- * (end)\n+ * Method: draw\n */\n+ draw: function() {\n+ var clickCallbacks = {\n+ click: this.defaultClick,\n+ dblclick: this.defaultDblClick\n+ };\n+ var clickOptions = OpenLayers.Util.extend({\n+ \"double\": true,\n+ stopDouble: true,\n+ pixelTolerance: 2\n+ }, this.clickHandlerOptions);\n+ this.handlers.click = new OpenLayers.Handler.Click(\n+ this, clickCallbacks, clickOptions\n+ );\n+ this.dragPan = new OpenLayers.Control.DragPan(\n+ OpenLayers.Util.extend({\n+ map: this.map,\n+ documentDrag: this.documentDrag\n+ }, this.dragPanOptions)\n+ );\n+ this.dragPan.draw();\n+ this.pinchZoom = new OpenLayers.Control.PinchZoom(\n+ OpenLayers.Util.extend({\n+ map: this.map\n+ }, this.pinchZoomOptions)\n+ );\n+ },\n \n /**\n- * Property: handler\n- * {Object} Reference to the for this control\n+ * Method: defaultClick\n+ *\n+ * Parameters:\n+ * evt - {Event}\n */\n- handler: null,\n+ defaultClick: function(evt) {\n+ if (evt.lastTouches && evt.lastTouches.length == 2) {\n+ this.map.zoomOut();\n+ }\n+ },\n \n /**\n- * Property: hoverRequest\n- * {} contains the currently running hover request\n- * (if any).\n- */\n- hoverRequest: null,\n-\n- /** \n- * APIProperty: events\n- * {} Events instance for listeners and triggering\n- * control specific events.\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * control.events.register(type, obj, listener);\n- * (end)\n- *\n- * Supported event types (in addition to those from ):\n- * beforegetfeatureinfo - Triggered before each request is sent.\n- * The event object has an *xy* property with the position of the \n- * mouse click or hover event that triggers the request and a *layer*\n- * property referencing the layer about to be queried. If a listener\n- * returns false, the request will not be issued.\n- * getfeatureinfo - Triggered when a GetFeatureInfo response is received.\n- * The event object has a *text* property with the body of the\n- * response (String), a *features* property with an array of the\n- * parsed features, an *xy* property with the position of the mouse\n- * click or hover event that triggered the request, a *layer* property\n- * referencing the layer queried and a *request* property with the \n- * request itself. If drillDown is set to true, one event will be fired\n- * for each layer queried.\n- * exception - Triggered when a GetFeatureInfo request fails (with a \n- * status other than 200) or whenparsing fails. Listeners will receive \n- * an event with *request*, *xy*, and *layer* properties. In the case \n- * of a parsing error, the event will also contain an *error* property.\n+ * Method: defaultDblClick\n+ *\n+ * Parameters:\n+ * evt - {Event}\n */\n+ defaultDblClick: function(evt) {\n+ this.map.zoomTo(this.map.zoom + 1, evt.xy);\n+ },\n \n- /** \n- * Property: pending\n- * {Number} The number of pending requests.\n- */\n- pending: 0,\n+ CLASS_NAME: \"OpenLayers.Control.TouchNavigation\"\n+});\n+/* ======================================================================\n+ OpenLayers/Format/WMSGetFeatureInfo.js\n+ ====================================================================== */\n \n- /**\n- * Constructor: \n- *\n- * Parameters:\n- * options - {Object} \n- */\n- initialize: function(options) {\n- options = options || {};\n- options.handlerOptions = options.handlerOptions || {};\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+/**\n+ * @requires OpenLayers/Format/XML.js\n+ */\n \n- if (!this.format) {\n- this.format = new OpenLayers.Format.WMSGetFeatureInfo(\n- options.formatOptions\n- );\n- }\n+/**\n+ * Class: OpenLayers.Format.WMSGetFeatureInfo\n+ * Class to read GetFeatureInfo responses from Web Mapping Services\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Format.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Format.XML, {\n \n- if (this.drillDown === true) {\n- this.hover = false;\n- }\n+ /**\n+ * APIProperty: layerIdentifier\n+ * {String} All xml nodes containing this search criteria will populate an\n+ * internal array of layer nodes.\n+ */\n+ layerIdentifier: '_layer',\n \n- if (this.hover) {\n- this.handler = new OpenLayers.Handler.Hover(\n- this, {\n- move: this.cancelHover,\n- pause: this.getInfoForHover\n- },\n- OpenLayers.Util.extend(\n- this.handlerOptions.hover || {}, {\n- delay: 250\n- }\n- )\n- );\n- } else {\n- var callbacks = {};\n- callbacks[this.clickCallback] = this.getInfoForClick;\n- this.handler = new OpenLayers.Handler.Click(\n- this, callbacks, this.handlerOptions.click || {}\n- );\n- }\n+ /**\n+ * APIProperty: featureIdentifier\n+ * {String} All xml nodes containing this search criteria will populate an \n+ * internal array of feature nodes for each layer node found.\n+ */\n+ featureIdentifier: '_feature',\n+\n+ /**\n+ * Property: regExes\n+ * Compiled regular expressions for manipulating strings.\n+ */\n+ regExes: {\n+ trimSpace: (/^\\s*|\\s*$/g),\n+ removeSpace: (/\\s*/g),\n+ splitSpace: (/\\s+/),\n+ trimComma: (/\\s*,\\s*/g)\n },\n \n /**\n- * Method: getInfoForClick \n- * Called on click\n+ * Property: gmlFormat\n+ * {} internal GML format for parsing geometries\n+ * in msGMLOutput\n+ */\n+ gmlFormat: null,\n+\n+ /**\n+ * Constructor: OpenLayers.Format.WMSGetFeatureInfo\n+ * Create a new parser for WMS GetFeatureInfo responses\n *\n * Parameters:\n- * evt - {} \n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n */\n- getInfoForClick: function(evt) {\n- this.request(evt.xy, {});\n- },\n \n /**\n- * Method: getInfoForHover\n- * Pause callback for the hover handler\n+ * APIMethod: read\n+ * Read WMS GetFeatureInfo data from a string, and return an array of features\n *\n * Parameters:\n- * evt - {Object}\n+ * data - {String} or {DOMElement} data to read/parse.\n+ *\n+ * Returns:\n+ * {Array()} An array of features.\n */\n- getInfoForHover: function(evt) {\n- this.request(evt.xy, {\n- hover: true\n- });\n+ read: function(data) {\n+ var result;\n+ if (typeof data == \"string\") {\n+ data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n+ }\n+ var root = data.documentElement;\n+ if (root) {\n+ var scope = this;\n+ var read = this[\"read_\" + root.nodeName];\n+ if (read) {\n+ result = read.call(this, root);\n+ } else {\n+ // fall-back to GML since this is a common output format for WMS\n+ // GetFeatureInfo responses\n+ result = new OpenLayers.Format.GML((this.options ? this.options : {})).read(data);\n+ }\n+ } else {\n+ result = data;\n+ }\n+ return result;\n },\n \n+\n /**\n- * Method: cancelHover\n- * Cancel callback for the hover handler\n+ * Method: read_msGMLOutput\n+ * Parse msGMLOutput nodes.\n+ *\n+ * Parameters:\n+ * data - {DOMElement}\n+ *\n+ * Returns:\n+ * {Array}\n */\n- cancelHover: function() {\n- if (this.hoverRequest) {\n- --this.pending;\n- if (this.pending <= 0) {\n- OpenLayers.Element.removeClass(this.map.viewPortDiv, \"olCursorWait\");\n- this.pending = 0;\n+ read_msGMLOutput: function(data) {\n+ var response = [];\n+ var layerNodes = this.getSiblingNodesByTagCriteria(data,\n+ this.layerIdentifier);\n+ if (layerNodes) {\n+ for (var i = 0, len = layerNodes.length; i < len; ++i) {\n+ var node = layerNodes[i];\n+ var layerName = node.nodeName;\n+ if (node.prefix) {\n+ layerName = layerName.split(':')[1];\n+ }\n+ var layerName = layerName.replace(this.layerIdentifier, '');\n+ var featureNodes = this.getSiblingNodesByTagCriteria(node,\n+ this.featureIdentifier);\n+ if (featureNodes) {\n+ for (var j = 0; j < featureNodes.length; j++) {\n+ var featureNode = featureNodes[j];\n+ var geomInfo = this.parseGeometry(featureNode);\n+ var attributes = this.parseAttributes(featureNode);\n+ var feature = new OpenLayers.Feature.Vector(geomInfo.geometry,\n+ attributes, null);\n+ feature.bounds = geomInfo.bounds;\n+ feature.type = layerName;\n+ response.push(feature);\n+ }\n+ }\n }\n- this.hoverRequest.abort();\n- this.hoverRequest = null;\n }\n+ return response;\n },\n \n /**\n- * Method: findLayers\n- * Internal method to get the layers, independent of whether we are\n- * inspecting the map or using a client-provided array\n+ * Method: read_FeatureInfoResponse\n+ * Parse FeatureInfoResponse nodes.\n+ *\n+ * Parameters:\n+ * data - {DOMElement}\n+ *\n+ * Returns:\n+ * {Array}\n */\n- findLayers: function() {\n- var candidates = this.layers || this.map.layers;\n- var layers = [];\n- var layer;\n- for (var i = candidates.length - 1; i >= 0; --i) {\n- layer = candidates[i];\n- if (layer instanceof OpenLayers.Layer.WMTS &&\n- layer.requestEncoding === this.requestEncoding &&\n- (!this.queryVisible || layer.getVisibility())) {\n- layers.push(layer);\n- if (!this.drillDown || this.hover) {\n- break;\n+ read_FeatureInfoResponse: function(data) {\n+ var response = [];\n+ var featureNodes = this.getElementsByTagNameNS(data, '*',\n+ 'FIELDS');\n+\n+ for (var i = 0, len = featureNodes.length; i < len; i++) {\n+ var featureNode = featureNodes[i];\n+ var geom = null;\n+\n+ // attributes can be actual attributes on the FIELDS tag, \n+ // or FIELD children\n+ var attributes = {};\n+ var j;\n+ var jlen = featureNode.attributes.length;\n+ if (jlen > 0) {\n+ for (j = 0; j < jlen; j++) {\n+ var attribute = featureNode.attributes[j];\n+ attributes[attribute.nodeName] = attribute.nodeValue;\n+ }\n+ } else {\n+ var nodes = featureNode.childNodes;\n+ for (j = 0, jlen = nodes.length; j < jlen; ++j) {\n+ var node = nodes[j];\n+ if (node.nodeType != 3) {\n+ attributes[node.getAttribute(\"name\")] =\n+ node.getAttribute(\"value\");\n+ }\n }\n }\n+\n+ response.push(\n+ new OpenLayers.Feature.Vector(geom, attributes, null)\n+ );\n }\n- return layers;\n+ return response;\n },\n \n /**\n- * Method: buildRequestOptions\n- * Build an object with the relevant options for the GetFeatureInfo request.\n- *\n+ * Method: getSiblingNodesByTagCriteria\n+ * Recursively searches passed xml node and all it's descendant levels for \n+ * nodes whose tagName contains the passed search string. This returns an \n+ * array of all sibling nodes which match the criteria from the highest \n+ * hierarchial level from which a match is found.\n+ * \n * Parameters:\n- * layer - {} A WMTS layer.\n- * xy - {} The position on the map where the \n- * mouse event occurred.\n+ * node - {DOMElement} An xml node\n+ * criteria - {String} Search string which will match some part of a tagName \n+ * \n+ * Returns:\n+ * Array({DOMElement}) An array of sibling xml nodes\n */\n- buildRequestOptions: function(layer, xy) {\n- var loc = this.map.getLonLatFromPixel(xy);\n- var getTileUrl = layer.getURL(\n- new OpenLayers.Bounds(loc.lon, loc.lat, loc.lon, loc.lat)\n- );\n- var params = OpenLayers.Util.getParameters(getTileUrl);\n- var tileInfo = layer.getTileInfo(loc);\n- OpenLayers.Util.extend(params, {\n- service: \"WMTS\",\n- version: layer.version,\n- request: \"GetFeatureInfo\",\n- infoFormat: this.infoFormat,\n- i: tileInfo.i,\n- j: tileInfo.j\n- });\n- OpenLayers.Util.applyDefaults(params, this.vendorParams);\n- return {\n- url: OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url,\n- params: OpenLayers.Util.upperCaseObject(params),\n- callback: function(request) {\n- this.handleResponse(xy, request, layer);\n- },\n- scope: this\n- };\n+ getSiblingNodesByTagCriteria: function(node, criteria) {\n+ var nodes = [];\n+ var children, tagName, n, matchNodes, child;\n+ if (node && node.hasChildNodes()) {\n+ children = node.childNodes;\n+ n = children.length;\n+\n+ for (var k = 0; k < n; k++) {\n+ child = children[k];\n+ while (child && child.nodeType != 1) {\n+ child = child.nextSibling;\n+ k++;\n+ }\n+ tagName = (child ? child.nodeName : '');\n+ if (tagName.length > 0 && tagName.indexOf(criteria) > -1) {\n+ nodes.push(child);\n+ } else {\n+ matchNodes = this.getSiblingNodesByTagCriteria(\n+ child, criteria);\n+\n+ if (matchNodes.length > 0) {\n+ (nodes.length == 0) ?\n+ nodes = matchNodes: nodes.push(matchNodes);\n+ }\n+ }\n+ }\n+\n+ }\n+ return nodes;\n },\n \n /**\n- * Method: request\n- * Sends a GetFeatureInfo request to the WMTS\n- * \n+ * Method: parseAttributes\n+ *\n * Parameters:\n- * xy - {} The position on the map where the mouse event \n- * occurred.\n- * options - {Object} additional options for this method.\n+ * node - {}\n+ *\n+ * Returns:\n+ * {Object} An attributes object.\n * \n- * Valid options:\n- * - *hover* {Boolean} true if we do the request for the hover handler\n+ * Notes:\n+ * Assumes that attributes are direct child xml nodes of the passed node\n+ * and contain only a single text node. \n */\n- request: function(xy, options) {\n- options = options || {};\n- var layers = this.findLayers();\n- if (layers.length > 0) {\n- var issue, layer;\n- for (var i = 0, len = layers.length; i < len; i++) {\n- layer = layers[i];\n- issue = this.events.triggerEvent(\"beforegetfeatureinfo\", {\n- xy: xy,\n- layer: layer\n- });\n- if (issue !== false) {\n- ++this.pending;\n- var requestOptions = this.buildRequestOptions(layer, xy);\n- var request = OpenLayers.Request.GET(requestOptions);\n- if (options.hover === true) {\n- this.hoverRequest = request;\n+ parseAttributes: function(node) {\n+ var attributes = {};\n+ if (node.nodeType == 1) {\n+ var children = node.childNodes;\n+ var n = children.length;\n+ for (var i = 0; i < n; ++i) {\n+ var child = children[i];\n+ if (child.nodeType == 1) {\n+ var grandchildren = child.childNodes;\n+ var name = (child.prefix) ?\n+ child.nodeName.split(\":\")[1] : child.nodeName;\n+ if (grandchildren.length == 0) {\n+ attributes[name] = null;\n+ } else if (grandchildren.length == 1) {\n+ var grandchild = grandchildren[0];\n+ if (grandchild.nodeType == 3 ||\n+ grandchild.nodeType == 4) {\n+ var value = grandchild.nodeValue.replace(\n+ this.regExes.trimSpace, \"\");\n+ attributes[name] = value;\n+ }\n }\n }\n }\n- if (this.pending > 0) {\n- OpenLayers.Element.addClass(this.map.viewPortDiv, \"olCursorWait\");\n- }\n }\n+ return attributes;\n },\n \n /**\n- * Method: handleResponse\n- * Handler for the GetFeatureInfo response.\n- * \n+ * Method: parseGeometry\n+ * Parse the geometry and the feature bounds out of the node using \n+ * Format.GML\n+ *\n * Parameters:\n- * xy - {} The position on the map where the mouse event \n- * occurred.\n- * request - {XMLHttpRequest} The request object.\n- * layer - {} The queried layer.\n+ * node - {}\n+ *\n+ * Returns:\n+ * {Object} An object containing the geometry and the feature bounds\n */\n- handleResponse: function(xy, request, layer) {\n- --this.pending;\n- if (this.pending <= 0) {\n- OpenLayers.Element.removeClass(this.map.viewPortDiv, \"olCursorWait\");\n- this.pending = 0;\n+ parseGeometry: function(node) {\n+ // we need to use the old Format.GML parser since we do not know the \n+ // geometry name\n+ if (!this.gmlFormat) {\n+ this.gmlFormat = new OpenLayers.Format.GML();\n }\n- if (request.status && (request.status < 200 || request.status >= 300)) {\n- this.events.triggerEvent(\"exception\", {\n- xy: xy,\n- request: request,\n- layer: layer\n- });\n- } else {\n- var doc = request.responseXML;\n- if (!doc || !doc.documentElement) {\n- doc = request.responseText;\n- }\n- var features, except;\n- try {\n- features = this.format.read(doc);\n- } catch (error) {\n- except = true;\n- this.events.triggerEvent(\"exception\", {\n- xy: xy,\n- request: request,\n- error: error,\n- layer: layer\n- });\n- }\n- if (!except) {\n- this.events.triggerEvent(\"getfeatureinfo\", {\n- text: request.responseText,\n- features: features,\n- request: request,\n- xy: xy,\n- layer: layer\n- });\n- }\n+ var feature = this.gmlFormat.parseFeature(node);\n+ var geometry, bounds = null;\n+ if (feature) {\n+ geometry = feature.geometry && feature.geometry.clone();\n+ bounds = feature.bounds && feature.bounds.clone();\n+ feature.destroy();\n }\n+ return {\n+ geometry: geometry,\n+ bounds: bounds\n+ };\n },\n \n- CLASS_NAME: \"OpenLayers.Control.WMTSGetFeatureInfo\"\n+ CLASS_NAME: \"OpenLayers.Format.WMSGetFeatureInfo\"\n+\n });\n /* ======================================================================\n- OpenLayers/Control/GetFeature.js\n+ OpenLayers/Control/WMSGetFeatureInfo.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n * @requires OpenLayers/Control.js\n * @requires OpenLayers/Handler/Click.js\n- * @requires OpenLayers/Handler/Box.js\n * @requires OpenLayers/Handler/Hover.js\n- * @requires OpenLayers/Filter/Spatial.js\n+ * @requires OpenLayers/Request.js\n+ * @requires OpenLayers/Format/WMSGetFeatureInfo.js\n */\n \n /**\n- * Class: OpenLayers.Control.GetFeature\n- * Gets vector features for locations underneath the mouse cursor. Can be\n- * configured to act on click, hover or dragged boxes. Uses an\n- * that supports spatial filters to retrieve\n- * features from a server and fires events that notify applications of the\n- * selected features. \n+ * Class: OpenLayers.Control.WMSGetFeatureInfo\n+ * The WMSGetFeatureInfo control uses a WMS query to get information about a point on the map. The\n+ * information may be in a display-friendly format such as HTML, or a machine-friendly format such\n+ * as GML, depending on the server's capabilities and the client's configuration. This control\n+ * handles click or hover events, attempts to parse the results using an OpenLayers.Format, and\n+ * fires a 'getfeatureinfo' event with the click position, the raw body of the response, and an\n+ * array of features if it successfully read the response.\n *\n * Inherits from:\n * - \n */\n-OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {\n-\n- /**\n- * APIProperty: protocol\n- * {} Required. The protocol used for fetching\n- * features.\n- */\n- protocol: null,\n-\n- /**\n- * APIProperty: multipleKey\n- * {String} An event modifier ('altKey' or 'shiftKey') that temporarily sets\n- * the property to true. Default is null.\n- */\n- multipleKey: null,\n+OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * APIProperty: toggleKey\n- * {String} An event modifier ('altKey' or 'shiftKey') that temporarily sets\n- * the property to true. Default is null.\n+ * APIProperty: hover\n+ * {Boolean} Send GetFeatureInfo requests when mouse stops moving.\n+ * Default is false.\n */\n- toggleKey: null,\n+ hover: false,\n \n /**\n- * Property: modifiers\n- * {Object} The event modifiers to use, according to the current event\n- * being handled by this control's handlers\n+ * APIProperty: drillDown\n+ * {Boolean} Drill down over all WMS layers in the map. When\n+ * using drillDown mode, hover is not possible, and an infoFormat that\n+ * returns parseable features is required. Default is false.\n */\n- modifiers: null,\n+ drillDown: false,\n \n /**\n- * APIProperty: multiple\n- * {Boolean} Allow selection of multiple geometries. Default is false.\n+ * APIProperty: maxFeatures\n+ * {Integer} Maximum number of features to return from a WMS query. This\n+ * sets the feature_count parameter on WMS GetFeatureInfo\n+ * requests.\n */\n- multiple: false,\n+ maxFeatures: 10,\n \n /**\n- * APIProperty: click\n- * {Boolean} Use a click handler for selecting/unselecting features. If\n- * both and are set to true, the click handler takes\n- * precedence over the box handler if a box with zero extent was\n- * selected. Default is true.\n+ * APIProperty: clickCallback\n+ * {String} The click callback to register in the\n+ * {} object created when the hover\n+ * option is set to false. Default is \"click\".\n */\n- click: true,\n+ clickCallback: \"click\",\n \n /**\n- * APIProperty: single\n- * {Boolean} Tells whether select by click should select a single\n- * feature. If set to false, all matching features are selected.\n- * If set to true, only the best matching feature is selected.\n- * This option has an effect only of the option is set\n- * to true. Default is true.\n+ * APIProperty: output\n+ * {String} Either \"features\" or \"object\". When triggering a getfeatureinfo\n+ * request should we pass on an array of features or an object with with\n+ * a \"features\" property and other properties (such as the url of the\n+ * WMS). Default is \"features\".\n */\n- single: true,\n+ output: \"features\",\n \n /**\n- * APIProperty: clickout\n- * {Boolean} Unselect features when clicking outside any feature.\n- * Applies only if is true. Default is true.\n+ * APIProperty: layers\n+ * {Array()} The layers to query for feature info.\n+ * If omitted, all map WMS layers with a url that matches this or\n+ * will be considered.\n */\n- clickout: true,\n+ layers: null,\n \n /**\n- * APIProperty: toggle\n- * {Boolean} Unselect a selected feature on click. Applies only if\n- * is true. Default is false.\n+ * APIProperty: queryVisible\n+ * {Boolean} If true, filter out hidden layers when searching the map for\n+ * layers to query. Default is false.\n */\n- toggle: false,\n+ queryVisible: false,\n \n /**\n- * APIProperty: clickTolerance\n- * {Integer} Tolerance for the filter query in pixels. This has the\n- * same effect as the tolerance parameter on WMS GetFeatureInfo\n- * requests. Will be ignored for box selections. Applies only if\n- * or is true. Default is 5. Note that this not\n- * only affects requests on click, but also on hover.\n+ * APIProperty: url\n+ * {String} The URL of the WMS service to use. If not provided, the url\n+ * of the first eligible layer will be used.\n */\n- clickTolerance: 5,\n+ url: null,\n \n /**\n- * APIProperty: hover\n- * {Boolean} Send feature requests on mouse moves. Default is false.\n+ * APIProperty: layerUrls\n+ * {Array(String)} Optional list of urls for layers that should be queried.\n+ * This can be used when the layer url differs from the url used for\n+ * making GetFeatureInfo requests (in the case of a layer using cached\n+ * tiles).\n */\n- hover: false,\n+ layerUrls: null,\n \n /**\n- * APIProperty: box\n- * {Boolean} Allow feature selection by drawing a box. If set to\n- * true set to false to disable the click handler and\n- * rely on the box handler only, even for \"zero extent\" boxes.\n- * See the description of the option for additional\n- * information. Default is false.\n+ * APIProperty: infoFormat\n+ * {String} The mimetype to request from the server. If you are using\n+ * drillDown mode and have multiple servers that do not share a common\n+ * infoFormat, you can override the control's infoFormat by providing an\n+ * INFO_FORMAT parameter in your instance(s).\n */\n- box: false,\n+ infoFormat: 'text/html',\n \n /**\n- * APIProperty: maxFeatures\n- * {Integer} Maximum number of features to return from a query in single mode\n- * if supported by the . This set of features is then used to\n- * determine the best match client-side. Default is 10.\n+ * APIProperty: vendorParams\n+ * {Object} Additional parameters that will be added to the request, for\n+ * WMS implementations that support them. This could e.g. look like\n+ * (start code)\n+ * {\n+ * radius: 5\n+ * }\n+ * (end)\n */\n- maxFeatures: 10,\n+ vendorParams: {},\n \n /**\n- * Property: features\n- * {Object} Hash of {}, keyed by fid, holding\n- * the currently selected features\n+ * APIProperty: format\n+ * {} A format for parsing GetFeatureInfo responses.\n+ * Default is .\n */\n- features: null,\n+ format: null,\n \n /**\n- * Proeprty: hoverFeature\n- * {} The feature currently selected by the\n- * hover handler\n+ * APIProperty: formatOptions\n+ * {Object} Optional properties to set on the format (if one is not provided\n+ * in the property.\n */\n- hoverFeature: null,\n+ formatOptions: null,\n \n /**\n * APIProperty: handlerOptions\n- * {Object} Additional options for the handlers used by this control. This\n- * is a hash with the keys \"click\", \"box\" and \"hover\".\n+ * {Object} Additional options for the handlers used by this control, e.g.\n+ * (start code)\n+ * {\n+ * \"click\": {delay: 100},\n+ * \"hover\": {delay: 300}\n+ * }\n+ * (end)\n */\n \n /**\n- * Property: handlers\n- * {Object} Object with references to multiple \n- * instances.\n+ * Property: handler\n+ * {Object} Reference to the for this control\n */\n- handlers: null,\n+ handler: null,\n \n /**\n- * Property: hoverResponse\n- * {} The response object associated with\n- * the currently running hover request (if any).\n+ * Property: hoverRequest\n+ * {} contains the currently running hover request\n+ * (if any).\n */\n- hoverResponse: null,\n+ hoverRequest: null,\n \n /**\n- * Property: filterType\n- * {} The type of filter to use when sending off a request. \n- * Possible values: \n- * OpenLayers.Filter.Spatial.\n- * Defaults to: OpenLayers.Filter.Spatial.BBOX\n- */\n- filterType: OpenLayers.Filter.Spatial.BBOX,\n-\n- /** \n * APIProperty: events\n * {} Events instance for listeners and triggering\n * control specific events.\n *\n * Register a listener for a particular event with the following syntax:\n * (code)\n * control.events.register(type, obj, listener);\n * (end)\n *\n * Supported event types (in addition to those from ):\n- * beforefeatureselected - Triggered when is true before a\n- * feature is selected. The event object has a feature property with\n- * the feature about to select\n- * featureselected - Triggered when is true and a feature is\n- * selected. The event object has a feature property with the\n- * selected feature\n- * beforefeaturesselected - Triggered when is true before a\n- * set of features is selected. The event object is an array of\n- * feature properties with the features about to be selected. \n- * Return false after receiving this event to discontinue processing\n- * of all featureselected events and the featuresselected event.\n- * featuresselected - Triggered when is true and a set of\n- * features is selected. The event object is an array of feature\n- * properties of the selected features\n- * featureunselected - Triggered when is true and a feature is\n- * unselected. The event object has a feature property with the\n- * unselected feature\n- * clickout - Triggered when when is true and no feature was\n- * selected.\n- * hoverfeature - Triggered when is true and the mouse has\n- * stopped over a feature\n- * outfeature - Triggered when is true and the mouse moves\n- * moved away from a hover-selected feature\n+ * beforegetfeatureinfo - Triggered before the request is sent.\n+ * The event object has an *xy* property with the position of the\n+ * mouse click or hover event that triggers the request.\n+ * nogetfeatureinfo - no queryable layers were found.\n+ * getfeatureinfo - Triggered when a GetFeatureInfo response is received.\n+ * The event object has a *text* property with the body of the\n+ * response (String), a *features* property with an array of the\n+ * parsed features, an *xy* property with the position of the mouse\n+ * click or hover event that triggered the request, and a *request*\n+ * property with the request itself. If drillDown is set to true and\n+ * multiple requests were issued to collect feature info from all\n+ * layers, *text* and *request* will only contain the response body\n+ * and request object of the last request.\n */\n \n /**\n- * Constructor: OpenLayers.Control.GetFeature\n- * Create a new control for fetching remote features.\n+ * Constructor: \n *\n * Parameters:\n- * options - {Object} A configuration object which at least has to contain\n- * a property (if not, it has to be set before a request is\n- * made)\n+ * options - {Object}\n */\n initialize: function(options) {\n+ options = options || {};\n options.handlerOptions = options.handlerOptions || {};\n \n OpenLayers.Control.prototype.initialize.apply(this, [options]);\n \n- this.features = {};\n-\n- this.handlers = {};\n-\n- if (this.click) {\n- this.handlers.click = new OpenLayers.Handler.Click(this, {\n- click: this.selectClick\n- }, this.handlerOptions.click || {});\n+ if (!this.format) {\n+ this.format = new OpenLayers.Format.WMSGetFeatureInfo(\n+ options.formatOptions\n+ );\n }\n \n- if (this.box) {\n- this.handlers.box = new OpenLayers.Handler.Box(\n- this, {\n- done: this.selectBox\n- },\n- OpenLayers.Util.extend(this.handlerOptions.box, {\n- boxDivClassName: \"olHandlerBoxSelectFeature\"\n- })\n- );\n+ if (this.drillDown === true) {\n+ this.hover = false;\n }\n \n if (this.hover) {\n- this.handlers.hover = new OpenLayers.Handler.Hover(\n+ this.handler = new OpenLayers.Handler.Hover(\n this, {\n 'move': this.cancelHover,\n- 'pause': this.selectHover\n+ 'pause': this.getInfoForHover\n },\n- OpenLayers.Util.extend(this.handlerOptions.hover, {\n- 'delay': 250,\n- 'pixelTolerance': 2\n- })\n- );\n- }\n- },\n-\n- /**\n- * Method: activate\n- * Activates the control.\n- * \n- * Returns:\n- * {Boolean} The control was effectively activated.\n- */\n- activate: function() {\n- if (!this.active) {\n- for (var i in this.handlers) {\n- this.handlers[i].activate();\n- }\n- }\n- return OpenLayers.Control.prototype.activate.apply(\n- this, arguments\n- );\n- },\n-\n- /**\n- * Method: deactivate\n- * Deactivates the control.\n- * \n- * Returns:\n- * {Boolean} The control was effectively deactivated.\n- */\n- deactivate: function() {\n- if (this.active) {\n- for (var i in this.handlers) {\n- this.handlers[i].deactivate();\n- }\n+ OpenLayers.Util.extend(this.handlerOptions.hover || {}, {\n+ 'delay': 250\n+ }));\n+ } else {\n+ var callbacks = {};\n+ callbacks[this.clickCallback] = this.getInfoForClick;\n+ this.handler = new OpenLayers.Handler.Click(\n+ this, callbacks, this.handlerOptions.click || {});\n }\n- return OpenLayers.Control.prototype.deactivate.apply(\n- this, arguments\n- );\n },\n \n /**\n- * Method: selectClick\n+ * Method: getInfoForClick\n * Called on click\n *\n * Parameters:\n- * evt - {} \n+ * evt - {}\n */\n- selectClick: function(evt) {\n- var bounds = this.pixelToBounds(evt.xy);\n-\n- this.setModifiers(evt);\n- this.request(bounds, {\n- single: this.single\n+ getInfoForClick: function(evt) {\n+ this.events.triggerEvent(\"beforegetfeatureinfo\", {\n+ xy: evt.xy\n });\n+ // Set the cursor to \"wait\" to tell the user we're working on their\n+ // click.\n+ OpenLayers.Element.addClass(this.map.viewPortDiv, \"olCursorWait\");\n+ this.request(evt.xy, {});\n },\n \n /**\n- * Method: selectBox\n- * Callback from the handlers.box set up when selection is on\n- *\n- * Parameters:\n- * position - {|Object} An OpenLayers.Bounds or\n- * an object with a 'left', 'bottom', 'right' and 'top' properties.\n- */\n- selectBox: function(position) {\n- var bounds;\n- if (position instanceof OpenLayers.Bounds) {\n- var minXY = this.map.getLonLatFromPixel({\n- x: position.left,\n- y: position.bottom\n- });\n- var maxXY = this.map.getLonLatFromPixel({\n- x: position.right,\n- y: position.top\n- });\n- bounds = new OpenLayers.Bounds(\n- minXY.lon, minXY.lat, maxXY.lon, maxXY.lat\n- );\n-\n- } else {\n- if (this.click) {\n- // box without extent - let the click handler take care of it\n- return;\n- }\n- bounds = this.pixelToBounds(position);\n- }\n- this.setModifiers(this.handlers.box.dragHandler.evt);\n- this.request(bounds);\n- },\n-\n- /**\n- * Method: selectHover\n- * Callback from the handlers.hover set up when selection is on\n+ * Method: getInfoForHover\n+ * Pause callback for the hover handler\n *\n * Parameters:\n- * evt - {Object} event object with an xy property\n+ * evt - {Object}\n */\n- selectHover: function(evt) {\n- var bounds = this.pixelToBounds(evt.xy);\n- this.request(bounds, {\n- single: true,\n+ getInfoForHover: function(evt) {\n+ this.events.triggerEvent(\"beforegetfeatureinfo\", {\n+ xy: evt.xy\n+ });\n+ this.request(evt.xy, {\n hover: true\n });\n },\n \n /**\n * Method: cancelHover\n- * Callback from the handlers.hover set up when selection is on\n+ * Cancel callback for the hover handler\n */\n cancelHover: function() {\n- if (this.hoverResponse) {\n- this.protocol.abort(this.hoverResponse);\n- this.hoverResponse = null;\n-\n- OpenLayers.Element.removeClass(this.map.viewPortDiv, \"olCursorWait\");\n+ if (this.hoverRequest) {\n+ this.hoverRequest.abort();\n+ this.hoverRequest = null;\n }\n },\n \n /**\n- * Method: request\n- * Sends a GetFeature request to the WFS\n- * \n- * Parameters:\n- * bounds - {} bounds for the request's BBOX filter\n- * options - {Object} additional options for this method.\n- * \n- * Supported options include:\n- * single - {Boolean} A single feature should be returned.\n- * Note that this will be ignored if the protocol does not\n- * return the geometries of the features.\n- * hover - {Boolean} Do the request for the hover handler.\n+ * Method: findLayers\n+ * Internal method to get the layers, independent of whether we are\n+ * inspecting the map or using a client-provided array\n */\n- request: function(bounds, options) {\n- options = options || {};\n- var filter = new OpenLayers.Filter.Spatial({\n- type: this.filterType,\n- value: bounds\n- });\n-\n- // Set the cursor to \"wait\" to tell the user we're working.\n- OpenLayers.Element.addClass(this.map.viewPortDiv, \"olCursorWait\");\n+ findLayers: function() {\n \n- var response = this.protocol.read({\n- maxFeatures: options.single == true ? this.maxFeatures : undefined,\n- filter: filter,\n- callback: function(result) {\n- if (result.success()) {\n- if (result.features.length) {\n- if (options.single == true) {\n- this.selectBestFeature(result.features,\n- bounds.getCenterLonLat(), options);\n- } else {\n- this.select(result.features);\n- }\n- } else if (options.hover) {\n- this.hoverSelect();\n- } else {\n- this.events.triggerEvent(\"clickout\");\n- if (this.clickout) {\n- this.unselectAll();\n- }\n- }\n+ var candidates = this.layers || this.map.layers;\n+ var layers = [];\n+ var layer, url;\n+ for (var i = candidates.length - 1; i >= 0; --i) {\n+ layer = candidates[i];\n+ if (layer instanceof OpenLayers.Layer.WMS &&\n+ (!this.queryVisible || layer.getVisibility())) {\n+ url = OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url;\n+ // if the control was not configured with a url, set it\n+ // to the first layer url\n+ if (this.drillDown === false && !this.url) {\n+ this.url = url;\n }\n- // Reset the cursor.\n- OpenLayers.Element.removeClass(this.map.viewPortDiv, \"olCursorWait\");\n- },\n- scope: this\n- });\n- if (options.hover == true) {\n- this.hoverResponse = response;\n+ if (this.drillDown === true || this.urlMatches(url)) {\n+ layers.push(layer);\n+ }\n+ }\n }\n+ return layers;\n },\n \n /**\n- * Method: selectBestFeature\n- * Selects the feature from an array of features that is the best match\n- * for the click position.\n- * \n+ * Method: urlMatches\n+ * Test to see if the provided url matches either the control or one\n+ * of the .\n+ *\n * Parameters:\n- * features - {Array()}\n- * clickPosition - {}\n- * options - {Object} additional options for this method\n- * \n- * Supported options include:\n- * hover - {Boolean} Do the selection for the hover handler.\n+ * url - {String} The url to test.\n+ *\n+ * Returns:\n+ * {Boolean} The provided url matches the control or one of the\n+ * .\n */\n- selectBestFeature: function(features, clickPosition, options) {\n- options = options || {};\n- if (features.length) {\n- var point = new OpenLayers.Geometry.Point(clickPosition.lon,\n- clickPosition.lat);\n- var feature, resultFeature, dist;\n- var minDist = Number.MAX_VALUE;\n- for (var i = 0; i < features.length; ++i) {\n- feature = features[i];\n- if (feature.geometry) {\n- dist = point.distanceTo(feature.geometry, {\n- edge: false\n- });\n- if (dist < minDist) {\n- minDist = dist;\n- resultFeature = feature;\n- if (minDist == 0) {\n- break;\n- }\n- }\n+ urlMatches: function(url) {\n+ var matches = OpenLayers.Util.isEquivalentUrl(this.url, url);\n+ if (!matches && this.layerUrls) {\n+ for (var i = 0, len = this.layerUrls.length; i < len; ++i) {\n+ if (OpenLayers.Util.isEquivalentUrl(this.layerUrls[i], url)) {\n+ matches = true;\n+ break;\n }\n }\n-\n- if (options.hover == true) {\n- this.hoverSelect(resultFeature);\n- } else {\n- this.select(resultFeature || features);\n- }\n }\n+ return matches;\n },\n \n /**\n- * Method: setModifiers\n- * Sets the multiple and toggle modifiers according to the current event\n- * \n+ * Method: buildWMSOptions\n+ * Build an object with the relevant WMS options for the GetFeatureInfo request\n+ *\n * Parameters:\n- * evt - {}\n+ * url - {String} The url to be used for sending the request\n+ * layers - {Array(} The position on the map where the mouse\n+ * event occurred.\n+ * format - {String} The format from the corresponding GetMap request\n */\n- setModifiers: function(evt) {\n- this.modifiers = {\n- multiple: this.multiple || (this.multipleKey && evt[this.multipleKey]),\n- toggle: this.toggle || (this.toggleKey && evt[this.toggleKey])\n+ buildWMSOptions: function(url, layers, clickPosition, format) {\n+ var layerNames = [],\n+ styleNames = [];\n+ for (var i = 0, len = layers.length; i < len; i++) {\n+ if (layers[i].params.LAYERS != null) {\n+ layerNames = layerNames.concat(layers[i].params.LAYERS);\n+ styleNames = styleNames.concat(this.getStyleNames(layers[i]));\n+ }\n+ }\n+ var firstLayer = layers[0];\n+ // use the firstLayer's projection if it matches the map projection -\n+ // this assumes that all layers will be available in this projection\n+ var projection = this.map.getProjection();\n+ var layerProj = firstLayer.projection;\n+ if (layerProj && layerProj.equals(this.map.getProjectionObject())) {\n+ projection = layerProj.getCode();\n+ }\n+ var params = OpenLayers.Util.extend({\n+ service: \"WMS\",\n+ version: firstLayer.params.VERSION,\n+ request: \"GetFeatureInfo\",\n+ exceptions: firstLayer.params.EXCEPTIONS,\n+ bbox: this.map.getExtent().toBBOX(null,\n+ firstLayer.reverseAxisOrder()),\n+ feature_count: this.maxFeatures,\n+ height: this.map.getSize().h,\n+ width: this.map.getSize().w,\n+ format: format,\n+ info_format: firstLayer.params.INFO_FORMAT || this.infoFormat\n+ }, (parseFloat(firstLayer.params.VERSION) >= 1.3) ? {\n+ crs: projection,\n+ i: parseInt(clickPosition.x),\n+ j: parseInt(clickPosition.y)\n+ } : {\n+ srs: projection,\n+ x: parseInt(clickPosition.x),\n+ y: parseInt(clickPosition.y)\n+ });\n+ if (layerNames.length != 0) {\n+ params = OpenLayers.Util.extend({\n+ layers: layerNames,\n+ query_layers: layerNames,\n+ styles: styleNames\n+ }, params);\n+ }\n+ OpenLayers.Util.applyDefaults(params, this.vendorParams);\n+ return {\n+ url: url,\n+ params: OpenLayers.Util.upperCaseObject(params),\n+ callback: function(request) {\n+ this.handleResponse(clickPosition, request, url);\n+ },\n+ scope: this\n };\n },\n \n /**\n- * Method: select\n- * Add feature to the hash of selected features and trigger the\n- * featureselected and featuresselected events.\n- * \n+ * Method: getStyleNames\n+ * Gets the STYLES parameter for the layer. Make sure the STYLES parameter\n+ * matches the LAYERS parameter\n+ *\n * Parameters:\n- * features - {} or an array of features\n+ * layer - {}\n+ *\n+ * Returns:\n+ * {Array(String)} The STYLES parameter\n */\n- select: function(features) {\n- if (!this.modifiers.multiple && !this.modifiers.toggle) {\n- this.unselectAll();\n- }\n- if (!(OpenLayers.Util.isArray(features))) {\n- features = [features];\n- }\n-\n- var cont = this.events.triggerEvent(\"beforefeaturesselected\", {\n- features: features\n- });\n- if (cont !== false) {\n- var selectedFeatures = [];\n- var feature;\n- for (var i = 0, len = features.length; i < len; ++i) {\n- feature = features[i];\n- if (this.features[feature.fid || feature.id]) {\n- if (this.modifiers.toggle) {\n- this.unselect(this.features[feature.fid || feature.id]);\n- }\n- } else {\n- cont = this.events.triggerEvent(\"beforefeatureselected\", {\n- feature: feature\n- });\n- if (cont !== false) {\n- this.features[feature.fid || feature.id] = feature;\n- selectedFeatures.push(feature);\n-\n- this.events.triggerEvent(\"featureselected\", {\n- feature: feature\n- });\n- }\n- }\n+ getStyleNames: function(layer) {\n+ // in the event of a WMS layer bundling multiple layers but not\n+ // specifying styles,we need the same number of commas to specify\n+ // the default style for each of the layers. We can't just leave it\n+ // blank as we may be including other layers that do specify styles.\n+ var styleNames;\n+ if (layer.params.STYLES) {\n+ styleNames = layer.params.STYLES;\n+ } else {\n+ if (OpenLayers.Util.isArray(layer.params.LAYERS)) {\n+ styleNames = new Array(layer.params.LAYERS.length);\n+ } else { // Assume it's a String\n+ styleNames = layer.params.LAYERS.replace(/[^,]/g, \"\");\n }\n- this.events.triggerEvent(\"featuresselected\", {\n- features: selectedFeatures\n- });\n }\n+ return styleNames;\n },\n \n /**\n- * Method: hoverSelect\n- * Sets/unsets the \n- * \n+ * Method: request\n+ * Sends a GetFeatureInfo request to the WMS\n+ *\n * Parameters:\n- * feature - {} the feature to hover-select.\n- * If none is provided, the current will be nulled and\n- * the outfeature event will be triggered.\n+ * clickPosition - {} The position on the map where the\n+ * mouse event occurred.\n+ * options - {Object} additional options for this method.\n+ *\n+ * Valid options:\n+ * - *hover* {Boolean} true if we do the request for the hover handler\n */\n- hoverSelect: function(feature) {\n- var fid = feature ? feature.fid || feature.id : null;\n- var hfid = this.hoverFeature ?\n- this.hoverFeature.fid || this.hoverFeature.id : null;\n-\n- if (hfid && hfid != fid) {\n- this.events.triggerEvent(\"outfeature\", {\n- feature: this.hoverFeature\n- });\n- this.hoverFeature = null;\n+ request: function(clickPosition, options) {\n+ var layers = this.findLayers();\n+ if (layers.length == 0) {\n+ this.events.triggerEvent(\"nogetfeatureinfo\");\n+ // Reset the cursor.\n+ OpenLayers.Element.removeClass(this.map.viewPortDiv, \"olCursorWait\");\n+ return;\n }\n- if (fid && fid != hfid) {\n- this.events.triggerEvent(\"hoverfeature\", {\n- feature: feature\n- });\n- this.hoverFeature = feature;\n+\n+ options = options || {};\n+ if (this.drillDown === false) {\n+ var wmsOptions = this.buildWMSOptions(this.url, layers,\n+ clickPosition, layers[0].params.FORMAT);\n+ var request = OpenLayers.Request.GET(wmsOptions);\n+\n+ if (options.hover === true) {\n+ this.hoverRequest = request;\n+ }\n+ } else {\n+ this._requestCount = 0;\n+ this._numRequests = 0;\n+ this.features = [];\n+ // group according to service url to combine requests\n+ var services = {},\n+ url;\n+ for (var i = 0, len = layers.length; i < len; i++) {\n+ var layer = layers[i];\n+ var service, found = false;\n+ url = OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url;\n+ if (url in services) {\n+ services[url].push(layer);\n+ } else {\n+ this._numRequests++;\n+ services[url] = [layer];\n+ }\n+ }\n+ var layers;\n+ for (var url in services) {\n+ layers = services[url];\n+ var wmsOptions = this.buildWMSOptions(url, layers,\n+ clickPosition, layers[0].params.FORMAT);\n+ OpenLayers.Request.GET(wmsOptions);\n+ }\n }\n },\n \n /**\n- * Method: unselect\n- * Remove feature from the hash of selected features and trigger the\n- * featureunselected event.\n+ * Method: triggerGetFeatureInfo\n+ * Trigger the getfeatureinfo event when all is done\n *\n * Parameters:\n- * feature - {}\n+ * request - {XMLHttpRequest} The request object\n+ * xy - {} The position on the map where the\n+ * mouse event occurred.\n+ * features - {Array()} or\n+ * {Array({Object}) when output is \"object\". The object has a url and a\n+ * features property which contains an array of features.\n */\n- unselect: function(feature) {\n- delete this.features[feature.fid || feature.id];\n- this.events.triggerEvent(\"featureunselected\", {\n- feature: feature\n+ triggerGetFeatureInfo: function(request, xy, features) {\n+ this.events.triggerEvent(\"getfeatureinfo\", {\n+ text: request.responseText,\n+ features: features,\n+ request: request,\n+ xy: xy\n });\n- },\n-\n- /**\n- * Method: unselectAll\n- * Unselect all selected features.\n- */\n- unselectAll: function() {\n- // we'll want an option to supress notification here\n- for (var fid in this.features) {\n- this.unselect(this.features[fid]);\n- }\n- },\n \n- /** \n- * Method: setMap\n- * Set the map property for the control. \n- * \n- * Parameters:\n- * map - {} \n- */\n- setMap: function(map) {\n- for (var i in this.handlers) {\n- this.handlers[i].setMap(map);\n- }\n- OpenLayers.Control.prototype.setMap.apply(this, arguments);\n+ // Reset the cursor.\n+ OpenLayers.Element.removeClass(this.map.viewPortDiv, \"olCursorWait\");\n },\n \n /**\n- * Method: pixelToBounds\n- * Takes a pixel as argument and creates bounds after adding the\n- * .\n- * \n+ * Method: handleResponse\n+ * Handler for the GetFeatureInfo response.\n+ *\n * Parameters:\n- * pixel - {}\n+ * xy - {} The position on the map where the\n+ * mouse event occurred.\n+ * request - {XMLHttpRequest} The request object.\n+ * url - {String} The url which was used for this request.\n */\n- pixelToBounds: function(pixel) {\n- var llPx = pixel.add(-this.clickTolerance / 2, this.clickTolerance / 2);\n- var urPx = pixel.add(this.clickTolerance / 2, -this.clickTolerance / 2);\n- var ll = this.map.getLonLatFromPixel(llPx);\n- var ur = this.map.getLonLatFromPixel(urPx);\n- return new OpenLayers.Bounds(ll.lon, ll.lat, ur.lon, ur.lat);\n+ handleResponse: function(xy, request, url) {\n+\n+ var doc = request.responseXML;\n+ if (!doc || !doc.documentElement) {\n+ doc = request.responseText;\n+ }\n+ var features = this.format.read(doc);\n+ if (this.drillDown === false) {\n+ this.triggerGetFeatureInfo(request, xy, features);\n+ } else {\n+ this._requestCount++;\n+ if (this.output === \"object\") {\n+ this._features = (this._features || []).concat({\n+ url: url,\n+ features: features\n+ });\n+ } else {\n+ this._features = (this._features || []).concat(features);\n+ }\n+ if (this._requestCount === this._numRequests) {\n+ this.triggerGetFeatureInfo(request, xy, this._features.concat());\n+ delete this._features;\n+ delete this._requestCount;\n+ delete this._numRequests;\n+ }\n+ }\n },\n \n- CLASS_NAME: \"OpenLayers.Control.GetFeature\"\n+ CLASS_NAME: \"OpenLayers.Control.WMSGetFeatureInfo\"\n });\n /* ======================================================================\n- OpenLayers/Format/ArcXML.js\n+ OpenLayers/Handler/MouseWheel.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format/XML.js\n- * @requires OpenLayers/Geometry/Polygon.js\n- * @requires OpenLayers/Geometry/Point.js\n- * @requires OpenLayers/Geometry/MultiPolygon.js\n- * @requires OpenLayers/Geometry/LinearRing.js\n+ * @requires OpenLayers/Handler.js\n */\n \n /**\n- * Class: OpenLayers.Format.ArcXML\n- * Read/Write ArcXML. Create a new instance with the \n- * constructor.\n+ * Class: OpenLayers.Handler.MouseWheel\n+ * Handler for wheel up/down events.\n * \n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Format.ArcXML = OpenLayers.Class(OpenLayers.Format.XML, {\n-\n- /**\n- * Property: fontStyleKeys\n- * {Array} List of keys used in font styling.\n+OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {\n+ /** \n+ * Property: wheelListener \n+ * {function} \n */\n- fontStyleKeys: [\n- 'antialiasing', 'blockout', 'font', 'fontcolor', 'fontsize', 'fontstyle',\n- 'glowing', 'interval', 'outline', 'printmode', 'shadow', 'transparency'\n- ],\n+ wheelListener: null,\n \n /**\n- * Property: request\n- * A get_image request destined for an ArcIMS server.\n+ * Property: interval\n+ * {Integer} In order to increase server performance, an interval (in \n+ * milliseconds) can be set to reduce the number of up/down events \n+ * called. If set, a new up/down event will not be set until the \n+ * interval has passed. \n+ * Defaults to 0, meaning no interval. \n */\n- request: null,\n+ interval: 0,\n \n /**\n- * Property: response\n- * A parsed response from an ArcIMS server.\n+ * Property: maxDelta\n+ * {Integer} Maximum delta to collect before breaking from the current\n+ * interval. In cumulative mode, this also limits the maximum delta\n+ * returned from the handler. Default is Number.POSITIVE_INFINITY.\n */\n- response: null,\n+ maxDelta: Number.POSITIVE_INFINITY,\n \n /**\n- * Constructor: OpenLayers.Format.ArcXML\n- * Create a new parser/writer for ArcXML. Create an instance of this class\n- * to begin authoring a request to an ArcIMS service. This is used\n- * primarily by the ArcIMS layer, but could be used to do other wild\n- * stuff, like geocoding.\n- *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ * Property: delta\n+ * {Integer} When interval is set, delta collects the mousewheel z-deltas\n+ * of the events that occur within the interval.\n+ * See also the cumulative option\n */\n- initialize: function(options) {\n- this.request = new OpenLayers.Format.ArcXML.Request();\n- this.response = new OpenLayers.Format.ArcXML.Response();\n-\n- if (options) {\n- if (options.requesttype == \"feature\") {\n- this.request.get_image = null;\n-\n- var qry = this.request.get_feature.query;\n- this.addCoordSys(qry.featurecoordsys, options.featureCoordSys);\n- this.addCoordSys(qry.filtercoordsys, options.filterCoordSys);\n-\n- if (options.polygon) {\n- qry.isspatial = true;\n- qry.spatialfilter.polygon = options.polygon;\n- } else if (options.envelope) {\n- qry.isspatial = true;\n- qry.spatialfilter.envelope = {\n- minx: 0,\n- miny: 0,\n- maxx: 0,\n- maxy: 0\n- };\n- this.parseEnvelope(qry.spatialfilter.envelope, options.envelope);\n- }\n- } else if (options.requesttype == \"image\") {\n- this.request.get_feature = null;\n-\n- var props = this.request.get_image.properties;\n- this.parseEnvelope(props.envelope, options.envelope);\n-\n- this.addLayers(props.layerlist, options.layers);\n- this.addImageSize(props.imagesize, options.tileSize);\n- this.addCoordSys(props.featurecoordsys, options.featureCoordSys);\n- this.addCoordSys(props.filtercoordsys, options.filterCoordSys);\n- } else {\n- // if an arcxml object is being created with no request type, it is\n- // probably going to consume a response, so do not throw an error if\n- // the requesttype is not defined\n- this.request = null;\n- }\n- }\n-\n- OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);\n- },\n+ delta: 0,\n \n /**\n- * Method: parseEnvelope\n- * Parse an array of coordinates into an ArcXML envelope structure.\n- *\n- * Parameters:\n- * env - {Object} An envelope object that will contain the parsed coordinates.\n- * arr - {Array(double)} An array of coordinates in the order: [ minx, miny, maxx, maxy ]\n- */\n- parseEnvelope: function(env, arr) {\n- if (arr && arr.length == 4) {\n- env.minx = arr[0];\n- env.miny = arr[1];\n- env.maxx = arr[2];\n- env.maxy = arr[3];\n- }\n- },\n-\n- /** \n- * Method: addLayers\n- * Add a collection of layers to another collection of layers. Each layer in the list is tuple of\n- * { id, visible }. These layer collections represent the \n- * /ARCXML/REQUEST/get_image/PROPERTIES/LAYERLIST/LAYERDEF items in ArcXML\n- *\n- * TODO: Add support for dynamic layer rendering.\n- *\n- * Parameters:\n- * ll - {Array({id,visible})} A list of layer definitions.\n- * lyrs - {Array({id,visible})} A list of layer definitions.\n+ * Property: cumulative\n+ * {Boolean} When interval is set: true to collect all the mousewheel \n+ * z-deltas, false to only record the delta direction (positive or\n+ * negative)\n */\n- addLayers: function(ll, lyrs) {\n- for (var lind = 0, len = lyrs.length; lind < len; lind++) {\n- ll.push(lyrs[lind]);\n- }\n- },\n+ cumulative: true,\n \n /**\n- * Method: addImageSize\n- * Set the size of the requested image.\n+ * Constructor: OpenLayers.Handler.MouseWheel\n *\n * Parameters:\n- * imsize - {Object} An ArcXML imagesize object.\n- * olsize - {} The image size to set.\n+ * control - {} \n+ * callbacks - {Object} An object containing a single function to be\n+ * called when the drag operation is finished.\n+ * The callback should expect to recieve a single\n+ * argument, the point geometry.\n+ * options - {Object} \n */\n- addImageSize: function(imsize, olsize) {\n- if (olsize !== null) {\n- imsize.width = olsize.w;\n- imsize.height = olsize.h;\n- imsize.printwidth = olsize.w;\n- imsize.printheight = olsize.h;\n- }\n+ initialize: function(control, callbacks, options) {\n+ OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n+ this.wheelListener = OpenLayers.Function.bindAsEventListener(\n+ this.onWheelEvent, this\n+ );\n },\n \n /**\n- * Method: addCoordSys\n- * Add the coordinate system information to an object. The object may be \n- *\n- * Parameters:\n- * featOrFilt - {Object} A featurecoordsys or filtercoordsys ArcXML structure.\n- * fsys - {String} or {} or {filtercoordsys} or \n- * {featurecoordsys} A projection representation. If it's a {String}, \n- * the value is assumed to be the SRID. If it's a {OpenLayers.Projection} \n- * AND Proj4js is available, the projection number and name are extracted \n- * from there. If it's a filter or feature ArcXML structure, it is copied.\n+ * Method: destroy\n */\n- addCoordSys: function(featOrFilt, fsys) {\n- if (typeof fsys == \"string\") {\n- featOrFilt.id = parseInt(fsys);\n- featOrFilt.string = fsys;\n- }\n- // is this a proj4js instance?\n- else if (typeof fsys == \"object\" && fsys.proj !== null) {\n- featOrFilt.id = fsys.proj.srsProjNumber;\n- featOrFilt.string = fsys.proj.srsCode;\n- } else {\n- featOrFilt = fsys;\n- }\n+ destroy: function() {\n+ OpenLayers.Handler.prototype.destroy.apply(this, arguments);\n+ this.wheelListener = null;\n },\n \n /**\n- * APIMethod: iserror\n- * Check to see if the response from the server was an error.\n- *\n- * Parameters:\n- * data - {String} or {DOMElement} data to read/parse. If nothing is supplied,\n- * the current response is examined.\n- *\n- * Returns:\n- * {Boolean} true if the response was an error.\n+ * Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/\n */\n- iserror: function(data) {\n- var ret = null;\n-\n- if (!data) {\n- ret = (this.response.error !== '');\n- } else {\n- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n- var errorNodes = data.documentElement.getElementsByTagName(\"ERROR\");\n- ret = (errorNodes !== null && errorNodes.length > 0);\n- }\n \n- return ret;\n- },\n-\n- /**\n- * APIMethod: read\n- * Read data from a string, and return an response. \n+ /** \n+ * Method: onWheelEvent\n+ * Catch the wheel event and handle it xbrowserly\n * \n * Parameters:\n- * data - {String} or {DOMElement} data to read/parse.\n- *\n- * Returns:\n- * {} An ArcXML response. Note that this response\n- * data may change in the future. \n+ * e - {Event} \n */\n- read: function(data) {\n- if (typeof data == \"string\") {\n- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n- }\n-\n- var arcNode = null;\n- if (data && data.documentElement) {\n- if (data.documentElement.nodeName == \"ARCXML\") {\n- arcNode = data.documentElement;\n- } else {\n- arcNode = data.documentElement.getElementsByTagName(\"ARCXML\")[0];\n- }\n- }\n-\n- // in Safari, arcNode will be there but will have a child named \n- // parsererror\n- if (!arcNode || arcNode.firstChild.nodeName === 'parsererror') {\n- var error, source;\n- try {\n- error = data.firstChild.nodeValue;\n- source = data.firstChild.childNodes[1].firstChild.nodeValue;\n- } catch (err) {\n- // pass\n- }\n- throw {\n- message: \"Error parsing the ArcXML request\",\n- error: error,\n- source: source\n- };\n- }\n-\n- var response = this.parseResponse(arcNode);\n- return response;\n- },\n+ onWheelEvent: function(e) {\n \n- /**\n- * APIMethod: write\n- * Generate an ArcXml document string for sending to an ArcIMS server. \n- * \n- * Returns:\n- * {String} A string representing the ArcXML document request.\n- */\n- write: function(request) {\n- if (!request) {\n- request = this.request;\n+ // make sure we have a map and check keyboard modifiers\n+ if (!this.map || !this.checkModifiers(e)) {\n+ return;\n }\n- var root = this.createElementNS(\"\", \"ARCXML\");\n- root.setAttribute(\"version\", \"1.1\");\n-\n- var reqElem = this.createElementNS(\"\", \"REQUEST\");\n-\n- if (request.get_image != null) {\n- var getElem = this.createElementNS(\"\", \"GET_IMAGE\");\n- reqElem.appendChild(getElem);\n-\n- var propElem = this.createElementNS(\"\", \"PROPERTIES\");\n- getElem.appendChild(propElem);\n-\n- var props = request.get_image.properties;\n- if (props.featurecoordsys != null) {\n- var feat = this.createElementNS(\"\", \"FEATURECOORDSYS\");\n- propElem.appendChild(feat);\n-\n- if (props.featurecoordsys.id === 0) {\n- feat.setAttribute(\"string\", props.featurecoordsys['string']);\n- } else {\n- feat.setAttribute(\"id\", props.featurecoordsys.id);\n- }\n- }\n-\n- if (props.filtercoordsys != null) {\n- var filt = this.createElementNS(\"\", \"FILTERCOORDSYS\");\n- propElem.appendChild(filt);\n-\n- if (props.filtercoordsys.id === 0) {\n- filt.setAttribute(\"string\", props.filtercoordsys.string);\n- } else {\n- filt.setAttribute(\"id\", props.filtercoordsys.id);\n- }\n- }\n-\n- if (props.envelope != null) {\n- var env = this.createElementNS(\"\", \"ENVELOPE\");\n- propElem.appendChild(env);\n-\n- env.setAttribute(\"minx\", props.envelope.minx);\n- env.setAttribute(\"miny\", props.envelope.miny);\n- env.setAttribute(\"maxx\", props.envelope.maxx);\n- env.setAttribute(\"maxy\", props.envelope.maxy);\n- }\n-\n- var imagesz = this.createElementNS(\"\", \"IMAGESIZE\");\n- propElem.appendChild(imagesz);\n-\n- imagesz.setAttribute(\"height\", props.imagesize.height);\n- imagesz.setAttribute(\"width\", props.imagesize.width);\n-\n- if (props.imagesize.height != props.imagesize.printheight ||\n- props.imagesize.width != props.imagesize.printwidth) {\n- imagesz.setAttribute(\"printheight\", props.imagesize.printheight);\n- imagesz.setArrtibute(\"printwidth\", props.imagesize.printwidth);\n- }\n-\n- if (props.background != null) {\n- var backgrnd = this.createElementNS(\"\", \"BACKGROUND\");\n- propElem.appendChild(backgrnd);\n-\n- backgrnd.setAttribute(\"color\",\n- props.background.color.r + \",\" +\n- props.background.color.g + \",\" +\n- props.background.color.b);\n-\n- if (props.background.transcolor !== null) {\n- backgrnd.setAttribute(\"transcolor\",\n- props.background.transcolor.r + \",\" +\n- props.background.transcolor.g + \",\" +\n- props.background.transcolor.b);\n- }\n- }\n-\n- if (props.layerlist != null && props.layerlist.length > 0) {\n- var layerlst = this.createElementNS(\"\", \"LAYERLIST\");\n- propElem.appendChild(layerlst);\n-\n- for (var ld = 0; ld < props.layerlist.length; ld++) {\n- var ldef = this.createElementNS(\"\", \"LAYERDEF\");\n- layerlst.appendChild(ldef);\n-\n- ldef.setAttribute(\"id\", props.layerlist[ld].id);\n- ldef.setAttribute(\"visible\", props.layerlist[ld].visible);\n-\n- if (typeof props.layerlist[ld].query == \"object\") {\n- var query = props.layerlist[ld].query;\n-\n- if (query.where.length < 0) {\n- continue;\n- }\n-\n- var queryElem = null;\n- if (typeof query.spatialfilter == \"boolean\" && query.spatialfilter) {\n- // handle spatial filter madness\n- queryElem = this.createElementNS(\"\", \"SPATIALQUERY\");\n- } else {\n- queryElem = this.createElementNS(\"\", \"QUERY\");\n- }\n-\n- queryElem.setAttribute(\"where\", query.where);\n-\n- if (typeof query.accuracy == \"number\" && query.accuracy > 0) {\n- queryElem.setAttribute(\"accuracy\", query.accuracy);\n- }\n- if (typeof query.featurelimit == \"number\" && query.featurelimit < 2000) {\n- queryElem.setAttribute(\"featurelimit\", query.featurelimit);\n- }\n- if (typeof query.subfields == \"string\" && query.subfields != \"#ALL#\") {\n- queryElem.setAttribute(\"subfields\", query.subfields);\n- }\n- if (typeof query.joinexpression == \"string\" && query.joinexpression.length > 0) {\n- queryElem.setAttribute(\"joinexpression\", query.joinexpression);\n- }\n- if (typeof query.jointables == \"string\" && query.jointables.length > 0) {\n- queryElem.setAttribute(\"jointables\", query.jointables);\n- }\n-\n- ldef.appendChild(queryElem);\n- }\n-\n- if (typeof props.layerlist[ld].renderer == \"object\") {\n- this.addRenderer(ldef, props.layerlist[ld].renderer);\n- }\n- }\n- }\n- } else if (request.get_feature != null) {\n- var getElem = this.createElementNS(\"\", \"GET_FEATURES\");\n- getElem.setAttribute(\"outputmode\", \"newxml\");\n- getElem.setAttribute(\"checkesc\", \"true\");\n-\n- if (request.get_feature.geometry) {\n- getElem.setAttribute(\"geometry\", request.get_feature.geometry);\n- } else {\n- getElem.setAttribute(\"geometry\", \"false\");\n- }\n-\n- if (request.get_feature.compact) {\n- getElem.setAttribute(\"compact\", request.get_feature.compact);\n- }\n-\n- if (request.get_feature.featurelimit == \"number\") {\n- getElem.setAttribute(\"featurelimit\", request.get_feature.featurelimit);\n- }\n-\n- getElem.setAttribute(\"globalenvelope\", \"true\");\n- reqElem.appendChild(getElem);\n-\n- if (request.get_feature.layer != null && request.get_feature.layer.length > 0) {\n- var lyrElem = this.createElementNS(\"\", \"LAYER\");\n- lyrElem.setAttribute(\"id\", request.get_feature.layer);\n- getElem.appendChild(lyrElem);\n- }\n-\n- var fquery = request.get_feature.query;\n- if (fquery != null) {\n- var qElem = null;\n- if (fquery.isspatial) {\n- qElem = this.createElementNS(\"\", \"SPATIALQUERY\");\n- } else {\n- qElem = this.createElementNS(\"\", \"QUERY\");\n- }\n- getElem.appendChild(qElem);\n-\n- if (typeof fquery.accuracy == \"number\") {\n- qElem.setAttribute(\"accuracy\", fquery.accuracy);\n- }\n- //qElem.setAttribute(\"featurelimit\", \"5\");\n-\n- if (fquery.featurecoordsys != null) {\n- var fcsElem1 = this.createElementNS(\"\", \"FEATURECOORDSYS\");\n \n- if (fquery.featurecoordsys.id == 0) {\n- fcsElem1.setAttribute(\"string\", fquery.featurecoordsys.string);\n- } else {\n- fcsElem1.setAttribute(\"id\", fquery.featurecoordsys.id);\n- }\n- qElem.appendChild(fcsElem1);\n- }\n+ // Ride up the element's DOM hierarchy to determine if it or any of \n+ // its ancestors was: \n+ // * specifically marked as scrollable (CSS overflow property)\n+ // * one of our layer divs or a div marked as scrollable\n+ // ('olScrollable' CSS class)\n+ // * the map div\n+ //\n+ var overScrollableDiv = false;\n+ var allowScroll = false;\n+ var overMapDiv = false;\n \n- if (fquery.filtercoordsys != null) {\n- var fcsElem2 = this.createElementNS(\"\", \"FILTERCOORDSYS\");\n+ var elem = OpenLayers.Event.element(e);\n+ while ((elem != null) && !overMapDiv && !overScrollableDiv) {\n \n- if (fquery.filtercoordsys.id === 0) {\n- fcsElem2.setAttribute(\"string\", fquery.filtercoordsys.string);\n+ if (!overScrollableDiv) {\n+ try {\n+ var overflow;\n+ if (elem.currentStyle) {\n+ overflow = elem.currentStyle[\"overflow\"];\n } else {\n- fcsElem2.setAttribute(\"id\", fquery.filtercoordsys.id);\n- }\n- qElem.appendChild(fcsElem2);\n- }\n-\n- if (fquery.buffer > 0) {\n- var bufElem = this.createElementNS(\"\", \"BUFFER\");\n- bufElem.setAttribute(\"distance\", fquery.buffer);\n- qElem.appendChild(bufElem);\n- }\n-\n- if (fquery.isspatial) {\n- var spfElem = this.createElementNS(\"\", \"SPATIALFILTER\");\n- spfElem.setAttribute(\"relation\", fquery.spatialfilter.relation);\n- qElem.appendChild(spfElem);\n-\n- if (fquery.spatialfilter.envelope) {\n- var envElem = this.createElementNS(\"\", \"ENVELOPE\");\n- envElem.setAttribute(\"minx\", fquery.spatialfilter.envelope.minx);\n- envElem.setAttribute(\"miny\", fquery.spatialfilter.envelope.miny);\n- envElem.setAttribute(\"maxx\", fquery.spatialfilter.envelope.maxx);\n- envElem.setAttribute(\"maxy\", fquery.spatialfilter.envelope.maxy);\n- spfElem.appendChild(envElem);\n- } else if (typeof fquery.spatialfilter.polygon == \"object\") {\n- spfElem.appendChild(this.writePolygonGeometry(fquery.spatialfilter.polygon));\n+ var style =\n+ document.defaultView.getComputedStyle(elem, null);\n+ overflow = style.getPropertyValue(\"overflow\");\n }\n+ overScrollableDiv = (overflow &&\n+ (overflow == \"auto\") || (overflow == \"scroll\"));\n+ } catch (err) {\n+ //sometimes when scrolling in a popup, this causes \n+ // obscure browser error\n }\n-\n- if (fquery.where != null && fquery.where.length > 0) {\n- qElem.setAttribute(\"where\", fquery.where);\n- }\n- }\n- }\n-\n- root.appendChild(reqElem);\n-\n- return OpenLayers.Format.XML.prototype.write.apply(this, [root]);\n- },\n-\n-\n- addGroupRenderer: function(ldef, toprenderer) {\n- var topRelem = this.createElementNS(\"\", \"GROUPRENDERER\");\n- ldef.appendChild(topRelem);\n-\n- for (var rind = 0; rind < toprenderer.length; rind++) {\n- var renderer = toprenderer[rind];\n- this.addRenderer(topRelem, renderer);\n- }\n- },\n-\n-\n- addRenderer: function(topRelem, renderer) {\n- if (OpenLayers.Util.isArray(renderer)) {\n- this.addGroupRenderer(topRelem, renderer);\n- } else {\n- var renderElem = this.createElementNS(\"\", renderer.type.toUpperCase() + \"RENDERER\");\n- topRelem.appendChild(renderElem);\n-\n- if (renderElem.tagName == \"VALUEMAPRENDERER\") {\n- this.addValueMapRenderer(renderElem, renderer);\n- } else if (renderElem.tagName == \"VALUEMAPLABELRENDERER\") {\n- this.addValueMapLabelRenderer(renderElem, renderer);\n- } else if (renderElem.tagName == \"SIMPLELABELRENDERER\") {\n- this.addSimpleLabelRenderer(renderElem, renderer);\n- } else if (renderElem.tagName == \"SCALEDEPENDENTRENDERER\") {\n- this.addScaleDependentRenderer(renderElem, renderer);\n }\n- }\n- },\n-\n-\n- addScaleDependentRenderer: function(renderElem, renderer) {\n- if (typeof renderer.lower == \"string\" || typeof renderer.lower == \"number\") {\n- renderElem.setAttribute(\"lower\", renderer.lower);\n- }\n- if (typeof renderer.upper == \"string\" || typeof renderer.upper == \"number\") {\n- renderElem.setAttribute(\"upper\", renderer.upper);\n- }\n-\n- this.addRenderer(renderElem, renderer.renderer);\n- },\n-\n-\n- addValueMapLabelRenderer: function(renderElem, renderer) {\n- renderElem.setAttribute(\"lookupfield\", renderer.lookupfield);\n- renderElem.setAttribute(\"labelfield\", renderer.labelfield);\n-\n- if (typeof renderer.exacts == \"object\") {\n- for (var ext = 0, extlen = renderer.exacts.length; ext < extlen; ext++) {\n- var exact = renderer.exacts[ext];\n-\n- var eelem = this.createElementNS(\"\", \"EXACT\");\n-\n- if (typeof exact.value == \"string\") {\n- eelem.setAttribute(\"value\", exact.value);\n- }\n- if (typeof exact.label == \"string\") {\n- eelem.setAttribute(\"label\", exact.label);\n- }\n- if (typeof exact.method == \"string\") {\n- eelem.setAttribute(\"method\", exact.method);\n- }\n-\n- renderElem.appendChild(eelem);\n-\n- if (typeof exact.symbol == \"object\") {\n- var selem = null;\n-\n- if (exact.symbol.type == \"text\") {\n- selem = this.createElementNS(\"\", \"TEXTSYMBOL\");\n- }\n-\n- if (selem != null) {\n- var keys = this.fontStyleKeys;\n- for (var i = 0, len = keys.length; i < len; i++) {\n- var key = keys[i];\n- if (exact.symbol[key]) {\n- selem.setAttribute(key, exact.symbol[key]);\n- }\n- }\n- eelem.appendChild(selem);\n- }\n- }\n- } // for each exact\n- }\n- },\n-\n- addValueMapRenderer: function(renderElem, renderer) {\n- renderElem.setAttribute(\"lookupfield\", renderer.lookupfield);\n \n- if (typeof renderer.ranges == \"object\") {\n- for (var rng = 0, rnglen = renderer.ranges.length; rng < rnglen; rng++) {\n- var range = renderer.ranges[rng];\n-\n- var relem = this.createElementNS(\"\", \"RANGE\");\n- relem.setAttribute(\"lower\", range.lower);\n- relem.setAttribute(\"upper\", range.upper);\n-\n- renderElem.appendChild(relem);\n-\n- if (typeof range.symbol == \"object\") {\n- var selem = null;\n-\n- if (range.symbol.type == \"simplepolygon\") {\n- selem = this.createElementNS(\"\", \"SIMPLEPOLYGONSYMBOL\");\n- }\n-\n- if (selem != null) {\n- if (typeof range.symbol.boundarycolor == \"string\") {\n- selem.setAttribute(\"boundarycolor\", range.symbol.boundarycolor);\n- }\n- if (typeof range.symbol.fillcolor == \"string\") {\n- selem.setAttribute(\"fillcolor\", range.symbol.fillcolor);\n- }\n- if (typeof range.symbol.filltransparency == \"number\") {\n- selem.setAttribute(\"filltransparency\", range.symbol.filltransparency);\n+ if (!allowScroll) {\n+ allowScroll = OpenLayers.Element.hasClass(elem, 'olScrollable');\n+ if (!allowScroll) {\n+ for (var i = 0, len = this.map.layers.length; i < len; i++) {\n+ // Are we in the layer div? Note that we have two cases\n+ // here: one is to catch EventPane layers, which have a\n+ // pane above the layer (layer.pane)\n+ var layer = this.map.layers[i];\n+ if (elem == layer.div || elem == layer.pane) {\n+ allowScroll = true;\n+ break;\n }\n- relem.appendChild(selem);\n }\n }\n- } // for each range\n- } else if (typeof renderer.exacts == \"object\") {\n- for (var ext = 0, extlen = renderer.exacts.length; ext < extlen; ext++) {\n- var exact = renderer.exacts[ext];\n-\n- var eelem = this.createElementNS(\"\", \"EXACT\");\n- if (typeof exact.value == \"string\") {\n- eelem.setAttribute(\"value\", exact.value);\n- }\n- if (typeof exact.label == \"string\") {\n- eelem.setAttribute(\"label\", exact.label);\n- }\n- if (typeof exact.method == \"string\") {\n- eelem.setAttribute(\"method\", exact.method);\n- }\n-\n- renderElem.appendChild(eelem);\n-\n- if (typeof exact.symbol == \"object\") {\n- var selem = null;\n+ }\n+ overMapDiv = (elem == this.map.div);\n \n- if (exact.symbol.type == \"simplemarker\") {\n- selem = this.createElementNS(\"\", \"SIMPLEMARKERSYMBOL\");\n- }\n+ elem = elem.parentNode;\n+ }\n \n- if (selem != null) {\n- if (typeof exact.symbol.antialiasing == \"string\") {\n- selem.setAttribute(\"antialiasing\", exact.symbol.antialiasing);\n- }\n- if (typeof exact.symbol.color == \"string\") {\n- selem.setAttribute(\"color\", exact.symbol.color);\n- }\n- if (typeof exact.symbol.outline == \"string\") {\n- selem.setAttribute(\"outline\", exact.symbol.outline);\n- }\n- if (typeof exact.symbol.overlap == \"string\") {\n- selem.setAttribute(\"overlap\", exact.symbol.overlap);\n- }\n- if (typeof exact.symbol.shadow == \"string\") {\n- selem.setAttribute(\"shadow\", exact.symbol.shadow);\n- }\n- if (typeof exact.symbol.transparency == \"number\") {\n- selem.setAttribute(\"transparency\", exact.symbol.transparency);\n- }\n- //if (typeof exact.symbol.type == \"string\")\n- // selem.setAttribute(\"type\", exact.symbol.type);\n- if (typeof exact.symbol.usecentroid == \"string\") {\n- selem.setAttribute(\"usecentroid\", exact.symbol.usecentroid);\n- }\n- if (typeof exact.symbol.width == \"number\") {\n- selem.setAttribute(\"width\", exact.symbol.width);\n- }\n+ // Logic below is the following:\n+ //\n+ // If we are over a scrollable div or not over the map div:\n+ // * do nothing (let the browser handle scrolling)\n+ //\n+ // otherwise \n+ // \n+ // If we are over the layer div or a 'olScrollable' div:\n+ // * zoom/in out\n+ // then\n+ // * kill event (so as not to also scroll the page after zooming)\n+ //\n+ // otherwise\n+ //\n+ // Kill the event (dont scroll the page if we wheel over the \n+ // layerswitcher or the pan/zoom control)\n+ //\n+ if (!overScrollableDiv && overMapDiv) {\n+ if (allowScroll) {\n+ var delta = 0;\n \n- eelem.appendChild(selem);\n+ if (e.wheelDelta) {\n+ delta = e.wheelDelta;\n+ if (delta % 160 === 0) {\n+ // opera have steps of 160 instead of 120\n+ delta = delta * 0.75;\n }\n+ delta = delta / 120;\n+ } else if (e.detail) {\n+ // detail in Firefox on OS X is 1/3 of Windows\n+ // so force delta 1 / -1\n+ delta = -(e.detail / Math.abs(e.detail));\n }\n- } // for each exact\n- }\n- },\n-\n-\n- addSimpleLabelRenderer: function(renderElem, renderer) {\n- renderElem.setAttribute(\"field\", renderer.field);\n- var keys = ['featureweight', 'howmanylabels', 'labelbufferratio',\n- 'labelpriorities', 'labelweight', 'linelabelposition',\n- 'rotationalangles'\n- ];\n- for (var i = 0, len = keys.length; i < len; i++) {\n- var key = keys[i];\n- if (renderer[key]) {\n- renderElem.setAttribute(key, renderer[key]);\n- }\n- }\n-\n- if (renderer.symbol.type == \"text\") {\n- var symbol = renderer.symbol;\n- var selem = this.createElementNS(\"\", \"TEXTSYMBOL\");\n- renderElem.appendChild(selem);\n+ this.delta += delta;\n \n- var keys = this.fontStyleKeys;\n- for (var i = 0, len = keys.length; i < len; i++) {\n- var key = keys[i];\n- if (symbol[key]) {\n- selem.setAttribute(key, renderer[key]);\n+ window.clearTimeout(this._timeoutId);\n+ if (this.interval && Math.abs(this.delta) < this.maxDelta) {\n+ // store e because window.event might change during delay\n+ var evt = OpenLayers.Util.extend({}, e);\n+ this._timeoutId = window.setTimeout(\n+ OpenLayers.Function.bind(function() {\n+ this.wheelZoom(evt);\n+ }, this),\n+ this.interval\n+ );\n+ } else {\n+ this.wheelZoom(e);\n }\n }\n+ OpenLayers.Event.stop(e);\n }\n },\n \n- writePolygonGeometry: function(polygon) {\n- if (!(polygon instanceof OpenLayers.Geometry.Polygon)) {\n- throw {\n- message: 'Cannot write polygon geometry to ArcXML with an ' +\n- polygon.CLASS_NAME + ' object.',\n- geometry: polygon\n- };\n- }\n-\n- var polyElem = this.createElementNS(\"\", \"POLYGON\");\n-\n- for (var ln = 0, lnlen = polygon.components.length; ln < lnlen; ln++) {\n- var ring = polygon.components[ln];\n- var ringElem = this.createElementNS(\"\", \"RING\");\n-\n- for (var rn = 0, rnlen = ring.components.length; rn < rnlen; rn++) {\n- var point = ring.components[rn];\n- var pointElem = this.createElementNS(\"\", \"POINT\");\n-\n- pointElem.setAttribute(\"x\", point.x);\n- pointElem.setAttribute(\"y\", point.y);\n-\n- ringElem.appendChild(pointElem);\n- }\n-\n- polyElem.appendChild(ringElem);\n- }\n-\n- return polyElem;\n- },\n-\n /**\n- * Method: parseResponse\n- * Take an ArcXML response, and parse in into this object's internal properties.\n- *\n+ * Method: wheelZoom\n+ * Given the wheel event, we carry out the appropriate zooming in or out,\n+ * based on the 'wheelDelta' or 'detail' property of the event.\n+ * \n * Parameters:\n- * data - {String} or {DOMElement} The ArcXML response, as either a string or the\n- * top level DOMElement of the response.\n+ * e - {Event}\n */\n- parseResponse: function(data) {\n- if (typeof data == \"string\") {\n- var newData = new OpenLayers.Format.XML();\n- data = newData.read(data);\n- }\n- var response = new OpenLayers.Format.ArcXML.Response();\n-\n- var errorNode = data.getElementsByTagName(\"ERROR\");\n-\n- if (errorNode != null && errorNode.length > 0) {\n- response.error = this.getChildValue(errorNode, \"Unknown error.\");\n- } else {\n- var responseNode = data.getElementsByTagName(\"RESPONSE\");\n-\n- if (responseNode == null || responseNode.length == 0) {\n- response.error = \"No RESPONSE tag found in ArcXML response.\";\n- return response;\n- }\n-\n- var rtype = responseNode[0].firstChild.nodeName;\n- if (rtype == \"#text\") {\n- rtype = responseNode[0].firstChild.nextSibling.nodeName;\n- }\n-\n- if (rtype == \"IMAGE\") {\n- var envelopeNode = data.getElementsByTagName(\"ENVELOPE\");\n- var outputNode = data.getElementsByTagName(\"OUTPUT\");\n-\n- if (envelopeNode == null || envelopeNode.length == 0) {\n- response.error = \"No ENVELOPE tag found in ArcXML response.\";\n- } else if (outputNode == null || outputNode.length == 0) {\n- response.error = \"No OUTPUT tag found in ArcXML response.\";\n- } else {\n- var envAttr = this.parseAttributes(envelopeNode[0]);\n- var outputAttr = this.parseAttributes(outputNode[0]);\n-\n- if (typeof outputAttr.type == \"string\") {\n- response.image = {\n- envelope: envAttr,\n- output: {\n- type: outputAttr.type,\n- data: this.getChildValue(outputNode[0])\n- }\n- };\n- } else {\n- response.image = {\n- envelope: envAttr,\n- output: outputAttr\n- };\n- }\n- }\n- } else if (rtype == \"FEATURES\") {\n- var features = responseNode[0].getElementsByTagName(\"FEATURES\");\n-\n- // get the feature count\n- var featureCount = features[0].getElementsByTagName(\"FEATURECOUNT\");\n- response.features.featurecount = featureCount[0].getAttribute(\"count\");\n-\n- if (response.features.featurecount > 0) {\n- // get the feature envelope\n- var envelope = features[0].getElementsByTagName(\"ENVELOPE\");\n- response.features.envelope = this.parseAttributes(envelope[0], typeof(0));\n-\n- // get the field values per feature\n- var featureList = features[0].getElementsByTagName(\"FEATURE\");\n- for (var fn = 0; fn < featureList.length; fn++) {\n- var feature = new OpenLayers.Feature.Vector();\n- var fields = featureList[fn].getElementsByTagName(\"FIELD\");\n-\n- for (var fdn = 0; fdn < fields.length; fdn++) {\n- var fieldName = fields[fdn].getAttribute(\"name\");\n- var fieldValue = fields[fdn].getAttribute(\"value\");\n- feature.attributes[fieldName] = fieldValue;\n- }\n-\n- var geom = featureList[fn].getElementsByTagName(\"POLYGON\");\n-\n- if (geom.length > 0) {\n- // if there is a polygon, create an openlayers polygon, and assign\n- // it to the .geometry property of the feature\n- var ring = geom[0].getElementsByTagName(\"RING\");\n-\n- var polys = [];\n- for (var rn = 0; rn < ring.length; rn++) {\n- var linearRings = [];\n- linearRings.push(this.parsePointGeometry(ring[rn]));\n-\n- var holes = ring[rn].getElementsByTagName(\"HOLE\");\n- for (var hn = 0; hn < holes.length; hn++) {\n- linearRings.push(this.parsePointGeometry(holes[hn]));\n- }\n- holes = null;\n- polys.push(new OpenLayers.Geometry.Polygon(linearRings));\n- linearRings = null;\n- }\n- ring = null;\n-\n- if (polys.length == 1) {\n- feature.geometry = polys[0];\n- } else {\n- feature.geometry = new OpenLayers.Geometry.MultiPolygon(polys);\n- }\n- }\n+ wheelZoom: function(e) {\n+ var delta = this.delta;\n+ this.delta = 0;\n \n- response.features.feature.push(feature);\n- }\n- }\n+ if (delta) {\n+ e.xy = this.map.events.getMousePosition(e);\n+ if (delta < 0) {\n+ this.callback(\"down\",\n+ [e, this.cumulative ? Math.max(-this.maxDelta, delta) : -1]);\n } else {\n- response.error = \"Unidentified response type.\";\n+ this.callback(\"up\",\n+ [e, this.cumulative ? Math.min(this.maxDelta, delta) : 1]);\n }\n }\n- return response;\n },\n \n-\n /**\n- * Method: parseAttributes\n- *\n- * Parameters:\n- * node - {} An element to parse attributes from.\n- *\n- * Returns:\n- * {Object} An attributes object, with properties set to attribute values.\n+ * Method: activate \n */\n- parseAttributes: function(node, type) {\n- var attributes = {};\n- for (var attr = 0; attr < node.attributes.length; attr++) {\n- if (type == \"number\") {\n- attributes[node.attributes[attr].nodeName] = parseFloat(node.attributes[attr].nodeValue);\n- } else {\n- attributes[node.attributes[attr].nodeName] = node.attributes[attr].nodeValue;\n- }\n+ activate: function(evt) {\n+ if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n+ //register mousewheel events specifically on the window and document\n+ var wheelListener = this.wheelListener;\n+ OpenLayers.Event.observe(window, \"DOMMouseScroll\", wheelListener);\n+ OpenLayers.Event.observe(window, \"mousewheel\", wheelListener);\n+ OpenLayers.Event.observe(document, \"mousewheel\", wheelListener);\n+ return true;\n+ } else {\n+ return false;\n }\n- return attributes;\n },\n \n-\n /**\n- * Method: parsePointGeometry\n- *\n- * Parameters:\n- * node - {} An element to parse or arcxml data from.\n- *\n- * Returns:\n- * {} A linear ring represented by the node's points.\n+ * Method: deactivate \n */\n- parsePointGeometry: function(node) {\n- var ringPoints = [];\n- var coords = node.getElementsByTagName(\"COORDS\");\n-\n- if (coords.length > 0) {\n- // if coords is present, it's the only coords item\n- var coordArr = this.getChildValue(coords[0]);\n- coordArr = coordArr.split(/;/);\n- for (var cn = 0; cn < coordArr.length; cn++) {\n- var coordItems = coordArr[cn].split(/ /);\n- ringPoints.push(new OpenLayers.Geometry.Point(coordItems[0], coordItems[1]));\n- }\n- coords = null;\n+ deactivate: function(evt) {\n+ if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n+ // unregister mousewheel events specifically on the window and document\n+ var wheelListener = this.wheelListener;\n+ OpenLayers.Event.stopObserving(window, \"DOMMouseScroll\", wheelListener);\n+ OpenLayers.Event.stopObserving(window, \"mousewheel\", wheelListener);\n+ OpenLayers.Event.stopObserving(document, \"mousewheel\", wheelListener);\n+ return true;\n } else {\n- var point = node.getElementsByTagName(\"POINT\");\n- if (point.length > 0) {\n- for (var pn = 0; pn < point.length; pn++) {\n- ringPoints.push(\n- new OpenLayers.Geometry.Point(\n- parseFloat(point[pn].getAttribute(\"x\")),\n- parseFloat(point[pn].getAttribute(\"y\"))\n- )\n- );\n- }\n- }\n- point = null;\n+ return false;\n }\n-\n- return new OpenLayers.Geometry.LinearRing(ringPoints);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Format.ArcXML\"\n-});\n-\n-OpenLayers.Format.ArcXML.Request = OpenLayers.Class({\n- initialize: function(params) {\n- var defaults = {\n- get_image: {\n- properties: {\n- background: null,\n- /*{ \n- color: { r:255, g:255, b:255 },\n- transcolor: null\n- },*/\n- draw: true,\n- envelope: {\n- minx: 0,\n- miny: 0,\n- maxx: 0,\n- maxy: 0\n- },\n- featurecoordsys: {\n- id: 0,\n- string: \"\",\n- datumtransformid: 0,\n- datumtransformstring: \"\"\n- },\n- filtercoordsys: {\n- id: 0,\n- string: \"\",\n- datumtransformid: 0,\n- datumtransformstring: \"\"\n- },\n- imagesize: {\n- height: 0,\n- width: 0,\n- dpi: 96,\n- printheight: 0,\n- printwidth: 0,\n- scalesymbols: false\n- },\n- layerlist: [],\n- /* no support for legends */\n- output: {\n- baseurl: \"\",\n- legendbaseurl: \"\",\n- legendname: \"\",\n- legendpath: \"\",\n- legendurl: \"\",\n- name: \"\",\n- path: \"\",\n- type: \"jpg\",\n- url: \"\"\n- }\n- }\n- },\n-\n- get_feature: {\n- layer: \"\",\n- query: {\n- isspatial: false,\n- featurecoordsys: {\n- id: 0,\n- string: \"\",\n- datumtransformid: 0,\n- datumtransformstring: \"\"\n- },\n- filtercoordsys: {\n- id: 0,\n- string: \"\",\n- datumtransformid: 0,\n- datumtransformstring: \"\"\n- },\n- buffer: 0,\n- where: \"\",\n- spatialfilter: {\n- relation: \"envelope_intersection\",\n- envelope: null\n- }\n- }\n- },\n-\n- environment: {\n- separators: {\n- cs: \" \",\n- ts: \";\"\n- }\n- },\n-\n- layer: [],\n- workspaces: []\n- };\n-\n- return OpenLayers.Util.extend(this, defaults);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Format.ArcXML.Request\"\n-});\n-\n-OpenLayers.Format.ArcXML.Response = OpenLayers.Class({\n- initialize: function(params) {\n- var defaults = {\n- image: {\n- envelope: null,\n- output: ''\n- },\n-\n- features: {\n- featurecount: 0,\n- envelope: null,\n- feature: []\n- },\n-\n- error: ''\n- };\n-\n- return OpenLayers.Util.extend(this, defaults);\n },\n \n- CLASS_NAME: \"OpenLayers.Format.ArcXML.Response\"\n+ CLASS_NAME: \"OpenLayers.Handler.MouseWheel\"\n });\n /* ======================================================================\n- OpenLayers/Layer/ArcIMS.js\n+ OpenLayers/Control/Navigation.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Layer/Grid.js\n- * @requires OpenLayers/Format/ArcXML.js\n- * @requires OpenLayers/Request.js\n+ * @requires OpenLayers/Control/ZoomBox.js\n+ * @requires OpenLayers/Control/DragPan.js\n+ * @requires OpenLayers/Handler/MouseWheel.js\n+ * @requires OpenLayers/Handler/Click.js\n */\n \n /**\n- * Class: OpenLayers.Layer.ArcIMS\n- * Instances of OpenLayers.Layer.ArcIMS are used to display data from ESRI ArcIMS\n- * Mapping Services. Create a new ArcIMS layer with the \n- * constructor.\n+ * Class: OpenLayers.Control.Navigation\n+ * The navigation control handles map browsing with mouse events (dragging,\n+ * double-clicking, and scrolling the wheel). Create a new navigation \n+ * control with the control. \n * \n- * Inherits from:\n- * - \n+ * Note that this control is added to the map by default (if no controls \n+ * array is sent in the options object to the \n+ * constructor).\n+ * \n+ * Inherits:\n+ * - \n */\n-OpenLayers.Layer.ArcIMS = OpenLayers.Class(OpenLayers.Layer.Grid, {\n+OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {\n+\n+ /** \n+ * Property: dragPan\n+ * {} \n+ */\n+ dragPan: null,\n \n /**\n- * Constant: DEFAULT_PARAMS\n- * {Object} Default query string parameters.\n+ * APIProperty: dragPanOptions\n+ * {Object} Options passed to the DragPan control.\n */\n- DEFAULT_PARAMS: {\n- ClientVersion: \"9.2\",\n- ServiceName: ''\n- },\n+ dragPanOptions: null,\n \n /**\n- * APIProperty: featureCoordSys\n- * {String} Code for feature coordinate system. Default is \"4326\".\n+ * Property: pinchZoom\n+ * {}\n */\n- featureCoordSys: \"4326\",\n+ pinchZoom: null,\n \n /**\n- * APIProperty: filterCoordSys\n- * {String} Code for filter coordinate system. Default is \"4326\".\n+ * APIProperty: pinchZoomOptions\n+ * {Object} Options passed to the PinchZoom control.\n */\n- filterCoordSys: \"4326\",\n+ pinchZoomOptions: null,\n \n /**\n- * APIProperty: layers\n- * {Array} An array of objects with layer properties.\n+ * APIProperty: documentDrag\n+ * {Boolean} Allow panning of the map by dragging outside map viewport.\n+ * Default is false.\n */\n- layers: null,\n+ documentDrag: false,\n+\n+ /** \n+ * Property: zoomBox\n+ * {}\n+ */\n+ zoomBox: null,\n \n /**\n- * APIProperty: async\n- * {Boolean} Request images asynchronously. Default is true.\n+ * APIProperty: zoomBoxEnabled\n+ * {Boolean} Whether the user can draw a box to zoom\n */\n- async: true,\n+ zoomBoxEnabled: true,\n \n /**\n- * APIProperty: name\n- * {String} Layer name. Default is \"ArcIMS\".\n+ * APIProperty: zoomWheelEnabled\n+ * {Boolean} Whether the mousewheel should zoom the map\n */\n- name: \"ArcIMS\",\n+ zoomWheelEnabled: true,\n \n /**\n- * APIProperty: isBaseLayer\n- * {Boolean} The layer is a base layer. Default is true.\n+ * Property: mouseWheelOptions\n+ * {Object} Options passed to the MouseWheel control (only useful if\n+ * is set to true). Default is no options for maps\n+ * with fractionalZoom set to true, otherwise\n+ * {cumulative: false, interval: 50, maxDelta: 6} \n */\n- isBaseLayer: true,\n+ mouseWheelOptions: null,\n \n /**\n- * Constant: DEFAULT_OPTIONS\n- * {Object} Default layers properties.\n+ * APIProperty: handleRightClicks\n+ * {Boolean} Whether or not to handle right clicks. Default is false.\n */\n- DEFAULT_OPTIONS: {\n- tileSize: new OpenLayers.Size(512, 512),\n- featureCoordSys: \"4326\",\n- filterCoordSys: \"4326\",\n- layers: null,\n- isBaseLayer: true,\n- async: true,\n- name: \"ArcIMS\"\n- },\n+ handleRightClicks: false,\n \n /**\n- * Constructor: OpenLayers.Layer.ArcIMS\n- * Create a new ArcIMS layer object.\n- *\n- * Example:\n- * (code)\n- * var arcims = new OpenLayers.Layer.ArcIMS(\n- * \"Global Sample\",\n- * \"http://sample.avencia.com/servlet/com.esri.esrimap.Esrimap\", \n- * {\n- * service: \"OpenLayers_Sample\", \n- * layers: [\n- * // layers to manipulate\n- * {id: \"1\", visible: true}\n- * ]\n- * }\n- * );\n- * (end)\n- *\n+ * APIProperty: zoomBoxKeyMask\n+ * {Integer} key code of the key, which has to be\n+ * pressed, while drawing the zoom box with the mouse on the screen. \n+ * You should probably set handleRightClicks to true if you use this\n+ * with MOD_CTRL, to disable the context menu for machines which use\n+ * CTRL-Click as a right click.\n+ * Default: \n+ */\n+ zoomBoxKeyMask: OpenLayers.Handler.MOD_SHIFT,\n+\n+ /**\n+ * APIProperty: autoActivate\n+ * {Boolean} Activate the control when it is added to a map. Default is\n+ * true.\n+ */\n+ autoActivate: true,\n+\n+ /**\n+ * Constructor: OpenLayers.Control.Navigation\n+ * Create a new navigation control\n+ * \n * Parameters:\n- * name - {String} A name for the layer\n- * url - {String} Base url for the ArcIMS server\n- * options - {Object} Optional object with properties to be set on the\n- * layer.\n+ * options - {Object} An optional object whose properties will be set on\n+ * the control\n */\n- initialize: function(name, url, options) {\n+ initialize: function(options) {\n+ this.handlers = {};\n+ OpenLayers.Control.prototype.initialize.apply(this, arguments);\n+ },\n \n- this.tileSize = new OpenLayers.Size(512, 512);\n+ /**\n+ * Method: destroy\n+ * The destroy method is used to perform any clean up before the control\n+ * is dereferenced. Typically this is where event listeners are removed\n+ * to prevent memory leaks.\n+ */\n+ destroy: function() {\n+ this.deactivate();\n \n- // parameters\n- this.params = OpenLayers.Util.applyDefaults({\n- ServiceName: options.serviceName\n- },\n- this.DEFAULT_PARAMS\n- );\n- this.options = OpenLayers.Util.applyDefaults(\n- options, this.DEFAULT_OPTIONS\n- );\n+ if (this.dragPan) {\n+ this.dragPan.destroy();\n+ }\n+ this.dragPan = null;\n \n- OpenLayers.Layer.Grid.prototype.initialize.apply(\n- this, [name, url, this.params, options]\n- );\n+ if (this.zoomBox) {\n+ this.zoomBox.destroy();\n+ }\n+ this.zoomBox = null;\n \n- //layer is transparent \n- if (this.transparent) {\n+ if (this.pinchZoom) {\n+ this.pinchZoom.destroy();\n+ }\n+ this.pinchZoom = null;\n \n- // unless explicitly set in options, make layer an overlay\n- if (!this.isBaseLayer) {\n- this.isBaseLayer = false;\n- }\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n+ },\n \n- // jpegs can never be transparent, so intelligently switch the \n- // format, depending on the browser's capabilities\n- if (this.format == \"image/jpeg\") {\n- this.format = OpenLayers.Util.alphaHack() ? \"image/gif\" : \"image/png\";\n- }\n+ /**\n+ * Method: activate\n+ */\n+ activate: function() {\n+ this.dragPan.activate();\n+ if (this.zoomWheelEnabled) {\n+ this.handlers.wheel.activate();\n+ }\n+ this.handlers.click.activate();\n+ if (this.zoomBoxEnabled) {\n+ this.zoomBox.activate();\n+ }\n+ if (this.pinchZoom) {\n+ this.pinchZoom.activate();\n }\n+ return OpenLayers.Control.prototype.activate.apply(this, arguments);\n+ },\n \n- // create an empty layer list if no layers specified in the options\n- if (this.options.layers === null) {\n- this.options.layers = [];\n+ /**\n+ * Method: deactivate\n+ */\n+ deactivate: function() {\n+ if (this.pinchZoom) {\n+ this.pinchZoom.deactivate();\n }\n+ this.zoomBox.deactivate();\n+ this.dragPan.deactivate();\n+ this.handlers.click.deactivate();\n+ this.handlers.wheel.deactivate();\n+ return OpenLayers.Control.prototype.deactivate.apply(this, arguments);\n },\n \n /**\n- * Method: getURL\n- * Return an image url this layer.\n- *\n- * Parameters:\n- * bounds - {} A bounds representing the bbox for the\n- * request.\n- *\n- * Returns:\n- * {String} A string with the map image's url.\n+ * Method: draw\n */\n- getURL: function(bounds) {\n- var url = \"\";\n- bounds = this.adjustBounds(bounds);\n+ draw: function() {\n+ // disable right mouse context menu for support of right click events\n+ if (this.handleRightClicks) {\n+ this.map.viewPortDiv.oncontextmenu = OpenLayers.Function.False;\n+ }\n \n- // create an arcxml request to generate the image\n- var axlReq = new OpenLayers.Format.ArcXML(\n- OpenLayers.Util.extend(this.options, {\n- requesttype: \"image\",\n- envelope: bounds.toArray(),\n- tileSize: this.tileSize\n- })\n+ var clickCallbacks = {\n+ 'click': this.defaultClick,\n+ 'dblclick': this.defaultDblClick,\n+ 'dblrightclick': this.defaultDblRightClick\n+ };\n+ var clickOptions = {\n+ 'double': true,\n+ 'stopDouble': true\n+ };\n+ this.handlers.click = new OpenLayers.Handler.Click(\n+ this, clickCallbacks, clickOptions\n );\n-\n- // create a synchronous ajax request to get an arcims image\n- var req = new OpenLayers.Request.POST({\n- url: this.getFullRequestString(),\n- data: axlReq.write(),\n- async: false\n+ this.dragPan = new OpenLayers.Control.DragPan(\n+ OpenLayers.Util.extend({\n+ map: this.map,\n+ documentDrag: this.documentDrag\n+ }, this.dragPanOptions)\n+ );\n+ this.zoomBox = new OpenLayers.Control.ZoomBox({\n+ map: this.map,\n+ keyMask: this.zoomBoxKeyMask\n });\n-\n- // if the response exists\n- if (req != null) {\n- var doc = req.responseXML;\n-\n- if (!doc || !doc.documentElement) {\n- doc = req.responseText;\n- }\n-\n- // create a new arcxml format to read the response\n- var axlResp = new OpenLayers.Format.ArcXML();\n- var arcxml = axlResp.read(doc);\n- url = this.getUrlOrImage(arcxml.image.output);\n+ this.dragPan.draw();\n+ this.zoomBox.draw();\n+ var wheelOptions = this.map.fractionalZoom ? {} : {\n+ cumulative: false,\n+ interval: 50,\n+ maxDelta: 6\n+ };\n+ this.handlers.wheel = new OpenLayers.Handler.MouseWheel(\n+ this, {\n+ up: this.wheelUp,\n+ down: this.wheelDown\n+ },\n+ OpenLayers.Util.extend(wheelOptions, this.mouseWheelOptions)\n+ );\n+ if (OpenLayers.Control.PinchZoom) {\n+ this.pinchZoom = new OpenLayers.Control.PinchZoom(\n+ OpenLayers.Util.extend({\n+ map: this.map\n+ }, this.pinchZoomOptions));\n }\n-\n- return url;\n },\n \n-\n /**\n- * Method: getURLasync\n- * Get an image url this layer asynchronously, and execute a callback\n- * when the image url is generated.\n+ * Method: defaultClick\n *\n * Parameters:\n- * bounds - {} A bounds representing the bbox for the\n- * request.\n- * callback - {Function} Function to call when image url is retrieved.\n- * scope - {Object} The scope of the callback method.\n+ * evt - {Event}\n */\n- getURLasync: function(bounds, callback, scope) {\n- bounds = this.adjustBounds(bounds);\n-\n- // create an arcxml request to generate the image\n- var axlReq = new OpenLayers.Format.ArcXML(\n- OpenLayers.Util.extend(this.options, {\n- requesttype: \"image\",\n- envelope: bounds.toArray(),\n- tileSize: this.tileSize\n- })\n- );\n-\n- // create an asynchronous ajax request to get an arcims image\n- OpenLayers.Request.POST({\n- url: this.getFullRequestString(),\n- async: true,\n- data: axlReq.write(),\n- callback: function(req) {\n- // process the response from ArcIMS, and call the callback function\n- // to set the image URL\n- var doc = req.responseXML;\n- if (!doc || !doc.documentElement) {\n- doc = req.responseText;\n- }\n-\n- // create a new arcxml format to read the response\n- var axlResp = new OpenLayers.Format.ArcXML();\n- var arcxml = axlResp.read(doc);\n+ defaultClick: function(evt) {\n+ if (evt.lastTouches && evt.lastTouches.length == 2) {\n+ this.map.zoomOut();\n+ }\n+ },\n \n- callback.call(scope, this.getUrlOrImage(arcxml.image.output));\n- },\n- scope: this\n- });\n+ /**\n+ * Method: defaultDblClick \n+ * \n+ * Parameters:\n+ * evt - {Event} \n+ */\n+ defaultDblClick: function(evt) {\n+ this.map.zoomTo(this.map.zoom + 1, evt.xy);\n },\n \n /**\n- * Method: getUrlOrImage\n- * Extract a url or image from the ArcXML image output.\n- *\n+ * Method: defaultDblRightClick \n+ * \n * Parameters:\n- * output - {Object} The image.output property of the object returned from\n- * the ArcXML format read method.\n- *\n- * Returns:\n- * {String} A URL for an image (potentially with the data protocol).\n+ * evt - {Event} \n */\n- getUrlOrImage: function(output) {\n- var ret = \"\";\n- if (output.url) {\n- // If the image response output url is a string, then the image\n- // data is not inline.\n- ret = output.url;\n- } else if (output.data) {\n- // The image data is inline and base64 encoded, create a data\n- // url for the image. This will only work for small images,\n- // due to browser url length limits.\n- ret = \"data:image/\" + output.type +\n- \";base64,\" + output.data;\n- }\n- return ret;\n+ defaultDblRightClick: function(evt) {\n+ this.map.zoomTo(this.map.zoom - 1, evt.xy);\n },\n \n /**\n- * Method: setLayerQuery\n- * Set the query definition on this layer. Query definitions are used to\n- * render parts of the spatial data in an image, and can be used to\n- * filter features or layers in the ArcIMS service.\n+ * Method: wheelChange \n *\n * Parameters:\n- * id - {String} The ArcIMS layer ID.\n- * querydef - {Object} The query definition to apply to this layer.\n+ * evt - {Event}\n+ * deltaZ - {Integer}\n */\n- setLayerQuery: function(id, querydef) {\n- // find the matching layer, if it exists\n- for (var lyr = 0; lyr < this.options.layers.length; lyr++) {\n- if (id == this.options.layers[lyr].id) {\n- // replace this layer definition\n- this.options.layers[lyr].query = querydef;\n- return;\n- }\n+ wheelChange: function(evt, deltaZ) {\n+ if (!this.map.fractionalZoom) {\n+ deltaZ = Math.round(deltaZ);\n }\n-\n- // no layer found, create a new definition\n- this.options.layers.push({\n- id: id,\n- visible: true,\n- query: querydef\n- });\n+ var currentZoom = this.map.getZoom(),\n+ newZoom = currentZoom + deltaZ;\n+ newZoom = Math.max(newZoom, 0);\n+ newZoom = Math.min(newZoom, this.map.getNumZoomLevels());\n+ if (newZoom === currentZoom) {\n+ return;\n+ }\n+ this.map.zoomTo(newZoom, evt.xy);\n },\n \n- /**\n- * Method: getFeatureInfo\n- * Get feature information from ArcIMS. Using the applied geometry, apply\n- * the options to the query (buffer, area/envelope intersection), and\n- * query the ArcIMS service.\n- *\n- * A note about accuracy:\n- * ArcIMS interprets the accuracy attribute in feature requests to be\n- * something like the 'modulus' operator on feature coordinates,\n- * applied to the database geometry of the feature. It doesn't round,\n- * so your feature coordinates may be up to (1 x accuracy) offset from\n- * the actual feature coordinates. If the accuracy of the layer is not\n- * specified, the accuracy will be computed to be approximately 1\n- * feature coordinate per screen pixel.\n- *\n+ /** \n+ * Method: wheelUp\n+ * User spun scroll wheel up\n+ * \n * Parameters:\n- * geometry - {} or {} The\n- * geometry to use when making the query. This should be a closed\n- * polygon for behavior approximating a free selection.\n- * layer - {Object} The ArcIMS layer definition. This is an anonymous object\n- * that looks like:\n- * (code)\n- * {\n- * id: \"ArcXML layer ID\", // the ArcXML layer ID\n- * query: {\n- * where: \"STATE = 'PA'\", // the where clause of the query\n- * accuracy: 100 // the accuracy of the returned feature\n- * }\n- * }\n- * (end)\n- * options - {Object} Object with non-default properties to set on the layer.\n- * Supported properties are buffer, callback, scope, and any other\n- * properties applicable to the ArcXML format. Set the 'callback' and\n- * 'scope' for an object and function to recieve the parsed features\n- * from ArcIMS.\n+ * evt - {Event}\n+ * delta - {Integer}\n */\n- getFeatureInfo: function(geometry, layer, options) {\n- // set the buffer to 1 unit (dd/m/ft?) by default\n- var buffer = options.buffer || 1;\n- // empty callback by default\n- var callback = options.callback || function() {};\n- // default scope is window (global)\n- var scope = options.scope || window;\n+ wheelUp: function(evt, delta) {\n+ this.wheelChange(evt, delta || 1);\n+ },\n \n- // apply these option to the request options\n- var requestOptions = {};\n- OpenLayers.Util.extend(requestOptions, this.options);\n+ /** \n+ * Method: wheelDown\n+ * User spun scroll wheel down\n+ * \n+ * Parameters:\n+ * evt - {Event}\n+ * delta - {Integer}\n+ */\n+ wheelDown: function(evt, delta) {\n+ this.wheelChange(evt, delta || -1);\n+ },\n \n- // this is a feature request\n- requestOptions.requesttype = \"feature\";\n+ /**\n+ * Method: disableZoomBox\n+ */\n+ disableZoomBox: function() {\n+ this.zoomBoxEnabled = false;\n+ this.zoomBox.deactivate();\n+ },\n \n- if (geometry instanceof OpenLayers.LonLat) {\n- // create an envelope if the geometry is really a lon/lat\n- requestOptions.polygon = null;\n- requestOptions.envelope = [\n- geometry.lon - buffer,\n- geometry.lat - buffer,\n- geometry.lon + buffer,\n- geometry.lat + buffer\n- ];\n- } else if (geometry instanceof OpenLayers.Geometry.Polygon) {\n- // use the polygon assigned, and empty the envelope\n- requestOptions.envelope = null;\n- requestOptions.polygon = geometry;\n+ /**\n+ * Method: enableZoomBox\n+ */\n+ enableZoomBox: function() {\n+ this.zoomBoxEnabled = true;\n+ if (this.active) {\n+ this.zoomBox.activate();\n }\n+ },\n \n- // create an arcxml request to get feature requests\n- var arcxml = new OpenLayers.Format.ArcXML(requestOptions);\n+ /**\n+ * Method: disableZoomWheel\n+ */\n \n- // apply any get feature options to the arcxml request\n- OpenLayers.Util.extend(arcxml.request.get_feature, options);\n+ disableZoomWheel: function() {\n+ this.zoomWheelEnabled = false;\n+ this.handlers.wheel.deactivate();\n+ },\n \n- arcxml.request.get_feature.layer = layer.id;\n- if (typeof layer.query.accuracy == \"number\") {\n- // set the accuracy if it was specified\n- arcxml.request.get_feature.query.accuracy = layer.query.accuracy;\n- } else {\n- // guess that the accuracy is 1 per screen pixel\n- var mapCenter = this.map.getCenter();\n- var viewPx = this.map.getViewPortPxFromLonLat(mapCenter);\n- viewPx.x++;\n- var mapOffCenter = this.map.getLonLatFromPixel(viewPx);\n- arcxml.request.get_feature.query.accuracy = mapOffCenter.lon - mapCenter.lon;\n+ /**\n+ * Method: enableZoomWheel\n+ */\n+\n+ enableZoomWheel: function() {\n+ this.zoomWheelEnabled = true;\n+ if (this.active) {\n+ this.handlers.wheel.activate();\n }\n+ },\n \n- // set the get_feature query to be the same as the layer passed in\n- arcxml.request.get_feature.query.where = layer.query.where;\n+ CLASS_NAME: \"OpenLayers.Control.Navigation\"\n+});\n+/* ======================================================================\n+ OpenLayers/Control/NavToolbar.js\n+ ====================================================================== */\n \n- // use area_intersection\n- arcxml.request.get_feature.query.spatialfilter.relation = \"area_intersection\";\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- // create a new asynchronous request to get the feature info\n- OpenLayers.Request.POST({\n- url: this.getFullRequestString({\n- 'CustomService': 'Query'\n- }),\n- data: arcxml.write(),\n- callback: function(request) {\n- // parse the arcxml response\n- var response = arcxml.parseResponse(request.responseText);\n+/**\n+ * @requires OpenLayers/Control/Panel.js\n+ * @requires OpenLayers/Control/Navigation.js\n+ * @requires OpenLayers/Control/ZoomBox.js\n+ */\n \n- if (!arcxml.iserror()) {\n- // if the arcxml is not an error, call the callback with the features parsed\n- callback.call(scope, response.features);\n- } else {\n- // if the arcxml is an error, return null features selected\n- callback.call(scope, null);\n- }\n- }\n- });\n- },\n+/**\n+ * Class: OpenLayers.Control.NavToolbar\n+ * This Toolbar is an alternative to the Navigation control that displays\n+ * the state of the control, and provides a UI for changing state to\n+ * use the zoomBox via a Panel control.\n+ *\n+ * If you wish to change the properties of the Navigation control used\n+ * in the NavToolbar, see: \n+ * http://trac.openlayers.org/wiki/Toolbars#SubclassingNavToolbar \n+ * \n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Control.NavToolbar = OpenLayers.Class(OpenLayers.Control.Panel, {\n \n /**\n- * Method: clone\n- * Create a clone of this layer\n+ * Constructor: OpenLayers.Control.NavToolbar \n+ * Add our two mousedefaults controls.\n *\n- * Returns:\n- * {} An exact clone of this layer\n+ * Parameters:\n+ * options - {Object} An optional object whose properties will be used\n+ * to extend the control.\n */\n- clone: function(obj) {\n+ initialize: function(options) {\n+ OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);\n+ this.addControls([\n+ new OpenLayers.Control.Navigation(),\n+ new OpenLayers.Control.ZoomBox()\n+ ]);\n+ },\n \n- if (obj == null) {\n- obj = new OpenLayers.Layer.ArcIMS(this.name,\n- this.url,\n- this.getOptions());\n+ /**\n+ * Method: draw \n+ * calls the default draw, and then activates mouse defaults.\n+ */\n+ draw: function() {\n+ var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);\n+ if (this.defaultControl === null) {\n+ this.defaultControl = this.controls[0];\n }\n-\n- //get all additions from superclasses\n- obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);\n-\n- // copy/set any non-init, non-simple values here\n-\n- return obj;\n+ return div;\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.ArcIMS\"\n+ CLASS_NAME: \"OpenLayers.Control.NavToolbar\"\n });\n /* ======================================================================\n- OpenLayers/Layer/Image.js\n+ OpenLayers/Control/DrawFeature.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Layer.js\n- * @requires OpenLayers/Tile/Image.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Feature/Vector.js\n */\n \n /**\n- * Class: OpenLayers.Layer.Image\n- * Instances of OpenLayers.Layer.Image are used to display data from a web\n- * accessible image as a map layer. Create a new image layer with the\n- * constructor.\n+ * Class: OpenLayers.Control.DrawFeature\n+ * The DrawFeature control draws point, line or polygon features on a vector\n+ * layer when active.\n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.Image = OpenLayers.Class(OpenLayers.Layer, {\n+OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * Property: isBaseLayer\n- * {Boolean} The layer is a base layer. Default is true. Set this property\n- * in the layer options\n+ * Property: layer\n+ * {}\n */\n- isBaseLayer: true,\n+ layer: null,\n \n /**\n- * Property: url\n- * {String} URL of the image to use\n+ * Property: callbacks\n+ * {Object} The functions that are sent to the handler for callback\n */\n- url: null,\n+ callbacks: null,\n \n- /**\n- * Property: extent\n- * {} The image bounds in map units. This extent will\n- * also be used as the default maxExtent for the layer. If you wish\n- * to have a maxExtent that is different than the image extent, set the\n- * maxExtent property of the options argument (as with any other layer).\n+ /** \n+ * APIProperty: events\n+ * {} Events instance for listeners and triggering\n+ * control specific events.\n+ *\n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * control.events.register(type, obj, listener);\n+ * (end)\n+ *\n+ * Supported event types (in addition to those from ):\n+ * featureadded - Triggered when a feature is added\n */\n- extent: null,\n \n /**\n- * Property: size\n- * {} The image size in pixels\n+ * APIProperty: multi\n+ * {Boolean} Cast features to multi-part geometries before passing to the\n+ * layer. Default is false.\n */\n- size: null,\n+ multi: false,\n \n /**\n- * Property: tile\n- * {}\n+ * APIProperty: featureAdded\n+ * {Function} Called after each feature is added\n */\n- tile: null,\n+ featureAdded: function() {},\n \n /**\n- * Property: aspectRatio\n- * {Float} The ratio of height/width represented by a single pixel in the\n- * graphic\n+ * APIProperty: handlerOptions\n+ * {Object} Used to set non-default properties on the control's handler\n */\n- aspectRatio: null,\n \n /**\n- * Constructor: OpenLayers.Layer.Image\n- * Create a new image layer\n- *\n+ * Constructor: OpenLayers.Control.DrawFeature\n+ * \n * Parameters:\n- * name - {String} A name for the layer.\n- * url - {String} Relative or absolute path to the image\n- * extent - {} The extent represented by the image\n- * size - {} The size (in pixels) of the image\n- * options - {Object} Hashtable of extra options to tag onto the layer\n+ * layer - {} \n+ * handler - {} \n+ * options - {Object} \n */\n- initialize: function(name, url, extent, size, options) {\n- this.url = url;\n- this.extent = extent;\n- this.maxExtent = extent;\n- this.size = size;\n- OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);\n-\n- this.aspectRatio = (this.extent.getHeight() / this.size.h) /\n- (this.extent.getWidth() / this.size.w);\n+ initialize: function(layer, handler, options) {\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+ this.callbacks = OpenLayers.Util.extend({\n+ done: this.drawFeature,\n+ modify: function(vertex, feature) {\n+ this.layer.events.triggerEvent(\n+ \"sketchmodified\", {\n+ vertex: vertex,\n+ feature: feature\n+ }\n+ );\n+ },\n+ create: function(vertex, feature) {\n+ this.layer.events.triggerEvent(\n+ \"sketchstarted\", {\n+ vertex: vertex,\n+ feature: feature\n+ }\n+ );\n+ }\n+ },\n+ this.callbacks\n+ );\n+ this.layer = layer;\n+ this.handlerOptions = this.handlerOptions || {};\n+ this.handlerOptions.layerOptions = OpenLayers.Util.applyDefaults(\n+ this.handlerOptions.layerOptions, {\n+ renderers: layer.renderers,\n+ rendererOptions: layer.rendererOptions\n+ }\n+ );\n+ if (!(\"multi\" in this.handlerOptions)) {\n+ this.handlerOptions.multi = this.multi;\n+ }\n+ var sketchStyle = this.layer.styleMap && this.layer.styleMap.styles.temporary;\n+ if (sketchStyle) {\n+ this.handlerOptions.layerOptions = OpenLayers.Util.applyDefaults(\n+ this.handlerOptions.layerOptions, {\n+ styleMap: new OpenLayers.StyleMap({\n+ \"default\": sketchStyle\n+ })\n+ }\n+ );\n+ }\n+ this.handler = new handler(this, this.callbacks, this.handlerOptions);\n },\n \n /**\n- * Method: destroy\n- * Destroy this layer\n+ * Method: drawFeature\n */\n- destroy: function() {\n- if (this.tile) {\n- this.removeTileMonitoringHooks(this.tile);\n- this.tile.destroy();\n- this.tile = null;\n+ drawFeature: function(geometry) {\n+ var feature = new OpenLayers.Feature.Vector(geometry);\n+ var proceed = this.layer.events.triggerEvent(\n+ \"sketchcomplete\", {\n+ feature: feature\n+ }\n+ );\n+ if (proceed !== false) {\n+ feature.state = OpenLayers.State.INSERT;\n+ this.layer.addFeatures([feature]);\n+ this.featureAdded(feature);\n+ this.events.triggerEvent(\"featureadded\", {\n+ feature: feature\n+ });\n }\n- OpenLayers.Layer.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * Method: clone\n- * Create a clone of this layer\n- *\n- * Paramters:\n- * obj - {Object} An optional layer (is this ever used?)\n+ * APIMethod: insertXY\n+ * Insert a point in the current sketch given x & y coordinates.\n *\n- * Returns:\n- * {} An exact copy of this layer\n+ * Parameters:\n+ * x - {Number} The x-coordinate of the point.\n+ * y - {Number} The y-coordinate of the point.\n */\n- clone: function(obj) {\n-\n- if (obj == null) {\n- obj = new OpenLayers.Layer.Image(this.name,\n- this.url,\n- this.extent,\n- this.size,\n- this.getOptions());\n+ insertXY: function(x, y) {\n+ if (this.handler && this.handler.line) {\n+ this.handler.insertXY(x, y);\n }\n-\n- //get all additions from superclasses\n- obj = OpenLayers.Layer.prototype.clone.apply(this, [obj]);\n-\n- // copy/set any non-init, non-simple values here\n-\n- return obj;\n },\n \n /**\n- * APIMethod: setMap\n- * \n+ * APIMethod: insertDeltaXY\n+ * Insert a point given offsets from the previously inserted point.\n+ *\n * Parameters:\n- * map - {}\n+ * dx - {Number} The x-coordinate offset of the point.\n+ * dy - {Number} The y-coordinate offset of the point.\n */\n- setMap: function(map) {\n- /**\n- * If nothing to do with resolutions has been set, assume a single\n- * resolution determined by ratio*extent/size - if an image has a\n- * pixel aspect ratio different than one (as calculated above), the\n- * image will be stretched in one dimension only.\n- */\n- if (this.options.maxResolution == null) {\n- this.options.maxResolution = this.aspectRatio *\n- this.extent.getWidth() /\n- this.size.w;\n+ insertDeltaXY: function(dx, dy) {\n+ if (this.handler && this.handler.line) {\n+ this.handler.insertDeltaXY(dx, dy);\n }\n- OpenLayers.Layer.prototype.setMap.apply(this, arguments);\n },\n \n- /** \n- * Method: moveTo\n- * Create the tile for the image or resize it for the new resolution\n- * \n+ /**\n+ * APIMethod: insertDirectionLength\n+ * Insert a point in the current sketch given a direction and a length.\n+ *\n * Parameters:\n- * bounds - {}\n- * zoomChanged - {Boolean}\n- * dragging - {Boolean}\n+ * direction - {Number} Degrees clockwise from the positive x-axis.\n+ * length - {Number} Distance from the previously drawn point.\n */\n- moveTo: function(bounds, zoomChanged, dragging) {\n- OpenLayers.Layer.prototype.moveTo.apply(this, arguments);\n-\n- var firstRendering = (this.tile == null);\n-\n- if (zoomChanged || firstRendering) {\n-\n- //determine new tile size\n- this.setTileSize();\n-\n- //determine new position (upper left corner of new bounds)\n- var ulPx = this.map.getLayerPxFromLonLat({\n- lon: this.extent.left,\n- lat: this.extent.top\n- });\n-\n- if (firstRendering) {\n- //create the new tile\n- this.tile = new OpenLayers.Tile.Image(this, ulPx, this.extent,\n- null, this.tileSize);\n- this.addTileMonitoringHooks(this.tile);\n- } else {\n- //just resize the tile and set it's new position\n- this.tile.size = this.tileSize.clone();\n- this.tile.position = ulPx.clone();\n- }\n- this.tile.draw();\n+ insertDirectionLength: function(direction, length) {\n+ if (this.handler && this.handler.line) {\n+ this.handler.insertDirectionLength(direction, length);\n }\n },\n \n /**\n- * Set the tile size based on the map size.\n+ * APIMethod: insertDeflectionLength\n+ * Insert a point in the current sketch given a deflection and a length.\n+ * The deflection should be degrees clockwise from the previously \n+ * digitized segment.\n+ *\n+ * Parameters:\n+ * deflection - {Number} Degrees clockwise from the previous segment.\n+ * length - {Number} Distance from the previously drawn point.\n */\n- setTileSize: function() {\n- var tileWidth = this.extent.getWidth() / this.map.getResolution();\n- var tileHeight = this.extent.getHeight() / this.map.getResolution();\n- this.tileSize = new OpenLayers.Size(tileWidth, tileHeight);\n+ insertDeflectionLength: function(deflection, length) {\n+ if (this.handler && this.handler.line) {\n+ this.handler.insertDeflectionLength(deflection, length);\n+ }\n },\n \n- /** \n- * Method: addTileMonitoringHooks\n- * This function takes a tile as input and adds the appropriate hooks to \n- * the tile so that the layer can keep track of the loading tiles.\n- * \n- * Parameters: \n- * tile - {}\n+ /**\n+ * APIMethod: undo\n+ * Remove the most recently added point in the current sketch geometry.\n+ *\n+ * Returns: \n+ * {Boolean} An edit was undone.\n */\n- addTileMonitoringHooks: function(tile) {\n- tile.onLoadStart = function() {\n- this.events.triggerEvent(\"loadstart\");\n- };\n- tile.events.register(\"loadstart\", this, tile.onLoadStart);\n-\n- tile.onLoadEnd = function() {\n- this.events.triggerEvent(\"loadend\");\n- };\n- tile.events.register(\"loadend\", this, tile.onLoadEnd);\n- tile.events.register(\"unload\", this, tile.onLoadEnd);\n+ undo: function() {\n+ return this.handler.undo && this.handler.undo();\n },\n \n- /** \n- * Method: removeTileMonitoringHooks\n- * This function takes a tile as input and removes the tile hooks \n- * that were added in .\n- * \n- * Parameters: \n- * tile - {}\n+ /**\n+ * APIMethod: redo\n+ * Reinsert the most recently removed point resulting from an call.\n+ * The undo stack is deleted whenever a point is added by other means.\n+ *\n+ * Returns: \n+ * {Boolean} An edit was redone.\n */\n- removeTileMonitoringHooks: function(tile) {\n- tile.unload();\n- tile.events.un({\n- \"loadstart\": tile.onLoadStart,\n- \"loadend\": tile.onLoadEnd,\n- \"unload\": tile.onLoadEnd,\n- scope: this\n- });\n+ redo: function() {\n+ return this.handler.redo && this.handler.redo();\n },\n \n /**\n- * APIMethod: setUrl\n- * \n- * Parameters:\n- * newUrl - {String}\n+ * APIMethod: finishSketch\n+ * Finishes the sketch without including the currently drawn point.\n+ * This method can be called to terminate drawing programmatically\n+ * instead of waiting for the user to end the sketch.\n */\n- setUrl: function(newUrl) {\n- this.url = newUrl;\n- this.tile.draw();\n+ finishSketch: function() {\n+ this.handler.finishGeometry();\n },\n \n- /** \n- * APIMethod: getURL\n- * The url we return is always the same (the image itself never changes)\n- * so we can ignore the bounds parameter (it will always be the same, \n- * anyways) \n- * \n- * Parameters:\n- * bounds - {}\n+ /**\n+ * APIMethod: cancel\n+ * Cancel the current sketch. This removes the current sketch and keeps\n+ * the drawing control active.\n */\n- getURL: function(bounds) {\n- return this.url;\n+ cancel: function() {\n+ this.handler.cancel();\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.Image\"\n+ CLASS_NAME: \"OpenLayers.Control.DrawFeature\"\n });\n /* ======================================================================\n- OpenLayers/Layer/EventPane.js\n+ OpenLayers/Control/EditingToolbar.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+/**\n+ * @requires OpenLayers/Control/Panel.js\n+ * @requires OpenLayers/Control/Navigation.js\n+ * @requires OpenLayers/Control/DrawFeature.js\n+ * @requires OpenLayers/Handler/Point.js\n+ * @requires OpenLayers/Handler/Path.js\n+ * @requires OpenLayers/Handler/Polygon.js\n+ */\n \n /**\n- * @requires OpenLayers/Layer.js\n+ * Class: OpenLayers.Control.EditingToolbar \n+ * The EditingToolbar is a panel of 4 controls to draw polygons, lines, \n+ * points, or to navigate the map by panning. By default it appears in the \n+ * upper right corner of the map.\n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Control.EditingToolbar = OpenLayers.Class(\n+ OpenLayers.Control.Panel, {\n+\n+ /**\n+ * APIProperty: citeCompliant\n+ * {Boolean} If set to true, coordinates of features drawn in a map extent\n+ * crossing the date line won't exceed the world bounds. Default is false.\n+ */\n+ citeCompliant: false,\n+\n+ /**\n+ * Constructor: OpenLayers.Control.EditingToolbar\n+ * Create an editing toolbar for a given layer. \n+ *\n+ * Parameters:\n+ * layer - {} \n+ * options - {Object} \n+ */\n+ initialize: function(layer, options) {\n+ OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);\n+\n+ this.addControls(\n+ [new OpenLayers.Control.Navigation()]\n+ );\n+ var controls = [\n+ new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point, {\n+ displayClass: 'olControlDrawFeaturePoint',\n+ handlerOptions: {\n+ citeCompliant: this.citeCompliant\n+ }\n+ }),\n+ new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path, {\n+ displayClass: 'olControlDrawFeaturePath',\n+ handlerOptions: {\n+ citeCompliant: this.citeCompliant\n+ }\n+ }),\n+ new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Polygon, {\n+ displayClass: 'olControlDrawFeaturePolygon',\n+ handlerOptions: {\n+ citeCompliant: this.citeCompliant\n+ }\n+ })\n+ ];\n+ this.addControls(controls);\n+ },\n+\n+ /**\n+ * Method: draw\n+ * calls the default draw, and then activates mouse defaults.\n+ *\n+ * Returns:\n+ * {DOMElement}\n+ */\n+ draw: function() {\n+ var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);\n+ if (this.defaultControl === null) {\n+ this.defaultControl = this.controls[0];\n+ }\n+ return div;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Control.EditingToolbar\"\n+ });\n+/* ======================================================================\n+ OpenLayers/Control/LayerSwitcher.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Lang.js\n * @requires OpenLayers/Util.js\n+ * @requires OpenLayers/Events/buttonclick.js\n */\n \n /**\n- * Class: OpenLayers.Layer.EventPane\n- * Base class for 3rd party layers, providing a DOM element which isolates\n- * the 3rd-party layer from mouse events.\n- * Only used by Google layers.\n+ * Class: OpenLayers.Control.LayerSwitcher\n+ * The LayerSwitcher control displays a table of contents for the map. This\n+ * allows the user interface to switch between BaseLasyers and to show or hide\n+ * Overlays. By default the switcher is shown minimized on the right edge of\n+ * the map, the user may expand it by clicking on the handle.\n *\n- * Automatically instantiated by the Google constructor, and not usually instantiated directly.\n+ * To create the LayerSwitcher outside of the map, pass the Id of a html div\n+ * as the first argument to the constructor.\n *\n- * Create a new event pane layer with the\n- * constructor.\n- * \n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.EventPane = OpenLayers.Class(OpenLayers.Layer, {\n+OpenLayers.Control.LayerSwitcher = OpenLayers.Class(OpenLayers.Control, {\n+\n+ /** \n+ * Property: layerStates \n+ * {Array(Object)} Basically a copy of the \"state\" of the map's layers \n+ * the last time the control was drawn. We have this in order to avoid\n+ * unnecessarily redrawing the control.\n+ */\n+ layerStates: null,\n+\n+ // DOM Elements\n \n /**\n- * APIProperty: smoothDragPan\n- * {Boolean} smoothDragPan determines whether non-public/internal API\n- * methods are used for better performance while dragging EventPane \n- * layers. When not in sphericalMercator mode, the smoother dragging \n- * doesn't actually move north/south directly with the number of \n- * pixels moved, resulting in a slight offset when you drag your mouse \n- * north south with this option on. If this visual disparity bothers \n- * you, you should turn this option off, or use spherical mercator. \n- * Default is on.\n+ * Property: layersDiv\n+ * {DOMElement}\n */\n- smoothDragPan: true,\n+ layersDiv: null,\n \n /**\n- * Property: isBaseLayer\n- * {Boolean} EventPaned layers are always base layers, by necessity.\n+ * Property: baseLayersDiv\n+ * {DOMElement}\n */\n- isBaseLayer: true,\n+ baseLayersDiv: null,\n \n /**\n- * APIProperty: isFixed\n- * {Boolean} EventPaned layers are fixed by default.\n+ * Property: baseLayers\n+ * {Array(Object)}\n */\n- isFixed: true,\n+ baseLayers: null,\n+\n \n /**\n- * Property: pane\n- * {DOMElement} A reference to the element that controls the events.\n+ * Property: dataLbl\n+ * {DOMElement}\n */\n- pane: null,\n+ dataLbl: null,\n \n+ /**\n+ * Property: dataLayersDiv\n+ * {DOMElement}\n+ */\n+ dataLayersDiv: null,\n \n /**\n- * Property: mapObject\n- * {Object} This is the object which will be used to load the 3rd party library\n- * in the case of the google layer, this will be of type GMap, \n- * in the case of the ve layer, this will be of type VEMap\n+ * Property: dataLayers\n+ * {Array(Object)}\n */\n- mapObject: null,\n+ dataLayers: null,\n \n \n /**\n- * Constructor: OpenLayers.Layer.EventPane\n- * Create a new event pane layer\n- *\n- * Parameters:\n- * name - {String}\n- * options - {Object} Hashtable of extra options to tag onto the layer\n+ * Property: minimizeDiv\n+ * {DOMElement}\n */\n- initialize: function(name, options) {\n- OpenLayers.Layer.prototype.initialize.apply(this, arguments);\n- if (this.pane == null) {\n- this.pane = OpenLayers.Util.createDiv(this.div.id + \"_EventPane\");\n- }\n- },\n+ minimizeDiv: null,\n \n /**\n- * APIMethod: destroy\n- * Deconstruct this layer.\n+ * Property: maximizeDiv\n+ * {DOMElement}\n */\n- destroy: function() {\n- this.mapObject = null;\n- this.pane = null;\n- OpenLayers.Layer.prototype.destroy.apply(this, arguments);\n- },\n+ maximizeDiv: null,\n \n+ /**\n+ * APIProperty: ascending\n+ * {Boolean}\n+ */\n+ ascending: true,\n \n /**\n- * Method: setMap\n- * Set the map property for the layer. This is done through an accessor\n- * so that subclasses can override this and take special action once \n- * they have their map variable set. \n+ * Constructor: OpenLayers.Control.LayerSwitcher\n *\n * Parameters:\n- * map - {}\n+ * options - {Object}\n */\n- setMap: function(map) {\n- OpenLayers.Layer.prototype.setMap.apply(this, arguments);\n+ initialize: function(options) {\n+ OpenLayers.Control.prototype.initialize.apply(this, arguments);\n+ this.layerStates = [];\n+ },\n \n- this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1;\n- this.pane.style.display = this.div.style.display;\n- this.pane.style.width = \"100%\";\n- this.pane.style.height = \"100%\";\n- if (OpenLayers.BROWSER_NAME == \"msie\") {\n- this.pane.style.background =\n- \"url(\" + OpenLayers.Util.getImageLocation(\"blank.gif\") + \")\";\n- }\n+ /**\n+ * APIMethod: destroy\n+ */\n+ destroy: function() {\n \n- if (this.isFixed) {\n- this.map.viewPortDiv.appendChild(this.pane);\n- } else {\n- this.map.layerContainerDiv.appendChild(this.pane);\n- }\n+ //clear out layers info and unregister their events\n+ this.clearLayersArray(\"base\");\n+ this.clearLayersArray(\"data\");\n \n- // once our layer has been added to the map, we can load it\n- this.loadMapObject();\n+ this.map.events.un({\n+ buttonclick: this.onButtonClick,\n+ addlayer: this.redraw,\n+ changelayer: this.redraw,\n+ removelayer: this.redraw,\n+ changebaselayer: this.redraw,\n+ scope: this\n+ });\n+ this.events.unregister(\"buttonclick\", this, this.onButtonClick);\n \n- // if map didn't load, display warning\n- if (this.mapObject == null) {\n- this.loadWarningMessage();\n- }\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * APIMethod: removeMap\n- * On being removed from the map, we'll like to remove the invisible 'pane'\n- * div that we added to it on creation. \n- * \n- * Parameters:\n+ * Method: setMap\n+ *\n+ * Properties:\n * map - {}\n */\n- removeMap: function(map) {\n- if (this.pane && this.pane.parentNode) {\n- this.pane.parentNode.removeChild(this.pane);\n+ setMap: function(map) {\n+ OpenLayers.Control.prototype.setMap.apply(this, arguments);\n+\n+ this.map.events.on({\n+ addlayer: this.redraw,\n+ changelayer: this.redraw,\n+ removelayer: this.redraw,\n+ changebaselayer: this.redraw,\n+ scope: this\n+ });\n+ if (this.outsideViewport) {\n+ this.events.attachToElement(this.div);\n+ this.events.register(\"buttonclick\", this, this.onButtonClick);\n+ } else {\n+ this.map.events.register(\"buttonclick\", this, this.onButtonClick);\n }\n- OpenLayers.Layer.prototype.removeMap.apply(this, arguments);\n },\n \n /**\n- * Method: loadWarningMessage\n- * If we can't load the map lib, then display an error message to the \n- * user and tell them where to go for help.\n- * \n- * This function sets up the layout for the warning message. Each 3rd\n- * party layer must implement its own getWarningHTML() function to \n- * provide the actual warning message.\n+ * Method: draw\n+ *\n+ * Returns:\n+ * {DOMElement} A reference to the DIV DOMElement containing the\n+ * switcher tabs.\n */\n- loadWarningMessage: function() {\n-\n- this.div.style.backgroundColor = \"darkblue\";\n-\n- var viewSize = this.map.getSize();\n-\n- var msgW = Math.min(viewSize.w, 300);\n- var msgH = Math.min(viewSize.h, 200);\n- var size = new OpenLayers.Size(msgW, msgH);\n-\n- var centerPx = new OpenLayers.Pixel(viewSize.w / 2, viewSize.h / 2);\n-\n- var topLeft = centerPx.add(-size.w / 2, -size.h / 2);\n+ draw: function() {\n+ OpenLayers.Control.prototype.draw.apply(this);\n \n- var div = OpenLayers.Util.createDiv(this.name + \"_warning\",\n- topLeft,\n- size,\n- null,\n- null,\n- null,\n- \"auto\");\n+ // create layout divs\n+ this.loadContents();\n \n- div.style.padding = \"7px\";\n- div.style.backgroundColor = \"yellow\";\n+ // set mode to minimize\n+ if (!this.outsideViewport) {\n+ this.minimizeControl();\n+ }\n \n- div.innerHTML = this.getWarningHTML();\n- this.div.appendChild(div);\n- },\n+ // populate div with current info\n+ this.redraw();\n \n- /** \n- * Method: getWarningHTML\n- * To be implemented by subclasses.\n- * \n- * Returns:\n- * {String} String with information on why layer is broken, how to get\n- * it working.\n- */\n- getWarningHTML: function() {\n- //should be implemented by subclasses\n- return \"\";\n+ return this.div;\n },\n \n /**\n- * Method: display\n- * Set the display on the pane\n+ * Method: onButtonClick\n *\n * Parameters:\n- * display - {Boolean}\n+ * evt - {Event}\n */\n- display: function(display) {\n- OpenLayers.Layer.prototype.display.apply(this, arguments);\n- this.pane.style.display = this.div.style.display;\n+ onButtonClick: function(evt) {\n+ var button = evt.buttonElement;\n+ if (button === this.minimizeDiv) {\n+ this.minimizeControl();\n+ } else if (button === this.maximizeDiv) {\n+ this.maximizeControl();\n+ } else if (button._layerSwitcher === this.id) {\n+ if (button[\"for\"]) {\n+ button = document.getElementById(button[\"for\"]);\n+ }\n+ if (!button.disabled) {\n+ if (button.type == \"radio\") {\n+ button.checked = true;\n+ this.map.setBaseLayer(this.map.getLayer(button._layer));\n+ } else {\n+ button.checked = !button.checked;\n+ this.updateMap();\n+ }\n+ }\n+ }\n },\n \n /**\n- * Method: setZIndex\n- * Set the z-index order for the pane.\n- * \n+ * Method: clearLayersArray\n+ * User specifies either \"base\" or \"data\". we then clear all the\n+ * corresponding listeners, the div, and reinitialize a new array.\n+ *\n * Parameters:\n- * zIndex - {int}\n+ * layersType - {String}\n */\n- setZIndex: function(zIndex) {\n- OpenLayers.Layer.prototype.setZIndex.apply(this, arguments);\n- this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1;\n+ clearLayersArray: function(layersType) {\n+ this[layersType + \"LayersDiv\"].innerHTML = \"\";\n+ this[layersType + \"Layers\"] = [];\n },\n \n+\n /**\n- * Method: moveByPx\n- * Move the layer based on pixel vector. To be implemented by subclasses.\n+ * Method: checkRedraw\n+ * Checks if the layer state has changed since the last redraw() call.\n *\n- * Parameters:\n- * dx - {Number} The x coord of the displacement vector.\n- * dy - {Number} The y coord of the displacement vector.\n+ * Returns:\n+ * {Boolean} The layer state changed since the last redraw() call.\n */\n- moveByPx: function(dx, dy) {\n- OpenLayers.Layer.prototype.moveByPx.apply(this, arguments);\n+ checkRedraw: function() {\n+ if (!this.layerStates.length ||\n+ (this.map.layers.length != this.layerStates.length)) {\n+ return true;\n+ }\n \n- if (this.dragPanMapObject) {\n- this.dragPanMapObject(dx, -dy);\n- } else {\n- this.moveTo(this.map.getCachedCenter());\n+ for (var i = 0, len = this.layerStates.length; i < len; i++) {\n+ var layerState = this.layerStates[i];\n+ var layer = this.map.layers[i];\n+ if ((layerState.name != layer.name) ||\n+ (layerState.inRange != layer.inRange) ||\n+ (layerState.id != layer.id) ||\n+ (layerState.visibility != layer.visibility)) {\n+ return true;\n+ }\n }\n+\n+ return false;\n },\n \n /**\n- * Method: moveTo\n- * Handle calls to move the layer.\n- * \n- * Parameters:\n- * bounds - {}\n- * zoomChanged - {Boolean}\n- * dragging - {Boolean}\n+ * Method: redraw\n+ * Goes through and takes the current state of the Map and rebuilds the\n+ * control to display that state. Groups base layers into a\n+ * radio-button group and lists each data layer with a checkbox.\n+ *\n+ * Returns:\n+ * {DOMElement} A reference to the DIV DOMElement containing the control\n */\n- moveTo: function(bounds, zoomChanged, dragging) {\n- OpenLayers.Layer.prototype.moveTo.apply(this, arguments);\n+ redraw: function() {\n+ //if the state hasn't changed since last redraw, no need\n+ // to do anything. Just return the existing div.\n+ if (!this.checkRedraw()) {\n+ return this.div;\n+ }\n \n- if (this.mapObject != null) {\n+ //clear out previous layers\n+ this.clearLayersArray(\"base\");\n+ this.clearLayersArray(\"data\");\n \n- var newCenter = this.map.getCenter();\n- var newZoom = this.map.getZoom();\n+ var containsOverlays = false;\n+ var containsBaseLayers = false;\n \n- if (newCenter != null) {\n+ // Save state -- for checking layer if the map state changed.\n+ // We save this before redrawing, because in the process of redrawing\n+ // we will trigger more visibility changes, and we want to not redraw\n+ // and enter an infinite loop.\n+ var len = this.map.layers.length;\n+ this.layerStates = new Array(len);\n+ for (var i = 0; i < len; i++) {\n+ var layer = this.map.layers[i];\n+ this.layerStates[i] = {\n+ 'name': layer.name,\n+ 'visibility': layer.visibility,\n+ 'inRange': layer.inRange,\n+ 'id': layer.id\n+ };\n+ }\n \n- var moOldCenter = this.getMapObjectCenter();\n- var oldCenter = this.getOLLonLatFromMapObjectLonLat(moOldCenter);\n+ var layers = this.map.layers.slice();\n+ if (!this.ascending) {\n+ layers.reverse();\n+ }\n+ for (var i = 0, len = layers.length; i < len; i++) {\n+ var layer = layers[i];\n+ var baseLayer = layer.isBaseLayer;\n \n- var moOldZoom = this.getMapObjectZoom();\n- var oldZoom = this.getOLZoomFromMapObjectZoom(moOldZoom);\n+ if (layer.displayInLayerSwitcher) {\n \n- if (!(newCenter.equals(oldCenter)) || newZoom != oldZoom) {\n+ if (baseLayer) {\n+ containsBaseLayers = true;\n+ } else {\n+ containsOverlays = true;\n+ }\n \n- if (!zoomChanged && oldCenter && this.dragPanMapObject &&\n- this.smoothDragPan) {\n- var oldPx = this.map.getViewPortPxFromLonLat(oldCenter);\n- var newPx = this.map.getViewPortPxFromLonLat(newCenter);\n- this.dragPanMapObject(newPx.x - oldPx.x, oldPx.y - newPx.y);\n- } else {\n- var center = this.getMapObjectLonLatFromOLLonLat(newCenter);\n- var zoom = this.getMapObjectZoomFromOLZoom(newZoom);\n- this.setMapObjectCenter(center, zoom, dragging);\n- }\n+ // only check a baselayer if it is *the* baselayer, check data\n+ // layers if they are visible\n+ var checked = (baseLayer) ? (layer == this.map.baseLayer) :\n+ layer.getVisibility();\n+\n+ // create input element\n+ var inputElem = document.createElement(\"input\"),\n+ // The input shall have an id attribute so we can use\n+ // labels to interact with them.\n+ inputId = OpenLayers.Util.createUniqueID(\n+ this.id + \"_input_\"\n+ );\n+\n+ inputElem.id = inputId;\n+ inputElem.name = (baseLayer) ? this.id + \"_baseLayers\" : layer.name;\n+ inputElem.type = (baseLayer) ? \"radio\" : \"checkbox\";\n+ inputElem.value = layer.name;\n+ inputElem.checked = checked;\n+ inputElem.defaultChecked = checked;\n+ inputElem.className = \"olButton\";\n+ inputElem._layer = layer.id;\n+ inputElem._layerSwitcher = this.id;\n+\n+ if (!baseLayer && !layer.inRange) {\n+ inputElem.disabled = true;\n+ }\n+\n+ // create span\n+ var labelSpan = document.createElement(\"label\");\n+ // this isn't the DOM attribute 'for', but an arbitrary name we\n+ // use to find the appropriate input element in \n+ labelSpan[\"for\"] = inputElem.id;\n+ OpenLayers.Element.addClass(labelSpan, \"labelSpan olButton\");\n+ labelSpan._layer = layer.id;\n+ labelSpan._layerSwitcher = this.id;\n+ if (!baseLayer && !layer.inRange) {\n+ labelSpan.style.color = \"gray\";\n }\n+ labelSpan.innerHTML = layer.name;\n+ labelSpan.style.verticalAlign = (baseLayer) ? \"bottom\" :\n+ \"baseline\";\n+ // create line break\n+ var br = document.createElement(\"br\");\n+\n+\n+ var groupArray = (baseLayer) ? this.baseLayers :\n+ this.dataLayers;\n+ groupArray.push({\n+ 'layer': layer,\n+ 'inputElem': inputElem,\n+ 'labelSpan': labelSpan\n+ });\n+\n+\n+ var groupDiv = (baseLayer) ? this.baseLayersDiv :\n+ this.dataLayersDiv;\n+ groupDiv.appendChild(inputElem);\n+ groupDiv.appendChild(labelSpan);\n+ groupDiv.appendChild(br);\n }\n }\n- },\n \n+ // if no overlays, dont display the overlay label\n+ this.dataLbl.style.display = (containsOverlays) ? \"\" : \"none\";\n \n- /********************************************************/\n- /* */\n- /* Baselayer Functions */\n- /* */\n- /********************************************************/\n+ // if no baselayers, dont display the baselayer label\n+ this.baseLbl.style.display = (containsBaseLayers) ? \"\" : \"none\";\n+\n+ return this.div;\n+ },\n \n /**\n- * Method: getLonLatFromViewPortPx\n- * Get a map location from a pixel location\n- * \n- * Parameters:\n- * viewPortPx - {}\n- *\n- * Returns:\n- * {} An OpenLayers.LonLat which is the passed-in view\n- * port OpenLayers.Pixel, translated into lon/lat by map lib\n- * If the map lib is not loaded or not centered, returns null\n+ * Method: updateMap\n+ * Cycles through the loaded data and base layer input arrays and makes\n+ * the necessary calls to the Map object such that that the map's\n+ * visual state corresponds to what the user has selected in\n+ * the control.\n */\n- getLonLatFromViewPortPx: function(viewPortPx) {\n- var lonlat = null;\n- if ((this.mapObject != null) &&\n- (this.getMapObjectCenter() != null)) {\n- var moPixel = this.getMapObjectPixelFromOLPixel(viewPortPx);\n- var moLonLat = this.getMapObjectLonLatFromMapObjectPixel(moPixel);\n- lonlat = this.getOLLonLatFromMapObjectLonLat(moLonLat);\n+ updateMap: function() {\n+\n+ // set the newly selected base layer\n+ for (var i = 0, len = this.baseLayers.length; i < len; i++) {\n+ var layerEntry = this.baseLayers[i];\n+ if (layerEntry.inputElem.checked) {\n+ this.map.setBaseLayer(layerEntry.layer, false);\n+ }\n+ }\n+\n+ // set the correct visibilities for the overlays\n+ for (var i = 0, len = this.dataLayers.length; i < len; i++) {\n+ var layerEntry = this.dataLayers[i];\n+ layerEntry.layer.setVisibility(layerEntry.inputElem.checked);\n }\n- return lonlat;\n- },\n \n+ },\n \n /**\n- * Method: getViewPortPxFromLonLat\n- * Get a pixel location from a map location\n+ * Method: maximizeControl\n+ * Set up the labels and divs for the control\n *\n * Parameters:\n- * lonlat - {}\n- *\n- * Returns:\n- * {} An OpenLayers.Pixel which is the passed-in\n- * OpenLayers.LonLat, translated into view port pixels by map lib\n- * If map lib is not loaded or not centered, returns null\n+ * e - {Event}\n */\n- getViewPortPxFromLonLat: function(lonlat) {\n- var viewPortPx = null;\n- if ((this.mapObject != null) &&\n- (this.getMapObjectCenter() != null)) {\n+ maximizeControl: function(e) {\n \n- var moLonLat = this.getMapObjectLonLatFromOLLonLat(lonlat);\n- var moPixel = this.getMapObjectPixelFromMapObjectLonLat(moLonLat);\n+ // set the div's width and height to empty values, so\n+ // the div dimensions can be controlled by CSS\n+ this.div.style.width = \"\";\n+ this.div.style.height = \"\";\n \n- viewPortPx = this.getOLPixelFromMapObjectPixel(moPixel);\n+ this.showControls(false);\n+\n+ if (e != null) {\n+ OpenLayers.Event.stop(e);\n }\n- return viewPortPx;\n },\n \n- /********************************************************/\n- /* */\n- /* Translation Functions */\n- /* */\n- /* The following functions translate Map Object and */\n- /* OL formats for Pixel, LonLat */\n- /* */\n- /********************************************************/\n-\n- //\n- // TRANSLATION: MapObject LatLng <-> OpenLayers.LonLat\n- //\n-\n /**\n- * Method: getOLLonLatFromMapObjectLonLat\n- * Get an OL style map location from a 3rd party style map location\n+ * Method: minimizeControl\n+ * Hide all the contents of the control, shrink the size,\n+ * add the maximize icon\n *\n- * Parameters\n- * moLonLat - {Object}\n- * \n- * Returns:\n- * {} An OpenLayers.LonLat, translated from the passed in \n- * MapObject LonLat\n- * Returns null if null value is passed in\n+ * Parameters:\n+ * e - {Event}\n */\n- getOLLonLatFromMapObjectLonLat: function(moLonLat) {\n- var olLonLat = null;\n- if (moLonLat != null) {\n- var lon = this.getLongitudeFromMapObjectLonLat(moLonLat);\n- var lat = this.getLatitudeFromMapObjectLonLat(moLonLat);\n- olLonLat = new OpenLayers.LonLat(lon, lat);\n+ minimizeControl: function(e) {\n+\n+ // to minimize the control we set its div's width\n+ // and height to 0px, we cannot just set \"display\"\n+ // to \"none\" because it would hide the maximize\n+ // div\n+ this.div.style.width = \"0px\";\n+ this.div.style.height = \"0px\";\n+\n+ this.showControls(true);\n+\n+ if (e != null) {\n+ OpenLayers.Event.stop(e);\n }\n- return olLonLat;\n },\n \n /**\n- * Method: getMapObjectLonLatFromOLLonLat\n- * Get a 3rd party map location from an OL map location.\n+ * Method: showControls\n+ * Hide/Show all LayerSwitcher controls depending on whether we are\n+ * minimized or not\n *\n * Parameters:\n- * olLonLat - {}\n- * \n- * Returns:\n- * {Object} A MapObject LonLat, translated from the passed in \n- * OpenLayers.LonLat\n- * Returns null if null value is passed in\n+ * minimize - {Boolean}\n */\n- getMapObjectLonLatFromOLLonLat: function(olLonLat) {\n- var moLatLng = null;\n- if (olLonLat != null) {\n- moLatLng = this.getMapObjectLonLatFromLonLat(olLonLat.lon,\n- olLonLat.lat);\n- }\n- return moLatLng;\n- },\n+ showControls: function(minimize) {\n \n+ this.maximizeDiv.style.display = minimize ? \"\" : \"none\";\n+ this.minimizeDiv.style.display = minimize ? \"none\" : \"\";\n \n- //\n- // TRANSLATION: MapObject Pixel <-> OpenLayers.Pixel\n- //\n-\n- /**\n- * Method: getOLPixelFromMapObjectPixel\n- * Get an OL pixel location from a 3rd party pixel location.\n- *\n- * Parameters:\n- * moPixel - {Object}\n- * \n- * Returns:\n- * {} An OpenLayers.Pixel, translated from the passed in \n- * MapObject Pixel\n- * Returns null if null value is passed in\n- */\n- getOLPixelFromMapObjectPixel: function(moPixel) {\n- var olPixel = null;\n- if (moPixel != null) {\n- var x = this.getXFromMapObjectPixel(moPixel);\n- var y = this.getYFromMapObjectPixel(moPixel);\n- olPixel = new OpenLayers.Pixel(x, y);\n- }\n- return olPixel;\n+ this.layersDiv.style.display = minimize ? \"none\" : \"\";\n },\n \n /**\n- * Method: getMapObjectPixelFromOLPixel\n- * Get a 3rd party pixel location from an OL pixel location\n- *\n- * Parameters:\n- * olPixel - {}\n- * \n- * Returns:\n- * {Object} A MapObject Pixel, translated from the passed in \n- * OpenLayers.Pixel\n- * Returns null if null value is passed in\n+ * Method: loadContents\n+ * Set up the labels and divs for the control\n */\n- getMapObjectPixelFromOLPixel: function(olPixel) {\n- var moPixel = null;\n- if (olPixel != null) {\n- moPixel = this.getMapObjectPixelFromXY(olPixel.x, olPixel.y);\n+ loadContents: function() {\n+\n+ // layers list div\n+ this.layersDiv = document.createElement(\"div\");\n+ this.layersDiv.id = this.id + \"_layersDiv\";\n+ OpenLayers.Element.addClass(this.layersDiv, \"layersDiv\");\n+\n+ this.baseLbl = document.createElement(\"div\");\n+ this.baseLbl.innerHTML = OpenLayers.i18n(\"Base Layer\");\n+ OpenLayers.Element.addClass(this.baseLbl, \"baseLbl\");\n+\n+ this.baseLayersDiv = document.createElement(\"div\");\n+ OpenLayers.Element.addClass(this.baseLayersDiv, \"baseLayersDiv\");\n+\n+ this.dataLbl = document.createElement(\"div\");\n+ this.dataLbl.innerHTML = OpenLayers.i18n(\"Overlays\");\n+ OpenLayers.Element.addClass(this.dataLbl, \"dataLbl\");\n+\n+ this.dataLayersDiv = document.createElement(\"div\");\n+ OpenLayers.Element.addClass(this.dataLayersDiv, \"dataLayersDiv\");\n+\n+ if (this.ascending) {\n+ this.layersDiv.appendChild(this.baseLbl);\n+ this.layersDiv.appendChild(this.baseLayersDiv);\n+ this.layersDiv.appendChild(this.dataLbl);\n+ this.layersDiv.appendChild(this.dataLayersDiv);\n+ } else {\n+ this.layersDiv.appendChild(this.dataLbl);\n+ this.layersDiv.appendChild(this.dataLayersDiv);\n+ this.layersDiv.appendChild(this.baseLbl);\n+ this.layersDiv.appendChild(this.baseLayersDiv);\n }\n- return moPixel;\n+\n+ this.div.appendChild(this.layersDiv);\n+\n+ // maximize button div\n+ var img = OpenLayers.Util.getImageLocation('layer-switcher-maximize.png');\n+ this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(\n+ \"OpenLayers_Control_MaximizeDiv\",\n+ null,\n+ null,\n+ img,\n+ \"absolute\");\n+ OpenLayers.Element.addClass(this.maximizeDiv, \"maximizeDiv olButton\");\n+ this.maximizeDiv.style.display = \"none\";\n+\n+ this.div.appendChild(this.maximizeDiv);\n+\n+ // minimize button div\n+ var img = OpenLayers.Util.getImageLocation('layer-switcher-minimize.png');\n+ this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv(\n+ \"OpenLayers_Control_MinimizeDiv\",\n+ null,\n+ null,\n+ img,\n+ \"absolute\");\n+ OpenLayers.Element.addClass(this.minimizeDiv, \"minimizeDiv olButton\");\n+ this.minimizeDiv.style.display = \"none\";\n+\n+ this.div.appendChild(this.minimizeDiv);\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.EventPane\"\n+ CLASS_NAME: \"OpenLayers.Control.LayerSwitcher\"\n });\n /* ======================================================================\n- OpenLayers/Layer/Zoomify.js\n+ OpenLayers/Control/OverviewMap.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-/*\n- * Development supported by a R&D grant DC08P02OUK006 - Old Maps Online\n- * (www.oldmapsonline.org) from Ministry of Culture of the Czech Republic.\n- */\n-\n-\n-/**\n- * @requires OpenLayers/Layer/Grid.js\n+/** \n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/BaseTypes.js\n+ * @requires OpenLayers/Events/buttonclick.js\n+ * @requires OpenLayers/Map.js\n+ * @requires OpenLayers/Handler/Click.js\n+ * @requires OpenLayers/Handler/Drag.js\n */\n \n /**\n- * Class: OpenLayers.Layer.Zoomify\n+ * Class: OpenLayers.Control.OverviewMap\n+ * The OverMap control creates a small overview map, useful to display the \n+ * extent of a zoomed map and your main map and provide additional \n+ * navigation options to the User. By default the overview map is drawn in\n+ * the lower right corner of the main map. Create a new overview map with the\n+ * constructor.\n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.Zoomify = OpenLayers.Class(OpenLayers.Layer.Grid, {\n+OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * Property: size\n- * {} The Zoomify image size in pixels.\n+ * Property: element\n+ * {DOMElement} The DOM element that contains the overview map\n */\n- size: null,\n+ element: null,\n \n /**\n- * APIProperty: isBaseLayer\n- * {Boolean}\n+ * APIProperty: ovmap\n+ * {} A reference to the overview map itself.\n */\n- isBaseLayer: true,\n+ ovmap: null,\n \n /**\n- * Property: standardTileSize\n- * {Integer} The size of a standard (non-border) square tile in pixels.\n+ * APIProperty: size\n+ * {} The overvew map size in pixels. Note that this is\n+ * the size of the map itself - the element that contains the map (default\n+ * class name olControlOverviewMapElement) may have padding or other style\n+ * attributes added via CSS.\n */\n- standardTileSize: 256,\n+ size: {\n+ w: 180,\n+ h: 90\n+ },\n \n- /** \n- * Property: tileOriginCorner\n- * {String} This layer uses top-left as tile origin\n- **/\n- tileOriginCorner: \"tl\",\n+ /**\n+ * APIProperty: layers\n+ * {Array()} Ordered list of layers in the overview map.\n+ * If none are sent at construction, the base layer for the main map is used.\n+ */\n+ layers: null,\n \n /**\n- * Property: numberOfTiers\n- * {Integer} Depth of the Zoomify pyramid, number of tiers (zoom levels)\n- * - filled during Zoomify pyramid initialization.\n+ * APIProperty: minRectSize\n+ * {Integer} The minimum width or height (in pixels) of the extent\n+ * rectangle on the overview map. When the extent rectangle reaches\n+ * this size, it will be replaced depending on the value of the\n+ * property. Default is 15 pixels.\n */\n- numberOfTiers: 0,\n+ minRectSize: 15,\n \n /**\n- * Property: tileCountUpToTier\n- * {Array(Integer)} Number of tiles up to the given tier of pyramid.\n- * - filled during Zoomify pyramid initialization.\n+ * APIProperty: minRectDisplayClass\n+ * {String} Replacement style class name for the extent rectangle when\n+ * is reached. This string will be suffixed on to the\n+ * displayClass. Default is \"RectReplacement\".\n+ *\n+ * Example CSS declaration:\n+ * (code)\n+ * .olControlOverviewMapRectReplacement {\n+ * overflow: hidden;\n+ * cursor: move;\n+ * background-image: url(\"img/overview_replacement.gif\");\n+ * background-repeat: no-repeat;\n+ * background-position: center;\n+ * }\n+ * (end)\n */\n- tileCountUpToTier: null,\n+ minRectDisplayClass: \"RectReplacement\",\n \n /**\n- * Property: tierSizeInTiles\n- * {Array()} Size (in tiles) for each tier of pyramid.\n- * - filled during Zoomify pyramid initialization.\n+ * APIProperty: minRatio\n+ * {Float} The ratio of the overview map resolution to the main map\n+ * resolution at which to zoom farther out on the overview map.\n */\n- tierSizeInTiles: null,\n+ minRatio: 8,\n \n /**\n- * Property: tierImageSize\n- * {Array()} Image size in pixels for each pyramid tier.\n- * - filled during Zoomify pyramid initialization.\n+ * APIProperty: maxRatio\n+ * {Float} The ratio of the overview map resolution to the main map\n+ * resolution at which to zoom farther in on the overview map.\n */\n- tierImageSize: null,\n+ maxRatio: 32,\n \n /**\n- * Constructor: OpenLayers.Layer.Zoomify\n- *\n- * Parameters:\n- * name - {String} A name for the layer.\n- * url - {String} - Relative or absolute path to the image or more\n- * precisly to the TileGroup[X] directories root.\n- * Flash plugin use the variable name \"zoomifyImagePath\" for this.\n- * size - {} The size (in pixels) of the image.\n- * options - {Object} Hashtable of extra options to tag onto the layer\n+ * APIProperty: mapOptions\n+ * {Object} An object containing any non-default properties to be sent to\n+ * the overview map's map constructor. These should include any\n+ * non-default options that the main map was constructed with.\n */\n- initialize: function(name, url, size, options) {\n+ mapOptions: null,\n \n- // initilize the Zoomify pyramid for given size\n- this.initializeZoomify(size);\n+ /**\n+ * APIProperty: autoPan\n+ * {Boolean} Always pan the overview map, so the extent marker remains in\n+ * the center. Default is false. If true, when you drag the extent\n+ * marker, the overview map will update itself so the marker returns\n+ * to the center.\n+ */\n+ autoPan: false,\n \n- OpenLayers.Layer.Grid.prototype.initialize.apply(this, [\n- name, url, size, {},\n- options\n- ]);\n- },\n+ /**\n+ * Property: handlers\n+ * {Object}\n+ */\n+ handlers: null,\n \n /**\n- * Method: initializeZoomify\n- * It generates constants for all tiers of the Zoomify pyramid\n+ * Property: resolutionFactor\n+ * {Object}\n+ */\n+ resolutionFactor: 1,\n+\n+ /**\n+ * APIProperty: maximized\n+ * {Boolean} Start as maximized (visible). Defaults to false.\n+ */\n+ maximized: false,\n+\n+ /**\n+ * APIProperty: maximizeTitle\n+ * {String} This property is used for showing a tooltip over the \n+ * maximize div. Defaults to \"\" (no title).\n+ */\n+ maximizeTitle: \"\",\n+\n+ /**\n+ * APIProperty: minimizeTitle\n+ * {String} This property is used for showing a tooltip over the \n+ * minimize div. Defaults to \"\" (no title).\n+ */\n+ minimizeTitle: \"\",\n+\n+ /**\n+ * Constructor: OpenLayers.Control.OverviewMap\n+ * Create a new overview map\n *\n * Parameters:\n- * size - {} The size of the image in pixels\n- *\n+ * options - {Object} Properties of this object will be set on the overview\n+ * map object. Note, to set options on the map object contained in this\n+ * control, set as one of the options properties.\n */\n- initializeZoomify: function(size) {\n+ initialize: function(options) {\n+ this.layers = [];\n+ this.handlers = {};\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+ },\n \n- var imageSize = size.clone();\n- this.size = size.clone();\n- var tiles = new OpenLayers.Size(\n- Math.ceil(imageSize.w / this.standardTileSize),\n- Math.ceil(imageSize.h / this.standardTileSize)\n- );\n+ /**\n+ * APIMethod: destroy\n+ * Deconstruct the control\n+ */\n+ destroy: function() {\n+ if (!this.mapDiv) { // we've already been destroyed\n+ return;\n+ }\n+ if (this.handlers.click) {\n+ this.handlers.click.destroy();\n+ }\n+ if (this.handlers.drag) {\n+ this.handlers.drag.destroy();\n+ }\n \n- this.tierSizeInTiles = [tiles];\n- this.tierImageSize = [imageSize];\n+ this.ovmap && this.ovmap.viewPortDiv.removeChild(this.extentRectangle);\n+ this.extentRectangle = null;\n \n- while (imageSize.w > this.standardTileSize ||\n- imageSize.h > this.standardTileSize) {\n+ if (this.rectEvents) {\n+ this.rectEvents.destroy();\n+ this.rectEvents = null;\n+ }\n \n- imageSize = new OpenLayers.Size(\n- Math.floor(imageSize.w / 2),\n- Math.floor(imageSize.h / 2)\n- );\n- tiles = new OpenLayers.Size(\n- Math.ceil(imageSize.w / this.standardTileSize),\n- Math.ceil(imageSize.h / this.standardTileSize)\n- );\n- this.tierSizeInTiles.push(tiles);\n- this.tierImageSize.push(imageSize);\n+ if (this.ovmap) {\n+ this.ovmap.destroy();\n+ this.ovmap = null;\n }\n \n- this.tierSizeInTiles.reverse();\n- this.tierImageSize.reverse();\n+ this.element.removeChild(this.mapDiv);\n+ this.mapDiv = null;\n \n- this.numberOfTiers = this.tierSizeInTiles.length;\n- var resolutions = [1];\n- this.tileCountUpToTier = [0];\n- for (var i = 1; i < this.numberOfTiers; i++) {\n- resolutions.unshift(Math.pow(2, i));\n- this.tileCountUpToTier.push(\n- this.tierSizeInTiles[i - 1].w * this.tierSizeInTiles[i - 1].h +\n- this.tileCountUpToTier[i - 1]\n- );\n+ this.div.removeChild(this.element);\n+ this.element = null;\n+\n+ if (this.maximizeDiv) {\n+ this.div.removeChild(this.maximizeDiv);\n+ this.maximizeDiv = null;\n }\n- if (!this.serverResolutions) {\n- this.serverResolutions = resolutions;\n+\n+ if (this.minimizeDiv) {\n+ this.div.removeChild(this.minimizeDiv);\n+ this.minimizeDiv = null;\n }\n+\n+ this.map.events.un({\n+ buttonclick: this.onButtonClick,\n+ moveend: this.update,\n+ changebaselayer: this.baseLayerDraw,\n+ scope: this\n+ });\n+\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * APIMethod:destroy\n+ * Method: draw\n+ * Render the control in the browser.\n */\n- destroy: function() {\n- // for now, nothing special to do here.\n- OpenLayers.Layer.Grid.prototype.destroy.apply(this, arguments);\n+ draw: function() {\n+ OpenLayers.Control.prototype.draw.apply(this, arguments);\n+ if (this.layers.length === 0) {\n+ if (this.map.baseLayer) {\n+ var layer = this.map.baseLayer.clone();\n+ this.layers = [layer];\n+ } else {\n+ this.map.events.register(\"changebaselayer\", this, this.baseLayerDraw);\n+ return this.div;\n+ }\n+ }\n \n- // Remove from memory the Zoomify pyramid - is that enough?\n- this.tileCountUpToTier.length = 0;\n- this.tierSizeInTiles.length = 0;\n- this.tierImageSize.length = 0;\n+ // create overview map DOM elements\n+ this.element = document.createElement('div');\n+ this.element.className = this.displayClass + 'Element';\n+ this.element.style.display = 'none';\n \n- },\n+ this.mapDiv = document.createElement('div');\n+ this.mapDiv.style.width = this.size.w + 'px';\n+ this.mapDiv.style.height = this.size.h + 'px';\n+ this.mapDiv.style.position = 'relative';\n+ this.mapDiv.style.overflow = 'hidden';\n+ this.mapDiv.id = OpenLayers.Util.createUniqueID('overviewMap');\n \n- /**\n- * APIMethod: clone\n- *\n- * Parameters:\n- * obj - {Object}\n- *\n- * Returns:\n- * {} An exact clone of this \n- */\n- clone: function(obj) {\n+ this.extentRectangle = document.createElement('div');\n+ this.extentRectangle.style.position = 'absolute';\n+ this.extentRectangle.style.zIndex = 1000; //HACK\n+ this.extentRectangle.className = this.displayClass + 'ExtentRectangle';\n \n- if (obj == null) {\n- obj = new OpenLayers.Layer.Zoomify(this.name,\n- this.url,\n- this.size,\n- this.options);\n+ this.element.appendChild(this.mapDiv);\n+\n+ this.div.appendChild(this.element);\n+\n+ // Optionally add min/max buttons if the control will go in the\n+ // map viewport.\n+ if (!this.outsideViewport) {\n+ this.div.className += \" \" + this.displayClass + 'Container';\n+ // maximize button div\n+ var img = OpenLayers.Util.getImageLocation('layer-switcher-maximize.png');\n+ this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(\n+ this.displayClass + 'MaximizeButton',\n+ null,\n+ null,\n+ img,\n+ 'absolute');\n+ this.maximizeDiv.style.display = 'none';\n+ this.maximizeDiv.className = this.displayClass + 'MaximizeButton olButton';\n+ if (this.maximizeTitle) {\n+ this.maximizeDiv.title = this.maximizeTitle;\n+ }\n+ this.div.appendChild(this.maximizeDiv);\n+\n+ // minimize button div\n+ var img = OpenLayers.Util.getImageLocation('layer-switcher-minimize.png');\n+ this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv(\n+ 'OpenLayers_Control_minimizeDiv',\n+ null,\n+ null,\n+ img,\n+ 'absolute');\n+ this.minimizeDiv.style.display = 'none';\n+ this.minimizeDiv.className = this.displayClass + 'MinimizeButton olButton';\n+ if (this.minimizeTitle) {\n+ this.minimizeDiv.title = this.minimizeTitle;\n+ }\n+ this.div.appendChild(this.minimizeDiv);\n+ this.minimizeControl();\n+ } else {\n+ // show the overview map\n+ this.element.style.display = '';\n+ }\n+ if (this.map.getExtent()) {\n+ this.update();\n }\n \n- //get all additions from superclasses\n- obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);\n+ this.map.events.on({\n+ buttonclick: this.onButtonClick,\n+ moveend: this.update,\n+ scope: this\n+ });\n \n- // copy/set any non-init, non-simple values here\n+ if (this.maximized) {\n+ this.maximizeControl();\n+ }\n+ return this.div;\n+ },\n \n- return obj;\n+ /**\n+ * Method: baseLayerDraw\n+ * Draw the base layer - called if unable to complete in the initial draw\n+ */\n+ baseLayerDraw: function() {\n+ this.draw();\n+ this.map.events.unregister(\"changebaselayer\", this, this.baseLayerDraw);\n },\n \n /**\n- * Method: getURL\n+ * Method: rectDrag\n+ * Handle extent rectangle drag\n *\n * Parameters:\n- * bounds - {}\n- *\n- * Returns:\n- * {String} A string with the layer's url and parameters and also the\n- * passed-in bounds and appropriate tile size specified as\n- * parameters\n+ * px - {} The pixel location of the drag.\n */\n- getURL: function(bounds) {\n- bounds = this.adjustBounds(bounds);\n- var res = this.getServerResolution();\n- var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));\n- var y = Math.round((this.tileOrigin.lat - bounds.top) / (res * this.tileSize.h));\n- var z = this.getZoomForResolution(res);\n-\n- var tileIndex = x + y * this.tierSizeInTiles[z].w + this.tileCountUpToTier[z];\n- var path = \"TileGroup\" + Math.floor((tileIndex) / 256) +\n- \"/\" + z + \"-\" + x + \"-\" + y + \".jpg\";\n- var url = this.url;\n- if (OpenLayers.Util.isArray(url)) {\n- url = this.selectUrl(path, url);\n+ rectDrag: function(px) {\n+ var deltaX = this.handlers.drag.last.x - px.x;\n+ var deltaY = this.handlers.drag.last.y - px.y;\n+ if (deltaX != 0 || deltaY != 0) {\n+ var rectTop = this.rectPxBounds.top;\n+ var rectLeft = this.rectPxBounds.left;\n+ var rectHeight = Math.abs(this.rectPxBounds.getHeight());\n+ var rectWidth = this.rectPxBounds.getWidth();\n+ // don't allow dragging off of parent element\n+ var newTop = Math.max(0, (rectTop - deltaY));\n+ newTop = Math.min(newTop,\n+ this.ovmap.size.h - this.hComp - rectHeight);\n+ var newLeft = Math.max(0, (rectLeft - deltaX));\n+ newLeft = Math.min(newLeft,\n+ this.ovmap.size.w - this.wComp - rectWidth);\n+ this.setRectPxBounds(new OpenLayers.Bounds(newLeft,\n+ newTop + rectHeight,\n+ newLeft + rectWidth,\n+ newTop));\n }\n- return url + path;\n },\n \n /**\n- * Method: getImageSize\n- * getImageSize returns size for a particular tile. If bounds are given as\n- * first argument, size is calculated (bottom-right tiles are non square).\n+ * Method: mapDivClick\n+ * Handle browser events\n *\n+ * Parameters:\n+ * evt - {} evt\n */\n- getImageSize: function() {\n- if (arguments.length > 0) {\n- var bounds = this.adjustBounds(arguments[0]);\n- var res = this.getServerResolution();\n- var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));\n- var y = Math.round((this.tileOrigin.lat - bounds.top) / (res * this.tileSize.h));\n- var z = this.getZoomForResolution(res);\n- var w = this.standardTileSize;\n- var h = this.standardTileSize;\n- if (x == this.tierSizeInTiles[z].w - 1) {\n- var w = this.tierImageSize[z].w % this.standardTileSize;\n- }\n- if (y == this.tierSizeInTiles[z].h - 1) {\n- var h = this.tierImageSize[z].h % this.standardTileSize;\n- }\n- return (new OpenLayers.Size(w, h));\n- } else {\n- return this.tileSize;\n- }\n+ mapDivClick: function(evt) {\n+ var pxCenter = this.rectPxBounds.getCenterPixel();\n+ var deltaX = evt.xy.x - pxCenter.x;\n+ var deltaY = evt.xy.y - pxCenter.y;\n+ var top = this.rectPxBounds.top;\n+ var left = this.rectPxBounds.left;\n+ var height = Math.abs(this.rectPxBounds.getHeight());\n+ var width = this.rectPxBounds.getWidth();\n+ var newTop = Math.max(0, (top + deltaY));\n+ newTop = Math.min(newTop, this.ovmap.size.h - height);\n+ var newLeft = Math.max(0, (left + deltaX));\n+ newLeft = Math.min(newLeft, this.ovmap.size.w - width);\n+ this.setRectPxBounds(new OpenLayers.Bounds(newLeft,\n+ newTop + height,\n+ newLeft + width,\n+ newTop));\n+ this.updateMapToRect();\n },\n \n /**\n- * APIMethod: setMap\n- * When the layer is added to a map, then we can fetch our origin\n- * (if we don't have one.)\n+ * Method: onButtonClick\n *\n * Parameters:\n- * map - {}\n+ * evt - {Event}\n */\n- setMap: function(map) {\n- OpenLayers.Layer.Grid.prototype.setMap.apply(this, arguments);\n- this.tileOrigin = new OpenLayers.LonLat(this.map.maxExtent.left,\n- this.map.maxExtent.top);\n+ onButtonClick: function(evt) {\n+ if (evt.buttonElement === this.minimizeDiv) {\n+ this.minimizeControl();\n+ } else if (evt.buttonElement === this.maximizeDiv) {\n+ this.maximizeControl();\n+ }\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.Zoomify\"\n-});\n-/* ======================================================================\n- OpenLayers/Layer/PointTrack.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Layer/Vector.js\n- */\n-\n-/**\n- * Class: OpenLayers.Layer.PointTrack\n- * Vector layer to display ordered point features as a line, creating one\n- * LineString feature for each pair of two points.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Layer.PointTrack = OpenLayers.Class(OpenLayers.Layer.Vector, {\n-\n /**\n- * APIProperty: dataFrom\n- * {} or\n- * {} optional. If the lines\n- * should get the data/attributes from one of the two points it is\n- * composed of, which one should it be?\n+ * Method: maximizeControl\n+ * Unhide the control. Called when the control is in the map viewport.\n+ *\n+ * Parameters:\n+ * e - {}\n */\n- dataFrom: null,\n+ maximizeControl: function(e) {\n+ this.element.style.display = '';\n+ this.showToggle(false);\n+ if (e != null) {\n+ OpenLayers.Event.stop(e);\n+ }\n+ },\n \n /**\n- * APIProperty: styleFrom\n- * {} or\n- * {} optional. If the lines\n- * should get the style from one of the two points it is composed of,\n- * which one should it be?\n+ * Method: minimizeControl\n+ * Hide all the contents of the control, shrink the size, \n+ * add the maximize icon\n+ * \n+ * Parameters:\n+ * e - {}\n */\n- styleFrom: null,\n+ minimizeControl: function(e) {\n+ this.element.style.display = 'none';\n+ this.showToggle(true);\n+ if (e != null) {\n+ OpenLayers.Event.stop(e);\n+ }\n+ },\n \n /**\n- * Constructor: OpenLayers.PointTrack\n- * Constructor for a new OpenLayers.PointTrack instance.\n+ * Method: showToggle\n+ * Hide/Show the toggle depending on whether the control is minimized\n *\n * Parameters:\n- * name - {String} name of the layer\n- * options - {Object} Optional object with properties to tag onto the\n- * instance.\n+ * minimize - {Boolean} \n */\n+ showToggle: function(minimize) {\n+ if (this.maximizeDiv) {\n+ this.maximizeDiv.style.display = minimize ? '' : 'none';\n+ }\n+ if (this.minimizeDiv) {\n+ this.minimizeDiv.style.display = minimize ? 'none' : '';\n+ }\n+ },\n \n /**\n- * APIMethod: addNodes\n- * Adds point features that will be used to create lines from, using point\n- * pairs. The first point of a pair will be the source node, the second\n- * will be the target node.\n- * \n- * Parameters:\n- * pointFeatures - {Array()}\n- * options - {Object}\n- * \n- * Supported options:\n- * silent - {Boolean} true to suppress (before)feature(s)added events\n+ * Method: update\n+ * Update the overview map after layers move.\n */\n- addNodes: function(pointFeatures, options) {\n- if (pointFeatures.length < 2) {\n- throw new Error(\"At least two point features have to be added to \" +\n- \"create a line from\");\n+ update: function() {\n+ if (this.ovmap == null) {\n+ this.createMap();\n }\n \n- var lines = new Array(pointFeatures.length - 1);\n-\n- var pointFeature, startPoint, endPoint;\n- for (var i = 0, len = pointFeatures.length; i < len; i++) {\n- pointFeature = pointFeatures[i];\n- endPoint = pointFeature.geometry;\n-\n- if (!endPoint) {\n- var lonlat = pointFeature.lonlat;\n- endPoint = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);\n- } else if (endPoint.CLASS_NAME != \"OpenLayers.Geometry.Point\") {\n- throw new TypeError(\"Only features with point geometries are supported.\");\n- }\n+ if (this.autoPan || !this.isSuitableOverview()) {\n+ this.updateOverview();\n+ }\n \n- if (i > 0) {\n- var attributes = (this.dataFrom != null) ?\n- (pointFeatures[i + this.dataFrom].data ||\n- pointFeatures[i + this.dataFrom].attributes) :\n- null;\n- var style = (this.styleFrom != null) ?\n- (pointFeatures[i + this.styleFrom].style) :\n- null;\n- var line = new OpenLayers.Geometry.LineString([startPoint,\n- endPoint\n- ]);\n+ // update extent rectangle\n+ this.updateRectToMap();\n+ },\n \n- lines[i - 1] = new OpenLayers.Feature.Vector(line, attributes,\n- style);\n- }\n+ /**\n+ * Method: isSuitableOverview\n+ * Determines if the overview map is suitable given the extent and\n+ * resolution of the main map.\n+ */\n+ isSuitableOverview: function() {\n+ var mapExtent = this.map.getExtent();\n+ var maxExtent = this.map.getMaxExtent();\n+ var testExtent = new OpenLayers.Bounds(\n+ Math.max(mapExtent.left, maxExtent.left),\n+ Math.max(mapExtent.bottom, maxExtent.bottom),\n+ Math.min(mapExtent.right, maxExtent.right),\n+ Math.min(mapExtent.top, maxExtent.top));\n \n- startPoint = endPoint;\n+ if (this.ovmap.getProjection() != this.map.getProjection()) {\n+ testExtent = testExtent.transform(\n+ this.map.getProjectionObject(),\n+ this.ovmap.getProjectionObject());\n }\n \n- this.addFeatures(lines, options);\n+ var resRatio = this.ovmap.getResolution() / this.map.getResolution();\n+ return ((resRatio > this.minRatio) &&\n+ (resRatio <= this.maxRatio) &&\n+ (this.ovmap.getExtent().containsBounds(testExtent)));\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.PointTrack\"\n-});\n-\n-/**\n- * Constant: OpenLayers.Layer.PointTrack.SOURCE_NODE\n- * {Number} value for and\n- * \n- */\n-OpenLayers.Layer.PointTrack.SOURCE_NODE = -1;\n+ /**\n+ * Method updateOverview\n+ * Called by if returns true\n+ */\n+ updateOverview: function() {\n+ var mapRes = this.map.getResolution();\n+ var targetRes = this.ovmap.getResolution();\n+ var resRatio = targetRes / mapRes;\n+ if (resRatio > this.maxRatio) {\n+ // zoom in overview map\n+ targetRes = this.minRatio * mapRes;\n+ } else if (resRatio <= this.minRatio) {\n+ // zoom out overview map\n+ targetRes = this.maxRatio * mapRes;\n+ }\n+ var center;\n+ if (this.ovmap.getProjection() != this.map.getProjection()) {\n+ center = this.map.center.clone();\n+ center.transform(this.map.getProjectionObject(),\n+ this.ovmap.getProjectionObject());\n+ } else {\n+ center = this.map.center;\n+ }\n+ this.ovmap.setCenter(center, this.ovmap.getZoomForResolution(\n+ targetRes * this.resolutionFactor));\n+ this.updateRectToMap();\n+ },\n \n-/**\n- * Constant: OpenLayers.Layer.PointTrack.TARGET_NODE\n- * {Number} value for and\n- * \n- */\n-OpenLayers.Layer.PointTrack.TARGET_NODE = 0;\n+ /**\n+ * Method: createMap\n+ * Construct the map that this control contains\n+ */\n+ createMap: function() {\n+ // create the overview map\n+ var options = OpenLayers.Util.extend({\n+ controls: [],\n+ maxResolution: 'auto',\n+ fallThrough: false\n+ }, this.mapOptions);\n+ this.ovmap = new OpenLayers.Map(this.mapDiv, options);\n+ this.ovmap.viewPortDiv.appendChild(this.extentRectangle);\n \n-/**\n- * Constant: OpenLayers.Layer.PointTrack.dataFrom\n- * {Object} with the following keys - *deprecated*\n- * - SOURCE_NODE: take data/attributes from the source node of the line\n- * - TARGET_NODE: take data/attributes from the target node of the line\n- */\n-OpenLayers.Layer.PointTrack.dataFrom = {\n- 'SOURCE_NODE': -1,\n- 'TARGET_NODE': 0\n-};\n-/* ======================================================================\n- OpenLayers/Layer/KaMap.js\n- ====================================================================== */\n+ // prevent ovmap from being destroyed when the page unloads, because\n+ // the OverviewMap control has to do this (and does it).\n+ OpenLayers.Event.stopObserving(window, 'unload', this.ovmap.unloadDestroy);\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ this.ovmap.addLayers(this.layers);\n+ this.ovmap.zoomToMaxExtent();\n+ // check extent rectangle border width\n+ this.wComp = parseInt(OpenLayers.Element.getStyle(this.extentRectangle,\n+ 'border-left-width')) +\n+ parseInt(OpenLayers.Element.getStyle(this.extentRectangle,\n+ 'border-right-width'));\n+ this.wComp = (this.wComp) ? this.wComp : 2;\n+ this.hComp = parseInt(OpenLayers.Element.getStyle(this.extentRectangle,\n+ 'border-top-width')) +\n+ parseInt(OpenLayers.Element.getStyle(this.extentRectangle,\n+ 'border-bottom-width'));\n+ this.hComp = (this.hComp) ? this.hComp : 2;\n \n+ this.handlers.drag = new OpenLayers.Handler.Drag(\n+ this, {\n+ move: this.rectDrag,\n+ done: this.updateMapToRect\n+ }, {\n+ map: this.ovmap\n+ }\n+ );\n+ this.handlers.click = new OpenLayers.Handler.Click(\n+ this, {\n+ \"click\": this.mapDivClick\n+ }, {\n+ \"single\": true,\n+ \"double\": false,\n+ \"stopSingle\": true,\n+ \"stopDouble\": true,\n+ \"pixelTolerance\": 1,\n+ map: this.ovmap\n+ }\n+ );\n+ this.handlers.click.activate();\n \n-/**\n- * @requires OpenLayers/Layer/Grid.js\n- */\n+ this.rectEvents = new OpenLayers.Events(this, this.extentRectangle,\n+ null, true);\n+ this.rectEvents.register(\"mouseover\", this, function(e) {\n+ if (!this.handlers.drag.active && !this.map.dragging) {\n+ this.handlers.drag.activate();\n+ }\n+ });\n+ this.rectEvents.register(\"mouseout\", this, function(e) {\n+ if (!this.handlers.drag.dragging) {\n+ this.handlers.drag.deactivate();\n+ }\n+ });\n \n-/**\n- * Class: OpenLayers.Layer.KaMap\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Layer.KaMap = OpenLayers.Class(OpenLayers.Layer.Grid, {\n+ if (this.ovmap.getProjection() != this.map.getProjection()) {\n+ var sourceUnits = this.map.getProjectionObject().getUnits() ||\n+ this.map.units || this.map.baseLayer.units;\n+ var targetUnits = this.ovmap.getProjectionObject().getUnits() ||\n+ this.ovmap.units || this.ovmap.baseLayer.units;\n+ this.resolutionFactor = sourceUnits && targetUnits ?\n+ OpenLayers.INCHES_PER_UNIT[sourceUnits] /\n+ OpenLayers.INCHES_PER_UNIT[targetUnits] : 1;\n+ }\n+ },\n \n- /** \n- * APIProperty: isBaseLayer\n- * {Boolean} KaMap Layer is always a base layer \n+ /**\n+ * Method: updateRectToMap\n+ * Updates the extent rectangle position and size to match the map extent\n */\n- isBaseLayer: true,\n+ updateRectToMap: function() {\n+ // If the projections differ we need to reproject\n+ var bounds;\n+ if (this.ovmap.getProjection() != this.map.getProjection()) {\n+ bounds = this.map.getExtent().transform(\n+ this.map.getProjectionObject(),\n+ this.ovmap.getProjectionObject());\n+ } else {\n+ bounds = this.map.getExtent();\n+ }\n+ var pxBounds = this.getRectBoundsFromMapBounds(bounds);\n+ if (pxBounds) {\n+ this.setRectPxBounds(pxBounds);\n+ }\n+ },\n \n /**\n- * Constant: DEFAULT_PARAMS\n- * {Object} parameters set by default. The default parameters set \n- * the format via the 'i' parameter to 'jpeg'. \n+ * Method: updateMapToRect\n+ * Updates the map extent to match the extent rectangle position and size\n */\n- DEFAULT_PARAMS: {\n- i: 'jpeg',\n- map: ''\n+ updateMapToRect: function() {\n+ var lonLatBounds = this.getMapBoundsFromRectBounds(this.rectPxBounds);\n+ if (this.ovmap.getProjection() != this.map.getProjection()) {\n+ lonLatBounds = lonLatBounds.transform(\n+ this.ovmap.getProjectionObject(),\n+ this.map.getProjectionObject());\n+ }\n+ this.map.panTo(lonLatBounds.getCenterLonLat());\n },\n \n /**\n- * Constructor: OpenLayers.Layer.KaMap\n- * \n+ * Method: setRectPxBounds\n+ * Set extent rectangle pixel bounds.\n+ *\n * Parameters:\n- * name - {String}\n- * url - {String}\n- * params - {Object} Parameters to be sent to the HTTP server in the\n- * query string for the tile. The format can be set via the 'i'\n- * parameter (defaults to jpg) , and the map should be set via \n- * the 'map' parameter. It has been reported that ka-Map may behave\n- * inconsistently if your format parameter does not match the format\n- * parameter configured in your config.php. (See ticket #327 for more\n- * information.)\n- * options - {Object} Additional options for the layer. Any of the \n- * APIProperties listed on this layer, and any layer types it\n- * extends, can be overridden through the options parameter. \n+ * pxBounds - {}\n */\n- initialize: function(name, url, params, options) {\n- OpenLayers.Layer.Grid.prototype.initialize.apply(this, arguments);\n- this.params = OpenLayers.Util.applyDefaults(\n- this.params, this.DEFAULT_PARAMS\n+ setRectPxBounds: function(pxBounds) {\n+ var top = Math.max(pxBounds.top, 0);\n+ var left = Math.max(pxBounds.left, 0);\n+ var bottom = Math.min(pxBounds.top + Math.abs(pxBounds.getHeight()),\n+ this.ovmap.size.h - this.hComp);\n+ var right = Math.min(pxBounds.left + pxBounds.getWidth(),\n+ this.ovmap.size.w - this.wComp);\n+ var width = Math.max(right - left, 0);\n+ var height = Math.max(bottom - top, 0);\n+ if (width < this.minRectSize || height < this.minRectSize) {\n+ this.extentRectangle.className = this.displayClass +\n+ this.minRectDisplayClass;\n+ var rLeft = left + (width / 2) - (this.minRectSize / 2);\n+ var rTop = top + (height / 2) - (this.minRectSize / 2);\n+ this.extentRectangle.style.top = Math.round(rTop) + 'px';\n+ this.extentRectangle.style.left = Math.round(rLeft) + 'px';\n+ this.extentRectangle.style.height = this.minRectSize + 'px';\n+ this.extentRectangle.style.width = this.minRectSize + 'px';\n+ } else {\n+ this.extentRectangle.className = this.displayClass +\n+ 'ExtentRectangle';\n+ this.extentRectangle.style.top = Math.round(top) + 'px';\n+ this.extentRectangle.style.left = Math.round(left) + 'px';\n+ this.extentRectangle.style.height = Math.round(height) + 'px';\n+ this.extentRectangle.style.width = Math.round(width) + 'px';\n+ }\n+ this.rectPxBounds = new OpenLayers.Bounds(\n+ Math.round(left), Math.round(bottom),\n+ Math.round(right), Math.round(top)\n );\n },\n \n /**\n- * Method: getURL\n- * \n+ * Method: getRectBoundsFromMapBounds\n+ * Get the rect bounds from the map bounds.\n+ *\n * Parameters:\n- * bounds - {} \n- * \n+ * lonLatBounds - {}\n+ *\n * Returns:\n- * {String} A string with the layer's url and parameters and also the \n- * passed-in bounds and appropriate tile size specified as \n- * parameters\n+ * {}A bounds which is the passed-in map lon/lat extent\n+ * translated into pixel bounds for the overview map\n */\n- getURL: function(bounds) {\n- bounds = this.adjustBounds(bounds);\n- var mapRes = this.map.getResolution();\n- var scale = Math.round((this.map.getScale() * 10000)) / 10000;\n- var pX = Math.round(bounds.left / mapRes);\n- var pY = -Math.round(bounds.top / mapRes);\n- return this.getFullRequestString({\n- t: pY,\n- l: pX,\n- s: scale\n+ getRectBoundsFromMapBounds: function(lonLatBounds) {\n+ var leftBottomPx = this.getOverviewPxFromLonLat({\n+ lon: lonLatBounds.left,\n+ lat: lonLatBounds.bottom\n+ });\n+ var rightTopPx = this.getOverviewPxFromLonLat({\n+ lon: lonLatBounds.right,\n+ lat: lonLatBounds.top\n });\n+ var bounds = null;\n+ if (leftBottomPx && rightTopPx) {\n+ bounds = new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y,\n+ rightTopPx.x, rightTopPx.y);\n+ }\n+ return bounds;\n },\n \n- /** \n- * Method: calculateGridLayout\n- * ka-Map uses the center point of the map as an origin for \n- * its tiles. Override calculateGridLayout to center tiles \n- * correctly for this case.\n+ /**\n+ * Method: getMapBoundsFromRectBounds\n+ * Get the map bounds from the rect bounds.\n *\n * Parameters:\n- * bounds - {}\n- * origin - {}\n- * resolution - {Number}\n+ * pxBounds - {}\n *\n * Returns:\n- * {Object} Object containing properties tilelon, tilelat, startcol,\n- * startrow\n+ * {} Bounds which is the passed-in overview rect bounds\n+ * translated into lon/lat bounds for the overview map\n */\n- calculateGridLayout: function(bounds, origin, resolution) {\n- var tilelon = resolution * this.tileSize.w;\n- var tilelat = resolution * this.tileSize.h;\n-\n- var offsetlon = bounds.left;\n- var tilecol = Math.floor(offsetlon / tilelon) - this.buffer;\n-\n- var offsetlat = bounds.top;\n- var tilerow = Math.floor(offsetlat / tilelat) + this.buffer;\n-\n- return {\n- tilelon: tilelon,\n- tilelat: tilelat,\n- startcol: tilecol,\n- startrow: tilerow\n- };\n+ getMapBoundsFromRectBounds: function(pxBounds) {\n+ var leftBottomLonLat = this.getLonLatFromOverviewPx({\n+ x: pxBounds.left,\n+ y: pxBounds.bottom\n+ });\n+ var rightTopLonLat = this.getLonLatFromOverviewPx({\n+ x: pxBounds.right,\n+ y: pxBounds.top\n+ });\n+ return new OpenLayers.Bounds(leftBottomLonLat.lon, leftBottomLonLat.lat,\n+ rightTopLonLat.lon, rightTopLonLat.lat);\n },\n \n /**\n- * Method: getTileBoundsForGridIndex\n+ * Method: getLonLatFromOverviewPx\n+ * Get a map location from a pixel location\n *\n * Parameters:\n- * row - {Number} The row of the grid\n- * col - {Number} The column of the grid\n+ * overviewMapPx - {|Object} OpenLayers.Pixel or\n+ * an object with a\n+ * 'x' and 'y' properties.\n *\n * Returns:\n- * {} The bounds for the tile at (row, col)\n- */\n- getTileBoundsForGridIndex: function(row, col) {\n- var origin = this.getTileOrigin();\n- var tileLayout = this.gridLayout;\n- var tilelon = tileLayout.tilelon;\n- var tilelat = tileLayout.tilelat;\n- var minX = (tileLayout.startcol + col) * tilelon;\n- var minY = (tileLayout.startrow - row) * tilelat;\n- return new OpenLayers.Bounds(\n- minX, minY,\n- minX + tilelon, minY + tilelat\n- );\n- },\n-\n- /**\n- * APIMethod: clone\n- * \n- * Parameters: \n- * obj - {Object}\n- * \n- * Returns:\n- * {} An exact clone of this OpenLayers.Layer.KaMap\n+ * {Object} Location which is the passed-in overview map\n+ * OpenLayers.Pixel, translated into lon/lat by the overview\n+ * map. An object with a 'lon' and 'lat' properties.\n */\n- clone: function(obj) {\n-\n- if (obj == null) {\n- obj = new OpenLayers.Layer.KaMap(this.name,\n- this.url,\n- this.params,\n- this.getOptions());\n- }\n-\n- //get all additions from superclasses\n- obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);\n-\n- // copy/set any non-init, non-simple values here\n- if (this.tileSize != null) {\n- obj.tileSize = this.tileSize.clone();\n- }\n+ getLonLatFromOverviewPx: function(overviewMapPx) {\n+ var size = this.ovmap.size;\n+ var res = this.ovmap.getResolution();\n+ var center = this.ovmap.getExtent().getCenterLonLat();\n \n- // we do not want to copy reference to grid, so we make a new array\n- obj.grid = [];\n+ var deltaX = overviewMapPx.x - (size.w / 2);\n+ var deltaY = overviewMapPx.y - (size.h / 2);\n \n- return obj;\n+ return {\n+ lon: center.lon + deltaX * res,\n+ lat: center.lat - deltaY * res\n+ };\n },\n \n /**\n- * APIMethod: getTileBounds\n- * Returns The tile bounds for a layer given a pixel location.\n+ * Method: getOverviewPxFromLonLat\n+ * Get a pixel location from a map location\n *\n * Parameters:\n- * viewPortPx - {} The location in the viewport.\n+ * lonlat - {|Object} OpenLayers.LonLat or an\n+ * object with a 'lon' and 'lat' properties.\n *\n * Returns:\n- * {} Bounds of the tile at the given pixel location.\n+ * {Object} Location which is the passed-in OpenLayers.LonLat, \n+ * translated into overview map pixels\n */\n- getTileBounds: function(viewPortPx) {\n- var resolution = this.getResolution();\n- var tileMapWidth = resolution * this.tileSize.w;\n- var tileMapHeight = resolution * this.tileSize.h;\n- var mapPoint = this.getLonLatFromViewPortPx(viewPortPx);\n- var tileLeft = tileMapWidth * Math.floor(mapPoint.lon / tileMapWidth);\n- var tileBottom = tileMapHeight * Math.floor(mapPoint.lat / tileMapHeight);\n- return new OpenLayers.Bounds(tileLeft, tileBottom,\n- tileLeft + tileMapWidth,\n- tileBottom + tileMapHeight);\n+ getOverviewPxFromLonLat: function(lonlat) {\n+ var res = this.ovmap.getResolution();\n+ var extent = this.ovmap.getExtent();\n+ if (extent) {\n+ return {\n+ x: Math.round(1 / res * (lonlat.lon - extent.left)),\n+ y: Math.round(1 / res * (extent.top - lonlat.lat))\n+ };\n+ }\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.KaMap\"\n+ CLASS_NAME: 'OpenLayers.Control.OverviewMap'\n });\n /* ======================================================================\n- OpenLayers/Layer/KaMapCache.js\n+ OpenLayers/Control/Geolocate.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/Layer/Grid.js\n- * @requires OpenLayers/Layer/KaMap.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Geometry/Point.js\n+ * @requires OpenLayers/Projection.js\n */\n \n /**\n- * Class: OpenLayers.Layer.KaMapCache\n- * \n- * This class is designed to talk directly to a web-accessible ka-Map\n- * cache generated by the precache2.php script.\n- * \n- * To create a a new KaMapCache layer, you must indicate also the \"i\" parameter\n- * (that will be used to calculate the file extension), and another special\n- * parameter, object names \"metaTileSize\", with \"h\" (height) and \"w\" (width)\n- * properties.\n- * \n- * // Create a new kaMapCache layer. \n- * var kamap_base = new OpenLayers.Layer.KaMapCache(\n- * \"Satellite\",\n- * \"http://www.example.org/web/acessible/cache\",\n- * {g: \"satellite\", map: \"world\", i: 'png24', metaTileSize: {w: 5, h: 5} }\n- * );\n- * \n- * // Create an kaMapCache overlay layer (using \"isBaseLayer: false\"). \n- * // Forces the output to be a \"gif\", using the \"i\" parameter.\n- * var kamap_overlay = new OpenLayers.Layer.KaMapCache(\n- * \"Streets\",\n- * \"http://www.example.org/web/acessible/cache\",\n- * {g: \"streets\", map: \"world\", i: \"gif\", metaTileSize: {w: 5, h: 5} },\n- * {isBaseLayer: false}\n- * );\n+ * Class: OpenLayers.Control.Geolocate\n+ * The Geolocate control wraps w3c geolocation API into control that can be\n+ * bound to a map, and generate events on location update\n *\n- * The cache URLs must look like: \n- * var/cache/World/50000/Group_Name/def/t-440320/l20480\n- * \n- * This means that the cache generated via tile.php will *not* work with\n- * this class, and should instead use the KaMap layer.\n+ * To use this control requires to load the proj4js library if the projection\n+ * of the map is not EPSG:4326 or EPSG:900913.\n *\n- * More information is available in Ticket #1518.\n- * \n * Inherits from:\n- * - \n- * - \n+ * - \n */\n-OpenLayers.Layer.KaMapCache = OpenLayers.Class(OpenLayers.Layer.KaMap, {\n+OpenLayers.Control.Geolocate = OpenLayers.Class(OpenLayers.Control, {\n+\n+ /** \n+ * APIProperty: events\n+ * {} Events instance for listeners and triggering\n+ * control specific events.\n+ *\n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * control.events.register(type, obj, listener);\n+ * (end)\n+ *\n+ * Supported event types (in addition to those from ):\n+ * locationupdated - Triggered when browser return a new position. Listeners will \n+ * receive an object with a 'position' property which is the browser.geolocation.position\n+ * native object, as well as a 'point' property which is the location transformed in the \n+ * current map projection.\n+ * locationfailed - Triggered when geolocation has failed\n+ * locationuncapable - Triggered when control is activated on a browser\n+ * which doesn't support geolocation\n+ */\n \n /**\n- * Constant: IMAGE_EXTENSIONS\n- * {Object} Simple hash map to convert format to extension.\n+ * Property: geolocation\n+ * {Object} The geolocation engine, as a property to be possibly mocked.\n+ * This is set lazily to avoid a memory leak in IE9.\n */\n- IMAGE_EXTENSIONS: {\n- 'jpeg': 'jpg',\n- 'gif': 'gif',\n- 'png': 'png',\n- 'png8': 'png',\n- 'png24': 'png',\n- 'dithered': 'png'\n- },\n+ geolocation: null,\n \n /**\n- * Constant: DEFAULT_FORMAT\n- * {Object} Simple hash map to convert format to extension.\n+ * Property: available\n+ * {Boolean} The navigator.geolocation object is available.\n */\n- DEFAULT_FORMAT: 'jpeg',\n+ available: ('geolocation' in navigator),\n \n /**\n- * Constructor: OpenLayers.Layer.KaMapCache\n- * \n- * Parameters:\n- * name - {String}\n- * url - {String}\n- * params - {Object} Parameters to be sent to the HTTP server in the\n- * query string for the tile. The format can be set via the 'i'\n- * parameter (defaults to jpg) , and the map should be set via \n- * the 'map' parameter. It has been reported that ka-Map may behave\n- * inconsistently if your format parameter does not match the format\n- * parameter configured in your config.php. (See ticket #327 for more\n- * information.)\n- * options - {Object} Additional options for the layer. Any of the \n- * APIProperties listed on this layer, and any layer types it\n- * extends, can be overridden through the options parameter. \n+ * APIProperty: bind\n+ * {Boolean} If true, map center will be set on location update.\n */\n- initialize: function(name, url, params, options) {\n- OpenLayers.Layer.KaMap.prototype.initialize.apply(this, arguments);\n- this.extension = this.IMAGE_EXTENSIONS[this.params.i.toLowerCase() || this.DEFAULT_FORMAT];\n+ bind: true,\n+\n+ /**\n+ * APIProperty: watch\n+ * {Boolean} If true, position will be update regularly.\n+ */\n+ watch: false,\n+\n+ /**\n+ * APIProperty: geolocationOptions\n+ * {Object} Options to pass to the navigator's geolocation API. See\n+ * . No specific\n+ * option is passed to the geolocation API by default.\n+ */\n+ geolocationOptions: null,\n+\n+ /**\n+ * Constructor: OpenLayers.Control.Geolocate\n+ * Create a new control to deal with browser geolocation API\n+ *\n+ */\n+\n+ /**\n+ * Method: destroy\n+ */\n+ destroy: function() {\n+ this.deactivate();\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * Method: getURL\n- * \n- * Parameters:\n- * bounds - {} \n- * \n+ * Method: activate\n+ * Activates the control.\n+ *\n * Returns:\n- * {String} A string with the layer's url and parameters and also the \n- * passed-in bounds and appropriate tile size specified as \n- * parameters\n+ * {Boolean} The control was effectively activated.\n */\n- getURL: function(bounds) {\n- bounds = this.adjustBounds(bounds);\n- var mapRes = this.map.getResolution();\n- var scale = Math.round((this.map.getScale() * 10000)) / 10000;\n- var pX = Math.round(bounds.left / mapRes);\n- var pY = -Math.round(bounds.top / mapRes);\n-\n- var metaX = Math.floor(pX / this.tileSize.w / this.params.metaTileSize.w) * this.tileSize.w * this.params.metaTileSize.w;\n- var metaY = Math.floor(pY / this.tileSize.h / this.params.metaTileSize.h) * this.tileSize.h * this.params.metaTileSize.h;\n+ activate: function() {\n+ if (this.available && !this.geolocation) {\n+ // set lazily to avoid IE9 memory leak\n+ this.geolocation = navigator.geolocation;\n+ }\n+ if (!this.geolocation) {\n+ this.events.triggerEvent(\"locationuncapable\");\n+ return false;\n+ }\n+ if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {\n+ if (this.watch) {\n+ this.watchId = this.geolocation.watchPosition(\n+ OpenLayers.Function.bind(this.geolocate, this),\n+ OpenLayers.Function.bind(this.failure, this),\n+ this.geolocationOptions\n+ );\n+ } else {\n+ this.getCurrentLocation();\n+ }\n+ return true;\n+ }\n+ return false;\n+ },\n \n- var components = [\n- \"/\",\n- this.params.map,\n- \"/\",\n- scale,\n- \"/\",\n- this.params.g.replace(/\\s/g, '_'),\n- \"/def/t\",\n- metaY,\n- \"/l\",\n- metaX,\n- \"/t\",\n- pY,\n- \"l\",\n- pX,\n- \".\",\n- this.extension\n- ];\n+ /**\n+ * Method: deactivate\n+ * Deactivates the control.\n+ *\n+ * Returns:\n+ * {Boolean} The control was effectively deactivated.\n+ */\n+ deactivate: function() {\n+ if (this.active && this.watchId !== null) {\n+ this.geolocation.clearWatch(this.watchId);\n+ }\n+ return OpenLayers.Control.prototype.deactivate.apply(\n+ this, arguments\n+ );\n+ },\n \n- var url = this.url;\n+ /**\n+ * Method: geolocate\n+ * Activates the control.\n+ *\n+ */\n+ geolocate: function(position) {\n+ var center = new OpenLayers.LonLat(\n+ position.coords.longitude,\n+ position.coords.latitude\n+ ).transform(\n+ new OpenLayers.Projection(\"EPSG:4326\"),\n+ this.map.getProjectionObject()\n+ );\n+ if (this.bind) {\n+ this.map.setCenter(center);\n+ }\n+ this.events.triggerEvent(\"locationupdated\", {\n+ position: position,\n+ point: new OpenLayers.Geometry.Point(\n+ center.lon, center.lat\n+ )\n+ });\n+ },\n \n- if (OpenLayers.Util.isArray(url)) {\n- url = this.selectUrl(components.join(''), url);\n+ /**\n+ * APIMethod: getCurrentLocation\n+ *\n+ * Returns:\n+ * {Boolean} Returns true if a event will be fired (successfull\n+ * registration)\n+ */\n+ getCurrentLocation: function() {\n+ if (!this.active || this.watch) {\n+ return false;\n }\n- return url + components.join(\"\");\n+ this.geolocation.getCurrentPosition(\n+ OpenLayers.Function.bind(this.geolocate, this),\n+ OpenLayers.Function.bind(this.failure, this),\n+ this.geolocationOptions\n+ );\n+ return true;\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.KaMapCache\"\n+ /**\n+ * Method: failure\n+ * method called on browser's geolocation failure\n+ *\n+ */\n+ failure: function(error) {\n+ this.events.triggerEvent(\"locationfailed\", {\n+ error: error\n+ });\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Control.Geolocate\"\n });\n /* ======================================================================\n- OpenLayers/Layer/TMS.js\n+ OpenLayers/Control/NavigationHistory.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/Layer/Grid.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Control/Button.js\n */\n \n /**\n- * Class: OpenLayers.Layer.TMS\n- * Create a layer for accessing tiles from services that conform with the \n- * Tile Map Service Specification \n- * (http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification).\n+ * Class: OpenLayers.Control.NavigationHistory\n+ * A navigation history control. This is a meta-control, that creates two\n+ * dependent controls: and . Call the trigger method\n+ * on the and controls to restore previous and next\n+ * history states. The previous and next controls will become active\n+ * when there are available states to restore and will become deactive\n+ * when there are no states to restore.\n *\n- * Example:\n- * (code)\n- * var layer = new OpenLayers.Layer.TMS(\n- * \"My Layer\", // name for display in LayerSwitcher\n- * \"http://tilecache.osgeo.org/wms-c/Basic.py/\", // service endpoint\n- * {layername: \"basic\", type: \"png\"} // required properties\n- * );\n- * (end)\n- * \n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.TMS = OpenLayers.Class(OpenLayers.Layer.Grid, {\n+OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * APIProperty: serviceVersion\n- * {String} Service version for tile requests. Default is \"1.0.0\".\n+ * Property: type\n+ * {String} Note that this control is not intended to be added directly\n+ * to a control panel. Instead, add the sub-controls previous and\n+ * next. These sub-controls are button type controls that activate\n+ * and deactivate themselves. If this parent control is added to\n+ * a panel, it will act as a toggle.\n */\n- serviceVersion: \"1.0.0\",\n+ type: OpenLayers.Control.TYPE_TOGGLE,\n \n /**\n- * APIProperty: layername\n- * {String} The identifier for the as advertised by the service. \n- * For example, if the service advertises a with \n- * 'href=\"http://tms.osgeo.org/1.0.0/vmap0\"', the property \n- * would be set to \"vmap0\".\n+ * APIProperty: previous\n+ * {} A button type control whose trigger method restores\n+ * the previous state managed by this control.\n */\n- layername: null,\n+ previous: null,\n \n /**\n- * APIProperty: type\n- * {String} The format extension corresponding to the requested tile image\n- * type. This is advertised in a element as the \n- * \"extension\" attribute. For example, if the service advertises a \n- * with ,\n- * the property would be set to \"jpg\".\n+ * APIProperty: previousOptions\n+ * {Object} Set this property on the options argument of the constructor\n+ * to set optional properties on the control.\n */\n- type: null,\n+ previousOptions: null,\n \n /**\n- * APIProperty: isBaseLayer\n- * {Boolean} Make this layer a base layer. Default is true. Set false to\n- * use the layer as an overlay.\n+ * APIProperty: next\n+ * {} A button type control whose trigger method restores\n+ * the next state managed by this control.\n */\n- isBaseLayer: true,\n+ next: null,\n \n /**\n- * APIProperty: tileOrigin\n- * {} Optional origin for aligning the grid of tiles.\n- * If provided, requests for tiles at all resolutions will be aligned\n- * with this location (no tiles shall overlap this location). If\n- * not provided, the grid of tiles will be aligned with the bottom-left\n- * corner of the map's . Default is ``null``.\n- *\n- * Example:\n- * (code)\n- * var layer = new OpenLayers.Layer.TMS(\n- * \"My Layer\",\n- * \"http://tilecache.osgeo.org/wms-c/Basic.py/\",\n- * {\n- * layername: \"basic\", \n- * type: \"png\",\n- * // set if different than the bottom left of map.maxExtent\n- * tileOrigin: new OpenLayers.LonLat(-180, -90)\n- * }\n- * );\n- * (end)\n+ * APIProperty: nextOptions\n+ * {Object} Set this property on the options argument of the constructor\n+ * to set optional properties on the control.\n */\n- tileOrigin: null,\n+ nextOptions: null,\n \n /**\n- * APIProperty: serverResolutions\n- * {Array} A list of all resolutions available on the server. Only set this\n- * property if the map resolutions differ from the server. This\n- * property serves two purposes. (a) can include\n- * resolutions that the server supports and that you don't want to\n- * provide with this layer; you can also look at , which is\n- * an alternative to for that specific purpose.\n- * (b) The map can work with resolutions that aren't supported by\n- * the server, i.e. that aren't in . When the\n- * map is displayed in such a resolution data for the closest\n- * server-supported resolution is loaded and the layer div is\n- * stretched as necessary.\n+ * APIProperty: limit\n+ * {Integer} Optional limit on the number of history items to retain. If\n+ * null, there is no limit. Default is 50.\n */\n- serverResolutions: null,\n+ limit: 50,\n \n /**\n- * APIProperty: zoomOffset\n- * {Number} If your cache has more zoom levels than you want to provide\n- * access to with this layer, supply a zoomOffset. This zoom offset\n- * is added to the current map zoom level to determine the level\n- * for a requested tile. For example, if you supply a zoomOffset\n- * of 3, when the map is at the zoom 0, tiles will be requested from\n- * level 3 of your cache. Default is 0 (assumes cache level and map\n- * zoom are equivalent). Using is an alternative to\n- * setting if you only want to expose a subset\n- * of the server resolutions.\n+ * APIProperty: autoActivate\n+ * {Boolean} Activate the control when it is added to a map. Default is\n+ * true.\n */\n- zoomOffset: 0,\n+ autoActivate: true,\n \n /**\n- * Constructor: OpenLayers.Layer.TMS\n- * \n- * Parameters:\n- * name - {String} Title to be displayed in a \n- * url - {String} Service endpoint (without the version number). E.g.\n- * \"http://tms.osgeo.org/\".\n- * options - {Object} Additional properties to be set on the layer. The\n- * and properties must be set here.\n+ * Property: clearOnDeactivate\n+ * {Boolean} Clear the history when the control is deactivated. Default\n+ * is false.\n */\n- initialize: function(name, url, options) {\n- var newArguments = [];\n- newArguments.push(name, url, {}, options);\n- OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);\n- },\n+ clearOnDeactivate: false,\n \n /**\n- * APIMethod: clone\n- * Create a complete copy of this layer.\n- *\n- * Parameters:\n- * obj - {Object} Should only be provided by subclasses that call this\n- * method.\n- * \n- * Returns:\n- * {} An exact clone of this \n+ * Property: registry\n+ * {Object} An object with keys corresponding to event types. Values\n+ * are functions that return an object representing the current state.\n */\n- clone: function(obj) {\n-\n- if (obj == null) {\n- obj = new OpenLayers.Layer.TMS(this.name,\n- this.url,\n- this.getOptions());\n- }\n+ registry: null,\n \n- //get all additions from superclasses\n- obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);\n+ /**\n+ * Property: nextStack\n+ * {Array} Array of items in the history.\n+ */\n+ nextStack: null,\n \n- // copy/set any non-init, non-simple values here\n+ /**\n+ * Property: previousStack\n+ * {Array} List of items in the history. First item represents the current\n+ * state.\n+ */\n+ previousStack: null,\n \n- return obj;\n- },\n+ /**\n+ * Property: listeners\n+ * {Object} An object containing properties corresponding to event types.\n+ * This object is used to configure the control and is modified on\n+ * construction.\n+ */\n+ listeners: null,\n \n /**\n- * Method: getURL\n- * \n- * Parameters:\n- * bounds - {}\n- * \n- * Returns:\n- * {String} A string with the layer's url and parameters and also the \n- * passed-in bounds and appropriate tile size specified as \n- * parameters\n+ * Property: restoring\n+ * {Boolean} Currently restoring a history state. This is set to true\n+ * before calling restore and set to false after restore returns.\n */\n- getURL: function(bounds) {\n- bounds = this.adjustBounds(bounds);\n- var res = this.getServerResolution();\n- var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));\n- var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h));\n- var z = this.getServerZoom();\n- var path = this.serviceVersion + \"/\" + this.layername + \"/\" + z + \"/\" + x + \"/\" + y + \".\" + this.type;\n- var url = this.url;\n- if (OpenLayers.Util.isArray(url)) {\n- url = this.selectUrl(path, url);\n- }\n- return url + path;\n- },\n+ restoring: false,\n \n- /** \n- * Method: setMap\n- * When the layer is added to a map, then we can fetch our origin \n- * (if we don't have one.) \n+ /**\n+ * Constructor: OpenLayers.Control.NavigationHistory \n * \n * Parameters:\n- * map - {}\n+ * options - {Object} An optional object whose properties will be used\n+ * to extend the control.\n */\n- setMap: function(map) {\n- OpenLayers.Layer.Grid.prototype.setMap.apply(this, arguments);\n- if (!this.tileOrigin) {\n- this.tileOrigin = new OpenLayers.LonLat(this.map.maxExtent.left,\n- this.map.maxExtent.bottom);\n- }\n- },\n-\n- CLASS_NAME: \"OpenLayers.Layer.TMS\"\n-});\n-/* ======================================================================\n- OpenLayers/Layer/MapGuide.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Request/XMLHttpRequest.js\n- * @requires OpenLayers/Layer/Grid.js\n- */\n-\n-/**\n- * Class: OpenLayers.Layer.MapGuide\n- * Instances of OpenLayers.Layer.MapGuide are used to display\n- * data from a MapGuide OS instance.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, {\n-\n- /** \n- * APIProperty: isBaseLayer\n- * {Boolean} Treat this layer as a base layer. Default is true.\n- **/\n- isBaseLayer: true,\n+ initialize: function(options) {\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n \n- /**\n- * APIProperty: useHttpTile\n- * {Boolean} use a tile cache exposed directly via a webserver rather than the \n- * via mapguide server. This does require extra configuration on the Mapguide Server,\n- * and will only work when singleTile is false. The url for the layer must be set to the\n- * webserver path rather than the Mapguide mapagent.\n- * See http://trac.osgeo.org/mapguide/wiki/CodeSamples/Tiles/ServingTilesViaHttp\n- **/\n- useHttpTile: false,\n+ this.registry = OpenLayers.Util.extend({\n+ \"moveend\": this.getState\n+ }, this.registry);\n \n- /** \n- * APIProperty: singleTile\n- * {Boolean} use tile server or request single tile image. \n- **/\n- singleTile: false,\n+ var previousOptions = {\n+ trigger: OpenLayers.Function.bind(this.previousTrigger, this),\n+ displayClass: this.displayClass + \" \" + this.displayClass + \"Previous\"\n+ };\n+ OpenLayers.Util.extend(previousOptions, this.previousOptions);\n+ this.previous = new OpenLayers.Control.Button(previousOptions);\n \n- /** \n- * APIProperty: useOverlay\n- * {Boolean} flag to indicate if the layer should be retrieved using\n- * GETMAPIMAGE (default) or using GETDYNAMICOVERLAY requests.\n- **/\n- useOverlay: false,\n+ var nextOptions = {\n+ trigger: OpenLayers.Function.bind(this.nextTrigger, this),\n+ displayClass: this.displayClass + \" \" + this.displayClass + \"Next\"\n+ };\n+ OpenLayers.Util.extend(nextOptions, this.nextOptions);\n+ this.next = new OpenLayers.Control.Button(nextOptions);\n \n- /** \n- * APIProperty: useAsyncOverlay\n- * {Boolean} indicates if the MapGuide site supports the asynchronous \n- * GETDYNAMICOVERLAY requests which is available in MapGuide Enterprise 2010\n- * and MapGuide Open Source v2.0.3 or higher. The newer versions of MG \n- * is called asynchronously, allows selections to be drawn separately from \n- * the map and offers styling options.\n- * \n- * With older versions of MapGuide, set useAsyncOverlay=false. Note that in\n- * this case a synchronous AJAX call is issued and the mapname and session\n- * parameters must be used to initialize the layer, not the mapdefinition\n- * parameter. Also note that this will issue a synchronous AJAX request \n- * before the image request can be issued so the users browser may lock\n- * up if the MG Web tier does not respond in a timely fashion.\n- **/\n- useAsyncOverlay: true,\n+ this.clear();\n+ },\n \n /**\n- * Constant: TILE_PARAMS\n- * {Object} Hashtable of default parameter key/value pairs for tiled layer\n+ * Method: onPreviousChange\n+ * Called when the previous history stack changes.\n+ *\n+ * Parameters:\n+ * state - {Object} An object representing the state to be restored\n+ * if previous is triggered again or null if no previous states remain.\n+ * length - {Integer} The number of remaining previous states that can\n+ * be restored.\n */\n- TILE_PARAMS: {\n- operation: 'GETTILEIMAGE',\n- version: '1.2.0'\n+ onPreviousChange: function(state, length) {\n+ if (state && !this.previous.active) {\n+ this.previous.activate();\n+ } else if (!state && this.previous.active) {\n+ this.previous.deactivate();\n+ }\n },\n \n /**\n- * Constant: SINGLE_TILE_PARAMS\n- * {Object} Hashtable of default parameter key/value pairs for untiled layer\n+ * Method: onNextChange\n+ * Called when the next history stack changes.\n+ *\n+ * Parameters:\n+ * state - {Object} An object representing the state to be restored\n+ * if next is triggered again or null if no next states remain.\n+ * length - {Integer} The number of remaining next states that can\n+ * be restored.\n */\n- SINGLE_TILE_PARAMS: {\n- operation: 'GETMAPIMAGE',\n- format: 'PNG',\n- locale: 'en',\n- clip: '1',\n- version: '1.0.0'\n+ onNextChange: function(state, length) {\n+ if (state && !this.next.active) {\n+ this.next.activate();\n+ } else if (!state && this.next.active) {\n+ this.next.deactivate();\n+ }\n },\n \n /**\n- * Constant: OVERLAY_PARAMS\n- * {Object} Hashtable of default parameter key/value pairs for untiled layer\n+ * APIMethod: destroy\n+ * Destroy the control.\n */\n- OVERLAY_PARAMS: {\n- operation: 'GETDYNAMICMAPOVERLAYIMAGE',\n- format: 'PNG',\n- locale: 'en',\n- clip: '1',\n- version: '2.0.0'\n+ destroy: function() {\n+ OpenLayers.Control.prototype.destroy.apply(this);\n+ this.previous.destroy();\n+ this.next.destroy();\n+ this.deactivate();\n+ for (var prop in this) {\n+ this[prop] = null;\n+ }\n },\n \n /** \n- * Constant: FOLDER_PARAMS\n- * {Object} Hashtable of parameter key/value pairs which describe \n- * the folder structure for tiles as configured in the mapguide \n- * serverconfig.ini section [TileServiceProperties]\n+ * Method: setMap\n+ * Set the map property for the control and and child\n+ * controls.\n+ *\n+ * Parameters:\n+ * map - {} \n */\n- FOLDER_PARAMS: {\n- tileColumnsPerFolder: 30,\n- tileRowsPerFolder: 30,\n- format: 'png',\n- querystring: null\n+ setMap: function(map) {\n+ this.map = map;\n+ this.next.setMap(map);\n+ this.previous.setMap(map);\n },\n \n- /** \n- * Property: defaultSize\n- * {} Tile size as produced by MapGuide server\n- **/\n- defaultSize: new OpenLayers.Size(300, 300),\n-\n- /** \n- * Property: tileOriginCorner\n- * {String} MapGuide tile server uses top-left as tile origin\n- **/\n- tileOriginCorner: \"tl\",\n+ /**\n+ * Method: draw\n+ * Called when the control is added to the map.\n+ */\n+ draw: function() {\n+ OpenLayers.Control.prototype.draw.apply(this, arguments);\n+ this.next.draw();\n+ this.previous.draw();\n+ },\n \n /**\n- * Constructor: OpenLayers.Layer.MapGuide\n- * Create a new Mapguide layer, either tiled or untiled. \n- *\n- * For tiled layers, the 'groupName' and 'mapDefinition' values \n- * must be specified as parameters in the constructor.\n- *\n- * For untiled base layers, specify either combination of 'mapName' and\n- * 'session', or 'mapDefinition' and 'locale'. \n- *\n- * For older versions of MapGuide and overlay layers, set useAsyncOverlay \n- * to false and in this case mapName and session are required parameters \n- * for the constructor.\n- *\n- * NOTE: MapGuide OS uses a DPI value and degrees to meters conversion \n- * factor that are different than the defaults used in OpenLayers, \n- * so these must be adjusted accordingly in your application. \n- * See the MapGuide example for how to set these values for MGOS.\n+ * Method: previousTrigger\n+ * Restore the previous state. If no items are in the previous history\n+ * stack, this has no effect.\n *\n- * Parameters:\n- * name - {String} Name of the layer displayed in the interface\n- * url - {String} Location of the MapGuide mapagent executable\n- * (e.g. http://localhost:8008/mapguide/mapagent/mapagent.fcgi)\n- * params - {Object} hashtable of additional parameters to use. Some\n- * parameters may require additional code on the server. The ones that\n- * you may want to use are: \n- * - mapDefinition - {String} The MapGuide resource definition\n- * (e.g. Library://Samples/Gmap/Maps/gmapTiled.MapDefinition)\n- * - locale - Locale setting \n- * (for untiled overlays layers only)\n- * - mapName - {String} Name of the map as stored in the MapGuide session.\n- * (for untiled layers with a session parameter only)\n- * - session - { String} MapGuide session ID \n- * (for untiled overlays layers only)\n- * - basemaplayergroupname - {String} GroupName for tiled MapGuide layers only\n- * - format - Image format to be returned (for untiled overlay layers only)\n- * - showLayers - {String} A comma separated list of GUID's for the\n- * layers to display eg: 'cvc-xcv34,453-345-345sdf'.\n- * - hideLayers - {String} A comma separated list of GUID's for the\n- * layers to hide eg: 'cvc-xcv34,453-345-345sdf'.\n- * - showGroups - {String} A comma separated list of GUID's for the\n- * groups to display eg: 'cvc-xcv34,453-345-345sdf'.\n- * - hideGroups - {String} A comma separated list of GUID's for the\n- * groups to hide eg: 'cvc-xcv34,453-345-345sdf'\n- * - selectionXml - {String} A selection xml string Some server plumbing\n- * is required to read such a value.\n- * options - {Object} Hashtable of extra options to tag onto the layer; \n- * will vary depending if tiled or untiled maps are being requested\n+ * Returns:\n+ * {Object} Item representing state that was restored. Undefined if no\n+ * items are in the previous history stack.\n */\n- initialize: function(name, url, params, options) {\n-\n- OpenLayers.Layer.Grid.prototype.initialize.apply(this, arguments);\n-\n- // unless explicitly set in options, if the layer is transparent, \n- // it will be an overlay\n- if (options == null || options.isBaseLayer == null) {\n- this.isBaseLayer = ((this.transparent != \"true\") &&\n- (this.transparent != true));\n- }\n-\n- if (options && options.useOverlay != null) {\n- this.useOverlay = options.useOverlay;\n- }\n-\n- //initialize for untiled layers\n- if (this.singleTile) {\n- if (this.useOverlay) {\n- OpenLayers.Util.applyDefaults(\n- this.params,\n- this.OVERLAY_PARAMS\n- );\n- if (!this.useAsyncOverlay) {\n- this.params.version = \"1.0.0\";\n- }\n- } else {\n- OpenLayers.Util.applyDefaults(\n- this.params,\n- this.SINGLE_TILE_PARAMS\n- );\n- }\n+ previousTrigger: function() {\n+ var current = this.previousStack.shift();\n+ var state = this.previousStack.shift();\n+ if (state != undefined) {\n+ this.nextStack.unshift(current);\n+ this.previousStack.unshift(state);\n+ this.restoring = true;\n+ this.restore(state);\n+ this.restoring = false;\n+ this.onNextChange(this.nextStack[0], this.nextStack.length);\n+ this.onPreviousChange(\n+ this.previousStack[1], this.previousStack.length - 1\n+ );\n } else {\n- //initialize for tiled layers\n- if (this.useHttpTile) {\n- OpenLayers.Util.applyDefaults(\n- this.params,\n- this.FOLDER_PARAMS\n- );\n- } else {\n- OpenLayers.Util.applyDefaults(\n- this.params,\n- this.TILE_PARAMS\n- );\n- }\n- this.setTileSize(this.defaultSize);\n+ this.previousStack.unshift(current);\n }\n+ return state;\n },\n \n /**\n- * Method: clone\n- * Create a clone of this layer\n+ * APIMethod: nextTrigger\n+ * Restore the next state. If no items are in the next history\n+ * stack, this has no effect. The next history stack is populated\n+ * as states are restored from the previous history stack.\n *\n * Returns:\n- * {} An exact clone of this layer\n+ * {Object} Item representing state that was restored. Undefined if no\n+ * items are in the next history stack.\n */\n- clone: function(obj) {\n- if (obj == null) {\n- obj = new OpenLayers.Layer.MapGuide(this.name,\n- this.url,\n- this.params,\n- this.getOptions());\n+ nextTrigger: function() {\n+ var state = this.nextStack.shift();\n+ if (state != undefined) {\n+ this.previousStack.unshift(state);\n+ this.restoring = true;\n+ this.restore(state);\n+ this.restoring = false;\n+ this.onNextChange(this.nextStack[0], this.nextStack.length);\n+ this.onPreviousChange(\n+ this.previousStack[1], this.previousStack.length - 1\n+ );\n }\n- //get all additions from superclasses\n- obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);\n+ return state;\n+ },\n \n- return obj;\n+ /**\n+ * APIMethod: clear\n+ * Clear history.\n+ */\n+ clear: function() {\n+ this.previousStack = [];\n+ this.previous.deactivate();\n+ this.nextStack = [];\n+ this.next.deactivate();\n },\n \n /**\n- * Method: getURL\n- * Return a query string for this layer\n- *\n- * Parameters:\n- * bounds - {} A bounds representing the bbox \n- * for the request\n+ * Method: getState\n+ * Get the current state and return it.\n *\n * Returns:\n- * {String} A string with the layer's url and parameters and also \n- * the passed-in bounds and appropriate tile size specified \n- * as parameters.\n+ * {Object} An object representing the current state.\n */\n- getURL: function(bounds) {\n- var url;\n- var center = bounds.getCenterLonLat();\n- var mapSize = this.map.getSize();\n-\n- if (this.singleTile) {\n- //set up the call for GETMAPIMAGE or GETDYNAMICMAPOVERLAY with\n- //dynamic map parameters\n- var params = {\n- setdisplaydpi: OpenLayers.DOTS_PER_INCH,\n- setdisplayheight: mapSize.h * this.ratio,\n- setdisplaywidth: mapSize.w * this.ratio,\n- setviewcenterx: center.lon,\n- setviewcentery: center.lat,\n- setviewscale: this.map.getScale()\n- };\n-\n- if (this.useOverlay && !this.useAsyncOverlay) {\n- //first we need to call GETVISIBLEMAPEXTENT to set the extent\n- var getVisParams = {};\n- getVisParams = OpenLayers.Util.extend(getVisParams, params);\n- getVisParams.operation = \"GETVISIBLEMAPEXTENT\";\n- getVisParams.version = \"1.0.0\";\n- getVisParams.session = this.params.session;\n- getVisParams.mapName = this.params.mapName;\n- getVisParams.format = 'text/xml';\n- url = this.getFullRequestString(getVisParams);\n-\n- OpenLayers.Request.GET({\n- url: url,\n- async: false\n- });\n- }\n- //construct the full URL\n- url = this.getFullRequestString(params);\n- } else {\n-\n- //tiled version\n- var currentRes = this.map.getResolution();\n- var colidx = Math.floor((bounds.left - this.maxExtent.left) / currentRes);\n- colidx = Math.round(colidx / this.tileSize.w);\n- var rowidx = Math.floor((this.maxExtent.top - bounds.top) / currentRes);\n- rowidx = Math.round(rowidx / this.tileSize.h);\n-\n- if (this.useHttpTile) {\n- url = this.getImageFilePath({\n- tilecol: colidx,\n- tilerow: rowidx,\n- scaleindex: this.resolutions.length - this.map.zoom - 1\n- });\n-\n- } else {\n- url = this.getFullRequestString({\n- tilecol: colidx,\n- tilerow: rowidx,\n- scaleindex: this.resolutions.length - this.map.zoom - 1\n- });\n- }\n- }\n- return url;\n+ getState: function() {\n+ return {\n+ center: this.map.getCenter(),\n+ resolution: this.map.getResolution(),\n+ projection: this.map.getProjectionObject(),\n+ units: this.map.getProjectionObject().getUnits() ||\n+ this.map.units || this.map.baseLayer.units\n+ };\n },\n \n /**\n- * Method: getFullRequestString\n- * getFullRequestString on MapGuide layers is special, because we \n- * do a regular expression replace on ',' in parameters to '+'.\n- * This is why it is subclassed here.\n+ * Method: restore\n+ * Update the state with the given object.\n *\n * Parameters:\n- * altUrl - {String} Alternative base URL to use.\n- *\n- * Returns:\n- * {String} A string with the layer's url appropriately encoded for MapGuide\n+ * state - {Object} An object representing the state to restore.\n */\n- getFullRequestString: function(newParams, altUrl) {\n- // use layer's url unless altUrl passed in\n- var url = (altUrl == null) ? this.url : altUrl;\n-\n- // if url is not a string, it should be an array of strings, \n- // in which case we will randomly select one of them in order\n- // to evenly distribute requests to different urls.\n- if (typeof url == \"object\") {\n- url = url[Math.floor(Math.random() * url.length)];\n- }\n- // requestString always starts with url\n- var requestString = url;\n-\n- // create a new params hashtable with all the layer params and the \n- // new params together. then convert to string\n- var allParams = OpenLayers.Util.extend({}, this.params);\n- allParams = OpenLayers.Util.extend(allParams, newParams);\n- // ignore parameters that are already in the url search string\n- var urlParams = OpenLayers.Util.upperCaseObject(\n- OpenLayers.Util.getParameters(url));\n- for (var key in allParams) {\n- if (key.toUpperCase() in urlParams) {\n- delete allParams[key];\n- }\n+ restore: function(state) {\n+ var center, zoom;\n+ if (this.map.getProjectionObject() == state.projection) {\n+ zoom = this.map.getZoomForResolution(state.resolution);\n+ center = state.center;\n+ } else {\n+ center = state.center.clone();\n+ center.transform(state.projection, this.map.getProjectionObject());\n+ var sourceUnits = state.units;\n+ var targetUnits = this.map.getProjectionObject().getUnits() ||\n+ this.map.units || this.map.baseLayer.units;\n+ var resolutionFactor = sourceUnits && targetUnits ?\n+ OpenLayers.INCHES_PER_UNIT[sourceUnits] / OpenLayers.INCHES_PER_UNIT[targetUnits] : 1;\n+ zoom = this.map.getZoomForResolution(resolutionFactor * state.resolution);\n }\n- var paramsString = OpenLayers.Util.getParameterString(allParams);\n-\n- /* MapGuide needs '+' seperating things like bounds/height/width.\n- Since typically this is URL encoded, we use a slight hack: we\n- depend on the list-like functionality of getParameterString to\n- leave ',' only in the case of list items (since otherwise it is\n- encoded) then do a regular expression replace on the , characters\n- to '+' */\n- paramsString = paramsString.replace(/,/g, \"+\");\n+ this.map.setCenter(center, zoom);\n+ },\n \n- if (paramsString != \"\") {\n- var lastServerChar = url.charAt(url.length - 1);\n- if ((lastServerChar == \"&\") || (lastServerChar == \"?\")) {\n- requestString += paramsString;\n- } else {\n- if (url.indexOf('?') == -1) {\n- //serverPath has no ? -- add one\n- requestString += '?' + paramsString;\n- } else {\n- //serverPath contains ?, so must already have paramsString at the end\n- requestString += '&' + paramsString;\n+ /**\n+ * Method: setListeners\n+ * Sets functions to be registered in the listeners object.\n+ */\n+ setListeners: function() {\n+ this.listeners = {};\n+ for (var type in this.registry) {\n+ this.listeners[type] = OpenLayers.Function.bind(function() {\n+ if (!this.restoring) {\n+ var state = this.registry[type].apply(this, arguments);\n+ this.previousStack.unshift(state);\n+ if (this.previousStack.length > 1) {\n+ this.onPreviousChange(\n+ this.previousStack[1], this.previousStack.length - 1\n+ );\n+ }\n+ if (this.previousStack.length > (this.limit + 1)) {\n+ this.previousStack.pop();\n+ }\n+ if (this.nextStack.length > 0) {\n+ this.nextStack = [];\n+ this.onNextChange(null, 0);\n+ }\n }\n- }\n+ return true;\n+ }, this);\n }\n- return requestString;\n },\n \n- /** \n- * Method: getImageFilePath\n- * special handler to request mapguide tiles from an http exposed tilecache \n- *\n- * Parameters:\n- * altUrl - {String} Alternative base URL to use.\n+ /**\n+ * APIMethod: activate\n+ * Activate the control. This registers any listeners.\n *\n * Returns:\n- * {String} A string with the url for the tile image\n+ * {Boolean} Control successfully activated.\n */\n- getImageFilePath: function(newParams, altUrl) {\n- // use layer's url unless altUrl passed in\n- var url = (altUrl == null) ? this.url : altUrl;\n-\n- // if url is not a string, it should be an array of strings, \n- // in which case we will randomly select one of them in order\n- // to evenly distribute requests to different urls.\n- if (typeof url == \"object\") {\n- url = url[Math.floor(Math.random() * url.length)];\n- }\n- // requestString always starts with url\n- var requestString = url;\n-\n- var tileRowGroup = \"\";\n- var tileColGroup = \"\";\n-\n- if (newParams.tilerow < 0) {\n- tileRowGroup = '-';\n- }\n-\n- if (newParams.tilerow == 0) {\n- tileRowGroup += '0';\n- } else {\n- tileRowGroup += Math.floor(Math.abs(newParams.tilerow / this.params.tileRowsPerFolder)) * this.params.tileRowsPerFolder;\n- }\n-\n- if (newParams.tilecol < 0) {\n- tileColGroup = '-';\n+ activate: function() {\n+ var activated = false;\n+ if (this.map) {\n+ if (OpenLayers.Control.prototype.activate.apply(this)) {\n+ if (this.listeners == null) {\n+ this.setListeners();\n+ }\n+ for (var type in this.listeners) {\n+ this.map.events.register(type, this, this.listeners[type]);\n+ }\n+ activated = true;\n+ if (this.previousStack.length == 0) {\n+ this.initStack();\n+ }\n+ }\n }\n+ return activated;\n+ },\n \n- if (newParams.tilecol == 0) {\n- tileColGroup += '0';\n- } else {\n- tileColGroup += Math.floor(Math.abs(newParams.tilecol / this.params.tileColumnsPerFolder)) * this.params.tileColumnsPerFolder;\n+ /**\n+ * Method: initStack\n+ * Called after the control is activated if the previous history stack is\n+ * empty.\n+ */\n+ initStack: function() {\n+ if (this.map.getCenter()) {\n+ this.listeners.moveend();\n }\n+ },\n \n- var tilePath = '/S' + Math.floor(newParams.scaleindex) +\n- '/' + this.params.basemaplayergroupname +\n- '/R' + tileRowGroup +\n- '/C' + tileColGroup +\n- '/' + (newParams.tilerow % this.params.tileRowsPerFolder) +\n- '_' + (newParams.tilecol % this.params.tileColumnsPerFolder) +\n- '.' + this.params.format;\n-\n- if (this.params.querystring) {\n- tilePath += \"?\" + this.params.querystring;\n+ /**\n+ * APIMethod: deactivate\n+ * Deactivate the control. This unregisters any listeners.\n+ *\n+ * Returns:\n+ * {Boolean} Control successfully deactivated.\n+ */\n+ deactivate: function() {\n+ var deactivated = false;\n+ if (this.map) {\n+ if (OpenLayers.Control.prototype.deactivate.apply(this)) {\n+ for (var type in this.listeners) {\n+ this.map.events.unregister(\n+ type, this, this.listeners[type]\n+ );\n+ }\n+ if (this.clearOnDeactivate) {\n+ this.clear();\n+ }\n+ deactivated = true;\n+ }\n }\n-\n- requestString += tilePath;\n- return requestString;\n+ return deactivated;\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.MapGuide\"\n+ CLASS_NAME: \"OpenLayers.Control.NavigationHistory\"\n });\n+\n /* ======================================================================\n- OpenLayers/Layer/ArcGIS93Rest.js\n+ OpenLayers/Control/CacheRead.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Layer/Grid.js\n+ * @requires OpenLayers/Control.js\n */\n \n /**\n- * Class: OpenLayers.Layer.ArcGIS93Rest\n- * Instances of OpenLayers.Layer.ArcGIS93Rest are used to display data from\n- * ESRI ArcGIS Server 9.3 (and up?) Mapping Services using the REST API.\n- * Create a new ArcGIS93Rest layer with the \n- * constructor. More detail on the REST API is available at\n- * http://sampleserver1.arcgisonline.com/ArcGIS/SDK/REST/index.html ;\n- * specifically, the URL provided to this layer should be an export service\n- * URL: http://sampleserver1.arcgisonline.com/ArcGIS/SDK/REST/export.html \n- * \n+ * Class: OpenLayers.Control.CacheRead\n+ * A control for using image tiles cached with \n+ * from the browser's local storage.\n+ *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.ArcGIS93Rest = OpenLayers.Class(OpenLayers.Layer.Grid, {\n+OpenLayers.Control.CacheRead = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * Constant: DEFAULT_PARAMS\n- * {Object} Hashtable of default parameter key/value pairs \n+ * APIProperty: fetchEvent\n+ * {String} The layer event to listen to for replacing remote resource tile\n+ * URLs with cached data URIs. Supported values are \"tileerror\" (try\n+ * remote first, fall back to cached) and \"tileloadstart\" (try cache\n+ * first, fall back to remote). Default is \"tileloadstart\".\n+ *\n+ * Note that \"tileerror\" will not work for CORS enabled images (see\n+ * https://developer.mozilla.org/en/CORS_Enabled_Image), i.e. layers\n+ * configured with a in\n+ * .\n */\n- DEFAULT_PARAMS: {\n- format: \"png\"\n- },\n+ fetchEvent: \"tileloadstart\",\n \n /**\n- * APIProperty: isBaseLayer\n- * {Boolean} Default is true for ArcGIS93Rest layer\n+ * APIProperty: layers\n+ * {Array()}. Optional. If provided, only these\n+ * layers will receive tiles from the cache.\n */\n- isBaseLayer: true,\n-\n+ layers: null,\n \n /**\n- * Constructor: OpenLayers.Layer.ArcGIS93Rest\n- * Create a new ArcGIS93Rest layer object.\n- *\n- * Example:\n- * (code)\n- * var arcims = new OpenLayers.Layer.ArcGIS93Rest(\"MyName\",\n- * \"http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/export\", \n- * {\n- * layers: \"0,1,2\"\n- * });\n- * (end)\n- *\n- * Parameters:\n- * name - {String} A name for the layer\n- * url - {String} Base url for the ArcGIS server REST service\n- * options - {Object} An object with key/value pairs representing the\n- * options and option values.\n- *\n- * Valid Options:\n- * format - {String} MIME type of desired image type.\n- * layers - {String} Comma-separated list of layers to display.\n- * srs - {String} Projection ID.\n+ * APIProperty: autoActivate\n+ * {Boolean} Activate the control when it is added to a map. Default is\n+ * true.\n */\n- initialize: function(name, url, params, options) {\n- var newArguments = [];\n- //uppercase params\n- params = OpenLayers.Util.upperCaseObject(params);\n- newArguments.push(name, url, params, options);\n- OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);\n- OpenLayers.Util.applyDefaults(\n- this.params,\n- OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)\n- );\n-\n- //layer is transparent \n- if (this.params.TRANSPARENT &&\n- this.params.TRANSPARENT.toString().toLowerCase() == \"true\") {\n-\n- // unless explicitly set in options, make layer an overlay\n- if ((options == null) || (!options.isBaseLayer)) {\n- this.isBaseLayer = false;\n- }\n-\n- // jpegs can never be transparent, so intelligently switch the \n- // format, depending on the browser's capabilities\n- if (this.params.FORMAT == \"jpg\") {\n- this.params.FORMAT = OpenLayers.Util.alphaHack() ? \"gif\" :\n- \"png\";\n- }\n- }\n- },\n+ autoActivate: true,\n \n /**\n- * Method: clone\n- * Create a clone of this layer\n+ * Constructor: OpenLayers.Control.CacheRead\n *\n- * Returns:\n- * {} An exact clone of this layer\n+ * Parameters:\n+ * options - {Object} Object with API properties for this control\n */\n- clone: function(obj) {\n \n- if (obj == null) {\n- obj = new OpenLayers.Layer.ArcGIS93Rest(this.name,\n- this.url,\n- this.params,\n- this.getOptions());\n+ /** \n+ * Method: setMap\n+ * Set the map property for the control. \n+ * \n+ * Parameters:\n+ * map - {} \n+ */\n+ setMap: function(map) {\n+ OpenLayers.Control.prototype.setMap.apply(this, arguments);\n+ var i, layers = this.layers || map.layers;\n+ for (i = layers.length - 1; i >= 0; --i) {\n+ this.addLayer({\n+ layer: layers[i]\n+ });\n+ }\n+ if (!this.layers) {\n+ map.events.on({\n+ addlayer: this.addLayer,\n+ removeLayer: this.removeLayer,\n+ scope: this\n+ });\n }\n-\n- //get all additions from superclasses\n- obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);\n-\n- // copy/set any non-init, non-simple values here\n-\n- return obj;\n },\n \n-\n /**\n- * Method: getURL\n- * Return an image url this layer.\n+ * Method: addLayer\n+ * Adds a layer to the control. Once added, tiles requested for this layer\n+ * will be cached.\n *\n * Parameters:\n- * bounds - {} A bounds representing the bbox for the\n- * request.\n- *\n- * Returns:\n- * {String} A string with the map image's url.\n+ * evt - {Object} Object with a layer property referencing an\n+ * instance\n */\n- getURL: function(bounds) {\n- bounds = this.adjustBounds(bounds);\n-\n- // ArcGIS Server only wants the numeric portion of the projection ID.\n- var projWords = this.projection.getCode().split(\":\");\n- var srid = projWords[projWords.length - 1];\n-\n- var imageSize = this.getImageSize();\n- var newParams = {\n- 'BBOX': bounds.toBBOX(),\n- 'SIZE': imageSize.w + \",\" + imageSize.h,\n- // We always want image, the other options were json, image with a whole lotta html around it, etc.\n- 'F': \"image\",\n- 'BBOXSR': srid,\n- 'IMAGESR': srid\n- };\n-\n- // Now add the filter parameters.\n- if (this.layerDefs) {\n- var layerDefStrList = [];\n- var layerID;\n- for (layerID in this.layerDefs) {\n- if (this.layerDefs.hasOwnProperty(layerID)) {\n- if (this.layerDefs[layerID]) {\n- layerDefStrList.push(layerID);\n- layerDefStrList.push(\":\");\n- layerDefStrList.push(this.layerDefs[layerID]);\n- layerDefStrList.push(\";\");\n- }\n- }\n- }\n- if (layerDefStrList.length > 0) {\n- newParams['LAYERDEFS'] = layerDefStrList.join(\"\");\n- }\n- }\n- var requestString = this.getFullRequestString(newParams);\n- return requestString;\n+ addLayer: function(evt) {\n+ evt.layer.events.register(this.fetchEvent, this, this.fetch);\n },\n \n /**\n- * Method: setLayerFilter\n- * addTile creates a tile, initializes it, and adds it to the layer div. \n+ * Method: removeLayer\n+ * Removes a layer from the control. Once removed, tiles requested for this\n+ * layer will no longer be cached.\n *\n * Parameters:\n- * id - {String} The id of the layer to which the filter applies.\n- * queryDef - {String} A sql-ish query filter, for more detail see the ESRI\n- * documentation at http://sampleserver1.arcgisonline.com/ArcGIS/SDK/REST/export.html\n+ * evt - {Object} Object with a layer property referencing an\n+ * instance\n */\n- setLayerFilter: function(id, queryDef) {\n- if (!this.layerDefs) {\n- this.layerDefs = {};\n- }\n- if (queryDef) {\n- this.layerDefs[id] = queryDef;\n- } else {\n- delete this.layerDefs[id];\n- }\n+ removeLayer: function(evt) {\n+ evt.layer.events.unregister(this.fetchEvent, this, this.fetch);\n },\n \n /**\n- * Method: clearLayerFilter\n- * Clears layer filters, either from a specific layer,\n- * or all of them.\n+ * Method: fetch\n+ * Listener to the event. Replaces a tile's url with a data\n+ * URI from the cache.\n *\n * Parameters:\n- * id - {String} The id of the layer from which to remove any\n- * filter. If unspecified/blank, all filters\n- * will be removed.\n+ * evt - {Object} Event object with a tile property.\n */\n- clearLayerFilter: function(id) {\n- if (id) {\n- delete this.layerDefs[id];\n- } else {\n- delete this.layerDefs;\n+ fetch: function(evt) {\n+ if (this.active && window.localStorage &&\n+ evt.tile instanceof OpenLayers.Tile.Image) {\n+ var tile = evt.tile,\n+ url = tile.url;\n+ // deal with modified tile urls when both CacheWrite and CacheRead\n+ // are active\n+ if (!tile.layer.crossOriginKeyword && OpenLayers.ProxyHost &&\n+ url.indexOf(OpenLayers.ProxyHost) === 0) {\n+ url = OpenLayers.Control.CacheWrite.urlMap[url];\n+ }\n+ var dataURI = window.localStorage.getItem(\"olCache_\" + url);\n+ if (dataURI) {\n+ tile.url = dataURI;\n+ if (evt.type === \"tileerror\") {\n+ tile.setImgSrc(dataURI);\n+ }\n+ }\n }\n },\n \n /**\n- * APIMethod: mergeNewParams\n- * Catch changeParams and uppercase the new params to be merged in\n- * before calling changeParams on the super class.\n- * \n- * Once params have been changed, the tiles will be reloaded with\n- * the new parameters.\n- * \n- * Parameters:\n- * newParams - {Object} Hashtable of new params to use\n+ * Method: destroy\n+ * The destroy method is used to perform any clean up before the control\n+ * is dereferenced. Typically this is where event listeners are removed\n+ * to prevent memory leaks.\n */\n- mergeNewParams: function(newParams) {\n- var upperParams = OpenLayers.Util.upperCaseObject(newParams);\n- var newArguments = [upperParams];\n- return OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this,\n- newArguments);\n+ destroy: function() {\n+ if (this.layers || this.map) {\n+ var i, layers = this.layers || this.map.layers;\n+ for (i = layers.length - 1; i >= 0; --i) {\n+ this.removeLayer({\n+ layer: layers[i]\n+ });\n+ }\n+ }\n+ if (this.map) {\n+ this.map.events.un({\n+ addlayer: this.addLayer,\n+ removeLayer: this.removeLayer,\n+ scope: this\n+ });\n+ }\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.ArcGIS93Rest\"\n+ CLASS_NAME: \"OpenLayers.Control.CacheRead\"\n });\n /* ======================================================================\n- OpenLayers/Layer/TileCache.js\n+ OpenLayers/Control/CacheWrite.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/Layer/Grid.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Request.js\n+ * @requires OpenLayers/Console.js\n */\n \n /**\n- * Class: OpenLayers.Layer.TileCache\n- * A read only TileCache layer. Used to requests tiles cached by TileCache in\n- * a web accessible cache. This means that you have to pre-populate your\n- * cache before this layer can be used. It is meant only to read tiles\n- * created by TileCache, and not to make calls to TileCache for tile\n- * creation. Create a new instance with the\n- * constructor.\n+ * Class: OpenLayers.Control.CacheWrite\n+ * A control for caching image tiles in the browser's local storage. The\n+ * control is used to fetch and use the cached\n+ * tile images.\n+ *\n+ * Note: Before using this control on any layer that is not your own, make sure\n+ * that the terms of service of the tile provider allow local storage of tiles.\n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.TileCache = OpenLayers.Class(OpenLayers.Layer.Grid, {\n+OpenLayers.Control.CacheWrite = OpenLayers.Class(OpenLayers.Control, {\n \n /** \n- * APIProperty: isBaseLayer\n- * {Boolean} Treat this layer as a base layer. Default is true.\n+ * APIProperty: events\n+ * {} Events instance for listeners and triggering\n+ * control specific events.\n+ *\n+ * To register events in the constructor, configure .\n+ *\n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * control.events.register(type, obj, listener);\n+ * (end)\n+ *\n+ * Supported event types (in addition to those from ):\n+ * cachefull - Triggered when the cache is full. Listeners receive an\n+ * object with a tile property as first argument. The tile references\n+ * the tile that couldn't be cached.\n */\n- isBaseLayer: true,\n \n- /** \n- * APIProperty: format\n- * {String} Mime type of the images returned. Default is image/png.\n+ /**\n+ * APIProperty: eventListeners\n+ * {Object} Object with event listeners, keyed by event name. An optional\n+ * scope property defines the scope that listeners will be executed in.\n */\n- format: 'image/png',\n \n /**\n- * APIProperty: serverResolutions\n- * {Array} A list of all resolutions available on the server. Only set this\n- * property if the map resolutions differ from the server. This\n- * property serves two purposes. (a) can include\n- * resolutions that the server supports and that you don't want to\n- * provide with this layer. (b) The map can work with resolutions\n- * that aren't supported by the server, i.e. that aren't in\n- * . When the map is displayed in such a resolution\n- * data for the closest server-supported resolution is loaded and the\n- * layer div is stretched as necessary.\n+ * APIProperty: layers\n+ * {Array()}. Optional. If provided, caching\n+ * will be enabled for these layers only, otherwise for all cacheable\n+ * layers.\n */\n- serverResolutions: null,\n+ layers: null,\n \n /**\n- * Constructor: OpenLayers.Layer.TileCache\n- * Create a new read only TileCache layer.\n+ * APIProperty: imageFormat\n+ * {String} The image format used for caching. The default is \"image/png\".\n+ * Supported formats depend on the user agent. If an unsupported\n+ * is provided, \"image/png\" will be used. For aerial\n+ * imagery, \"image/jpeg\" is recommended.\n+ */\n+ imageFormat: \"image/png\",\n+\n+ /**\n+ * Property: quotaRegEx\n+ * {RegExp}\n+ */\n+ quotaRegEx: (/quota/i),\n+\n+ /**\n+ * Constructor: OpenLayers.Control.CacheWrite\n *\n * Parameters:\n- * name - {String} Name of the layer displayed in the interface\n- * url - {String} Location of the web accessible cache (not the location of\n- * your tilecache script!)\n- * layername - {String} Layer name as defined in the TileCache \n- * configuration\n- * options - {Object} Optional object with properties to be set on the\n- * layer. Note that you should speficy your resolutions to match\n- * your TileCache configuration. This can be done by setting\n- * the resolutions array directly (here or on the map), by setting\n- * maxResolution and numZoomLevels, or by using scale based properties.\n+ * options - {Object} Object with API properties for this control.\n */\n- initialize: function(name, url, layername, options) {\n- this.layername = layername;\n- OpenLayers.Layer.Grid.prototype.initialize.apply(this,\n- [name, url, {}, options]);\n- this.extension = this.format.split('/')[1].toLowerCase();\n- this.extension = (this.extension == 'jpg') ? 'jpeg' : this.extension;\n- },\n \n- /**\n- * APIMethod: clone\n- * obj - {Object} \n+ /** \n+ * Method: setMap\n+ * Set the map property for the control. \n * \n- * Returns:\n- * {} An exact clone of this \n- * \n+ * Parameters:\n+ * map - {} \n */\n- clone: function(obj) {\n-\n- if (obj == null) {\n- obj = new OpenLayers.Layer.TileCache(this.name,\n- this.url,\n- this.layername,\n- this.getOptions());\n+ setMap: function(map) {\n+ OpenLayers.Control.prototype.setMap.apply(this, arguments);\n+ var i, layers = this.layers || map.layers;\n+ for (i = layers.length - 1; i >= 0; --i) {\n+ this.addLayer({\n+ layer: layers[i]\n+ });\n }\n+ if (!this.layers) {\n+ map.events.on({\n+ addlayer: this.addLayer,\n+ removeLayer: this.removeLayer,\n+ scope: this\n+ });\n+ }\n+ },\n \n- //get all additions from superclasses\n- obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);\n+ /**\n+ * Method: addLayer\n+ * Adds a layer to the control. Once added, tiles requested for this layer\n+ * will be cached.\n+ *\n+ * Parameters:\n+ * evt - {Object} Object with a layer property referencing an\n+ * instance\n+ */\n+ addLayer: function(evt) {\n+ evt.layer.events.on({\n+ tileloadstart: this.makeSameOrigin,\n+ tileloaded: this.onTileLoaded,\n+ scope: this\n+ });\n+ },\n \n- // copy/set any non-init, non-simple values here\n+ /**\n+ * Method: removeLayer\n+ * Removes a layer from the control. Once removed, tiles requested for this\n+ * layer will no longer be cached.\n+ *\n+ * Parameters:\n+ * evt - {Object} Object with a layer property referencing an\n+ * instance\n+ */\n+ removeLayer: function(evt) {\n+ evt.layer.events.un({\n+ tileloadstart: this.makeSameOrigin,\n+ tileloaded: this.onTileLoaded,\n+ scope: this\n+ });\n+ },\n \n- return obj;\n+ /**\n+ * Method: makeSameOrigin\n+ * If the tile does not have CORS image loading enabled and is from a\n+ * different origin, use OpenLayers.ProxyHost to make it a same origin url.\n+ *\n+ * Parameters:\n+ * evt - {}\n+ */\n+ makeSameOrigin: function(evt) {\n+ if (this.active) {\n+ var tile = evt.tile;\n+ if (tile instanceof OpenLayers.Tile.Image &&\n+ !tile.crossOriginKeyword &&\n+ tile.url.substr(0, 5) !== \"data:\") {\n+ var sameOriginUrl = OpenLayers.Request.makeSameOrigin(\n+ tile.url, OpenLayers.ProxyHost\n+ );\n+ OpenLayers.Control.CacheWrite.urlMap[sameOriginUrl] = tile.url;\n+ tile.url = sameOriginUrl;\n+ }\n+ }\n },\n \n /**\n- * Method: getURL\n+ * Method: onTileLoaded\n+ * Decides whether a tile can be cached and calls the cache method.\n *\n * Parameters:\n- * bounds - {} \n- * \n- * Returns:\n- * {String} A string with the layer's url and parameters and also the \n- * passed-in bounds and appropriate tile size specified as parameters.\n+ * evt - {Event}\n */\n- getURL: function(bounds) {\n- var res = this.getServerResolution();\n- var bbox = this.maxExtent;\n- var size = this.tileSize;\n- var tileX = Math.round((bounds.left - bbox.left) / (res * size.w));\n- var tileY = Math.round((bounds.bottom - bbox.bottom) / (res * size.h));\n- var tileZ = this.serverResolutions != null ?\n- OpenLayers.Util.indexOf(this.serverResolutions, res) :\n- this.map.getZoom();\n+ onTileLoaded: function(evt) {\n+ if (this.active && !evt.aborted &&\n+ evt.tile instanceof OpenLayers.Tile.Image &&\n+ evt.tile.url.substr(0, 5) !== 'data:') {\n+ this.cache({\n+ tile: evt.tile\n+ });\n+ delete OpenLayers.Control.CacheWrite.urlMap[evt.tile.url];\n+ }\n+ },\n \n- var components = [\n- this.layername,\n- OpenLayers.Number.zeroPad(tileZ, 2),\n- OpenLayers.Number.zeroPad(parseInt(tileX / 1000000), 3),\n- OpenLayers.Number.zeroPad((parseInt(tileX / 1000) % 1000), 3),\n- OpenLayers.Number.zeroPad((parseInt(tileX) % 1000), 3),\n- OpenLayers.Number.zeroPad(parseInt(tileY / 1000000), 3),\n- OpenLayers.Number.zeroPad((parseInt(tileY / 1000) % 1000), 3),\n- OpenLayers.Number.zeroPad((parseInt(tileY) % 1000), 3) + '.' + this.extension\n- ];\n- var path = components.join('/');\n- var url = this.url;\n- if (OpenLayers.Util.isArray(url)) {\n- url = this.selectUrl(path, url);\n+ /**\n+ * Method: cache\n+ * Adds a tile to the cache. When the cache is full, the \"cachefull\" event\n+ * is triggered.\n+ *\n+ * Parameters:\n+ * obj - {Object} Object with a tile property, tile being the\n+ * with the data to add to the cache\n+ */\n+ cache: function(obj) {\n+ if (window.localStorage) {\n+ var tile = obj.tile;\n+ try {\n+ var canvasContext = tile.getCanvasContext();\n+ if (canvasContext) {\n+ var urlMap = OpenLayers.Control.CacheWrite.urlMap;\n+ var url = urlMap[tile.url] || tile.url;\n+ window.localStorage.setItem(\n+ \"olCache_\" + url,\n+ canvasContext.canvas.toDataURL(this.imageFormat)\n+ );\n+ }\n+ } catch (e) {\n+ // local storage full or CORS violation\n+ var reason = e.name || e.message;\n+ if (reason && this.quotaRegEx.test(reason)) {\n+ this.events.triggerEvent(\"cachefull\", {\n+ tile: tile\n+ });\n+ } else {\n+ OpenLayers.Console.error(e.toString());\n+ }\n+ }\n }\n- url = (url.charAt(url.length - 1) == '/') ? url : url + '/';\n- return url + path;\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.TileCache\"\n+ /**\n+ * Method: destroy\n+ * The destroy method is used to perform any clean up before the control\n+ * is dereferenced. Typically this is where event listeners are removed\n+ * to prevent memory leaks.\n+ */\n+ destroy: function() {\n+ if (this.layers || this.map) {\n+ var i, layers = this.layers || this.map.layers;\n+ for (i = layers.length - 1; i >= 0; --i) {\n+ this.removeLayer({\n+ layer: layers[i]\n+ });\n+ }\n+ }\n+ if (this.map) {\n+ this.map.events.un({\n+ addlayer: this.addLayer,\n+ removeLayer: this.removeLayer,\n+ scope: this\n+ });\n+ }\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Control.CacheWrite\"\n });\n+\n+/**\n+ * APIFunction: OpenLayers.Control.CacheWrite.clearCache\n+ * Clears all tiles cached with from the cache.\n+ */\n+OpenLayers.Control.CacheWrite.clearCache = function() {\n+ if (!window.localStorage) {\n+ return;\n+ }\n+ var i, key;\n+ for (i = window.localStorage.length - 1; i >= 0; --i) {\n+ key = window.localStorage.key(i);\n+ if (key.substr(0, 8) === \"olCache_\") {\n+ window.localStorage.removeItem(key);\n+ }\n+ }\n+};\n+\n+/**\n+ * Property: OpenLayers.Control.CacheWrite.urlMap\n+ * {Object} Mapping of same origin urls to cache url keys. Entries will be\n+ * deleted as soon as a tile was cached.\n+ */\n+OpenLayers.Control.CacheWrite.urlMap = {};\n+\n+\n /* ======================================================================\n- OpenLayers/Layer/WMTS.js\n+ OpenLayers/Control/Graticule.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Layer/Grid.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Lang.js\n+ * @requires OpenLayers/Rule.js\n+ * @requires OpenLayers/StyleMap.js\n+ * @requires OpenLayers/Layer/Vector.js\n */\n \n /**\n- * Class: OpenLayers.Layer.WMTS\n- * Instances of the WMTS class allow viewing of tiles from a service that \n- * implements the OGC WMTS specification version 1.0.0.\n+ * Class: OpenLayers.Control.Graticule\n+ * The Graticule displays a grid of latitude/longitude lines reprojected on\n+ * the map. \n * \n * Inherits from:\n- * - \n+ * - \n+ * \n */\n-OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {\n-\n- /**\n- * APIProperty: isBaseLayer\n- * {Boolean} The layer will be considered a base layer. Default is true.\n- */\n- isBaseLayer: true,\n-\n- /**\n- * Property: version\n- * {String} WMTS version. Default is \"1.0.0\".\n- */\n- version: \"1.0.0\",\n-\n- /**\n- * APIProperty: requestEncoding\n- * {String} Request encoding. Can be \"REST\" or \"KVP\". Default is \"KVP\".\n- */\n- requestEncoding: \"KVP\",\n-\n- /**\n- * APIProperty: url\n- * {String|Array(String)} The base URL or request URL template for the WMTS\n- * service. Must be provided. Array is only supported for base URLs, not\n- * for request URL templates. URL templates are only supported for\n- * REST .\n- */\n- url: null,\n+OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * APIProperty: layer\n- * {String} The layer identifier advertised by the WMTS service. Must be \n- * provided.\n- */\n- layer: null,\n-\n- /** \n- * APIProperty: matrixSet\n- * {String} One of the advertised matrix set identifiers. Must be provided.\n- */\n- matrixSet: null,\n-\n- /** \n- * APIProperty: style\n- * {String} One of the advertised layer styles. Must be provided.\n- */\n- style: null,\n-\n- /** \n- * APIProperty: format\n- * {String} The image MIME type. Default is \"image/jpeg\".\n+ * APIProperty: autoActivate\n+ * {Boolean} Activate the control when it is added to a map. Default is\n+ * true. \n */\n- format: \"image/jpeg\",\n+ autoActivate: true,\n \n /**\n- * APIProperty: tileOrigin\n- * {} The top-left corner of the tile matrix in map \n- * units. If the tile origin for each matrix in a set is different,\n- * the should include a topLeftCorner property. If\n- * not provided, the tile origin will default to the top left corner\n- * of the layer .\n+ * APIProperty: intervals\n+ * {Array(Float)} A list of possible graticule widths in degrees.\n */\n- tileOrigin: null,\n+ intervals: [45, 30, 20, 10, 5, 2, 1,\n+ 0.5, 0.2, 0.1, 0.05, 0.01,\n+ 0.005, 0.002, 0.001\n+ ],\n \n /**\n- * APIProperty: tileFullExtent\n- * {} The full extent of the tile set. If not supplied,\n- * the layer's property will be used.\n+ * APIProperty: displayInLayerSwitcher\n+ * {Boolean} Allows the Graticule control to be switched on and off by \n+ * LayerSwitcher control. Defaults is true.\n */\n- tileFullExtent: null,\n+ displayInLayerSwitcher: true,\n \n /**\n- * APIProperty: formatSuffix\n- * {String} For REST request encoding, an image format suffix must be \n- * included in the request. If not provided, the suffix will be derived\n- * from the property.\n+ * APIProperty: visible\n+ * {Boolean} should the graticule be initially visible (default=true)\n */\n- formatSuffix: null,\n+ visible: true,\n \n /**\n- * APIProperty: matrixIds\n- * {Array} A list of tile matrix identifiers. If not provided, the matrix\n- * identifiers will be assumed to be integers corresponding to the \n- * map zoom level. If a list of strings is provided, each item should\n- * be the matrix identifier that corresponds to the map zoom level.\n- * Additionally, a list of objects can be provided. Each object should\n- * describe the matrix as presented in the WMTS capabilities. These\n- * objects should have the propertes shown below.\n- * \n- * Matrix properties:\n- * identifier - {String} The matrix identifier (required).\n- * scaleDenominator - {Number} The matrix scale denominator.\n- * topLeftCorner - {} The top left corner of the \n- * matrix. Must be provided if different than the layer .\n- * tileWidth - {Number} The tile width for the matrix. Must be provided \n- * if different than the width given in the layer .\n- * tileHeight - {Number} The tile height for the matrix. Must be provided \n- * if different than the height given in the layer .\n+ * APIProperty: numPoints\n+ * {Integer} The number of points to use in each graticule line. Higher\n+ * numbers result in a smoother curve for projected maps \n */\n- matrixIds: null,\n+ numPoints: 50,\n \n /**\n- * APIProperty: dimensions\n- * {Array} For RESTful request encoding, extra dimensions may be specified.\n- * Items in this list should be property names in the object.\n- * Values of extra dimensions will be determined from the corresponding\n- * values in the object.\n+ * APIProperty: targetSize\n+ * {Integer} The maximum size of the grid in pixels on the map\n */\n- dimensions: null,\n+ targetSize: 200,\n \n /**\n- * APIProperty: params\n- * {Object} Extra parameters to include in tile requests. For KVP \n- * , these properties will be encoded in the request \n- * query string. For REST , these properties will\n- * become part of the request path, with order determined by the \n- * list.\n+ * APIProperty: layerName\n+ * {String} The name to be displayed in the layer switcher, default is set \n+ * by {}.\n */\n- params: null,\n+ layerName: null,\n \n /**\n- * APIProperty: zoomOffset\n- * {Number} If your cache has more levels than you want to provide\n- * access to with this layer, supply a zoomOffset. This zoom offset\n- * is added to the current map zoom level to determine the level\n- * for a requested tile. For example, if you supply a zoomOffset\n- * of 3, when the map is at the zoom 0, tiles will be requested from\n- * level 3 of your cache. Default is 0 (assumes cache level and map\n- * zoom are equivalent). Additionally, if this layer is to be used\n- * as an overlay and the cache has fewer zoom levels than the base\n- * layer, you can supply a negative zoomOffset. For example, if a\n- * map zoom level of 1 corresponds to your cache level zero, you would\n- * supply a -1 zoomOffset (and set the maxResolution of the layer\n- * appropriately). The zoomOffset value has no effect if complete\n- * matrix definitions (including scaleDenominator) are supplied in\n- * the property. Defaults to 0 (no zoom offset).\n+ * APIProperty: labelled\n+ * {Boolean} Should the graticule lines be labelled?. default=true\n */\n- zoomOffset: 0,\n+ labelled: true,\n \n /**\n- * APIProperty: serverResolutions\n- * {Array} A list of all resolutions available on the server. Only set this\n- * property if the map resolutions differ from the server. This\n- * property serves two purposes. (a) can include\n- * resolutions that the server supports and that you don't want to\n- * provide with this layer; you can also look at , which is\n- * an alternative to for that specific purpose.\n- * (b) The map can work with resolutions that aren't supported by\n- * the server, i.e. that aren't in . When the\n- * map is displayed in such a resolution data for the closest\n- * server-supported resolution is loaded and the layer div is\n- * stretched as necessary.\n+ * APIProperty: labelFormat\n+ * {String} the format of the labels, default = 'dm'. See\n+ * for other options.\n */\n- serverResolutions: null,\n+ labelFormat: 'dm',\n \n /**\n- * Property: formatSuffixMap\n- * {Object} a map between WMTS 'format' request parameter and tile image file suffix\n+ * APIProperty: lineSymbolizer\n+ * {symbolizer} the symbolizer used to render lines\n */\n- formatSuffixMap: {\n- \"image/png\": \"png\",\n- \"image/png8\": \"png\",\n- \"image/png24\": \"png\",\n- \"image/png32\": \"png\",\n- \"png\": \"png\",\n- \"image/jpeg\": \"jpg\",\n- \"image/jpg\": \"jpg\",\n- \"jpeg\": \"jpg\",\n- \"jpg\": \"jpg\"\n+ lineSymbolizer: {\n+ strokeColor: \"#333\",\n+ strokeWidth: 1,\n+ strokeOpacity: 0.5\n },\n \n /**\n- * Property: matrix\n- * {Object} Matrix definition for the current map resolution. Updated by\n- * the method.\n+ * APIProperty: labelSymbolizer\n+ * {symbolizer} the symbolizer used to render labels\n */\n- matrix: null,\n+ labelSymbolizer: {},\n \n /**\n- * Constructor: OpenLayers.Layer.WMTS\n- * Create a new WMTS layer.\n- *\n- * Example:\n- * (code)\n- * var wmts = new OpenLayers.Layer.WMTS({\n- * name: \"My WMTS Layer\",\n- * url: \"http://example.com/wmts\", \n- * layer: \"layer_id\",\n- * style: \"default\",\n- * matrixSet: \"matrix_id\"\n- * });\n- * (end)\n- *\n- * Parameters:\n- * config - {Object} Configuration properties for the layer.\n- *\n- * Required configuration properties:\n- * url - {String} The base url for the service. See the property.\n- * layer - {String} The layer identifier. See the property.\n- * style - {String} The layer style identifier. See the