ref: motis2_journeys
app/src/main/java/xyz/apiote/bimba/czwek/repo/Journey.kt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
// SPDX-FileCopyrightText: Adam Evyčędo // // SPDX-License-Identifier: GPL-3.0-or-later package xyz.apiote.bimba.czwek.repo import android.os.Parcelable import kotlinx.parcelize.Parcelize import xyz.apiote.bimba.czwek.api.transitous.model.Place import xyz.apiote.bimba.czwek.units.DistanceUnit import xyz.apiote.bimba.czwek.units.TimeUnit import java.time.ZonedDateTime data class Journey(val startTime: ZonedDateTime, val endTime: ZonedDateTime, val legs: List<Leg>) data class Leg( val start: Event, val end: Event, val origin: xyz.apiote.bimba.czwek.repo.Place, val destination: xyz.apiote.bimba.czwek.repo.Place, val agencyName: String?, val distance: DistanceUnit?, val duration: TimeUnit, val intermediateStops: List<xyz.apiote.bimba.czwek.repo.Place>, /* TODO val shape: EncodedPolyline, val rental: Rental?, val steps: List<StepInstruction>?,*/ ) @Parcelize class Place(val stop: Stop, val latitude: Double, val longitude: Double) : Parcelable { constructor(place: Place) : this( stop = Stop(place), latitude = place.lat.toDouble(), longitude = place.lon.toDouble() ) constructor(latitude: Double, longitude: Double) : this( Stop( "", "", "", "", null, Position(latitude, longitude), emptyList<ChangeOption>(), null ), latitude, longitude ) fun planString(): String = if (stop.code == "") { "${latitude},${longitude},0" } else { stop.code } fun shortString(): String = if (stop.name == "") { "%.2f, %.2f".format( latitude, longitude ) } else { stop.name } } |