Bimba.git

ref: 8693f82819b7dc79e894edcff7d67d69c7f68b2b

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
// 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()
	)

	fun planString(): String = if (stop.code == "") {
		"${latitude},${longitude},0"
	} else {
		stop.code
	}
}