Changeset 121

Show
Ignore:
Timestamp:
02/17/07 16:56:57 (2 years ago)
Author:
migurski
Message:

Added IMapProvider.sourceCoordinate() for cylindrical projection panning (ticket:11)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/as2/lib/com/modestmaps/core/MarkerSet.as

    r99 r121  
    7777        var names:Array = []; 
    7878        var touched:/*Marker*/Array = []; 
     79        var sourceCoord:Coordinate; 
    7980         
    80         for(var i:Number = 0; i < tiles.length; i += 1) 
    81             if(tileMarkers[tiles[i].coord.toString()] != undefined) 
    82                 for(var markerName:String in tileMarkers[tiles[i].coord.toString()]) { 
     81        for(var i:Number = 0; i < tiles.length; i += 1) { 
     82            sourceCoord = grid.mapProvider.sourceCoordinate(tiles[i].coord); 
     83         
     84            if(tileMarkers[sourceCoord.toString()] != undefined) 
     85                for(var markerName:String in tileMarkers[sourceCoord.toString()]) { 
    8386                    names.push(markerName); 
    8487                    touched.push(markers[markerName]); 
    8588                } 
     89        } 
    8690         
    8791        //grid.log('Touched markers: '+names.toString()); 
  • trunk/as2/lib/com/modestmaps/mapproviders/AbstractMapProvider.as

    r95 r121  
    6262        return __projection.toString(); 
    6363        } 
     64 
     65    public function sourceCoordinate(coord:Coordinate):Coordinate 
     66    { 
     67        return coord; 
     68    } 
    6469 
    6570   /* 
  • trunk/as2/lib/com/modestmaps/mapproviders/BlueMarbleMapProvider.as

    r119 r121  
    3535    private function getTileUrl(coord:Coordinate):String 
    3636    { 
    37         return 'http://s3.amazonaws.com/com.modestmaps.bluemarble/'+(coord.zoom)+'-r'+(coord.row)+'-c'+(coord.column)+'.jpg'; 
     37        var sourceCoord:Coordinate = sourceCoordinate(coord); 
     38        return 'http://s3.amazonaws.com/com.modestmaps.bluemarble/'+(sourceCoord.zoom)+'-r'+(sourceCoord.row)+'-c'+(sourceCoord.column)+'.jpg'; 
     39    } 
     40 
     41    public function sourceCoordinate(coord:Coordinate):Coordinate 
     42    { 
     43            var wrappedColumn:Number = coord.column % Math.pow(2, coord.zoom); 
     44 
     45            while(wrappedColumn < 0) 
     46                wrappedColumn += Math.pow(2, coord.zoom); 
     47                 
     48        return new Coordinate(coord.row, wrappedColumn, coord.zoom); 
    3849    } 
    3950} 
  • trunk/as2/lib/com/modestmaps/mapproviders/google/AbstractGoogleMapProvider.as

    r99 r121  
    2929        __bottomRightInLimit = (new Coordinate(1, Number.POSITIVE_INFINITY, 0)).zoomTo(Coordinate.MAX_ZOOM); 
    3030        } 
     31 
     32    public function sourceCoordinate(coord:Coordinate):Coordinate 
     33    { 
     34            var wrappedColumn:Number = coord.column % Math.pow(2, coord.zoom); 
     35 
     36            while(wrappedColumn < 0) 
     37                wrappedColumn += Math.pow(2, coord.zoom); 
     38                 
     39        return new Coordinate(coord.row, wrappedColumn, coord.zoom); 
     40    } 
    3141} 
  • trunk/as2/lib/com/modestmaps/mapproviders/google/GoogleAerialMapProvider.as

    r114 r121  
    2020        public function getTileUrl( coord : Coordinate ) : String 
    2121        { 
    22                 return "http://kh" + Math.floor(Math.random() * 4) + ".google.com/kh?n=404&v=17&t=" + getZoomString(coord); 
     22                return "http://kh" + Math.floor(Math.random() * 4) + ".google.com/kh?n=404&v=17&t=" + getZoomString(sourceCoordinate(coord)); 
    2323        } 
    2424         
  • trunk/as2/lib/com/modestmaps/mapproviders/google/GoogleHybridMapProvider.as

    r114 r121  
    5353        } 
    5454 
    55         private function getOverlayTileUrl( coord : Coordinate ) : String 
     55        private function getOverlayTileUrl(coord:Coordinate):String 
    5656        {                
    57                 var zoomString : String = "&x=" + coord.column + "&y=" + coord.row + "&zoom=" + ( 17 - coord.zoom ); 
    58                 return "http://mt" + Math.floor(Math.random() * 4) + ".google.com/mt?n=404&v=w2t.39" + zoomString;       
     57        var sourceCoord:Coordinate = sourceCoordinate(coord); 
     58        var zoomString:String = "&x=" + sourceCoord.column + "&y=" + sourceCoord.row + "&zoom=" + (17 - sourceCoord.zoom); 
     59                return "http://mt" + Math.floor(Math.random() * 4) + ".google.com/mt?n=404&v=w2t.39" + zoomString; 
    5960        } 
    60  
    6161 
    6262        // Event Handlers 
  • trunk/as2/lib/com/modestmaps/mapproviders/google/GoogleRoadMapProvider.as

    r114 r121  
    1919        private function getTileUrl( coord : Coordinate ) : String 
    2020        {                
    21                 return "http://mt" + Math.floor(Math.random() * 4) + ".google.com/mt?n=404&v=w2.39" + getZoomString( coord );          
     21                return "http://mt" + Math.floor(Math.random() * 4) + ".google.com/mt?n=404&v=w2.39" + getZoomString(sourceCoordinate(coord));          
    2222        } 
    2323         
    2424        private function getZoomString( coord : Coordinate ) : String 
    25         {                
    26                 var zoomString : String = "&x=" + coord.column + "&y=" + coord.row + "&zoom=" + ( 17 - coord.zoom ); 
    27                 return zoomString;  
     25        { 
     26        return "&x=" + coord.column + "&y=" + coord.row + "&zoom=" + (17 - coord.zoom); 
    2827        }        
    2928} 
  • trunk/as2/lib/com/modestmaps/mapproviders/IMapProvider.as

    r97 r121  
    3131     
    3232    public function toString() : String; 
     33     
     34   /* 
     35    * Munge coordinate for purposes of image selection and marker containment. 
     36    * E.g., useful for cylindical projections with infinite horizontal scroll. 
     37    */ 
     38    public function sourceCoordinate(coord:Coordinate):Coordinate; 
    3339} 
  • trunk/as2/lib/com/modestmaps/mapproviders/microsoft/AbstractMicrosoftMapProvider.as

    r99 r121  
    2525        } 
    2626         
    27         private function getZoomString( coord : Coordinate ) : String 
    28         {                
     27        private function getZoomString(coord:Coordinate):String 
     28        { 
     29        var sourceCoord:Coordinate = sourceCoordinate(coord); 
     30             
    2931                // convert row + col to zoom string 
    30                 var rowBinaryString : String = BinaryUtil.convertToBinary( coord.row );                
    31                 rowBinaryString = rowBinaryString.substring( rowBinaryString.length - coord.zoom ); 
     32                var rowBinaryString : String = BinaryUtil.convertToBinary(sourceCoord.row);            
     33                rowBinaryString = rowBinaryString.substring(rowBinaryString.length - sourceCoord.zoom); 
    3234                 
    33                 var colBinaryString : String = BinaryUtil.convertToBinary( coord.column ); 
    34                 colBinaryString = colBinaryString.substring( colBinaryString.length - coord.zoom ); 
     35                var colBinaryString : String = BinaryUtil.convertToBinary(sourceCoord.column); 
     36                colBinaryString = colBinaryString.substring(colBinaryString.length - sourceCoord.zoom); 
    3537 
    3638                // generate zoom string by combining strings 
    3739                var zoomString : String = ""; 
    38                 for ( var i : Number = 0; i < coord.zoom; i++ )  
    39                 { 
     40 
     41                for(var i:Number = 0; i < sourceCoord.zoom; i += 1) 
    4042                        zoomString += BinaryUtil.convertToDecimal( rowBinaryString.charAt( i ) + colBinaryString.charAt( i ) ).toString(); 
    41                 } 
    4243                 
    4344                return zoomString;  
    4445        } 
     46 
     47    public function sourceCoordinate(coord:Coordinate):Coordinate 
     48    { 
     49            var wrappedColumn:Number = coord.column % Math.pow(2, coord.zoom); 
     50 
     51            while(wrappedColumn < 0) 
     52                wrappedColumn += Math.pow(2, coord.zoom); 
     53                 
     54        return new Coordinate(coord.row, wrappedColumn, coord.zoom); 
     55    } 
    4556} 
  • trunk/as2/lib/com/modestmaps/mapproviders/OpenStreetMapProvider.as

    r119 r121  
    3535    private function getTileUrl(coord:Coordinate):String 
    3636    { 
    37         return 'http://tile.openstreetmap.org/'+(coord.zoom)+'/'+(coord.column)+'/'+(coord.row)+'.png'; 
     37        var sourceCoord:Coordinate = sourceCoordinate(coord); 
     38        return 'http://tile.openstreetmap.org/'+(sourceCoord.zoom)+'/'+(sourceCoord.column)+'/'+(sourceCoord.row)+'.png'; 
     39    } 
     40 
     41    public function sourceCoordinate(coord:Coordinate):Coordinate 
     42    { 
     43            var wrappedColumn:Number = coord.column % Math.pow(2, coord.zoom); 
     44 
     45            while(wrappedColumn < 0) 
     46                wrappedColumn += Math.pow(2, coord.zoom); 
     47                 
     48        return new Coordinate(coord.row, wrappedColumn, coord.zoom); 
    3849    } 
    3950} 
  • trunk/as2/lib/com/modestmaps/mapproviders/yahoo/AbstractYahooMapProvider.as

    r100 r121  
    2424        __bottomRightInLimit = (new Coordinate(1, Number.POSITIVE_INFINITY, 0)).zoomTo(Coordinate.MAX_ZOOM); 
    2525        } 
     26 
     27    public function sourceCoordinate(coord:Coordinate):Coordinate 
     28    { 
     29            var wrappedColumn:Number = coord.column % Math.pow(2, coord.zoom); 
     30 
     31            while(wrappedColumn < 0) 
     32                wrappedColumn += Math.pow(2, coord.zoom); 
     33                 
     34        return new Coordinate(coord.row, wrappedColumn, coord.zoom); 
     35    } 
    2636} 
  • trunk/as2/lib/com/modestmaps/mapproviders/yahoo/YahooAerialMapProvider.as

    r100 r121  
    1616        } 
    1717 
    18         private function getTileUrl( coord : Coordinate ) : String 
     18        private function getTileUrl(coord:Coordinate):String 
    1919        {                
    20                 var url : String = "http://us.maps3.yimg.com/aerial.maps.yimg.com/img?md=200605101500"  
    21                         + getZoomString( coord );        
    22                          
    23                 return url;  
     20        return "http://us.maps3.yimg.com/aerial.maps.yimg.com/img?md=200605101500" + getZoomString(sourceCoordinate(coord));     
    2421        } 
    2522         
  • trunk/as2/lib/com/modestmaps/mapproviders/yahoo/YahooHybridMapProvider.as

    r102 r121  
    3838        }        
    3939 
    40         private function getBGTileUrl( coord : Coordinate ) : String 
     40        private function getBGTileUrl(coord:Coordinate):String 
    4141        {                
    42                 var url : String = "http://us.maps3.yimg.com/aerial.maps.yimg.com/img?md=200605101500"  
    43                         + getZoomString( coord ) + "&v=1.5&t=a";         
    44                          
    45                 return url;  
     42                return "http://us.maps3.yimg.com/aerial.maps.yimg.com/img?md=200605101500" + getZoomString(sourceCoordinate(coord)) + "&v=1.5&t=a"; 
    4643        } 
    4744 
    48         private function getOverlayTileUrl( coord : Coordinate ) : String 
     45        private function getOverlayTileUrl(coord:Coordinate):String 
    4946        {                
    50                 var url : String = "http://us.maps3.yimg.com/aerial.maps.yimg.com/img?md=200608221700&v=2.0&t=h"  
    51                         + getZoomString( coord );        
    52                          
    53                 return url;  
     47        return "http://us.maps3.yimg.com/aerial.maps.yimg.com/img?md=200608221700&v=2.0&t=h" + getZoomString(sourceCoordinate(coord)); 
    5448        } 
    5549         
  • trunk/as2/lib/com/modestmaps/mapproviders/yahoo/YahooRoadMapProvider.as

    r101 r121  
    1717        } 
    1818 
    19         private function getTileUrl( coord : Coordinate ) : String 
     19        private function getTileUrl(coord:Coordinate):String 
    2020        {                
    21                 var url : String = "http://us.maps1.yimg.com/us.tile.maps.yimg.com/tile?md=200608221700"  
    22                         + getZoomString( coord );        
    23                          
    24                 return url;  
     21        return "http://us.maps1.yimg.com/us.tile.maps.yimg.com/tile?md=200608221700" + getZoomString(sourceCoordinate(coord));   
    2522        } 
    2623