11package com.mapbox.navigation.core.adas
22
3+ import androidx.annotation.IntDef
34import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI
45
56/* *
@@ -14,13 +15,18 @@ import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI
1415 * Position is a shape index, where integer part in an index of geometry segment is
1516 * and fractional part is a position on the segment
1617 * @param isDividedRoad A flag indicating if the edge is a divided road
18+ * @param formOfWay Form Of Way information from ADAS tiles, may differ from the Valhalla value, but should be used for ADAS purposes.
19+ * See [FormOfWay.Type]. If not set, then the value is not known
20+ * @param etc2 Road class in ETC2.0 format (Japan specific), see [Etc2Road.Type]
1721 */
1822@ExperimentalPreviewMapboxNavigationAPI
1923class AdasEdgeAttributes private constructor(
2024 val speedLimit : List <AdasSpeedLimitInfo >,
2125 val slopes : List <AdasValueOnEdge >,
2226 val curvatures : List <AdasValueOnEdge >,
2327 val isDividedRoad : Boolean? ,
28+ @FormOfWay.Type val formOfWay : Int? ,
29+ @Etc2Road.Type val etc2 : Int ,
2430) {
2531
2632 /* *
@@ -35,7 +41,10 @@ class AdasEdgeAttributes private constructor(
3541 if (speedLimit != other.speedLimit) return false
3642 if (slopes != other.slopes) return false
3743 if (curvatures != other.curvatures) return false
38- return isDividedRoad == other.isDividedRoad
44+ if (isDividedRoad != other.isDividedRoad) return false
45+ if (formOfWay != other.formOfWay) return false
46+ if (etc2 != other.etc2) return false
47+ return true
3948 }
4049
4150 /* *
@@ -46,6 +55,8 @@ class AdasEdgeAttributes private constructor(
4655 result = 31 * result + slopes.hashCode()
4756 result = 31 * result + curvatures.hashCode()
4857 result = 31 * result + isDividedRoad.hashCode()
58+ result = 31 * result + formOfWay.hashCode()
59+ result = 31 * result + etc2.hashCode()
4960 return result
5061 }
5162
@@ -57,10 +68,195 @@ class AdasEdgeAttributes private constructor(
5768 " speedLimit=$speedLimit , " +
5869 " slopes=$slopes , " +
5970 " curvatures=$curvatures , " +
60- " isDividedRoad=$isDividedRoad " +
71+ " isDividedRoad=$isDividedRoad , " +
72+ " formOfWay=$formOfWay , " +
73+ " etc2=$etc2 " +
6174 " )"
6275 }
6376
77+ /* *
78+ * Form of way type.
79+ */
80+ object FormOfWay {
81+
82+ /* *
83+ * Unknown form of way.
84+ */
85+ const val UNKNOWN = 0
86+
87+ /* *
88+ * Freeway form of way.
89+ */
90+ const val FREEWAY = 1
91+
92+ /* *
93+ * Multiple carriageway form of way.
94+ */
95+ const val MULTIPLE_CARRIAGEWAY = 2
96+
97+ /* *
98+ * Single carriageway form of way.
99+ */
100+ const val SINGLE_CARRIAGEWAY = 3
101+
102+ /* *
103+ * Roundabout circle form of way.
104+ */
105+ const val ROUNDABOUT_CIRCLE = 4
106+
107+ /* *
108+ * Traffic square form of way.
109+ */
110+ const val TRAFFIC_SQUARE = 5
111+
112+ /* *
113+ * Slip road form of way.
114+ */
115+ const val SLIP_ROAD = 6
116+
117+ /* *
118+ * Parallel road form of way.
119+ */
120+ const val PARALLEL_ROAD = 7
121+
122+ /* *
123+ * Ramp on freeway form of way.
124+ */
125+ const val RAMP_ON_FREEWAY = 8
126+
127+ /* *
128+ * Ramp form of way.
129+ */
130+ const val RAMP = 9
131+
132+ /* *
133+ * Service road form of way.
134+ */
135+ const val SERVICE_ROAD = 10
136+
137+ /* *
138+ * Car park entrance form of way.
139+ */
140+ const val CAR_PARK_ENTRANCE = 11
141+
142+ /* *
143+ * Service entrance form of way.
144+ */
145+ const val SERVICE_ENTRANCE = 12
146+
147+ /* *
148+ * Pedestrian zone form of way.
149+ */
150+ const val PEDESTRIAN_ZONE = 13
151+
152+ /* *
153+ * Form of way is not applicable.
154+ */
155+ const val NA = 14
156+
157+ /* *
158+ * Retention policy for [FormOfWay].
159+ */
160+ @Retention(AnnotationRetention .BINARY )
161+ @IntDef(
162+ UNKNOWN ,
163+ FREEWAY ,
164+ MULTIPLE_CARRIAGEWAY ,
165+ SINGLE_CARRIAGEWAY ,
166+ ROUNDABOUT_CIRCLE ,
167+ TRAFFIC_SQUARE ,
168+ SLIP_ROAD ,
169+ PARALLEL_ROAD ,
170+ RAMP_ON_FREEWAY ,
171+ RAMP ,
172+ SERVICE_ROAD ,
173+ CAR_PARK_ENTRANCE ,
174+ SERVICE_ENTRANCE ,
175+ PEDESTRIAN_ZONE ,
176+ NA ,
177+ )
178+ annotation class Type
179+
180+ @Type
181+ @JvmSynthetic
182+ internal fun createFromNativeObject (nativeObj : com.mapbox.navigator.FormOfWay ): Int =
183+ when (nativeObj) {
184+ com.mapbox.navigator.FormOfWay .FREEWAY -> FREEWAY
185+ com.mapbox.navigator.FormOfWay .MULTIPLE_CARRIAGEWAY -> MULTIPLE_CARRIAGEWAY
186+ com.mapbox.navigator.FormOfWay .SINGLE_CARRIAGEWAY -> SINGLE_CARRIAGEWAY
187+ com.mapbox.navigator.FormOfWay .ROUNDABOUT_CIRCLE -> ROUNDABOUT_CIRCLE
188+ com.mapbox.navigator.FormOfWay .TRAFFIC_SQUARE -> TRAFFIC_SQUARE
189+ com.mapbox.navigator.FormOfWay .SLIP_ROAD -> SLIP_ROAD
190+ com.mapbox.navigator.FormOfWay .PARALLEL_ROAD -> PARALLEL_ROAD
191+ com.mapbox.navigator.FormOfWay .RAMP_ON_FREEWAY -> RAMP_ON_FREEWAY
192+ com.mapbox.navigator.FormOfWay .RAMP -> RAMP
193+ com.mapbox.navigator.FormOfWay .SERVICE_ROAD -> SERVICE_ROAD
194+ com.mapbox.navigator.FormOfWay .CAR_PARK_ENTRANCE -> CAR_PARK_ENTRANCE
195+ com.mapbox.navigator.FormOfWay .SERVICE_ENTRANCE -> SERVICE_ENTRANCE
196+ com.mapbox.navigator.FormOfWay .PEDESTRIAN_ZONE -> PEDESTRIAN_ZONE
197+ com.mapbox.navigator.FormOfWay .NA -> NA
198+ com.mapbox.navigator.FormOfWay .UNKNOWN -> UNKNOWN
199+ }
200+ }
201+
202+ /* *
203+ * ETC2 road type.
204+ */
205+ object Etc2Road {
206+
207+ /* *
208+ * Unknown ETC2 road type.
209+ */
210+ const val UNKNOWN = 0
211+
212+ /* *
213+ * Highway ETC2 road type.
214+ */
215+ const val HIGHWAY = 1
216+
217+ /* *
218+ * City highway ETC2 road type.
219+ */
220+ const val CITY_HIGHWAY = 2
221+
222+ /* *
223+ * Normal road ETC2 road type.
224+ */
225+ const val NORMAL_ROAD = 3
226+
227+ /* *
228+ * Other ETC2 road type.
229+ */
230+ const val OTHER = 4
231+
232+ /* *
233+ * Retention policy for the [Etc2Road.Type].
234+ */
235+ @Retention(AnnotationRetention .BINARY )
236+ @IntDef(
237+ UNKNOWN ,
238+ HIGHWAY ,
239+ CITY_HIGHWAY ,
240+ NORMAL_ROAD ,
241+ OTHER ,
242+ )
243+ annotation class Type
244+
245+ @Type
246+ @JvmSynthetic
247+ internal fun createFromNativeObject (
248+ nativeObj : com.mapbox.navigator.ETC2RoadType ,
249+ ): Int {
250+ return when (nativeObj) {
251+ com.mapbox.navigator.ETC2RoadType .HIGHWAY -> HIGHWAY
252+ com.mapbox.navigator.ETC2RoadType .CITY_HIGHWAY -> CITY_HIGHWAY
253+ com.mapbox.navigator.ETC2RoadType .NORMAL_ROAD -> NORMAL_ROAD
254+ com.mapbox.navigator.ETC2RoadType .OTHER -> OTHER
255+ com.mapbox.navigator.ETC2RoadType .UNKNOWN -> UNKNOWN
256+ }
257+ }
258+ }
259+
64260 internal companion object {
65261
66262 @JvmSynthetic
@@ -76,6 +272,8 @@ class AdasEdgeAttributes private constructor(
76272 AdasValueOnEdge .createFromNativeObject(it)
77273 },
78274 isDividedRoad = nativeObj.isDividedRoad,
275+ formOfWay = nativeObj.formOfWay?.let { FormOfWay .createFromNativeObject(it) },
276+ etc2 = Etc2Road .createFromNativeObject(nativeObj.etc2),
79277 )
80278 }
81279}
0 commit comments