Skip to content

Commit

Permalink
Do not include features with geometries null or empty (after clipping)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaime committed Mar 8, 2024
1 parent 700e84c commit 527d0df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class MapMLGenerator {
/**
* @param sf a feature
* @param featureCaptionTemplate - template optionally containing ${placeholders}. Can be null.
* @return the feature
* @return the feature, or null if clipping removed its geometry
* @throws IOException - IOException
*/
public Feature buildFeature(SimpleFeature sf, String featureCaptionTemplate)
Expand Down Expand Up @@ -102,6 +102,7 @@ public Feature buildFeature(SimpleFeature sf, String featureCaptionTemplate)
if (g != null && !g.isEmpty() && clipBounds != null) {
MapMLGeometryClipper clipper = new MapMLGeometryClipper(g, clipBounds);
g = clipper.clipAndTag();
if (g == null || g.isEmpty()) return null;
}
f.setGeometry(buildGeometry(g));
return f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,12 @@ public void write(
featureBuilder.buildFeature(
feature,
captionTemplates.get(fc.getSchema().getName()));
// might be interesting to be able to put features
// from different layers into a layer-specific div
features.add(f);
// returning null features is WMS specific, but just in case, check
if (f != null) {
// might be interesting to be able to put features
// from different layers into a layer-specific div
features.add(f);
}
} catch (IllegalStateException e) {
LOGGER.log(Level.INFO, "Error transforming feature.");
}
Expand Down

0 comments on commit 527d0df

Please sign in to comment.