Skip to content

Commit

Permalink
🐛 [#4955] Provide coordinates to objects-api and zgw-apis using lng/l…
Browse files Browse the repository at this point in the history
…at format

The Objects-api and zgw-apis backend registrations expect the geometry coordinates data to follow the lng/lat format.

Our coordinates are saved as [lat,lng], so for these registrations we have to switch the coordinates around

Backport-of: #4957
  • Loading branch information
robinmolen authored and sergei-maertens committed Dec 19, 2024
1 parent 7ad3588 commit a8c848f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
def _point_coordinate(value: Any) -> dict[str, Any] | object:
if not isinstance(value, list) or len(value) != 2:
return SKIP
return {"type": "Point", "coordinates": [value[0], value[1]]}
# Providing the coordinates as [lng, lat] #4955
return {"type": "Point", "coordinates": [value[1], value[0]]}


def build_options(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ interactions:
- request:
body: '{"informatieobjecttype": "http://localhost:8003/catalogi/api/v1/informatieobjecttypen/7a474713-0833-402a-8441-e467c08ac55b",
"bronorganisatie": "000000000", "creatiedatum": "2024-03-19", "titel": "Form
037", "auteur": "Aanvrager", "taal": "nld", "formaat": "application/pdf", "inhoud":
"", "status": "definitief", "bestandsnaam": "open-forms-Form 037.pdf", "beschrijving":
"Ingezonden formulier", "indicatieGebruiksrecht": false, "bestandsomvang": 0}'
024", "auteur": "Aanvrager", "taal": "nld", "formaat": "application/pdf", "inhoud":
"", "status": "definitief", "bestandsnaam": "open-forms-Form 024.pdf", "ontvangstdatum":
null, "beschrijving": "Ingezonden formulier", "indicatieGebruiksrecht": false,
"bestandsomvang": 0}'
headers:
Accept:
- '*/*'
Expand All @@ -15,7 +16,7 @@ interactions:
Connection:
- keep-alive
Content-Length:
- '450'
- '474'
Content-Type:
- application/json
User-Agent:
Expand All @@ -24,9 +25,9 @@ interactions:
uri: http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten
response:
body:
string: '{"url":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/2c9ffadf-210a-4c38-bf48-5d5dc948f51c","identificatie":"DOCUMENT-2024-0000000015","bronorganisatie":"000000000","creatiedatum":"2024-03-19","titel":"Form
037","vertrouwelijkheidaanduiding":"openbaar","auteur":"Aanvrager","status":"definitief","formaat":"application/pdf","taal":"nld","versie":1,"beginRegistratie":"2024-07-05T06:35:16.966133Z","bestandsnaam":"open-forms-Form
037.pdf","inhoud":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/2c9ffadf-210a-4c38-bf48-5d5dc948f51c/download?versie=1","bestandsomvang":0,"link":"","beschrijving":"Ingezonden
string: '{"url":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/ce8a6eb5-e6f8-4f1b-8103-433e36eddcf3","identificatie":"DOCUMENT-2024-0000000091","bronorganisatie":"000000000","creatiedatum":"2024-03-19","titel":"Form
024","vertrouwelijkheidaanduiding":"openbaar","auteur":"Aanvrager","status":"definitief","formaat":"application/pdf","taal":"nld","versie":1,"beginRegistratie":"2024-12-19T12:25:04.784956Z","bestandsnaam":"open-forms-Form
024.pdf","inhoud":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/ce8a6eb5-e6f8-4f1b-8103-433e36eddcf3/download?versie=1","bestandsomvang":0,"link":"","beschrijving":"Ingezonden
formulier","ontvangstdatum":null,"verzenddatum":null,"indicatieGebruiksrecht":false,"verschijningsvorm":"","ondertekening":{"soort":"","datum":null},"integriteit":{"algoritme":"","waarde":"","datum":null},"informatieobjecttype":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/7a474713-0833-402a-8441-e467c08ac55b","locked":false,"bestandsdelen":[],"trefwoorden":[],"lock":""}'
headers:
API-version:
Expand All @@ -40,7 +41,7 @@ interactions:
Cross-Origin-Opener-Policy:
- same-origin
Location:
- http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/2c9ffadf-210a-4c38-bf48-5d5dc948f51c
- http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/ce8a6eb5-e6f8-4f1b-8103-433e36eddcf3
Referrer-Policy:
- same-origin
Vary:
Expand All @@ -55,11 +56,11 @@ interactions:
- request:
body: '{"informatieobjecttype": "http://localhost:8003/catalogi/api/v1/informatieobjecttypen/b2d83b94-9b9b-4e80-a82f-73ff993c62f3",
"bronorganisatie": "000000000", "creatiedatum": "2024-03-19", "titel": "Form
037 (csv)", "auteur": "Aanvrager", "taal": "nld", "formaat": "text/csv", "inhoud":
"Rm9ybXVsaWVybmFhbSxJbnplbmRpbmdkYXR1bSxhZ2UsbGFzdG5hbWUsbG9jYXRpb24NCkZvcm0gMDM3LDIwMjQtMDMtMDEgMDE6NDA6MTkuNDgwOTc5LDIwLE15IGxhc3QgbmFtZSwiWzUyLjM2NjczMzc4OTY3MTIyLCA0Ljg5MzE2NDI3NDQ3MDI5OV0iDQo=",
"status": "definitief", "bestandsnaam": "open-forms-Form 037 (csv).csv", "beschrijving":
"Ingezonden formulierdata", "indicatieGebruiksrecht": false, "bestandsomvang":
146}'
024 (csv)", "auteur": "Aanvrager", "taal": "nld", "formaat": "text/csv", "inhoud":
"Rm9ybXVsaWVybmFhbSxJbnplbmRpbmdkYXR1bSxhZ2UsbGFzdG5hbWUsbG9jYXRpb24NCkZvcm0gMDI0LDIwMjQtMDMtMDggMjI6MDk6NTAuMzg4NTMyLDIwLE15IGxhc3QgbmFtZSwiWzUyLjM2NjczMzc4OTY3MTIyLCA0Ljg5MzE2NDI3NDQ3MDI5OV0iDQo=",
"status": "definitief", "bestandsnaam": "open-forms-Form 024 (csv).csv", "ontvangstdatum":
null, "beschrijving": "Ingezonden formulierdata", "indicatieGebruiksrecht":
false, "bestandsomvang": 146}'
headers:
Accept:
- '*/*'
Expand All @@ -70,7 +71,7 @@ interactions:
Connection:
- keep-alive
Content-Length:
- '657'
- '681'
Content-Type:
- application/json
User-Agent:
Expand All @@ -79,9 +80,9 @@ interactions:
uri: http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten
response:
body:
string: '{"url":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/8cff74cd-3d5a-4f64-8673-0e7764d5a07c","identificatie":"DOCUMENT-2024-0000000016","bronorganisatie":"000000000","creatiedatum":"2024-03-19","titel":"Form
037 (csv)","vertrouwelijkheidaanduiding":"openbaar","auteur":"Aanvrager","status":"definitief","formaat":"text/csv","taal":"nld","versie":1,"beginRegistratie":"2024-07-05T06:35:17.084495Z","bestandsnaam":"open-forms-Form
037 (csv).csv","inhoud":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/8cff74cd-3d5a-4f64-8673-0e7764d5a07c/download?versie=1","bestandsomvang":146,"link":"","beschrijving":"Ingezonden
string: '{"url":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4b7487e1-2479-4cc6-b0d9-f3b08b426604","identificatie":"DOCUMENT-2024-0000000092","bronorganisatie":"000000000","creatiedatum":"2024-03-19","titel":"Form
024 (csv)","vertrouwelijkheidaanduiding":"openbaar","auteur":"Aanvrager","status":"definitief","formaat":"text/csv","taal":"nld","versie":1,"beginRegistratie":"2024-12-19T12:25:04.959507Z","bestandsnaam":"open-forms-Form
024 (csv).csv","inhoud":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4b7487e1-2479-4cc6-b0d9-f3b08b426604/download?versie=1","bestandsomvang":146,"link":"","beschrijving":"Ingezonden
formulierdata","ontvangstdatum":null,"verzenddatum":null,"indicatieGebruiksrecht":false,"verschijningsvorm":"","ondertekening":{"soort":"","datum":null},"integriteit":{"algoritme":"","waarde":"","datum":null},"informatieobjecttype":"http://localhost:8003/catalogi/api/v1/informatieobjecttypen/b2d83b94-9b9b-4e80-a82f-73ff993c62f3","locked":false,"bestandsdelen":[],"trefwoorden":[],"lock":""}'
headers:
API-version:
Expand All @@ -95,7 +96,7 @@ interactions:
Cross-Origin-Opener-Policy:
- same-origin
Location:
- http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/8cff74cd-3d5a-4f64-8673-0e7764d5a07c
- http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4b7487e1-2479-4cc6-b0d9-f3b08b426604
Referrer-Policy:
- same-origin
Vary:
Expand Down Expand Up @@ -124,24 +125,24 @@ interactions:
uri: http://localhost:8001/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48
response:
body:
string: '{"url":"http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48","uuid":"8e46e0a5-b1b4-449b-b9e9-fa3cea655f48","name":"Person","namePlural":"Persons","description":"","dataClassification":"open","maintainerOrganization":"","maintainerDepartment":"","contactPerson":"","contactEmail":"","source":"","updateFrequency":"unknown","providerOrganization":"","documentationUrl":"","labels":{},"createdAt":"2023-10-24","modifiedAt":"2024-02-08","allowGeometry":true,"versions":["http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48/versions/1","http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48/versions/2","http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48/versions/3"]}'
string: '{"url":"http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48","uuid":"8e46e0a5-b1b4-449b-b9e9-fa3cea655f48","name":"Person","namePlural":"Persons","description":"","dataClassification":"open","maintainerOrganization":"","maintainerDepartment":"","contactPerson":"","contactEmail":"","source":"","updateFrequency":"unknown","providerOrganization":"","documentationUrl":"","labels":{},"createdAt":"2023-10-24","modifiedAt":"2024-02-08","allowGeometry":true,"versions":["http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48/versions/2","http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48/versions/3","http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48/versions/1","http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48/versions/4"]}'
headers:
Allow:
- GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Connection:
- keep-alive
Content-Length:
- '790'
- '887'
Content-Type:
- application/json
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Fri, 05 Jul 2024 06:35:17 GMT
- Thu, 19 Dec 2024 12:25:05 GMT
Referrer-Policy:
- same-origin
Server:
- nginx/1.27.0
- nginx/1.27.3
Vary:
- origin
X-Content-Type-Options:
Expand All @@ -155,11 +156,11 @@ interactions:
body: '{"type": "http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48",
"record": {"typeVersion": 3, "data": {"age": 20, "name": {"last.name": "My last
name"}, "submission_date": "2024-03-19T13:40:00+00:00", "submission_pdf_url":
"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/2c9ffadf-210a-4c38-bf48-5d5dc948f51c",
"submission_csv_url": "http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/8cff74cd-3d5a-4f64-8673-0e7764d5a07c",
"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/ce8a6eb5-e6f8-4f1b-8103-433e36eddcf3",
"submission_csv_url": "http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4b7487e1-2479-4cc6-b0d9-f3b08b426604",
"submission_payment_completed": false, "submission_payment_amount": null, "submission_payment_public_ids":
[], "cosign_date": null}, "startAt": "2024-03-19", "geometry": {"type": "Point",
"coordinates": [52.36673378967122, 4.893164274470299]}}}'
"coordinates": [4.893164274470299, 52.36673378967122]}}}'
headers:
Accept:
- '*/*'
Expand All @@ -181,8 +182,8 @@ interactions:
uri: http://localhost:8002/api/v2/objects
response:
body:
string: '{"url":"http://objects-web:8000/api/v2/objects/7e67c555-dd41-4870-a2bc-4601b83b0fd6","uuid":"7e67c555-dd41-4870-a2bc-4601b83b0fd6","type":"http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48","record":{"index":1,"typeVersion":3,"data":{"age":20,"name":{"last.name":"My
last name"},"submission_date":"2024-03-19T13:40:00+00:00","submission_pdf_url":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/2c9ffadf-210a-4c38-bf48-5d5dc948f51c","submission_csv_url":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/8cff74cd-3d5a-4f64-8673-0e7764d5a07c","submission_payment_completed":false,"submission_payment_amount":null,"submission_payment_public_ids":[],"cosign_date":null},"geometry":{"type":"Point","coordinates":[52.36673378967122,4.893164274470299]},"startAt":"2024-03-19","endAt":null,"registrationAt":"2024-07-05","correctionFor":null,"correctedBy":null}}'
string: '{"url":"http://objects-web:8000/api/v2/objects/fabd19c4-36c6-4094-b3f5-24748cf06078","uuid":"fabd19c4-36c6-4094-b3f5-24748cf06078","type":"http://objecttypes-web:8000/api/v2/objecttypes/8e46e0a5-b1b4-449b-b9e9-fa3cea655f48","record":{"index":1,"typeVersion":3,"data":{"age":20,"name":{"last.name":"My
last name"},"submission_date":"2024-03-19T13:40:00+00:00","submission_pdf_url":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/ce8a6eb5-e6f8-4f1b-8103-433e36eddcf3","submission_csv_url":"http://localhost:8003/documenten/api/v1/enkelvoudiginformatieobjecten/4b7487e1-2479-4cc6-b0d9-f3b08b426604","submission_payment_completed":false,"submission_payment_amount":null,"submission_payment_public_ids":[],"cosign_date":null},"geometry":{"type":"Point","coordinates":[4.893164274470299,52.36673378967122]},"startAt":"2024-03-19","endAt":null,"registrationAt":"2024-12-19","correctionFor":null,"correctedBy":null}}'
headers:
Allow:
- GET, POST, HEAD, OPTIONS
Expand All @@ -197,13 +198,13 @@ interactions:
Cross-Origin-Opener-Policy:
- same-origin
Date:
- Fri, 05 Jul 2024 06:35:17 GMT
- Thu, 19 Dec 2024 12:25:05 GMT
Location:
- http://localhost:8002/api/v2/objects/7e67c555-dd41-4870-a2bc-4601b83b0fd6
- http://localhost:8002/api/v2/objects/fabd19c4-36c6-4094-b3f5-24748cf06078
Referrer-Policy:
- same-origin
Server:
- nginx/1.27.0
- nginx/1.27.3
X-Content-Type-Options:
- nosniff
X-Frame-Options:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def test_submission_with_objects_api_backend_override_defaults(self, m):
"startAt": date.today().isoformat(),
"geometry": {
"type": "Point",
"coordinates": [52.36673378967122, 4.893164274470299],
"coordinates": [4.893164274470299, 52.36673378967122],
},
},
}
Expand All @@ -263,7 +263,7 @@ def test_submission_with_objects_api_backend_override_defaults(self, m):
"data": submitted_object_data["record"]["data"],
"geometry": {
"type": "Point",
"coordinates": [52.36673378967122, 4.893164274470299],
"coordinates": [4.893164274470299, 52.36673378967122],
},
"startAt": date.today().isoformat(),
"endAt": None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def test_submission_with_objects_api_v2(self):
result["record"]["geometry"],
{
"type": "Point",
"coordinates": [52.36673378967122, 4.893164274470299],
"coordinates": [4.893164274470299, 52.36673378967122],
},
)

Expand Down Expand Up @@ -473,7 +473,7 @@ def test_submission_with_map_component_inside_data(self):
data["pointCoordinates"],
{
"type": "Point",
"coordinates": [52.36673378967122, 4.893164274470299],
"coordinates": [4.893164274470299, 52.36673378967122],
},
)

Expand Down
3 changes: 2 additions & 1 deletion src/openforms/registrations/contrib/zgw_apis/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def get_property_mappings_from_submission(
def _point_coordinate(value):
if not value or not isinstance(value, list) or len(value) != 2:
return SKIP
return {"type": "Point", "coordinates": [value[0], value[1]]}
# Providing the coordinates as [lng, lat] #4955
return {"type": "Point", "coordinates": [value[1], value[0]]}


def _gender_choices(value):
Expand Down

0 comments on commit a8c848f

Please sign in to comment.