Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd9a3d6

Browse files
authored
more profiles in config-example.yml (#3228)
* include foot and bike* make it working* less strict* fix config
1 parent2e03e7d commitdd9a3d6

File tree

3 files changed

+47
-52
lines changed

3 files changed

+47
-52
lines changed

‎config-example.yml‎

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,20 @@ graphhopper:
3030

3131
profiles:
3232
-name:car
33+
# By default car comes without turn restrictions as this requires less resources. Uncomment the following if you need it:
3334
# turn_costs:
3435
# vehicle_types: [motorcar, motor_vehicle]
3536
# u_turn_costs: 60
3637
# for more advanced turn costs see avoid_turns.json
3738
custom_model_files:[car.json]
39+
# By default foot and bike are without CH preparation as this requires less resources. Add them to "profiles_ch" if you need it.
40+
-name:foot
41+
custom_model_files:[foot.json, foot_elevation.json]
3842

39-
# You can use the following in-built profiles. After you start GraphHopper it will print which encoded values you'll have to add to graph.encoded_values in this config file.
40-
#
41-
# - name: foot
42-
# custom_model_files: [foot.json, foot_elevation.json]
43-
#
44-
# - name: bike
45-
# custom_model_files: [bike.json, bike_elevation.json]
43+
-name:bike
44+
custom_model_files:[bike.json, bike_elevation.json]
45+
46+
# Uncomment the following in-built profiles if you want more profiles. After you start GraphHopper it will print which encoded values you'll have to add to graph.encoded_values in this config file.
4647
#
4748
# - name: racingbike
4849
# custom_model_files: [racingbike.json, bike_elevation.json]
@@ -101,13 +102,16 @@ graphhopper:
101102
#### Encoded Values ####
102103

103104
# Add additional information to every edge. Used for path details (#1548) and custom models (docs/core/custom-models.md)
104-
# Possible values: road_class,road_class_link,road_environment,max_speed,road_access
105-
# surface,smoothness,max_width,max_height,max_weight,max_weight_except,hgv,max_axle_load,max_length,
106-
# hazmat,hazmat_tunnel,hazmat_water,lanes,osm_way_id,toll,track_type,mtb_rating,hike_rating,horse_rating,
107-
# country,curvature,average_slope,max_slope,car_temporal_access,bike_temporal_access,foot_temporal_access
108-
# Private roads are blocked by default to disable this you can specify (also applies to other access encoded values like bike_access):
109-
# car_access|block_private=false
110-
graph.encoded_values:car_access, car_average_speed, road_access
105+
# Example values:
106+
# average_slope,country,curvature,hazmat,hgv,hike_rating,lanes,max_height,max_length, ...
107+
# For more details and a full list see the documentation: https://github.com/graphhopper/graphhopper/blob/master/docs/core/custom-models.md
108+
# Private roads are blocked by default. To disable this you can specify block_private=false as option:
109+
# car_access|block_private=false, bike_access|block_private=false
110+
# By default we add the necessary encoded values for car.json, bike.json and foot.json (remove them if you do not need them)
111+
graph.encoded_values:|
112+
car_access, car_average_speed, country, road_class, roundabout,
113+
foot_access, foot_average_speed, foot_priority, foot_road_access, hike_rating, average_slope,
114+
bike_access, bike_average_speed, bike_priority, bike_road_access, bike_network, mtb_rating,
111115
112116
#### Speed, hybrid and flexible mode ####
113117

@@ -215,8 +219,9 @@ graphhopper:
215219
# motorized vehicles. This leads to a smaller and less dense graph, because there are fewer ways (obviously),
216220
# but also because there are fewer crossings between highways (=junctions).
217221
# Another typical example is excluding 'motorway', 'trunk' and maybe 'primary' highways for bicycle or pedestrian routing.
218-
import.osm.ignored_highways:footway,construction,cycleway,path,steps# typically useful for motorized-only routing
219-
# import.osm.ignored_highways: motorway,trunk # typically useful for non-motorized routing
222+
import.osm.ignored_highways:''
223+
# import.osm.ignored_highways: footway,construction,cycleway,path,steps # use if you only have motorized-only vehicle profiles
224+
# import.osm.ignored_highways: motorway,trunk # use if you only have non-motorized vehicle profiles
220225

221226
# configure the memory access, use RAM_STORE for well equipped servers (default and recommended)
222227
graph.dataaccess.default_type:RAM_STORE

‎core/src/main/java/com/graphhopper/routing/Router.java‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ public class Router {
6666
protectedfinalWeightingFactoryweightingFactory;
6767
protectedfinalMap<String,RoutingCHGraph>chGraphs;
6868
protectedfinalMap<String,LandmarkStorage>landmarks;
69-
protectedfinalbooleanchEnabled;
70-
protectedfinalbooleanlmEnabled;
7169

7270
publicRouter(BaseGraphgraph,EncodingManagerencodingManager,LocationIndexlocationIndex,
7371
Map<String,Profile>profilesByName,PathDetailsBuilderFactorypathDetailsBuilderFactory,
@@ -83,10 +81,6 @@ public Router(BaseGraph graph, EncodingManager encodingManager, LocationIndex lo
8381
this.weightingFactory =weightingFactory;
8482
this.chGraphs =chGraphs;
8583
this.landmarks =landmarks;
86-
// note that his is not the same as !ghStorage.getCHConfigs().isEmpty(), because the GHStorage might have some
87-
// CHGraphs that were not built yet (and possibly no CH profiles were configured).
88-
this.chEnabled = !chGraphs.isEmpty();
89-
this.lmEnabled = !landmarks.isEmpty();
9084

9185
for (Stringprofile :profilesByName.keySet()) {
9286
if (!encodingManager.hasEncodedValue(Subnetwork.key(profile)))
@@ -188,11 +182,9 @@ private void checkCustomModel(GHRequest request) {
188182
}
189183

190184
protectedSolvercreateSolver(GHRequestrequest) {
191-
finalbooleandisableCH =getDisableCH(request.getHints());
192-
finalbooleandisableLM =getDisableLM(request.getHints());
193-
if (chEnabled && !disableCH) {
185+
if (chGraphs.containsKey(request.getProfile()) && !getDisableCH(request.getHints())) {
194186
returncreateCHSolver(request,profilesByName,routerConfig,encodingManager,chGraphs);
195-
}elseif (lmEnabled && !disableLM) {
187+
}elseif (landmarks.containsKey(request.getProfile()) && !getDisableLM(request.getHints())) {
196188
returncreateLMSolver(request,profilesByName,routerConfig,encodingManager,weightingFactory,graph,locationIndex,landmarks);
197189
}else {
198190
returncreateFlexSolver(request,profilesByName,routerConfig,encodingManager,weightingFactory,graph,locationIndex);

‎core/src/test/java/com/graphhopper/GraphHopperTest.java‎

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,13 +1685,14 @@ public void testLMConstraints() {
16851685
assertFalse(response.hasErrors(),response.getErrors().toString());
16861686
assertEquals(3587,response.getBest().getDistance(),1);
16871687

1688-
//currently required to disable LM forp2too, see #1904 (default isLMfor *all* profiles once LM preparationisenabled for any profile)
1688+
// p2has noLMand so no lm.disable=trueisrequired
16891689
response =hopper.route(newGHRequest(43.727687,7.418737,43.74958,7.436566).
16901690
setCustomModel(customModel).
16911691
setProfile("p2"));
1692-
assertTrue(response.getErrors().get(0).toString().contains("Cannot find LM preparation for the requested profile: 'p2'"),response.getErrors().toString());
1693-
assertEquals(IllegalArgumentException.class,response.getErrors().get(0).getClass());
1692+
assertFalse(response.hasErrors(),response.getErrors().toString());
1693+
assertEquals(3587,response.getBest().getDistance(),1);
16941694

1695+
// but still works
16951696
response =hopper.route(newGHRequest(43.727687,7.418737,43.74958,7.436566).
16961697
setCustomModel(customModel).
16971698
setProfile("p2").putHint("lm.disable",true));
@@ -1743,21 +1744,21 @@ public void testPreparedProfileNotAvailable() {
17431744
GHRequestreq =newGHRequest(43.727687,7.418737,43.74958,7.436566).
17441745
setProfile(profile2);
17451746

1746-
//try with CH
1747+
//no CH or LM profile and so nothing can be ignored
17471748
req.putHint(CH.DISABLE,false);
17481749
req.putHint(Landmark.DISABLE,false);
17491750
GHResponseres =hopper.route(req);
1750-
assertTrue(res.hasErrors(),res.getErrors().toString());
1751-
assertTrue(res.getErrors().get(0).getMessage().contains("Cannot find CH preparation for the requested profile: 'short_fast_profile'"),res.getErrors().toString());
1751+
assertFalse(res.hasErrors(),res.getErrors().toString());
1752+
assertEquals(3587,res.getBest().getDistance(),1);
17521753

17531754
// try with LM
17541755
req.putHint(CH.DISABLE,true);
17551756
req.putHint(Landmark.DISABLE,false);
17561757
res =hopper.route(req);
1757-
assertTrue(res.hasErrors(),res.getErrors().toString());
1758-
assertTrue(res.getErrors().get(0).getMessage().contains("Cannot find LM preparation for the requested profile: 'short_fast_profile'"),res.getErrors().toString());
1758+
assertFalse(res.hasErrors(),res.getErrors().toString());
1759+
assertEquals(3587,res.getBest().getDistance(),1);
17591760

1760-
// falling back to non-prepared algo works
1761+
// falling back to non-prepared algo
17611762
req.putHint(CH.DISABLE,true);
17621763
req.putHint(Landmark.DISABLE,true);
17631764
res =hopper.route(req);
@@ -1978,44 +1979,41 @@ public void testCHOnOffWithTurnCosts() {
19781979

19791980
@Test
19801981
publicvoidtestNodeBasedCHOnlyButTurnCostForNonCH() {
1981-
finalStringprofile1 ="car_profile_tc";
1982-
finalStringprofile2 ="car_profile_notc";
1982+
finalStringprofile_tc ="car_profile_tc";
1983+
finalStringprofile_no_tc ="car_profile_notc";
19831984

19841985
// before edge-based CH was added a common case was to use edge-based without CH and CH for node-based
19851986
GraphHopperhopper =newGraphHopper().
19861987
setGraphHopperLocation(GH_LOCATION).
19871988
setOSMFile(MOSCOW).
19881989
setEncodedValuesString("car_access, car_average_speed").
19891990
setProfiles(List.of(
1990-
TestProfiles.accessAndSpeed(profile1,"car").setTurnCostsConfig(TurnCostsConfig.car()),
1991-
TestProfiles.accessAndSpeed(profile2,"car")
1991+
TestProfiles.accessAndSpeed(profile_tc,"car").setTurnCostsConfig(TurnCostsConfig.car()),
1992+
TestProfiles.accessAndSpeed(profile_no_tc,"car")
19921993
)).
19931994
setStoreOnFlush(true);
19941995
hopper.getCHPreparationHandler()
19951996
// we only do the CH preparation for the profile without turn costs
1996-
.setCHProfiles(newCHProfile(profile2));
1997+
.setCHProfiles(newCHProfile(profile_no_tc));
19971998
hopper.importOrLoad();
19981999

19992000
GHRequestreq =newGHRequest(55.813357,37.5958585,55.811042,37.594689);
2000-
// without CH, turn turn costs onandoff
2001+
// without CHandwith tc
20012002
req.putHint(CH.DISABLE,true);
2002-
req.setProfile(profile1);
2003+
req.setProfile(profile_tc);
20032004
assertEquals(1044,hopper.route(req).getBest().getDistance(),1);
2004-
req.setProfile(profile2);
2005+
// without CH and without tc
2006+
req.setProfile(profile_no_tc);
20052007
assertEquals(400,hopper.route(req).getBest().getDistance(),1);
20062008

2007-
// with CH, turn turn costs on and off, since turn costs not supported for CH throw an error
2009+
// with CH and without tc => since turn costs not supported for CH throw an error
20082010
req.putHint(CH.DISABLE,false);
2009-
req.setProfile(profile2);
2011+
req.setProfile(profile_no_tc);
20102012
assertEquals(400,hopper.route(req).getBest().getDistance(),1);
2011-
req.setProfile(profile1);
2013+
// since there is no CH preparation for car_profile_tc the ch.disable parameter is ignored
2014+
req.setProfile(profile_tc);
20122015
GHResponsersp =hopper.route(req);
2013-
assertEquals(1,rsp.getErrors().size());
2014-
Stringexpected ="Cannot find CH preparation for the requested profile: 'car_profile_tc'" +
2015-
"\nYou can try disabling CH using ch.disable=true" +
2016-
"\navailable CH profiles: [car_profile_notc]";
2017-
assertTrue(rsp.getErrors().toString().contains(expected),"unexpected error:\n" +rsp.getErrors().toString() +"\nwhen expecting an error containing:\n" +expected
2018-
);
2016+
assertEquals(1044,hopper.route(req).getBest().getDistance(),1);
20192017
}
20202018

20212019
@Test

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp