From 9fe98165c7ff72e1c0741623a141e79352abdd3e Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 4 Nov 2024 17:44:18 +0100 Subject: [PATCH] Fix and changelog - typeof null === 'object' - CI is not run for PRs of first commiters --- CHANGES.md | 4 ++++ src/VectorEncoder.ts | 39 ++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4961a1e..254f362 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # @geoblocks/mapfisprint changes +## 0.2.17 + +- Evaluate geometry functions. + ## 0.2.16 - Make it compatible with OpenLayers 10. diff --git a/src/VectorEncoder.ts b/src/VectorEncoder.ts index 4b2cbeb..a336641 100644 --- a/src/VectorEncoder.ts +++ b/src/VectorEncoder.ts @@ -190,28 +190,29 @@ export default class VectorEncoder { // In some cases, the geometries are objects, in other cases they're functions. // we need to ensure we're handling functions, wether they return an object or not. if (typeof geometry === 'function') { - geometry = geometry(feature); + geometry = geometry(feature); + } + if (geometry && typeof geometry === 'object') { + // note that (typeof null === 'object') + const styledFeature = feature.clone(); + styledFeature.setGeometry(geometry); + geojsonFeature = this.geojsonFormat.writeFeatureObject(styledFeature); + geojsonFeatures.push(geojsonFeature); + } else { + geojsonFeature = origGeojsonFeature; + geometry = feature.getGeometry(); + // no need to encode features with no geometry + if (!geometry) { + return; } - if (typeof geometry === 'object') { - const styledFeature = feature.clone(); - styledFeature.setGeometry(geometry); - geojsonFeature = this.geojsonFormat.writeFeatureObject(styledFeature); + if (!this.customizer_.geometryFilter(geometry)) { + return; + } + if (!isOriginalFeatureAdded) { geojsonFeatures.push(geojsonFeature); - } else { - geojsonFeature = origGeojsonFeature; - geometry = feature.getGeometry(); - // no need to encode features with no geometry - if (!geometry) { - return; - } - if (!this.customizer_.geometryFilter(geometry)) { - return; - } - if (!isOriginalFeatureAdded) { - geojsonFeatures.push(geojsonFeature); - isOriginalFeatureAdded = true; - } + isOriginalFeatureAdded = true; } + } this.addVectorStyle(mapfishStyleObject, geojsonFeature, style); });