Exemplo n.º 1
0
def plot_all_rides(xml_tree, graph_filebase, graph_dir, hires, segs):
    """
    Generate profiles for all the rides in a rideset, and all the rides'
    segments as well (if asked).

    @param xml_tree: C{ElementTree} representation of a rideset
    @type xml_tree: C{ElementTree} stuff
    @param graph_filebase: base filename for profile plots
    @type graph_filebase: C{string}
    @param graph_dir: directory to place profile plots into
    @type graph_dir: C{string}
    @param hires: high resolution?
    @type hires: C{boolean}
    @param segs: plot segments?
    @type segs: C{boolean}
    """
    if hires:
        ppi = PROFILE_PDF_PPI
    else:
        ppi = PROFILE_PPI

    ride_list, bounds = process_rides(xml_tree)
    for ride in ride_list:
        plotter = ProfilePlotter(ride, graph_filebase, graph_dir, ppi)
        if segs:
            _process_segs(plotter, ride.segs)
        _process_ride(plotter, ride)
Exemplo n.º 2
0
Arquivo: osm.py Projeto: jfarrimo/sabx
def _process_all_rides(xml_tree, title, node_id):
    """
    Go through all the rides in the rideset and generate the data needed by the
    template to create the PDF map data.

    @param xml_tree: C{ElementTree} representation of a rideset
    @type xml_tree: C{ElementTree} stuff
    @param title: title for the map
    @type title: C{string}
    @param node_id: L{NodeId} to generate the node ids from
    @type node_id: L{NodeId}
    """
    ride_data, bounds = process_rides(xml_tree)
    for ride in ride_data:
        _process_parking(ride, node_id)
        _process_segments(ride)
        _process_turns(ride, node_id)
        ride.stops = _process_stops_pois(ride.stops, node_id)
        ride.pois = _process_stops_pois(ride.pois, node_id)

        ride.bounds = Bounds(box=ride.bounds)
        ride.bounds.set_pixel_size()
        ride.bounds.expand_to_good_size(0.1)
        bounds.expand_to_box(ride.bounds)

        _process_zooms_n_clusters(ride, node_id)
        generate_legend(ride, title, node_id)

    return ride_data, bounds
Exemplo n.º 3
0
def pdf_all_rides(xml_tree, out_dir, out_base):
    """
    Generate instruction PDF files for each ride in a rideset.

    @param xml_tree: C{ElementTree} representation of a rideset
    @type xml_tree: C{ElementTree} stuff
    @param out_dir: directory to write the PDF files to
    @type out_dir: C{string}
    @param out_base: file name base for PDF files
    @type out_base: C{string}
    """
    sabx = parse_top_level(xml_tree)
    ride_list, bounds = process_rides(xml_tree)
    pdf_gen = InstructionPdfGenerator(sabx['title'], out_dir, out_base)
    for ride in ride_list:
        table_data = _create_table_data(ride)
        pdf_gen.process_ride(ride.index, ride.distance, table_data)
Exemplo n.º 4
0
def ride_profiles_to_pdfs(xml_tree, prof_dir, prof_base, out_dir, out_base):
    """
    Convert the large overall profile for each ride in a rideset into a PDF
    file.

    @param xml_tree: C{ElementTree} representation of a rideset
    @type xml_tree: C{ElementTree} stuff
    @param prof_dir: directory containing the profile PNG files
    @type prof_dir: C{string}
    @param prof_base: base name for profile PNG file names
    @type prof_base: C{string}
    @param out_dir: directory to put PDF files into
    @type out_dir: C{string}
    @param out_base: base name for PDF files
    @type out_base: C{string}
    """
    sabx = parse_top_level(xml_tree)
    ride_list, bounds = process_rides(xml_tree)
    for ride in ride_list:
        _large_profile_to_pdf(sabx['title'], ride,
                              prof_dir, prof_base, out_dir, out_base)
Exemplo n.º 5
0
Arquivo: map.py Projeto: jfarrimo/sabx
def _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.

    @param xml_tree: C{ElementTree} representation of a rideset
    @type xml_tree: C{ElementTree} stuff
    @param filebase: base upon which to build file names
    @type filebase: C{string}

    @return: modified ride data
    @rtype: C{list} of L{Ride}
    """
    ride_data, bounds = oxm.process_rides(xml_tree)
    for ride in ride_data:
        # basic processing
        _process_segments(ride.segs, filebase, ride.index)
        _process_turns(ride.turns)
        _process_stops(ride.stops)
        _process_pois(ride.pois)

        # stop/poi distances
        ride.stop_dists = _process_stop_poi_dists(ride.stops)
        ride.poi_dists = _process_stop_poi_dists(ride.pois)

        # elevations
        ride.ele, ride.ele_segs = process_elevations(ride)

        # file names
        ride.profile_small = \
            '%s_prof_small_%s_all.png' % (filebase, ride.index)
        ride.profile_large = \
            '%s_prof_large_%s_all.png' % (filebase, ride.index)
        ride.map_large = '%s_map_%s.png' % (filebase, ride.index)
        ride.map_small_base = '%s_map_%s_' % (filebase, ride.index)

    return ride_data