Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ public void initConstructUtils(ObjectMapper mapper) {
public void init() {
// register modudle for json serializing
mapper.registerModule(new JsonNullableModule());
// configure ObjectMapper to exclude null fields while serializing
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
// Configure ObjectMapper to exclude null fields while serializing
mapper.setDefaultPropertyInclusion(
JsonInclude.Value.construct(
JsonInclude.Include.NON_NULL,
JsonInclude.Include.USE_DEFAULTS
)
);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ private static Map<String, Geometry> loadStaticMap(String path, String keyField)
if (properties != null) {
JsonNode objectId = properties.get(keyField);
if (objectId != null) {
String key = objectId.asText();
// This is used to avoid the trailing zeros in the number, for example 123.0 in key,
// where the React frontend with javascript number type will parse the number to 123
// and cause the key mismatch with the map.
final String key = objectId.isNumber()
? objectId.decimalValue().stripTrailingZeros().toPlainString()
: objectId.asText();
JsonNode geometry = feature.get("geometry");
if (geometry != null) {
String geoJson = mapper.writeValueAsString(geometry);
Expand Down Expand Up @@ -82,8 +87,11 @@ public IBoundaryFunction(List<Expression> parameters, Literal fallback) {
public Object evaluate(Object feature) {
String name = getParameters().get(0).evaluate(feature, String.class);
String id = getParameters().get(1).evaluate(feature, String.class);

return getGeoJsonFromMap(name, id);
Geometry geometry = getGeoJsonFromMap(name, id);
if(geometry == null) {
log.warn("IBoundaryFunction lookup failed: name={}, id={}", name, id);
}
return geometry;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ public void testIBoundaryFunction() {
assertInstanceOf(Geometry.class, geom);
}

@Test
public void testMeowKeyNormalization() {
// Meow.json has ECO_CODE like 20192.0 (as JSON number), React/JS does String(20192.0) === '20192'
// so loadStaticMap must store keys without trailing .0 to avoid lookup mismatch
assertNotNull(IBoundaryFunction.MEOW.get("20192"), "Expected key '20192' for MEOW (from 20192.0)");
assertNotNull(IBoundaryFunction.MEOW.get("20053"));
assertNull(IBoundaryFunction.MEOW.get("20192.0"), "Should not have .0 suffixed key");
}

@Test
public void testIBoundaryWithCQL() throws Exception {
// Parse full CQL2 string
Expand Down
Loading