[OpenLayers-Commits] r11941 - in sandbox/tschaub/editing: examples lib/OpenLayers/Geometry lib/OpenLayers/Layer

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Mon May 2 19:49:48 EDT 2011


Author: tschaub
Date: 2011-05-02 16:49:47 -0700 (Mon, 02 May 2011)
New Revision: 11941

Modified:
   sandbox/tschaub/editing/examples/point-grid.html
   sandbox/tschaub/editing/examples/snap-grid.html
   sandbox/tschaub/editing/lib/OpenLayers/Geometry/Polygon.js
   sandbox/tschaub/editing/lib/OpenLayers/Layer/PointGrid.js
Log:
Docs for point grid.

Modified: sandbox/tschaub/editing/examples/point-grid.html
===================================================================
--- sandbox/tschaub/editing/examples/point-grid.html	2011-05-02 23:12:17 UTC (rev 11940)
+++ sandbox/tschaub/editing/examples/point-grid.html	2011-05-02 23:49:47 UTC (rev 11941)
@@ -53,6 +53,15 @@
         <option value="350">350</option>
     </select>
 
+    <div class="docs">
+        <p>
+            This example demonstrates a <code>OpenLayers.Layer.PointGrid</code>
+            layer to render a regularly spaced grid of point features.
+        </p><p>
+            See the <a href="point-grid.js" target="_blank">
+            point-grid.js source</a> to see how this is done.
+        </p>
+    </div>
     <script src="../lib/OpenLayers.js"></script>
     <script src="point-grid.js"></script>
   </body>

Modified: sandbox/tschaub/editing/examples/snap-grid.html
===================================================================
--- sandbox/tschaub/editing/examples/snap-grid.html	2011-05-02 23:12:17 UTC (rev 11940)
+++ sandbox/tschaub/editing/examples/snap-grid.html	2011-05-02 23:49:47 UTC (rev 11941)
@@ -59,6 +59,17 @@
         <option value="350">350</option>
     </select>
 
+    <div class="docs">
+        <p>
+            This example demonstrates feature editing with snapping to a regular
+            grid.  The map is configured with a <code>OpenLayers.Layer.PointGrid</code>
+            layer and a <code>OpenLayers.Control.Snapping</code> agent.
+        </p><p>
+            See the <a href="snap-grid.js" target="_blank">
+            snap-grid.js source</a> to see how this is done.
+        </p>
+    </div>
+
     <script src="../lib/OpenLayers.js"></script>
     <script src="snap-grid.js"></script>
   </body>

Modified: sandbox/tschaub/editing/lib/OpenLayers/Geometry/Polygon.js
===================================================================
--- sandbox/tschaub/editing/lib/OpenLayers/Geometry/Polygon.js	2011-05-02 23:12:17 UTC (rev 11940)
+++ sandbox/tschaub/editing/lib/OpenLayers/Geometry/Polygon.js	2011-05-02 23:49:47 UTC (rev 11941)
@@ -258,6 +258,16 @@
     return new OpenLayers.Geometry.Polygon([ring]);
 };
 
