Changeset 2020
- Timestamp:
- 12/06/06 22:47:42 (2 years ago)
- Files:
-
- sandbox/vector/lib/OpenLayers/BaseTypes.js (modified) (1 diff)
- sandbox/vector/lib/OpenLayers/Control/EditingAttributes.js (modified) (7 diffs)
- sandbox/vector/lib/OpenLayers/Feature.js (modified) (3 diffs)
- sandbox/vector/lib/OpenLayers/Geometry.js (modified) (2 diffs)
- sandbox/vector/lib/OpenLayers/Geometry/Aggregate.js (modified) (1 diff)
- sandbox/vector/lib/OpenLayers/Parser/GML.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/vector/lib/OpenLayers/BaseTypes.js
r2013 r2020 488 488 this.top=(top>this.top)?top:this.top; 489 489 }else{ 490 this.right=(left <this.left)?left:this.left;491 this.top=(bottom <this.bottom)?bottom:this.bottom;490 this.right=(left>this.right)?left:this.right; 491 this.top=(bottom>this.top)?bottom:this.top; 492 492 } 493 493 } sandbox/vector/lib/OpenLayers/Control/EditingAttributes.js
r2009 r2020 28 28 29 29 /** 30 * Register for mousedown events 31 */ 32 turnOn: function() { 33 34 this.setLayer(); 35 36 this.defaultMouseDown = this.defaultMouseDown.bindAsEventListener(this); 37 this.map.events.register( "mousedown", this, this.defaultMouseDown); 38 }, 39 40 /** 41 * 42 */ 43 turnOff: function() { 44 this.map.events.unregister( "mousedown", this, this.defaultMouseDown); 45 }, 46 47 /** 30 48 * Render an array of attributes into a popup. 31 49 * @param attributes Attributes array to render 32 50 */ 33 51 setContent: function(attributes) { 34 // Clear previous popup35 this.div.innerHTML="";36 52 // Clear previous popup 53 this.div.innerHTML=""; 54 37 55 //configure main div 38 56 this.div.style.position = "absolute"; … … 50 68 51 69 this.innerDiv = document.createElement("div"); 52 this.innerDiv.innerHTML="<b>Attribute List</b><br/>"70 this.innerDiv.innerHTML="<b>Attribute List</b><br/>" 53 71 this.innerDiv.id = "layersDiv"; 54 72 this.innerDiv.style.paddingTop = "2px"; … … 57 75 this.innerDiv.style.paddingRight = "2px"; 58 76 this.innerDiv.style.backgroundColor = this.activeColor; 59 this.div.appendChild(this.innerDiv);77 this.div.appendChild(this.innerDiv); 60 78 61 79 Rico.Corner.round(this.div, {corners: "tl bl", … … 65 83 66 84 Rico.Corner.changeOpacity(this.innerDiv, 0.75); 67 85 68 86 attribs=attributes.getAttributes(); 69 87 for (var i = 0; i < attribs.length; i++) { … … 85 103 this.innerDiv.appendChild(attributeDiv); 86 104 } 87 105 88 106 // minimize button div 89 107 var imgLocation = OpenLayers.Util.getImagesLocation(); … … 105 123 this.div.appendChild(this.minimizeDiv); 106 124 107 // Stop MouseEvents from propogating through this popup125 // Stop MouseEvents from propogating through this popup 108 126 OpenLayers.Event.observe(this.div, "mouseup", this.ignoreEvent); 109 127 OpenLayers.Event.observe(this.div, "mousedown", this.ignoreEvent); … … 130 148 }, 131 149 150 /** 151 * Add the Geometry that has been selected to the Event. 152 * The top geometry layer is selected first, this is done using 153 * SVG/VML feature selection and is accurate. If a feature is not 154 * found, features in layers below are progressively queried using 155 * the BoundingBox of the feature. (Ie, it is not very accurate). 156 * See http://trac.openlayers.org/ticket/434 for more info. 157 * 158 * @param {Event} evt 159 */ 160 setEventContext: function(evt) { 161 // calculate the mouse position 162 var lonlat = this.map.getLonLatFromLayerPx(evt.xy); 163 evt.point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat); 164 165 // For the top layer, query the SVG/VML feature 166 if(map.layers.length>0){ 167 evt.targetGeometry = map.layers[map.layers.length-1].renderer.getGeometryFromEvent(evt); 168 } 169 // For remaining layers, query features based on feature bounds. 170 // Exit loop when a feature is found. 171 for(var i=map.layers.length-1;(!evt.targetGeometry&&(i>=0));i--){ 172 if(map.layers[i].getVisibility()&&map.layers[i].isVector){ 173 for(var f=0;!evt.targetGeometry&&(f<map.layers[i].features.length);f++){ 174 if(map.layers[i].features[f].atPoint(lonlat)){ 175 evt.targetGeometry=map.layers[i].features[f].geometry; 176 } 177 178 } 179 } 180 } 181 182 // reset evt.point if modes are activated. 183 if (this.editingModes) { 184 for (var i = 0; i < this.editingModes.length; i++) { 185 var snappingCoordinates = 186 this.editingModes[i].calculatePoint(evt.point, evt.targetGeometry, this.geometry, this.layer); 187 188 if (snappingCoordinates) { 189 evt.point = snappingCoordinates; 190 break; 191 } 192 } 193 } 194 }, 195 132 196 /** Hide all the contents of the control, shrink the size, 133 197 * add the maximize icon sandbox/vector/lib/OpenLayers/Feature.js
r2010 r2020 60 60 initialize: function(layer, geometry, data) { 61 61 this.layer = layer; 62 this.setGeometry(geometry);62 this.setGeometry(geometry); 63 63 this.data = (data != null) ? data : new Object(); 64 64 this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); … … 169 169 */ 170 170 setGeometry: function(geometry) { 171 if(geometry){172 this.geometry = geometry;173 this.geometry.feature = this;174 this._setGeometryFeatureReference(this.geometry, this);175 }171 if(geometry){ 172 this.geometry = geometry; 173 this.geometry.feature = this; 174 this._setGeometryFeatureReference(this.geometry, this); 175 } 176 176 }, 177 177 … … 217 217 218 218 /** 219 * Takes an lonLat point and returns true if the feature is at this location. 220 * @param {OpenLayers.LonLat} lonlat 221 * @return Boolean 222 */ 223 atPoint: function(lonlat){ 224 var atPoint=false; 225 if(this.geometry){ 226 atPoint=this.geometry.atPoint(lonlat); 227 } 228 return atPoint; 229 }, 230 231 /** 219 232 * Set geometry style 220 233 * sandbox/vector/lib/OpenLayers/Geometry.js
r2013 r2020 14 14 /** @type OpenLayers.Bounds */ 15 15 bounds: null, 16 17 /**18 * Cross reference back to the feature that owns this geometry so19 * that that the feature can be identified after the geometry has been20 * selected by a mouse click.21 * @type OpenLayers.Feature */22 feature: null,16 17 /** 18 * Cross reference back to the feature that owns this geometry so 19 * that that the feature can be identified after the geometry has been 20 * selected by a mouse click. 21 * @type OpenLayers.Feature */ 22 feature: null, 23 23 24 24 /** … … 30 30 this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME+ "_"); 31 31 }, 32 33 /**34 * Set the bounds for this Geometry.35 * @param {OpenLayers.Bounds} bounds36 */37 setBounds: function(bounds){38 this.bounds=bounds;39 },40 41 /**42 * Extend the existing bounds to include the new bounds. If existing43 * bounds=null, then set a new Bounds.44 * @param {Object} bounds45 */46 extendBounds: function(bounds){47 if(!this.bounds){48 this.setBounds(bounds);49 }else{50 this.bounds.extendBounds(bounds);51 }52 },53 54 /**55 * Get the bounds for this Geometry. The bounds will be null if not it has56 * not been set.57 * Once the bounds is set, it is not calculated again, this makes queries58 * faster.59 * @return {OpenLayers.Bounds}60 */61 getBounds: function(){62 return this.bounds;63 },64 32 33 /** 34 * Set the bounds for this Geometry. 35 * @param {OpenLayers.Bounds} bounds 36 */ 37 setBounds: function(bounds){ 38 this.bounds=bounds; 39 }, 40 41 /** 42 * Extend the existing bounds to include the new bounds. If existing 43 * bounds=null, then set a new Bounds. 44 * @param {Object} bounds 45 */ 46 extendBounds: function(bounds){ 47 if(!this.bounds){ 48 this.setBounds(bounds); 49 }else{ 50 this.bounds.extendBounds(bounds); 51 } 52 }, 53 54 /** 55 * Get the bounds for this Geometry. The bounds will be null if not it has 56 * not been set. 57 * Once the bounds is set, it is not calculated again, this makes queries 58 * faster. 59 * @return {OpenLayers.Bounds} 60 */ 61 getBounds: function(){ 62 return this.bounds; 63 }, 64 65 /** 66 * Takes an lonLat point and returns true if the geometry is at this location. 67 * This is only an approximation based on the bounds of the geometry. 68 * @param {OpenLayers.LonLat} lonlat 69 * @return Boolean 70 */ 71 atPoint: function(lonlat){ 72 var atPoint=false; 73 if(this.bounds){ 74 atPoint=(this.bounds.bottom<=lonlat.lat) 75 && (lonlat.lat<=this.bounds.top) 76 && (this.bounds.left<=lonlat.lon) 77 && (lonlat.lon<=this.bounds.right); 78 } 79 return atPoint; 80 }, 81 65 82 CLASS_NAME: "OpenLayers.Geometry" 66 83 }; sandbox/vector/lib/OpenLayers/Geometry/Aggregate.js
r1982 r2020 46 46 }, 47 47 48 // /** 49 // * Takes an lonLat point and returns true if the feature is at this location. 50 // * @param {OpenLayers.LonLat} lonlat 51 // * @return Boolean 52 // */ 53 // atPoint: function(lonlat){ 54 // var atPoint=false; 55 // var bounds; 56 // if(this.components){ 57 // for(var i=0;!atPoint&&(i<this.components.length);i++){ 58 // atPoint=this.components[i].atPoint(lonlat); 59 // } 60 // }else{ 61 // // The following code is probably not required as 62 // // agregate geometries will always have components. Right? 63 // // Cameron Shorter. 64 // if(this.bounds){ 65 // atPoint=(this.bounds.bottom<=lonlat.lat) 66 // && (lonlat.lat<=this.bounds.top) 67 // && (this.bounds.left<=lonlat.lon) 68 // && (lonlat.lon<=this.bounds.right); 69 // } 70 // } 71 // return atPoint; 72 // }, 73 48 74 CLASS_NAME: "OpenLayers.Geometry.Aggregate" 49 75 }); sandbox/vector/lib/OpenLayers/Parser/GML.js
r2015 r2020 95 95 polygon = this.parsePolygonNode(polygons[i],geom); 96 96 geom.addComponents(polygon); 97 geom.extendBounds(polygon.getBounds());97 geom.extendBounds(polygon.getBounds()); 98 98 } 99 99 } … … 184 184 var rings = []; 185 185 var p; 186 var polyBounds;186 var polyBounds; 187 187 for (var i = 0; i < linearRings.length; i++) { 188 188 p = this.parseCoords(linearRings[i]); 189 ring1=new OpenLayers.Geometry.LinearRing(p.points);190 ring1.extendBounds(p.bounds);191 if(polyBounds){192 polyBounds.extend(p.bounds);193 }else{194 polyBounds=p.bounds;195 }189 ring1=new OpenLayers.Geometry.LinearRing(p.points); 190 ring1.extendBounds(p.bounds); 191 if(polyBounds){ 192 polyBounds.extend(p.bounds); 193 }else{ 194 polyBounds=p.bounds; 195 } 196 196 rings.push(ring1); 197 197 } … … 247 247 y=parseFloat(nums[i+1]); 248 248 p.points.push(new OpenLayers.Geometry.Point(x,y)); 249 250 if(!p.bounds){251 p.bounds=new OpenLayers.Bounds(x,y,x,y);252 }else{253 p.bounds.extendBounds(x,y);254 }249 250 if(!p.bounds){ 251 p.bounds=new OpenLayers.Bounds(x,y,x,y); 252 }else{ 253 p.bounds.extendBounds(x,y); 254 } 255 255 } 256 256 }
