[OpenLayers-Commits] r7323 - in sandbox/tschaub/olon: examples lib lib/OpenLayers lib/OpenLayers/BaseTypes lib/OpenLayers/Feature lib/OpenLayers/Format lib/OpenLayers/Geometry lib/OpenLayers/Layer

commits at openlayers.org commits at openlayers.org
Fri Jun 6 12:37:34 EDT 2008


Author: tschaub
Date: 2008-06-06 12:37:34 -0400 (Fri, 06 Jun 2008)
New Revision: 7323

Added:
   sandbox/tschaub/olon/examples/olon.html
   sandbox/tschaub/olon/lib/OpenLayers/Format/OLON.js
Modified:
   sandbox/tschaub/olon/lib/OpenLayers.js
   sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/Bounds.js
   sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/Class.js
   sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/LonLat.js
   sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/Size.js
   sandbox/tschaub/olon/lib/OpenLayers/Feature/Vector.js
   sandbox/tschaub/olon/lib/OpenLayers/Geometry.js
   sandbox/tschaub/olon/lib/OpenLayers/Geometry/Collection.js
   sandbox/tschaub/olon/lib/OpenLayers/Geometry/Point.js
   sandbox/tschaub/olon/lib/OpenLayers/Layer.js
   sandbox/tschaub/olon/lib/OpenLayers/Layer/Google.js
   sandbox/tschaub/olon/lib/OpenLayers/Layer/Grid.js
   sandbox/tschaub/olon/lib/OpenLayers/Layer/HTTPRequest.js
   sandbox/tschaub/olon/lib/OpenLayers/Layer/Image.js
   sandbox/tschaub/olon/lib/OpenLayers/Layer/Vector.js
   sandbox/tschaub/olon/lib/OpenLayers/Layer/WFS.js
   sandbox/tschaub/olon/lib/OpenLayers/Map.js
Log:
initial support for reading/writing olon

