diff --git a/src/openforms/formio/constants.py b/src/openforms/formio/constants.py
index 69e21071ce..d193827a03 100644
--- a/src/openforms/formio/constants.py
+++ b/src/openforms/formio/constants.py
@@ -1,3 +1,5 @@
+from django.db import models
+
COMPONENT_DATATYPES = {
"date": "date",
"time": "time",
@@ -11,3 +13,9 @@
"editgrid": "array",
"datetime": "datetime",
}
+
+
+class GeoJsonGeometryTypes(models.TextChoices):
+ point = "Point", "Point"
+ polygon = "Polygon", "Polygon"
+ line_string = "LineString", "LineString"
diff --git a/src/openforms/formio/formatters/custom.py b/src/openforms/formio/formatters/custom.py
index 6c87744fc9..8d5db8a4d3 100644
--- a/src/openforms/formio/formatters/custom.py
+++ b/src/openforms/formio/formatters/custom.py
@@ -6,6 +6,7 @@
from django.utils.html import format_html
from django.utils.safestring import mark_safe
+from ..constants import GeoJsonGeometryTypes
from ..typing import AddressNLComponent, Component, MapComponent
from .base import FormatterBase
@@ -21,10 +22,26 @@ def format(self, component: Component, value: str) -> str:
return f"{fmt_date(parsed_value)} {fmt_time(parsed_value, 'H:i')}"
+class GeoJsonGeometry(TypedDict):
+ type: str
+ coordinates: list[float] | list[list[float]] | list[list[list[float]]]
+
+
+class GeoJson(TypedDict):
+ type: GeoJsonGeometryTypes
+ properties: dict[str, str]
+ geometry: GeoJsonGeometry
+
+
class MapFormatter(FormatterBase):
- def format(self, component: MapComponent, value: list[float]) -> str:
+ def format(self, component: MapComponent, value: GeoJson) -> str:
# use a comma here since its a single data element
- return ", ".join((str(x) for x in value))
+ if (geometry := value.get("geometry")) and geometry.get(
+ "type"
+ ) in GeoJsonGeometryTypes:
+ return ", ".join((str(x) for x in geometry["coordinates"]))
+ else:
+ return ""
class AddressValue(TypedDict):
diff --git a/src/openforms/registrations/contrib/objects_api/handlers/v2.py b/src/openforms/registrations/contrib/objects_api/handlers/v2.py
index d03093f320..33a1677a8e 100644
--- a/src/openforms/registrations/contrib/objects_api/handlers/v2.py
+++ b/src/openforms/registrations/contrib/objects_api/handlers/v2.py
@@ -9,6 +9,7 @@
from glom import Assign, Path, glom
from openforms.api.utils import underscore_to_camel
+from openforms.formio.constants import GeoJsonGeometryTypes
from openforms.formio.typing import Component
from openforms.typing import JSONObject, JSONValue
@@ -105,13 +106,11 @@ def process_mapped_variable(
value = value[0] if value else ""
case {"type": "map"}:
- # Currently we only support Point coordinates
- assert isinstance(value, list) and len(value) == 2
- value = {
- "type": "Point",
- # Providing the coordinates as [lng, lat] #4955
- "coordinates": [value[1], value[0]],
- }
+ assert isinstance(value, dict)
+ if (geometry := value["geometry"]) and geometry.get(
+ "type"
+ ) in GeoJsonGeometryTypes:
+ value = geometry
# not a component or standard behaviour where no transformation is necessary
case None | _:
diff --git a/src/openforms/registrations/contrib/objects_api/submission_registration.py b/src/openforms/registrations/contrib/objects_api/submission_registration.py
index 11ba2024f1..9870a9e404 100644
--- a/src/openforms/registrations/contrib/objects_api/submission_registration.py
+++ b/src/openforms/registrations/contrib/objects_api/submission_registration.py
@@ -33,6 +33,8 @@
create_csv_document,
create_report_document,
)
+from openforms.formio.constants import GeoJsonGeometryTypes
+from openforms.formio.formatters.custom import GeoJson, GeoJsonGeometry
from openforms.formio.service import FormioData
from openforms.formio.typing import Component
from openforms.registrations.exceptions import RegistrationFailed
@@ -69,11 +71,15 @@
logger = logging.getLogger(__name__)
-def _point_coordinate(value: Any) -> dict[str, Any] | object:
- if not isinstance(value, list) or len(value) != 2:
- return SKIP
- # Providing the coordinates as [lng, lat] #4955
- return {"type": "Point", "coordinates": [value[1], value[0]]}
+def _point_coordinate(value: GeoJson) -> GeoJsonGeometry | object:
+ return (
+ geometry
+ if (
+ (geometry := value.get("geometry"))
+ and geometry.get("type", None) in GeoJsonGeometryTypes
+ )
+ else SKIP
+ )
def _resolve_documenttype(
diff --git a/src/openforms/registrations/contrib/stuf_zds/plugin.py b/src/openforms/registrations/contrib/stuf_zds/plugin.py
index 11077daf60..3ea29bf233 100644
--- a/src/openforms/registrations/contrib/stuf_zds/plugin.py
+++ b/src/openforms/registrations/contrib/stuf_zds/plugin.py
@@ -11,6 +11,8 @@
from json_logic.typing import Primitive
+from openforms.formio.constants import GeoJsonGeometryTypes
+from openforms.formio.formatters.custom import GeoJson
from openforms.plugins.exceptions import InvalidPluginConfiguration
from openforms.registrations.base import BasePlugin, PreRegistrationResult
from openforms.registrations.constants import (
@@ -38,7 +40,7 @@
from ...utils import execute_unless_result_exists
from .options import ZaakOptionsSerializer
from .registration_variables import register as variables_registry
-from .typing import RegistrationOptions
+from .typing import PointCoordinate, RegistrationOptions
from .utils import flatten_data
if TYPE_CHECKING:
@@ -111,10 +113,15 @@ def _safe_int(num):
)
-def _point_coordinate(value):
- if not value or not isinstance(value, list) or len(value) != 2:
- return SKIP
- return {"lat": value[0], "lng": value[1]}
+def _point_coordinate(value: GeoJson) -> PointCoordinate | object:
+ return (
+ geometry
+ if (
+ (geometry := value.get("geometry"))
+ and geometry.get("type", None) in GeoJsonGeometryTypes
+ )
+ else SKIP
+ )
def _gender_choices(value):
diff --git a/src/openforms/registrations/contrib/stuf_zds/typing.py b/src/openforms/registrations/contrib/stuf_zds/typing.py
index 7e56285f46..2682469d1d 100644
--- a/src/openforms/registrations/contrib/stuf_zds/typing.py
+++ b/src/openforms/registrations/contrib/stuf_zds/typing.py
@@ -23,3 +23,8 @@ class RegistrationOptions(TypedDict):
"OPENBAAR",
]
payment_status_update_mapping: NotRequired[list[MappingItem]]
+
+
+class PointCoordinate(TypedDict):
+ lat: float
+ lng: float
diff --git a/src/openforms/registrations/contrib/zgw_apis/plugin.py b/src/openforms/registrations/contrib/zgw_apis/plugin.py
index ae95c28405..019855d723 100644
--- a/src/openforms/registrations/contrib/zgw_apis/plugin.py
+++ b/src/openforms/registrations/contrib/zgw_apis/plugin.py
@@ -26,6 +26,8 @@
create_attachment_document,
create_report_document,
)
+from openforms.formio.constants import GeoJsonGeometryTypes
+from openforms.formio.formatters.custom import GeoJson, GeoJsonGeometry
from openforms.submissions.mapping import SKIP, FieldConf, apply_data_mapping
from openforms.submissions.models import Submission, SubmissionReport
from openforms.utils.date import datetime_in_amsterdam
@@ -75,11 +77,15 @@ def get_property_mappings_from_submission(
return property_mappings
-def _point_coordinate(value):
- if not value or not isinstance(value, list) or len(value) != 2:
- return SKIP
- # Providing the coordinates as [lng, lat] #4955
- return {"type": "Point", "coordinates": [value[1], value[0]]}
+def _point_coordinate(value: GeoJson) -> GeoJsonGeometry | object:
+ return (
+ geometry
+ if (
+ (geometry := value.get("geometry"))
+ and geometry.get("type", None) in GeoJsonGeometryTypes
+ )
+ else SKIP
+ )
def _gender_choices(value):
diff --git a/src/stuf/stuf_zds/templates/stuf_zds/soap/creeerZaak.xml b/src/stuf/stuf_zds/templates/stuf_zds/soap/creeerZaak.xml
index b3b415e755..74f2701ffa 100644
--- a/src/stuf/stuf_zds/templates/stuf_zds/soap/creeerZaak.xml
+++ b/src/stuf/stuf_zds/templates/stuf_zds/soap/creeerZaak.xml
@@ -27,14 +27,32 @@
{% endfor %}
{% if locatie %}
-
- {{ locatie.key }}
-
-
- {{ locatie.lat }} {{ locatie.lng }}
-
+
+ {{ locatie.key }}
+
+ {% if locatie.type == 'Point' %}
+
+ {{ locatie.coordinates.0 }} {{ locatie.coordinates.1 }}
+
+ {% elif locatie.type == 'Polygon' %}
+
+
+
+ {% for coordinates in locatie.coordinates.0 %}
+ {{ coordinates.0 }} {{ coordinates.1 }}
+ {% endfor %}
+
+
+
+ {% elif locatie.type == 'LineString' %}
+
+
+ {% for coordinates in locatie.coordinates %}{{ coordinates.0 }} {{ coordinates.1 }} {% endfor %}
+
+
+ {% endif %}
-
+
{% endif %}
{{ datum_vandaag }}
{{ datum_vandaag }}