-
Notifications
You must be signed in to change notification settings - Fork 376
/
ORSDefaultFlagEncoderFactory.java
88 lines (72 loc) 路 4.97 KB
/
ORSDefaultFlagEncoderFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* This file is part of Openrouteservice.
*
* Openrouteservice is free software; you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License along with this library;
* if not, see <https://www.gnu.org/licenses/>.
*/
package org.heigit.ors.routing.graphhopper.extensions;
import com.graphhopper.routing.util.DefaultFlagEncoderFactory;
import com.graphhopper.routing.util.FlagEncoder;
import com.graphhopper.routing.util.FlagEncoderFactory;
import com.graphhopper.util.PMap;
import org.heigit.ors.routing.graphhopper.extensions.flagencoders.FlagEncoderNames;
public class ORSDefaultFlagEncoderFactory extends DefaultFlagEncoderFactory implements FlagEncoderFactory {
public static final String KEY_CONSIDER_ELEVATION = "consider_elevation";
@Override
public FlagEncoder createFlagEncoder(String name, PMap configuration) {
switch (name) {
case FlagEncoderNames.CAR_ORS:
return new org.heigit.ors.routing.graphhopper.extensions.flagencoders.CarFlagEncoder(configuration);
case FlagEncoderNames.EMERGENCY:
return new org.heigit.ors.routing.graphhopper.extensions.flagencoders.EmergencyFlagEncoder(configuration);
case FlagEncoderNames.HEAVYVEHICLE:
return new org.heigit.ors.routing.graphhopper.extensions.flagencoders.HeavyVehicleFlagEncoder(configuration);
case FlagEncoderNames.BIKE_ORS:
if (configuration.getBool(KEY_CONSIDER_ELEVATION, false)) {
configuration.remove(KEY_CONSIDER_ELEVATION);
}
return new org.heigit.ors.routing.graphhopper.extensions.flagencoders.bike.RegularBikeFlagEncoder(configuration);
case FlagEncoderNames.MTB_ORS:
// MARQ24 hardcoded "ignore" consider_elevation for the NextGenMountainBike FlagEncoder - when
// consider_elevation is enabled we have various detours (over smaler tracks)
if (configuration.getBool(KEY_CONSIDER_ELEVATION, false)) {
configuration.remove(KEY_CONSIDER_ELEVATION);
}
return new org.heigit.ors.routing.graphhopper.extensions.flagencoders.bike.MountainBikeFlagEncoder(configuration);
case FlagEncoderNames.BIKE_ELECTRO:
// MARQ24 hardcoded "ignore" consider_elevation for the NextGenMountainBike FlagEncoder - when
// consider_elevation is enabled we have various detours (over smaler tracks)
if (configuration.getBool(KEY_CONSIDER_ELEVATION, false)) {
configuration.remove(KEY_CONSIDER_ELEVATION);
}
return new org.heigit.ors.routing.graphhopper.extensions.flagencoders.bike.ElectroBikeFlagEncoder(configuration);
case FlagEncoderNames.ROADBIKE_ORS:
// MARQ24 hardcoded "ignore" consider_elevation for the NextGenRoadbike FlagEncoder - when
// consider_elevation is enabled we have various detours (over smaler tracks)
// see http://localhost:3035/directions?n1=51.562385&n2=8.724582&n3=15&a=51.573202,8.709326,51.54879,8.710184&b=1c&c=0&g1=-1&g2=0&h2=3&k1=en-US&k2=km
if (configuration.getBool(KEY_CONSIDER_ELEVATION, false)) {
configuration.remove(KEY_CONSIDER_ELEVATION);
}
return new org.heigit.ors.routing.graphhopper.extensions.flagencoders.bike.RoadBikeFlagEncoder(configuration);
case FlagEncoderNames.WHEELCHAIR:
return new org.heigit.ors.routing.graphhopper.extensions.flagencoders.WheelchairFlagEncoder(configuration);
case FlagEncoderNames.PEDESTRIAN_ORS:
return new org.heigit.ors.routing.graphhopper.extensions.flagencoders.PedestrianFlagEncoder(configuration);
case FlagEncoderNames.HIKING_ORS:
return new org.heigit.ors.routing.graphhopper.extensions.flagencoders.HikingFlagEncoder(configuration);
default:
// for all the types that DOES not match the ORS specific encoders we make
// use of the GH defaults - PLEASE note, that even if the GH defaults are
// used, the ors-fork of gh includes an adjustment in the
// 'AbstractFlagEncoder' (which is the parent class of ALL vehicles - so
// even if a gh default flagEncoder impl ist used - we have some additional
// features inside!
return super.createFlagEncoder(name, configuration);
}
}
}