

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

# 如何使用邮政编码对地址号进行地理编码
<a name="how-to-geocode-address-postal-code"></a>

在邮政编码非常具体（每个邮政编码仅对应同一街道上的少数几个地址）的国家/地区，只需知道门牌号和邮政编码就能找到相应的地址。这种做法在交通运输和包裹配送物流领域十分常见。加拿大、英国、荷兰、美国（ZIP\+4）、以色列、爱尔兰和新加坡支持此功能。在爱尔兰和新加坡，邮政编码都能提供确切的位置详细信息，甚至能精确到具体的门牌号。

## 示例
<a name="geocode-postal-code-examples"></a>

### 使用邮政编码对地址进行地理编码
<a name="geocode-postal-code-example1"></a>

------
#### [ 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"}'
```

------

### 使用邮政编码在新加坡和爱尔兰对地址进行地理编码
<a name="geocode-postal-code-example2"></a>

在爱尔兰，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"}'
```

------

## 开发人员提示
<a name="geocode-postal-code-dev-tips"></a>

了解有关 [ZIP\+4](https://en.wikipedia.org/wiki/ZIP_Code#ZIP+4)（美国）和 [Eircode](https://en.wikipedia.org/wiki/Postal_addresses_in_the_Republic_of_Ireland)（爱尔兰）的更多信息。此外，还可了解加拿大、英国、荷兰、新加坡和以色列的邮政编码系统。