Package sabx10 :: Package osm :: Module bounds :: Class Bounds
[hide private]
[frames] | no frames]

Class Bounds

source code

  object --+    
           |    
oxm.geom.Box --+
               |
              Bounds
Known Subclasses:

Bounding box that understands pixel sizes in addition to the basic lat/lon sizes. You need this because a Mapnik map is rendered into a PNG file, which has its size defined in terms of pixels, while the map data is represented in terms of lat/lon co-ordinates.

Instance Methods [hide private]
 
__init__(self, min_lat=200.0, min_lon=200.0, max_lat=-200.0, max_lon=-200.0, box=None)
Initialize the bounds, either from explicit lat/lon coordinates, or based on the size of a given Box.
source code
 
expand_to_good_size(self, perc)
Resize the bounding box so that the width and height have the correct aspect ratio, and so that the box is a certain percent bigger than the map indicates.
source code
 
set_pixel_size(self)
Set the pixel width and height of this box to the desired width and height based on whether the map is taller that it's wide, or wider than it's tall.
source code
float
calc_sep_dist(self, pix_icon_width, pix_icon_height)
Calculate how far apart two points in this bounding box need to be so that their icons won't overlap.
source code

Inherited from oxm.geom.Box: area, expand_to_box, expand_to_point, height, is_pt_in_box, resize, width

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
float pix_height
height of box in pixels
float pix_width
width of box in pixels

Inherited from oxm.geom.Box: max_lat, max_lon, min_lat, min_lon

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, min_lat=200.0, min_lon=200.0, max_lat=-200.0, max_lon=-200.0, box=None)
(Constructor)

source code 

Initialize the bounds, either from explicit lat/lon coordinates, or based on the size of a given Box.

Parameters:
  • min_lat (float) - minimum latitude of box
  • min_lon (float) - minimum longitude of box
  • max_lat (float) - maximum latitude of box
  • max_lon (float) - maximum longitude of box
  • box (Box) - example box to base this one on
Overrides: object.__init__

expand_to_good_size(self, perc)

source code 

Resize the bounding box so that the width and height have the correct aspect ratio, and so that the box is a certain percent bigger than the map indicates. This way any icons and street names drawn near the edge of the map won't get clipped.

Parameters:
  • perc (float) - percentage to expand map (0.xx format)

calc_sep_dist(self, pix_icon_width, pix_icon_height)

source code 

Calculate how far apart two points in this bounding box need to be so that their icons won't overlap.

Parameters:
  • pix_icon_width (float) - pixel width of icon being considered
  • pix_icon_height (float) - pixel height of icon being considered
Returns: float
distance apart, in statute miles, the icons must be