예제 #1
0
        private static List<Document> FilterSearchEventsByLocation(List<Document> documents, double ratioInMiles, string zipCode)
        {
            List<Document> documentsToReturn;
            Dictionary<string, string> coordinatesOrigin;
            double latitude;
            double longitude;

            coordinatesOrigin = Geography.LookupCoordinates(zipCode);
            documentsToReturn = new List<Document>();

            if (coordinatesOrigin != null && coordinatesOrigin.Keys.Contains(Geography.sLatitudeKey) && coordinatesOrigin.Keys.Contains(Geography.sLongitudeKey))
            {
                if (double.TryParse(coordinatesOrigin[Geography.sLatitudeKey], out latitude) && double.TryParse(coordinatesOrigin[Geography.sLongitudeKey], out longitude))
                {
                    documentsToReturn = FilterDocumentsByLatitudeAndLongitude(documents, latitude, longitude, ratioInMiles);
                }
                else
                {
                    Sitecore.Diagnostics.Log.Error("SearchEvents - Unable to obtain latitude/longitude for origin location", typeof(EventHelper));
                }
            }

            return documentsToReturn;
        }