none
Strategies for supporting a limited set of "territories"? RRS feed

  • Question

  • I have very little experience with Bing maps (but I've been coding for a long time).  I'm now supporting a service that interfaces to the Bing maps service. Our service provides a somewhat limited facade.  For instance, we can query for a specific zip code with an optional "territory qualifier" (I'm using that term loosely), and it will just return the first match.

    We recently noticed that there are some zip codes in the US that are also present in other territories that our service does not intend to support.  For instance, zip code 75010 is in Texas, and also in France.  We implemented a workaround at the time to add ",US" to the query string.  That solved that particular problem.  Note that I say "we" as in our organization, but this was done before I was introduced to this project.

    This was working fine until someone from Puerto Rico entered their zip code, 00802.  Our code which appends ",US" to the query now was getting nothing back, because that's not the right territory name for Puerto Rico.

    One simple question would be, what is the territory name for Puerto Rico?  Is it "VI"?

    I was thinking that perhaps our service could support a "territories" parameter, which had a list of territories to support in the query, and to limit the results based on that list.  Is this a workable strategy?

    Tuesday, November 7, 2017 12:34 AM

Answers

  • If using the autosuggest module, there is a new option to limit the results to a specific country. If using the geocoding service, have the iso2 value for the country returned and manually filter the results.

    [Blog] [twitter] [LinkedIn]

    Tuesday, November 7, 2017 6:57 PM
  • Combining the earlier response with info I got from Bing Maps support, I found that adding the "incl=iso2" request parameter (ironically, that parameter only supports that value), results in the "Address" element now containing a "CountryRegionIso2" element, which has the ISO2 country code. My implementation will filter the results against a known list of support ISO2  country codes, to return the first match (which will be fine until the day when we support two countries that share at least one zip code).
    Thursday, November 9, 2017 8:41 PM

All replies

  • If using the autosuggest module, there is a new option to limit the results to a specific country. If using the geocoding service, have the iso2 value for the country returned and manually filter the results.

    [Blog] [twitter] [LinkedIn]

    Tuesday, November 7, 2017 6:57 PM
  • Ok, I'm finally at the point where I can ask more questions about this.

    If I use the following (elided) URL: http://dev.virtualearth.net/REST/v1/Locations?q=75010&o=xml&key=...&maxResults=10 , I get a response which contains the following:

          <Resources>
            <Location>
              <Name>10e arr., Paris, France</Name>
              <Point>
                <Latitude>48.8735084533691</Latitude>
                <Longitude>2.35853004455566</Longitude>
              </Point>
              <BoundingBox>
                <SouthLatitude>48.8696457357985</SouthLatitude>
                <WestLongitude>2.35070017115118</WestLongitude>
                <NorthLatitude>48.8773711709398</NorthLatitude>
                <EastLongitude>2.36635991796015</EastLongitude>
              </BoundingBox>
              <EntityType>Neighborhood</EntityType>
              <Address>
                <AdminDistrict>IdF</AdminDistrict>
                <AdminDistrict2>Paris</AdminDistrict2>
                <CountryRegion>France</CountryRegion>
                <FormattedAddress>10e arr., Paris, France</FormattedAddress>
                <Locality>Paris</Locality>
              </Address>
              <Confidence>High</Confidence>
              <MatchCode>Ambiguous</MatchCode>
              <GeocodePoint>
                <Latitude>48.8735084533691</Latitude>
                <Longitude>2.35853004455566</Longitude>
                <CalculationMethod>Rooftop</CalculationMethod>
                <UsageType>Display</UsageType>
              </GeocodePoint>
            </Location>
            <Location>
              <Name>75010, TX</Name>
              <Point>
                <Latitude>33.0227813720703</Latitude>
                <Longitude>-96.9356460571289</Longitude>
              </Point>
              <BoundingBox>
                <SouthLatitude>33.0035400390625</SouthLatitude>
                <WestLongitude>-96.9533615112305</WestLongitude>
                <NorthLatitude>33.057430267334</NorthLatitude>
                <EastLongitude>-96.8474273681641</EastLongitude>
              </BoundingBox>
              <EntityType>Postcode1</EntityType>
              <Address>
                <AdminDistrict>TX</AdminDistrict>
                <AdminDistrict2>Denton</AdminDistrict2>
                <CountryRegion>United States</CountryRegion>
                <FormattedAddress>75010, TX</FormattedAddress>
                <Locality>Carrollton</Locality>
                <PostalCode>75010</PostalCode>
              </Address>
              <Confidence>Medium</Confidence>
              <MatchCode>Ambiguous</MatchCode>
              <GeocodePoint>
                <Latitude>33.0227813720703</Latitude>
                <Longitude>-96.9356460571289</Longitude>
                <CalculationMethod>Rooftop</CalculationMethod>
                <UsageType>Display</UsageType>
              </GeocodePoint>
            </Location>
          </Resources>
    
    Can you clarify how I can get the iso2 value so I can filter the results from this list?

    Wednesday, November 8, 2017 10:34 PM
  • Combining the earlier response with info I got from Bing Maps support, I found that adding the "incl=iso2" request parameter (ironically, that parameter only supports that value), results in the "Address" element now containing a "CountryRegionIso2" element, which has the ISO2 country code. My implementation will filter the results against a known list of support ISO2  country codes, to return the first match (which will be fine until the day when we support two countries that share at least one zip code).
    Thursday, November 9, 2017 8:41 PM