#138 WIP NETGIS Map client

* adds functionality for address search widget
    * drops default proxy.php (replaced by own python call)
* reduces maxZoom in config.json
This commit is contained in:
mpeltriaux 2022-04-20 09:23:24 +02:00
parent d13c3e8094
commit 49c14a67b6
4 changed files with 31 additions and 26 deletions

View File

@ -24,7 +24,7 @@ from konova.autocompletes import EcoAccountAutocomplete, \
ShareTeamAutocomplete, HandlerCodeAutocomplete ShareTeamAutocomplete, HandlerCodeAutocomplete
from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG
from konova.sso.sso import KonovaSSOClient from konova.sso.sso import KonovaSSOClient
from konova.views import logout_view, home_view, get_geom_parcels from konova.views import logout_view, home_view, get_geom_parcels, map_client_proxy_view
sso_client = KonovaSSOClient(SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY) sso_client = KonovaSSOClient(SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY)
urlpatterns = [ urlpatterns = [
@ -41,6 +41,7 @@ urlpatterns = [
path('analysis/', include("analysis.urls")), path('analysis/', include("analysis.urls")),
path('api/', include("api.urls")), path('api/', include("api.urls")),
path('geom/<id>/parcels', get_geom_parcels, name="geometry-parcels"), path('geom/<id>/parcels', get_geom_parcels, name="geometry-parcels"),
path('client/proxy', map_client_proxy_view, name="map-client-proxy"),
# Autocomplete paths for all apps # Autocomplete paths for all apps
path("atcmplt/eco-accounts", EcoAccountAutocomplete.as_view(), name="accounts-autocomplete"), path("atcmplt/eco-accounts", EcoAccountAutocomplete.as_view(), name="accounts-autocomplete"),

View File

@ -5,9 +5,12 @@ Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 16.11.20 Created on: 16.11.20
""" """
import json
import requests
from django.contrib.auth import logout from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse, JsonResponse
from django.shortcuts import redirect, render, get_object_or_404 from django.shortcuts import redirect, render, get_object_or_404
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.utils import timezone from django.utils import timezone
@ -168,3 +171,26 @@ def get_500_view(request: HttpRequest):
""" """
context = BaseContext.context context = BaseContext.context
return render(request, "500.html", context, status=500) return render(request, "500.html", context, status=500)
@login_required
def map_client_proxy_view(request: HttpRequest):
""" Provides proxy functionality for NETGIS map client.
Used for fetching content of a provided url
Args:
request (HttpRequest): The incoming request
Returns:
"""
url = request.META.get("QUERY_STRING")
response = requests.get(url)
body = json.loads(response.content)
if response.status_code != 200:
return JsonResponse({
"status_code": response.status_code,
"content": body,
})
return JsonResponse(body)

View File

@ -34,7 +34,7 @@
"projection": "EPSG:25832", "projection": "EPSG:25832",
"center": [ 385000, 5543000 ], "center": [ 385000, 5543000 ],
"minZoom": 5, "minZoom": 5,
"maxZoom": 25, "maxZoom": 21,
"zoom": 8, "zoom": 8,
"attribution": "LANIS RLP" "attribution": "LANIS RLP"
}, },
@ -46,6 +46,6 @@
"search": "search":
{ {
"url": "./proxy.php?https://www.geoportal.rlp.de/mapbender/geoportal/gaz_geom_mobile.php?outputFormat=json&resultTarget=web&searchEPSG={epsg}&maxResults=5&maxRows=5&featureClass=P&style=full&searchText={q}&name_startsWith={q}" "url": "/client/proxy?https://www.geoportal.rlp.de/mapbender/geoportal/gaz_geom_mobile.php?outputFormat=json&resultTarget=web&searchEPSG={epsg}&maxResults=5&maxRows=5&featureClass=P&style=full&searchText={q}&name_startsWith={q}"
} }
} }

View File

@ -1,22 +0,0 @@
<?php
//$query = urldecode( $_GET[ "q" ] );
$query = urldecode( $_SERVER[ "QUERY_STRING" ] );
// Open the Curl session
$session = curl_init( $query );
// Don't return HTTP headers. Do return the contents of the call
curl_setopt( $session, CURLOPT_HEADER, false );
curl_setopt( $session, CURLOPT_RETURNTRANSFER, true );
// Make the call
$response = curl_exec( $session );
// Output
header( "Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept" );
header( "Access-Control-Allow-Origin: *" );
header( "Content-Type: application/json" );
echo $response;
curl_close( $session );