車輛位置範例
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
以下範例是車輛位置動態饋給的 ASCII 表示法。
如要進一步瞭解如何建構車輛位置動態饋給,請參閱「使用 VehiclePosition
提供即時行程資訊」一文。
# header information
header {
# version of speed specification. Currently "2.0"
gtfs_realtime_version: "2.0"
# DIFFERENTIAL is unsupported. use FULL_DATASET only
incrementality: FULL_DATASET
# the moment when this dataset was generated on the server
timestamp: 1656230726
}
# a definition (or update) of an entity in the transit feed
# multiple entities can be included in the feed
# be sure to provide information about EVERY active trip
entity {
# unique identifier for the entity within the feed update message
id: "1"
# "type" of the entity
vehicle {
# a descriptor that identifies an instance of a GTFS trip
# defines the identifier of a trip in reference to the trips.txt file
# it is recommended to provide trip_id, which should be one of the following
# (1) a trip defined in the static feed
# (2) a duplicate trip with schedule_relationship ADDED and new start time
# (3) a frequency based trip with a clearly defined start time
trip {
# the trip_id from the GTFS feed that this trip refers to
trip_id: "trip1"
# the start time of this trip instance as specified from the GTFS feed
start_time: "14:05:00"
# the start date of this trip instance
# the trip should be active at this start date
start_date: "20220628"
# The relation between this trip and the static schedule
schedule_relationship: SCHEDULED
# the route_id from the GTFS feed that this trip belongs to
route_id: "ROUTE1"
# the direction_id from the GTFS feed that this trip refers to
direction_id: 0
}
# realtime positioning information for a given vehicle
position {
# Degrees North, in the WGS84 coordinate system
# update latitude with the actual value
latitude: 123.45
# Degrees East, in the WGS84 coordinate system
# update longitude with the actual value
longitude: 12.345
}
# moment at which the vehicle's position was measured in seconds after epoch
timestamp: 1656390815
vehicle {
# a unique identifier for the vehicle serving this particular trip
# the vehicle id must be provided
id: "vehicle1"
}
# the degree of passenger occupancy for the vehicle
occupancy_status: MANY_SEATS_AVAILABLE
}
}
entity {
id: "2"
vehicle {
trip {
# the trip_id from the GTFS feed that this added trip is duplicated after
trip_id: "trip2"
# the start time of the new added trip instance
start_time: "14:05:00"
start_date: "20220628"
# use “ADDED” to specify an extra trip that was added in addition to
# a running schedule
schedule_relationship: ADDED
}
position {
latitude: 123.45
longitude: 123.45
}
timestamp: 1656390815
vehicle {
id: "vehicle2"
}
occupancy_status: MANY_SEATS_AVAILABLE
# details of the multiple carriages of this given vehicle
# the number of occurrences of the multi_carriage_details field
# represents the number of carriages of the vehicle
# it also includes non boardable carriages,
# like engines, maintenance carriages, etc. as they provide
# valuable information to passengers about where to stand on a platform
multi_carriage_details {
# identification of the carriage, should be unique per vehicle carriage
id: "1234-1"
# user visible label that helps passengers identify the carriage
label: "1"
# the degree of passenger occupancy for this vehicle’s carriage
occupancy_status: MANY_SEATS_AVAILABLE
# identifies the order of this carriage
carriage_sequence: 1
}
multi_carriage_details {
id: "1234-2"
label: "2"
occupancy_status: STANDING_ROOM_ONLY
carriage_sequence: 2
}
multi_carriage_details {
id: "1234-3"
label: "3"
occupancy_status: STANDING_ROOM_ONLY
carriage_sequence: 3
}
multi_carriage_details {
id: "1234-4"
label: "4"
occupancy_status: MANY_SEATS_AVAILABLE
carriage_sequence: 4
}
multi_carriage_details {
id: "1234-5"
label: "5"
occupancy_status: MANY_SEATS_AVAILABLE
carriage_sequence: 5
}
multi_carriage_details {
id: "1234-6"
label: "6"
occupancy_status: MANY_SEATS_AVAILABLE
carriage_sequence: 6
}
multi_carriage_details {
id: "1234-7"
label: "7"
occupancy_status: MANY_SEATS_AVAILABLE
carriage_sequence: 7
}
multi_carriage_details {
id: "1234-8"
label: "8"
occupancy_status: MANY_SEATS_AVAILABLE
carriage_sequence: 8
}
}
}
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[[["\u003cp\u003eThis document provides an ASCII example of a Vehicle Position feed, outlining the structure and data elements for real-time vehicle information.\u003c/p\u003e\n"],["\u003cp\u003eThe feed includes details such as vehicle location (latitude/longitude), trip information (trip_id, start time, route), and occupancy status.\u003c/p\u003e\n"],["\u003cp\u003eIt demonstrates how to represent both scheduled and added trips, using the \u003ccode\u003eschedule_relationship\u003c/code\u003e field for differentiation.\u003c/p\u003e\n"],["\u003cp\u003eThe example illustrates the use of \u003ccode\u003emulti_carriage_details\u003c/code\u003e to convey occupancy information for individual carriages within a multi-carriage vehicle.\u003c/p\u003e\n"],["\u003cp\u003eThe feed adheres to the GTFS Realtime specification version 2.0 and uses the FULL_DATASET incrementality.\u003c/p\u003e\n"]]],["This document details a Vehicle Position feed using an ASCII representation. The feed includes header information like the version (\"2.0\"), incrementality (FULL_DATASET), and timestamp. Each entity contains a unique ID, vehicle data with the trip's ID, start time, date, schedule relationship, route and direction IDs. Real-time position data (latitude and longitude), vehicle ID, the timestamp of position, and the occupancy status are detailed. Multiple carriages occupancy are provided for one of the vehicle.\n"],null,["# Vehicle Position example\n\nThe following example is an ASCII representation of a Vehicle Position feed.\n\nFor more details on how to construct a Vehicle Position feed, see [Provide\nRealtime trip information with `VehiclePosition`](https://support.google.com/transitpartners/answer/10105813). \n\n # header information\n header {\n # version of speed specification. Currently \"2.0\"\n gtfs_realtime_version: \"2.0\"\n\n # DIFFERENTIAL is unsupported. use FULL_DATASET only\n incrementality: FULL_DATASET\n\n # the moment when this dataset was generated on the server\n timestamp: 1656230726\n }\n # a definition (or update) of an entity in the transit feed\n # multiple entities can be included in the feed\n # be sure to provide information about EVERY active trip\n entity {\n # unique identifier for the entity within the feed update message\n id: \"1\"\n\n # \"type\" of the entity\n vehicle {\n # a descriptor that identifies an instance of a GTFS trip\n # defines the identifier of a trip in reference to the trips.txt file \n # it is recommended to provide trip_id, which should be one of the following\n # (1) a trip defined in the static feed \n # (2) a duplicate trip with schedule_relationship ADDED and new start time \n # (3) a frequency based trip with a clearly defined start time \n trip {\n # the trip_id from the GTFS feed that this trip refers to\n trip_id: \"trip1\"\n # the start time of this trip instance as specified from the GTFS feed\n start_time: \"14:05:00\"\n # the start date of this trip instance\n # the trip should be active at this start date\n start_date: \"20220628\"\n # The relation between this trip and the static schedule\n schedule_relationship: SCHEDULED\n # the route_id from the GTFS feed that this trip belongs to\n route_id: \"ROUTE1\"\n # the direction_id from the GTFS feed that this trip refers to\n direction_id: 0\n }\n\n\n # realtime positioning information for a given vehicle\n position {\n # Degrees North, in the WGS84 coordinate system\n # update latitude with the actual value\n latitude: 123.45\n # Degrees East, in the WGS84 coordinate system\n # update longitude with the actual value\n longitude: 12.345\n\n }\n\n # moment at which the vehicle's position was measured in seconds after epoch\n timestamp: 1656390815\n\n vehicle {\n # a unique identifier for the vehicle serving this particular trip \n # the vehicle id must be provided\n id: \"vehicle1\"\n }\n # the degree of passenger occupancy for the vehicle\n occupancy_status: MANY_SEATS_AVAILABLE\n }\n }\n entity {\n id: \"2\"\n vehicle {\n trip {\n # the trip_id from the GTFS feed that this added trip is duplicated after\n trip_id: \"trip2\"\n # the start time of the new added trip instance\n start_time: \"14:05:00\"\n start_date: \"20220628\"\n # use \"ADDED\" to specify an extra trip that was added in addition to \n # a running schedule\n schedule_relationship: ADDED\n\n }\n position {\n latitude: 123.45\n longitude: 123.45\n }\n timestamp: 1656390815\n vehicle {\n id: \"vehicle2\"\n }\n occupancy_status: MANY_SEATS_AVAILABLE\n # details of the multiple carriages of this given vehicle \n # the number of occurrences of the multi_carriage_details field\n # represents the number of carriages of the vehicle\n # it also includes non boardable carriages, \n # like engines, maintenance carriages, etc. as they provide \n # valuable information to passengers about where to stand on a platform\n multi_carriage_details {\n # identification of the carriage, should be unique per vehicle carriage\n id: \"1234-1\"\n # user visible label that helps passengers identify the carriage\n label: \"1\"\n # the degree of passenger occupancy for this vehicle's carriage\n occupancy_status: MANY_SEATS_AVAILABLE\n # identifies the order of this carriage\n carriage_sequence: 1\n\n }\n multi_carriage_details {\n id: \"1234-2\"\n label: \"2\"\n occupancy_status: STANDING_ROOM_ONLY\n carriage_sequence: 2\n\n }\n multi_carriage_details {\n id: \"1234-3\"\n label: \"3\"\n occupancy_status: STANDING_ROOM_ONLY\n carriage_sequence: 3\n\n }\n multi_carriage_details {\n id: \"1234-4\"\n label: \"4\"\n occupancy_status: MANY_SEATS_AVAILABLE\n carriage_sequence: 4\n\n }\n multi_carriage_details {\n id: \"1234-5\"\n label: \"5\"\n occupancy_status: MANY_SEATS_AVAILABLE\n carriage_sequence: 5\n\n }\n multi_carriage_details {\n id: \"1234-6\"\n label: \"6\"\n occupancy_status: MANY_SEATS_AVAILABLE\n carriage_sequence: 6\n\n }\n multi_carriage_details {\n id: \"1234-7\"\n label: \"7\"\n occupancy_status: MANY_SEATS_AVAILABLE\n carriage_sequence: 7\n\n }\n multi_carriage_details {\n id: \"1234-8\"\n label: \"8\"\n occupancy_status: MANY_SEATS_AVAILABLE\n carriage_sequence: 8\n\n }\n }\n }"]]