diff --git a/application/core/filters.py b/application/core/filters.py index c6022167..a415956d 100644 --- a/application/core/filters.py +++ b/application/core/filters.py @@ -166,7 +166,10 @@ def get_entity_name(entity): def digital_land_to_json(dict): - filtered_dict = {k: v for k, v in dict.items() if k != "geometry"} + filtered_dict = dict.get("row", {}) + is_truncated = dict.get("is_truncated", False) + if is_truncated: + filtered_dict = {k: v for k, v in filtered_dict.items() if k != "geometry"} # dict["geometry"] = dict["geometry"][:1000] return json.dumps( filtered_dict, default=str, indent=4, cls=NoneToEmptyStringEncoder diff --git a/application/templates/entity.html b/application/templates/entity.html index 12a77aec..c9c6af39 100644 --- a/application/templates/entity.html +++ b/application/templates/entity.html @@ -8,12 +8,16 @@ {%- from "components/entity-field/macro.jinja" import entityField %} {%- from "components/back-button/macro.jinja" import dlBackButton %} +{% set is_truncated = false %} {% if row['geometry'] %} - {% set truncated_geometry = row['geometry'][:10000] %} - {% set full_geometry = row['geometry'] %} + {% if row['geometry']|length > 10000 %} + {% set is_truncated = true %} + {% set truncated_geometry = row['geometry'][:10000] %} + {% else %} + {% set truncated_geometry = row['geometry'] %} + {% endif %} {% else %} {% set truncated_geometry = "" %} - {% set full_geometry = "" %} {% endif %} @@ -29,6 +33,7 @@ {%- endif %} {% set geometry_url = "/entity/" + row["entity"] | string + ".geojson" if row['typology'] == "geography" else None %} +{% set geometry_json_url = "/entity/" + row["entity"] | string + ".json" if row['typology'] == "geography" else None %} {% set geojson_data = entity %} {% if geometry_url or geojson_features %} @@ -93,7 +98,7 @@

{{ row_name }}

{% if field == 'geometry' %} {% if row[field] is not none %} - {{ row[field][:10000] }}{% if row[field]|length > 10000 %}... Load More{% endif %} + {{ truncated_geometry }}{% if row[field]|length > 10000 %}... Load More{% endif %} {% endif %}