Skip to content

Commit

Permalink
Merge pull request #360 from HSLdevcom/develop
Browse files Browse the repository at this point in the history
Add message Topic and properties StopTimeProperties.assigned_stop_id and StopEstimate.is_via_point
  • Loading branch information
thjarvin authored Jun 12, 2024
2 parents dd6a796 + 10022bf commit 3bc86e0
Show file tree
Hide file tree
Showing 19 changed files with 12,491 additions and 7,621 deletions.
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fi.hsl</groupId>
<artifactId>transitdata-common</artifactId>
<version>1.5.4</version>
<version>1.6.1</version>
<packaging>jar</packaging>
<name>Common utilities for Transitdata projects</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<pulsar.version>2.3.1</pulsar.version>
<testcontainers.version>1.18.0</testcontainers.version>
<testcontainers.version>1.18.3</testcontainers.version>
</properties>

<profiles>
Expand Down Expand Up @@ -81,7 +81,7 @@
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>4.3.2</version>
<version>4.4.3</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
Expand Down Expand Up @@ -168,7 +168,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<executions>
<execution>
<id>make-assembly</id>
Expand Down Expand Up @@ -249,7 +249,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.0</version>
<executions>
<!-- Add a new source directory to our build -->
<execution>
Expand Down Expand Up @@ -288,7 +288,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.2</version>
<configuration>
<skipTests>${skip.unit.tests}</skipTests>
<!-- Excludes integration tests when unit tests are run -->
Expand All @@ -307,7 +307,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.2</version>
<executions>
<execution>
<id>integration-tests</id>
Expand Down
31 changes: 31 additions & 0 deletions protos/gtfs-realtime.proto
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,35 @@ message TripUpdate {
extensions 1000 to 1999;
}

// Realtime update for certain properties defined within GTFS stop_times.txt.
// Caution: this message is still experimental, and subject to change. It
// may be formally adopted in the future.
message StopTimeProperties {
// Supports real-time stop assignments. Refers to a stop_id defined in the
// GTFS stops.txt.
//
// The new assigned_stop_id should not result in a significantly different
// trip experience for the end user than the stop_id defined in GTFS
// stop_times.txt. In other words, the end user should not view this new
// stop_id as an "unusual change" if the new stop was presented within an
// app without any additional context. For example, this field is intended
// to be used for platform assignments by using a stop_id that belongs to
// the same station as the stop originally defined in GTFS stop_times.txt.
//
// To assign a stop without providing any real-time arrival or departure
// predictions, populate this field and set
// StopTimeUpdate.schedule_relationship = NO_DATA.
//
// If this field is populated, StopTimeUpdate.stop_sequence must be
// populated and StopTimeUpdate.stop_id should not be populated. Stop
// assignments should be reflected in other GTFS-realtime fields as well
// (e.g., VehiclePosition.stop_id).
//
// Caution: this field is still experimental, and subject to change. It
// may be formally adopted in the future.
optional string assigned_stop_id = 1;
}

