[OpenLayers-Commits] r10912 - in sandbox/bartvde/openls/openlayers: examples lib lib/OpenLayers/Format

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Tue Nov 23 09:19:10 EST 2010


Author: bartvde
Date: 2010-11-23 06:19:09 -0800 (Tue, 23 Nov 2010)
New Revision: 10912

Added:
   sandbox/bartvde/openls/openlayers/examples/openls.html
   sandbox/bartvde/openls/openlayers/lib/OpenLayers/Format/XLS.js
   sandbox/bartvde/openls/openlayers/lib/OpenLayers/Format/XLS/
Modified:
   sandbox/bartvde/openls/openlayers/lib/OpenLayers.js
Log:
work in progress

Added: sandbox/bartvde/openls/openlayers/examples/openls.html
===================================================================
--- sandbox/bartvde/openls/openlayers/examples/openls.html	                        (rev 0)
+++ sandbox/bartvde/openls/openlayers/examples/openls.html	2010-11-23 14:19:09 UTC (rev 10912)
@@ -0,0 +1,38 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
+    <link rel="stylesheet" href="style.css" type="text/css" />
+    <script src="../lib/OpenLayers.js"></script>
+    <script type="text/javascript">
+        var lon = 5;
+        var lat = 40;
+        var zoom = 5;
+        var map, layer;
+
+        function init(){
+            var format = new OpenLayers.Format.XLS();
+            var request = format.write({header: {clientName: 'ArcLocation'}});
+            console.log(request);
+        }
+    </script>
+  </head>
+  <body onload="init()">
+    <h1 id="title"> WMS Untiled Example</h1>
+
+    <div id="tags">
+        singletile, tile
+    </div>
+        <p id="shortdesc">
+            Shows an example of an "untiled" WMS layer, which requests a single
+            image for the entire map view.
+        </p>
+    <div id="map" class="smallmap"></div>
+        <div id="docs">
+            An untiled layer will only request a single image at a time.
+            This is equivalent to using the deprecated
+            OpenLayers.Layer.WMS.Untiled class, which will be removed at 3.0.
+        </div>
+  </body>
+</html>
+
+

Added: sandbox/bartvde/openls/openlayers/lib/OpenLayers/Format/XLS.js
===================================================================
--- sandbox/bartvde/openls/openlayers/lib/OpenLayers/Format/XLS.js	                        (rev 0)
+++ sandbox/bartvde/openls/openlayers/lib/OpenLayers/Format/XLS.js	2010-11-23 14:19:09 UTC (rev 10912)
@@ -0,0 +1,118 @@
+/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for 
+ * full list of contributors). Published under the Clear BSD license.  
+ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
+ * full text of the license. */
+
+/**
+ * @requires OpenLayers/Format/XML.js
+ */
+
+/**
+ * Class: OpenLayers.Format.XLS
+ * Read/Wite XLS (OpenLS). Create a new instance with the <OpenLayers.Format.XLS>
+ *     constructor. Currently only implemented for Location Utility Services, more
+ *     specifically only for Geocoding. No support for Reverse Geocoding as yet.
+ * 
+ * Inherits from:
+ *  - <OpenLayers.Format.XML>
+ */
+OpenLayers.Format.XLS = OpenLayers.Class(OpenLayers.Format.XML, {
+    
+    /**
+     * APIProperty: defaultVersion
+     * {String} Version number to assume if none found.  Default is "1.1.0".
+     */
+    defaultVersion: "1.1.0",
+    
+    /**
+     * APIProperty: version
+     * {String} Specify a version string if one is known.
+     */
+    version: null,
+    
+    /**
+     * Property: parser
+     * {Object} Instance of the versioned parser.  Cached for multiple read and
+     *     write calls of the same version.
+     */
+    parser: null,
+
+    /**
+     * Constructor: OpenLayers.Format.XLS
+     * Create a new parser for XLS.
+     *
+     * Parameters:
+     * options - {Object} An optional object whose properties will be set on
+     *     this instance.
+     */
+    initialize: function(options) {
+        OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
+    },
+
+    /**
+     * APIMethod: write
+     * Write out an XLS request.
+     *
+     * Parameters:
+     * request - {Object} An object representing the LUS request.
+     * options - {Object} Optional configuration object.
+     *
+     * Returns:
+     * {String} An XLS document string.
+     */
+    write: function(request, options) {
+        var version = (options && options.version) ||
+                      this.version || this.defaultVersion;
+        if(!this.parser || this.parser.VERSION != version) {
+            var format = OpenLayers.Format.XLS[
+                "v" + version.replace(/\./g, "_")
+            ];
+            if(!format) {
+                throw "Can't find an XLS parser for version " +
+                      version;
+            }
+            this.parser = new format(this.options);
+        }
+        var root = this.parser.write(request);
+        return OpenLayers.Format.XML.prototype.write.apply(this, [root]);
+    },
+    
+    /**
+     * APIMethod: read
+     * Read an XLS doc and return an object representing the result.
+     *
+     * Parameters:
+     * data - {String | DOMElement} Data to read.
+     * options - {Object} Options for the reader.
+     *
+     * Returns:
+     * {Object} An object representing the GeocodeResponse.
+     */
+    read: function(data, options) {
+        if(typeof data == "string") {
+            data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
+        }
+        var root = data.documentElement;
+        var version = this.version;
+        if(!version) {
+            version = root.getAttribute("version");
+            if(!version) {
+                version = this.defaultVersion;
+            }
+        }
+        if(!this.parser || this.parser.VERSION != version) {
+            var format = OpenLayers.Format.XLS[
+                "v" + version.replace(/\./g, "_")
+            ];
+            if(!format) {
+                throw "Can't find an XLS parser for version " +
+                      version;
+            }
+            this.parser = new format(this.options);
+        }
+        var xls = this.parser.read(data, options);
+        return xls;
+    },
+
+    CLASS_NAME: "OpenLayers.Format.XLS" 
+});

Modified: sandbox/bartvde/openls/openlayers/lib/OpenLayers.js
===================================================================
--- sandbox/bartvde/openls/openlayers/lib/OpenLayers.js	2010-11-23 10:15:59 UTC (rev 10911)
+++ sandbox/bartvde/openls/openlayers/lib/OpenLayers.js	2010-11-23 14:19:09 UTC (rev 10912)
@@ -293,6 +293,9 @@
             "OpenLayers/Format/OWSContext/v0_3_1.js",
             "OpenLayers/Format/WMTSCapabilities.js",
             "OpenLayers/Format/WMTSCapabilities/v1_0_0.js",
+            "OpenLayers/Format/XLS.js",
+            "OpenLayers/Format/XLS/v1.js",
+            "OpenLayers/Format/XLS/v1_1_0.js",
             "OpenLayers/Layer/WFS.js",
             "OpenLayers/Control/GetFeature.js",
             "OpenLayers/Control/MouseToolbar.js",



More information about the Commits mailing list