question

TebenArturUS-1800 avatar image
0 Votes"
TebenArturUS-1800 asked TebenArturUS-1800 commented

Why does the Bing Maps API Location use an array for resource sets in its response body if they always return 1 resource set?

I'm going to use the Bing Maps API to find places, and I can't understand why they use as array resources sets and always return only 1 resource set. I could not find this information in the documentation. Maybe they have a reason why they do it.
Does anyone know why?

Response for request query: Denver
{
"authenticationResultCode": "ValidCredentials",
"brandLogoUri": "http://dev.virtualearth.net/Branding/logo_powered_by.png",
"copyright": "Copyright © 2021 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
"resourceSets": [
{
"estimatedTotal": 3,
"resources": [
{
"__type": "Location:http://schemas.microsoft.com/search/local/ws/rest/v1",
"bbox": [
39.394721984863281,
-105.71308135986328,
40.087486267089844,
-104.25537872314453
],
"name": "Denver, CO",
"point": {
"type": "Point",
"coordinates": [
39.738452911376953,
-104.98485565185547
]
},
"address": {
"adminDistrict": "CO",
"adminDistrict2": "Denver County",
"countryRegion": "United States",
"formattedAddress": "Denver, CO",
"locality": "Denver"
},
"confidence": "High",
"entityType": "PopulatedPlace",
"geocodePoints": [
{
"type": "Point",
"coordinates": [
39.738452911376953,
-104.98485565185547
],
"calculationMethod": "Rooftop",
"usageTypes": [
"Display"
]
}
],
"matchCodes": [
"Ambiguous"
]
},
{
"__type": "Location:http://schemas.microsoft.com/search/local/ws/rest/v1",
"bbox": [
39.614158630371094,
-105.10982513427734,
39.914108276367188,
-104.59976196289062
],
"name": "Denver County",
"point": {
"type": "Point",
"coordinates": [
39.738452911376953,
-104.98485565185547
]
},
"address": {
"adminDistrict": "CO",
"adminDistrict2": "Denver County",
"countryRegion": "United States",
"formattedAddress": "Denver County"
},
"confidence": "Low",
"entityType": "AdminDivision2",
"geocodePoints": [
{
"type": "Point",
"coordinates": [
39.738452911376953,
-104.98485565185547
],
"calculationMethod": "Rooftop",
"usageTypes": [
"Display"
]
}
],
"matchCodes": [
"Ambiguous"
]
},
{
"__type": "Location:http://schemas.microsoft.com/search/local/ws/rest/v1",
"bbox": [
40.221256256103516,
-76.1585693359375,
40.246849060058594,
-76.124885559082031
],
"name": "Denver, PA",
"point": {
"type": "Point",
"coordinates": [
40.234416961669922,
-76.139396667480469
]
},
"address": {
"adminDistrict": "PA",
"adminDistrict2": "Lancaster County",
"countryRegion": "United States",
"formattedAddress": "Denver, PA",
"locality": "Denver"
},
"confidence": "Low",
"entityType": "PopulatedPlace",
"geocodePoints": [
{
"type": "Point",
"coordinates": [
40.234416961669922,
-76.139396667480469
],
"calculationMethod": "Rooftop",
"usageTypes": [
"Display"
]
}
],
"matchCodes": [
"Ambiguous"
]
}
]
}
],
"statusCode": 200,
"statusDescription": "OK",
"traceId": "fb400f3f713842efa838d9d632d429fb|DU00000D71|0.0.0.1|Ref A: 67A3CD9AF489429B9D40FA0529AE8DD2 Ref B: DB3EDGE1109 Ref C: 2021-07-02T14:23:50Z"
}

azure-maps
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

rbrundritt avatar image
1 Vote"
rbrundritt answered TebenArturUS-1800 commented

I suspect this is for consistency, as the route service rourseSet value can return have multiple values in it. By making the resourceSet an array for both services, a common base response class can be used.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for your answer @rbrundritt

Even though, can I expect multiple resourceSet? Can I work with this like with one entity or should I expect cases when I get multiple resourceSets?

0 Votes 0 ·
IoTGirl avatar image
0 Votes"
IoTGirl answered TebenArturUS-1800 commented

Please see the documentation https://docs.microsoft.com/en-us/bingmaps/rest-services/common-response-description

It seems fairly straight forward that the resourcesets tag separates the result contents from the job header. Maybe this process examples will help with your understanding...https://docs.microsoft.com/en-us/bingmaps/v8-web-control/map-control-concepts/rest-services-examples/

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your answer!

I'm not sure that I get you. Can you please explain me about what job headers you are talking exactly?
From the examples from the second link I can see that in every code example, only resourceSet[0] value is used.
They just use first element of resourceSet.
So, my question was about the way I should work with resourceSets.
Can I only use first resourceSet element or I should always work with it just like with collection, because it may have more than 1
element?

0 Votes 0 ·

The location API's only ever have one value in the resourceSet, So writing code that only uses the first value is sufficient.

1 Vote 1 ·

It's what I was exactly looking for. Thank you!

0 Votes 0 ·