Skip to content

Commit f91a028

Browse files
authored
fix: missing boundaries warning (#2079)
2 parents cec2dc6 + afb1498 commit f91a028

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

ors-engine/src/main/java/org/heigit/ors/config/profile/ExtendedStorageProperties.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class ExtendedStorageProperties {
6161
@JsonIgnore
6262
private Path openborders;
6363
@JsonIgnore
64-
private Boolean preprocessed = false;
64+
private Boolean preprocessed;
6565

6666
// Relevant for RoadAccessRestrictions
6767
@JsonProperty("use_for_warnings")
@@ -98,6 +98,7 @@ public void merge(ExtendedStorageProperties other) {
9898
outputLog = ofNullable(this.outputLog).orElse(other.outputLog);
9999
logLocation = ofNullable(this.logLocation).orElse(other.logLocation);
100100
maximumSlope = ofNullable(this.maximumSlope).orElse(other.maximumSlope);
101+
preprocessed = ofNullable(this.preprocessed).orElse(other.preprocessed);
101102
boundaries = ofNullable(this.boundaries).orElse(other.boundaries);
102103
ids = ofNullable(this.ids).orElse(other.ids);
103104
openborders = ofNullable(this.openborders).orElse(other.openborders);
@@ -135,6 +136,9 @@ private void setAllPropertiesToNull(ArrayList<String> excludedProperties) {
135136
if (!excludedProperties.contains("maximum_slope")) {
136137
this.maximumSlope = null;
137138
}
139+
if (!excludedProperties.contains("preprocessed")) {
140+
this.preprocessed = null;
141+
}
138142
if (!excludedProperties.contains("boundaries")) {
139143
this.boundaries = null;
140144
}
@@ -230,9 +234,14 @@ private void initializeFilepath(ArrayList<String> nonNullableProperties, Extende
230234

231235
private void initializeBorders(ArrayList<String> nonNullableProperties, ExtendedStorageName storageName) {
232236
final Path emptyPath = Path.of("");
237+
if (preprocessed == null) {
238+
this.preprocessed = false;
239+
}
233240
if (boundaries == null || boundaries.equals(emptyPath)) {
234-
LOGGER.warn("Storage %s is missing boundaries. Disabling storage.".formatted(storageName));
235-
enabled = false;
241+
if (!preprocessed) {
242+
LOGGER.warn("Storage %s is missing boundaries. Disabling storage.".formatted(storageName));
243+
enabled = false;
244+
}
236245
boundaries = Path.of("");
237246
} else {
238247
boundaries = boundaries.toAbsolutePath();
@@ -251,6 +260,7 @@ private void initializeBorders(ArrayList<String> nonNullableProperties, Extended
251260
} else {
252261
openborders = openborders.toAbsolutePath();
253262
}
263+
nonNullableProperties.add("preprocessed");
254264
nonNullableProperties.add("boundaries");
255265
nonNullableProperties.add("ids");
256266
nonNullableProperties.add("openborders");

ors-engine/src/main/java/org/heigit/ors/routing/graphhopper/extensions/storages/builders/BordersGraphStorageBuilder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public class BordersGraphStorageBuilder extends AbstractGraphStorageBuilder {
5757
private BordersGraphStorage storage;
5858
private CountryBordersReader cbReader;
5959
private boolean preprocessed;
60-
6160
private final GeometryFactory gf;
6261

6362
public static final String BUILDER_NAME = "Borders";

ors-engine/src/test/java/org/heigit/ors/config/ExtendedStoragePropertiesTest.java

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ Boolean testStorageObjectIsEmpty(ExtendedStorageProperties storage, ArrayList<St
7070
} else {
7171
assertNotNull(storage.getMaximumSlope(), "maximum_slope should not be null");
7272
}
73+
if (!nonNullFields.contains("preprocessed")) {
74+
assertNull(storage.getPreprocessed(), "preprocessed should be null");
75+
} else {
76+
assertNotNull(storage.getPreprocessed(), "preprocessed should not be null");
77+
}
7378
if (!nonNullFields.contains("boundaries")) {
7479
assertNull(storage.getBoundaries(), "boundaries should be null");
7580
} else {
@@ -135,6 +140,8 @@ void testSetBoundaries() {
135140
assertEquals(Path.of(""), storage.getBoundaries());
136141
}
137142

143+
144+
138145
@Test
139146
void testSetIds() {
140147
HelperClass storage = new HelperClass();
@@ -421,16 +428,18 @@ void assertSetHereTrafficPathLogic(String streets, String refPattern, String pat
421428

422429
// Same for borders
423430
@ParameterizedTest
424-
@CsvSource({"'', '', ''", // All paths null
425-
"'/custom/path.csv', '', ''", // Only boundaries set
426-
"'', '/custom/path.csv', ''", // Only ids set
427-
"'', '', '/custom/path.csv'", // Only openborders set
428-
"'/custom/path.csv', '/custom/path.csv', ''", // boundaries and ids set
429-
"'/custom/path.csv', '', '/custom/path.csv'", // boundaries and openborders set
430-
"'', '/custom/path.csv', '/custom/path.csv'", // ids and openborders set
431-
"'/custom/path.csv', '/custom/path.csv', '/custom/path.csv'" // All paths set -> Enabled!
431+
@CsvSource({"'','', '', '', ''", // All paths null
432+
"'','/custom/path.csv', '', ''", // Only boundaries set
433+
"'','', '/custom/path.csv', ''", // Only ids set
434+
"'','', '', '/custom/path.csv'", // Only openborders set
435+
"'','/custom/path.csv', '/custom/path.csv', ''", // boundaries and ids set
436+
"'','/custom/path.csv', '', '/custom/path.csv'", // boundaries and openborders set
437+
"'','', '/custom/path.csv', '/custom/path.csv'", // ids and openborders set
438+
"'true','', '/custom/path.csv', '/custom/path.csv'",
439+
"'','/custom/path.csv', '/custom/path.csv', '/custom/path.csv'", // All paths set -> Enabled!
440+
"'true','/custom/path.csv', '/custom/path.csv', '/custom/path.csv'"
432441
})
433-
void assertSetBordersPathLogic(String boundaries, String ids, String openborders) {
442+
void assertSetBordersPathLogic(String preprocessed, String boundaries, String ids, String openborders) {
434443
ExtendedStorageProperties storage;
435444
// Test null values
436445
storage = new ExtendedStorageProperties();
@@ -439,13 +448,15 @@ void assertSetBordersPathLogic(String boundaries, String ids, String openborders
439448

440449
// Create JSON string based on parameters
441450
storage = new ExtendedStorageProperties();
451+
var isPreprocessed = Boolean.parseBoolean(preprocessed);
452+
storage.setPreprocessed(isPreprocessed);
442453
storage.setBoundaries(Path.of(boundaries));
443454
storage.setIds(Path.of(ids));
444455
storage.setOpenborders(Path.of(openborders));
445456
storage.initialize(ExtendedStorageName.BORDERS);
446457

447458
// Check if storage is enabled or disabled based on paths
448-
boolean shouldBeEnabled = !boundaries.isEmpty() && !ids.isEmpty() && !openborders.isEmpty();
459+
boolean shouldBeEnabled = (isPreprocessed || !boundaries.isEmpty()) && !ids.isEmpty() && !openborders.isEmpty();
449460
assertEquals(shouldBeEnabled, storage.getEnabled(), "initialize should disable storage if one of the paths is null");
450461

451462
// Check paths
@@ -471,6 +482,7 @@ void assertSetBordersPathLogic(String boundaries, String ids, String openborders
471482
// Assert everything else was set to null
472483
testStorageObjectIsEmpty(storage, new ArrayList<>() {{
473484
add("enabled");
485+
add("preprocessed");
474486
add("boundaries");
475487
add("ids");
476488
add("openborders");

0 commit comments

Comments
 (0)