Added: sandbox/tschaub/olon/examples/olon.html
===================================================================
--- sandbox/tschaub/olon/examples/olon.html	                        (rev 0)
+++ sandbox/tschaub/olon/examples/olon.html	2008-06-06 16:37:34 UTC (rev 7323)
@@ -0,0 +1,189 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <style type="text/css">
+        #map {
+            width: 400px;
+            height: 400px;
+            border: 1px solid gray;
+        }
+        #col {
+            position: absolute;
+            top: 1.75em;
+            left: 425px;
+        }
+        #output {
+            width: 400px;
+            height: 350px;
+        }
+        p {
+            margin: 1em 0;
+            width: 800px;
+        }
+    </style>
+    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAeDjUod8ItM9dBg5_lz0esxTk5UTxNMOJaMwpeYJby65YwI0-cxSmHf2_ZfIP7bDb_moMph5qZy25YA" type="text/javascript"></script>
+    <!--
+    <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
+    -->
+    <script src="../lib/OpenLayers.js"></script>
+    <script type="text/javascript">
+        var lon = 5;
+        var lat = 40;
+        var zoom = 5;
+        var map, controls, panel, switcher;
+
+        function init(){
+            var options = {
+                projection: "EPSG:900913",
+                units: "m",
+                maxResolution: 156543.0339,
+                maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
+                                                 20037508, 20037508.34)
+            };
+            map = new OpenLayers.Map('map', options);
+
+            if(!restoreState()) {
+    
+                // create Google Mercator layers
+                var gmap = new OpenLayers.Layer.Google(
+                    "Google Streets",
+                    {'sphericalMercator': true}
+                );
+    
+                // create WMS layer
+                var wms = new OpenLayers.Layer.WMS(
+                    "World Map",
+                    "http://world.freemap.in/tiles/",
+                    {'layers': 'factbook-overlay', 'format':'png'},
+                    {
+                        'reproject': false, 'opacity': 0.4,
+                        'isBaseLayer': false,'wrapDateLine': true
+                    }
+                );
+    
+                // create a vector layer for drawing
+                var vector = new OpenLayers.Layer.Vector("Editable Vectors");
+                
+                map.addLayers([gmap, wms, vector]);
+                panel = new OpenLayers.Control.EditingToolbar(vector);
+                map.addControl(panel);
+                switcher = new OpenLayers.Control.LayerSwitcher();
+                map.addControl(switcher);
+                map.zoomToMaxExtent();
+            }
+
+        }
+        
+        var olon = new OpenLayers.Format.OLON();
+        
+        function saveState() {
+            var str = olon.write(map);
+            if(str.length < 3950) {
+                createCookie("olmap", str, 10);
+                document.getElementById('output').value = "saved:\n\n" + str;
+            } else {
+                document.getElementById('output').value = "too long:\n\n" + str;
+            }
+        }
+        function restoreState() {
+            var restored = false;
+            var str = readCookie("olmap");
+            if(str) {
+                deserializeMap(str);
+                restored = true;
+                document.getElementById('output').value = "restored:\n\n" + str;
+            } else {
+                document.getElementById('output').value = 'no state saved';
+            }
+            return restored;
+        }
+
+        function createCookie(name, value, days) {
+            var expires = "";
+            if(days) {
+                var date = new Date();
+                date.setTime(date.getTime()+(days*24*60*60*1000));
+                expires = "; expires="+date.toGMTString();
+            }
+            document.cookie = name + "=" + value + expires + "; path=/";
+        }
+        function readCookie(name) {
+            var value = null;
+            var nameEQ = name + "=";
+            var ca = document.cookie.split(';');
+            for(var i=0; i<ca.length; i++) {
+                var c = ca[i].replace(/^s+/, '');
+                if(c.indexOf(nameEQ) == 0) {
+                    value = c.substring(nameEQ.length, c.length);
+                    break;
+                }
+            }
+            return value;
+        }
+        function eraseCookie(name) {
+            createCookie(name,"",-1);
+        }
+
+        function serializeMap() {
+            var str = olon.write(map, true);
+            document.getElementById('output').value = str;
+        }
+
+        function clearMap() {
+            // simpler destroy anyone?
+            try {
+                panel.deactivate();
+                map.removeControl(panel);
+                panel.destroy();
+            } catch(e) {
+                // destroy should work better
+            }
+            for(var i=map.layers.length-1; i>=0; --i) {
+                map.layers[i].destroy();
+            }
+        }
+        function deserializeMap(str) {
+            clearMap();
+            var obj = olon.read(str);
+            map.addLayers(obj.layers);
+            var zoom = map.getZoomForResolution(obj.resolution, true);
+            map.setCenter(obj.center, zoom, false, true);
+
+            // hack to reset the editing toolbar
+            var vector = map.layers[2];
+            panel = new OpenLayers.Control.EditingToolbar(vector);
+            map.addControl(panel);
+
+            if(!switcher) {
+                switcher = new OpenLayers.Control.LayerSwitcher();
+                map.addControl(switcher);
+            }
+        }
+        function clearSaved() {
+            eraseCookie("olmap");
+            document.getElementById('output').value = "cookie erased";
+        }
+        function clearFeatures() {
+            var vector = map.layers[2];
+            vector.removeFeatures(vector.features);
+        }
+    </script>
+  </head>
+  <body onload="init()">
+    <h3>OpenLayers Object Notation</h3>
+    <div id="map"></div>
+    <div id="col">
+        <a href="javascript: void saveState();">save state</a> |
+        <a href="javascript: void restoreState();">restore state</a> |
+        <a href="javascript: void clearSaved();">clear saved state</a><br />
+        <textarea id="output"></textarea><br />
+        <a href="javascript: void serializeMap();">serialize map</a> |
+        <a href="javascript: void clearFeatures();">clear features</a><br />
+    </div>
+    <p>This example show how a map can be serialized using OpenLayers Object Notation.
+    The serialized map can be saved somewhere (like a cookie if it's under 4KB), and
+    deserialized to restore the state of a map.  Serializing features on a vector layer
+    is possible, but creates a string that is typically too large for cookie storage</p>
+    <p>Navigate to some location, turn layers on/off, click save state.  Close this page
+    and reopen it (or just refresh) to see the state restored.</p>
+  </body>
+</html>

Modified: sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/Bounds.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/Bounds.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/Bounds.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -41,6 +41,14 @@
     top: null,    
 
     /**
+     * Property: serializable
+     * {Object}
+     */
+    serializable: {
+        "args": ["left", "bottom", "right", "top"]
+    },
+
+    /**
      * Constructor: OpenLayers.Bounds
      * Construct a new bounds object.
      *

Modified: sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/Class.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/Class.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/Class.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -31,24 +31,270 @@
         if (arguments && arguments[0] != OpenLayers.Class.isPrototype) {
             this.initialize.apply(this, arguments);
         }
+        return this;
     };
-    var extended = {};
-    var parent;
+    
+    // All instances of OpenLayers classes inherit from the extended prototype.    
+    var extended = {
+        /**
+         * APIMethod: Class.prototype.serialize
+         * This is an instance method that returns a data structure representing
+         *     the instance.  This data structure can be passed to the
+         *     appropriate deserialize class method to return a new instance
+         *     which is the equivalent of a clone of this instance.
+         *
+         * Returns:
+         * {Object} A data structure representing the instance.
+         */
+        serialize: function() {
+            var data = {};
+            var olClass = eval(this.CLASS_NAME);
+            var obj = olClass.prototype.serializable;
+            // serialize the args and props
+            var index;
+            var args = obj.args;
+            if(args) {
+                for(index=0; index<args.length; ++index) {
+                    data[args[index]] = OpenLayers.Class.serialize(
+                        this[args[index]]
+                    );
+                }
+            }
+            var props = obj.props;
+            for(index=0; index<props.length; ++index) {
+                data[props[index]] = OpenLayers.Class.serialize(
+                    this[props[index]]
+                );
+            }
+            // add in the class name
+            data.CLASS_NAME = this.CLASS_NAME;
+            return data;
+        }
+    };
+    
+    // get the serializable object on the prototype
+    var proto = arguments[arguments.length - 1];
+    var serializable;
+    if(proto.serializable) {
+        /**
+         * Property: Class.prototype.serializable
+         * {Object} Object that maps serializalble properties of an instance
+         *     of this class.  By default, instances will not be serialized.
+         *     To allow an instance to be serialized, add a serializable
+         *     property to the prototype.  Subclasses will inherit this
+         *     property in the manor described below.  The simplest way to make
+         *     an instance serializable is to set the serializable property
+         *     to an empty object ({}).
+         *
+         * The serializable object has three properties:
+         * args - {Array} Property names to be applied to the constructor.
+         *     All required argument names must be supplied here.  If args
+         *     is undefined, args will be inherited from the parent.
+         * props - {Array} All additional properties to set on the new
+         *     instance.  These will be set by direct assignment.  The props
+         *     array inherits from its parent by merging arrays.  Any new
+         *     properties specified in a child props array will be added
+         *     to the properties inherited from a parent class.
+         * except - {Array}  List of properties from a parent class' props
+         *     array that will not be merged with the props array of a child
+         *     class.  There is no inheritance of the except array.
+         */
+        serializable = {
+            "args": (proto.serializable.args) ?
+                proto.serializable.args : undefined,
+            "props": (proto.serializable.props) ?
+                proto.serializable.props : [],
+            "except": (proto.serializable.except) ?
+                proto.serializable.except : []
+        };
+    };
+
+    // inherit from all arguments
+    var parent = {};
     for(var i=0; i<arguments.length; ++i) {
         if(typeof arguments[i] == "function") {
             // get the prototype of the superclass
             parent = arguments[i].prototype;
+            // All OpenLayers classes are serializable.
+            // Inheriting from others still works.
+            if(parent.serializable) {
+                // prototype may not have serializable property
+                serializable = (serializable) ?
+                    serializable : {"props": [], "except": []};
+                // props are merged with the parent
+                var prop;
+                var indexOf = OpenLayers.Util.indexOf;
+                for(var j=0; j<parent.serializable.props.length; ++j) {
+                    prop = parent.serializable.props[j];
+                    if(indexOf(serializable.except, prop) == -1) {
+                        if(indexOf(serializable.props, prop) == -1) {
+                            serializable.props.push(prop);
+                        }
+                    }
+                }
+                // args are inherited only if not specified in the prototype
+                if(!serializable.args) {
+                    serializable.args = parent.serializable.args;
+                }
+            }
         } else {
             // in this case we're extending with the prototype
             parent = arguments[i];
         }
         OpenLayers.Util.extend(extended, parent);
     }
