Created
July 8, 2015 00:27
-
-
Save vramirez122000/06abc6e72ceeec660239 to your computer and use it in GitHub Desktop.
GTFS Realtime Example Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.transit.realtime.GtfsRealtime; | |
import static com.google.transit.realtime.GtfsRealtime.*; | |
/** | |
* Created by victor on 2/07/15. | |
*/ | |
public class EndpointMain { | |
public static void main(String[] args) throws Exception { | |
VehiclePosition vehPosition = VehiclePosition.newBuilder() | |
.setPosition( | |
Position.newBuilder() | |
.setLatitude(18) | |
.setLongitude(-66).build()) | |
.build(); | |
FeedMessage.Builder feedBuilder = FeedMessage.newBuilder() | |
.setHeader(FeedHeader.newBuilder().setGtfsRealtimeVersion("1")) | |
.addEntity(FeedEntity.newBuilder().setId("1").setVehicle(vehPosition)); | |
if(!feedBuilder.isInitialized()) { | |
System.err.print("error"); | |
}; | |
FeedMessage msg = feedBuilder.build(); | |
msg.writeTo(System.out); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment