refactor(server): move gtfsrt to separate module
This commit is contained in:
parent
0181497420
commit
ed9d294afc
10 changed files with 205 additions and 180 deletions
|
|
@ -6,7 +6,6 @@ plugins {
|
|||
alias(libs.plugins.androidMultiplatformLibrary)
|
||||
alias(libs.plugins.ksp)
|
||||
alias(libs.plugins.room)
|
||||
alias(libs.plugins.wire)
|
||||
}
|
||||
|
||||
room {
|
||||
|
|
@ -62,10 +61,3 @@ dependencies {
|
|||
add("kspIosSimulatorArm64", libs.room.compiler)
|
||||
add("kspJvm", libs.room.compiler)
|
||||
}
|
||||
|
||||
wire {
|
||||
sourcePath {
|
||||
srcDir("src/commonMain/proto")
|
||||
}
|
||||
kotlin {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
package moe.lava.banksia.data.gtfsr
|
||||
|
||||
import com.google.transit.realtime.FeedMessage
|
||||
|
||||
abstract class GtfsRealtime(protected val data: FeedMessage) {
|
||||
companion object {
|
||||
inline fun <T: GtfsRealtime> parse(ctor: (FeedMessage) -> T, data: ByteArray): T {
|
||||
val message = FeedMessage.ADAPTER.decode(data)
|
||||
return ctor(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package moe.lava.banksia.data.gtfsr
|
||||
|
||||
import com.google.transit.realtime.FeedMessage
|
||||
import moe.lava.banksia.util.Point
|
||||
|
||||
class RealtimeVehiclePositions(data: FeedMessage) : GtfsRealtime(data) {
|
||||
private val positions = mutableMapOf<String, Point>()
|
||||
|
||||
init {
|
||||
data.entity
|
||||
.mapNotNull { ent ->
|
||||
if (ent.vehicle?.position == null) return@mapNotNull null
|
||||
ent.id to ent.vehicle.position.run {
|
||||
Point(latitude.toDouble(), longitude.toDouble())
|
||||
}
|
||||
}
|
||||
.let { positions.putAll(it) }
|
||||
}
|
||||
|
||||
fun getAll() = positions.toMap()
|
||||
fun forTrip(tripId: String) = positions[tripId]
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue