Changeset 542

Show
Ignore:
Timestamp:
04/06/08 23:47:59 (5 months ago)
Author:
allens
Message:

added some niceties to MapExtent?: getRect() returns a Rectangle of the bounding box, and contains() tells you if the extent contains a Location

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/as3/lib/com/modestmaps/core/MapExtent.as

    r502 r542  
    66{ 
    77        import com.modestmaps.geo.Location; 
     8         
     9        import flash.geom.Rectangle; 
    810         
    911        public class MapExtent extends Object 
     
    116118        } 
    117119 
     120        public function getRect():Rectangle 
     121        { 
     122            var rect:Rectangle = new Rectangle(Math.min(east, west), Math.min(north, south)); 
     123            rect.right = Math.max(east, west); 
     124            rect.bottom = Math.max(north, south); 
     125            return rect; 
     126        } 
     127         
     128        public function contains(location:Location):Boolean 
     129        { 
     130            return getRect().contains(location.lon, location.lat); 
     131        } 
     132 
    118133                /** @return "north, south, east, west" */ 
    119134                public function toString():String 
    120135                { 
    121                         return [north, west, south, east].toString(); 
     136                        return [north, south, east, west].join(', '); 
    122137                } 
    123138        }