本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
如何使用邮政编码对地址号码进行地理编码
在邮政编码非常具体(仅链接同一条街上的几个地址)的国家,只能使用门牌号和邮政编码来找到地址。这种做法在运输和包裹配送物流中很常见。加拿大、英国、荷兰、美国 (ZIP+4)、以色列、爱尔兰和新加坡支持此功能。在爱尔兰和新加坡,邮政编码都提供精确的位置信息,直至具体的门牌号码。
示例
- Sample request
-
使用查询组件
{ "QueryComponents": { "AddressNumber": "1368", "PostalCode": "V5N 1T2" } }
使用自由文本
{ "QueryText": "1368, V5N1T2" }
- Sample response
-
{ "ResultItems": [ { "PlaceId": "<Redacted>", "PlaceType": "PointAddress", "Title": "1368 E 8th Ave, Vancouver, BC V5N 1T2, Canada", "Address": { "Label": "1368 E 8th Ave, Vancouver, BC V5N 1T2, Canada", "Country": { "Code2": "CA", "Code3": "CAN", "Name": "Canada" }, "Region": { "Code": "BC", "Name": "British Columbia" }, "SubRegion": { "Name": "Metro Vancouver" }, "Locality": "Vancouver", "District": "Grandview-Woodland", "PostalCode": "V5N 1T2", "Street": "E 8th Ave", "StreetComponents": [ { "BaseName": "8th", "Type": "Ave", "TypePlacement": "AfterBaseName", "TypeSeparator": " ", "Prefix": "E", "Language": "en" } ], "AddressNumber": "1368" }, "Position": [ -123.07612, 49.26306 ], "MapView": [ -123.0775, 49.26216, -123.07474, 49.26396 ], "AccessPoints": [ { "Position": [ -123.07611, 49.26333 ] } ], "MatchScores": { "Overall": 1, "Components": { "Address": { "PostalCode": 1, "AddressNumber": 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 '{ "QueryComponents": { "AddressNumber": "1368", "PostalCode": "V5N 1T2" } }'
- AWS CLI
-
aws geo-places geocode --key ${YourKey} --query-components '{"AddressNumber" : "1368", "PostalCode": "V5N 1T2"}'
在爱尔兰,Eircode系统为每个家庭和企业分配一个唯一的代码,而在新加坡,邮政编码同样具体。在这两个国家,仅凭邮政编码就能识别出确切的地址:不需要街道名称、城市或门牌号。
-
新加坡:6 位数的邮政编码
-
爱尔兰:7 个字符的 Eircode
- Sample request
-
使用查询组件
{ "QueryComponents": { "PostalCode": "D02 X285" } }
使用自由文本
{ "QueryText": "D02 X285" }
- Sample response
-
{ "ResultItems": [ { "PlaceId": "<Redacted>", "PlaceType": "PointAddress", "Title": "29-31 Adelaide Road, Dublin, County Dublin, D02 X285, Ireland", "Address": { "Label": "29-31 Adelaide Road, Dublin, County Dublin, D02 X285, Ireland", "Country": { "Code2": "IE", "Code3": "IRL", "Name": "Ireland" }, "SubRegion": { "Code": "D", "Name": "County Dublin" }, "Locality": "Dublin", "District": "Dublin 2", "PostalCode": "D02 X285", "Street": "Adelaide Road", "StreetComponents": [ { "BaseName": "Adelaide", "Type": "Road", "TypePlacement": "AfterBaseName", "TypeSeparator": " ", "Language": "en" } ], "AddressNumber": "29-31" }, "Position": [ -6.25549, 53.33207 ], "MapView": [ -6.257, 53.33117, -6.25398, 53.33297 ], "AccessPoints": [ { "Position": [ -6.25536, 53.33231 ] } ], "MatchScores": { "Overall": 1, "Components": { "Address": { "PostalCode": 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 '{ "QueryComponents": { "PostalCode": "D02 X285" } }'
- AWS CLI
-
aws geo-places geocode --key ${YourKey} --query-components '{"PostalCode": "V5N 1T2"}'
开发者小贴士
了解有关 ZIP+4
地理编码 POI
使用地理空间上下文进行地理编码