149 lines
3 KiB
Kotlin
149 lines
3 KiB
Kotlin
package eu.ztsh.garmin.data
|
|
|
|
enum class OutType(val value: Int) {
|
|
|
|
Off(0x00),
|
|
Lane(0x01),
|
|
LongerLane(0x02),
|
|
LeftRoundabout(0x04),
|
|
RightRoundabout(0x08),
|
|
Flag(0x40),
|
|
ArrowOnly(0x80);
|
|
|
|
}
|
|
|
|
enum class OutAngle(val value: Int) {
|
|
|
|
Down(0x01),
|
|
SharpRight(0x02),
|
|
Right(0x04),
|
|
EasyRight(0x08),
|
|
Straight(0x10),
|
|
EasyLeft(0x20),
|
|
Left(0x40),
|
|
SharpLeft(0x80),
|
|
LeftDown(0x81),
|
|
RightDown(0x82),
|
|
AsDirection(0x00)
|
|
|
|
}
|
|
|
|
enum class Unit(val value: Int) {
|
|
|
|
Any(0),
|
|
Metres(1),
|
|
Kilometres(3),
|
|
Miles(5),
|
|
Foot(8)
|
|
|
|
}
|
|
|
|
enum class Lane(val value: Int) {
|
|
|
|
DotsRight(0x01),
|
|
OuterRight(0x02),
|
|
MiddleRight(0x04),
|
|
InnerRight(0x08),
|
|
InnerLeft(0x10),
|
|
MiddleLeft(0x20),
|
|
OuterLeft(0x40),
|
|
DotsLeft(0x80);
|
|
|
|
companion object {
|
|
val iterator = {sortedSetOf(OuterRight, MiddleRight, InnerRight, InnerLeft, MiddleLeft, OuterLeft).iterator()}
|
|
}
|
|
|
|
}
|
|
|
|
class Arrows(val lanes: Set<Lane>) {
|
|
|
|
override fun equals(other: Any?): Boolean {
|
|
if (this === other) return true
|
|
if (javaClass != other?.javaClass) return false
|
|
|
|
other as Arrows
|
|
|
|
return lanes == other.lanes
|
|
}
|
|
|
|
override fun hashCode(): Int {
|
|
return lanes.hashCode()
|
|
}
|
|
}
|
|
|
|
class Lanes(val outlines: Arrows, val lanes: Arrows)
|
|
|
|
class Distance(val distance: Double, val unit: Unit) {
|
|
|
|
override fun equals(other: Any?): Boolean {
|
|
if (this === other) return true
|
|
if (javaClass != other?.javaClass) return false
|
|
|
|
other as Distance
|
|
|
|
if (distance != other.distance) return false
|
|
if (unit != other.unit) return false
|
|
|
|
return true
|
|
}
|
|
|
|
override fun hashCode(): Int {
|
|
var result = distance.hashCode()
|
|
result = 31 * result + unit.hashCode()
|
|
return result
|
|
}
|
|
|
|
override fun toString(): String {
|
|
return "Distance($distance$unit)"
|
|
}
|
|
|
|
}
|
|
|
|
class Speed(val speed: Int, val limit: Int)
|
|
|
|
class Arrival(val hours: Int, val minutes: Int) {
|
|
|
|
override fun equals(other: Any?): Boolean {
|
|
if (this === other) return true
|
|
if (javaClass != other?.javaClass) return false
|
|
|
|
other as Arrival
|
|
|
|
if (hours != other.hours) return false
|
|
if (minutes != other.minutes) return false
|
|
|
|
return true
|
|
}
|
|
|
|
override fun hashCode(): Int {
|
|
return 61 * hours + minutes
|
|
}
|
|
}
|
|
|
|
class Direction(
|
|
var angle: OutAngle = OutAngle.AsDirection,
|
|
var out: OutType = OutType.Lane,
|
|
var roundabout: OutAngle = OutAngle.AsDirection
|
|
) {
|
|
|
|
override fun equals(other: Any?): Boolean {
|
|
if (this === other) return true
|
|
if (javaClass != other?.javaClass) return false
|
|
|
|
other as Direction
|
|
|
|
if (angle != other.angle) return false
|
|
if (out != other.out) return false
|
|
if (roundabout != other.roundabout) return false
|
|
|
|
return true
|
|
}
|
|
|
|
override fun hashCode(): Int {
|
|
var result = angle.hashCode()
|
|
result = 31 * result + out.hashCode()
|
|
result = 31 * result + roundabout.hashCode()
|
|
return result
|
|
}
|
|
|
|
}
|