Changeset 99

Show
Ignore:
Timestamp:
02/07/07 02:17:31 (2 years ago)
Author:
darren
Message:

refactored MapProvider? throttled requests to use MapProviderPaintThrottledRequest?, which enabled removal of all getCoordinateFromUrl methods.

Files:

Legend:

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

    r96 r99  
    7070        */ 
    7171         
    72         grid.log('Marker '+markerName+' in '+tileKey); 
     72        //grid.log('Marker '+markerName+' in '+tileKey); 
    7373    } 
    7474     
     
    8585                } 
    8686         
    87         grid.log('Touched markers: '+names.toString()); 
     87        //grid.log('Touched markers: '+names.toString()); 
    8888        return touched; 
    8989    } 
  • trunk/as2/lib/com/modestmaps/core/TilePaintCall.as

    r87 r99  
    2222    public function toString():String 
    2323    { 
    24         return __mapProvider.toString() + ', ' + __tileCoord.toString(); 
     24        return __mapProvider.toString() + ', ' + __tileCoord.toString();  
    2525    } 
    2626     
  • trunk/as2/lib/com/modestmaps/geo/IProjection.as

    r59 r99  
    2424    */ 
    2525    public function coordinateLocation(coordinate:Coordinate):Location; 
     26     
     27    public function toString():String; 
    2628} 
  • trunk/as2/lib/com/modestmaps/mapproviders/AbstractImageBasedMapProvider.as

    r97 r99  
    33import com.modestmaps.io.LoadMovieThrottledRequest; 
    44import mx.utils.Delegate; 
     5import com.modestmaps.io.MapProviderPaintThrottledRequest; 
    56 
    67/** 
     
    1920                super.paint( clip, coord ); 
    2021                 
    21                 var request : LoadMovieThrottledRequest = new LoadMovieThrottledRequest( clip.image, getTileUrl( coord ) ); 
    22                 request.addEventListener( LoadMovieThrottledRequest.EVENT_REQUEST_ERROR, Delegate.create( this, this.onRequestError )); 
    23                 request.addEventListener( LoadMovieThrottledRequest.EVENT_RESPONSE_COMPLETE, Delegate.create( this, this.onResponseComplete )); 
    24                 request.addEventListener( LoadMovieThrottledRequest.EVENT_RESPONSE_ERROR, Delegate.create( this, this.onResponseError )); 
     22                var request : MapProviderPaintThrottledRequest = new MapProviderPaintThrottledRequest( clip.image, getTileUrl( coord ), coord ); 
     23                request.addEventListener( MapProviderPaintThrottledRequest.EVENT_REQUEST_ERROR, Delegate.create( this, this.onRequestError )); 
     24                request.addEventListener( MapProviderPaintThrottledRequest.EVENT_RESPONSE_COMPLETE, Delegate.create( this, this.onResponseComplete )); 
     25                request.addEventListener( MapProviderPaintThrottledRequest.EVENT_RESPONSE_ERROR, Delegate.create( this, this.onResponseError )); 
    2526                request.send(); 
    2627                 
     
    7374        private function onResponseComplete( eventObj : Object ) : Void 
    7475        { 
    75                 var clip : MovieClip = MovieClip( eventObj.clip ); 
    76                 var url : String = String( eventObj.url ); 
    77                  
    78                 raisePaintComplete( clip, getCoordinateFromURL( url ) ); 
     76                raisePaintComplete( eventObj.clip, eventObj.coord ); 
    7977        } 
    8078         
  • trunk/as2/lib/com/modestmaps/mapproviders/google/AbstractGoogleMapProvider.as

    r97 r99  
    2929        __bottomRightInLimit = (new Coordinate(1, Number.POSITIVE_INFINITY, 0)).zoomTo(Coordinate.MAX_ZOOM); 
    3030        } 
    31          
    32          
    33  
    3431} 
  • trunk/as2/lib/com/modestmaps/mapproviders/google/GoogleAerialMapProvider.as

    r98 r99  
    1313implements IMapProvider, IDispatchable  
    1414{ 
    15         private static var BASE_URL : String = "http://kh0.google.com/kh?n=404&v=14&t="; 
    16         private static var ASSET_EXTENSION : String = ""; 
    17  
    1815        public function toString() : String 
    1916        { 
     
    2118        } 
    2219 
    23         public function get baseUrl() : String 
    24         { 
    25                 return BASE_URL;         
    26         } 
    27  
    28         public function get assetExtension() : String 
    29         { 
    30                 return ASSET_EXTENSION;  
    31         } 
    32                          
    3320        private function getTileUrl( coord : Coordinate ) : String 
    3421        { 
    35                 var url:String = BASE_URL + getZoomString(coord); 
    36                  
    37                 _level0.map.grid.log(this + ": Mapped " + coord.toString() + " to URL: " + url); 
    38                  
    39                 return url;  
     22                return "http://kh0.google.com/kh?n=404&v=14&t=" + getZoomString(coord);          
    4023        } 
    4124         
     
    6245                return zoomString;  
    6346        } 
    64          
    65         /* 
    66          * Given a URL, returns the coordinates that the URL refers to. 
    67          */ 
    68         private function getCoordinateFromURL( url : String ) : Coordinate 
    69         { 
    70                 var row, col, zoom : Number; 
    71                  
    72                 // first locate the meaty bits (i.e. the zoomString). 
    73                 var zoombits : Array = url.split( "&" ); 
    74                  
    75                 col = parseInt( zoombits[2].split( '=' )[1] );  
    76                 row = parseInt( zoombits[3].split( '=' )[1] );  
    77                 zoom = parseInt( zoombits[4].split( '=' )[1] );  
    78                          
    79                 var coord : Coordinate = new Coordinate( row, col, zoom ); 
    80                 return coord; 
    81         } 
    8247} 
  • trunk/as2/lib/com/modestmaps/mapproviders/google/GoogleRoadMapProvider.as

    r97 r99  
    1212implements IMapProvider, IDispatchable  
    1313{ 
    14         private static var BASE_URL : String = "http://mt1.google.com/mt?n=404&v=w2.38"; 
    15         private static var ASSET_EXTENSION : String = ""; 
    16  
    1714        public function toString() : String 
    1815        { 
     
    3229        private function getTileUrl( coord : Coordinate ) : String 
    3330        {                
    34                 var url : String = BASE_URL + getZoomString( coord );          
     31                var url : String = "http://mt1.google.com/mt?n=404&v=w2.38" + getZoomString( coord );          
    3532                return url;  
    3633        } 
     
    4138                return zoomString;  
    4239        }        
    43  
    44          
    45         /* 
    46          * Given a URL, returns the coordinates that the URL refers to. 
    47          */ 
    48         private function getCoordinateFromURL( url : String ) : Coordinate 
    49         { 
    50                 var row, col, zoom : Number; 
    51                  
    52                 var zoombits : Array = url.split( "&" ); 
    53                  
    54                 col = parseInt( zoombits[2].split( '=' )[1] );  
    55                 row = parseInt( zoombits[3].split( '=' )[1] );  
    56                 zoom = parseInt( zoombits[4].split( '=' )[1] );  
    57                          
    58                 var coord : Coordinate = new Coordinate( row, col, ( 17 - zoom ) ); 
    59                 return coord; 
    60         } 
    6140} 
  • trunk/as2/lib/com/modestmaps/mapproviders/microsoft/AbstractMicrosoftMapProvider.as

    r97 r99  
    1111extends AbstractImageBasedMapProvider  
    1212{ 
    13         public static var BASE_URL : String; 
    14         public static var ASSET_EXTENSION : String; 
    15          
    1613        function AbstractMicrosoftMapProvider()  
    1714        { 
     
    4643                return zoomString;  
    4744        } 
    48          
    49         /* 
    50          * Given a URL, returns the coordinates that the URL refers to. 
    51          */ 
    52         private function getCoordinateFromURL( url : String ) : Coordinate 
    53         { 
    54                 var row, col, zoom : Number; 
    55                  
    56                 // first locate the meaty bits (i.e. the zoomString). 
    57                 var zoomString : String = url.substring( baseUrl.length ); 
    58                 zoomString = zoomString.substring( 0, zoomString.indexOf( assetExtension ) ); 
    59  
    60                 // now work backwards to determine row and col 
    61                 zoom = zoomString.length; 
    62          
    63                 var rowStr : String = ""; 
    64                 var colStr : String = ""; 
    65                 var tempStr : String = ""; 
    66                  
    67                 for ( var i : Number = 0; i < zoom; i++ ) 
    68                 { 
    69                         tempStr = BinaryUtil.convertToBinary( parseInt( zoomString.charAt( i ) ) ); 
    70                         colStr += tempStr.charAt( tempStr.length-1 ); 
    71                         rowStr += tempStr.charAt( tempStr.length-2 ); 
    72                 } 
    73                                  
    74                 row = BinaryUtil.convertToDecimal( rowStr ); 
    75                 col = BinaryUtil.convertToDecimal( colStr ); 
    76                  
    77                 var coord : Coordinate = new Coordinate( row, col, zoom ); 
    78                 return coord; 
    79         } 
    8045} 
  • trunk/as2/lib/com/modestmaps/mapproviders/microsoft/MicrosoftAerialMapProvider.as

    r71 r99  
    1313implements IMapProvider, IDispatchable 
    1414{ 
    15         private static var BASE_URL : String = "http://a0.ortho.tiles.virtualearth.net/tiles/a"; 
    16         private static var ASSET_EXTENSION : String = ".jpeg"; 
    17                  
    1815        public function toString() : String 
    1916        { 
     
    2118        } 
    2219         
    23         public function get baseUrl() : String 
    24         { 
    25                 return BASE_URL;         
    26         } 
    27          
    28         public function get assetExtension() : String 
    29         { 
    30                 return ASSET_EXTENSION;  
    31         } 
    32                  
    3320        private function getTileUrl( coord : Coordinate ) : String 
    3421        {                
    35                 var url : String = BASE_URL + getZoomString( coord ) + ASSET_EXTENSION + "?g=45"; 
    36                  
    37                 //trace (this + ": Mapped " + coord.toString() + " to URL: " + url); 
     22                var url : String = "http://a0.ortho.tiles.virtualearth.net/tiles/a" +  
     23                        getZoomString( coord ) + ".jpeg?g=45"; 
    3824                 
    3925                return url;  
  • trunk/as2/lib/com/modestmaps/mapproviders/microsoft/MicrosoftHybridMapProvider.as

    r71 r99  
    1313implements IMapProvider, IDispatchable 
    1414{ 
    15         private static var BASE_URL : String = "http://h1.ortho.tiles.virtualearth.net/tiles/h"; 
    16         private static var ASSET_EXTENSION : String = ".jpeg"; 
    17          
    1815        public function toString() : String 
    1916        { 
     
    2118        } 
    2219         
    23         public function get baseUrl() : String 
    24         { 
    25                 return BASE_URL;         
    26         } 
    27  
    28         public function get assetExtension() : String 
    29         { 
    30                 return ASSET_EXTENSION;  
    31         } 
    32                  
    3320        private function getTileUrl( coord : Coordinate ) : String 
    3421        {                
    35                 var url : String = BASE_URL + getZoomString( coord ) + ASSET_EXTENSION + "?g=45";                
     22                var url : String = "http://h1.ortho.tiles.virtualearth.net/tiles/h" +  
     23                        getZoomString( coord ) + ".jpeg?g=45";           
     24 
    3625                return url;  
    3726        } 
  • trunk/as2/lib/com/modestmaps/mapproviders/microsoft/MicrosoftRoadMapProvider.as

    r71 r99  
    1313implements IMapProvider, IDispatchable 
    1414{ 
    15         private static var BASE_URL : String = "http://r3.ortho.tiles.virtualearth.net/tiles/r"; 
    16         private static var ASSET_EXTENSION : String = ".png"; 
    17                  
    1815        public function toString() : String 
    1916        { 
     
    2118        } 
    2219         
    23         public function get baseUrl() : String 
    24         { 
    25                 return BASE_URL;         
    26         } 
    27  
    28         public function get assetExtension() : String 
    29         { 
    30                 return ASSET_EXTENSION;  
    31         } 
    32                          
    3320        private function getTileUrl( coord : Coordinate ) : String 
    3421        {                
    35                 var url : String = BASE_URL + getZoomString( coord ) + ASSET_EXTENSION + "?g=45"; 
    36                  
    37                 //trace (this + ": Mapped " + tile.toString() + " to URL: " + url); 
     22                var url : String = "http://r3.ortho.tiles.virtualearth.net/tiles/r" +  
     23                        getZoomString( coord ) + ".png?g=45"; 
    3824                 
    3925                return url;