From 4936c7eaa78e4bb38501d7ae75325e1e9d256b18 Mon Sep 17 00:00:00 2001 From: Walter Lorenzetti Date: Wed, 22 Nov 2023 14:27:19 +0100 Subject: [PATCH] Fix crs property of layer in /api/config API REST. (#658) Co-authored-by: wlorenzetti --- g3w-admin/qdjango/api/projects/serializers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/g3w-admin/qdjango/api/projects/serializers.py b/g3w-admin/qdjango/api/projects/serializers.py index c7efcba94..fbc06e57a 100644 --- a/g3w-admin/qdjango/api/projects/serializers.py +++ b/g3w-admin/qdjango/api/projects/serializers.py @@ -823,16 +823,22 @@ def to_representation(self, instance): # Patch for Proj4 > 4.9.3 version if ret["crs"] in settings.G3W_PROJ4_EPSG.keys(): - proj4 = settings.G3W_PROJ4_EPSG[ret["crs"]] + proj4 = settings.G3W_PROJ4_EPSG[ret["crs"]]['proj4'] + extent = settings.G3W_PROJ4_EPSG[ret["crs"]]['extent'] + else: proj4 = crs.toProj4() + if crs.postgisSrid() in (4326, 3857): + extent = get_crs_bbox(crs) + else: + extent = [0, 0, 8388608, 8388608] ret['crs'] = { 'epsg': crs.postgisSrid(), 'proj4': proj4, 'geographic': crs.isGeographic(), 'axisinverted': crs.hasAxisInverted(), - 'extent': get_crs_bbox(crs) + 'extent': extent } # add metadata