OpenLayers OpenLayers

Changeset 5430

Show
Ignore:
Timestamp:
12/15/07 11:24:31 (1 year ago)
Author:
crschmidt
Message:

Don't flip SVG Y values anymore, since we're working in pixel space these days,
and the Y transforms just make working with the SVG directly -- for example,
with people modifying it to support text -- more difficult than it should be.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Renderer/SVG.js

    r5373 r5430  
    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)) {  
  • trunk/openlayers/tests/Renderer/test_SVG.html

    r5340 r5430  
    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    } 
     
    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"); 
     
    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