OpenLayers OpenLayers

Changeset 5827

Show
Ignore:
Timestamp:
01/20/08 15:12:48 (1 year ago)
Author:
crschmidt
Message:

Merge with trunk.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/crschmidt/osm/doc/authors.txt

    r5743 r5827  
    1111Pierre Giraud 
    1212Andreas Hocevar 
     13Ian Johnson 
    1314Eric Lemoine 
    1415Philip Lindsay 
  • sandbox/crschmidt/osm/examples/vector-features.html

    r5743 r5827  
    3838            var style_green = { 
    3939                strokeColor: "#00FF00", 
    40                 strokeOpacity: 1, 
    4140                strokeWidth: 3, 
    4241                pointRadius: 6, 
  • sandbox/crschmidt/osm/lib/OpenLayers.js

    r5743 r5827  
    118118            "OpenLayers/Handler.js", 
    119119            "OpenLayers/Handler/Click.js", 
     120            "OpenLayers/Handler/Hover.js", 
    120121            "OpenLayers/Handler/Point.js", 
    121122            "OpenLayers/Handler/Path.js", 
  • sandbox/crschmidt/osm/lib/OpenLayers/Control/ArgParser.js

    r5743 r5827  
    1 /* Cpyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD 
     1/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD 
    22 * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the 
    33 * full text of the license. */ 
  • sandbox/crschmidt/osm/lib/OpenLayers/Control/ZoomBox.js

    r5743 r5827  
    2222 
    2323    /** 
     24     * Property: out 
     25     * {Boolean} Should the control be used for zooming out? 
     26     */ 
     27    out: false, 
     28 
     29    /** 
    2430     * Method: draw 
    2531     */     
     
    3743    zoomBox: function (position) { 
    3844        if (position instanceof OpenLayers.Bounds) { 
    39             var minXY = this.map.getLonLatFromPixel( 
     45            if (!this.out) { 
     46                var minXY = this.map.getLonLatFromPixel( 
    4047                            new OpenLayers.Pixel(position.left, position.bottom)); 
    41             var maxXY = this.map.getLonLatFromPixel( 
     48                var maxXY = this.map.getLonLatFromPixel( 
    4249                            new OpenLayers.Pixel(position.right, position.top)); 
    43             var bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat, 
     50                var bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat, 
    4451                                               maxXY.lon, maxXY.lat); 
     52            } else { 
     53                var pixWidth = Math.abs(position.right-position.left); 
     54                var pixHeight = Math.abs(position.top-position.bottom); 
     55                var zoomFactor = Math.min((this.map.size.h / pixHeight), 
     56                    (this.map.size.w / pixWidth)); 
     57                var extent = map.getExtent(); 
     58                var center = this.map.getLonLatFromPixel( 
     59                    position.getCenterPixel()); 
     60                var xmin = center.lon - (extent.getWidth()/2)*zoomFactor; 
     61                var xmax = center.lon + (extent.getWidth()/2)*zoomFactor; 
     62                var ymin = center.lat - (extent.getHeight()/2)*zoomFactor; 
     63                var ymax = center.lat + (extent.getHeight()/2)*zoomFactor; 
     64                var bounds = new OpenLayers.Bounds(xmin, ymin, xmax, ymax); 
     65            } 
    4566            this.map.zoomToExtent(bounds); 
    4667        } else { // it's a pixel 
    47             this.map.setCenter(this.map.getLonLatFromPixel(position), 
     68            if (!this.out) { 
     69                this.map.setCenter(this.map.getLonLatFromPixel(position), 
    4870                               this.map.getZoom() + 1); 
     71            } else { 
     72                this.map.setCenter(this.map.getLonLatFromPixel(position), 
     73                               this.map.getZoom() - 1); 
     74            } 
    4975        } 
    5076    }, 
  • sandbox/crschmidt/osm/lib/OpenLayers/Layer.js

    r5743 r5827  
    625625        } 
    626626 
     627        // Do not use the scales/resolutions at the map level if 
     628        // minScale/minResolution and maxScale/maxResolution are 
     629        // specified at the layer level 
     630        if (this.options.minScale != null && 
     631            this.options.maxScale != null && 
     632            this.options.scales == null) { 
     633            confProps.scales = null; 
     634        } 
     635        if (this.options.minResolution != null && 
     636            this.options.maxResolution != null && 
     637            this.options.resolutions == null) { 
     638            confProps.resolutions = null; 
     639        } 
     640 
    627641        // If numZoomLevels hasn't been set and the maxZoomLevel *has*,  
    628642        //  then use maxZoomLevel to calculate numZoomLevels 
  • sandbox/crschmidt/osm/lib/OpenLayers/Layer/GML.js

    r5743 r5827  
    9898        }     
    9999    },     
    100          
     100     
     101    /** 
     102     * Method: setUrl 
     103     * Change the URL and reload the GML 
     104     * 
     105     * Parameters: 
     106     * url - {String} URL of a GML file. 
     107     */ 
     108    setUrl:function(url) { 
     109        this.url = url; 
     110        this.destroyFeatures(); 
     111        this.loaded = false; 
     112        this.events.triggerEvent("loadstart"); 
     113        this.loadGML(); 
     114    }, 
    101115     
    102116    /** 
  • sandbox/crschmidt/osm/lib/OpenLayers/Layer/SphericalMercator.js

    r5743 r5827  
    129129     
    130130    /** 
    131      * Method: projectForward  
     131     * Method: projectInverse 
    132132     * Given an object with x and y properties in Spherical Mercator, modify 
    133133     * the x,y properties on the object to be the unprojected coordinates. 
  • sandbox/crschmidt/osm/lib/OpenLayers/Layer/TileCache.js

    r5743 r5827  
    104104        var bbox = this.maxExtent; 
    105105        var size = this.tileSize; 
    106         var tileX = Math.floor((bounds.left - bbox.left) / (res * size.w)); 
    107         var tileY = Math.floor((bounds.bottom - bbox.bottom) / (res * size.h)); 
     106        var tileX = Math.round((bounds.left - bbox.left) / (res * size.w)); 
     107        var tileY = Math.round((bounds.bottom - bbox.bottom) / (res * size.h)); 
    108108        var tileZ = this.map.zoom; 
    109109        /** 
  • sandbox/crschmidt/osm/lib/OpenLayers/Projection.js

    r5743 r5827  
    9090     */ 
    9191    equals: function(projection) { 
    92         return this.getCode() == projection.getCode(); 
     92        if (projection && projection.getCode) { 
     93            return this.getCode() == projection.getCode(); 
     94        } else { 
     95            return false; 
     96        }     
    9397    }, 
    9498 
  • sandbox/crschmidt/osm/lib/OpenLayers/Renderer/Elements.js

    r5743 r5827  
    135135            //now actually draw the node, and style it 
    136136            node = this.drawGeometryNode(node, geometry); 
    137             this.root.appendChild(node); 
     137             
     138            // append the node to root (but only if it's new) 
     139            if (node.parentNode != this.root) {  
     140                this.root.appendChild(node);  
     141            } 
    138142            this.postDraw(node); 
    139143        } else { 
  • sandbox/crschmidt/osm/lib/OpenLayers/Renderer/SVG.js

    r5749 r5827  
    337337            node.setAttributeNS(null, "r", radius); 
    338338        } else { 
    339             if (node.parentNode) { 
     339            if (node.parentNode == this.root) { 
    340340                this.root.removeChild(node); 
    341             }     
     341            } 
    342342        }     
    343343    }, 
  • sandbox/crschmidt/osm/lib/OpenLayers/Renderer/VML.js

    r5743 r5827  
    241241                node.appendChild(stroke); 
    242242            } 
    243             stroke.setAttribute("opacity", style.strokeOpacity); 
     243            if (style.strokeOpacity) { 
     244                stroke.setAttribute("opacity", style.strokeOpacity); 
     245            } 
    244246            stroke.setAttribute("endcap", !style.strokeLinecap || style.strokeLinecap == 'butt' ? 'flat' : style.strokeLinecap); 
    245247        } 
  • sandbox/crschmidt/osm/lib/OpenLayers/Tile/WFS.js

    r5743 r5827  
    6868        if(this.request) { 
    6969            this.request.transport.abort(); 
     70            //this.request.destroy(); 
     71            this.request = null; 
    7072        } 
    7173    }, 
     
    109111    */ 
    110112    loadFeaturesForRegion:function(success, failure) { 
     113        if(this.request) { 
     114            this.request.transport.abort(); 
     115            //this.request.destroy(); 
     116        } 
    111117        this.request = OpenLayers.loadURL(this.url, null, this, success); 
    112118    }, 
     
    142148            this.events.triggerEvent("loadend");  
    143149        } 
     150 
     151        //request produced with success, we can delete the request object. 
     152        //this.request.destroy(); 
     153        this.request = null; 
    144154    }, 
    145155 
  • sandbox/crschmidt/osm/tests/Layer/test_GML.html

    r4252 r5827  
    77     
    88    var gml = "./owls.xml"; 
     9    var gml2 = "./mice.xml"; 
    910 
    1011    // if this test is running online, different rules apply 
     
    4142 
    4243    } 
     44    function test_GML_setUrl(t) { 
     45        t.plan(2); 
     46        var layer = new OpenLayers.Layer.GML(name, gml); 
     47        var map = new OpenLayers.Map("map"); 
     48        map.addLayer(layer); 
     49        t.eq(layer.url, gml, "layer has correct original url"); 
     50        layer.setUrl(gml2); 
     51        t.eq(layer.url, gml2, "layer has correctly changed url"); 
     52    } 
    4353  </script> 
    4454</head> 
  • sandbox/crschmidt/osm/tests/Renderer/test_SVG.html

    r5743 r5827  
    128128        } 
    129129         
    130         t.plan(3); 
     130        t.plan(6); 
    131131         
    132132        var r = new OpenLayers.Renderer.SVG(document.body); 
     
    143143         
    144144        r.drawCircle(node, geometry, 3); 
     145         
     146        t.eq(node.getAttributeNS(null, 'cx'), '2', "cx is correct"); 
     147        t.eq(node.getAttributeNS(null, 'cy'), '-4', "cy is correct"); 
     148        t.eq(node.getAttributeNS(null, 'r'), '3', "r is correct"); 
     149        
     150        // #1274: out of bound node fails when first added 
     151        var geometry = { 
     152            x: 10000000, 
     153            y: 200000000 
     154        } 
     155         
     156        r.drawCircle(node, geometry, "blah_4000"); 
    145157         
    146158        t.eq(node.getAttributeNS(null, 'cx'), '2', "cx is correct"); 
  • sandbox/crschmidt/osm/tests/Tile/test_WFS.html

    r5743 r5827  
    2828 
    2929    function test_Tile_WFS_requestSuccess(t) { 
    30         t.plan(1); 
     30        t.plan(2); 
     31 
     32        var tile = { 
     33            'request': {} 
     34        }; 
     35             
     36        OpenLayers.Tile.WFS.prototype.requestSuccess.apply(tile, []); 
     37         
     38        t.ok(tile.request == null, "request property on tile set to null"); 
     39 
    3140        var layer = {}; // bogus layer 
    3241        var position = new OpenLayers.Pixel(10,20); 
     
    4251    } 
    4352     
     53    function test_Tile_WFS_loadFeaturesForRegion(t) { 
     54        t.plan(9); 
     55         
     56        var tile = { 
     57            'url': {} 
     58        }; 
     59 
     60        var g_Success = {};      
     61 
     62        var tLoadURL = OpenLayers.loadURL; 
     63        OpenLayers.loadURL = function(url, params, caller, onComplete) { 
     64            t.ok(url == tile.url, "tile's url correctly passed as 1st param to loadURL"); 
     65            t.ok(params == null, "null passed as 2nd param to loadURL"); 
     66            t.ok(caller == tile, "tile passed as 3rd param to loadURL"); 
     67            t.ok(onComplete == g_Success, "success param from loadFeaturesForRegion() passed as 4th param to loadURL"); 
     68        }; 
     69         
     70      //no running request -- 4 tests 
     71        OpenLayers.Tile.WFS.prototype.loadFeaturesForRegion.apply(tile, [g_Success]); 
     72 
     73      //running request (cancelled) -- 4 tests + 1 test (for request abort) 
     74        tile.request = { 
     75            'transport': { 
     76                'abort': function() { 
     77                    t.ok(true, "request aborted"); 
     78                } 
     79            } 
     80        }; 
     81        OpenLayers.Tile.WFS.prototype.loadFeaturesForRegion.apply(tile, [g_Success]); 
     82                 
     83        OpenLayers.loadURL = tLoadURL; 
     84    } 
     85     
    4486    function test_Tile_WFS_destroy(t) { 
    45         t.plan(8); 
     87        t.plan(9); 
    4688 
    4789        var layer = {}; // bogus layer 
     
    74116        t.ok(tile.position == null, "tile.position set to null"); 
    75117        t.ok(_gAbort, "request transport is aborted"); 
     118        t.ok(tile.request == null, "tile.request set to null"); 
    76119         
    77120        t.ok(tile.events == null, "tile.events set to null"); 
  • sandbox/crschmidt/osm/tests/list-tests.html

    r5816 r5827  
    9090    <li>test_Handler.html</li> 
    9191    <li>Handler/test_Click.html</li> 
     92    <li>Handler/test_Hover.html</li> 
    9293    <li>Handler/test_Drag.html</li> 
    9394    <li>Handler/test_Feature.html</li> 
  • sandbox/crschmidt/osm/tests/run-tests.html

    r5743 r5827  
    799799{ 
    800800    var test_page=Test.AnotherWay._g_tests_queue[0]; 
    801     test_page.loading_timeout_milliseconds=6000; 
     801    test_page.loading_timeout_milliseconds=12000; 
    802802    test_page.timeout_id=setTimeout( Test.AnotherWay._loading_timeout, Test.AnotherWay._g_timeout_granularity ); 
    803803    test_page.wait_msg=Test.AnotherWay._print_counter_result( test_page.url, "loading...", test_page.loading_timeout_milliseconds, "loading" ); 
  • sandbox/crschmidt/osm/tests/test_Projection.html

    r5743 r5827  
    1919         t.eq(out.x, 10, "Null transform has no effect");  
    2020         t.eq(out.y, 12, "Null transform has no effect");  
     21 
     22         t.eq(projection.equals(null), false, "equals on null projection returns false"); 
     23         t.eq(projection.equals({}), false, "equals on null projection object returns false (doesn't call getCode)"); 
    2124     }  
    2225