Receber rotas selecionadas

Depois de criar uma rota, use o endpoint GET da API Roads Selection para receber as informações dela e monitorar o status de validação.

Nesta página, descrevemos como listar todas as rotas selecionadas no seu projeto e como acessar detalhes de uma rota específica.

Receber um trajeto selecionado específico

Para receber informações sobre uma rota específica selecionada, envie uma solicitação GET para o endpoint get, incluindo o selectedRouteId da rota que você quer recuperar.

  "https://roads.googleapis.com/selection/v1/projects/PROJECT_NUMBER/selectedRoutes/SELECTED_ROUTE_ID"

O exemplo de código a seguir mostra a estrutura de uma solicitação GET para o endpoint get para receber informações sobre uma única rota selecionada.

curl -X GET \
-H 'X-Goog-User-Project: PROJECT_NUMBER' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
"https://roads.googleapis.com/selection/v1/projects/PROJECT_NUMBER/selectedRoutes/SELECTED_ROUTE_ID"

O exemplo de código a seguir mostra a estrutura de uma resposta do endpoint get com as informações de uma única rota selecionada.

{
  "name": "projects/PROJECT_NUMBER/selectedRoutes/SELECTED_ROUTE_ID",
  "dynamicRoute": {
    "origin": {
      "latitude": ORIGIN_LATITUDE,
      "longitude": ORIGIN_LONGITUDE
    },
    "destination": {
      "latitude": DESTINATION_LATITUDE,
      "longitude": DESTINATION_LONGITUDE
    },
    "intermediates": [
      {
        "latitude": LATITUDE,
        "longitude": LONGITUDE
      },
      {
        "latitude": LATITUDE,
        "longitude": LONGITUDE
      },
      {
        "latitude": LATITUDE,
        "longitude": LONGITUDE
      }
    ]
  },
  "createTime": "CREATE_TIME",
  "state": "STATE"

}

Listar rotas selecionadas

Para listar todas as rotas selecionadas associadas ao seu projeto, envie uma solicitação GET ao endpoint list.

https://roads.googleapis.com/selection/v1/projects/PROJECT_NUMBER/selectedRoutes

O exemplo de código a seguir mostra a estrutura de uma solicitação GET para o endpoint list para receber as informações de todas as rotas selecionadas associadas a um projeto do Google Cloud.

curl -X GET \
-H 'X-Goog-User-Project: PROJECT_NUMBER' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
"https://roads.googleapis.com/selection/v1/projects/PROJECT_NUMBER/selectedRoutes"

O exemplo de código a seguir mostra a estrutura de uma resposta do endpoint list com as informações de todas as rotas selecionadas associadas a um projeto do Google Cloud.

{
  "selectedRoutes": [
    {
      "name": "projects/PROJECT_NUMBER/selectedRoutes/SELECTED_ROUTE_ID",
      "dynamicRoute": {
        "origin": {
          "latitude": ORIGIN_LATITUDE,
          "longitude": ORIGIN_LONGITUDE
        },
        "destination": {
          "latitude": DESTINATION_LATITUDE,
          "longitude": DESTINATION_LONGITUDE
        }
      },
      "createTime": "CREATE_TIME",
      "state": "STATE"
    },
    {
      "name": "projects/PROJECT_NUMBER/selectedRoutes/SELECTED_ROUTE_ID",
      "dynamicRoute": {
        "origin": {
          "latitude": ORIGIN_LATITUDE,
          "longitude": ORIGIN_LONGITUDE
        },
        "destination": {
          "latitude": DESTINATION_LATITUDE,
          "longitude": DESTINATION_LONGITUDE
        },
        "intermediates": [
          {
            "latitude": LATITUDE,
            "longitude": LONGITUDE
          },
          {
            "latitude": LATITUDE,
            "longitude": LONGITUDE
          },
          {
            "latitude": LATITUDE,
            "longitude": LONGITUDE
          }
        ]
      },
      "createTime": "CREATE_TIME",
      "state": "STATE"
    },
  ]
}