-    Class.prototype = extended;
+    extended.serializable = serializable;
+
+    Class.prototype = extended;    
     return Class;
 };
 
+/*
+ * APIProperty: OpenLayers.Class.recursionDepth
+ * Class property that limits the recursion depth for serializing instances
+ *     of OpenLayers classes.  Defaults to 20.
+ */
+OpenLayers.Class.recursionDepth = 20;
+
 /**
+ * APIFunction: OpenLayers.Class.serialize
+ * Recursively serialize an object.  Stops recursion at a depth of
+ *     <OpenLayers.Class.recursionDepth>.
+ *
+ * Parameters:
+ * obj - {Object} An object to be serialized.
+ *
+ * Returns:
+ * {Object} An object without circular references or methods.
+ */
+OpenLayers.Class.serialize = function(obj, depth) {
+    var data;
+    depth = (depth != undefined) ? depth + 1 : 0;
+    if(!(obj instanceof Function)) {
+        if(depth <= OpenLayers.Class.recursionDepth) { 
+            if(obj && obj.serialize instanceof Function) {
+                data = obj.serialize();
+            } else {
+                if(obj instanceof Array) {
+                    data = new Array(obj.length);
+                    for(var i=0; i<obj.length; ++i) {
+                        data[i] = OpenLayers.Class.serialize(obj[i], depth);
+                    }
+                } else if(obj instanceof Object) {
+                    data = {};
+                    var value;
+                    for(var key in obj) {
+                        value = OpenLayers.Class.serialize(obj[key], depth);
+                        if(value !== undefined) {
+                            data[key] = OpenLayers.Class.serialize(
+                                obj[key], depth
+                            );
+                        }
+                    }
+                } else {
+                    data = obj;
+                }
+            }
+        }
+    }
+    return data;
+};
+
+/**
+ * APIFunction: OpenLayers.Class.deserialize
+ * Class method that deserializes any data structure into an instance of
+ *     an OpenLayers class.  In the case of arrays and objects, an object
+ *     with the same data structure is returned, with each item or proerty
+ *     value deserialized.
+ *
+ * Parameters:
+ * struct - {Object} Data structure representing an object.
+ * 
+ * Returns:
+ * {Object} An instance of an OpenLayers class based on the data structure.
+ */
+OpenLayers.Class.deserialize = function(struct, depth) {
+    var instance, index, key;
+    depth = (depth != undefined) ? depth + 1 : 1;
+    if(struct instanceof Function) {
+        var msg = "Cannot serialize functions";
+        OpenLayers.Console.error(msg);
+    } else if(depth <= OpenLayers.Class.recursionDepth) {
+        if(!struct) {
+            // deal with null and all else that evaluates to false
+            instance = struct;
+        } else if(!struct.CLASS_NAME ||
+                  struct.CLASS_NAME.indexOf("OpenLayers") != 0) {
+            if(struct instanceof Array) {
+                // deserialize items in an array
+                instance = new Array(struct.length);
+                for(index=0; index<struct.length; ++index) {
+                    instance[index] = OpenLayers.Class.deserialize(
+                        struct[index], depth
+                    );
+                }
+            } else if(struct instanceof Object) {
+                // deserialize properties of an object
+                instance = {};
+                for(key in struct) {
+                    instance[key] = OpenLayers.Class.deserialize(
+                        struct[key], depth
+                    );
+                }
+            } else {
+                // all other literals
+                instance = struct;
+            }
+        } else {
+            // deal with instances of OpenLayers classes
+            var olClass = eval(struct.CLASS_NAME);
+            if(!olClass.prototype.serializable) {
+                var msg = "Unable to deserialize.  CLASS_NAME: " +
+                    struct.CLASS_NAME;
+                throw Error(msg);
+            }
+            // deserialize the args
+            var argArray = olClass.prototype.serializable.args;
+            var args = [];
+            if(argArray) {
+                for(index=0; index<argArray.length; ++index) {
+                    key = argArray[index];
+                    if(struct[key] === undefined) {
+                        var msg = "Deserializing failed.  " +
+                            struct.CLASS_NAME + " requires argument: " + key;
+                        throw Error(msg);
+                    }
+                    args.push(OpenLayers.Class.deserialize(struct[key], depth));
+                }
+            }
+            // create prototype with properties deserialized from the structure
+            var proto = {};
+            var propArray = olClass.prototype.serializable.props;
+            if(propArray) {
+                for(index=0; index<propArray.length; ++index) {
+                    key = propArray[index];
+                    proto[key] = OpenLayers.Class.deserialize(
+                        struct[key], depth
+                    );
+                }
+            }
+            // construct our instance (except for maps at this point)
+            if(struct.CLASS_NAME == "OpenLayers.Map") {
+                instance = proto;
+            } else {
+                OpenLayers.Util.applyDefaults(proto, olClass.prototype);
+                instance = olClass.apply(proto, args);
+            }
+        }
+    }
+    return instance;
+};
+
+/////////////////////////////////////////////////////////////////////
+// Deprecated methods below.  Remove everything below here in 3.0. //
+/////////////////////////////////////////////////////////////////////
+
+/**
  * Property: isPrototype
  * *Deprecated*.  This is no longer needed and will be removed at 3.0.
  */

