aboutsummaryrefslogtreecommitdiff
path: root/shared/src/commonMain/kotlin/mx
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-29 22:33:13 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-29 22:33:13 -0600
commit3f4400be135ee50b9da9c9aa7e709b04b26f80ac (patch)
treebb858c409a22d2176aecbe8f7774043d92723916 /shared/src/commonMain/kotlin/mx
parent4ff1b200f12fc335abd1f0f6117649f50b3968ce (diff)
downloadetbsa-trackermap-mobile-3f4400be135ee50b9da9c9aa7e709b04b26f80ac.tar.gz
etbsa-trackermap-mobile-3f4400be135ee50b9da9c9aa7e709b04b26f80ac.tar.bz2
etbsa-trackermap-mobile-3f4400be135ee50b9da9c9aa7e709b04b26f80ac.zip
Moved MarkerType to Marker.Type in shared module
Diffstat (limited to 'shared/src/commonMain/kotlin/mx')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Marker.kt60
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MarkerType.kt25
2 files changed, 33 insertions, 52 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Marker.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Marker.kt
index a0cc729..606d92a 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Marker.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Marker.kt
@@ -1,26 +1,32 @@
package mx.trackermap.TrackerMap.client.models
import android.util.Log
-import mx.trackermap.TrackerMap.utils.MarkerType
data class Marker(
val id: Int,
val name: String,
val latitude: Double,
val longitude: Double,
- val type: MarkerType = MarkerType.DEFAULT
+ val type: Type = Type.DEFAULT
) {
+ enum class Type {
+ ANIMAL, BICYCLE, BOAT, BUS, CAR, CRANE, DEFAULT, HELICOPTER, MOTORCYCLE, OFFROAD, PERSON,
+ PICKUP, PLANE, SCOOTER, SHIP, TRACTOR, TRAIN, TRAM, TROLLEYBUS, TRUCK, VAN,
+
+ REPORT_POSITION, REPORT_START, REPORT_END
+ }
+
companion object {
fun fromUnit(unit: UnitInformation): Marker? {
- if (unit.position == null || unit.position!!.latitude == null || unit.position!!.longitude == null) {
+ if (unit.position?.latitude == null || unit.position.longitude == null) {
return null
}
return Marker(
unit.position.id!!,
unit.device.name,
- unit.position.latitude!!,
- unit.position.longitude!!,
+ unit.position.latitude,
+ unit.position.longitude,
categoryToMarkerType(unit.device.category ?: "")
)
}
@@ -52,29 +58,29 @@ data class Marker(
)
}
- fun categoryToMarkerType(category: String?): MarkerType {
+ fun categoryToMarkerType(category: String?): Type {
return when (category?.lowercase()) {
- "animal" -> MarkerType.ANIMAL
- "bicycle" -> MarkerType.BICYCLE
- "boat" -> MarkerType.BOAT
- "bus" -> MarkerType.BUS
- "car" -> MarkerType.CAR
- "crane" -> MarkerType.CRANE
- "helicopter" -> MarkerType.HELICOPTER
- "motorcycle" -> MarkerType.MOTORCYCLE
- "offroad" -> MarkerType.OFFROAD
- "person" -> MarkerType.PERSON
- "pickup" -> MarkerType.PICKUP
- "plane" -> MarkerType.PLANE
- "scooter" -> MarkerType.SCOOTER
- "ship" -> MarkerType.SHIP
- "tractor" -> MarkerType.TRACTOR
- "train" -> MarkerType.TRAIN
- "tram" -> MarkerType.TRAM
- "trolleybus" -> MarkerType.TROLLEYBUS
- "truck" -> MarkerType.TRUCK
- "van" -> MarkerType.VAN
- else -> MarkerType.DEFAULT
+ "animal" -> Type.ANIMAL
+ "bicycle" -> Type.BICYCLE
+ "boat" -> Type.BOAT
+ "bus" -> Type.BUS
+ "car" -> Type.CAR
+ "crane" -> Type.CRANE
+ "helicopter" -> Type.HELICOPTER
+ "motorcycle" -> Type.MOTORCYCLE
+ "offroad" -> Type.OFFROAD
+ "person" -> Type.PERSON
+ "pickup" -> Type.PICKUP
+ "plane" -> Type.PLANE
+ "scooter" -> Type.SCOOTER
+ "ship" -> Type.SHIP
+ "tractor" -> Type.TRACTOR
+ "train" -> Type.TRAIN
+ "tram" -> Type.TRAM
+ "trolleybus" -> Type.TROLLEYBUS
+ "truck" -> Type.TRUCK
+ "van" -> Type.VAN
+ else -> Type.DEFAULT
}
}
}
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MarkerType.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MarkerType.kt
deleted file mode 100644
index fc2abf1..0000000
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MarkerType.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * TrackerMap
- * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package mx.trackermap.TrackerMap.utils
-
-enum class MarkerType {
- ANIMAL, BICYCLE, BOAT, BUS, CAR, CRANE, DEFAULT, HELICOPTER, MOTORCYCLE, OFFROAD, PERSON,
- PICKUP, PLANE, SCOOTER, SHIP, TRACTOR, TRAIN, TRAM, TROLLEYBUS, TRUCK, VAN,
-
- REPORT_POSITION, REPORT_START, REPORT_END
-} \ No newline at end of file