Example #1
0
def build_transect_context(transect, kml_args_dict):
    """
    Return a formatted transect object as input for the kml
    >>> transect = makejarkustransect(7003800)
    >>> build_transect_context(transect, {}) # doctest:+ELLIPSIS
    {...'transect': <lizard_kml...>,...'years': OrderedDict([(datetime...
    """
    result = {}
    result['transect'] = transect
    years = collections.OrderedDict()
    exaggeration = float(kml_args_dict.get('exaggeration', 4))
    lift = float(kml_args_dict.get('lift', 40))
    result['extrude'] = int(kml_args_dict.get('extrude',0))
    move = float(kml_args_dict.get('move', 0.1))
    for i, year in enumerate(transect.t):
        lon, lat = transect.move_by(i*move)
        coords = helpers.textcoordinates(
            lon,
            lat,
            transect.z[i,:] * exaggeration + lift
            )
        years[year] = {
            'coordinates': coords,
            'begindate': helpers.kmldate(transect.begindates()[i]),
            'enddate': helpers.kmldate(transect.enddates()[i]),
            'style': 'year{0}'.format(transect.begindates()[i].year)
            }
    result['years'] = years
    return result
Example #2
0
def build_lod_context(overview, kml_args_dict):
    """
    Return the formatted overview as input for the kml
    >>> overview = makejarkuslod()
    >>> build_lod_context(overview, {}) # doctest:+ELLIPSIS
    {'overview':..., 'lines': [{'bbox': {'...': ...}, 'coordinates':...
    """
    result = {}
    result['overview'] = overview
    lines = []
    # TODO: clean this up a bit...
    for (id,
         north,
         south,
         east,
         west,
         lat0,
         lat1,
         lon0,
         lon1) in zip(overview['id'],
                      overview['north'],
                      overview['south'],
                      overview['east'],
                      overview['west'],
                      overview['lat0'],
                      overview['lat1'],
                      overview['lon0'],
                      overview['lon1']):
        line = {}
        bbox = {
            'north': north,
            'south': south,
            'east': east,
            'west': west
            }
        coordinates = helpers.textcoordinates(x0=lon0, y0=lat0, x1=lon1, y1=lat1)
        line['coordinates'] = coordinates
        line['point_coordinates'] = helpers.textcoordinates(x0=lon0, y0=lat0)
        line['bbox'] = bbox
        line['id'] = id
        lines.append(line)
    result['lines'] = lines
    result['exaggeration'] = float(kml_args_dict.get('exaggeration', 4))
    result['lift'] = float(kml_args_dict.get('lift', 40))
    return result