Modified: sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/LonLat.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/LonLat.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/LonLat.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -21,6 +21,14 @@
     lat: 0.0,
 
     /**
+     * Property: serializable
+     * {Object}
+     */
+    serializable: {
+        "args": ["lon", "lat"]
+    },
+
+    /**
      * Constructor: OpenLayers.LonLat
      * Create a new map location.
      *

Modified: sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/Size.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/Size.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/BaseTypes/Size.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -20,6 +20,13 @@
      */
     h: 0.0,
 
+    /**
+     * Property: serializable
+     * {Object}
+     */
+    serializable: {
+        "args": ["w", "h"]
+    },
 
     /**
      * Constructor: OpenLayers.Size

Modified: sandbox/tschaub/olon/lib/OpenLayers/Feature/Vector.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/Feature/Vector.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/Feature/Vector.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -60,6 +60,13 @@
     style: null,
     
     /**
+     * Property: serializable
+     */
+    serializable: {
+        "args": ["geometry", "attributes", "style"]
+    },
+
+    /**
      * Property: renderIntent
      * {String} rendering intent currently being used
      */

Added: sandbox/tschaub/olon/lib/OpenLayers/Format/OLON.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/Format/OLON.js	                        (rev 0)
+++ sandbox/tschaub/olon/lib/OpenLayers/Format/OLON.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -0,0 +1,78 @@
+/* Copyright (c) 2006-2007 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * Note:
+ * This work draws heavily from the public domain JSON serializer/deserializer
+ *     at http://www.json.org/json.js. Rewritten so that it doesn't modify
+ *     basic data prototypes.
+ */
+
+/**
+ * @requires OpenLayers/Format/JSON.js
+ *
+ * Class: OpenLayers.Format.OLON
+ * A parser to read/write OLON safely.  Create a new instance with the
+ *     <OpenLayers.Format.OLON> constructor.
+ *
+ * Inherits from:
+ *  - <OpenLayers.Format.JSON>
+ */
+OpenLayers.Format.OLON = OpenLayers.Class(OpenLayers.Format.JSON, {
+    
+    /**
+     * Constructor: OpenLayers.Format.OLON
+     * Create a new parser for OLON.
+     *
+     * Parameters:
+     * options - {Object} An optional object whose properties will be set on
+     *     this instance.
+     */
+    initialize: function(options) {
+        OpenLayers.Format.JSON.prototype.initialize.apply(this, [options]);
+    },
+
+    /**
+     * APIMethod: read
+     * Deserialize an OpenLayers JSON string.
+     *
+     * Parameters:
+     * str - {String} An OLON string
+     * filter - {Function} A function which will be called for every key and
+     *     value at every level of the final result. Each value will be
+     *     replaced by the result of the filter function. This can be used to
+     *     reform generic objects into instances of classes, or to transform
+     *     date strings into Date objects.
+     *     
+     * Returns:
+     * {Object} An object, array, string, or number.
+     */
+    read: function(str, filter) {
+        var data = OpenLayers.Format.JSON.prototype.read(str, filter);
+        var instance = OpenLayers.Class.deserialize(data);
+        return instance;
+    },
+
+    /**
+     * APIMethod: write
+     * Serialize an object into an OLON string.
+     *
+     * Parameters:
+     * value - {String} The object, array, string, number, boolean or date
+     *     to be serialized.
+     * pretty - {Boolean} Structure the output with newlines and indentation.
+     *     Default is false.
+     *
+     * Returns:
+     * {String} The OpenLayers JSON string representation of the input value.
+     */
+    write: function(value, pretty) {
+        var data = OpenLayers.Class.serialize(value);
+        var str = OpenLayers.Format.JSON.prototype.write(data, pretty);
+        return str;
+    },
+    
+    CLASS_NAME: "OpenLayers.Format.OLON" 
+
+});     

