Example #1
0
def process_ride_stops(seg_set, xml_segs, xml_stops):
    """
    Process the stop references for the given ride and generate a list of
    L{Stop} objects for it and the bounding box for all of the stops.

    @param seg_set: C{list} of L{Segment} objects for the ride
    @type seg_set: C{list} of L{Segment} objects
    @param xml_segs: C{list} of C{Element} segment objects for this ride
    @type xml_segs: C{list} of C{Element}s
    @param xml_stops: C{list} of C{Element} stop objects
    @type xml_stops: C{list} of C{Element}s

    @return: (C{list} of L{Stop},C{bounds})
    @rtype: (C{list},L{Box})
    """
    index = 1
    stop_list = []
    bounds = Box()
    for ride_seg in seg_set:
        new_stops, new_bounds, index = \
            _process_stops_in_seg_data(ride_seg, xml_stops, index)
        stop_list.extend(new_stops)
        bounds.expand_to_box(new_bounds)

    return stop_list, bounds
Example #2
0
File: poi.py Project: jfarrimo/sabx
def process_ride_pois(seg_set, xml_segs, xml_pois):
    """
    Process the point of interest references for the given ride and generate a
    list of L{Poi} objects for it and the bounding box for all of the POIs.

    @param seg_set: C{list} of L{Segment} objects for the ride
    @type seg_set: C{list} of L{Segment} objects
    @param xml_segs: C{list} of C{Element} segment objects for this ride
    @type xml_segs: C{list} of C{Element}s
    @param xml_pois: C{list} of C{Element} point of interest objects
    @type xml_pois: C{list} of C{Element}s

    @return: (C{list} of L{Poi},C{bounds})
    @rtype: (C{list},L{Box})
    """
    index = 1
    poi_list = []
    bounds = Box()
    for ride_seg in seg_set:
        new_pois, new_bounds, index = \
            _process_pois_in_seg_data(ride_seg, xml_pois, index)
        poi_list.extend(new_pois)
        bounds.expand_to_box(new_bounds)

    return poi_list, bounds
Example #3
0
def process_rides(xml_tree, correct_ele=True):
    """
    Process the rides in the XML tree and generate a list of L{Ride} objects
    and the bounding box for all of the rides.

    @param xml_tree: root of C{Element} tree that has rides in it
    @type xml_tree: C{Element} or C{ElementTree}
    @param correct_ele: make sure that the segment elevations match-up?
    @type correct_ele: C{boolean}

    @return: (C{list} of L{Ride}s,C{bounds} of ride)
    @rtype: (C{list} of L{Ride},L{Box})
    """
    check_version(xml_tree)
    xml_rides = xml_tree.findall('ride')
    xml_parking_places = xml_tree.findall('parking')
    xml_segs = xml_tree.findall('segment')
    xml_turns = xml_tree.findall('turn')
    xml_stops = xml_tree.findall('stop')
    xml_pois = xml_tree.findall('poi')

    bounds = Box()
    ride_list = []
    for ride_index, xml_ride in enumerate(xml_rides):
        new_ride = _process_ride(ride_index, xml_ride, xml_parking_places, 
                                 xml_segs, xml_turns, xml_stops, xml_pois,
                                 correct_ele)
        bounds.expand_to_box(new_ride.bounds)
        ride_list.append(new_ride)

    return ride_list, bounds
Example #4
0
def process_ride_segments(xml_ride, xml_segs, correct_ele=True):
    """
    Process the segment references for the given ride and generate a list of
    L{Segment} objects for it and the bounding box for all of the segments.

    @param xml_ride: C{Element} for a ride
    @type xml_ride: C{Element}
    @param xml_segs: C{list} of C{Element} segment objects for this rideset
    @type xml_segs: C{list} of C{Element}s
    @param correct_ele: make sure that the segment elevations match-up?
    @type correct_ele: C{boolean}

    @return: (C{list} of L{Segment},C{bounds})
    @rtype: (C{list},L{Box})
    """
    """ Process the segments in the ride. """
    cum_distance = 0.0
    bounds = Box()

    ride_segs = _get_ride_segs(xml_ride, xml_segs)
    if correct_ele:
        _correct_elevations(ride_segs)
    _connect_segments_to_following_segment(ride_segs)
    for index, seg in enumerate(ride_segs):
        _process_segment(seg, index, cum_distance)
        cum_distance += seg.length
        bounds.expand_to_box(seg.bounds)

    return ride_segs, bounds
Example #5
0
def _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.

    @param ride: C{Ride} to process
    @type ride: C{Ride}
    @param seg_bounds: bounding C{Box} for segments
    @type seg_bounds: C{Box}
    @param stop_bounds: bounding C{Box} for stops
    @type stop_bounds: C{Box}
    @param poi_bounds: bounding C{Box} for pois
    @type poi_bounds: C{Box}

    @return: bounding box containing everything
    @rtype: L{Box}
    """
    bounds = Box()
    bounds.expand_to_point(ride.parking.lat, ride.parking.lon)
    bounds.expand_to_box(seg_bounds)
    bounds.expand_to_box(stop_bounds)
    bounds.expand_to_box(poi_bounds)
    return bounds