From 0af7c18500e2326e5b0f94c653262c3665d09de4 Mon Sep 17 00:00:00 2001 From: dzmitryfomchyn Date: Thu, 28 Sep 2023 14:01:44 +0200 Subject: [PATCH] Platform types for adasis --- libnavigation-core/api/current.txt | 146 +++++++++++++++++- .../navigation/core/MapboxNavigation.kt | 12 +- .../navigation/core/adasis/ADASISv2Message.kt | 37 +++++ .../core/adasis/ADASISv2MessageCallback.kt | 16 ++ .../navigation/core/adasis/AdasisConfig.kt | 64 ++++++++ .../core/adasis/AdasisConfigCycleTimes.kt | 64 ++++++++ .../core/adasis/AdasisConfigDataSending.kt | 76 +++++++++ .../core/adasis/AdasisConfigMessageOptions.kt | 64 ++++++++ .../adasis/AdasisConfigPathLevelOptions.kt | 71 +++++++++ .../core/adasis/AdasisConfigPathsConfigs.kt | 60 +++++++ .../AdasisConfigProfileLongTypeOptions.kt | 77 +++++++++ .../AdasisConfigProfileShortTypeOptions.kt | 94 +++++++++++ .../navigation/core/adasis/ProfileLong.kt | 55 +++++++ .../navigation/core/adasis/ProfileShort.kt | 55 +++++++ .../mapbox/navigation/core/adasis/Segment.kt | 49 ++++++ .../com/mapbox/navigation/core/adasis/Stub.kt | 49 ++++++ .../navigation/core/sensor/SensorData.kt | 1 + 17 files changed, 984 insertions(+), 6 deletions(-) create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ADASISv2Message.kt create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ADASISv2MessageCallback.kt create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfig.kt create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigCycleTimes.kt create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigDataSending.kt create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigMessageOptions.kt create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigPathLevelOptions.kt create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigPathsConfigs.kt create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigProfileLongTypeOptions.kt create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigProfileShortTypeOptions.kt create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ProfileLong.kt create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ProfileShort.kt create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/Segment.kt create mode 100644 libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/Stub.kt diff --git a/libnavigation-core/api/current.txt b/libnavigation-core/api/current.txt index f4671c6cb9c..0a0f3c2b3f2 100644 --- a/libnavigation-core/api/current.txt +++ b/libnavigation-core/api/current.txt @@ -85,7 +85,7 @@ package com.mapbox.navigation.core { method @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public void resetAdasisMessageCallback(); method @Deprecated public void resetTripSession(); method public void resetTripSession(com.mapbox.navigation.core.TripSessionResetCallback callback); - method @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public void setAdasisMessageCallback(com.mapbox.navigator.ADASISv2MessageCallback callback, com.mapbox.navigator.AdasisConfig adasisConfig); + method @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public void setAdasisMessageCallback(com.mapbox.navigation.core.adasis.ADASISv2MessageCallback callback, com.mapbox.navigation.core.adasis.AdasisConfig adasisConfig); method public void setArrivalController(com.mapbox.navigation.core.arrival.ArrivalController? arrivalController = com.mapbox.navigation.core.arrival.AutoArrivalController()); method public void setArrivalController(); method public void setNavigationRoutes(java.util.List routes, int initialLegIndex = 0, com.mapbox.navigation.core.RoutesSetCallback? callback = null); @@ -192,6 +192,150 @@ package com.mapbox.navigation.core { } +package com.mapbox.navigation.core.adasis { + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class ADASISv2Message { + method public long toBigEndian(); + method public java.util.List toFlatBuffer(); + method public String toHex(); + method public String toJson(); + method public long toLittleEndian(); + } + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public interface ADASISv2MessageCallback { + method public void onMessage(com.mapbox.navigation.core.adasis.ADASISv2Message message); + } + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class AdasisConfig { + ctor public AdasisConfig(com.mapbox.navigation.core.adasis.AdasisConfigCycleTimes cycleTimes, com.mapbox.navigation.core.adasis.AdasisConfigDataSending dataSending, com.mapbox.navigation.core.adasis.AdasisConfigPathsConfigs pathsOptions); + method public com.mapbox.navigation.core.adasis.AdasisConfigCycleTimes getCycleTimes(); + method public com.mapbox.navigation.core.adasis.AdasisConfigDataSending getDataSending(); + method public com.mapbox.navigation.core.adasis.AdasisConfigPathsConfigs getPathsOptions(); + property public final com.mapbox.navigation.core.adasis.AdasisConfigCycleTimes cycleTimes; + property public final com.mapbox.navigation.core.adasis.AdasisConfigDataSending dataSending; + property public final com.mapbox.navigation.core.adasis.AdasisConfigPathsConfigs pathsOptions; + } + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class AdasisConfigCycleTimes { + ctor public AdasisConfigCycleTimes(int metadataCycleOnStartMs, int metadataCycleSeconds, int positionCycleMs); + method public int getMetadataCycleOnStartMs(); + method public int getMetadataCycleSeconds(); + method public int getPositionCycleMs(); + property public final int metadataCycleOnStartMs; + property public final int metadataCycleSeconds; + property public final int positionCycleMs; + } + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class AdasisConfigDataSending { + ctor public AdasisConfigDataSending(int messageIntervalMs, int messagesInPackage, boolean sortProfileshortsByOffset, boolean sortProfilelongsByOffset, boolean enableRetransmission); + method public boolean getEnableRetransmission(); + method public int getMessageIntervalMs(); + method public int getMessagesInPackage(); + method public boolean getSortProfilelongsByOffset(); + method public boolean getSortProfileshortsByOffset(); + property public final boolean enableRetransmission; + property public final int messageIntervalMs; + property public final int messagesInPackage; + property public final boolean sortProfilelongsByOffset; + property public final boolean sortProfileshortsByOffset; + } + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class AdasisConfigMessageOptions { + ctor public AdasisConfigMessageOptions(boolean enable, int radiusMeters, int repetitionMeters); + method public boolean getEnable(); + method public int getRadiusMeters(); + method public int getRepetitionMeters(); + property public final boolean enable; + property public final int radiusMeters; + property public final int repetitionMeters; + } + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class AdasisConfigPathLevelOptions { + ctor public AdasisConfigPathLevelOptions(com.mapbox.navigation.core.adasis.Stub stub, com.mapbox.navigation.core.adasis.Segment segment, com.mapbox.navigation.core.adasis.ProfileShort profileShort, com.mapbox.navigation.core.adasis.ProfileLong profileLong); + method public com.mapbox.navigation.core.adasis.ProfileLong getProfileLong(); + method public com.mapbox.navigation.core.adasis.ProfileShort getProfileShort(); + method public com.mapbox.navigation.core.adasis.Segment getSegment(); + method public com.mapbox.navigation.core.adasis.Stub getStub(); + property public final com.mapbox.navigation.core.adasis.ProfileLong profileLong; + property public final com.mapbox.navigation.core.adasis.ProfileShort profileShort; + property public final com.mapbox.navigation.core.adasis.Segment segment; + property public final com.mapbox.navigation.core.adasis.Stub stub; + } + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class AdasisConfigPathsConfigs { + ctor public AdasisConfigPathsConfigs(com.mapbox.navigation.core.adasis.AdasisConfigPathLevelOptions mpp, com.mapbox.navigation.core.adasis.AdasisConfigPathLevelOptions level1, com.mapbox.navigation.core.adasis.AdasisConfigPathLevelOptions level2); + method public com.mapbox.navigation.core.adasis.AdasisConfigPathLevelOptions getLevel1(); + method public com.mapbox.navigation.core.adasis.AdasisConfigPathLevelOptions getLevel2(); + method public com.mapbox.navigation.core.adasis.AdasisConfigPathLevelOptions getMpp(); + property public final com.mapbox.navigation.core.adasis.AdasisConfigPathLevelOptions level1; + property public final com.mapbox.navigation.core.adasis.AdasisConfigPathLevelOptions level2; + property public final com.mapbox.navigation.core.adasis.AdasisConfigPathLevelOptions mpp; + } + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class AdasisConfigProfileLongTypeOptions { + ctor public AdasisConfigProfileLongTypeOptions(boolean lat, boolean lon, boolean alt, boolean trafficSign, boolean extendedLane); + method public boolean getAlt(); + method public boolean getExtendedLane(); + method public boolean getLat(); + method public boolean getLon(); + method public boolean getTrafficSign(); + property public final boolean alt; + property public final boolean extendedLane; + property public final boolean lat; + property public final boolean lon; + property public final boolean trafficSign; + } + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class AdasisConfigProfileShortTypeOptions { + ctor public AdasisConfigProfileShortTypeOptions(boolean slopeStep, boolean slopeLinear, boolean curvature, boolean routeNumTypes, boolean roadCondition, boolean roadAccessibility, boolean variableSpeedSign, boolean headingChange); + method public boolean getCurvature(); + method public boolean getHeadingChange(); + method public boolean getRoadAccessibility(); + method public boolean getRoadCondition(); + method public boolean getRouteNumTypes(); + method public boolean getSlopeLinear(); + method public boolean getSlopeStep(); + method public boolean getVariableSpeedSign(); + property public final boolean curvature; + property public final boolean headingChange; + property public final boolean roadAccessibility; + property public final boolean roadCondition; + property public final boolean routeNumTypes; + property public final boolean slopeLinear; + property public final boolean slopeStep; + property public final boolean variableSpeedSign; + } + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class ProfileLong { + ctor public ProfileLong(com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions options, com.mapbox.navigation.core.adasis.AdasisConfigProfileLongTypeOptions types); + method public com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions getOptions(); + method public com.mapbox.navigation.core.adasis.AdasisConfigProfileLongTypeOptions getTypes(); + property public final com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions options; + property public final com.mapbox.navigation.core.adasis.AdasisConfigProfileLongTypeOptions types; + } + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class ProfileShort { + ctor public ProfileShort(com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions options, com.mapbox.navigation.core.adasis.AdasisConfigProfileShortTypeOptions types); + method public com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions getOptions(); + method public com.mapbox.navigation.core.adasis.AdasisConfigProfileShortTypeOptions getTypes(); + property public final com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions options; + property public final com.mapbox.navigation.core.adasis.AdasisConfigProfileShortTypeOptions types; + } + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class Segment { + ctor public Segment(com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions options); + method public com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions getOptions(); + property public final com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions options; + } + + @com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI public final class Stub { + ctor public Stub(com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions options); + method public com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions getOptions(); + property public final com.mapbox.navigation.core.adasis.AdasisConfigMessageOptions options; + } + +} + package com.mapbox.navigation.core.arrival { public interface ArrivalController { diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt index 234400c70fc..6d7f499311e 100644 --- a/libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt @@ -43,6 +43,9 @@ import com.mapbox.navigation.base.trip.notification.NotificationAction import com.mapbox.navigation.base.trip.notification.TripNotification import com.mapbox.navigation.base.trip.notification.TripNotificationInterceptor import com.mapbox.navigation.core.accounts.BillingController +import com.mapbox.navigation.core.adasis.ADASISv2Message +import com.mapbox.navigation.core.adasis.ADASISv2MessageCallback +import com.mapbox.navigation.core.adasis.AdasisConfig import com.mapbox.navigation.core.arrival.ArrivalController import com.mapbox.navigation.core.arrival.ArrivalObserver import com.mapbox.navigation.core.arrival.ArrivalProgressObserver @@ -136,8 +139,6 @@ import com.mapbox.navigation.utils.internal.logD import com.mapbox.navigation.utils.internal.logE import com.mapbox.navigation.utils.internal.logI import com.mapbox.navigation.utils.internal.monitorChannelWithException -import com.mapbox.navigator.ADASISv2MessageCallback -import com.mapbox.navigator.AdasisConfig import com.mapbox.navigator.AlertsServiceOptions import com.mapbox.navigator.ConfigHandle import com.mapbox.navigator.ElectronicHorizonOptions @@ -1979,8 +1980,6 @@ class MapboxNavigation @VisibleForTesting internal constructor( } /** - * TODO use platform types? - * * Sets a callback for ADASIS messages * * @param callback Message callback @@ -1988,7 +1987,10 @@ class MapboxNavigation @VisibleForTesting internal constructor( */ @ExperimentalPreviewMapboxNavigationAPI fun setAdasisMessageCallback(callback: ADASISv2MessageCallback, adasisConfig: AdasisConfig) { - navigator.setAdasisMessageCallback(callback, adasisConfig) + navigator.setAdasisMessageCallback( + { message -> callback.onMessage(ADASISv2Message(message)) }, + adasisConfig.toNativeAdasisConfig() + ) } /** diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ADASISv2Message.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ADASISv2Message.kt new file mode 100644 index 00000000000..8f621542303 --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ADASISv2Message.kt @@ -0,0 +1,37 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * Describes a class holding methods for ADASISv2 messages. + */ +@ExperimentalPreviewMapboxNavigationAPI +class ADASISv2Message internal constructor( + private val nativeMessage: com.mapbox.navigator.ADASISv2Message +) { + + /** + * Converts this message to list of bytes + */ + fun toFlatBuffer(): List = nativeMessage.toFlatBuffer() + + /** + * Converts this message to JSON + */ + fun toJson(): String = nativeMessage.toJson() + + /** + * Converts this message to hex string + */ + fun toHex(): String = nativeMessage.toHex() + + /** + * Converts this message to big endian + */ + fun toBigEndian(): Long = nativeMessage.toBigEndian() + + /** + * Converts this message to little endian + */ + fun toLittleEndian(): Long = nativeMessage.toLittleEndian() +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ADASISv2MessageCallback.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ADASISv2MessageCallback.kt new file mode 100644 index 00000000000..d921b21a10a --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ADASISv2MessageCallback.kt @@ -0,0 +1,16 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * Callback which is getting called to report ADASISv2Message + */ +@ExperimentalPreviewMapboxNavigationAPI +interface ADASISv2MessageCallback { + + /** + * Called when ADASIS message is available + * @param message ADASIS message + */ + fun onMessage(message: ADASISv2Message) +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfig.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfig.kt new file mode 100644 index 00000000000..41a99584d53 --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfig.kt @@ -0,0 +1,64 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * Configuration of ADASISv2 feature. + * + * @param cycleTimes message generation cycle times configuration + * @param dataSending data sending configuration + * @param pathsOptions ADASISv2 path level specific configurations + */ +@ExperimentalPreviewMapboxNavigationAPI +class AdasisConfig( + val cycleTimes: AdasisConfigCycleTimes, + val dataSending: AdasisConfigDataSending, + val pathsOptions: AdasisConfigPathsConfigs, +) { + + @JvmSynthetic + internal fun toNativeAdasisConfig(): com.mapbox.navigator.AdasisConfig { + return com.mapbox.navigator.AdasisConfig( + cycleTimes.toNativeAdasisConfigCycleTimes(), + dataSending.toNativeAdasisConfigDataSending(), + pathsOptions.toNativeAdasisConfigPathsConfigs(), + ) + } + + /** + * Indicates whether some other object is "equal to" this one. + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as AdasisConfig + + if (cycleTimes != other.cycleTimes) return false + if (dataSending != other.dataSending) return false + if (pathsOptions != other.pathsOptions) return false + + return true + } + + /** + * Returns a hash code value for the object. + */ + override fun hashCode(): Int { + var result = cycleTimes.hashCode() + result = 31 * result + dataSending.hashCode() + result = 31 * result + pathsOptions.hashCode() + return result + } + + /** + * Returns a string representation of the object. + */ + override fun toString(): String { + return "AdasisConfig(" + + "cycleTimes=$cycleTimes, " + + "dataSending=$dataSending, " + + "pathsOptions=$pathsOptions" + + ")" + } +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigCycleTimes.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigCycleTimes.kt new file mode 100644 index 00000000000..986b7bdfc8f --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigCycleTimes.kt @@ -0,0 +1,64 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * Message generation cycle times configuration + * + * @param metadataCycleOnStartMs time in milliseconds between sending metadata message on start + * @param metadataCycleSeconds time in seconds between repetition of metadata message + * @param positionCycleMs time in milliseconds between sending position message + */ +@ExperimentalPreviewMapboxNavigationAPI +class AdasisConfigCycleTimes( + val metadataCycleOnStartMs: Int, + val metadataCycleSeconds: Int, + val positionCycleMs: Int, +) { + + @JvmSynthetic + internal fun toNativeAdasisConfigCycleTimes(): com.mapbox.navigator.AdasisConfigCycleTimes { + return com.mapbox.navigator.AdasisConfigCycleTimes( + metadataCycleOnStartMs, + metadataCycleSeconds, + positionCycleMs + ) + } + + /** + * Indicates whether some other object is "equal to" this one. + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as AdasisConfigCycleTimes + + if (metadataCycleOnStartMs != other.metadataCycleOnStartMs) return false + if (metadataCycleSeconds != other.metadataCycleSeconds) return false + if (positionCycleMs != other.positionCycleMs) return false + + return true + } + + /** + * Returns a hash code value for the object. + */ + override fun hashCode(): Int { + var result = metadataCycleOnStartMs + result = 31 * result + metadataCycleSeconds + result = 31 * result + positionCycleMs + return result + } + + /** + * Returns a string representation of the object. + */ + override fun toString(): String { + return "AdasisConfigCycleTimes(" + + "metadataCycleOnStartMs=$metadataCycleOnStartMs, " + + "metadataCycleSeconds=$metadataCycleSeconds, " + + "positionCycleMs=$positionCycleMs" + + ")" + } +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigDataSending.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigDataSending.kt new file mode 100644 index 00000000000..bb159ad820e --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigDataSending.kt @@ -0,0 +1,76 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * Data sending configuration + * * @param messageIntervalMs interval between sending messages in milliseconds + * @param messagesInPackage number of messages in one package (one message is 8 bytes) + * @param sortProfileshortsByOffset if true, profileshorts will be sorted by offset + * @param sortProfilelongsByOffset if true, profilelongs will be sorted by offset + * @param enableRetransmission if true, retransmission will be enabled + * (package will be appended with retransmission data, messages from previous cycles) + */ +@ExperimentalPreviewMapboxNavigationAPI +class AdasisConfigDataSending( + val messageIntervalMs: Int, + val messagesInPackage: Int, + val sortProfileshortsByOffset: Boolean, + val sortProfilelongsByOffset: Boolean, + val enableRetransmission: Boolean, +) { + + @JvmSynthetic + internal fun toNativeAdasisConfigDataSending(): com.mapbox.navigator.AdasisConfigDataSending { + return com.mapbox.navigator.AdasisConfigDataSending( + messageIntervalMs, + messagesInPackage, + sortProfileshortsByOffset, + sortProfilelongsByOffset, + enableRetransmission, + ) + } + + /** + * Indicates whether some other object is "equal to" this one. + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as AdasisConfigDataSending + + if (messageIntervalMs != other.messageIntervalMs) return false + if (messagesInPackage != other.messagesInPackage) return false + if (sortProfileshortsByOffset != other.sortProfileshortsByOffset) return false + if (sortProfilelongsByOffset != other.sortProfilelongsByOffset) return false + if (enableRetransmission != other.enableRetransmission) return false + + return true + } + + /** + * Returns a hash code value for the object. + */ + override fun hashCode(): Int { + var result = messageIntervalMs + result = 31 * result + messagesInPackage + result = 31 * result + sortProfileshortsByOffset.hashCode() + result = 31 * result + sortProfilelongsByOffset.hashCode() + result = 31 * result + enableRetransmission.hashCode() + return result + } + + /** + * Returns a string representation of the object. + */ + override fun toString(): String { + return "AdasisConfigDataSending(" + + "messageIntervalMs=$messageIntervalMs, " + + "messagesInPackage=$messagesInPackage, " + + "sortProfileshortsByOffset=$sortProfileshortsByOffset, " + + "sortProfilelongsByOffset=$sortProfilelongsByOffset, " + + "enableRetransmission=$enableRetransmission" + + ")" + } +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigMessageOptions.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigMessageOptions.kt new file mode 100644 index 00000000000..d2cdf207e96 --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigMessageOptions.kt @@ -0,0 +1,64 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * Common message options + * @param enable if true, message of that type will be generated + * @param radiusMeters distance along EH path in meters, for which message will be generated + * @param repetitionMeters distance along EH path in meters, for which message will be retransmitted + */ +@ExperimentalPreviewMapboxNavigationAPI +class AdasisConfigMessageOptions( + val enable: Boolean, + val radiusMeters: Int, + val repetitionMeters: Int, +) { + + @JvmSynthetic + internal fun toNativeAdasisConfigMessageOptions(): + com.mapbox.navigator.AdasisConfigMessageOptions { + return com.mapbox.navigator.AdasisConfigMessageOptions( + enable, + radiusMeters, + repetitionMeters + ) + } + + /** + * Indicates whether some other object is "equal to" this one. + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as AdasisConfigMessageOptions + + if (enable != other.enable) return false + if (radiusMeters != other.radiusMeters) return false + if (repetitionMeters != other.repetitionMeters) return false + + return true + } + + /** + * Returns a hash code value for the object. + */ + override fun hashCode(): Int { + var result = enable.hashCode() + result = 31 * result + radiusMeters + result = 31 * result + repetitionMeters + return result + } + + /** + * Returns a string representation of the object. + */ + override fun toString(): String { + return "AdasisConfigMessageOptions(" + + "enable=$enable, " + + "radiusMeters=$radiusMeters, " + + "repetitionMeters=$repetitionMeters" + + ")" + } +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigPathLevelOptions.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigPathLevelOptions.kt new file mode 100644 index 00000000000..ec199d1bbf0 --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigPathLevelOptions.kt @@ -0,0 +1,71 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * Path level options + * + * @param stub Stub message options + * @param segment Segment message options + * @param profileShort Profile short message options + * @param profileLong Profile long message options + */ +@ExperimentalPreviewMapboxNavigationAPI +class AdasisConfigPathLevelOptions( + val stub: Stub, + val segment: Segment, + val profileShort: ProfileShort, + val profileLong: ProfileLong, +) { + + @JvmSynthetic + internal fun toNativeAdasisConfigPathLevelOptions(): + com.mapbox.navigator.AdasisConfigPathLevelOptions { + return com.mapbox.navigator.AdasisConfigPathLevelOptions( + stub.toNativeStub(), + segment.toNativeSegment(), + profileShort.toNativeProfileShort(), + profileLong.toNativeProfileLong(), + ) + } + + /** + * Indicates whether some other object is "equal to" this one. + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as AdasisConfigPathLevelOptions + + if (stub != other.stub) return false + if (segment != other.segment) return false + if (profileShort != other.profileShort) return false + if (profileLong != other.profileLong) return false + + return true + } + + /** + * Returns a hash code value for the object. + */ + override fun hashCode(): Int { + var result = stub.hashCode() + result = 31 * result + segment.hashCode() + result = 31 * result + profileShort.hashCode() + result = 31 * result + profileLong.hashCode() + return result + } + + /** + * Returns a string representation of the object. + */ + override fun toString(): String { + return "AdasisConfigPathLevelOptions(" + + "stub=$stub, " + + "segment=$segment, " + + "profileShort=$profileShort, " + + "profileLong=$profileLong" + + ")" + } +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigPathsConfigs.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigPathsConfigs.kt new file mode 100644 index 00000000000..d960d1efc28 --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigPathsConfigs.kt @@ -0,0 +1,60 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * ADASISv2 path level specific configurations + * + * @param mpp most probable path config + * @param level1 level 1 path config + * @param level2 level 2 path config + */ +@ExperimentalPreviewMapboxNavigationAPI +class AdasisConfigPathsConfigs( + val mpp: AdasisConfigPathLevelOptions, + val level1: AdasisConfigPathLevelOptions, + val level2: AdasisConfigPathLevelOptions, +) { + + @JvmSynthetic + internal fun toNativeAdasisConfigPathsConfigs(): com.mapbox.navigator.AdasisConfigPathsConfigs { + return com.mapbox.navigator.AdasisConfigPathsConfigs( + mpp.toNativeAdasisConfigPathLevelOptions(), + level1.toNativeAdasisConfigPathLevelOptions(), + level2.toNativeAdasisConfigPathLevelOptions(), + ) + } + + /** + * Indicates whether some other object is "equal to" this one. + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as AdasisConfigPathsConfigs + + if (mpp != other.mpp) return false + if (level1 != other.level1) return false + if (level2 != other.level2) return false + + return true + } + + /** + * Returns a hash code value for the object. + */ + override fun hashCode(): Int { + var result = mpp.hashCode() + result = 31 * result + level1.hashCode() + result = 31 * result + level2.hashCode() + return result + } + + /** + * Returns a string representation of the object. + */ + override fun toString(): String { + return "AdasisConfigPathsConfigs(mpp=$mpp, level1=$level1, level2=$level2)" + } +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigProfileLongTypeOptions.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigProfileLongTypeOptions.kt new file mode 100644 index 00000000000..d059427c437 --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigProfileLongTypeOptions.kt @@ -0,0 +1,77 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * Profile Long message options + * + * @param lat if true, latitude type will be generated + * @param lon if true, longitude type will be generated + * @param alt if true, altitude type will be generated + * @param trafficSign if true, Traffic Sign type will be generated + * @param extendedLane if true, Extended Lane type will be generated + */ +@ExperimentalPreviewMapboxNavigationAPI +class AdasisConfigProfileLongTypeOptions( + val lat: Boolean, + val lon: Boolean, + val alt: Boolean, + val trafficSign: Boolean, + val extendedLane: Boolean, +) { + + @JvmSynthetic + internal fun toNativeAdasisConfigProfilelongTypeOptions(): + com.mapbox.navigator.AdasisConfigProfilelongTypeOptions { + return com.mapbox.navigator.AdasisConfigProfilelongTypeOptions( + lat, + lon, + alt, + trafficSign, + extendedLane + ) + } + + /** + * Indicates whether some other object is "equal to" this one. + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as AdasisConfigProfileLongTypeOptions + + if (lat != other.lat) return false + if (lon != other.lon) return false + if (alt != other.alt) return false + if (trafficSign != other.trafficSign) return false + if (extendedLane != other.extendedLane) return false + + return true + } + + /** + * Returns a hash code value for the object. + */ + override fun hashCode(): Int { + var result = lat.hashCode() + result = 31 * result + lon.hashCode() + result = 31 * result + alt.hashCode() + result = 31 * result + trafficSign.hashCode() + result = 31 * result + extendedLane.hashCode() + return result + } + + /** + * Returns a string representation of the object. + */ + override fun toString(): String { + return "AdasisConfigProfileLongTypeOptions(" + + "lat=$lat, " + + "lon=$lon, " + + "alt=$alt, " + + "trafficSign=$trafficSign, " + + "extendedLane=$extendedLane" + + ")" + } +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigProfileShortTypeOptions.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigProfileShortTypeOptions.kt new file mode 100644 index 00000000000..54a92984fdb --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/AdasisConfigProfileShortTypeOptions.kt @@ -0,0 +1,94 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * Profile short message options + * * @param slopeStep if true, slopeStep type will be generated + * @param slopeLinear if true, slopeLinear type will be generated + * @param curvature if true, curvature type will be generated + * @param routeNumTypes if true, routeNumTypes type will be generated + * @param roadCondition if true, roadCondition type will be generated + * @param roadAccessibility if true, roadAccessibility type will be generated + * @param variableSpeedSign if true, variableSpeedSign type will be generated + * @param headingChange if true, headingChange type will be generated + */ +@ExperimentalPreviewMapboxNavigationAPI +class AdasisConfigProfileShortTypeOptions( + val slopeStep: Boolean, + val slopeLinear: Boolean, + val curvature: Boolean, + val routeNumTypes: Boolean, + val roadCondition: Boolean, + val roadAccessibility: Boolean, + val variableSpeedSign: Boolean, + val headingChange: Boolean, +) { + + @JvmSynthetic + internal fun toNativeAdasisConfigProfileShortTypeOptions(): + com.mapbox.navigator.AdasisConfigProfileshortTypeOptions { + return com.mapbox.navigator.AdasisConfigProfileshortTypeOptions( + slopeStep, + slopeLinear, + curvature, + routeNumTypes, + roadCondition, + roadAccessibility, + variableSpeedSign, + headingChange + ) + } + + /** + * Indicates whether some other object is "equal to" this one. + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as AdasisConfigProfileShortTypeOptions + + if (slopeStep != other.slopeStep) return false + if (slopeLinear != other.slopeLinear) return false + if (curvature != other.curvature) return false + if (routeNumTypes != other.routeNumTypes) return false + if (roadCondition != other.roadCondition) return false + if (roadAccessibility != other.roadAccessibility) return false + if (variableSpeedSign != other.variableSpeedSign) return false + if (headingChange != other.headingChange) return false + + return true + } + + /** + * Returns a hash code value for the object. + */ + override fun hashCode(): Int { + var result = slopeStep.hashCode() + result = 31 * result + slopeLinear.hashCode() + result = 31 * result + curvature.hashCode() + result = 31 * result + routeNumTypes.hashCode() + result = 31 * result + roadCondition.hashCode() + result = 31 * result + roadAccessibility.hashCode() + result = 31 * result + variableSpeedSign.hashCode() + result = 31 * result + headingChange.hashCode() + return result + } + + /** + * Returns a string representation of the object. + */ + override fun toString(): String { + return "AdasisConfigProfileShortTypeOptions(" + + "slopeStep=$slopeStep, " + + "slopeLinear=$slopeLinear, " + + "curvature=$curvature, " + + "routeNumTypes=$routeNumTypes, " + + "roadCondition=$roadCondition, " + + "roadAccessibility=$roadAccessibility, " + + "variableSpeedSign=$variableSpeedSign, " + + "headingChange=$headingChange" + + ")" + } +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ProfileLong.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ProfileLong.kt new file mode 100644 index 00000000000..d3cc8b01cb6 --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ProfileLong.kt @@ -0,0 +1,55 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * Profile long message options + * + * @param options common options for profile long message + * @param types options for each type of profile long message + */ +@ExperimentalPreviewMapboxNavigationAPI +class ProfileLong( + val options: AdasisConfigMessageOptions, + val types: AdasisConfigProfileLongTypeOptions, +) { + + @JvmSynthetic + internal fun toNativeProfileLong(): com.mapbox.navigator.Profilelong { + return com.mapbox.navigator.Profilelong( + options.toNativeAdasisConfigMessageOptions(), + types.toNativeAdasisConfigProfilelongTypeOptions() + ) + } + + /** + * Indicates whether some other object is "equal to" this one. + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as ProfileLong + + if (options != other.options) return false + if (types != other.types) return false + + return true + } + + /** + * Returns a hash code value for the object. + */ + override fun hashCode(): Int { + var result = options.hashCode() + result = 31 * result + types.hashCode() + return result + } + + /** + * Returns a string representation of the object. + */ + override fun toString(): String { + return "ProfileLong(options=$options, types=$types)" + } +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ProfileShort.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ProfileShort.kt new file mode 100644 index 00000000000..322c956605d --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/ProfileShort.kt @@ -0,0 +1,55 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * Profile short message options + * + * @param options common options for profile short message + * @param types options for each type of profile short message + */ +@ExperimentalPreviewMapboxNavigationAPI +class ProfileShort( + val options: AdasisConfigMessageOptions, + val types: AdasisConfigProfileShortTypeOptions, +) { + + @JvmSynthetic + internal fun toNativeProfileShort(): com.mapbox.navigator.Profileshort { + return com.mapbox.navigator.Profileshort( + options.toNativeAdasisConfigMessageOptions(), + types.toNativeAdasisConfigProfileShortTypeOptions(), + ) + } + + /** + * Indicates whether some other object is "equal to" this one. + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as ProfileShort + + if (options != other.options) return false + if (types != other.types) return false + + return true + } + + /** + * Returns a hash code value for the object. + */ + override fun hashCode(): Int { + var result = options.hashCode() + result = 31 * result + types.hashCode() + return result + } + + /** + * Returns a string representation of the object. + */ + override fun toString(): String { + return "ProfileShort(options=$options, types=$types)" + } +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/Segment.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/Segment.kt new file mode 100644 index 00000000000..82defaaa8c2 --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/Segment.kt @@ -0,0 +1,49 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * Segment message options + * + * @param options common options for segment + */ +@ExperimentalPreviewMapboxNavigationAPI +class Segment( + val options: AdasisConfigMessageOptions, +) { + + @JvmSynthetic + internal fun toNativeSegment(): com.mapbox.navigator.Segment { + return com.mapbox.navigator.Segment( + options.toNativeAdasisConfigMessageOptions() + ) + } + + /** + * Indicates whether some other object is "equal to" this one. + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as Segment + + if (options != other.options) return false + + return true + } + + /** + * Returns a hash code value for the object. + */ + override fun hashCode(): Int { + return options.hashCode() + } + + /** + * Returns a string representation of the object. + */ + override fun toString(): String { + return "Segment(options=$options)" + } +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/Stub.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/Stub.kt new file mode 100644 index 00000000000..08743619aca --- /dev/null +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/adasis/Stub.kt @@ -0,0 +1,49 @@ +package com.mapbox.navigation.core.adasis + +import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI + +/** + * Stub message options + * + * @param options common options for segment + */ +@ExperimentalPreviewMapboxNavigationAPI +class Stub( + val options: AdasisConfigMessageOptions, +) { + + @JvmSynthetic + internal fun toNativeStub(): com.mapbox.navigator.Stub { + return com.mapbox.navigator.Stub( + options.toNativeAdasisConfigMessageOptions() + ) + } + + /** + * Indicates whether some other object is "equal to" this one. + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as Segment + + if (options != other.options) return false + + return true + } + + /** + * Returns a hash code value for the object. + */ + override fun hashCode(): Int { + return options.hashCode() + } + + /** + * Returns a string representation of the object. + */ + override fun toString(): String { + return "Stub(options=$options)" + } +} diff --git a/libnavigation-core/src/main/java/com/mapbox/navigation/core/sensor/SensorData.kt b/libnavigation-core/src/main/java/com/mapbox/navigation/core/sensor/SensorData.kt index 330fab032f9..a6a1bbaaa0f 100644 --- a/libnavigation-core/src/main/java/com/mapbox/navigation/core/sensor/SensorData.kt +++ b/libnavigation-core/src/main/java/com/mapbox/navigation/core/sensor/SensorData.kt @@ -110,6 +110,7 @@ abstract class SensorData internal constructor() { } } + @JvmSynthetic internal fun toNativeSensorData(): com.mapbox.navigator.SensorData { /** * NN requires [com.mapbox.navigator.SensorData.monotonicTimestampNanoseconds] to be based