सड़क का रीयल-टाइम डेटा

सड़क से जुड़ा रीयल-टाइम डेटा, आपके चुने गए रास्तों पर सड़क की स्थितियों और इवेंट के बारे में मौजूदा अपडेट देता है. इससे डाइनैमिक मॉनिटरिंग और तुरंत जवाब देने में मदद मिलती है. यह डेटा, BigQuery में समय-समय पर इकट्ठा किए जाने वाले डेटा से अलग होता है. साथ ही, यह उन स्थितियों के लिए सही होता है जिनमें समय पर जानकारी पाना ज़रूरी होता है.

यह डेटा लगातार स्ट्रीम होता है. इसमें यात्रा की अवधि शामिल होती है, जिससे किसी रास्ते पर यात्रा में लगने वाले समय का पता चलता है. साथ ही, इसमें रफ़्तार पढ़ने के इंटरवल शामिल होते हैं, जिनसे रास्ते पर ट्रैफ़िक की जानकारी मिलती है.

सड़क के रीयल-टाइम डेटा को ऐक्सेस करने के लिए, आपके कानूनी समझौते में Real-Time Operations पैकेज शामिल होना चाहिए.

यात्रा की अवधि और स्पीड रीडिंग इंटरवल के लिए Pub/Sub सदस्यता बनाना

आपको Google Cloud Pub/Sub के खास विषय दिए जाएंगे. यहां, बनाई गई सभी यात्राओं के रीयल-टाइम डेटा के लिए सदस्यता ली जा सकती है.

यहां दिए गए कोड सैंपल में, बाइनरी एन्कोडिंग का इस्तेमाल करके विषय का फ़ॉर्मैट दिखाया गया है:

projects/maps-platform-roads-management/topics/rmi-roadsinformation-PROJECT_NUMBER

हम JSON एन्कोडिंग (-json से सफ़िक्स किया गया) का इस्तेमाल करके, एक और विषय भी उपलब्ध कराते हैं. रीयल-टाइम डेटा मैसेज पाने के लिए, आपको Pub/Sub विषय की सदस्यता लेनी होगी. Cloud Pub/Sub विषय की सदस्यता लेने और उससे मैसेज पाने के बारे में खास जानकारी के लिए, किसी विषय की सदस्यता लेना लेख पढ़ें.

यात्रा की अवधि और स्पीड रीडिंग इंटरवल स्कीमा

रीयल-टाइम डेटा के हर मैसेज में, इस तरह का डेटा शामिल होता है:

  • सड़क की जानकारी, जैसे कि duration_in_seconds, static_duration_in_seconds, speed_reading_offsets (ऑफ़सेट के आधार पर रफ़्तार पढ़ने के इंटरवल) और retrieval_timestamp.
  • रास्ते के आइडेंटिफ़ायर, जैसे कि 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 {
  // Legacy message. May stop being populated on or after November 9, 2026.
  // Use top-level duration_in_seconds and static_duration_in_seconds instead.
  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;
  }
  // Legacy message representing the latitude and longitude of a coordinate
  // within a coordinate-based speed reading interval.
  message LatLng {
    float latitude = 1;
    float longitude = 2;
  }
  // Legacy coordinate-based speed reading interval message. May stop being
  // populated on or after November 9, 2026. Use SpeedReadingOffset instead.
  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": Traffic jam detected. In this legacy field, heavy
    //   traffic jams (dark red) are also reported as "TRAFFIC_JAM";
    //   "TRAFFIC_JAM_HEAVY" is never used.
    string speed = 2;
  }
  // Offset-based speed reading interval along the route.
  message SpeedReadingOffset {
    // The distance offset from the start of the route in meters for the start
    // of the interval (inclusive).
    int32 start_offset = 1;

    // The distance offset from the start of the route in meters for the end of
    // the interval (exclusive; equals the start_offset of the subsequent
    // interval).
    int32 end_offset = 2;

    // Describes the categorized current speed of traffic, aligned with the
    // colors in the Google Maps traffic layer. Possible values are:
    // - "NORMAL" (green): Traffic is flowing smoothly, no slowdown is detected.
    // - "SLOW" (yellow): Slowdown detected, but no traffic jam formed.
    // - "TRAFFIC_JAM" (red): Traffic jam detected.
    // - "TRAFFIC_JAM_HEAVY" (dark red): Heavy traffic jam detected (available
    //   as of October 8, 2026).
    string speed = 3;
  }
  // Id for selected_route.
  string selected_route_id = 1;
  // User provided name for the route.
  string display_name = 2;
  // Legacy coordinate-based speed reading intervals. May stop being populated
  // on or after November 9, 2026. Use speed_reading_offsets instead.
  repeated SpeedReadingInterval speed_reading_intervals = 3;
  // Legacy travel time information. May stop being populated on or after
  // November 9, 2026. Use duration_in_seconds and static_duration_in_seconds
  // instead.
  TravelDuration travel_duration = 4;
  // Legacy timestamp when the road data was collected. May stop being populated
  // on or after November 9, 2026. Use retrieval_timestamp instead.
  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;
  // Offset-based speed reading intervals representing traffic density across
  // the route; each interval is demarcated by the distance offset from the
  // start of the route.
  repeated SpeedReadingOffset speed_reading_offsets = 8;
  // The duration of travel through the route based on current traffic
  // conditions.
  float duration_in_seconds = 9;
  // The duration of travel through the route without taking traffic
  // conditions into consideration.
  float static_duration_in_seconds = 10;
  // The time the traffic data was collected, as an RFC 3339 UTC timestamp
  // string (for example, "2026-10-08T15:04:05+00:00").
  string retrieval_timestamp = 11;
}

ऑफ़सेट के आधार पर, तेज़ी से पढ़ने के इंटरवल और फ़ील्ड माइग्रेशन

आठ अक्टूबर, 2026 से, तेज़ गति से पढ़ने के इंटरवल, ऑफ़सेट पर आधारित speed_reading_offsets फ़ील्ड में दिए जाते हैं. इसमें हर इंटरवल को, रास्ते की शुरुआत से मीटर में start_offset (शामिल है) और end_offset (शामिल नहीं है) के हिसाब से बांटा जाता है. इसमें स्पीड की चौथी कैटगरी TRAFFIC_JAM_HEAVY भी शामिल है. स्पीड कैटगरी और इंटरवल फ़ॉर्मैट के बारे में ज़्यादा जानने के लिए, तेज़ी से पढ़ने के इंटरवल लेख पढ़ें.

यहां दी गई टेबल में, Pub/Sub के हर लेगसी फ़ील्ड को उसके बदले इस्तेमाल किए जाने वाले फ़ील्ड से मैप किया गया है. इन लेगसी फ़ील्ड में 9 नवंबर, 2026 या इसके बाद डेटा नहीं भरा जाएगा:

लेगसी फ़ील्ड बदला गया फ़ील्ड नोट
speed_reading_intervals speed_reading_offsets इसमें पॉलीलाइन कोऑर्डिनेट के बजाय मीटर ऑफ़सेट (start_offset, end_offset) का इस्तेमाल किया जाता है. साथ ही, इसमें TRAFFIC_JAM_HEAVY स्पीड कैटगरी जोड़ी जाती है.
travel_duration.duration_in_seconds duration_in_seconds इसे टॉप-लेवल के float फ़ील्ड में बदला गया है.
travel_duration.static_duration_in_seconds static_duration_in_seconds इसे टॉप-लेवल के float फ़ील्ड में बदला गया है.
retrieval_time retrieval_timestamp इसे RFC 3339 स्ट्रिंग के तौर पर फ़ॉर्मैट किया जाता है. BigQuery की सदस्यताएं इसे अपने-आप TIMESTAMP में बदल देती हैं.

Pub/Sub का इस्तेमाल करके, BigQuery में रूट का डेटा स्ट्रीम करना

Pub/Sub सदस्यता को कॉन्फ़िगर करके, सड़क का डेटा सीधे BigQuery टेबल में स्ट्रीम किया जा सकता है. इससे डेटा को सुरक्षित तरीके से सेव किया जा सकता है. साथ ही, दिए गए रास्ते की जानकारी के आधार पर बेहतर तरीके से विश्लेषण किया जा सकता है. इस तरह की सदस्यता सेट अप करने से पहले, आपको अपने BigQuery प्रोजेक्ट में एक सही डेटासेट और टेबल बनानी होगी, ताकि डेटा को उसमें लिखा जा सके.

BigQuery में डेटा लिखने वाली Pub/Sub सदस्यता बनाने के बारे में ज़्यादा जानकारी के लिए, BigQuery में डेटा स्ट्रीम करना लेख पढ़ें. JSON-कोड वाले विषय पर BigQuery सदस्यता बनाएं. सदस्यता कॉन्फ़िगर करते समय, टेबल स्कीमा का इस्तेमाल करें को चुनें. साथ ही, अज्ञात फ़ील्ड हटाएं को चालू करें, ताकि नए फ़ील्ड जोड़े जाने पर भी डेटा ट्रांसफ़र करने वाली पाइपलाइन आसानी से काम करती रहे. speed_reading_offsets जैसे नए फ़ील्ड सेव करने के लिए, अपनी टेबल में उनसे जुड़े कॉलम जोड़ें.

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 (groups red and dark red segments; does not include \"TRAFFIC_JAM_HEAVY\")."
      },
      {
        "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": "Legacy coordinate-based speed reading intervals. May stop being populated on or after November 9, 2026. Use speed_reading_offsets instead."
  },
  {
    "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": "Legacy travel time information. May stop being populated on or after November 9, 2026. Use top-level duration_in_seconds and static_duration_in_seconds instead."
  },
  {
    "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": "Legacy timestamp when the traffic data was collected. May stop being populated on or after November 9, 2026. Use retrieval_timestamp instead."
  },
  {
    "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"
  },
  {
    "fields": [
      {
        "mode": "NULLABLE",
        "name": "start_offset",
        "type": "INTEGER",
        "description": "The distance offset from the start of the route in meters for the start of the interval (inclusive)."
      },
      {
        "mode": "NULLABLE",
        "name": "end_offset",
        "type": "INTEGER",
        "description": "The distance offset from the start of the route in meters for the end of the interval (exclusive; equals the start_offset of the subsequent interval)."
      },
      {
        "mode": "NULLABLE",
        "name": "speed",
        "type": "STRING",
        "description": "Describes the categorized current speed of traffic, aligned with the colors in the Google Maps traffic layer. Possible values are: \"NORMAL\" (green): Traffic is flowing smoothly, no slowdown is detected. \"SLOW\" (yellow): Slowdown detected, but no traffic jam formed. \"TRAFFIC_JAM\" (red): Traffic jam detected. \"TRAFFIC_JAM_HEAVY\" (dark red): Heavy traffic jam detected (available as of October 8, 2026)."
      }
    ],
    "mode": "REPEATED",
    "name": "speed_reading_offsets",
    "type": "RECORD",
    "description": "Offset-based speed reading intervals representing traffic density across the route; each interval is demarcated by the distance offset from the start of the route."
  },
  {
    "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": "retrieval_timestamp",
    "type": "TIMESTAMP",
    "description": "The time the traffic data was collected."
  }
]