|
@@ -4,47 +4,90 @@ import java.util.EnumMap;
|
4
|
4
|
import java.util.EnumSet;
|
5
|
5
|
|
6
|
6
|
/**
|
|
7
|
+ * <p>
|
7
|
8
|
* Class containing access restrictions for roads/arcs.
|
|
9
|
+ * </p>
|
8
|
10
|
*
|
|
11
|
+ * <p>
|
9
|
12
|
* This class maps transport modes to their restriction and provide interface
|
10
|
13
|
* based on EnumSet to query restrictions.
|
|
14
|
+ * </p>
|
11
|
15
|
*
|
|
16
|
+ * <p>
|
12
|
17
|
* To each transport is associated at most one restriction per road (no
|
13
|
18
|
* restriction corresponds to {@link AccessRestriction#UNKNOWN} but a road can
|
14
|
19
|
* have different restrictions for different modes.
|
|
20
|
+ * </p>
|
15
|
21
|
*
|
16
|
22
|
*/
|
17
|
23
|
public class AccessRestrictions {
|
18
|
24
|
|
19
|
25
|
/**
|
20
|
|
- * List of managed transport modes.
|
|
26
|
+ * Enumeration representing the available transport modes.
|
21
|
27
|
*
|
|
28
|
+ * @see <a href=
|
|
29
|
+ * "https://wiki.openstreetmap.org/wiki/Key:access#Transport_mode_restrictions">OpenStreetMap
|
|
30
|
+ * reference for access modes.</a>
|
22
|
31
|
*/
|
23
|
32
|
public enum AccessMode {
|
24
|
33
|
|
25
|
|
- // Specific modes
|
|
34
|
+ /**
|
|
35
|
+ * Access mode corresponding to pedestrians.
|
|
36
|
+ */
|
26
|
37
|
FOOT,
|
|
38
|
+
|
|
39
|
+ /**
|
|
40
|
+ * Access mode corresponding to bicycles (non-motorized).
|
|
41
|
+ */
|
27
|
42
|
BICYCLE,
|
|
43
|
+
|
|
44
|
+ /**
|
|
45
|
+ * Access mode corresponding to small motorcycles (limited speed).
|
|
46
|
+ */
|
28
|
47
|
SMALL_MOTORCYCLE,
|
|
48
|
+
|
|
49
|
+ /**
|
|
50
|
+ * Access mode corresponding to agricultural vehicles.
|
|
51
|
+ */
|
29
|
52
|
AGRICULTURAL,
|
|
53
|
+
|
|
54
|
+ /**
|
|
55
|
+ * Access mode corresponding to motorcycles.
|
|
56
|
+ */
|
30
|
57
|
MOTORCYCLE,
|
|
58
|
+
|
|
59
|
+ /**
|
|
60
|
+ * Access mode corresponding to motorcars.
|
|
61
|
+ */
|
31
|
62
|
MOTORCAR,
|
|
63
|
+
|
|
64
|
+ /**
|
|
65
|
+ * Access mode corresponding to heavy transportation vehicles.
|
|
66
|
+ */
|
32
|
67
|
HEAVY_GOODS,
|
|
68
|
+
|
|
69
|
+ /**
|
|
70
|
+ * Access mode corresponding to public transport vehicles.
|
|
71
|
+ */
|
33
|
72
|
PUBLIC_TRANSPORT;
|
34
|
73
|
|
35
|
74
|
/**
|
36
|
|
- * EnumSet containing all the possible transport modes.
|
|
75
|
+ * {@code EnumSet} containing all possible transport modes.
|
|
76
|
+ *
|
|
77
|
+ *
|
37
|
78
|
*/
|
38
|
79
|
public static final EnumSet<AccessMode> ALL = EnumSet.allOf(AccessMode.class);
|
39
|
80
|
|
40
|
81
|
/**
|
41
|
|
- * EnumSet containing all the vehicle transport modes.
|
|
82
|
+ * {@code EnumSet} containing all vehicle transport modes.
|
|
83
|
+ *
|
42
|
84
|
*/
|
43
|
85
|
public static final EnumSet<AccessMode> VEHICLE = EnumSet.range(AccessMode.BICYCLE,
|
44
|
86
|
AccessMode.PUBLIC_TRANSPORT);
|
45
|
87
|
|
46
|
88
|
/**
|
47
|
|
- * EnumSet containing all the motorized vehicle transport modes.
|
|
89
|
+ * {@code EnumSet} containing all motorized vehicle transport modes.
|
|
90
|
+ *
|
48
|
91
|
*/
|
49
|
92
|
public static final EnumSet<AccessMode> MOTOR_VEHICLE = EnumSet
|
50
|
93
|
.range(AccessMode.SMALL_MOTORCYCLE, AccessMode.PUBLIC_TRANSPORT);
|
|
@@ -53,11 +96,56 @@ public class AccessRestrictions {
|
53
|
96
|
/**
|
54
|
97
|
* Possible restrictions for the roads/arcs.
|
55
|
98
|
*
|
|
99
|
+ * @see <a href=
|
|
100
|
+ * "https://wiki.openstreetmap.org/wiki/Key:access#Transport_mode_restrictions">OpenStreetMap
|
|
101
|
+ * reference for access restrictions.</a>
|
56
|
102
|
*/
|
57
|
103
|
public enum AccessRestriction {
|
58
|
|
- ALLOWED, FORBIDDEN, PRIVATE, DESTINATION, DELIVERY, CUSTOMERS, FORESTRY, UNKNOWN;
|
59
|
104
|
|
60
|
|
- // Not private or forbidden
|
|
105
|
+ /**
|
|
106
|
+ *
|
|
107
|
+ */
|
|
108
|
+ ALLOWED,
|
|
109
|
+
|
|
110
|
+ /**
|
|
111
|
+ *
|
|
112
|
+ */
|
|
113
|
+ FORBIDDEN,
|
|
114
|
+
|
|
115
|
+ /**
|
|
116
|
+ *
|
|
117
|
+ */
|
|
118
|
+ PRIVATE,
|
|
119
|
+
|
|
120
|
+ /**
|
|
121
|
+ *
|
|
122
|
+ */
|
|
123
|
+ DESTINATION,
|
|
124
|
+
|
|
125
|
+ /**
|
|
126
|
+ *
|
|
127
|
+ */
|
|
128
|
+ DELIVERY,
|
|
129
|
+
|
|
130
|
+ /**
|
|
131
|
+ *
|
|
132
|
+ */
|
|
133
|
+ CUSTOMERS,
|
|
134
|
+
|
|
135
|
+ /**
|
|
136
|
+ *
|
|
137
|
+ */
|
|
138
|
+ FORESTRY,
|
|
139
|
+
|
|
140
|
+ /**
|
|
141
|
+ *
|
|
142
|
+ */
|
|
143
|
+ UNKNOWN;
|
|
144
|
+
|
|
145
|
+ /**
|
|
146
|
+ * {@code EnumSet} corresponding to restrictions that are not totally private.
|
|
147
|
+ *
|
|
148
|
+ */
|
61
|
149
|
public static final EnumSet<AccessRestriction> ALLOWED_FOR_SOMETHING = EnumSet.of(
|
62
|
150
|
AccessRestriction.ALLOWED, AccessRestriction.DESTINATION,
|
63
|
151
|
AccessRestriction.DESTINATION, AccessRestriction.DELIVERY,
|
|
@@ -82,7 +170,7 @@ public class AccessRestrictions {
|
82
|
170
|
* Create a new AccessRestrictions instances with the given restrictions.
|
83
|
171
|
*
|
84
|
172
|
* @param restrictions Map of restrictions for this instance of
|
85
|
|
- * AccessRestrictions.
|
|
173
|
+ * AccessRestrictions.
|
86
|
174
|
*/
|
87
|
175
|
public AccessRestrictions(EnumMap<AccessMode, AccessRestriction> restrictions) {
|
88
|
176
|
this.restrictions = restrictions;
|
|
@@ -106,8 +194,8 @@ public class AccessRestrictions {
|
106
|
194
|
* @param mode Mode for which to check the restrictions.
|
107
|
195
|
* @param restrictions List of queried restrictions for the mode.
|
108
|
196
|
*
|
109
|
|
- * @return true if the restriction of the given mode is one of the given
|
110
|
|
- * restrictions.
|
|
197
|
+ * @return {@code true} if the restriction of the given mode is one of the given
|
|
198
|
+ * restrictions.
|
111
|
199
|
*/
|
112
|
200
|
public boolean isAllowedForAny(AccessMode mode, EnumSet<AccessRestriction> restrictions) {
|
113
|
201
|
return restrictions.contains(getRestrictionFor(mode));
|
|
@@ -120,8 +208,8 @@ public class AccessRestrictions {
|
120
|
208
|
* @param mode Mode for which the restriction should be checked.
|
121
|
209
|
* @param restriction Restriction to check against.
|
122
|
210
|
*
|
123
|
|
- * @return true if the restriction of the given mode corresponds to the given
|
124
|
|
- * restriction.
|
|
211
|
+ * @return {@code true} if the restriction of the given mode corresponds to the
|
|
212
|
+ * given restriction.
|
125
|
213
|
*/
|
126
|
214
|
public boolean isAllowedFor(AccessMode mode, AccessRestriction restriction) {
|
127
|
215
|
return getRestrictionFor(mode).equals(restriction);
|
|
@@ -134,8 +222,8 @@ public class AccessRestrictions {
|
134
|
222
|
* @param modes Modes for which restrictions should be checked.
|
135
|
223
|
* @param restrictions Set of wanted restrictions for the modes.
|
136
|
224
|
*
|
137
|
|
- * @return true if all the given modes are allowed for any of the given
|
138
|
|
- * restrictions.
|
|
225
|
+ * @return {@code true} if all the given modes are allowed for any of the given
|
|
226
|
+ * restrictions.
|
139
|
227
|
*/
|
140
|
228
|
public boolean areAllAllowedForAny(EnumSet<AccessMode> modes,
|
141
|
229
|
EnumSet<AccessRestriction> restrictions) {
|