सड़क का रीयल-टाइम डेटा, आपके चुने गए रास्तों पर सड़क की स्थितियों और इवेंट के बारे में मौजूदा अपडेट देता है. इससे डाइनैमिक मॉनिटरिंग और तुरंत कार्रवाई करने में मदद मिलती है. यह डेटा, BigQuery में समय-समय पर इकट्ठा किए जाने वाले डेटा से अलग होता है. साथ ही, यह उन स्थितियों के लिए सही होता है जिनमें समय पर जानकारी पाना ज़रूरी होता है.
यह डेटा लगातार स्ट्रीम होता है. इसमें ये शामिल हैं: यात्रा की अवधि, जो किसी रास्ते पर यात्रा करने में लगने वाले समय के बारे में बताती है. साथ ही, स्पीड रीडिंग इंटरवल, जो सड़क के सेगमेंट की डेंसिटी दिखाता है.
सड़क का रीयल-टाइम डेटा ऐक्सेस करने के लिए, आपके अनुबंध में रीयल-टाइम ऑपरेशंस पैकेज शामिल होना चाहिए.
Cloud Pub/Sub की सदस्यता बनाना
जब आपका प्रोजेक्ट, रीयल-टाइम डेटा पाने के लिए सेट अप हो जाता है, तब आपके प्रोजेक्ट के लिए Google Cloud Pub/Sub का एक खास विषय उपलब्ध हो जाता है. इस Pub/Sub विषय में, बनाए गए सभी रास्तों का रीयल-टाइम डेटा देखा जा सकता है.
यहां दिए गए कोड सैंपल में, विषय के यूआरएल का फ़ॉर्मैट दिखाया गया है.
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 में स्ट्रीम किए गए रास्ते का डेटा
Pub/Sub सदस्यता को कॉन्फ़िगर करके, सड़क का डेटा सीधे BigQuery टेबल में स्ट्रीम किया जा सकता है. इससे डेटा को सुरक्षित तरीके से सेव किया जा सकता है. साथ ही, दिए गए रास्ते की जानकारी के आधार पर बेहतर तरीके से विश्लेषण किया जा सकता है. इस तरह की सदस्यता सेट अप करने से पहले, आपको अपने BigQuery प्रोजेक्ट में एक सही डेटासेट और टेबल बनानी होगी, ताकि उसमें डेटा लिखा जा सके.
BigQuery में डेटा स्ट्रीम करने के बारे में ज़्यादा जानकारी के लिए, BigQuery में डेटा स्ट्रीम करना लेख पढ़ें. इसमें BigQuery में डेटा लिखने वाली Pub/Sub सदस्यता बनाने के बारे में निर्देश दिए गए हैं.
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 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" }