# Netgis client update

* integrates newest netgis map client
* generalizes map proxy response handling
This commit is contained in:
2024-11-21 13:46:35 +01:00
parent 6ff67d12c9
commit 457548da4d
6 changed files with 94 additions and 94 deletions

View File

@@ -48,9 +48,7 @@ class SimpleGeomForm(BaseForm):
raise AttributeError
geojson = self.instance.geometry.as_feature_collection(srid=DEFAULT_SRID_RLP)
geojson = self._set_editable_status(geojson)
geojson = self._set_properties(geojson, self.instance.identifier)
geom = json.dumps(geojson)
except AttributeError:
# If no geometry exists for this form, we simply set the value to None and zoom to the maximum level
@@ -227,7 +225,7 @@ class SimpleGeomForm(BaseForm):
geom = gdal.OGRGeometry(g_wkt)
return geom
def _set_editable_status(self, geojson: dict):
def _set_properties(self, geojson: dict, title: str):
""" Toggles the editable property of the geojson for proper handling in map client
Args:
@@ -238,7 +236,7 @@ class SimpleGeomForm(BaseForm):
"""
features = geojson.get("features", [])
for feature in features:
feature["properties"] = {
"editable": not self.read_only
}
feature["properties"]["editable"] = not self.read_only
if title:
feature["properties"]["title"] = title
return geojson

View File

@@ -342,6 +342,7 @@ class Geometry(BaseResource):
{
"type": "Feature",
"geometry": json.loads(p.json),
"properties": {},
}
for p in polygons
]

View File

@@ -10,11 +10,10 @@ from json import JSONDecodeError
import requests
from django.contrib.auth.decorators import login_required
from django.http import JsonResponse, HttpRequest
from django.http import JsonResponse, HttpRequest, HttpResponse
from django.utils.decorators import method_decorator
from django.utils.http import urlencode
from django.views import View
from django.utils.translation import gettext_lazy as _
from requests.auth import HTTPDigestAuth
@@ -60,24 +59,7 @@ class ClientProxyParcelSearch(BaseClientProxyView):
def get(self, request: HttpRequest):
url = request.META.get("QUERY_STRING")
content, response_code = self.perform_url_call(url)
try:
body = json.loads(content)
except JSONDecodeError as e:
body = {
"totalResultsCount": -1,
"geonames": [
{
"title": _("The external service is currently unavailable.<br>Please try again in a few moments...")
}
]
}
if response_code != 200:
return JsonResponse({
"status_code": response_code,
"content": body,
})
return JsonResponse(body)
return HttpResponse(content)
class ClientProxyParcelWFS(BaseClientProxyView):