Skip to content

Commit 49bf41b

Browse files
dzinadDzmitryFomchyn
authored andcommitted
getAdasAttributes improvements
1 parent d4bf480 commit 49bf41b

5 files changed

Lines changed: 38 additions & 79 deletions

File tree

libnavigation-core/api/current.txt

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,11 @@ package com.mapbox.navigation.core.adasis {
374374
method public String getDateTimeCondition();
375375
method public java.util.List<java.lang.Byte> getLanes();
376376
method public java.util.List<com.mapbox.navigation.core.adasis.SpeedLimitRestriction.VehicleType> getVehicleTypes();
377-
method public java.util.List<com.mapbox.navigation.core.adasis.SpeedLimitRestriction.Weather> getWeather();
377+
method public java.util.List<com.mapbox.navigation.core.sensor.SensorData.Weather.Condition> getWeather();
378378
property public final String dateTimeCondition;
379379
property public final java.util.List<java.lang.Byte> lanes;
380380
property public final java.util.List<com.mapbox.navigation.core.adasis.SpeedLimitRestriction.VehicleType> vehicleTypes;
381-
property public final java.util.List<com.mapbox.navigation.core.adasis.SpeedLimitRestriction.Weather> weather;
381+
property public final java.util.List<com.mapbox.navigation.core.sensor.SensorData.Weather.Condition> weather;
382382
}
383383

