feat: extend Main
This commit is contained in:
parent
71b6c8e170
commit
444777c386
|
@ -19,6 +19,13 @@
|
||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>public.onebusaway.org</id>
|
||||||
|
<url>http://nexus.onebusaway.org/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<url>https://github.com/Software-Ingenieur-Begerad/sandbox-java</url>
|
<url>https://github.com/Software-Ingenieur-Begerad/sandbox-java</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
@ -28,16 +35,24 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.onebusaway</groupId>
|
||||||
|
<artifactId>onebusaway-gtfs-realtime-exporter</artifactId>
|
||||||
|
<version>1.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mobilitydata</groupId>
|
||||||
|
<artifactId>gtfs-realtime-bindings</artifactId>
|
||||||
|
<version>0.0.8</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.10.1</version>
|
<version>3.10.1</version>
|
||||||
<configuration>
|
|
||||||
<!-- Target Java versions -->
|
|
||||||
<release>11</release>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|
|
@ -1,9 +1,73 @@
|
||||||
package de.swingbe.grb_use;
|
package de.swingbe.grb_use;
|
||||||
|
|
||||||
|
import org.onebusway.gtfs_realtime.exporter.GtfsRealtimeLibrary;
|
||||||
|
import org.onebusway.gtfs_realtime.exporter.GtfsRealtimeMutableProvider;
|
||||||
|
|
||||||
|
import com.google.transit.realtime.GtfsRealtime.FeedEntity;
|
||||||
|
import com.google.transit.realtime.GtfsRealtime.FeedMessage;
|
||||||
|
import com.google.transit.realtime.GtfsRealtime.Position;
|
||||||
|
import com.google.transit.realtime.GtfsRealtime.VehiclePosition;
|
||||||
|
import com.google.transit.realtime.GtfsRealtime.TripDescriptor;
|
||||||
|
import com.google.transit.realtime.GtfsRealtime.VehicleDescriptor;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
|
private static GtfsRealtimeMutableProvider gtfsRealtimeMutableProvider;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("Hello world!");
|
System.out.println("main() started...");
|
||||||
|
//GtfsRealtime.FeedMessage msg;
|
||||||
|
FeedMessage.Builder vehiclePositions = GtfsRealtimeLibrary.createFeedMessageBuilder();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We construct a TripDescriptor and VehicleDescriptor, which will be used
|
||||||
|
* in both trip updates and vehicle positions to identify the trip and
|
||||||
|
* vehicle. Ideally, we would have a trip id to use for the trip
|
||||||
|
* descriptor, but the SEPTA api doesn't include it, so we settle for a
|
||||||
|
* route id instead.
|
||||||
|
*/
|
||||||
|
TripDescriptor.Builder tripDescriptor = TripDescriptor.newBuilder();
|
||||||
|
tripDescriptor.setRouteId("tripDescriptor:RouteId");
|
||||||
|
|
||||||
|
VehicleDescriptor.Builder vehicleDescriptor = VehicleDescriptor.newBuilder();
|
||||||
|
vehicleDescriptor.setId("vehicleDescriptor:Id");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To construct our VehiclePosition, we create a position for the vehicle.
|
||||||
|
* We add the position to a VehiclePosition builder, along with the trip
|
||||||
|
* and vehicle descriptors.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Brunswick
|
||||||
|
*/
|
||||||
|
double lat = 52.268875;
|
||||||
|
double lon = 10.526770;
|
||||||
|
|
||||||
|
Position.Builder position = Position.newBuilder();
|
||||||
|
position.setLatitude((float) lat);
|
||||||
|
position.setLongitude((float) lon);
|
||||||
|
|
||||||
|
VehiclePosition.Builder vehiclePosition = VehiclePosition.newBuilder();
|
||||||
|
vehiclePosition.setPosition(position);
|
||||||
|
vehiclePosition.setTrip(tripDescriptor);
|
||||||
|
vehiclePosition.setVehicle(vehicleDescriptor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new feed entity to wrap the vehicle position and add it to the
|
||||||
|
* GTFS-realtime vehicle positions feed.
|
||||||
|
*/
|
||||||
|
FeedEntity.Builder vehiclePositionEntity = FeedEntity.newBuilder();
|
||||||
|
vehiclePositionEntity.setId("vehiclePositionEntity:Id");
|
||||||
|
vehiclePositionEntity.setVehicle(vehiclePosition);
|
||||||
|
vehiclePositions.addEntity(vehiclePositionEntity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build out the final GTFS-realtime feed messagse and save them.
|
||||||
|
*/
|
||||||
|
gtfsRealtimeMutableProvider.setVehiclePositions(vehiclePositions.build());
|
||||||
|
|
||||||
|
System.out.println("main() done.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue