[OpenLayers-Commits] r2312 - sandbox/vector-2.4/lib/OpenLayers
commits at openlayers.org
commits at openlayers.org
Mon Mar 5 11:46:59 EST 2007
Author: crschmidt
Date: 2007-03-05 11:46:58 -0500 (Mon, 05 Mar 2007)
New Revision: 2312
Added:
sandbox/vector-2.4/lib/OpenLayers/Geometry.js
sandbox/vector-2.4/lib/OpenLayers/Geometry/
sandbox/vector-2.4/lib/OpenLayers/Renderer.js
sandbox/vector-2.4/lib/OpenLayers/Renderer/
Log:
Add Renderer, Geometry classes for starting to get base Vector layer support
in.
Copied: sandbox/vector-2.4/lib/OpenLayers/Geometry (from rev 2311, sandbox/vector/lib/OpenLayers/Geometry)
Copied: sandbox/vector-2.4/lib/OpenLayers/Geometry.js (from rev 2311, sandbox/vector/lib/OpenLayers/Geometry.js)
===================================================================
--- sandbox/vector-2.4/lib/OpenLayers/Geometry.js (rev 0)
+++ sandbox/vector-2.4/lib/OpenLayers/Geometry.js 2007-03-05 16:46:58 UTC (rev 2312)
@@ -0,0 +1,131 @@
+/* Copyright (c) 2006 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. */
+
+/**
+ * @class
+ */
+OpenLayers.Geometry = OpenLayers.Class.create();
+OpenLayers.Geometry.prototype = {
+
+ /** @type String */
+ id: null,
+
+ /** @type OpenLayers.Style */
+ style: null,
+
+ /** @type OpenLayers.Bounds */
+ bounds: null,
+
+ /**
+ * Cross reference back to the feature that owns this geometry so
+ * that that the feature can be identified after the geometry has been
+ * selected by a mouse click.
+ * @type OpenLayers.Feature */
+ feature: null,
+
+ /** @type OpenLayers.Events */
+ events:null,
+
+ /**
+ * @constructor
+ *
+ * @param {array} linearRings
+ */
+ initialize: function() {
+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME+ "_");
+ },
+
+ /**
+ * Set the bounds for this Geometry.
+ * @param {OpenLayers.Bounds} bounds
+ */
+ setBounds: function(bounds){
+ this.bounds=bounds;
+ },
+
+ /**
+ * Extend the existing bounds to include the new bounds. If existing
+ * bounds=null, then set a new Bounds.
+ * @param {Object} bounds
+ */
+ extendBounds: function(bounds){
+ if(!this.bounds){
+ this.setBounds(bounds);
+ }else{
+ this.bounds.extendBounds(bounds.left, bounds.top, bounds.right, bounds.bottom);
+ }
+ },
+
+ /**
+ * Get the bounds for this Geometry. The bounds will be null if not it has
+ * not been set.
+ * Once the bounds is set, it is not calculated again, this makes queries
+ * faster.
+ * @return {OpenLayers.Bounds}
+ */
+ getBounds: function(){
+ return this.bounds;
+ },
+
+ /**
+ * Takes an lonLat point and returns true if the geometry is at this location.
+ * This is only an approximation based on the bounds of the geometry.
+ * @param {OpenLayers.LonLat} lonlat
+ * @param toleranceLon Optional tolerance in Geometric Coords
+ * @param toleranceLat Optional tolerance in Geographic Coords
+ * @return Boolean
+ */
+ atPoint: function(lonlat,toleranceLon,toleranceLat){
+ var atPoint=false;
+ toleranceLon=(toleranceLon)?toleranceLon:0;
+ toleranceLat=(toleranceLat)?toleranceLat:0;
+ if(this.bounds){
+ atPoint=((this.bounds.bottom-toleranceLat)<=lonlat.lat)
+ && (lonlat.lat<=(this.bounds.top+toleranceLat))
+ && ((this.bounds.left-toleranceLon)<=lonlat.lon)
+ && (lonlat.lon<=(this.bounds.right+toleranceLon));
+ }
+ return atPoint;
+ },
+
+ /**
+ * Returns the length of the geometry
+ */
+ getLength: function() {
+ return 0.0;
+ },
+
+ /**
+ * Returns the area of the geometry
+ */
+ getArea: function() {
+ return 0.0;
+ },
+
+ /**
+ * Set the "events" attribute.
+ */
+ setEvents: function() {
+ if (this.id == null)
+ return;
+
+ var domElement = $(this.id);
+
+ if (domElement == null)
+ return;
+
+ this.events = new OpenLayers.Events(this, domElement, null);
+ },
+
+ /**
+ * Register an event callback.
+ */
+ registerEventCallback: function(type, obj, callback) {
+ if (this.events != null) {
+ this.events.register(type, obj, callback);
+ }
+ },
+
+ CLASS_NAME: "OpenLayers.Geometry"
+};
Copied: sandbox/vector-2.4/lib/OpenLayers/Renderer (from rev 2311, sandbox/vector/lib/OpenLayers/Renderer)
Copied: sandbox/vector-2.4/lib/OpenLayers/Renderer.js (from rev 2311, sandbox/vector/lib/OpenLayers/Renderer.js)
===================================================================
--- sandbox/vector-2.4/lib/OpenLayers/Renderer.js (rev 0)
+++ sandbox/vector-2.4/lib/OpenLayers/Renderer.js 2007-03-05 16:46:58 UTC (rev 2312)
@@ -0,0 +1,201 @@
+/* Copyright (c) 2006 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. */
+
+/**
+ * @class Renderer is the base class for all renderers.
+ *
+ * This is based on a merger code written by Paul Spencer and Bertil Chapuis.
+ * It is largely composed of virtual functions that are to be implemented
+ * in technology-specific subclasses, but there is some generic code too.
+ *
+ */
+OpenLayers.Renderer = OpenLayers.Class.create();
+OpenLayers.Renderer.prototype =
+{
+ /**
+ * constructor. Sub-classes need to set up this.eventHandler (see above)
+ */
+ initialize: function() {},
+
+ /**
+ * virtual function
+ *
+ * Remove all the elements of the root
+ *
+ */
+ clearRoot: function() {},
+
+ /**
+ * virtual function
+ *
+ * Set the visible part of the layer.
+ *
+ * @param x {}
+ * @param y {}
+ * @param width {}
+ * @param height {}
+ */
+ setExtent: function(x, y, width, height) {},
+
+ /**
+ * virtual function
+ *
+ * sets the size of the drawing surface
+ *
+ * @param size {OpenLayers.Size} the size of the drawing surface
+ */
+ setSize: function(size) {},
+
+ /**
+ * virtual function
+ *
+ * returns a geometry from an event that happened on a layer. How this
+ * happens is specific to the renderer.
+ *
+ * @param evt {Object} an OpenLayers.Event object
+ *
+ * @return {Geometry} the geometry associated with the event, or null
+ */
+ getGeometryFromEvent: function(evt) {},
+
+ /**
+ * draw a geometry on the specified layer.
+ *
+ * @param layer {Object} the layer to draw on
+ * @param geometry {Geometry} a geometry to draw
+ */
+ drawGeometry: function(geometry, style) {
+ if (!style) {
+ return;
+ }
+
+ switch (geometry.CLASS_NAME) {
+ case "OpenLayers.Geometry.Point":
+ this.drawPoint(geometry, style);
+ break;
+ case "OpenLayers.Geometry.Curve":
+ this.drawCurve(geometry, style);
+ break;
+ case "OpenLayers.Geometry.LineSegment":
+ case "OpenLayers.Geometry.LineString":
+ this.drawLineString(geometry, style);
+ break;
+ case "OpenLayers.Geometry.LinearRing":
+ this.drawLinearRing(geometry, style);
+ break;
+ case "OpenLayers.Geometry.Polygon":
+ this.drawPolygon(geometry, style);
+ break;
+ case "OpenLayers.Geometry.Surface":
+ this.drawSurface(geometry, style);
+ break;
+ case "OpenLayers.Geometry.Rectangle":
+ this.drawRectangle(geometry, style);
+ break;
+ case "OpenLayers.Geometry.MultiPoint":
+ case "OpenLayers.Geometry.MultiLineString":
+ case "OpenLayers.Geometry.MultiPolygon":
+ // simply draws the components as primitive geometries
+ // may need a reference to the composite geometry
+ for (var i = 0; i < geometry.components.length; i++) {
+ this.drawGeometry(geometry.components[i], style);
+ }
+ break;
+ default:
+ break;
+ }
+ },
+
+ /**
+ * virtual function
+ *
+ * erases a geometry
+ * @param layer {Object} the layer to draw on
+ * @param geometry {Geometry} a geometry to draw
+ */
+ eraseGeometry: function(geometry) {},
+
+ /**
+ * virtual function
+ *
+ * draw a point geometry on the specified layer.
+ *
+ * @param geometry {Geometry} a geometry to draw
+ * @param style {Style} a style to use when drawing
+ */
+ drawPoint: function(geometry, style) {},
+
+ /**
+ * virtual function
+ *
+ * draw a line geometry on the specified layer.
+ *
+ * @param geometry {Geometry} a geometry to draw
+ * @param style {Style} a style to use when drawing
+ */
+ drawLineString: function(geometry, style) {},
+
+ /**
+ * virtual function
+ *
+ * draw a linear ring geometry on the specified layer.
+ *
+ * @param geometry {Geometry} a geometry to draw
+ * @param style {Style} a style to use when drawing
+ */
+ drawLinearRing: function(geometry, style) {},
+
+ /**
+ * virtual function
+ *
+ * draw a polygon geometry on the specified layer.
+ *
+ * @param geometry {Geometry} a geometry to draw
+ * @param style {Style} a style to use when drawing
+ */
+ drawPolygon: function(geometry, style) {},
+
+ /**
+ * virtual function
+ *
+ * draw a rectangular geometry on the specified layer.
+ *
+ * @param geometry {Geometry} a geometry to draw
+ * @param style {Style} a style to use when drawing
+ */
+ drawRectangle: function(geometry, style) {},
+
+ /**
+ * virtual function
+ *
+ * draw a cirle geometry on the specified layer.
+ *
+ * @param geometry {Geometry} a geometry to draw
+ * @param style {Style} a style to use when drawing
+ */
+ drawCircle: function(geometry, style) {},
+
+ /**
+ * virtual function
+ *
+ * draw a Curve geometry on the specified layer.
+ *
+ * @param geometry {Geometry} a geometry to draw
+ * @param style {Style} a style to use when drawing
+ */
+ drawCurve: function(geometry, style) {},
+
+ /**
+ * virtual function
+ *
+ * draw a surface geometry on the specified layer.
+ *
+ * @param geometry {Geometry} a geometry to draw
+ * @param style {Style} a style to use when drawing
+ */
+ drawSurface: function(geometry, style) {},
+
+ /** @final @type String */
+ CLASS_NAME: "OpenLayers.Renderer"
+};
More information about the Commits
mailing list