Beispiel #1
0
 def test_kmz(self):
     "Testing `render_to_kmz` with non-ASCII data. See #11624."
     name = "Åland Islands"
     places = [{'name': name,
               'description': name,
               'kml': '<Point><coordinates>5.0,23.0</coordinates></Point>'
               }]
     render_to_kmz('gis/kml/placemarks.kml', {'places': places})
Beispiel #2
0
 def test_kmz(self):
     "Testing `render_to_kmz` with non-ASCII data. See #11624."
     name = "Åland Islands"
     places = [{'name' : name,
               'description' : name,
               'kml' : '<Point><coordinates>5.0,23.0</coordinates></Point>'
               }]
     render_to_kmz('gis/kml/placemarks.kml', {'places' : places})
Beispiel #3
0
 def test_kmz(self):
     "Testing `render_to_kmz` with non-ASCII data. See #11624."
     name = "Åland Islands"
     places = [
         {
             "name": name,
             "description": name,
             "kml": "<Point><coordinates>5.0,23.0</coordinates></Point>",
         }
     ]
     render_to_kmz("gis/kml/placemarks.kml", {"places": places})
Beispiel #4
0
def build_kml(view, kml_type, id, kml_args_dict):
    '''builds a dynamic KML file'''
    # n.b.: kml_args_dict containts direct USER input
    # This means that we should process input as unsafe in the factory methods...

    # ensure kml_args_dict is sorted, so URLS always come out the same
    # this help Google Earth's caching
    kml_args_dict = SortedDict(sorted(kml_args_dict.items()))
    template_context = {
        'view': view,
        'kml_args': urllib.urlencode(kml_args_dict)
    }
    if kml_type == 'transect' and id is not None:
        transect = makejarkustransect(id)
        extra_context = build_transect_context(transect, kml_args_dict)
        template_context.update(extra_context)
    elif kml_type == 'lod':
        lod = makejarkuslod()
        extra_context = build_lod_context(lod, kml_args_dict)
        template_context.update(extra_context)
    elif kml_type == 'style':
        extra_context = build_style_context(kml_args_dict)
        template_context.update(extra_context)
    else:
        raise Exception('KML type not supported')
    return render_to_kmz("kml/{0}.kml".format(kml_type), template_context)
Beispiel #5
0
 def test02_kmz(self):
     "Testing `render_to_kmz` with non-ASCII data, see #11624."
     name = '\xc3\x85land Islands'.decode('iso-8859-1')
     places = [{'name' : name,
               'description' : name,
               'kml' : '<Point><coordinates>5.0,23.0</coordinates></Point>'
               }]
     kmz = render_to_kmz('gis/kml/placemarks.kml', {'places' : places})
Beispiel #6
0
 def test_kmz(self):
     "Testing `render_to_kmz` with non-ASCII data. See #11624."
     name = '\xc3\x85land Islands'.decode('iso-8859-1')
     places = [{'name' : name,
               'description' : name,
               'kml' : '<Point><coordinates>5.0,23.0</coordinates></Point>'
               }]
     kmz = render_to_kmz('gis/kml/placemarks.kml', {'places' : places})
Beispiel #7
0
def get_wms_kml(kml_resource):
    context = {
        'name': kml_resource.name,
        'wms_url': kml_resource.url
    }
    content = render_to_kmz("kml/wms.kml", context)
    content_type = MIME_KMZ
    return content, content_type
Beispiel #8
0
def contours(request, lat=0, lon=0, radius=0):
    origin = Point(float(lon), float(lat))
    distance_km = (float(radius) / 1000)
    distance_degrees = distance_km / 111.317
    queryset = Contours.objects.filter(geomData__dwithin=(origin,
                                                          distance_degrees))
    qsKML = queryset.kml()
    return render_to_kmz(templateFolder + "/contours.kml", {'places': qsKML})
Beispiel #9
0
def lUse(request, lat=0, lon=0, radius=0):
    origin = Point(float(lon), float(lat))
    distance_km = (float(radius) / 1000) + 0.1
    distance_degrees = distance_km / 111.317
    circle = origin.buffer((float(radius) / 1000) / 111.317)
    queryset = landUse.objects.filter(geomData__dwithin=(origin,
                                                         distance_degrees))
    qsKML = queryset.intersection(circle).kml()
    return render_to_kmz(templateFolder + "/landUse.kml", {'places': qsKML})
Beispiel #10
0
def parcel(request, lat=0, lon=0, radius=0):
    origin = Point(float(lon), float(lat))
    distance_km = (float(radius) / 1000)
    distance_degrees = distance_km / 111.317
    circle = origin.buffer((float(radius) / 1000) / 111.317)
    queryset = landParcel.objects.filter(
        geom__dwithin=(origin, distance_degrees)).intersection(circle).kml()
    return render_to_kmz(templateFolder + "/parcels.kml",
                         {'parcels': queryset})
Beispiel #11
0
def recommendAll(request, lat=0, lon=0, radius=0):
    origin = Point(float(lon), float(lat))
    distance_km = (float(radius) / 1000) + 0.01
    circle = origin.buffer((float(radius) / 1000) / 111.317)
    distance_degrees = distance_km / 111.317
    queryset = soilsAndRainfall.objects.select_related('soilFeatures').filter(
        geomData__dwithin=(origin,
                           distance_degrees)).intersection(circle).kml()
    return render_to_kmz(templateFolder + "/recommendAll.kml",
                         {'places': queryset})
Beispiel #12
0
def object_list_kml(request, format='kml', template_name="minagro/proyectos.kml"):
    viviendas= Vivienda.objects.all().exclude(geometry__exact=None).order_by('departamento', 'municipio').select_related()
    if format == 'kml':
        return render_to_kml(template_name, {'object_list':viviendas})
    if format == 'kmz':
        return render_to_kmz(template_name, {'object_list':viviendas})
    if format == 'xml':
        return render_to_response(template_name, {'object_list':viviendas}, mimetype="text/xml")
    if format == 'txt':
        return render_to_response(template_name, {'object_list':viviendas}, mimetype="text/plain")
Beispiel #13
0
def get_wms_kml(kml_resource):
    '''
    Wrap a WMS url in a KML file for given KmlResource instance.

    Returns a tuple (content, content_type).
    '''
    context = {
        'name': kml_resource.name,
        'wms_url': kml_resource.url
    }

    # Build KML file using a simple Django template.
    content = render_to_kmz("kml/wms.kml", context)
    content_type = MIME_KMZ
    return content, content_type