+/**
+ * APIMethod: fromBounds
+ * Generate a polygon for the given bounds.
+ *
+ * Parameters:
+ * bounds - {<OpenLayers.Bounds>} A bounds object.
+ *
+ * Returns:
+ * {<OpenLayers.Geometry.Polygon>} A polygon representing the given bounds.
+ */
 OpenLayers.Geometry.Polygon.fromBounds = function(bounds) {
     var Point = OpenLayers.Geometry.Point;
     return new OpenLayers.Geometry.Polygon([

Modified: sandbox/tschaub/editing/lib/OpenLayers/Layer/PointGrid.js
===================================================================
--- sandbox/tschaub/editing/lib/OpenLayers/Layer/PointGrid.js	2011-05-02 23:12:17 UTC (rev 11940)
+++ sandbox/tschaub/editing/lib/OpenLayers/Layer/PointGrid.js	2011-05-02 23:49:47 UTC (rev 11941)
@@ -17,19 +17,70 @@
 OpenLayers.Layer.PointGrid = OpenLayers.Class(OpenLayers.Layer.Vector, {
 
     /**
-     * Property: gridBounds
+     * APIProperty: dx
+     * {Number} Point grid spacing in the x-axis direction.  Read-only.  Use the
+     * <setSpacing> method to modify this value.
      */
-    gridBounds: null,
+    dx: null,
 
-    dx: null,
+    /**
+     * APIProperty: dy
+     * {Number} Point grid spacing in the y-axis direction.  Read-only.  Use the
+     * <setSpacing> method to modify this value.
+     */
     dy: null,
+
+    /**
+     * APIProperty: ratio
+     * {Number} Ratio of the desired grid size to the map viewport size.  
+     * Default is 1.5.  Larger ratios mean the grid is recalculated less often 
+     * while panning.  The <maxFeatures> setting has precedence when determining
+     * grid size.  Read-only.  Use the <setRatio> method to modify this value.
+     */
     ratio: 1.5,
+
+    /**
+     * APIProperty: maxFeatures
+     * {Number} The maximum number of points to generate in the grid.  Default
+     * is 250.  Read-only.  Use the <maxFeatures> method to modify this value.
+     */
     maxFeatures: 250,
+
+    /**
+     * APIProperty: rotation
+     * {Number} Grid rotation (in degrees clockwise from the positive x-axis).
+     * Default is 0.  Read-only.  Use the <setRotation> method to modify this
+     * value.
+     */
     rotation: 0,
 
-    initialize: function(options) {
-        options = options || {};
-        OpenLayers.Layer.Vector.prototype.initialize.apply(this, [options.name, options]);
+    /**
+     * APIProperty: origin
+     * {OpenLayers.LonLat} Grid origin.  If not set at construction, the center
+     * of the map's maximum extent is used.  Read-only.  Use the <setOrigin> 
+     * method to modify this value.
+     */
+    origin: 0,
+
+    /**
+     * Property: gridBounds
+     * {<OpenLayers.Bounds>}  Internally cached grid bounds (with optional 
+     * rotation applied).
+     */
+    gridBounds: null,
+
+    /**
+     * Constructor: OpenLayers.Layer.PointGrid
+     * Creates a new point grid layer.
+     *
+     * Parameters:
+     * config - {Object} An object containing all configuration properties for
+     *     the layer.  The <dx> and <dy> properties are required to be set at 
+     *     construction.  Any other layer properties may be set in this object.
+     */
+    initialize: function(config) {
+        config = config || {};
+        OpenLayers.Layer.Vector.prototype.initialize.apply(this, [config.name, config]);
     },
     
     /** 
@@ -56,27 +107,64 @@
         OpenLayers.Layer.Vector.prototype.removeMap.apply(this, arguments);
     },
     
+    /**
+     * APIMethod: setRatio
+     * Set the grid <ratio> property and update the grid.
+     *
+     * Parameters:
+     * ratio - {Number}
+     */
     setRatio: function(ratio) {
         this.ratio = ratio;
         this.updateGrid(true);
     },
     
+    /**
+     * APIMethod: setMaxFeatures
+     * Set the grid <maxFeatures> property and update the grid.
+     *
+     * Parameters:
+     * maxFeatures - {Number}
+     */
     setMaxFeatures: function(maxFeatures) {
         this.maxFeatures = maxFeatures;
         this.updateGrid(true);
     },
 
+    /**
+     * APIMethod: setSpacing
+     * Set the grid <dx> and <dy> properties and update the grid.  If only one
+     *     argument is provided, it will be set as <dx> and <dy>.
+     *
+     * Parameters:
+     * dx - {Number}
+     * dy - {Number}
+     */
     setSpacing: function(dx, dy) {
         this.dx = dx;
         this.dy = dy || dx;
         this.updateGrid(true);
     },
     
+    /**
+     * APIMethod: setOrigin
+     * Set the grid <origin> property and update the grid.
+     *
+     * Parameters:
+     * origin - {<OpenLayers.LonLat>}
+     */
     setOrigin: function(origin) {
         this.origin = origin;
         this.updateGrid(true);
     },
     
+    /**
+     * APIMethod: getOrigin
+     * Get the grid <origin> property.
+     *
+     * Returns:
+     * {<OpenLayers.LonLat>} The grid origin.
+     */
     getOrigin: function() {
         if (!this.origin) {
             this.origin = this.map.getExtent().getCenterLonLat();
@@ -84,15 +172,33 @@
         return this.origin;
     },
     
+    /**
+     * APIMethod: setRotation
+     * Set the grid <rotation> property and update the grid.
+     *
+     * Parameters:
+     * rotation - {Number} Degrees clockwise from the positive x-axis.
+     */
     setRotation: function(rotation) {
         this.rotation = rotation;
         this.updateGrid(true);
     },
     
+    /**
+     * Method: onMoveEnd
+     * Listener for map "moveend" events.
+     */
     onMoveEnd: function() {
         this.updateGrid();
     },
     
+    /**
+     * Method: getViewBounds
+     * Gets the (potentially rotated) view bounds for grid calculations.
+     *
+     * Returns:
+     * {<OpenLayers.Bounds>}
+     */
     getViewBounds: function() {
         var bounds = this.map.getExtent();
         if (this.rotation) {
@@ -105,6 +211,10 @@
         return bounds;
     },
     
+    /**
+     * Method: updateGrid
+     * Update the grid.
+     */
     updateGrid: function(force) {
         if (force || this.invalidBounds()) {
             var viewBounds = this.getViewBounds();



More information about the Commits mailing list