OpenLayers OpenLayers

Ticket #821: patch-821-r5408-B0.diff

File patch-821-r5408-B0.diff, 3.7 kB (added by pgiraud, 1 year ago)

same patch as Apoint.x with tests

  • tests/Renderer/test_SVG.html

    old new  
    144144        r.drawCircle(node, geometry, 3); 
    145145         
    146146        t.eq(node.getAttributeNS(null, 'cx'), '2', "cx is correct"); 
    147         t.eq(node.getAttributeNS(null, 'cy'), '4', "cy is correct"); 
     147        t.eq(node.getAttributeNS(null, 'cy'), '-4', "cy is correct"); 
    148148        t.eq(node.getAttributeNS(null, 'r'), '3', "r is correct"); 
    149149    } 
    150150     
     
    271271        r.drawRectangle(node, geometry); 
    272272         
    273273        t.eq(node.getAttributeNS(null, "x"), "2", "x attribute is correctly set"); 
    274         t.eq(node.getAttributeNS(null, "y"), "4", "y attribute is correctly set"); 
     274        t.eq(node.getAttributeNS(null, "y"), "-4", "y attribute is correctly set"); 
    275275        t.eq(node.getAttributeNS(null, "width"), "6", "width attribute is correctly set"); 
    276276        t.eq(node.getAttributeNS(null, "height"), "8", "height attribute is correctly set"); 
    277277    } 
     
    355355        }; 
    356356         
    357357        var string = r.getShortString(point); 
    358         t.eq(string, "2,4", "returned string is correct"); 
     358        t.eq(string, "2,-4", "returned string is correct"); 
    359359    } 
    360360     
    361361     
  • lib/OpenLayers/Renderer/SVG.js

    old new  
    215215                var opacity = style.graphicOpacity || style.fillOpacity; 
    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 { 
    225224                node.setAttributeNS(null, "r", style.pointRadius); 
     
    304303     */ 
    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    }, 
    316309 
     
    344337    drawCircle: function(node, geometry, radius) { 
    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)) {  
    350343            node.setAttributeNS(null, "cx", x); 
     
    423416    drawRectangle: function(node, geometry) { 
    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)) {  
    429422            node.setAttributeNS(null, "x", x); 
     
    504497    getShortString: function(point) { 
    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)) {  
    510503            return x + "," + y;