From 86bb5f657f7c4743c744b54a18714ac8d2f42e71 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 9 Jan 2024 16:01:10 +0100 Subject: [PATCH 1/2] do not exclude null properties --- tipg/factory.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tipg/factory.py b/tipg/factory.py index b1debf54..7f4f3127 100644 --- a/tipg/factory.py +++ b/tipg/factory.py @@ -756,14 +756,16 @@ async def items( # noqa: C901 ): rows = ( { - k: v - for k, v in { - "collectionId": collection.id, - "itemId": f.get("id"), - **f.get("properties", {}), - "geometry": f.get("geometry", None), - }.items() - if v is not None + **{ + k: v + for k, v in { + "collectionId": collection.id, + "itemId": f.get("id"), + "geometry": f.get("geometry", None), + }.items() + if v is not None + }, + **f.get("properties", {}), } for f in item_list["items"] ) From b0c9d141d2cb01ed6a95ef77a19f112e6c68fd7f Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 9 Jan 2024 16:09:32 +0100 Subject: [PATCH 2/2] do not mix geo and non-geom --- tipg/factory.py | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/tipg/factory.py b/tipg/factory.py index 7f4f3127..5bc5934f 100644 --- a/tipg/factory.py +++ b/tipg/factory.py @@ -754,21 +754,27 @@ async def items( # noqa: C901 MediaType.json, MediaType.ndjson, ): - rows = ( - { - **{ - k: v - for k, v in { - "collectionId": collection.id, - "itemId": f.get("id"), - "geometry": f.get("geometry", None), - }.items() - if v is not None - }, - **f.get("properties", {}), - } - for f in item_list["items"] - ) + if any( + [f.get("geometry", None) is not None for f in item_list["items"]] + ): + rows = ( + { + "collectionId": collection.id, + "itemId": f.get("id"), + **f.get("properties", {}), + "geometry": f.get("geometry", None), + } + for f in item_list["items"] + ) + else: + rows = ( + { + "collectionId": collection.id, + "itemId": f.get("id"), + **f.get("properties", {}), + } + for f in item_list["items"] + ) # CSV Response if output_type == MediaType.csv: