রিয়েল-টাইম রাস্তার ডেটা

রিয়েল-টাইম রোড ডেটা আপনার বেছে নেওয়া রুটের বর্তমান রোড কন্ডিশন ও ইভেন্ট সম্পর্কে আপডেট দেয়, যা ডায়নামিক মনিটরিং ও দ্রুত উত্তর দেওয়ার ক্ষেত্রে সহায়ক। এই ডেটা BigQuery-তে উপলভ্য পিরিয়ডিক ডেটা থেকে আলাদা এবং যেসব ক্ষেত্রে সময়মতো তথ্য প্রয়োজন, সেগুলির জন্য উপযুক্ত।

এই ডেটা ক্রমাগত স্ট্রিম করা হয় এবং এতে ট্রিপের সময়সীমা অন্তর্ভুক্ত থাকে, যা কোনও রুটে ভ্রমণের সময় এবং স্পিড রিডিং ইন্টারভ্যাল, দেখায়, যা রুট বরাবর ট্রাফিকের ঘনত্ব দেখায়।

রিয়েল-টাইম রোড ডেটা অ্যাক্সেস করতে, আপনার চুক্তিতে অবশ্যই রিয়েল-টাইম অপারেশন প্যাকেজ থাকতে হবে।

ভ্রমণের সময়সীমা ও স্পিড রিডিং ইন্টার্ভাল 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;
}

অফসেট-ভিত্তিক স্পিড রিডিং ইন্টার্ভাল ও ফিল্ড মাইগ্রেশন

৮ অক্টোবর, ২০২৬ অনুযায়ী, স্পিড রিডিং ইন্টারভ্যাল অফসেট-ভিত্তিক speed_reading_offsets ফিল্ডে প্রদান করা হয়, যেখানে প্রতিটি ইন্টারভ্যালকে এর start_offset (অন্তর্ভুক্ত) এবং end_offset (এক্সক্লুসিভ) দ্বারা রুট শুরুর থেকে মিটারে চিহ্নিত করা হয় এবং এতে চতুর্থ স্পিড ক্যাটেগরি TRAFFIC_JAM_HEAVY অন্তর্ভুক্ত থাকে। স্পিড ক্যাটেগরি ও ইন্টারভ্যাল ফর্ম্যাট সম্পর্কে বিস্তারিত জানতে, দ্রুত রিডিং ইন্টারভ্যাল দেখুন।

নিম্নলিখিত সারণী প্রতিটি লিগ্যাসি Pub/Sub ফিল্ডকে (যেগুলি ৯ নভেম্বর, ২০২৬ বা তার পরে আর পূরণ করা নাও হতে পারে) সেটির রিপ্লেসমেন্টের সাথে ম্যাপ করে:

পুরনো ফিল্ড পরিবর্ত ফিল্ড নোট
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-তে রুট ডেটা স্ট্রিম করা

আপনি রাস্তার ডেটা সরাসরি BigQuery টেবিলে স্ট্রিম করার জন্য Pub/Sub সাবস্ক্রিপশন কনফিগার করতে পারবেন। এর ফলে, ডেটা মজবুতভাবে স্টোর করা যায় এবং প্রদান করা রুট সংক্রান্ত তথ্যের উপর শক্তিশালী অ্যানালিটিক্স প্রয়োগ করা যায়। এই ধরনের সাবস্ক্রিপশন সেট-আপ করার আগে, ডেটা লেখার জন্য আপনার 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."
  }
]