// Realtime update for arrival and/or departure events for a given stop on a
// trip. Updates can be supplied for both past and future events.
// The producer is allowed, although not required, to drop past events.
Expand Down Expand Up @@ -221,6 +250,8 @@ message TripUpdate {
optional ScheduleRelationship schedule_relationship = 5
[default = SCHEDULED];

optional StopTimeProperties stop_time_properties = 6;

// The extensions namespace allows 3rd-party developers to extend the
// GTFS Realtime Specification in order to add and evaluate new features
// and modifications to the spec.
Expand Down
1 change: 1 addition & 0 deletions protos/internal-messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ message StopEstimate {


optional string targeted_stop_id = 11; //The stop where the vehicle is targeted to stop (e.g. train using a different track than scheduled)
optional bool is_via_point = 12 [default = false];
}

message Bulletin {
Expand Down
46 changes: 44 additions & 2 deletions protos/passenger-count.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,53 @@ option java_outer_classname = "PassengerCount";

message Data {
required int32 SchemaVersion = 1 [default = 1];
optional string topic = 2;
optional Topic topic = 2;
required Payload payload = 3;
optional int64 received_at = 4;
}

message Topic {
required int32 SchemaVersion = 1 [default = 1];

enum JourneyType {
journey = 0;
deadrun = 1; // Probably never used but included just in case
signoff = 2; // Probably never used but included just in case
}

enum TemporalType {
ongoing = 0;
upcoming = 1; // Probably never used but included just in case
}

enum TransportMode {
bus = 0;
train = 1;
tram = 2;
metro = 3;
ferry = 4;
ubus = 5; //Used by U-line buses and other lines with limited real-time information
robot = 6; //Used by robot buses
}

enum EventType {
apc = 0;
}

required int64 received_at = 2; // Our server timestamp as Epoch ms
required string topic_prefix = 3;
required string topic_version = 4;
required JourneyType journey_type = 5;
required TemporalType temporal_type = 6;

required EventType event_type = 7;

optional TransportMode transport_mode = 8; // Optional because of rare bug in data source systems

required int32 operator_id = 9;
required int32 vehicle_number = 10;
}

message Payload {
optional string desi = 1;
optional string dir = 2;
Expand Down Expand Up @@ -46,7 +88,7 @@ message DoorCount {
}

message Count {
optional string clazz = 1; //Field 'class' in JSON, represents passenger class. clazz is used for variable name here, because 'class' is reserved keyword in Java
optional string clazz = 1; //Field 'class' in JSON, represents passenger class.
optional int32 in = 2;
optional int32 out = 3;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,26 @@ public static InternalMessages.StopEstimate mockStopEstimate(long dvjId,
stopId, startTimeEpochMs);
return PubtransFactory.createStopEstimate(common, mockTripInfo, eventType);
}

public static InternalMessages.StopEstimate mockStopEstimate(String routeName,
InternalMessages.StopEstimate.Type eventType,
long stopId,
long targetedStopId,
int stopSequence,
int directionId) throws Exception {
long dvjId = generateValidJoreId();
PubtransTableProtos.Common common = MockDataUtils.mockCommon(dvjId, stopSequence).build();
PubtransTableProtos.DOITripInfo mockTripInfo = mockDOITripInfo(dvjId, routeName, stopId, targetedStopId, directionId);
return PubtransFactory.createStopEstimate(common, mockTripInfo, eventType);
}

public static PubtransTableProtos.DOITripInfo mockDOITripInfo(long dvjId, String routeName) throws Exception {
return mockDOITripInfo(dvjId, routeName, generateValidJoreId());
}

public static PubtransTableProtos.DOITripInfo mockDOITripInfo(long dvjId, String routeName, long stopId, long targetedStopId, int directionId) throws Exception {
return mockDOITripInfo(dvjId, routeName, stopId, targetedStopId, directionId, MOCK_START_DATE, MOCK_START_TIME);
}

public static PubtransTableProtos.DOITripInfo mockDOITripInfo(long dvjId, String routeName, int joreDirection) throws Exception {
long stopId = generateValidJoreId();
Expand Down Expand Up @@ -243,6 +259,11 @@ public static PubtransTableProtos.DOITripInfo mockDOITripInfo(long dvjId, String
int joreDirection, String startDate, String startTime) throws Exception {
return mockDOITripInfoBuilder(dvjId, routeName, stopId, joreDirection, startDate, startTime).build();
}

public static PubtransTableProtos.DOITripInfo mockDOITripInfo(long dvjId, String routeName, long stopId, long targetedStopId,
int joreDirection, String startDate, String startTime) throws Exception {
return mockDOITripInfoBuilder(dvjId, routeName, stopId, targetedStopId, joreDirection, startDate, startTime).build();
}

public static PubtransTableProtos.DOITripInfo.Builder mockDOITripInfoBuilder(long dvjId, String routeName, long stopId,
int joreDirection, String startDate,
Expand All @@ -256,6 +277,20 @@ public static PubtransTableProtos.DOITripInfo.Builder mockDOITripInfoBuilder(lon
builder.setDvjId(dvjId);
return builder;
}

public static PubtransTableProtos.DOITripInfo.Builder mockDOITripInfoBuilder(long dvjId, String routeName, long stopId,
long targetedStopId, int joreDirection,
String startDate, String startTime) {
PubtransTableProtos.DOITripInfo.Builder builder = PubtransTableProtos.DOITripInfo.newBuilder();
builder.setStopId(Long.toString(stopId));
builder.setTargetedStopId(Long.toString(targetedStopId));
builder.setDirectionId(joreDirection);
builder.setRouteId(routeName);
builder.setStartTime(startTime);
builder.setOperatingDay(startDate);
builder.setDvjId(dvjId);
return builder;
}

public static InternalMessages.TripCancellation mockTripCancellation(String routeId) throws Exception {
return mockTripCancellation(
Expand Down
Loading

0 comments on commit 3bc86e0

Please sign in to comment.