Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/main/java/org/mtransit/parser/DefaultAgencyTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import org.mtransit.parser.mt.data.MRoute;
import org.mtransit.parser.mt.data.MRouteSNToIDConverter;
import org.mtransit.parser.mt.data.MServiceDate;
import org.mtransit.parser.mt.data.MServiceId;
import org.mtransit.parser.mt.data.MServiceIds;
import org.mtransit.parser.mt.data.MSpec;
import org.mtransit.parser.mt.data.MDirection;

Expand Down Expand Up @@ -151,6 +153,8 @@ public void start(@NotNull String[] args) {
MTLog.log("Generating data...");
MTLog.logDebug("Args [%d]: %s.", args.length, Arrays.asList(args));
final List<MServiceDate> lastServiceDates = MReader.loadServiceDates(args[2]);
final List<MServiceId> lastServiceIds = MReader.loadServiceIds(args[2]);
MServiceIds.addAll(lastServiceIds);
this.serviceIdInts = extractUsefulServiceIdInts(args, this, true, lastServiceDates);
final String inputUrl = args.length >= 5 ? args[4] : null;
if (excludingAll()) {
Expand Down Expand Up @@ -1317,7 +1321,7 @@ public static HashSet<Integer> extractUsefulServiceIdInts(
MTLog.log("* Generated on %s | NEXT Schedules from %s to %s.", usefulPeriod.getTodayStringInt(), usefulPeriod.getStartDate(), usefulPeriod.getEndDate());
MTLog.log("------------------------------");
}
HashSet<Integer> serviceIds = getPeriodServiceIds(usefulPeriod.getStartDate(), usefulPeriod.getEndDate(), gCalendars, gCalendarDates);
final HashSet<Integer> serviceIds = getPeriodServiceIds(usefulPeriod.getStartDate(), usefulPeriod.getEndDate(), gCalendars, gCalendarDates);
improveUsefulPeriod(usefulPeriod, c, gCalendars, gCalendarDates);
MTLog.log("Extracting useful service IDs... DONE");
//noinspection UnusedAssignment // FIXME
Expand Down Expand Up @@ -1448,7 +1452,8 @@ && diffLowerThan(DATE_FORMAT, c, pPrevious.getStartDate(), pPrevious.getEndDate(
private static boolean refreshStartEndDatesFromCalendarDates(
Period p,
HashSet<Integer> serviceIds,
List<GCalendarDate> gCalendarDates) {
List<GCalendarDate> gCalendarDates
) {
boolean newDates = false;
for (GCalendarDate gCalendarDate : gCalendarDates) {
if (gCalendarDate.isServiceIdInts(serviceIds)) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/mtransit/parser/db/DumpDbUtils.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.mtransit.parser.db

import org.mtransit.commons.FeatureFlags
import org.mtransit.commons.GTFSCommons
import org.mtransit.parser.FileUtils
import java.io.File
Expand Down Expand Up @@ -30,12 +31,18 @@ object DumpDbUtils {
SQLUtils.executeUpdate(statement, GTFSCommons.T_STOP_SQL_DROP)
SQLUtils.executeUpdate(statement, GTFSCommons.T_DIRECTION_SQL_DROP)
SQLUtils.executeUpdate(statement, GTFSCommons.T_ROUTE_SQL_DROP)
if (FeatureFlags.F_EXPORT_SERVICE_ID_INTS) {
SQLUtils.executeUpdate(statement, GTFSCommons.T_SERVICE_IDS_SQL_DROP)
}
SQLUtils.executeUpdate(statement, GTFSCommons.T_SERVICE_DATES_SQL_DROP)
// CREATE
SQLUtils.executeUpdate(statement, GTFSCommons.T_ROUTE_SQL_CREATE)
SQLUtils.executeUpdate(statement, GTFSCommons.T_DIRECTION_SQL_CREATE)
SQLUtils.executeUpdate(statement, GTFSCommons.T_STOP_SQL_CREATE)
SQLUtils.executeUpdate(statement, GTFSCommons.T_DIRECTION_STOPS_SQL_CREATE)
if (FeatureFlags.F_EXPORT_SERVICE_ID_INTS) {
SQLUtils.executeUpdate(statement, GTFSCommons.T_SERVICE_IDS_SQL_CREATE)
}
SQLUtils.executeUpdate(statement, GTFSCommons.T_SERVICE_DATES_SQL_CREATE)
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/org/mtransit/parser/gtfs/data/GAgency.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ data class GAgency(
agencyEmail,
)

@Discouraged(message = "Not memory efficient")
@Suppress("unused")
val agencyId = _agencyId
@get:Discouraged(message = "Not memory efficient")
val agencyId: AgencyId get() = _agencyId

private val _agencyId: AgencyId
get() {
return GIDs.getString(agencyIdInt)
}
get() = GIDs.getString(agencyIdInt)

@Suppress("unused")
fun isDifferentAgency(otherAgencyIdInt: Int): Boolean = agencyIdInt != otherAgencyIdInt
Expand Down
16 changes: 4 additions & 12 deletions src/main/java/org/mtransit/parser/gtfs/data/GCalendar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.mtransit.parser.gtfs.data
import androidx.annotation.Discouraged
import org.mtransit.parser.MTLog
import org.mtransit.parser.db.SQLUtils.escape
import org.mtransit.parser.gtfs.GAgencyTools
import java.util.Calendar

// https://developers.google.com/transit/gtfs/reference#calendar_fields
Expand Down Expand Up @@ -68,26 +67,19 @@ data class GCalendar(
endDate
)

@Discouraged(message = "Not memory efficient")
@Suppress("unused")
val serviceId = _serviceId
@get:Discouraged(message = "Not memory efficient")
val serviceId: String get() = _serviceId

private val _serviceId: String
get() {
return GIDs.getString(serviceIdInt)
}
get() = GIDs.getString(serviceIdInt)

val escapedServiceId: String
get() = _serviceId.escape()

val escapedServiceIdInt: Int
get() = escapedServiceId.toGIDInt()

@Suppress("unused")
fun getCleanServiceId(agencyTools: GAgencyTools): String {
return agencyTools.cleanServiceId(_serviceId)
}

val dates: List<GCalendarDate> by lazy {
initAllDates(
serviceIdInt,
Expand Down Expand Up @@ -264,7 +256,7 @@ data class GCalendar(
sunday: Boolean,
startDate: Int,
endDate: Int,
exceptionType: GCalendarDatesExceptionType = GCalendarDatesExceptionType.SERVICE_ADDED,
exceptionType: GCalendarDatesExceptionType = GCalendarDatesExceptionType.SERVICE_DEFAULT,
) = buildList {
try {
val dateFormat = GFieldTypes.makeDateFormat()
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/org/mtransit/parser/gtfs/data/GCalendarDate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,19 @@ data class GCalendarDate(
GCalendarDatesExceptionType.parse(exceptionTypeInt)
)

@Discouraged(message = "Not memory efficient")
@Suppress("unused")
val serviceId = _serviceId
@get:Discouraged(message = "Not memory efficient")
val serviceId: String get() = _serviceId

private val _serviceId: String
get() {
return GIDs.getString(serviceIdInt)
}
get() = GIDs.getString(serviceIdInt)

val escapedServiceId: String
get() = _serviceId.escape()

val escapedServiceIdInt: Int
get() = escapedServiceId.toGIDInt()

@Suppress("unused")
fun getCleanServiceId(agencyTools: GAgencyTools): String {
return agencyTools.cleanServiceId(_serviceId)
}

val uID by lazy { getNewUID(date, serviceIdInt) }

@Suppress("unused")
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/org/mtransit/parser/gtfs/data/GDirection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ data class GDirection(
destination = destination,
)

@Discouraged(message = "Not memory efficient")
@Suppress("unused")
val routeId = _routeId
@get:Discouraged(message = "Not memory efficient")
val routeId: String get() = _routeId

private val _routeId: String
get() {
return GIDs.getString(routeIdInt)
}
get() = GIDs.getString(routeIdInt)

@Suppress("unused")
fun toStringPlus(): String {
Expand Down
28 changes: 8 additions & 20 deletions src/main/java/org/mtransit/parser/gtfs/data/GFrequency.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,46 +31,34 @@ data class GFrequency(
exactTimes,
)

@Discouraged(message = "Not memory efficient")
@Suppress("unused")
val tripId = _tripId
@get:Discouraged(message = "Not memory efficient")
val tripId: String get() = _tripId

@Suppress("unused")
private val _tripId: String
get() {
return GIDs.getString(tripIdInt)
}
get() = GIDs.getString(tripIdInt)

val startTime: Int = _startTime

@Suppress("unused")
val startTimeDate: Date
get() {
return GTime.toDate(_startTime)
}
get() = GTime.toDate(_startTime)

val startTimeMs: Long
get() {
return GTime.toMs(_startTime)
}
get() = GTime.toMs(_startTime)

val endTime: Int = _endTime

@Suppress("unused")
val endTimeDate: Date
get() {
return GTime.toDate(_endTime)
}
get() = GTime.toDate(_endTime)

val endTimeMs: Long
get() {
return GTime.toMs(_endTime)
}
get() = GTime.toMs(_endTime)

val headwayMs: Long
get() {
return TimeUnit.SECONDS.toMillis(headwaySecs.toLong())
}
get() = TimeUnit.SECONDS.toMillis(headwaySecs.toLong())

@Suppress("unused")
fun toStringPlus(): String {
Expand Down
24 changes: 10 additions & 14 deletions src/main/java/org/mtransit/parser/gtfs/data/GRoute.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,34 +67,30 @@ data class GRoute(
@Suppress("unused")
fun isDifferentAgency(otherAgencyId: String): Boolean = isDifferentAgency(GIDs.getInt(otherAgencyId))

@Discouraged(message = "Not memory efficient")
@Suppress("unused")
val agencyIdOrDefault: AgencyId = _agencyId
@get:Discouraged(message = "Not memory efficient")
val agencyIdOrDefault: AgencyId get() = _agencyId

@Discouraged(message = "Not memory efficient")
@Suppress("unused")
val agencyId: AgencyId = _agencyId
@get:Discouraged(message = "Not memory efficient")
val agencyId: AgencyId get() = _agencyId

private val _agencyId: AgencyId
get() = GIDs.getString(agencyIdInt)

@Discouraged(message = "Not memory efficient")
@Suppress("unused")
val routeId = _routeId
@get:Discouraged(message = "Not memory efficient")
val routeId: RouteId get() = _routeId

private val _routeId: RouteId
get() {
return GIDs.getString(routeIdInt)
}
get() = GIDs.getString(routeIdInt)

@Discouraged(message = "Not memory efficient")
@Suppress("unused")
val originalRouteId = _originalRouteId
@get:Discouraged(message = "Not memory efficient")
val originalRouteId: String get() = _originalRouteId

private val _originalRouteId: String
get() {
return GIDs.getString(originalRouteIdInt)
}
get() = GIDs.getString(originalRouteIdInt)

@Suppress("unused")
val shortestRouteName = routeShortName.ifEmpty { routeLongName }
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/mtransit/parser/gtfs/data/GSpecExt.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.mtransit.parser.gtfs.data

fun GSpec.getRoute(gTrip: GTrip): GRoute? {
return this.getRoute(gTrip.routeIdInt)
}
fun GSpec.getRoute(gTrip: GTrip) = this.getRoute(gTrip.routeIdInt)
16 changes: 6 additions & 10 deletions src/main/java/org/mtransit/parser/gtfs/data/GStop.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,19 @@ data class GStop(
GWheelchairBoardingType.parse(wheelchairBoarding),
)

@Discouraged(message = "Not memory efficient")
@Suppress("unused")
val stopId = _stopId
@get:Discouraged(message = "Not memory efficient")
val stopId: StopId get() = _stopId

private val _stopId: StopId
get() {
return GIDs.getString(stopIdInt)
}
get() = GIDs.getString(stopIdInt)

@Discouraged(message = "Not memory efficient")
@Suppress("unused")
val parentStationId = _parentStationId
@get:Discouraged(message = "Not memory efficient")
val parentStationId: StopId? get() = _parentStationId

private val _parentStationId: StopId?
get() {
return parentStationIdInt?.let { GIDs.getString(it) }
}
get() = parentStationIdInt?.let { GIDs.getString(it) }

@JvmOverloads
@Suppress("unused")
Expand Down
32 changes: 10 additions & 22 deletions src/main/java/org/mtransit/parser/gtfs/data/GStopTime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,54 +88,42 @@ data class GStopTime(
timePoint = timePoint,
)

@Discouraged(message = "Not memory efficient")
@Suppress("unused")
val tripId = _tripId
@get:Discouraged(message = "Not memory efficient")
val tripId: String get() = _tripId

private val _tripId: String
get() {
return GIDs.getString(tripIdInt)
}
get() = GIDs.getString(tripIdInt)

@Discouraged(message = "Not memory efficient")
@Suppress("unused")
val stopId = _stopId
@get:Discouraged(message = "Not memory efficient")
val stopId: String get() = _stopId

private val _stopId: String
get() {
return GIDs.getString(stopIdInt)
}
get() = GIDs.getString(stopIdInt)

val arrivalTime: Int = _arrivalTime

fun hasArrivalTime() = _arrivalTime >= 0

@Suppress("unused")
val arrivalTimeMs: Long
get() {
return GTime.toMs(_arrivalTime)
}
get() = GTime.toMs(_arrivalTime)

@Suppress("unused")
val arrivalTimeDate: Date
get() {
return GTime.toDate(_arrivalTime)
}
get() = GTime.toDate(_arrivalTime)

val departureTime: Int = _departureTime

fun hasDepartureTime() = _departureTime >= 0

val departureTimeMs: Long
get() {
return GTime.toMs(_departureTime)
}
get() = GTime.toMs(_departureTime)

@Suppress("unused")
val departureTimeDate: Date
get() {
return GTime.toDate(_departureTime)
}
get() = GTime.toDate(_departureTime)

val uID by lazy { getNewUID(tripIdInt, stopIdInt, stopSequence) }

Expand Down
Loading