From b76f8231c10a3a142cce0e0bf576209bfcb9fbfe Mon Sep 17 00:00:00 2001 From: easbar Date: Sat, 10 Feb 2024 10:52:53 +0100 Subject: [PATCH] EV sort index --- .../java/com/graphhopper/GraphHopper.java | 21 +++++-------------- .../reader/osm/GraphHopperOSMTest.java | 4 ++-- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/core/src/main/java/com/graphhopper/GraphHopper.java b/core/src/main/java/com/graphhopper/GraphHopper.java index 7d77bc2a3ac..7eb060c21b9 100644 --- a/core/src/main/java/com/graphhopper/GraphHopper.java +++ b/core/src/main/java/com/graphhopper/GraphHopper.java @@ -609,22 +609,7 @@ protected EncodingManager buildEncodingManager(Map 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 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 sortedEVs = getEVSortIndex(); encodedValues.sort(Comparator.comparingInt(ev -> sortedEVs.indexOf(ev.getName()))); EncodingManager.Builder emBuilder = new EncodingManager.Builder(); @@ -635,6 +620,10 @@ protected EncodingManager buildEncodingManager(Map encodedValuesWi return emBuilder.build(); } + protected List getEVSortIndex() { + return Collections.emptyList(); + } + protected OSMParsers buildOSMParsers(Map encodedValuesWithProps, Map activeImportUnits, Map vehiclesWithProps, List ignoredHighways, String dateRangeParserString) { ImportUnitSorter sorter = new ImportUnitSorter(activeImportUnits); diff --git a/core/src/test/java/com/graphhopper/reader/osm/GraphHopperOSMTest.java b/core/src/test/java/com/graphhopper/reader/osm/GraphHopperOSMTest.java index bf98f046bfb..ed18b161aa8 100644 --- a/core/src/test/java/com/graphhopper/reader/osm/GraphHopperOSMTest.java +++ b/core/src/test/java/com/graphhopper/reader/osm/GraphHopperOSMTest.java @@ -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(","))); } @@ -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