Modified: sandbox/tschaub/olon/lib/OpenLayers/Geometry/Collection.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/Geometry/Collection.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/Geometry/Collection.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -41,6 +41,14 @@
     componentTypes: null,
 
     /**
+     * Property: serializable
+     */
+    serializable: {
+        "args": ["components"],
+        "props": ["componentTypes"]
+    },
+
+    /**
      * Constructor: OpenLayers.Geometry.Collection
      * Creates a Geometry Collection -- a list of geoms.
      *

Modified: sandbox/tschaub/olon/lib/OpenLayers/Geometry/Point.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/Geometry/Point.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/Geometry/Point.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -28,6 +28,13 @@
     y: null,
 
     /**
+     * Property: serializable
+     */
+    serializable: {
+        "args": ["x", "y"]
+    },
+
+    /**
      * Constructor: OpenLayers.Geometry.Point
      * Construct a point geometry.
      *

Modified: sandbox/tschaub/olon/lib/OpenLayers/Geometry.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/Geometry.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/Geometry.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -34,7 +34,15 @@
      */
     bounds: null,
 
+
     /**
+     * Property: serializable
+     */
+    serializable: {
+        "args": []
+    },
+
+    /**
      * Constructor: OpenLayers.Geometry
      * Creates a geometry object.  
      */

