0

我需要使用 Geocoder API 验证地址是否是邮政信箱,并且认为PostalCodeType结果会为我提供信息,但似乎提供邮政信箱地址会返回不同的结果。

例如,以下查询是针对真实世界的邮政信箱的:

?app_id={appId}&app_code={appCode}&country=USA&state=WA&searchtext=PO%20Box%20871570%20Vancouver%20WA%2098687&locationattributes=ar,mr,mv,dt,sd,ad,ai,li,in,tz,nb,rn&additionaldata=PreserveUnitDesignators,true

我的预期输出将是这样的:

...
"Address": {
    "Label": "PO Box 871570, Vancouver, WA, United States",
    "Country": "USA",
    "State": "WA",
    "County": "Clark",
    "City": "Vancouver",
    "PostalCode": "98687",
    "AdditionalData": [
        {
            "value": "United States",
            "key": "CountryName"
        },
        {
            "value": "Washington",
            "key": "StateName"
        },
        {
            "value": "Clark",
            "key": "CountyName"
        },
        {
            "value": "P",
            "key": "PostalCodeType"
        }
    ]
}
...

但是,我得到了这个结果,对于不同的邮政编码,没有邮政信箱信息,PostalCodeTypeN不是P

...
"Address": {
    "Label": "Vancouver, WA, United States",
    "Country": "USA",
    "State": "WA",
    "County": "Clark",
    "City": "Vancouver",
    "PostalCode": "98660",
    "AdditionalData": [
        {
            "value": "United States",
            "key": "CountryName"
        },
        {
            "value": "Washington",
            "key": "StateName"
        },
        {
            "value": "Clark",
            "key": "CountyName"
        },
        {
            "value": "N",
            "key": "PostalCodeType"
        }
    ]
}
...

有没有更好的方法来搜索邮政信箱?

4

1 回答 1

0

美国的地理编码器“PostalCodeType”参数,地理编码器结果显示描述 5 位 ZIP 类型的补充信息,如 USPS 所述。值如下:

"N" = 非唯一 "M" = 军用 "P" = 邮政信箱 "U" = 唯一邮编

如果您只寻找“P”值,那么您可以在最后过滤 JSON 响应。基于 postalCodeType 过滤附加数据是不可行的。

https://geocoder.api.here.com/6.2/geocode.json?app_id=xxxx&app_code=xxx&country=USA&state=WA&searchtext=PO%20Box%20871570%20Vancouver%20WA%2098687&locationattributes=ar,mr,mv,dt,sd, ad,ai,li,in,tz,nb,rn&additionaldata=PreserveUnitDesignators,true&addressattributes=pst

于 2019-11-21T14:02:50.153 回答