কাছের রাস্তা

Roads API 100টি পর্যন্ত স্বতন্ত্র স্থানাঙ্ক নেয় এবং প্রতিটি পয়েন্টের জন্য নিকটতম রাস্তার অংশ প্রদান করে। পাস করা পয়েন্টগুলিকে একটানা পথের অংশ হতে হবে না।

আপনি যদি অনুক্রমিক GPS পয়েন্ট নিয়ে কাজ করেন, তাহলে Snap to Roads ব্যবহার করুন।

অনুরোধ

নিকটতম রাস্তাগুলির একটি অনুরোধ HTTPS এর মাধ্যমে পাঠাতে হবে এবং নিম্নলিখিত ফর্মটি গ্রহণ করতে হবে:

https://roads.googleapis.com/v1/nearestRoads?parameters&key=YOUR_API_KEY

Required parameters

  • points

    The points to be snapped. The points parameter accepts a list of latitude/longitude pairs. Separate latitude and longitude values with commas. Separate coordinates with the pipe character: "|". For example: points=60.170880,24.942795|60.170879,24.942796|60.170877,24.942796 .

Generated from the OpenAPI specification . Edit Report bug

উদাহরণ

নিম্নলিখিত অনুরোধটি স্থানাঙ্কের নির্দিষ্ট তালিকার উপর ভিত্তি করে রাস্তার অংশগুলির একটি সেট প্রদান করে৷

URL

https://roads.googleapis.com/v1/nearestRoads
  ?points=60.170880%2C24.942795%7C60.170879%2C24.942796%7C60.170877%2C24.942796
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://roads.googleapis.com/v1/nearestRoads?points=60.170880%2C24.942795%7C60.170879%2C24.942796%7C60.170877%2C24.942796&key=YOUR_API_KEY'

জাভাস্ক্রিপ্ট

var axios = require('axios');

var config = {
  method: 'get',
  url: 'https://roads.googleapis.com/v1/nearestRoads?points=60.170880%2C24.942795%7C60.170879%2C24.942796%7C60.170877%2C24.942796&key=YOUR_API_KEY',
  headers: { }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

পাইথন

import requests

url = "https://roads.googleapis.com/v1/nearestRoads?points=60.170880%2C24.942795%7C60.170879%2C24.942796%7C60.170877%2C24.942796&key=YOUR_API_KEY"

payload={}
headers = {}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

জাভা

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://roads.googleapis.com/v1/nearestRoads?points=60.170880%2C24.942795%7C60.170879%2C24.942796%7C60.170877%2C24.942796&key=YOUR_API_KEY")
  .method("GET", body)
  .build();
Response response = client.newCall(request).execute();

রুবি

require "uri"
require "net/http"

url = URI("https://roads.googleapis.com/v1/nearestRoads?points=60.170880%2C24.942795%7C60.170879%2C24.942796%7C60.170877%2C24.942796&key=YOUR_API_KEY")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)

response = https.request(request)
puts response.read_body

যাওয়া

package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://roads.googleapis.com/v1/nearestRoads?points=60.170880,24.942795%7C60.170879,24.942796%7C60.170877,24.942796&key=YOUR_API_KEY"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

পোস্টম্যান

OpenAPI স্পেসিফিকেশন পোস্টম্যান সংগ্রহ হিসাবেও পাওয়া যায়।

পোস্টম্যানে চালান

প্রতিক্রিয়া

প্রতিটি বৈধ অনুরোধের জন্য, Roads API অনুরোধ URL-এর মধ্যে নির্দেশিত বিন্যাসে একটি প্রতিক্রিয়া প্রদান করবে।

{
  "snappedPoints":
    [
      {
        "location":
          { "latitude": 60.170878428876755, "longitude": 24.94269540970182 },
        "originalIndex": 0,
        "placeId": "ChIJfVFHrM0LkkYRBzUQos_jR5w",
      },
      {
        "location":
          { "latitude": 60.17087741412199, "longitude": 24.942695474405202 },
        "originalIndex": 1,
        "placeId": "ChIJfVFHrM0LkkYRBzUQos_jR5w",
      },
      {
        "location":
          { "latitude": 60.170875416131736, "longitude": 24.942695601802203 },
        "originalIndex": 2,
        "placeId": "ChIJfVFHrM0LkkYRBzUQos_jR5w",
      },
    ],
}

প্রতিক্রিয়া নিম্নলিখিত স্কিমা ব্যবহার করে.

NearestRoadsResponse

FieldRequiredTypeDescription
optional Array< SnappedPoint >

An array of snapped points. Sometimes containing several snapped points for the same point with differing placeId or location.

See SnappedPoint for more information.

Generated from the OpenAPI specification . Edit Report bug

SnappedPoint

FieldRequiredTypeDescription
required LatitudeLongitudeLiteral See LatitudeLongitudeLiteral for more information.
required string

A unique identifier for a place. All place IDs returned by the Roads API correspond to road segments.

optionalnumber

An integer that indicates the corresponding value in the original request. Each value in the request should map to a snapped value in the response. However, if you've set interpolate=true or if you're using nearest roads, then it's possible that the response will contain more coordinates than the request. Interpolated values will not have an originalIndex . These values are indexed from 0 , so a point with an originalIndex of 4 will be the snapped value of the 5th latitude/longitude passed to the path parameter. Nearest Roads points may contain several points for single coordinates with differing location or placeId.

Generated from the OpenAPI specification . Edit Report bug

LatitudeLongitudeLiteral

An object describing a specific location with Latitude and Longitude in decimal degrees.

FieldRequiredTypeDescription
required number

Latitude in decimal degrees

required number

Longitude in decimal degrees

Generated from the OpenAPI specification . Edit Report bug