384384
public abstract static class SpeedLimitRestriction.VehicleType {
@@ -404,36 +404,15 @@ package com.mapbox.navigation.core.adasis {
404404
field public static final com.mapbox.navigation.core.adasis.SpeedLimitRestriction.VehicleType.Truck INSTANCE;
405405
}
406406

407-
public abstract static class SpeedLimitRestriction.Weather {
408-
}
409-
410-
public static final class SpeedLimitRestriction.Weather.Fog extends com.mapbox.navigation.core.adasis.SpeedLimitRestriction.Weather {
411-
field public static final com.mapbox.navigation.core.adasis.SpeedLimitRestriction.Weather.Fog INSTANCE;
412-
}
413-
414-
public static final class SpeedLimitRestriction.Weather.Rain extends com.mapbox.navigation.core.adasis.SpeedLimitRestriction.Weather {
415-
field public static final com.mapbox.navigation.core.adasis.SpeedLimitRestriction.Weather.Rain INSTANCE;
416-
}
417-
418-
public static final class SpeedLimitRestriction.Weather.Snow extends com.mapbox.navigation.core.adasis.SpeedLimitRestriction.Weather {
419-
field public static final com.mapbox.navigation.core.adasis.SpeedLimitRestriction.Weather.Snow INSTANCE;
420-
}
421-
422-
public static final class SpeedLimitRestriction.Weather.WetRoad extends com.mapbox.navigation.core.adasis.SpeedLimitRestriction.Weather {
423-
field public static final com.mapbox.navigation.core.adasis.SpeedLimitRestriction.Weather.WetRoad INSTANCE;
424-
}
425-
426407
@com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class Stub {
427408
ctor public Stub(com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions options);
428409
method public com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions getOptions();
429410
property public final com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions options;
430411
}
431412

432413
@com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class ValueOnEdge {
433-
method public double getPercentAlong();
434414
method public float getShapeIndex();
435415
method public double getValue();
436-
property public final double percentAlong;
437416
property public final float shapeIndex;
438417
property public final double value;
439418
}
@@ -1271,6 +1250,10 @@ package com.mapbox.navigation.core.sensor {
12711250
field public static final com.mapbox.navigation.core.sensor.SensorData.Weather.Condition.Snow INSTANCE;
12721251
}
12731252

1253+
public static final class SensorData.Weather.Condition.WetRoad extends com.mapbox.navigation.core.sensor.SensorData.Weather.Condition {
1254+
field public static final com.mapbox.navigation.core.sensor.SensorData.Weather.Condition.WetRoad INSTANCE;
1255+
}
1256+
12741257
@com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public fun interface UpdateExternalSensorDataCallback {
12751258
method public void onResult(boolean result);
12761259
}

libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/SpeedLimitInfo.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import com.mapbox.navigator.SpeedLimitUnit
88
/**
99
* Speed limit info.
1010
*
11-
* @param value TODO
12-
* @param speedUnit TODO
13-
* @param type TODO
14-
* @param restriction TODO
11+
* @param value the numerical value of the limit
12+
* @param speedUnit the unit the value is specified in
13+
* @param type speed limit type, see [Type]
14+
* @param restriction speed limit restriction, see [SpeedLimitRestriction]
1515
*/
1616
@ExperimentalPreviewMapboxNavigationAPI
1717
class SpeedLimitInfo private constructor(
18-
val value: Byte,
18+
val value: Short,
1919
val speedUnit: SpeedUnit,
2020
val type: Type,
2121
val restriction: SpeedLimitRestriction,

libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/SpeedLimitRestriction.kt

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
package com.mapbox.navigation.core.adasis
22

33
import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI
4+
import com.mapbox.navigation.core.sensor.SensorData
45

56
/**
67
* Speed limit restriction
78
*
89
* @param weather Weather conditions where the speed limit is applied. Empty means all
9-
* @param dateTimeCondition OSM "openning_hours" format, see https://wiki.openstreetmap.org/wiki/Key:opening_hours
10+
* @param dateTimeCondition OSM "opening_hours" format, see https://wiki.openstreetmap.org/wiki/Key:opening_hours
1011
* @param vehicleTypes A list of types of vehicles for that the speed limit is included. Empty means all
1112
* @param lanes Lane numbers where the speed limit is valid. Empty array means all lanes
1213
*/
1314
@ExperimentalPreviewMapboxNavigationAPI
1415
class SpeedLimitRestriction private constructor(
15-
val weather: List<Weather>,
16+
val weather: List<SensorData.Weather.Condition>,
1617
val dateTimeCondition: String,
1718
val vehicleTypes: List<VehicleType>,
1819
val lanes: List<Byte>
@@ -58,47 +59,6 @@ class SpeedLimitRestriction private constructor(
5859
")"
5960
}
6061

61-
/**
62-
* Weather conditions where the speed limit is applied.
63-
*
64-
* TODO merge with [com.mapbox.navigation.core.sensor.SensorData.Weather.Condition]?
65-
*/
66-
abstract class Weather internal constructor() {
67-
68-
/**
69-
* Rain weather condition
70-
*/
71-
object Rain : Weather()
72-
73-
/**
74-
* Snow weather condition
75-
*/
76-
object Snow : Weather()
77-
78-
/**
79-
* Fog weather condition
80-
*/
81-
object Fog : Weather()
82-
83-
/**
84-
* Wet road condition
85-
*/
86-
object WetRoad : Weather()
87-
88-
internal companion object {
89-
90-
@JvmSynthetic
91-
fun createFromNativeObject(nativeObj: com.mapbox.navigator.Weather): Weather {
92-
return when (nativeObj) {
93-
com.mapbox.navigator.Weather.RAIN -> Rain
94-
com.mapbox.navigator.Weather.SNOW -> Snow
95-
com.mapbox.navigator.Weather.FOG -> Fog
96-
com.mapbox.navigator.Weather.WET_ROAD -> WetRoad
97-
}
98-
}
99-
}
100-
}
101-
10262
/**
10363
* Type of vehicle for which the speed limit is included.
10464
*/
@@ -149,7 +109,9 @@ class SpeedLimitRestriction private constructor(
149109
@JvmSynthetic
150110
fun createFromNativeObject(nativeObj: com.mapbox.navigator.SpeedLimitRestriction) =
151111
SpeedLimitRestriction(
152-
weather = nativeObj.weather.map { Weather.createFromNativeObject(it) },
112+
weather = nativeObj.weather.map {
113+
SensorData.Weather.Condition.createFromNativeObject(it)
114+
},
153115
dateTimeCondition = nativeObj.dateTimeCondition,
154116
vehicleTypes = nativeObj.vehicleTypes.map { VehicleType.createFromNativeObject(it) },
155117
lanes = nativeObj.lanes,

libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ValueOnEdge.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI
99
* Integer part is an index of edge segment and fraction is a position on the segment:
1010
* 0 - left point, 1 - right point, 0.5 - in the middle between the segment points.
1111
* Ex.: 3.5 means the middle the the 3rd segment on the Edge shape, shape has more then 4 points
12-
* @param percentAlong Position along edge shape [0-1].
13-
* The value's added for compliance with Navigator interface, functionally it duplicates `shapeIndex`
1412
* @param value Floating point value, e.g. curvature in 1/m or slope as {elevation diff}/{horizontal length}
1513
*/
1614
@ExperimentalPreviewMapboxNavigationAPI
1715
class ValueOnEdge private constructor(
1816
val shapeIndex: Float,
19-
val percentAlong: Double,
2017
val value: Double,
2118
) {
2219

@@ -30,7 +27,6 @@ class ValueOnEdge private constructor(
3027
other as ValueOnEdge
3128

3229
if (shapeIndex != other.shapeIndex) return false
33-
if (percentAlong != other.percentAlong) return false
3430
if (value != other.value) return false
3531

3632
return true
@@ -41,7 +37,6 @@ class ValueOnEdge private constructor(
4137
*/
4238
override fun hashCode(): Int {
4339
var result = shapeIndex.hashCode()
44-
result = 31 * result + percentAlong.hashCode()
4540
result = 31 * result + value.hashCode()
4641
return result
4742
}
@@ -50,7 +45,7 @@ class ValueOnEdge private constructor(
5045
* Returns a string representation of the object.
5146
*/
5247
override fun toString(): String {
53-
return "ValueOnEdge(shapeIndex=$shapeIndex, percentAlong=$percentAlong, value=$value)"
48+
return "ValueOnEdge(shapeIndex=$shapeIndex, value=$value)"
5449
}
5550

5651
internal companion object {
@@ -59,7 +54,6 @@ class ValueOnEdge private constructor(
5954
fun createFromNativeObject(nativeObj: com.mapbox.navigator.ValueOnEdge) =
6055
ValueOnEdge(
6156
shapeIndex = nativeObj.shapeIndex,
62-
percentAlong = nativeObj.percentAlong,
6357
value = nativeObj.value
6458
)
6559
}

libnavigation-core/src/main/java/com/mapbox/navigation/core/sensor/SensorData.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.os.SystemClock
44
import com.mapbox.bindgen.Value
55
import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI
66
import com.mapbox.navigator.SensorType
7+
import com.mapbox.navigator.Weather
78

89
/**
910
* Data obtained from sensors
@@ -65,6 +66,24 @@ abstract class SensorData internal constructor() {
6566
* Fog weather condition
6667
*/
6768
object Fog : Condition()
69+
70+
/**
71+
* Wet road weather condition
72+
*/
73+
object WetRoad : Condition()
74+
75+
internal companion object {
76+
77+
@JvmSynthetic
78+
fun createFromNativeObject(nativeObject: com.mapbox.navigator.Weather): Condition {
79+
return when (nativeObject) {
80+
com.mapbox.navigator.Weather.FOG -> Fog
81+
com.mapbox.navigator.Weather.RAIN -> Rain
82+
com.mapbox.navigator.Weather.SNOW -> Snow
83+
com.mapbox.navigator.Weather.WET_ROAD -> WetRoad
84+
}
85+
}
86+
}
6887
}
6988
}
7089

@@ -138,6 +157,7 @@ abstract class SensorData internal constructor() {
138157
is Weather.Condition.Rain -> 0
139158
is Weather.Condition.Snow -> 1
140159
is Weather.Condition.Fog -> 2
160+
is Weather.Condition.WetRoad -> 3
141161
else -> error("Unsupported weather condition type: $condition")
142162
}
143163
return Value.valueOf(order)

0 commit comments

Comments
 (0)