Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 66277aa

Browse files
xieofxieryanisgrig
authored andcommitted
use azure map for GetPointOfInterestListByAddressAsync (#1988) (#1994)
1 parent 0c3aa86 commit 66277aa

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/FindParkingDialog.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,20 @@ protected async Task<DialogTurnResult> RouteToFindFindParkingDialog(WaterfallSte
116116
{
117117
var pointOfInterest = pointOfInterestAddressList[0];
118118
pointOfInterestList = await mapsService.GetPointOfInterestListByParkingCategoryAsync(pointOfInterest.Geolocation.Latitude, pointOfInterest.Geolocation.Longitude);
119-
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList);
119+
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, mapsService);
120120
}
121121
else
122122
{
123123
// Find parking lot near address
124124
pointOfInterestList = await mapsService.GetPointOfInterestListByParkingCategoryAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude);
125-
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList);
125+
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, mapsService);
126126
}
127127
}
128128
else
129129
{
130130
// No entities identified, find nearby parking lots
131131
pointOfInterestList = await mapsService.GetPointOfInterestListByParkingCategoryAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude);
132-
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList);
132+
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, mapsService);
133133
}
134134

135135
if (cards.Count == 0)

skills/src/csharp/pointofinterestskill/pointofinterestskill/Dialogs/PointOfInterestDialogBase.cs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected async Task<DialogTurnResult> ConfirmCurrentLocation(WaterfallStepConte
120120
var service = ServiceManager.InitAddressMapsService(Settings);
121121

122122
var pointOfInterestList = await service.GetPointOfInterestListByAddressAsync(double.NaN, double.NaN, sc.Result.ToString());
123-
var cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList);
123+
var cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, service);
124124

125125
if (cards.Count() == 0)
126126
{
@@ -247,7 +247,7 @@ protected async Task<DialogTurnResult> ProcessCurrentLocationSelection(Waterfall
247247
{
248248
// No entities identified, find nearby locations
249249
pointOfInterestList = await service.GetNearbyPointOfInterestListAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude);
250-
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList);
250+
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, service);
251251
}
252252
else if (!string.IsNullOrEmpty(state.Keyword) && !string.IsNullOrEmpty(state.Address))
253253
{
@@ -258,26 +258,26 @@ protected async Task<DialogTurnResult> ProcessCurrentLocationSelection(Waterfall
258258
{
259259
var pointOfInterest = pointOfInterestAddressList[0];
260260
pointOfInterestList = await service.GetPointOfInterestListByQueryAsync(pointOfInterest.Geolocation.Latitude, pointOfInterest.Geolocation.Longitude, state.Keyword);
261-
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList);
261+
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, service);
262262
}
263263
else
264264
{
265265
// No POIs found from address - search near current coordinates
266266
pointOfInterestList = await service.GetPointOfInterestListByQueryAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude, state.Keyword);
267-
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList);
267+
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, service);
268268
}
269269
}
270270
else if (!string.IsNullOrEmpty(state.Keyword))
271271
{
272272
// Fuzzy query search with keyword
273273
pointOfInterestList = await service.GetPointOfInterestListByQueryAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude, state.Keyword);
274-
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList);
274+
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, service);
275275
}
276276
else if (!string.IsNullOrEmpty(state.Address))
277277
{
278278
// Fuzzy query search with address
279-
pointOfInterestList = await service.GetPointOfInterestListByAddressAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude, state.Address);
280-
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList);
279+
pointOfInterestList = await addressMapsService.GetPointOfInterestListByAddressAsync(state.CurrentCoordinates.Latitude, state.CurrentCoordinates.Longitude, state.Address);
280+
cards = await GetPointOfInterestLocationCards(sc, pointOfInterestList, addressMapsService);
281281
}
282282

283283
if (cards.Count() == 0)
@@ -457,25 +457,17 @@ protected async Task<List<PointOfInterestModel>> CurrentLocationValidator(Prompt
457457
return await Task.FromResult(pointOfInterestList);
458458
}
459459

460-
protected async Task<List<Card>> GetPointOfInterestLocationCards(DialogContext sc, List<PointOfInterestModel> pointOfInterestList)
460+
// service: for details. the one generates pointOfInterestList
461+
protected async Task<List<Card>> GetPointOfInterestLocationCards(DialogContext sc, List<PointOfInterestModel> pointOfInterestList, IGeoSpatialService service)
461462
{
462463
var state = await Accessor.GetAsync(sc.Context);
463-
var service = ServiceManager.InitMapsService(Settings);
464-
var addressService = ServiceManager.InitAddressMapsService(Settings);
465464
var cards = new List<Card>();
466465

467466
if (pointOfInterestList != null && pointOfInterestList.Count > 0)
468467
{
469468
for (var i = 0; i < pointOfInterestList.Count; i++)
470469
{
471-
if (sc.ActiveDialog.Id.Equals(Actions.CheckForCurrentLocation))
472-
{
473-
pointOfInterestList[i] = await addressService.GetPointOfInterestDetailsAsync(pointOfInterestList[i]);
474-
}
475-
else
476-
{
477-
pointOfInterestList[i] = await service.GetPointOfInterestDetailsAsync(pointOfInterestList[i]);
478-
}
470+
pointOfInterestList[i] = await service.GetPointOfInterestDetailsAsync(pointOfInterestList[i]);
479471

480472
// Increase by one to avoid zero based options to the user which are confusing
481473
pointOfInterestList[i].Index = i + 1;

0 commit comments

Comments
 (0)