Package sabx10 :: Package map :: Module map
[hide private]
[frames] | no frames]

Module map

source code

Main code for generating interactive Google Maps representations of SABX data files. It takes an SABX file and parses it and processes its rides using the sabx10.oxm package. It then adds additional data to the processed rides.

Classes [hide private]
  SabxProcessor
Specialized TemplateProcessor to handle SABX files and turn them into Google Maps displayable maps.
Functions [hide private]
float
_min_distance(points, pt)
Determine how far away, in statute miles, the closest point to pt is in points.
source code
int
_min_zoom_level(points, pt)
Determine the minimum Google maps zoom level to show pt so that it won't overlap with other points in the points list at higher zooms.
source code
 
_process_segments(ride_segs, graph_filebase, ride_index)
For each segment in a ride, give it a type, Google Map encode its points, and add filenames for its profiles.
source code
 
_process_turns(ride_turns)
For each turn in a ride, set its type and calculate a zoom level.
source code
 
_process_stops(ride_stops)
For each stop in a ride, set its type.
source code
 
_process_pois(ride_pois)
For each poi in a ride, set its type.
source code
dictionary
_process_stop_poi_dists(item_list)
Calculate the ride distance and off-course distance for each poi or stop in a ride.
source code
list of Ride
_process_all_rides(xml_tree, filebase)
Go through all the rides in the rideset and update them with the extra information necessary to correctly render maps and their data from the templates.
source code
Variables [hide private]
list zoom_levels = [2690, 1354, 680, 342, 168, 86, 42, 21, 11, 5.3,...
distances between 32x32 map icons in Google Maps for each zoom level, with the zoom level being the index of the distance in the list
  __package__ = 'sabx10.map'
Function Details [hide private]

_min_distance(points, pt)

source code 

Determine how far away, in statute miles, the closest point to pt is in points.

Parameters:
  • points (list of Point objects) - list of points to check against
  • pt (Point object) - Point object to check for
Returns: float
distance to closest point

_min_zoom_level(points, pt)

source code 

Determine the minimum Google maps zoom level to show pt so that it won't overlap with other points in the points list at higher zooms. This assumes lower zoom levels show bigger areas, such that the highest zoom level would show a tick on a rat's back, while the lowest zoom level would show the continents of the world. Lowest is 0, while highest is 19. These are determined so that 32x32 icons won't overlap in the area of the map surrounding San Antonio, TX. For other parts of the world (closer or farther from the equator) these values may not be all that good.

Parameters:
  • points (list of Point objects) - list of points to check against
  • pt (Point object) - Point object to check for
Returns: int
zoom level

_process_segments(ride_segs, graph_filebase, ride_index)

source code 

For each segment in a ride, give it a type, Google Map encode its points, and add filenames for its profiles.

Set the type to "seg", so that Jinja2 can tell what type it is, since Jinja2 doesn't natively support object introspection.

Add encoded points, meaning points that have been encoded into Google Maps' compact format for storing segment points.

Add filenames for the profiles for the segments.

Parameters:
  • ride_segs (list of Segment objects) - list of segments in the ride
  • graph_filebase (string) - base name for profile files
  • ride_index (string) - index of ride being processed

_process_turns(ride_turns)

source code 

For each turn in a ride, set its type and calculate a zoom level.

Calculate the minimum Google Maps zoom level to display this turn.

Set the type to "turn" so that Jinja2 can tell what type it is, since Jinja2 doesn't natively support object introspection.

Parameters:
  • ride_turns (list of Turn objects) - list of turns for this ride

_process_stops(ride_stops)

source code 

For each stop in a ride, set its type.

Set the type to "stop" so that Jinja2 can tell what type it is, since Jinja2 doesn't natively support object introspection.

Parameters:
  • ride_stops (list of Stop objects) - list of stops to process

_process_pois(ride_pois)

source code 

For each poi in a ride, set its type.

Set all the pois to have type "poi" so that Jinja2 can tell what type it is, since Jinja2 doesn't natively support object introspection.

Parameters:
  • ride_pois (list of Poi objects) - list of pois to process

_process_stop_poi_dists(item_list)

source code 

Calculate the ride distance and off-course distance for each poi or stop in a ride. This function works on stop or poi lists, and expects one of these to be passed in.

Go through the list of stops/pois for a ride and correlate these with the stops/pois defined for the rideset. For each occurrence of a stop/poi in a ride, save the distance into the ride and the distance off course for the stop/poi. You want to do this because a single stop/poi can be used several times in a ride. When summarizing the stop/poi, you want to be able to list all the distances for the stop/poi. This is used when generating the stop/poi info dialog when clicking on the stop/poi icon in the Google Map.

Parameters:
  • item_list (list of Poi or Stop objects) - list of items to process
Returns: dictionary
distances dictionary

_process_all_rides(xml_tree, filebase)

source code 

Go through all the rides in the rideset and update them with the extra information necessary to correctly render maps and their data from the templates.

Parameters:
  • xml_tree (ElementTree stuff) - ElementTree representation of a rideset
  • filebase (string) - base upon which to build file names
Returns: list of Ride
modified ride data

Variables Details [hide private]

zoom_levels

distances between 32x32 map icons in Google Maps for each zoom level, with the zoom level being the index of the distance in the list
Type:
list
Value:
[2690,
 1354,
 680,
 342,
 168,
 86,
 42,
 21,
...