def _process_pois_in_seg_data(ride_seg, xml_pois, index): """ Process the segment, extracting the POIs and getting the bounds of the POIs. @param ride_seg: L{Segment} to process @type ride_seg: L{Segment} @param xml_pois: C{list} of C{Element}s for POIs in rideset @type xml_pois: C{list} of C{Element} @param index: next index to use for a POI @type index: C{int} @return: (POIs for segment, bounds, updated index) @rtype: (C{list} of L{Poi},L{Box},C{int}) """ seg_pois = [] bounds = Box() for waypoint, dist in _poi_pts_dist(ride_seg.waypoints): if waypoint.poi is not None: poi_list = waypoint.poi.split() for poi_item in poi_list: xml_poi = get_from_id(xml_pois, poi_item.strip()) new_poi = _parse_poi_xml(xml_poi) new_poi.description = " ".join(new_poi.description.split()) new_poi.distance = ride_seg.start_dist + dist new_poi.off_route = new_poi.calculate_distance(waypoint) new_poi.index = index index += 1 seg_pois.append(new_poi) bounds.expand_to_point(new_poi.lat, new_poi.lon) return seg_pois, bounds, index
def _process_stops_in_seg_data(ride_seg, xml_stops, index): """ Process the segment, extracting the stops and getting the bounds of the stops. @param ride_seg: L{Segment} to process @type ride_seg: L{Segment} @param xml_stops: C{list} of C{Element}s for stops in rideset @type xml_stops: C{list} of C{Element} @param index: next index to use for a stop @type index: C{int} @return: (stops for segment, bounds, updated index) @rtype: (C{list} of L{Stop},L{Box},C{int}) """ seg_stops = [] bounds = Box() for waypoint, dist in _stop_pts_dist(ride_seg.waypoints): if waypoint.stop is not None: stop_list = waypoint.stop.split() for stop_item in stop_list: xml_stop = get_from_id(xml_stops, stop_item.strip()) new_stop = _parse_stop_xml(xml_stop) new_stop.description = " ".join(new_stop.description.split()) new_stop.distance = ride_seg.start_dist + dist new_stop.off_route = new_stop.calculate_distance(waypoint) new_stop.index = index index += 1 seg_stops.append(new_stop) bounds.expand_to_point(new_stop.lat, new_stop.lon) return seg_stops, bounds, index
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