توفّر بيانات الطرق في الوقت الفعلي آخر المعلومات عن أحوال الطرق والأحداث على الطرق التي اخترتها، ما يتيح إجراء مراقبة ديناميكية والاستجابة بسرعة. تختلف هذه البيانات عن البيانات التي يتم جمعها بشكل دوري والمتاحة في BigQuery، وهي مناسبة للسيناريوهات التي تتطلب معلومات في الوقت المناسب.
تتضمّن هذه البيانات التي يتم بثّها باستمرار: مدة الرحلة، التي تشير إلى أوقات السفر على طريق معيّن، وفترات قراءة السرعة، التي توضّح كثافة مقطع الطريق.
للوصول إلى بيانات الطرق في الوقت الفعلي، يجب أن يتضمّن عقدك حزمة "العمليات في الوقت الفعلي".
إنشاء اشتراك في Pub/Sub لـ "مدة الرحلة" و"فترات قراءة السرعة"
سنزوّدك بمواضيع مخصّصة على Google Cloud Pub/Sub، وهي المواضيع التي يمكنك الاشتراك فيها لتلقّي البيانات في الوقت الفعلي لجميع الطرق التي أنشأتها.
يوضّح نموذج الرمز البرمجي التالي تنسيق الموضوع باستخدام الترميز الثنائي:
projects/maps-platform-roads-management/topics/rmi-roadsinformation-PROJECT_NUMBER
نوفّر أيضًا موضوعًا آخر باستخدام ترميز JSON (يُضاف إليه اللاحقة -json). عليك الاشتراك في موضوع 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; // Road segment place IDs along the route. They follow topological order // and are always connected. repeated string road_segment_ids = 7; }
بثّ بيانات الطريق إلى BigQuery باستخدام Pub/Sub
يمكنك إعداد اشتراك في Pub/Sub لبثّ بيانات الطريق مباشرةً إلى جدول BigQuery. يسمح ذلك بتخزين البيانات بشكل قوي ويتيح إجراء تحليلات فعّالة على معلومات الطريق المقدَّمة. قبل إعداد هذا النوع من الاشتراكات، عليك إنشاء مجموعة بيانات وجدول مناسبَين في مشروع BigQuery لكتابة البيانات فيهما.
يمكنك الاطّلاع على مقالة بثّ البيانات إلى BigQuery للحصول على تعليمات مفصّلة حول كيفية إنشاء اشتراك في Pub/Sub يكتب في BigQuery.
مخطط جدول BigQuery
تتّبع الرسائل المنشورة في موضوع Pub/Sub، والتي يمكن أيضًا كتابتها في جدول BigQuery، المخطط التالي. عليك استخدام هذا المخطط عند إنشاء جدول 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\ncurrent traffic conditions." }, { "mode": "NULLABLE", "name": "static_duration_in_seconds", "type": "FLOAT", "description": "The duration of travel through the route without\ntaking 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" }, { "mode": "REPEATED", "name": "road_segment_ids", "type": "STRING", "description": "Road segment place IDs along the route. They follow topological order and are always connected" }