Skip to content

Commit

Permalink
EV sort index
Browse files Browse the repository at this point in the history
  • Loading branch information
easbar committed Feb 10, 2024
1 parent da7d080 commit b76f823
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
21 changes: 5 additions & 16 deletions core/src/main/java/com/graphhopper/GraphHopper.java
Original file line number Diff line number Diff line change
Expand Up @@ -609,22 +609,7 @@ protected EncodingManager buildEncodingManager(Map<String, PMap> encodedValuesWi
.toList());
profilesByName.values().forEach(profile -> encodedValues.add(Subnetwork.create(profile.getName())));

// sort the encoded values, just so it is easier to compare with previous versions...
List<String> sortedEVs = new ArrayList<>();
vehiclePropsByVehicle.keySet().forEach(vehicle -> {
sortedEVs.add(VehicleAccess.key(vehicle));
sortedEVs.add(VehicleSpeed.key(vehicle));
sortedEVs.add(VehiclePriority.key(vehicle));
});
profilesByName.keySet().forEach(profile -> {
sortedEVs.add(Subnetwork.key(profile));
});
sortedEVs.add(MaxSpeedEstimated.KEY);
sortedEVs.add(UrbanDensity.KEY);
sortedEVs.addAll(List.of("max_speed", "road_class", "road_class_link", "road_environment", "road_access", "surface", "smoothness",
"hazmat", "hazmat_tunnel", "hazmat_water", "toll", "track_type", "max_weight", "max_width", "max_height", "max_length", "lanes",
"hike_rating", "mtb_rating", "horse_rating", "average_slope", "max_slope", "curvature", "bike_network", "mtb_network", "foot_network",
"country", "urban_ee", "hgv", "crossing", "roundabout", "ferry_speed", "get_off_bike"));
List<String> sortedEVs = getEVSortIndex();
encodedValues.sort(Comparator.comparingInt(ev -> sortedEVs.indexOf(ev.getName())));

EncodingManager.Builder emBuilder = new EncodingManager.Builder();
Expand All @@ -635,6 +620,10 @@ protected EncodingManager buildEncodingManager(Map<String, PMap> encodedValuesWi
return emBuilder.build();
}

protected List<String> getEVSortIndex() {
return Collections.emptyList();
}

protected OSMParsers buildOSMParsers(Map<String, PMap> encodedValuesWithProps, Map<String, ImportUnit> activeImportUnits, Map<String, PMap> vehiclesWithProps,
List<String> ignoredHighways, String dateRangeParserString) {
ImportUnitSorter sorter = new ImportUnitSorter(activeImportUnits);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ public void testNothingHappensWhenFlagEncodersAreChangedForLoad() {
setGraphHopperLocation(ghLoc);
instance.load();
assertEquals(5, instance.getBaseGraph().getNodes());
assertEquals("foot_access,foot_average_speed,foot_priority,car_access,car_average_speed,foot_subnetwork,car_subnetwork,max_speed,road_class,road_class_link,road_environment,foot_network,roundabout,ferry_speed",
assertEquals("road_class,road_environment,roundabout,road_class_link,max_speed,foot_access,foot_average_speed,foot_priority,foot_network,car_access,car_average_speed,ferry_speed,foot_subnetwork,car_subnetwork",
instance.getEncodingManager().getEncodedValues().stream().map(EncodedValue::getName).collect(Collectors.joining(",")));
}

Expand Down Expand Up @@ -530,7 +530,7 @@ public void testFailsForWrongEVConfig() {
setOSMFile(testOsm3);
instance.load();
assertEquals(5, instance.getBaseGraph().getNodes());
assertEquals("foot_access,foot_average_speed,foot_priority,car_access,car_average_speed,foot_subnetwork,car_subnetwork,max_speed,road_class,road_class_link,road_environment,foot_network,roundabout,ferry_speed", instance.getEncodingManager().getEncodedValues().stream().map(EncodedValue::getName).collect(Collectors.joining(",")));
assertEquals("road_class,road_environment,roundabout,road_class_link,max_speed,foot_access,foot_average_speed,foot_priority,foot_network,car_access,car_average_speed,ferry_speed,foot_subnetwork,car_subnetwork", instance.getEncodingManager().getEncodedValues().stream().map(EncodedValue::getName).collect(Collectors.joining(",")));
}

@Test
Expand Down

0 comments on commit b76f823

Please sign in to comment.