Changeset 5432
- Timestamp:
- 12/15/07 13:02:55 (1 year ago)
- Files:
-
- sandbox/ahocevar/styles/apidoc_config/Menu.txt (modified) (1 diff)
- sandbox/ahocevar/styles/doc/authors.txt (modified) (1 diff)
- sandbox/ahocevar/styles/doc_config/Menu.txt (modified) (1 diff)
- sandbox/ahocevar/styles/examples/georss-flickr.html (modified) (4 diffs)
- sandbox/ahocevar/styles/examples/sld.html (modified) (2 diffs)
- sandbox/ahocevar/styles/lib/OpenLayers.js (modified) (4 diffs)
- sandbox/ahocevar/styles/lib/OpenLayers/Format/Text.js (copied) (copied from trunk/openlayers/lib/OpenLayers/Format/Text.js)
- sandbox/ahocevar/styles/lib/OpenLayers/Layer/FixedZoomLevels.js (modified) (1 diff)
- sandbox/ahocevar/styles/lib/OpenLayers/Layer/SphericalMercator.js (modified) (2 diffs)
- sandbox/ahocevar/styles/lib/OpenLayers/Layer/Text.js (modified) (1 diff)
- sandbox/ahocevar/styles/lib/OpenLayers/Layer/Vector.js (modified) (1 diff)
- sandbox/ahocevar/styles/lib/OpenLayers/Popup/AnchoredBubble.js (modified) (1 diff)
- sandbox/ahocevar/styles/lib/OpenLayers/Projection.js (modified) (2 diffs)
- sandbox/ahocevar/styles/lib/OpenLayers/Renderer/SVG.js (modified) (5 diffs)
- sandbox/ahocevar/styles/lib/OpenLayers/Rule/Comparison.js (modified) (1 diff)
- sandbox/ahocevar/styles/lib/OpenLayers/Rule/FeatureId.js (modified) (1 diff)
- sandbox/ahocevar/styles/lib/OpenLayers/Rule/Logical.js (modified) (1 diff)
- sandbox/ahocevar/styles/lib/OpenLayers/Style.js (modified) (2 diffs)
- sandbox/ahocevar/styles/lib/OpenLayers/Tile/Image.js (modified) (1 diff)
- sandbox/ahocevar/styles/tests/Layer/test_SphericalMercator.html (modified) (3 diffs)
- sandbox/ahocevar/styles/tests/Popup/test_AnchoredBubble.html (copied) (copied from trunk/openlayers/tests/Popup/test_AnchoredBubble.html)
- sandbox/ahocevar/styles/tests/Renderer/test_SVG.html (modified) (3 diffs)
- sandbox/ahocevar/styles/tests/list-tests.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/ahocevar/styles/apidoc_config/Menu.txt
r5316 r5432 169 169 } # Group: Marker 170 170 171 File: Projection (no auto-title, OpenLayers/Projection.js) 172 171 173 Group: Popup { 172 174 sandbox/ahocevar/styles/doc/authors.txt
r5238 r5432 14 14 Philip Lindsay 15 15 Corey Puffault 16 Gregers Rygg 16 17 Tim Schaub 17 18 Christopher Schmidt sandbox/ahocevar/styles/doc_config/Menu.txt
r5316 r5432 169 169 } # Group: Marker 170 170 171 File: Projection (no auto-title, OpenLayers/Projection.js) 172 171 173 Group: Popup { 172 174 sandbox/ahocevar/styles/examples/georss-flickr.html
r5310 r5432 16 16 var map, layer, markerLayer, style, popup; 17 17 18 // create a property style that reads the externalGraphic url from19 // the thumbail attribute of the rss item20 style = new OpenLayers.Style({21 externalGraphic: "${thumbnail}",22 pointRadius: 20});23 24 // create a rule with a point symbolizer that will make the thumbnail25 // larger if the title of the rss item conatins "powder"26 var rule = new OpenLayers.Rule.Comparison({27 type: OpenLayers.Rule.Comparison.LIKE,28 property: "title",29 value: "*powder*",30 symbolizer: {"Point": {pointRadius: 30}}});31 rule.value2regex("*");32 33 style.addRules([rule]);34 18 35 19 function init(){ … … 42 26 map.setCenter(new OpenLayers.LonLat(0, 0), 0); 43 27 map.addControl(new OpenLayers.Control.LayerSwitcher()); 28 29 // create a property style that reads the externalGraphic url from 30 // the thumbail attribute of the rss item 31 style = new OpenLayers.Style({ 32 externalGraphic: "${thumbnail}", 33 pointRadius: 20}); 34 35 // create a rule with a point symbolizer that will make the thumbnail 36 // larger if the title of the rss item conatins "powder" 37 var rule = new OpenLayers.Rule.Comparison({ 38 type: OpenLayers.Rule.Comparison.LIKE, 39 property: "title", 40 value: "*powder*", 41 symbolizer: {"Point": {pointRadius: 30}}}); 42 rule.value2regex("*"); 43 44 style.addRules([rule]); 45 46 markerLayer = new OpenLayers.Layer.Vector("", {style: style}); 47 map.addLayer(markerLayer); 48 49 // control that will show a popup when clicking on a thumbnail 50 var popupControl = new OpenLayers.Control.SelectFeature(markerLayer, { 51 selectStyle: style, 52 onSelect: function(feature) { 53 var pos = feature.geometry; 54 if (popup) { 55 map.removePopup(popup); 56 } 57 popup = new OpenLayers.Popup("popup", 58 new OpenLayers.LonLat(pos.x, pos.y), 59 new OpenLayers.Size(254,320), 60 "<h3>" + feature.attributes.title + "</h3>" + 61 feature.attributes.description, 62 true); 63 map.addPopup(popup); 64 } 65 }); 66 map.addControl(popupControl); 67 68 popupControl.activate(); 44 69 45 70 OpenLayers.loadURL("xml/georss-flickr.xml", "", null, afterload); … … 60 85 61 86 var store = new OpenLayers.Format.GeoRSS({ 62 geons: "http://www.georss.org/georss",63 87 createFeatureFromItem: createFeatureFromItem}); 64 88 … … 68 92 var title = req.responseXML.getElementsByTagName("title")[0] 69 93 .firstChild.nodeValue; 70 71 // extended version of OpenLayers.Layer.Vector.drawFeature; 72 // applies the style before calling the original function 73 var drawFeature = function(feature) { 74 feature.style = feature.layer.style.createStyle(feature); 75 OpenLayers.Layer.Vector.prototype.drawFeature.apply(feature.layer, arguments); 76 } 77 78 markerLayer = new OpenLayers.Layer.Vector(title, { 79 style: style, 80 drawFeature: drawFeature}); 81 map.addLayer(markerLayer); 82 94 95 markerLayer.setName(title); 83 96 markerLayer.addFeatures(rss); 84 85 // control that will show a popup when clicking on a thumbnail86 var popupControl = new OpenLayers.Control.SelectFeature(markerLayer);87 map.addControl(popupControl);88 89 // onSelect function to create a popup90 popupControl.onSelect = function(feature) {91 var pos = feature.geometry;92 if (popup) {93 map.removePopup(popup);94 }95 popup = new OpenLayers.Popup("popup",96 new OpenLayers.LonLat(pos.x, pos.y),97 new OpenLayers.Size(254,320),98 "<h3>" + feature.attributes.title + "</h3>" +99 feature.attributes.description,100 true);101 map.addPopup(popup);102 }103 104 popupControl.activate();105 97 } 106 98 </script> sandbox/ahocevar/styles/examples/sld.html
r5304 r5432 34 34 waterStyle = styles["WaterBodies"]; 35 35 36 // replaces OpenLayers.Layer.Vector.drawFeature37 var drawFeature = function(feature) {38 feature.style = feature.layer.style.createStyle(feature);39 OpenLayers.Layer.Vector.prototype.drawFeature.apply(feature.layer, arguments);40 }41 42 36 gmlLayers = [ 43 37 // use the sld UserStyle named "Default Styler" 44 38 new OpenLayers.Layer.GML("StateBoundaries", 45 39 "tasmania/TasmaniaStateBoundaries.xml", { 46 style: waterStyle["default"], 47 drawFeature: drawFeature}), 40 style: waterStyle["default"]}), 48 41 new OpenLayers.Layer.GML("Roads", 49 42 "tasmania/TasmaniaRoads.xml", { 50 style: waterStyle["default"], 51 drawFeature: drawFeature}), 52 new OpenLayers.Layer.GML("WaterBodies", 43 style: waterStyle["default"]}), 44 new OpenLayers.Layer.GML("WaterBodies", 53 45 "tasmania/TasmaniaWaterBodies.xml", { 54 style: waterStyle["default"], 55 drawFeature: drawFeature}), 46 style: waterStyle["default"]}), 56 47 new OpenLayers.Layer.GML("Cities", 57 48 "tasmania/TasmaniaCities.xml", { 58 style: waterStyle["default"], 59 drawFeature: drawFeature})]; 49 style: waterStyle["default"]})]; 60 50 61 51 // add the first layer with the style passed to the constructor … … 96 86 // set a new style when the radio button changes 97 87 function setStyle(styleName) { 98 // change the style of the WaterBodies layer 99 gmlLayers[2].style = waterStyle[styleName]; 88 // change the style of the features of the WaterBodies layer 89 var features = gmlLayers[2].features; 90 for (var i=0; i<features.length; i++) { 91 features[i].style = waterStyle[styleName]; 92 } 100 93 gmlLayers[2].redraw(); 101 94 } sandbox/ahocevar/styles/lib/OpenLayers.js
r5409 r5432 79 79 "OpenLayers/Ajax.js", 80 80 "OpenLayers/Events.js", 81 "OpenLayers/Projection.js", 81 82 "OpenLayers/Map.js", 82 83 "OpenLayers/Layer.js", … … 177 178 "OpenLayers/Format/WKT.js", 178 179 "OpenLayers/Format/SLD.js", 180 "OpenLayers/Format/Text.js", 179 181 "OpenLayers/Format/JSON.js", 180 182 "OpenLayers/Format/GeoJSON.js", … … 182 184 "OpenLayers/Control/MouseToolbar.js", 183 185 "OpenLayers/Control/NavToolbar.js", 184 "OpenLayers/Control/EditingToolbar.js", 185 "OpenLayers/Projection.js" 186 "OpenLayers/Control/EditingToolbar.js" 186 187 ); // etc. 187 188 188 189 190 var allScriptTags = ""; 191 var host = OpenLayers._getScriptLocation() + "lib/"; 192 189 var agent = navigator.userAgent; 190 var docWrite = (agent.match("MSIE") || agent.match("Safari")); 191 if(docWrite) { 192 var allScriptTags = new Array(jsfiles.length); 193 } 194 var host = OpenLayers._getScriptLocation() + "lib/"; 193 195 for (var i = 0; i < jsfiles.length; i++) { 194 if ( /MSIE/.test(navigator.userAgent) || /Safari/.test(navigator.userAgent)) {195 var currentScriptTag = "<script src='" + host + jsfiles[i] + "'></script>";196 allScriptTags += currentScriptTag;196 if (docWrite) { 197 allScriptTags[i] = "<script src='" + host + jsfiles[i] + 198 "'></script>"; 197 199 } else { 198 200 var s = document.createElement("script"); … … 204 206 } 205 207 } 206 if ( allScriptTags) {207 document.write(allScriptTags );208 if (docWrite) { 209 document.write(allScriptTags.join("")); 208 210 } 209 211 } sandbox/ahocevar/styles/lib/OpenLayers/Layer/FixedZoomLevels.js
r5343 r5432 184 184 return OpenLayers.Layer.prototype.getZoomForResolution.apply(this, arguments); 185 185 } else { 186 var extent = OpenLayers.Layer.prototype.getExtent.apply(this, 187 [resolution]); 188 186 var extent = OpenLayers.Layer.prototype.getExtent.apply(this, []); 189 187 return this.getZoomForExtent(extent); 190 188 } sandbox/ahocevar/styles/lib/OpenLayers/Layer/SphericalMercator.js
r5409 r5432 1 1 /** @requires OpenLayers/Layer.js 2 * @requires OpenLayers/Projection.js 2 3 * 3 4 * Class: OpenLayers.Layer.SphericalMercator … … 102 103 103 104 return new OpenLayers.LonLat(lon, lat); 105 }, 106 107 /** 108 * Method: projectForward 109 * Given an object with x and y properties in EPSG:4326, modify the x,y 110 * properties on the object to be the Spherical Mercator projected 111 * coordinates. 112 * 113 * Parameters: 114 * point - {Object} An object with x and y properties. 115 * 116 * Returns: 117 * {Object} The point, with the x and y properties transformed to spherical 118 * mercator. 119 */ 120 projectForward: function(point) { 121 var lonlat = OpenLayers.Layer.SphericalMercator.forwardMercator(point.x, point.y); 122 point.x = lonlat.lon; 123 point.y = lonlat.lat; 124 return point; 125 }, 126 127 /** 128 * Method: projectForward 129 * Given an object with x and y properties in Spherical Mercator, modify 130 * the x,y properties on the object to be the unprojected coordinates. 131 * 132 * Parameters: 133 * point - {Object} An object with x and y properties. 134 * 135 * Returns: 136 * {Object} The point, with the x and y properties transformed from 137 * spherical mercator to unprojected coordinates.. 138 */ 139 projectInverse: function(point) { 140 var lonlat = OpenLayers.Layer.SphericalMercator.inverseMercator(point.x, point.y); 141 point.x = lonlat.lon; 142 point.y = lonlat.lat; 143 return point; 104 144 } 105 145 106 146 }; 147 148 /** 149 * Note: Two transforms declared 150 * Transforms from EPSG:4326 to EPSG:900913 and from EPSG:900913 to EPSG:4326 151 * are set by this class. 152 */ 153 OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:900913", 154 OpenLayers.Layer.SphericalMercator.projectForward); 155 OpenLayers.Projection.addTransform("EPSG:900913", "EPSG:4326", 156 OpenLayers.Layer.SphericalMercator.projectInverse); sandbox/ahocevar/styles/lib/OpenLayers/Layer/Text.js
r5316 r5432 101 101 parseData: function(ajaxRequest) { 102 102 var text = ajaxRequest.responseText; 103 var lines = text.split('\n');104 var columns;105 // length - 1 to allow for trailing new line106 for (var lcv = 0; lcv < (lines.length - 1); lcv++) {107 var currLine = lines[lcv].replace(/^\s*/,'').replace(/\s*$/,'');108 109 if (currLine.charAt(0) != '#') { /* not a comment */103 var parser = new OpenLayers.Format.Text(); 104 features = parser.read(text); 105 for (var i = 0; i < features.length; i++) { 106 var data = {}; 107 var feature = features[i]; 108 var location; 109 var iconSize, iconOffset; 110 110 111 if (!columns) { 112 //First line is columns 113 columns = currLine.split('\t'); 114 } else { 115 var vals = currLine.split('\t'); 116 var location = new OpenLayers.LonLat(0,0); 117 var title, url, description; 118 var icon, iconSize, iconOffset, overflow; 119 var set = false; 120 for (var valIndex = 0; valIndex < vals.length; valIndex++) { 121 if (vals[valIndex]) { 122 if (columns[valIndex] == 'point') { 123 var coords = vals[valIndex].split(','); 124 location.lat = parseFloat(coords[0]); 125 location.lon = parseFloat(coords[1]); 126 set = true; 127 } else if (columns[valIndex] == 'lat') { 128 location.lat = parseFloat(vals[valIndex]); 129 set = true; 130 } else if (columns[valIndex] == 'lon') { 131 location.lon = parseFloat(vals[valIndex]); 132 set = true; 133 } else if (columns[valIndex] == 'title') { 134 title = vals[valIndex]; 135 } else if (columns[valIndex] == 'image' || 136 columns[valIndex] == 'icon') { 137 url = vals[valIndex]; 138 } else if (columns[valIndex] == 'iconSize') { 139 var size = vals[valIndex].split(','); 140 iconSize = new OpenLayers.Size(parseFloat(size[0]), 141 parseFloat(size[1])); 142 } else if (columns[valIndex] == 'iconOffset') { 143 var offset = vals[valIndex].split(','); 144 iconOffset = new OpenLayers.Pixel(parseFloat(offset[0]), 145 parseFloat(offset[1])); 146 } else if (columns[valIndex] == 'title') { 147 title = vals[valIndex]; 148 } else if (columns[valIndex] == 'description') { 149 description = vals[valIndex]; 150 } else if (columns[valIndex] == 'overflow') { 151 overflow = vals[valIndex]; 152 } 153 } 154 } 155 if (set) { 156 var data = {}; 157 if (url != null) { 158 data.icon = new OpenLayers.Icon(url, 159 iconSize, 160 iconOffset); 161 } else { 162 data.icon = OpenLayers.Marker.defaultIcon(); 111 location = new OpenLayers.LonLat(feature.geometry.x, 112 feature.geometry.y); 113 114 if (feature.style.graphicWidth 115 && feature.style.graphicHeight) { 116 iconSize = new OpenLayers.Size( 117 feature.style.graphicWidth, 118 feature.style.graphicHeight); 119 } 120 121 // FIXME: At the moment, we only use this if we have an 122 // externalGraphic, because icon has no setOffset API Method. 123 if (feature.style.graphicXOffset 124 && feature.style.graphicYOffset) { 125 iconOffset = new OpenLayers.Size( 126 feature.style.graphicXOffset, 127 feature.style.graphicYOffset); 128 } 129 130 if (feature.style.externalGraphic != null) { 131 data.icon = new OpenLayers.Icon(feature.style.externalGraphic, 132 iconSize, 133 iconOffset); 134 } else { 135 data.icon = OpenLayers.Marker.defaultIcon(); 163 136 164 //allows for the case where the image url is not 165 // specified but the size is. use a default icon 166 // but change the size 167 if (iconSize != null) { 168 data.icon.setSize(iconSize); 169 } 170 171 } 172 if ((title != null) && (description != null)) { 173 data['popupContentHTML'] = '<h2>'+title+'</h2><p>'+description+'</p>'; 174 } 175 176 data['overflow'] = overflow || "auto"; 177 178 var feature = new OpenLayers.Feature(this, location, data); 179 this.features.push(feature); 180 var marker = feature.createMarker(); 181 if ((title != null) && (description != null)) { 182 marker.events.register('click', feature, this.markerClick); 183 } 184 this.addMarker(marker); 185 } 137 //allows for the case where the image url is not 138 // specified but the size is. use a default icon 139 // but change the size 140 if (iconSize != null) { 141 data.icon.setSize(iconSize); 186 142 } 187 143 } 144 145 if ((feature.attributes.title != null) 146 && (feature.attributes.description != null)) { 147 data['popupContentHTML'] = 148 '<h2>'+feature.attributes.title+'</h2>' + 149 '<p>'+feature.attributes.description+'</p>'; 150 } 151 152 data['overflow'] = feature.attributes.overflow || "auto"; 153 154 var markerFeature = new OpenLayers.Feature(this, location, data); 155 this.features.push(markerFeature); 156 var marker = markerFeature.createMarker(); 157 if ((feature.attributes.title != null) 158 && (feature.attributes.description != null)) { 159 marker.events.register('click', markerFeature, this.markerClick); 160 } 161 this.addMarker(marker); 188 162 } 189 163 this.events.triggerEvent("loadend"); sandbox/ahocevar/styles/lib/OpenLayers/Layer/Vector.js
r5343 r5432 351 351 } 352 352 } 353 354 if (style && style.CLASS_NAME && 355 style.CLASS_NAME == "OpenLayers.Style") { 356 style = style.createStyle(feature); 357 } 358 353 359 this.renderer.drawFeature(feature, style); 354 360 }, sandbox/ahocevar/styles/lib/OpenLayers/Popup/AnchoredBubble.js
r4985 r5432 129 129 */ 130 130 setOpacity:function(opacity) { 131 if (opacity != undefined) { 132 this.opacity = opacity; 133 } 131 OpenLayers.Popup.Anchored.prototype.setOpacity.call(this, opacity); 134 132 135 133 if (this.div != null) { 136 if (this. contentDiv != null) {137 OpenLayers.Rico.Corner.changeOpacity(this. contentDiv,134 if (this.groupDiv != null) { 135 OpenLayers.Rico.Corner.changeOpacity(this.groupDiv, 138 136 this.opacity); 139 137 } sandbox/ahocevar/styles/lib/OpenLayers/Projection.js
r5409 r5432 7 7 * 8 8 * Class: OpenLayers.Projection 9 * Class for coordinate transform ations between coordinate systems.9 * Class for coordinate transforms between coordinate systems. 10 10 * Depends on the proj4js library. If proj4js is not available, 11 11 * then this is just an empty stub. … … 103 103 104 104 /** 105 * Property: transforms 106 * Transforms is an object, with from properties, each of which may 107 * have a to property. This allows you to define projections without 108 * requiring support for proj4js to be included. 109 * 110 * This object has keys which correspond to a 'source' projection object. The 111 * keys should be strings, corresponding to the projection.getCode() value. 112 * Each source projection object should have a set of destination projection 113 * keys included in the object. 114 * 115 * Each value in the destination object should be a transformation function, 116 * where the function is expected to be passed an object with a .x and a .y 117 * property. The function should return the object, with the .x and .y 118 * transformed according to the transformation function. 119 * 120 * Note - Properties on this object should not be set directly. To add a 121 * transform method to this object, use the <addTransform> method. For an 122 * example of usage, see the OpenLayers.Layer.SphericalMercator file. 123 */ 124 OpenLayers.Projection.transforms = {}; 125 126 /** 127 * APIMethod: addTransform 128 * Set a custom transform method between two projections. Use this method in 129 * cases where the proj4js lib is not available or where custom projections 130 * need to be handled. 131 * 132 * Parameters: 133 * from - {String} The code for the source projection 134 * to - {String} the code for the destination projection 135 * method - {Function} A function that takes a point as an argument and 136 * transforms that point from the source to the destination projection 137 * in place. The original point should be modified. 138 */ 139 OpenLayers.Projection.addTransform = function(from, to, method) { 140 if(!OpenLayers.Projection.transforms[from]) { 141 OpenLayers.Projection.transforms[from] = {}; 142 } 143 OpenLayers.Projection.transforms[from][to] = method; 144 }; 145 146 /** 105 147 * APIMethod: transform 106 * Read data from a string, and return an object whose type depends on the107 * subclass.148 * Transform a point coordinate from one projection to another. Note that 149 * the input point is transformed in place. 108 150 * 109 151 * Parameters: 110 * point - {object} input horizontal coodinate 111 * sourceProj - {OpenLayers.Projection} source map coordinate system 112 * destProj - {OpenLayers.Projection} destination map coordinate system 152 * point - {{OpenLayers.Geometry.Point> | Object} An object with x and y 153 * properties representing coordinates in those dimensions. 154 * sourceProj - {OpenLayers.Projection} Source map coordinate system 155 * destProj - {OpenLayers.Projection} Destination map coordinate system 113 156 * 114 157 * Returns: 115 * point - {object} trasnformed coordinate158 * point - {object} A transformed coordinate. The original point is modified. 116 159 */ 117 160 OpenLayers.Projection.transform = function(point, source, dest) { 118 161 if (source.proj && dest.proj) { 119 162 point = Proj4js.transform(source.proj, dest.proj, point); 163 } else if (source && dest && 164 OpenLayers.Projection.transforms[source.getCode()] && 165 OpenLayers.Projection.transforms[source.getCode()][dest.getCode()]) { 166 OpenLayers.Projection.transforms[source.getCode()][dest.getCode()](point); 120 167 } 121 168 return point; sandbox/ahocevar/styles/lib/OpenLayers/Renderer/SVG.js
r5409 r5432 216 216 217 217 node.setAttributeNS(null, "x", (x + xOffset).toFixed()); 218 node.setAttributeNS(null, "y", ( -y + yOffset).toFixed());218 node.setAttributeNS(null, "y", (y + yOffset).toFixed()); 219 219 node.setAttributeNS(null, "width", width); 220 220 node.setAttributeNS(null, "height", height); 221 221 node.setAttributeNS("http://www.w3.org/1999/xlink", "href", style.externalGraphic); 222 node.setAttributeNS(null, "transform", "scale(1,-1)");223 222 node.setAttributeNS(null, "style", "opacity: "+opacity); 224 223 } else { … … 305 304 createRoot: function() { 306 305 var id = this.container.id + "_root"; 307 308 306 var root = this.nodeFactory(id, "g"); 309 310 // flip the SVG display Y axis upside down so it311 // matches the display Y axis of the map312 root.setAttributeNS(null, "transform", "scale(1, -1)");313 314 307 return root; 315 308 }, … … 345 338 var resolution = this.getResolution(); 346 339 var x = (geometry.x / resolution + this.left); 347 var y = ( geometry.y / resolution - this.top);340 var y = (this.top - geometry.y / resolution); 348 341 349 342 if (this.inValidRange(x, y)) { … … 424 417 var resolution = this.getResolution(); 425 418 var x = (geometry.x / resolution + this.left); 426 var y = ( geometry.y / resolution - this.top);419 var y = (this.top - geometry.y / resolution); 427 420 428 421 if (this.inValidRange(x, y)) { … … 505 498 var resolution = this.getResolution(); 506 499 var x = (point.x / resolution + this.left); 507 var y = ( point.y / resolution - this.top);500 var y = (this.top - point.y / resolution); 508 501 509 502 if (this.inValidRange(x, y)) { sandbox/ahocevar/styles/lib/OpenLayers/Rule/Comparison.js
r5308 r5432 1 /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license. 2 * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 3 * for the full text of the license. */ 4 1 /* Copyright (c) 2006-2007 MetaCarta, Inc., published under the Clear BSD 2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the 3 * full text of the license. */ 5 4 6 5 /** sandbox/ahocevar/styles/lib/OpenLayers/Rule/FeatureId.js
r5274 r5432 1 /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.2 * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt3 * for thefull text of the license. */1 /* Copyright (c) 2006-2007 MetaCarta, Inc., published under the Clear BSD 2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the 3 * full text of the license. */ 4 4 5 5 sandbox/ahocevar/styles/lib/OpenLayers/Rule/Logical.js
r5306 r5432 1 /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.2 * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt3 * for thefull text of the license. */1 /* Copyright (c) 2006-2007 MetaCarta, Inc., published under the Clear BSD 2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the 3 * full text of the license. */ 4 4 5 5 sandbox/ahocevar/styles/lib/OpenLayers/Style.js
r5315 r5432 1 /* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.2 * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt3 * for thefull text of the license. */1 /* Copyright (c) 2006-2007 MetaCarta, Inc., published under the Clear BSD 2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the 3 * full text of the license. */ 4 4 5 5 … … 257 257 if (typeof value == "string" && value.indexOf("${") != -1) { 258 258 var attributes = feature.attributes || feature.data; 259 // the following line depends on #1133260 259 value = OpenLayers.String.format(value, attributes) 261 260 value = isNaN(value) ? value : parseFloat(value); sandbox/ahocevar/styles/lib/OpenLayers/Tile/Image.js
r5316 r5432 217 217 OpenLayers.Function.bind(onload, this)); 218 218 219 // Bind a listener to the onerror of the image div so that we 220 // can registere when a tile has finished loading with errors. 221 var onerror = function() { 222 223 // If we have gone through all image reload attempts, it is time 224 // to realize that we are done with this image. Since 225 // OpenLayers.Util.onImageLoadError already has taken care about 226 // the error, we can continue as if the image was loaded 227 // successfully. 228 if (this.imgDiv._attempts > OpenLayers.IMAGE_RELOAD_ATTEMPTS) { 229 onload.call(this); 230 } 231 }; 232 OpenLayers.Event.observe(this.imgDiv, "error", 233 OpenLayers.Function.bind(onerror, this)); 219 234 }, 220 235 sandbox/ahocevar/styles/tests/Layer/test_SphericalMercator.html
r4221 r5432 1 1 <html> 2 2 <head> 3 <!-- this gmaps key generated for http://openlayers.org/dev/ -->4 3 <script src="../../lib/OpenLayers.js"></script> 5 4 <script type="text/javascript"> 6 function test_SphericalMercator_forward Project(t) {5 function test_SphericalMercator_forwardMercator(t) { 7 6 t.plan(12); 8 7 var arctic = OpenLayers.Layer.SphericalMercator.forwardMercator(0, 85); … … 33 32 } 34 33 35 function test_sphericalMercator_inverse Project(t) {34 function test_sphericalMercator_inverseMercator(t) { 36 35 t.plan(4); 37 36 var sw = OpenLayers.Layer.SphericalMercator.inverseMercator(-20037508.34, -20037508.34); … … 43 42 t.eq(ne.lat, 85.05112877980660, "Northeast lat correct"); 44 43 } 44 45 function strToFixed(str, dig) { 46 if(dig == undefined) { 47 dig = 5; 48 } 49 return str.replace(/(\d+\.\d+)/g, function(match) { 50 return parseFloat(match).toFixed(dig); 51 }); 52 } 53 54 function test_SphericalMercator_projectForward(t) { 55 t.plan(1); 56 var point = new OpenLayers.Geometry.Point(10, 20); 57 OpenLayers.Layer.SphericalMercator.projectForward(point); 58 59 t.eq(strToFixed(point.toString()), 60 strToFixed("POINT(1113194.9077777779 2273030.9266712805)"), 61 "point transforms from EPSG:4326 to Spherical Mercator"); 62 } 63 64 function test_SphericalMercator_to4326(t) { 65 t.plan(1); 66 var point = new OpenLayers.Geometry.Point(1113195, 2273031); 67 68 OpenLayers.Layer.SphericalMercator.projectInverse(point); 69 70 t.eq(strToFixed(point.toString()), 71 strToFixed("POINT(10.000000828446318 20.000000618997227)"), 72 "point transforms from EPSG:4326 to Spherical Mercator"); 73 } 74 75 function test_SphericalMercator_addTransform(t) { 76 // this class should add two methods to the 77 // OpenLayers.Projection.transforms object 78 t.plan(4); 79 var wgs84 = OpenLayers.Projection.transforms["EPSG:4326"]; 80 t.ok(wgs84 instanceof Object, "EPSG:4326 exists in table"); 81 82
