Skip to content

Commit

Permalink
Fix and changelog
Browse files Browse the repository at this point in the history
- typeof null === 'object'
- CI is not run for PRs of first commiters
  • Loading branch information
gberaudo committed Nov 4, 2024
1 parent d306253 commit 9fe9816
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @geoblocks/mapfisprint changes

## 0.2.17

- Evaluate geometry functions.

## 0.2.16

- Make it compatible with OpenLayers 10.
Expand Down
39 changes: 20 additions & 19 deletions src/VectorEncoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 9fe9816

Please sign in to comment.