From bdb5140b476c25814c06326c6a6e2fc8bc7fe25f Mon Sep 17 00:00:00 2001 From: Alicia Date: Wed, 20 Sep 2023 13:16:39 +0200 Subject: [PATCH] added coalesce to avoid issue when property does not exist --- api/apps/geoprocessing/src/modules/features/features.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/apps/geoprocessing/src/modules/features/features.service.ts b/api/apps/geoprocessing/src/modules/features/features.service.ts index f0758f4942..701e878ff3 100644 --- a/api/apps/geoprocessing/src/modules/features/features.service.ts +++ b/api/apps/geoprocessing/src/modules/features/features.service.ts @@ -74,7 +74,7 @@ export class FeatureService { const { z, x, y, id } = tileSpecification; const simplificationLevel = 360/(Math.pow(2, z+1)*100); const attributes = 'feature_id, properties'; - const table = `(select ST_RemoveRepeatedPoints((st_dump(the_geom)).geom, ${simplificationLevel}) as the_geom, (properties || jsonb_build_object('amount', amount)) as properties, feature_id from "${this.featuresRepository.metadata.tableName}")`; + const table = `(select ST_RemoveRepeatedPoints((st_dump(the_geom)).geom, ${simplificationLevel}) as the_geom, (coalesce(properties,'{}'::jsonb) || jsonb_build_object('amount', amount)) as properties, feature_id from "${this.featuresRepository.metadata.tableName}")`; const customQuery = this.buildFeaturesWhereQuery(id, bbox); return this.tileService.getTile({ z,