Package sabx10 :: Package oxm :: Module ride
[hide private]
[frames] | no frames]

Module ride

source code

Ride handling.

When I'm using SABX data to create maps, I like to process the XML data into a more useful object hierarchy. I de-reference the parking, turn, and seg ids for each ride and create full object hierarchies for each. This results in lots of duplication, but gives data that is easy to manipulate and reference. I also do some analysis of the rides and add things like distances and bounding boxes to the relevant objects, and modify some of the standard objects to be more programmer-friendly.

The entry point for this is the process_rides function. It orchestrates all the processing and calculating and returns a ride list that looks like this:

Make note of the fact that all comment and description fields are stripped of extra spaces and linefeeds during processing.

Classes [hide private]
  Ride
A Ride object describes a ride and keeps track of all relevant ride information.
Functions [hide private]
string
_parse_ride_parking(xml_ride)
Take the Element for a ride and extract the parking id for the ride.
source code
list of string
_parse_ride_turns(xml_ride)
Take the Element for a ride and extract the turn id's for the ride.
source code
list of string
_parse_ride_segments(xml_ride)
Take the Element for a ride and extract the segment id's for the ride.
source code
Ride
_parse_ride_xml(xml_ride)
Take the Element for a ride and turn it into a Ride object.
source code
(list of Ride,dict of Ride)
parse_rides(xml_tree)
Parse the rides in the given XML tree and turn them into valid Ride objects.
source code
list
_create_combined_list(ride)
Create a list containing all of the turns, segments, stops, and pois for the ride, ordered by distance into ride.
source code
Box
_process_bounds(ride, seg_bounds, stop_bounds, poi_bounds)
Creating a bounding box that includes the bounds for the parking, segments, stops, and pois for this ride.
source code
Ride
_process_ride(ride_index, xml_ride, xml_parking_places, xml_segs, xml_turns, xml_stops, xml_pois, correct_ele=True)
Create a Ride object and add pertinent calculated data.
source code
(list of Ride,Box)
process_rides(xml_tree, correct_ele=True)
Process the rides in the XML tree and generate a list of Ride objects and the bounding box for all of the rides.
source code
Variables [hide private]
  __package__ = 'sabx10.oxm'
Function Details [hide private]

_parse_ride_parking(xml_ride)

source code 

Take the Element for a ride and extract the parking id for the ride.

Parameters:
  • xml_ride (Element) - Element for a ride
Returns: string
parking id

_parse_ride_turns(xml_ride)

source code 

Take the Element for a ride and extract the turn id's for the ride.

Parameters:
  • xml_ride (Element) - Element for a ride
Returns: list of string
list of turn id's

_parse_ride_segments(xml_ride)

source code 

Take the Element for a ride and extract the segment id's for the ride.

Parameters:
  • xml_ride (Element) - Element for a ride
Returns: list of string
list of segment id's

_parse_ride_xml(xml_ride)

source code 

Take the Element for a ride and turn it into a Ride object. This Ride object will be populated with lists of string id's for the parking, turns, and segs of the ride.

Parameters:
  • xml_ride (Element) - Element for a ride
Returns: Ride
Ride object

parse_rides(xml_tree)

source code 

Parse the rides in the given XML tree and turn them into valid Ride objects.

Parameters:
  • xml_tree (Element or ElementTree) - root of Element tree that has rides in it
Returns: (list of Ride,dict of Ride)
rides in a list and a dictionary

_create_combined_list(ride)

source code 

Create a list containing all of the turns, segments, stops, and pois for the ride, ordered by distance into ride.

Parameters:
  • ride (Ride) - Ride to process
Returns: list
combined list

_process_bounds(ride, seg_bounds, stop_bounds, poi_bounds)

source code 

Creating a bounding box that includes the bounds for the parking, segments, stops, and pois for this ride.

Parameters:
  • ride (Ride) - Ride to process
  • seg_bounds (Box) - bounding Box for segments
  • stop_bounds (Box) - bounding Box for stops
  • poi_bounds (Box) - bounding Box for pois
Returns: Box
bounding box containing everything

_process_ride(ride_index, xml_ride, xml_parking_places, xml_segs, xml_turns, xml_stops, xml_pois, correct_ele=True)

source code 

Create a Ride object and add pertinent calculated data.

Calculated data includes:

  • index: index of ride
  • stops: list of Stops for this ride
  • pois: list of Pois for this ride
  • combined: distance sorted list of all turns, segments, stops, and pois
  • distance: length of entire ride
  • bounds: bounding box including all parking, segments, stops, and pois
Parameters:
  • ride_index (int) - index for this ride
  • xml_ride (Element) - Element for a ride
  • xml_parking_places (list of Element) - list of parking place Elements
  • xml_segs (list of Element) - list of segment Elements
  • xml_turns (list of Element) - list of turn Elements
  • xml_stops (list of Element) - list of stop Elements
  • xml_pois (list of Element) - list of poi Elements
  • correct_ele (boolean) - make sure that the segment elevations match-up?
Returns: Ride
Ride

process_rides(xml_tree, correct_ele=True)

source code 

Process the rides in the XML tree and generate a list of Ride objects and the bounding box for all of the rides.

Parameters:
  • xml_tree (Element or ElementTree) - root of Element tree that has rides in it
  • correct_ele (boolean) - make sure that the segment elevations match-up?
Returns: (list of Ride,Box)
(list of Rides,bounds of ride)