예제 #1
0
        public static List <TraveltimeStatic> GetGeoLocation(List <TraveltimeStatic> toProcess, string apiKey)
        {
            int c = 0;

            while (c < toProcess.Count)
            {
                List <TraveltimeStatic> slice =
                    toProcess.GetRange(c, (c + 100 < toProcess.Count) ? 100 : (toProcess.Count - c));

                List <NearestRoadResultModel.Location> locations = new List <NearestRoadResultModel.Location>();
                foreach (var travelTime in slice)
                {
                    locations.Add(new NearestRoadResultModel.Location
                    {
                        latitude  = travelTime.Merged.beginnodelatitude,
                        longitude = travelTime.Merged.beginnodelongitude
                    });
                }
                NearestRoadResultModel results = NearestRoadFetchercs.GetNearestRoads(apiKey, locations);
                for (int i = 0; i < results.snappedPoints.Length; i++)
                {
                    int originalIndex = results.snappedPoints[i].originalIndex;
                    if (toProcess[c + originalIndex].Merged.googleLocationsId == null)
                    {
                        toProcess[c + originalIndex].Merged.googleLocationsId = new List <string>();
                    }
                    toProcess[c + originalIndex].Merged.googleLocationsId.Add(results.snappedPoints[i].placeId);
                }
                c += slice.Count;
            }
            return(toProcess);
        }
예제 #2
0
 public static List <TraveltimeStatic> FillLocationInfoFromLocationId(List <TraveltimeStatic> toProcess, string apiKey)
 {
     foreach (TraveltimeStatic ts in toProcess)
     {
         ts.Merged.googleLocationInfo = new List <LocationInfoModel>();
         foreach (string locId in ts.Merged.googleLocationsId)
         {
             ts.Merged.googleLocationInfo.Add(NearestRoadFetchercs.GetRoadName(apiKey, locId));
         }
     }
     return(toProcess);
 }