Пример #1
0
def layerController(request, layername):
    DEFAULT_MAP_CONFIG, DEFAULT_BASE_LAYERS = default_map_config()
    layer = get_object_or_404(Layer, typename=layername)
    if (request.META['QUERY_STRING'] == "describe"):
        return _describe_layer(request,layer)
    if (request.META['QUERY_STRING'] == "remove"):
        return _removeLayer(request,layer)
    if (request.META['QUERY_STRING'] == "update"):
        return _updateLayer(request,layer)
    if (request.META['QUERY_STRING'] == "style"):
        return _changeLayerDefaultStyle(request,layer)
    else:
        if not request.user.has_perm('maps.view_layer', obj=layer):
            return HttpResponse(loader.render_to_string('401.html',
                RequestContext(request, {'error_message':
                    _("You are not permitted to view this layer")})), status=401)

        metadata = layer.metadata_csw()

        maplayer = MapLayer(name = layer.typename, ows_url = settings.GEOSERVER_BASE_URL + "wms")

        # center/zoom don't matter; the viewer will center on the layer bounds
        map = Map(projection="EPSG:900913")

	qualityRecord = layer.qualitymatrix	

        return render_to_response('quality/layer.html', RequestContext(request, {
            "layer": layer,
            "metadata": metadata,
            "viewer": json.dumps(map.viewer_json(* (DEFAULT_BASE_LAYERS + [maplayer]))),
            "permissions_json": _perms_info_json(layer, LAYER_LEV_NAMES),
            "GEOSERVER_BASE_URL": settings.GEOSERVER_BASE_URL,
	    "qualityRecord": qualityRecord
            }))
Пример #2
0
 def run(self):
     if not self.dry_run:
         self.query_set.delete()
     map_layers = []
     _, templates = default_map_config(None)
     for m in Map.objects.all():
         for t in templates:
             t.id = None
             t.map = m
             t.save()
             map_layers.append(t.id)
     print map_layers
Пример #3
0
def search(request):
    DEFAULT_MAP_CONFIG, DEFAULT_BASE_LAYERS = default_map_config()
    #DEFAULT_MAP_CONFIG, DEFAULT_BASE_LAYERS = default_map_config(request)
    # for non-ajax requests, render a generic search page

    params = dict(request.REQUEST)

    map = Map(projection="EPSG:900913", zoom=1, center_x=0, center_y=0)

    # Default Counts to 0, JS will Load the Correct Counts
    counts = {"map": 0, "layer": 0, "vector": 0, "raster": 0, "contact": 0, "group": 0}

    return render_to_response("search/search.html", RequestContext(request, {
        "init_search": json.dumps(params),
        #'viewer_config': json.dumps(map.viewer_json(added_layers=DEFAULT_BASE_LAYERS, authenticated=request.user.is_authenticated())),
        "viewer_config": json.dumps(map.viewer_json(*DEFAULT_BASE_LAYERS)),
        "GOOGLE_API_KEY": settings.GOOGLE_API_KEY,
        "site": settings.SITEURL,
        "counts": counts,
        "keywords": Layer.objects.gn_catalog.get_all_keywords()
    }))
Пример #4
0
def _create_viewer_config():
    DEFAULT_MAP_CONFIG, DEFAULT_BASE_LAYERS = default_map_config()
    _map = Map(projection="EPSG:900913", zoom=1, center_x=0, center_y=0)
    return json.dumps(_map.viewer_json(*DEFAULT_BASE_LAYERS))
Пример #5
0
def _create_viewer_config():
    DEFAULT_MAP_CONFIG, DEFAULT_BASE_LAYERS = default_map_config()
    _map = Map(projection="EPSG:900913", zoom = 1, center_x = 0, center_y = 0)
    return json.dumps(_map.viewer_json(*DEFAULT_BASE_LAYERS))
Пример #6
0
def newmaptpl(request):
	config = default_map_config()[0]
	return render_to_response('documents/newmaptpl.html',RequestContext(request, {'config':json.dumps(config)}))
Пример #7
0
def newmaptpl(request):
    config = default_map_config()[0]
    return render_to_response(
        'documents/newmaptpl.html',
        RequestContext(request, {'config': json.dumps(config)}))