Changeset 541

Show
Ignore:
Timestamp:
04/05/08 20:39:38 (8 months ago)
Author:
tom
Message:

fixed oops in Location in tweenbranch, added a couple of optimizations to TileGrid

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/tom-tweenlite/lib/com/modestmaps/core/TileGrid.as

    r536 r541  
    245245 
    246246                        // find the extents of the ur-tile: 
     247                        // (where would the top left and bottom right corners of the  
     248                        //  world be now if we only had one tile at zoom level 0?) 
    247249                        var worldMin:Point = worldMatrix.transformPoint(new Point(0,0)); 
    248250                        var worldMax:Point = worldMatrix.transformPoint(new Point(TILE_WIDTH,TILE_HEIGHT)); 
    249251 
    250                         // 0 when scale == 1, 1 when scale == 2, 2 when scale == 4, etc. 
     252                        // what zoom level of tiles should we be loading, taking into account min/max zoom? 
     253                        // (0 when scale == 1, 1 when scale == 2, 2 when scale == 4, etc.) 
    251254                        var newZoom:int = Math.min(maxZoom, Math.max(minZoom, Math.round(zoomLevel))); 
    252255                         
     256                        // see if the newZoom is different to currentZoom 
    253257                        // so we know which way we're zooming, if any: 
    254258                        if (currentZoom != newZoom) { 
     
    264268                        var numRows:int = numCols; // TODO deal with what happens with non-square projections! 
    265269                                         
    266                         // map size: 
    267                         var screenMin:Point = new Point(0,0); 
    268                         var screenMax:Point = new Point(mapWidth, mapHeight); 
    269                          
     270                        // find start and end columns for the visible tiles: 
    270271                        var realMinCol:Number = numCols * (-worldMin.x) / (worldMax.x-worldMin.x); 
    271272                        var realMaxCol:Number = numCols * (mapWidth-worldMin.x) / (worldMax.x-worldMin.x); 
     
    273274                        var realMaxRow:Number = numRows * (mapHeight-worldMin.y) / (worldMax.y-worldMin.y); 
    274275                         
    275                         // find start and end columns 
     276                        // round these up or down to pad things out a bit 
    276277                        var minCol:int = Math.floor(realMinCol); 
    277278                        var maxCol:int = Math.ceil(realMaxCol); 
     
    279280                        var maxRow:int = Math.ceil(realMaxRow); 
    280281                                         
    281                         // pad it out a little bit 
     282                        // optionally pad it out a little bit more 
    282283                        // TODO: investigate giving a directional bias to TILE_BUFFER when panning quickly 
    283284                        minCol -= TILE_BUFFER; 
     
    292293                        var tile:Tile; 
    293294                        var key:String; 
     295                        var coord:Coordinate = new Coordinate(0,0,0); 
    294296 
    295297                        // loop over currently visible tiles 
     
    308310                                                if (!tile) { 
    309311                                                        tile = map.createTile(col, row, currentZoom); 
    310                                                         childrenNeeded[tile] = provider.getTileUrls(new Coordinate(tile.row, tile.column, tile.zoom)).length; 
     312                                                        coord.row = tile.row; 
     313                                                        coord.column = tile.column; 
     314                                                        coord.zoom = tile.zoom; 
     315                                                        // TODO keep a local copy of the URLs so we don't have to call this twice?  
     316                                                        childrenNeeded[tile] = provider.getTileUrls(coord).length; 
    311317                                                        queue.push(tile); 
    312318                                                } 
     
    483489                         
    484490                        // process the queue 
     491                        var coord:Coordinate = new Coordinate(0,0,0); 
    485492                        while (openRequests.length < MAX_OPEN_REQUESTS && queue.length > 0) { 
    486493                                var tile:Tile = queue.shift() as Tile; 
     494                                coord.row = tile.row; 
     495                                coord.column = tile.column; 
     496                                coord.zoom = tile.zoom; 
    487497                                // if it's still on the stage: 
    488498                                if (tile.parent) { 
    489499                                        // TODO: add urls to Tile? 
    490                                         var urls:Array = provider.getTileUrls(new Coordinate(tile.row, tile.column, tile.zoom)); 
     500                                        var urls:Array = provider.getTileUrls(coord); 
    491501                                        var url:String = urls.shift() as String; 
    492502                                        var tileLoader:Loader = new Loader();  
  • branches/tom-tweenlite/lib/com/modestmaps/geo/Location.as

    r540 r541  
    1111            public var lon:Number; 
    1212         
    13                 public static function fromString(str:String, lonlat:Boolean=true):Location 
     13                public static function fromString(str:String, lonlat:Boolean=false):Location 
    1414                { 
    1515                        var parts:Array = str.split(/\s*,\s*/, 2);