# New API mapping on old client #601

Merged
mpeltriaux merged 1 commits from #600_Neue_Geodienste into master 2026-10-31 17:08:18 +01:00
3 changed files with 102 additions and 25 deletions

No files matched your search

+79 -2
View File
@@ -11,6 +11,7 @@ from json import JSONDecodeError
import requests
import urllib3.util
from django.contrib.auth.decorators import login_required
from django.contrib.gis import geos
from django.http import JsonResponse, HttpRequest, HttpResponse
from django.utils.decorators import method_decorator
from django.utils.http import urlencode
@@ -18,7 +19,7 @@ from django.views import View
from requests.auth import HTTPDigestAuth
from konova.sub_settings.lanis_settings import MAP_PROXY_HOST_WHITELIST
from konova.sub_settings.lanis_settings import MAP_PROXY_HOST_WHITELIST, DEFAULT_SRID_RLP
from konova.sub_settings.proxy_settings import PROXIES, GEOPORTAL_RLP_USER, GEOPORTAL_RLP_PASSWORD
@@ -76,7 +77,83 @@ class ClientProxyParcelSearch(BaseClientProxyView):
raise PermissionError(f"Proxied url '{url}' is not allowed!")
content, response_code = self.perform_url_call(url)
return HttpResponse(content)
content = json.loads(content)
try:
content = self.__process_response_into_old_client_format(content, url)
except KeyError:
pass
return JsonResponse(content)
def __process_response_into_old_client_format(self, content: dict, url: str) -> dict:
""" Returns the response in a structure which is compatible with the old netgis mapclient.
THIS METHOD IS TEMPORARILY USED AND WILL NOT BE NEEDED ANYMORE, ONCE THE MAPCLIENT IS CAPABLE OF PROCESSING
THE NEW API'S STRUCTURE!
Args:
content (dict): The api response body
url (str): The called api url
Returns:
backwards_compatible_content (dict): The restructured content
"""
def process_parcel_response_into_old_client_format(content: dict):
""" Processes parcel responses in a way that the old client can interpret them
Args:
content (dict): The new API response content
Returns:
backward_compatible_content (dict): The old client input content
"""
backward_compatible_content = {
"count": content["count"],
"data": [
{
"fln": elem["flur"],
"fsn_zae": elem["zaehler"],
"fsn_nen": elem["nenner"],
"fsk": elem["kennzeichen"],
"flaeche": elem["flaeche"],
"geometry": geos.fromstr(json.dumps(elem["geometry"])).transform(DEFAULT_SRID_RLP,
clone=True).wkt,
}
for elem in content["results"]
]
}
return backward_compatible_content
def process_gemarkung_response_into_old_client_format(content: dict):
""" Processes gemarkung responses in a way that the old client can interpret them
Args:
content (dict): The new API response content
Returns:
backward_compatible_content (dict): The old client input content
"""
content = content["results"]
backward_compatible_content = {
"data": [{"gmk_name": element["name"], "gmk_gmn": element["id"]} for element in content]
}
return backward_compatible_content
backwards_compatible_handling = {
"flurstueck_search.php": process_parcel_response_into_old_client_format,
"gemarkung_search.php": process_gemarkung_response_into_old_client_format,
}
backwards_compatible_handling_method = None
for key, method in backwards_compatible_handling.items():
if key in url:
backwards_compatible_handling_method = method
break
if backwards_compatible_handling_method is not None:
content = backwards_compatible_handling_method(content)
return content
class ClientProxyParcelWFS(BaseClientProxyView):
+22 -22
View File
@@ -62,33 +62,33 @@
{ "id": "dtk_farbe", "folder": "bg", "type": "WMS", "order": -1, "title": "DTK5 farbig", "attribution": "LVermGeo", "url": "https://geo4.service24.rlp.de/wms/dtk5_rp.fcgi?", "name": "rp_dtk5", "active": false },
{ "id": "dtk_grau", "folder": "bg", "type": "WMS", "order": -1, "title": "DTK5 grau", "attribution": "LVermGeo", "url": "https://geo4.service24.rlp.de/wms/dtk5_rp.fcgi?", "name": "rp_dtk5_grau", "active": false },
{ "id": "kom", "folder": "kom", "type": "WMS", "title": "KOM", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_recorded&", "name": "kom_recorded" },
{ "id": "kom_rec", "folder": "kom", "type": "WMS", "title": "KOM - In Bearbeitung", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_unrecorded&", "name": "kom_unrecorded" },
{ "id": "kom_rec_unfinished", "folder": "kom", "type": "WMS", "title": "KOM - Unvollständige Altfälle", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=kom_unrecorded_old_entries&", "name": "kom_unrecorded_old_entries" },
{ "id": "kom", "folder": "kom", "type": "WMS", "title": "KOM", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=kom_recorded&", "name": "kom_recorded" },
{ "id": "kom_rec", "folder": "kom", "type": "WMS", "title": "KOM - In Bearbeitung", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=kom_unrecorded&", "name": "kom_unrecorded" },
{ "id": "kom_rec_unfinished", "folder": "kom", "type": "WMS", "title": "KOM - Unvollständige Altfälle", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=kom_unrecorded_old_entries&", "name": "kom_unrecorded_old_entries" },
{ "id": "eiv", "folder": "eiv", "type": "WMS", "title": "EIV", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=eiv_recorded&", "name": "eiv_recorded" },
{ "id": "eiv_rec", "folder": "eiv", "type": "WMS", "title": "EIV - In Bearbeitung", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=eiv_unrecorded&", "name": "eiv_unrecorded" },
{ "id": "eiv_rec_unfinished", "folder": "eiv", "type": "WMS", "title": "EIV - Unvollständige Altfälle", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=eiv_unrecorded_old_entries&", "name": "eiv_unrecorded_old_entries" },
{ "id": "eiv", "folder": "eiv", "type": "WMS", "title": "EIV", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=eiv_recorded&", "name": "eiv_recorded" },
{ "id": "eiv_rec", "folder": "eiv", "type": "WMS", "title": "EIV - In Bearbeitung", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=eiv_unrecorded&", "name": "eiv_unrecorded" },
{ "id": "eiv_rec_unfinished", "folder": "eiv", "type": "WMS", "title": "EIV - Unvollständige Altfälle", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=eiv_unrecorded_old_entries&", "name": "eiv_unrecorded_old_entries" },
{ "id": "oek", "folder": "oek", "type": "WMS", "title": "OEK", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=oek_recorded&", "name": "oek_recorded" },
{ "id": "oek_rec", "folder": "oek", "type": "WMS", "title": "OEK - In Bearbeitung", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=oek_unrecorded&", "name": "oek_unrecorded" },
{ "id": "oek", "folder": "oek", "type": "WMS", "title": "OEK", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=oek_recorded&", "name": "oek_recorded" },
{ "id": "oek_rec", "folder": "oek", "type": "WMS", "title": "OEK - In Bearbeitung", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=oek_unrecorded&", "name": "oek_unrecorded" },
{ "id": "ema", "folder": "ema", "type": "WMS", "title": "EMA", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=ema_recorded&", "name": "ema_recorded" },
{ "id": "ema_rec", "folder": "ema", "type": "WMS", "title": "EMA - In Bearbeitung", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=ema_unrecorded&", "name": "ema_unrecorded" },
{ "id": "ema", "folder": "ema", "type": "WMS", "title": "EMA", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=ema_recorded&", "name": "ema_recorded" },
{ "id": "ema_rec", "folder": "ema", "type": "WMS", "title": "EMA - In Bearbeitung", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=ema_unrecorded&", "name": "ema_unrecorded" },
{ "id": "mae", "folder": "mae", "type": "WMS", "title": "MAE", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=mae&", "name": "mae" },
{ "id": "mae", "folder": "mae", "type": "WMS", "title": "MAE", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=mae&", "name": "mae" },
{ "id": "nsg", "folder": "schutzgebiet", "type": "WMS", "title": "Naturschutzgebiete", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=naturschutzgebiet&", "name": "naturschutzgebiet" },
{ "id": "npz", "folder": "schutzgebiet", "type": "WMS", "title": "Naturparkzonen", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=naturparkzonen&", "name": "naturparkzonen" },
{ "id": "lsg", "folder": "schutzgebiet", "type": "WMS", "title": "Landschaftsschutzgebiete", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=landschaftsschutzgebiet&", "name": "landschaftsschutzgebiet" },
{ "id": "vsg", "folder": "schutzgebiet", "type": "WMS", "title": "Vogelschutzgebiete", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=vogelschutzgebiet&", "name": "vogelschutzgebiet" },
{ "id": "ffh", "folder": "schutzgebiet", "type": "WMS", "title": "FFH Gebiete", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=ffh&", "name": "ffh" },
{ "id": "nsg", "folder": "schutzgebiet", "type": "WMS", "title": "Naturschutzgebiete", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=naturschutzgebiet&", "name": "naturschutzgebiet" },
{ "id": "npz", "folder": "schutzgebiet", "type": "WMS", "title": "Naturparkzonen", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=naturparkzone&", "name": "naturparkzone" },
{ "id": "lsg", "folder": "schutzgebiet", "type": "WMS", "title": "Landschaftsschutzgebiete", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=landschaftsschutzgebiet&", "name": "landschaftsschutzgebiet" },
{ "id": "vsg", "folder": "schutzgebiet", "type": "WMS", "title": "Vogelschutzgebiete", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=vogelschutzgebiet&", "name": "vogelschutzgebiet" },
{ "id": "ffh", "folder": "schutzgebiet", "type": "WMS", "title": "FFH Gebiete", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=ffhgebiet&", "name": "ffhgebiet" },
{"id": "ntpz", "folder": "nationalpark", "type": "WMS", "title": "Nationalpark Zonen", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=nationalpark_zonen&", "name": "nationalpark_zonen" },
{"id": "ntpg", "folder": "nationalpark", "type": "WMS", "title": "Nationalpark Grenzen", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=nationalpark_grenze&", "name": "nationalpark_grenze" },
{"id": "ntpz", "folder": "nationalpark", "type": "WMS", "title": "Nationalpark Zonen", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=nationalparkzonen&", "name": "nationalparkzonen" },
{"id": "ntpg", "folder": "nationalpark", "type": "WMS", "title": "Nationalpark Grenzen", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/2d/mapserver/map.php?layers=nationalpark&", "name": "nationalpark" },
{ "id": "natraum_g", "folder": "naturraum", "type": "WMS", "title": "Naturräume Grenzen", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=natraum_lkompvo_grenzen&", "name": "natraum_lkompvo_grenzen" },
{ "id": "natraum_f", "folder": "naturraum", "type": "WMS", "title": "Naturräume Flächen", "url": "https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_ogc/wms_getmap.php?mapfile=natraum_lkompvo&", "name": "natraum_lkompvo" },
{ "id": "natraum_g", "folder": "naturraum", "type": "WMS", "title": "Naturräume Grenzen", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/apps/service/wms_getmap.php?mapfile=natraum_lkompvo_grenzen&", "name": "natraum_lkompvo_grenzen" },
{ "id": "natraum_f", "folder": "naturraum", "type": "WMS", "title": "Naturräume Flächen", "url": "https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/apps/service/wms_getmap.php?mapfile=natraum_lkompvo&", "name": "natraum_lkompvo" },
{ "id": "lagebezeichnung", "folder": "alkis", "type": "WMS", "title": "Lagebezeichnungen", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Lagebezeichnungen" },
{ "id": "flurstueck_wms", "folder": "alkis", "type": "WMS", "title": "Flurstücke (WMS)", "url": "https://geo5.service24.rlp.de/wms/liegenschaften_rp.fcgi?", "name": "Flurstueck", "active": true},
@@ -129,8 +129,8 @@
"searchparcel":
{
"open": false,
"name_url": "/client/proxy?https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/gem_search.php?placename={q}",
"parcel_url": "/client/proxy?https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/flur_search.php?gmk_gmn={district}&fln={field}&fsn_zae={parcelA}&fsn_nen={parcelB}&export=json",
"name_url": "/client/proxy?https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/module/flurstuecksuche/api/gemarkung_search.php?q={q}",
"parcel_url": "/client/proxy?https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/module/flurstuecksuche/api/flurstueck_search.php?gemarkung={district}&flur={field}&zaehler={parcelA}&nenner={parcelB}&export=json",
"districts_service":
{
"type": "WFS",
+1 -1
View File
@@ -400,7 +400,7 @@ netgis.Search.prototype.clearResults=function(){this.results.innerHTML="";this.m
netgis.Search.prototype.showClearButton=function(a){!1===a?(this.button.classList.remove("netgis-hide"),this.closer.classList.add("netgis-hide")):(this.button.classList.add("netgis-hide"),this.closer.classList.remove("netgis-hide"))};netgis.Search.prototype.onInputKeyDown=function(a){if(13===a.keyCode)return a.preventDefault(),!1};
netgis.Search.prototype.onInputKeyUp=function(a){switch(a.keyCode){case 13:if(this.autocomplete)a=this.results.getElementsByTagName("button"),0<a.length&&a[0].click();else this.onInputTimeout();break;case 27:this.clearAll();break;default:if(this.autocomplete)this.onInputChange()}};netgis.Search.prototype.onInputChange=function(a){this.timeout&&window.clearTimeout(this.timeout);this.timeout=window.setTimeout(this.onInputTimeout.bind(this),this.debounce)};
netgis.Search.prototype.onInputTimeout=function(){var a=this.input.value;a=a.trim();0<a.length?this.requestSearch(a):this.clearAll()};netgis.Search.prototype.onButtonClick=function(a){this.input.focus()};netgis.Search.prototype.onCloserClick=function(a){this.clearAll();this.input.focus()};netgis.Search.prototype.onResultClick=function(a){a=a.currentTarget;var b=a.getAttribute("data-result");netgis.util.invoke(a,netgis.Events.SEARCH_SELECT,{item:a,data:b})};netgis=netgis||{};netgis.SearchParcel=function(a){this.config=a;this.districtsLayerID="searchparcel_districts";this.fieldsLayerID="searchparcel_fields";this.parcelsLayerID="searchparcel_parcels";this.selected={};this.initElements();this.initEvents();this.initConfig(a)};
netgis.SearchParcel.Config={open:!1,name_url:"./proxy.php?https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/gem_search.php?placename={q}",parcel_url:"./proxy.php?https://geodaten.naturschutz.rlp.de/kartendienste_naturschutz/mod_alkis/flur_search.php?gmk_gmn={district}&fln={field}&fsn_zae={parcelA}&fsn_nen={parcelB}&export=json",districts_service:{type:"WFS",url:"http://geo5.service24.rlp.de/wfs/verwaltungsgrenzen_rp.fcgi?",name:"vermkv:gemarkungen_rlp",format:"application/json; subtype=geojson",
netgis.SearchParcel.Config={open:!1,name_url:"./proxy.php?https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/module/flurstuecksuche/api/gemarkung_search.php?q={q}",parcel_url:"./proxy.php?https://geoportal.naturschutz.rlp.de/kartendienst_naturschutz/module/flurstuecksuche/api/flurstueck_search.php?gemarkung={district}&flur={field}&zaehler={parcelA}&nenner={parcelB}&export=json",districts_service:{type:"WFS",url:"http://geo5.service24.rlp.de/wfs/verwaltungsgrenzen_rp.fcgi?",name:"vermkv:gemarkungen_rlp",format:"application/json; subtype=geojson",
min_zoom:12},fields_service:{url:"http://geo5.service24.rlp.de/wfs/verwaltungsgrenzen_rp.fcgi?",name:"vermkv:fluren_rlp",filter_property:"gmkgnr"}};
netgis.SearchParcel.prototype.initElements=function(){this.panel=new netgis.Panel("Flurst\u00fccks-Suche");this.panel.container.style.minWidth="92mm";this.panel.container.addEventListener(netgis.Events.PANEL_TOGGLE,this.onPanelToggle.bind(this));this.container=document.createElement("section");this.container.className="netgis-search-parcel";this.panel.content.appendChild(this.container);this.popup=new netgis.Popup;this.popup.setHeader("Flurst\u00fcck");var a=document.createElement("section");this.top=
a;this.container.appendChild(a);var b=this.createInput("Gemarkungsname:");b.style.position="relative";a.appendChild(b);this.nameInput=b.children[0];this.nameInput.setAttribute("title","ENTER: Ausw\u00e4hlen, ESCAPE: Zur\u00fccksetzen");this.nameInput.addEventListener("keyup",this.onInputNameKey.bind(this));this.nameLoader=document.createElement("div");this.nameLoader.className="netgis-loader netgis-text-primary netgis-hide";this.nameLoader.innerHTML="<i class='fas fa-spinner'></i>";b.appendChild(this.nameLoader);