如何使用地理空间上下文进行地理编码 - Amazon Location Service

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

如何使用地理空间上下文进行地理编码

Geocode API 允许您使用地理空间上下文(例如偏差位置)来获得所需的结果。

注意

“偏置位置” 是指一种根据用户的指定位置或定义的区域对搜索结果进行优先级排序的机制。它本质上是将搜索结果的重点转移到地理上更接近指定偏差点的地点,而不一定排除其他结果。

潜在用途

使用地理空间上下文根据您的业务需求获得正确的结果。

示例

通过偏向某个位置,您可以更改结果的排名。尝试以下带有(然后不带)BiasPosition值的示例,然后比较结果。

Sample request
{ "QueryText": "George Street", "BiasPosition": [ 151.2059, -33.8691 ] }
Sample response
{ "ResultItems": [ { "PlaceId": "<Redacted>", "PlaceType": "Street", "Title": "George St, Sydney NSW, Australia", "Address": { "Label": "George St, Sydney NSW, Australia", "Country": { "Code2": "AU", "Code3": "AUS", "Name": "Australia" }, "Region": { "Code": "NSW", "Name": "New South Wales" }, "Locality": "Sydney", "Street": "George St", "StreetComponents": [ { "BaseName": "George", "Type": "St", "TypePlacement": "AfterBaseName", "TypeSeparator": " ", "Language": "en" } ] }, "Position": [ 151.20691, -33.86974 ], "Distance": 117, "MapView": [ 151.20225, -33.88406, 151.20912, -33.85635 ], "MatchScores": { "Overall": 1, "Components": { "Address": { "Intersection": [ 1 ] } } } }, ... ... ] }
cURL
curl --request POST \ --url 'https://places.geo.eu-central-1.amazonaws.com/v2/geocode?key=Your_Key' \ --header 'Content-Type: application/json' \ --data '{ "QueryText": "George Street", "BiasPosition": [ 151.2059, -33.8691 ] }'
AWS CLI
aws geo-places geocode --key ${YourKey} --query-text "George Street" --bias-position 151.2059 -33.8691

开发者小贴士

对于地址地理编码,请尝试使用完整的地址或带有偏差位置(包括国家和地点)组合的查询组件。要了解更多信息,请参阅如何对地址进行地理编码