Modified: sandbox/tschaub/olon/lib/OpenLayers/Layer/Google.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/Layer/Google.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/Layer/Google.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -83,6 +83,13 @@
      */
     dragObject: null, 
 
+    /**
+     * Property: serializable
+     */
+    serializable: {
+        "props": ["sphericalMercator"]
+    },
+
     /** 
      * Constructor: OpenLayers.Layer.Google
      * 

Modified: sandbox/tschaub/olon/lib/OpenLayers/Layer/Grid.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/Layer/Grid.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/Layer/Grid.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -60,6 +60,14 @@
     numLoadingTiles: 0,
 
     /**
+     * Property: serializable
+     * {Object}
+     */
+    serializable: {
+        "props": ["singleTile", "tileSize", "buffer"]
+    },
+
+    /**
      * Constructor: OpenLayers.Layer.Grid
      * Create a new grid layer
      *

Modified: sandbox/tschaub/olon/lib/OpenLayers/Layer/HTTPRequest.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/Layer/HTTPRequest.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/Layer/HTTPRequest.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -48,6 +48,15 @@
     reproject: false,
 
     /**
+     * Property: serializable
+     * {Object}
+     */
+    serializable: {
+        "args": ["name", "url", "params"],
+        "props": ["reproject"]
+    },
+
+    /**
      * Constructor: OpenLayers.Layer.HTTPRequest
      * 
      * Parameters:

Modified: sandbox/tschaub/olon/lib/OpenLayers/Layer/Image.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/Layer/Image.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/Layer/Image.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -54,6 +54,14 @@
     aspectRatio: null,
 
     /**
+     * Property: serializable
+     * {Object}
+     */
+    serializable: {
+        "args": ["name", "url", "extent", "size"]
+    },
+
+    /**
      * Constructor: OpenLayers.Layer.Image
      * Create a new image layer
      *

Modified: sandbox/tschaub/olon/lib/OpenLayers/Layer/Vector.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/Layer/Vector.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/Layer/Vector.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -156,6 +156,14 @@
     drawn: false,
 
     /**
+     * Property: serializable
+     * {Object}
+     */
+    serializable: {
+        "args": ["name"]
+    },
+
+    /**
      * Constructor: OpenLayers.Layer.Vector
      * Create a new vector layer
      *

Modified: sandbox/tschaub/olon/lib/OpenLayers/Layer/WFS.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/Layer/WFS.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/Layer/WFS.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -98,6 +98,15 @@
     extractAttributes: false,
 
     /**
+     * Property: serializable
+     * {Object}
+     */
+    serializable: {
+        "args": ["name", "url", "params"],
+        "props": ["extractAttributes", "vectorMode"]
+    },
+
+    /**
      * Constructor: OpenLayers.Layer.WFS
      *
      * Parameters:

Modified: sandbox/tschaub/olon/lib/OpenLayers/Layer.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/Layer.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/Layer.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -258,6 +258,17 @@
     wrapDateLine: false,
     
     /**
+     * Property: serializable
+     */
+    serializable: {
+        "args": ["name"],
+        "props": ["numZoomLevels", "maxResolution", "minResolution",
+                  "maxExtent", "wrapDateLine", "displayOutsideMaxExtent",
+                  "isBaseLayer", "displayInLayerSwitcher", "visibility",
+                  "opacity"]
+    },
+
+    /**
      * APIProperty: transitionEffect
      * {String} The transition effect to use when the map is panned or
      *     zoomed.  
@@ -1084,3 +1095,4 @@
 
     CLASS_NAME: "OpenLayers.Layer"
 });
+

Modified: sandbox/tschaub/olon/lib/OpenLayers/Map.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers/Map.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers/Map.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -338,6 +338,15 @@
     panTween: null,
 
     /**
+     * Property: serializable
+     * {Object}
+     */
+    serializable: {
+        "props": ["layers", "center", "resolution", "bounds",
+                  "projection", "units", "maxResolution", "numZoomLevels"]
+    },
+    
+    /**
      * APIProperty: eventListeners
      * {Object} If set as an option at construction, the eventListeners
      *     object will be registered with <OpenLayers.Events.on>.  Object

Modified: sandbox/tschaub/olon/lib/OpenLayers.js
===================================================================
--- sandbox/tschaub/olon/lib/OpenLayers.js	2008-06-06 16:11:10 UTC (rev 7322)
+++ sandbox/tschaub/olon/lib/OpenLayers.js	2008-06-06 16:37:34 UTC (rev 7323)
@@ -201,6 +201,7 @@
             "OpenLayers/Format/Text.js",
             "OpenLayers/Format/JSON.js",
             "OpenLayers/Format/GeoJSON.js",
+            "OpenLayers/Format/OLON.js",
             "OpenLayers/Format/WMC.js",
             "OpenLayers/Format/WMC/v1.js",
             "OpenLayers/Format/WMC/v1_0_0.js",



More information about the Commits mailing list