Exemple #1
0
def _calc_box_lats(ride, legend_height):
    """
    Split the map into three equal pieces going top to bottom.

    @param ride: ride representing map to split
    @type ride: L{Ride}
    @param legend_height: height of legend
    @type legend_height: C{float}

    @return: bottom min, bottom max, middle min, middle max, top min, top max
    @rtype: C{float},C{float},C{float},C{float},C{float},C{float}
    """
    # bottom
    bottom_lat_min = ride.bounds.min_lat
    bottom_lat_max, lon = pt_dist_from_pt(ride.bounds.min_lat, 
                                          ride.bounds.min_lon, 
                                          legend_height, 0)

    # mid
    mid_lat = (ride.bounds.min_lat + ride.bounds.max_lat) / 2.0
    mid_dist = legend_height / 2.0
    mid_lat_min, lon = pt_dist_from_pt(mid_lat, ride.bounds.min_lon, 
                                  mid_dist, 180)
    mid_lat_max, lon = pt_dist_from_pt(mid_lat, ride.bounds.min_lon, 
                                  mid_dist, 0)

    # top
    top_lat_min, lon = pt_dist_from_pt(ride.bounds.max_lat, 
                                       ride.bounds.max_lon, 
                                       legend_height, 180)
    top_lat_max = ride.bounds.max_lat

    return bottom_lat_min, bottom_lat_max, \
        mid_lat_min, mid_lat_max, \
        top_lat_min, top_lat_max
Exemple #2
0
def _calc_box_lons(ride, legend_width):
    """
    Split the map into three equal pieces going left to right.

    @param ride: ride representing map to split
    @type ride: L{Ride}
    @param legend_width: width of legend
    @type legend_width: C{float}

    @return: left min, left max, middle min, middle max, right min, right max
    @rtype: C{float},C{float},C{float},C{float},C{float},C{float}
    """
    # left
    left_lon_min = ride.bounds.min_lon
    lat, left_lon_max = pt_dist_from_pt(ride.bounds.min_lat, 
                                        ride.bounds.min_lon, 
                                        legend_width, 90)

    # mid
    mid_lon = (float(ride.bounds.min_lon) + float(ride.bounds.max_lon)) / 2.0
    mid_dist = legend_width / 2.0
    lat, mid_lon_min = pt_dist_from_pt(ride.bounds.min_lat, mid_lon, 
                                       mid_dist, 270)
    lat, mid_lon_max = pt_dist_from_pt(ride.bounds.min_lat, mid_lon, 
                                       mid_dist, 90)

    # right
    lat, right_lon_min = pt_dist_from_pt(ride.bounds.max_lat, 
                                         ride.bounds.max_lon, 
                                         legend_width, 270)
    right_lon_max = ride.bounds.max_lon

    return left_lon_min, left_lon_max, \
        mid_lon_min, mid_lon_max, \
        right_lon_min, right_lon_max
Exemple #3
0
def _gen_legend_item(lat, lon, text, dist, node_id):
    """
    Generate a L{LegendNode}, and calculate a point below it.  This allows us
    to generate the items and "walk" them down the page in the process.  We
    end-up with legend items on successive lines on the map page.

    @param lat: latitude of legend item
    @type lat: C{float}
    @param lon: longitude of legend item
    @type lon: C{float}
    @param text: text of legend item
    @type text: C{string}
    @param dist: distance down page for next item
    @type dist: C{float}
    @param node_id: L{NodeId} to generate id from
    @type node_id: L{NodeId}

    @return: L{LegendNode}, lat of next legend item, lon of next legend item
    @rtype: L{LegendNode},C{float},C{float}
    """
    node = LegendNode(node_id.next(), text, lat, lon)
    lat, lon = pt_dist_from_pt(lat, lon, dist, 180)

    return node, lat, lon