Bing 地图地理编码数据流的结果不准确

Inaccurate resulte from Bing Maps Geocode Dataflow

我正在使用 Python POST 请求对我公司分支机构的地址进行地理编码,但我得到的结果非常不准确。

我查看了 this 答案,但问题是某些结果未被处理。我的问题有所不同,因为我的 所有 结果都不准确,甚至 Confidence="High" 的结果也不准确。我有一个企业帐户。

以下文档显示了如何创建地理编码作业和上传数据:
https://docs.microsoft.com/en-us/bingmaps/spatial-data-services/geocode-dataflow-api/create-a-geocode-job-and-upload-data

这是我要上传的代码的基本版本:

import requests    

SDS_Geocode_URL = "https://spatial.virtualearth.net/REST/v1/dataflows/geocode?"

geocode_post_vars = {
    "input": "xml",
    "output": "json",
    "content-type": "application/xml",
    "key": Bing_key,
}

geocode_Post_URL = (
    SDS_Geocode_URL
    + urllib.parse.urlencode(geocode_post_vars)
    + "&dataLocation="
    + "https://account-name.blob.core.windows.net/myDataFile.xml"
)

r = requests.post(geocode_Post_URL)

对数据进行地理编码后,我使用 GET 请求获取地理编码后的 XML

geocode_Results = requests.get(
    "https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/"
    + jobID
    + "/output/succeeded?key=" + Bing_key
)

print(geocode_Results.text)

我得到这样的结果:

<GeocodeEntity Id="12040000">
    <GeocodeRequest Culture="en-US" IncludeNeighborhood="true" Query="Rush Truck Center - Los Angeles" IncludeQueryParse="true">
        <Address AddressLine="8830 Slauson Ave, Pico Rivera, CA 90660" AdminDistrict="California" CountryRegion="US" Locality="Pico Rivera" PostalCode="90660" />
    </GeocodeRequest>
    <GeocodeResponse Name="Los Angeles, CA" EntityType="PopulatedPlace" Confidence="High" MatchCodes="UpHierarchy">
        <Address AdminDistrict="CA" CountryRegion="United States" AdminDistrict2="Los Angeles County" FormattedAddress="Los Angeles, CA" Locality="Los Angeles" />
        <GeocodePoint CalculationMethod="Rooftop" Latitude="34.0522384643555" Longitude="-118.243347167969" Type="Point" UsageTypes="Display" />
        <QueryParseValue Property="Locality" Value="Los Angeles" />
        <BoundingBox SouthLatitude="33.6968193054199" WestLongitude="-118.683807373047" NorthLatitude="34.3506469726563" EastLongitude="-118.138854980469" />
        <Point Latitude="34.0522384643555" Longitude="-118.243347167969" />
    </GeocodeResponse>
    <StatusCode>Success</StatusCode>
    <TraceId>#######</TraceId>
</GeocodeEntity>

在我的地理编码请求中,我有一个特定的地址和公司分支机构名称(针对此问题进行了编辑)。此外,我还完全按照文档中的说明添加了城市、州、国家和邮政编码属性。

即使有所有这些信息,地理编码的响应数据 returns 也不会比洛杉矶的一般城市更精细,城市的 Lat/Long 坐标,而不是我提供的地址(为了记录,它是十距离它应该在的地方几英里远)。

此外,当我通过 Bing 地图门户手动上传 XML 文件时,它非常准确。我的请求格式有误吗,还是 Bing 问题?

我在您的请求数据中发现了几个问题:

  • 您传递的“查询”值是兴趣点名称和位置的组合。地理编码器仅适用于地址。所以在这种情况下,兴趣点名称被删除,地理编码器只使用“洛杉矶”,因此结果。
  • 您正在将两种不同的地理编码查询类型混合到一个查询中。要么只使用“查询”,要么只使用单独的地址部分(AddressLine、Locality、AdminDistrict、CountryRegion、PostalCode)。在这种情况下,“查询”值将被忽略,其他所有内容都将被忽略,使用单独的地址部分将比您的查询准确得多。
  • 您正在将完整地址传递到 AddressLine 字段。那应该只是街道地址(即“8830 Slauson Ave”)。

这是请求的修改版本,可能 return 您期望的信息:

<GeocodeRequest Culture="en-US" IncludeNeighborhood="true" IncludeQueryParse="true">
        <Address AddressLine="8830 Slauson Ave" AdminDistrict="California" CountryRegion="US" Locality="Pico Rivera" PostalCode="90660" />
    </GeocodeRequest>