실시간 도로 데이터는 선택한 경로의 도로 상황과 이벤트에 관한 최신 업데이트를 제공하여 동적 모니터링과 신속한 대응을 지원합니다. 이 데이터는 BigQuery에서 사용할 수 있는 주기적으로 수집된 데이터와 다르며, 적시에 정보가 필요한 시나리오에 적합합니다.
이 데이터는 지속적으로 스트리밍되며 경로의 이동 시간을 나타내는 이동 시간과 도로 구간 밀도를 보여주는 속도 판독 간격이 포함됩니다.
실시간 도로 데이터에 액세스하려면 계약에 실시간 운영 패키지가 포함되어야 합니다.
Cloud Pub/Sub 구독 만들기
프로젝트가 실시간 데이터를 수신하도록 설정되면 프로젝트에서 전용 Google Cloud Pub/Sub 주제를 사용할 수 있습니다. 이 Pub/Sub 주제에서 생성된 모든 경로의 실시간 데이터를 확인할 수 있습니다.
다음 코드 샘플은 주제 URL의 형식을 보여줍니다.
projects/maps-platform-roads-management/topics/rmi-roadsinformation-PROJECT_NUMBER
실시간 데이터 메시지를 받으려면 제공된 Pub/Sub 주제를 구독해야 합니다. Cloud Pub/Sub 주제에서 메시지를 구독하고 사용하는 방법에 관한 간략한 개요는 주제 구독을 참고하세요.
실시간 교통 데이터 메시지 스키마
각 실시간 데이터 메시지에는 다음과 같은 데이터가 포함됩니다.
travel_duration
,speed_reading_intervals
과 같은 도로 세부정보selected_route_id
및display_name
과 같은 경로 식별자
각 메시지는 다음 Protobuf 형식을 준수하여 게시됩니다.
syntax = "proto3"; // Contains the road information like travel duration and speed reading // intervals for a selected route. message RoadsInformation { message TravelDuration { // The duration of travel through the route based on current road conditions. float duration_in_seconds = 1; // The duration of travel through the route without taking road conditions into consideration. float static_duration_in_seconds = 2; } message Timestamp { // Represents seconds of UTC time since Unix epoch // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to // 9999-12-31T23:59:59Z inclusive. int64 seconds = 1; // Non-negative fractions of a second at nanosecond resolution. Negative // second values with fractions must still have non-negative nanos values // that count forward in time. Must be from 0 to 999,999,999 // inclusive. int32 nanos = 2; } // Represents the latitude and longitude of a coordinate // within speed reading interval. message LatLng { float latitude = 1; float longitude = 2; } message SpeedReadingInterval { // The coordinates on the polyline for the speed reading interval repeated LatLng interval_coordinates = 1; // Describes the categorized current speed of road conditions. Possible values are: // - "NORMAL": Road is flowing smoothly, no slowdown is detected. // - "SLOW": Slowdown detected, but no congestion formed. // - "TRAFFIC_JAM": Congestion detected. string speed = 2; } // Id for selected_route. string selected_route_id = 1; // User provided name for the route. string display_name = 2; // Intervals representing the road density across the route. repeated SpeedReadingInterval speed_reading_intervals = 3; // Travel time information. TravelDuration travel_duration = 4; // The time the road data was collected. Timestamp retrieval_time = 5; // Contains a geojson polyline representing the optimal route determined based // on user's input waypoints. string route_geometry = 6; }
Pub/Sub를 사용하여 BigQuery로 경로 데이터 스트리밍
도로 데이터를 BigQuery 테이블로 직접 스트리밍하도록 Pub/Sub 구독을 구성할 수 있습니다. 이를 통해 강력한 데이터 스토리지가 가능하며 제공된 경로 정보에 대한 강력한 분석이 가능합니다. 이 유형의 구독을 설정하기 전에 데이터를 쓸 적절한 데이터 세트와 테이블을 BigQuery 프로젝트에 만들어야 합니다.
BigQuery에 쓰는 Pub/Sub 구독을 만드는 방법에 관한 자세한 안내는 BigQuery로 데이터 스트리밍을 참고하세요.
BigQuery 테이블 스키마
BigQuery 테이블에 기록될 수도 있는 Pub/Sub 주제에 게시된 메시지는 다음 스키마를 준수합니다. 호환성을 보장하려면 대상 BigQuery 테이블을 만들 때 이 스키마를 사용해야 합니다.
{ "mode": "NULLABLE", "name": "selected_route_id", "type": "STRING", "description": "Id for selected_route." }, { "mode": "NULLABLE", "name": "display_name", "type": "STRING", "description": "User provided name for the route." }, { "fields": [ { "mode": "NULLABLE", "name": "speed", "type": "STRING", "description": "Describes the categorized current speed of traffic. Possible values are: \"NORMAL\": Traffic is flowing smoothly, no slowdown is detected. \"SLOW\": Slowdown detected, but no traffic jam formed. \"TRAFFIC_JAM\": Traffic jam detected." }, { "fields": [ { "mode": "NULLABLE", "name": "latitude", "type": "NUMERIC" }, { "mode": "NULLABLE", "name": "longitude", "type": "NUMERIC" } ], "mode": "REPEATED", "name": "interval_coordinates", "type": "RECORD", "description": "The geometry for this interval" } ], "mode": "REPEATED", "name": "speed_reading_intervals", "type": "RECORD", "description": "Intervals representing the traffic density across the route." }, { "fields": [ { "mode": "NULLABLE", "name": "duration_in_seconds", "type": "FLOAT", "description": "The duration of travel through the route based on current traffic conditions." }, { "mode": "NULLABLE", "name": "static_duration_in_seconds", "type": "FLOAT", "description": "The duration of travel through the route without taking traffic conditions into consideration." } ], "mode": "NULLABLE", "name": "travel_duration", "type": "RECORD", "description": "Travel time information." }, { "fields": [ { "mode": "NULLABLE", "name": "seconds", "type": "INTEGER", "description": "Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive." }, { "mode": "NULLABLE", "name": "nanos", "type": "INTEGER", "description": "Non-negative fractions of a second at nanosecond resolution. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be from 0 to 999,999,999 inclusive." } ], "mode": "NULLABLE", "name": "retrieval_time", "type": "RECORD", "description": "The time the traffic data was collected." }, { "mode": "NULLABLE", "name": "route_geometry", "type": "STRING", "description": "Contains a geojson polyline representing the optimal route determined based on user's input waypoints" }