Skip to content

Commit

Permalink
#56 operationalising with test. Making start with ironing out bugs/mi…
Browse files Browse the repository at this point in the history
…ssing functionality based on unit test. NOT DONE
  • Loading branch information
MarkRaadsen committed May 4, 2024
1 parent 3c56c32 commit 5c97699
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void logSettings() {
LOGGER.info(String.format("Country to base defaults on: %s",getCountryName()));
LOGGER.info(String.format("Setting Coordinate Reference System: %s",getSourceCRS().getName()));
if(hasBoundingBoundary()) {
LOGGER.info(String.format("Network bounding boundary set to: %s",getBoundingArea().toString()));
LOGGER.info(String.format("Network bounding boundary %s",getBoundingArea().toString()));
}

getHighwaySettings().logSettings();
Expand Down
35 changes: 15 additions & 20 deletions src/main/java/org/goplanit/osm/tags/OsmBoundaryTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,20 @@ public class OsmBoundaryTags {
public static final String ADMIN_LEVEL = "admin_level";

/** list all supported values for boundary key */
protected final static UnmodifiableSet<String> boundaryValueTags;

static {
boundaryValueTags = (UnmodifiableSet<String>) Set.of(
ADMINISTRATIVE,
ABORIGINAL,
FOREST,
FOREST_COMPARTMENT,
HAZARD,
HEALTH,
MARITIME,
MARKER,
NATIONAL_PARK,
PLACE,
POLITICAL,
POSTAL_CODE,
PROTECED_AREA
);
}
protected final static Set<String> boundaryValueTags = Set.of(
ADMINISTRATIVE,
ABORIGINAL,
FOREST,
FOREST_COMPARTMENT,
HAZARD,
HEALTH,
MARITIME,
MARKER,
NATIONAL_PARK,
PLACE,
POLITICAL,
POSTAL_CODE,
PROTECED_AREA);

/** get the boundary key tag
*
Expand All @@ -85,7 +80,7 @@ public static String getBoundaryKeyTag() {
*
* @return boundary value tags
*/
public static UnmodifiableSet<String> getBoundaryValues(){
public static Set<String> getBoundaryValues(){
return boundaryValueTags;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/goplanit/osm/util/OsmTagUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static boolean matchesAnyValueTag(final String valueTag, final String...
* @return true when present, false otherwise
*/
public static boolean matchesAnyValueTag(final String valueTag, final Collection<String> valueTags) {
return matchesAnyValueTag(valueTag, (String[])valueTags.toArray());
return matchesAnyValueTag(valueTag, valueTags.toArray(String[]::new));
}

/** Verify if the passed in key matches and of the passed in values in the tags provided, all value tags are filtered by applying {@link VALUETAG_SPECIALCHAR_STRIP_REGEX}
Expand Down
34 changes: 34 additions & 0 deletions src/test/java/org/goplanit/osm/test/MelbourneOsm2PlanitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.goplanit.logging.Logging;
import org.goplanit.osm.converter.OsmBoundary;
import org.goplanit.osm.converter.intermodal.OsmIntermodalReaderSettings;
import org.goplanit.osm.tags.OsmBoundaryTags;
import org.goplanit.utils.id.IdGenerator;
import org.goplanit.utils.locale.CountryNames;
import org.junit.jupiter.api.AfterAll;
Expand Down Expand Up @@ -87,4 +88,37 @@ public void test1Osm2PlanitIntermodalNoServicesBoundingBox() {
}
}

/**
* Test that is identical to {@link this.test1Osm2PlanitIntermodalNoServicesBoundingBox} only now we use a named
* bounding box for the "Melbourne District" which is a political boundary
*/
@Test
public void test2Osm2PlanitIntermodalNoServicesNamedBoundingBox() {

final String PLANIT_OUTPUT_DIR = Path.of(RESOURCE_PATH.toString(),"testcases","planit","melbourne","osm_intermodal_no_services_bb").toAbsolutePath().toString();
final String PLANIT_REF_DIR = Path.of(RESOURCE_PATH.toString(),"planit", "melbourne","osm_intermodal_no_services_named_bb").toAbsolutePath().toString();
try {

var inputSettings = new OsmIntermodalReaderSettings(MELBOURNE_PBF.toAbsolutePath().toString(), CountryNames.AUSTRALIA);
var outputSettings = new PlanitIntermodalWriterSettings(PLANIT_OUTPUT_DIR, CountryNames.AUSTRALIA);

// apply a boundary area based on name (osm relation id: 3898547)
inputSettings.getNetworkSettings().setBoundingArea(
OsmBoundary.of("Melbourne District", OsmBoundaryTags.POLITICAL));

/* minimise warnings Melbourne v2 */
OsmNetworkSettingsTestCaseUtils.melbourneMinimiseVerifiedWarnings(inputSettings.getNetworkSettings());
OsmPtSettingsTestCaseUtils.melbourneMinimiseVerifiedWarnings(inputSettings.getPublicTransportSettings());

Osm2PlanitConversionTemplates.osm2PlanitIntermodalNoServices(inputSettings, outputSettings);

//PlanitAssertionUtils.assertNetworkFilesSimilar(PLANIT_OUTPUT_DIR, PLANIT_REF_DIR);
//PlanitAssertionUtils.assertZoningFilesSimilar(PLANIT_OUTPUT_DIR, PLANIT_REF_DIR);

} catch (Exception e) {
e.printStackTrace();
fail("test1Osm2PlanitIntermodalNoServicesBoundingBox");
}
}

}

0 comments on commit 5c97699

Please sign in to comment.