Routes Preferred API 目前仅适用于部分客户。如需了解详情,请
与销售人员联系。
配置多段线的质量
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
多段线的质量可以用以下术语来描述:
- 组成多段线的点数
- 点越多,多段线越平滑(尤其是曲线)。
- 点的浮点精度
- 点以纬度和经度值指定,这些值采用单精度浮点格式表示。这对于小值(可精确表示)非常适用,但随着值的增大,精度会降低,因为会出现浮点舍入误差。
指定多段线质量
调用 ComputeRoutes() 方法时,您可以使用 PolylineQuality 枚举值来指定多段线的质量。
当您想要创建由最多点组成的多段线时,请使用 HIGH_QUALITY 值,以生成分辨率最高的多段线。不过,质量的提高会导致响应延迟。
如需创建路线的低分辨率概览(由最少数量的点组成的多段线),请使用 OVERVIEW 值。此选项可生成延迟时间最短的回答。
示例
以下示例演示了如何在请求正文中设置多段线质量。
{
"origin":{
"location":{
"latLng":{
"latitude":37.419734,
"longitude":-122.0827784
}
}
},
"destination":{
"location":{
"latLng":{
"latitude":37.417670,
"longitude":-122.079595
}
}
},
"polylineQuality":"HIGH_QUALITY"
}
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-04-25。
[null,null,["最后更新时间 (UTC):2025-04-25。"],[[["\u003cp\u003ePolyline quality is determined by the number of points and their floating-point precision, impacting smoothness and accuracy.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eHIGH_QUALITY\u003c/code\u003e setting yields the most detailed polyline with maximum points, potentially increasing response time.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eOVERVIEW\u003c/code\u003e setting creates a simplified polyline with minimal points, prioritizing faster response.\u003c/p\u003e\n"],["\u003cp\u003eYou can adjust the polyline quality using the \u003ccode\u003ePolylineQuality\u003c/code\u003e enumeration when making API requests, as shown in the example.\u003c/p\u003e\n"]]],["Polyline quality depends on the number of points and their floating-point precision. The `ComputeRoutes()` method uses `PolylineQuality` to set this. `HIGH_QUALITY` creates a polyline with the maximum points, resulting in high resolution but increased latency. `OVERVIEW` generates a low-resolution polyline with minimal points, reducing latency. The request body sets `polylineQuality` to specify either `HIGH_QUALITY` or `OVERVIEW`, which will influence the polyline's precision.\n"],null,["# Configure Polyline Quality\n\nThe quality of a polyline can be described in the following terms:\n\nThe number of points that make up the polyline\n: The more points there are, the smoother the polyline (especially in curves).\n\nThe floating-point precision of the points\n: Points are specified as latitude and longitude values, which are\n represented in single-precision floating-point format. This works well for\n small values (which can be represented precisely), but precision decreases\n as values increase because of floating-point rounding errors.\n\nSpecifying polyline quality\n---------------------------\n\nWhen you call the `ComputeRoutes()` method, you use a\n[`PolylineQuality`](/maps/documentation/routes_preferred/reference/rest/v1alpha/TopLevel/computeRoutes#polylinequality)\nenumeration value to specify the quality of the polyline.\n\nUse the `HIGH_QUALITY` value when you want to create a polyline composed of the\nmaximum number of points, to produce a polyline of the highest resolution. This\nincreased quality comes at the expense of response latency.\n\nUse the `OVERVIEW` value when you want to create a low-resolution overview of\nthe route, which is a polyline composed of a minimal number of points. This\noption produces responses with the lowest latency.\n\n### Example\n\nThe following example demonstrates how to set the polyline quality in the\nrequest body. \n\n```cplint\n{\n \"origin\":{\n \"location\":{\n \"latLng\":{\n \"latitude\":37.419734,\n \"longitude\":-122.0827784\n }\n }\n },\n \"destination\":{\n \"location\":{\n \"latLng\":{\n \"latitude\":37.417670,\n \"longitude\":-122.079595\n }\n }\n },\n \"polylineQuality\":\"HIGH_QUALITY\"\n}\n```"]]