Bimba.git

ref: a52096478ab19aae3f657e40d0b973ae1276e090

app/src/main/java/ml/adamsprogs/bimba/gtfs/Trip.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
package ml.adamsprogs.bimba.gtfs

data class Trip(val routeId: AgencyAndId, val serviceId: AgencyAndId, val id: ID, val headsign: String, val direction: Int, val shapeId: AgencyAndId) {
    data class ID(val id: AgencyAndId, val modification: Set<Modification>, val isMain: Boolean) {
        data class Modification(val id: AgencyAndId, val stopRange: IntRange?)
    }

    val rawId: String
        get() {
            val builder = StringBuilder(id.id.toString())
            id.modification.forEach {
                builder.append("^")
                builder.append(it.id)
                if (it.stopRange != null) {
                    builder.append(":")
                    builder.append(it.stopRange.start)
                    builder.append(it.stopRange.endInclusive)
                }
            }
            if (id.isMain)
                builder.append("+")
            return builder.toString()
        }
}