OpenLayers OpenLayers

Changeset 5432

Show
Ignore:
Timestamp:
12/15/07 13:02:55 (1 year ago)
Author:
ahocevar
Message:

merging r5409 to HEAD from trunk; Style and Rule are now in trunk! Modified sld example to make use of recent trunk changes on Layer.Vector.drawFeature

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/ahocevar/styles/apidoc_config/Menu.txt

    r5316 r5432  
    169169      }  # Group: Marker 
    170170 
     171   File: Projection  (no auto-title, OpenLayers/Projection.js) 
     172 
    171173   Group: Popup  { 
    172174 
  • sandbox/ahocevar/styles/doc/authors.txt

    r5238 r5432  
    1414Philip Lindsay 
    1515Corey Puffault 
     16Gregers Rygg 
    1617Tim Schaub 
    1718Christopher Schmidt 
  • sandbox/ahocevar/styles/doc_config/Menu.txt

    r5316 r5432  
    169169      }  # Group: Marker 
    170170 
     171   File: Projection  (no auto-title, OpenLayers/Projection.js) 
     172 
    171173   Group: Popup  { 
    172174 
  • sandbox/ahocevar/styles/examples/georss-flickr.html

    r5310 r5432  
    1616        var map, layer, markerLayer, style, popup; 
    1717         
    18         // create a property style that reads the externalGraphic url from 
    19         // the thumbail attribute of the rss item 
    20         style = new OpenLayers.Style({ 
    21             externalGraphic: "${thumbnail}", 
    22             pointRadius: 20}); 
    23          
    24         // create a rule with a point symbolizer that will make the thumbnail 
    25         // 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]); 
    3418 
    3519        function init(){ 
     
    4226            map.setCenter(new OpenLayers.LonLat(0, 0), 0); 
    4327            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(); 
    4469             
    4570            OpenLayers.loadURL("xml/georss-flickr.xml", "", null, afterload); 
     
    6085 
    6186            var store = new OpenLayers.Format.GeoRSS({ 
    62                     geons: "http://www.georss.org/georss", 
    6387                    createFeatureFromItem: createFeatureFromItem}); 
    6488 
     
    6892            var title = req.responseXML.getElementsByTagName("title")[0] 
    6993                    .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); 
    8396            markerLayer.addFeatures(rss); 
    84              
    85             // control that will show a popup when clicking on a thumbnail 
    86             var popupControl = new OpenLayers.Control.SelectFeature(markerLayer);  
    87             map.addControl(popupControl); 
    88              
    89             // onSelect function to create a popup 
    90             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(); 
    10597        } 
    10698    </script> 
  • sandbox/ahocevar/styles/examples/sld.html

    r5304 r5432  
    3434            waterStyle = styles["WaterBodies"]; 
    3535             
    36             // replaces OpenLayers.Layer.Vector.drawFeature 
    37             var drawFeature = function(feature) { 
    38                 feature.style = feature.layer.style.createStyle(feature); 
    39                 OpenLayers.Layer.Vector.prototype.drawFeature.apply(feature.layer, arguments); 
    40             } 
    41  
    4236            gmlLayers = [ 
    4337                    // use the sld UserStyle named "Default Styler" 
    4438                    new OpenLayers.Layer.GML("StateBoundaries", 
    4539                            "tasmania/TasmaniaStateBoundaries.xml", { 
    46                             style: waterStyle["default"], 
    47                             drawFeature: drawFeature}), 
     40                            style: waterStyle["default"]}), 
    4841                    new OpenLayers.Layer.GML("Roads", 
    4942                            "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", 
    5345                            "tasmania/TasmaniaWaterBodies.xml", { 
    54                             style: waterStyle["default"], 
    55                             drawFeature: drawFeature}), 
     46                            style: waterStyle["default"]}), 
    5647                    new OpenLayers.Layer.GML("Cities", 
    5748                            "tasmania/TasmaniaCities.xml", { 
    58                             style: waterStyle["default"], 
    59                             drawFeature: drawFeature})]; 
     49                            style: waterStyle["default"]})]; 
    6050  
    6151            // add the first layer with the style passed to the constructor 
     
    9686        // set a new style when the radio button changes 
    9787        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            } 
    10093            gmlLayers[2].redraw(); 
    10194        } 
  • sandbox/ahocevar/styles/lib/OpenLayers.js

    r5409 r5432  
    7979            "OpenLayers/Ajax.js", 
    8080            "OpenLayers/Events.js", 
     81            "OpenLayers/Projection.js", 
    8182            "OpenLayers/Map.js", 
    8283            "OpenLayers/Layer.js", 
     
    177178            "OpenLayers/Format/WKT.js", 
    178179            "OpenLayers/Format/SLD.js", 
     180            "OpenLayers/Format/Text.js", 
    179181            "OpenLayers/Format/JSON.js", 
    180182            "OpenLayers/Format/GeoJSON.js", 
     
    182184            "OpenLayers/Control/MouseToolbar.js", 
    183185            "OpenLayers/Control/NavToolbar.js", 
    184             "OpenLayers/Control/EditingToolbar.js", 
    185             "OpenLayers/Projection.js" 
     186            "OpenLayers/Control/EditingToolbar.js" 
    186187        ); // etc. 
    187188 
    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/";     
    193195        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>";  
    197199            } else { 
    198200                var s = document.createElement("script"); 
     
    204206            } 
    205207        } 
    206         if (allScriptTags) { 
    207             document.write(allScriptTags); 
     208        if (docWrite) { 
     209            document.write(allScriptTags.join("")); 
    208210        } 
    209211    } 
  • sandbox/ahocevar/styles/lib/OpenLayers/Layer/FixedZoomLevels.js

    r5343 r5432  
    184184            return OpenLayers.Layer.prototype.getZoomForResolution.apply(this, arguments); 
    185185        } else { 
    186             var extent = OpenLayers.Layer.prototype.getExtent.apply(this,  
    187                                                                     [resolution]); 
    188                                                                      
     186            var extent = OpenLayers.Layer.prototype.getExtent.apply(this, []); 
    189187            return this.getZoomForExtent(extent); 
    190188        } 
  • sandbox/ahocevar/styles/lib/OpenLayers/Layer/SphericalMercator.js

    r5409 r5432  
    11/** @requires OpenLayers/Layer.js 
     2 * @requires OpenLayers/Projection.js 
    23 * 
    34 * Class: OpenLayers.Layer.SphericalMercator 
     
    102103         
    103104        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; 
    104144    } 
    105145 
    106146}; 
     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 */ 
     153OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:900913", 
     154    OpenLayers.Layer.SphericalMercator.projectForward); 
     155OpenLayers.Projection.addTransform("EPSG:900913", "EPSG:4326", 
     156    OpenLayers.Layer.SphericalMercator.projectInverse); 
  • sandbox/ahocevar/styles/lib/OpenLayers/Layer/Text.js

    r5316 r5432  
    101101    parseData: function(ajaxRequest) { 
    102102        var text = ajaxRequest.responseText; 
    103         var lines = text.split('\n'); 
    104         var columns
    105         // length - 1 to allow for trailing new line 
    106         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; 
    110110             
    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(); 
    163136 
    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); 
    186142                } 
    187143            } 
     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); 
    188162        } 
    189163        this.events.triggerEvent("loadend"); 
  • sandbox/ahocevar/styles/lib/OpenLayers/Layer/Vector.js

    r5343 r5432  
    351351            } 
    352352        } 
     353 
     354        if (style && style.CLASS_NAME &&  
     355            style.CLASS_NAME == "OpenLayers.Style") { 
     356            style = style.createStyle(feature); 
     357        }     
     358         
    353359        this.renderer.drawFeature(feature, style); 
    354360    }, 
  • sandbox/ahocevar/styles/lib/OpenLayers/Popup/AnchoredBubble.js

    r4985 r5432  
    129129     */ 
    130130    setOpacity:function(opacity) {  
    131         if (opacity != undefined) { 
    132             this.opacity = opacity;  
    133         } 
     131        OpenLayers.Popup.Anchored.prototype.setOpacity.call(this, opacity); 
    134132         
    135133        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,  
    138136                                                     this.opacity); 
    139137            } 
  • sandbox/ahocevar/styles/lib/OpenLayers/Projection.js

    r5409 r5432  
    77 *  
    88 * Class: OpenLayers.Projection 
    9  * Class for coordinate transformations between coordinate systems. 
     9 * Class for coordinate transforms between coordinate systems. 
    1010 *     Depends on the proj4js library. If proj4js is not available,  
    1111 *     then this is just an empty stub. 
     
    103103 
    104104/** 
     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 */ 
     124OpenLayers.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 */ 
     139OpenLayers.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/** 
    105147 * APIMethod: transform 
    106  * Read data from a string, and return an object whose type depends on the 
    107  * subclass.  
     148 * Transform a point coordinate from one projection to another.  Note that 
     149 *     the input point is transformed in place. 
    108150 *  
    109151 * 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 
    113156 * 
    114157 * Returns: 
    115  * point - {object} trasnformed coordinate 
     158 * point - {object} A transformed coordinate.  The original point is modified. 
    116159 */ 
    117160OpenLayers.Projection.transform = function(point, source, dest) { 
    118161    if (source.proj && dest.proj) { 
    119162        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);  
    120167    } 
    121168    return point; 
  • sandbox/ahocevar/styles/lib/OpenLayers/Renderer/SVG.js

    r5409 r5432  
    216216                 
    217217                node.setAttributeNS(null, "x", (x + xOffset).toFixed()); 
    218                 node.setAttributeNS(null, "y", (-y + yOffset).toFixed()); 
     218                node.setAttributeNS(null, "y", (y + yOffset).toFixed()); 
    219219                node.setAttributeNS(null, "width", width); 
    220220                node.setAttributeNS(null, "height", height); 
    221221                node.setAttributeNS("http://www.w3.org/1999/xlink", "href", style.externalGraphic); 
    222                 node.setAttributeNS(null, "transform", "scale(1,-1)"); 
    223222                node.setAttributeNS(null, "style", "opacity: "+opacity); 
    224223            } else { 
     
    305304    createRoot: function() { 
    306305        var id = this.container.id + "_root"; 
    307  
    308306        var root = this.nodeFactory(id, "g"); 
    309  
    310         // flip the SVG display Y axis upside down so it  
    311         // matches the display Y axis of the map 
    312         root.setAttributeNS(null, "transform", "scale(1, -1)"); 
    313  
    314307        return root; 
    315308    }, 
     
    345338        var resolution = this.getResolution(); 
    346339        var x = (geometry.x / resolution + this.left); 
    347         var y = (geometry.y / resolution - this.top); 
     340        var y = (this.top - geometry.y / resolution); 
    348341 
    349342        if (this.inValidRange(x, y)) {  
     
    424417        var resolution = this.getResolution(); 
    425418        var x = (geometry.x / resolution + this.left); 
    426         var y = (geometry.y / resolution - this.top); 
     419        var y = (this.top - geometry.y / resolution); 
    427420 
    428421        if (this.inValidRange(x, y)) {  
     
    505498        var resolution = this.getResolution(); 
    506499        var x = (point.x / resolution + this.left); 
    507         var y = (point.y / resolution - this.top); 
     500        var y = (this.top - point.y / resolution); 
    508501 
    509502        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. */ 
    54 
    65/** 
  • 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.txt  
    3  * for the full 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. */ 
    44 
    55 
  • 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.txt  
    3  * for the full 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. */ 
    44 
    55 
  • 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.txt  
    3  * for the full 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. */ 
    44 
    55 
     
    257257    if (typeof value == "string" && value.indexOf("${") != -1) { 
    258258        var attributes = feature.attributes || feature.data; 
    259         // the following line depends on #1133 
    260259        value = OpenLayers.String.format(value, attributes) 
    261260        value = isNaN(value) ? value : parseFloat(value); 
  • sandbox/ahocevar/styles/lib/OpenLayers/Tile/Image.js

    r5316 r5432  
    217217                                 OpenLayers.Function.bind(onload, this)); 
    218218 
     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)); 
    219234    }, 
    220235 
  • sandbox/ahocevar/styles/tests/Layer/test_SphericalMercator.html

    r4221 r5432  
    11<html> 
    22<head> 
    3     <!-- this gmaps key generated for http://openlayers.org/dev/ --> 
    43    <script src="../../lib/OpenLayers.js"></script> 
    54    <script type="text/javascript"> 
    6     function test_SphericalMercator_forwardProject(t) { 
     5    function test_SphericalMercator_forwardMercator(t) { 
    76        t.plan(12); 
    87        var arctic = OpenLayers.Layer.SphericalMercator.forwardMercator(0, 85); 
     
    3332    }  
    3433     
    35     function test_sphericalMercator_inverseProject(t) { 
     34    function test_sphericalMercator_inverseMercator(t) { 
    3635        t.plan(4); 
    3736        var sw =  OpenLayers.Layer.SphericalMercator.inverseMercator(-20037508.34,  -20037508.34); 
     
    4342        t.eq(ne.lat, 85.05112877980660, "Northeast lat correct"); 
    4443    } 
     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