Example #1
0
        public List <NearByLocations> GetNearByLocationsDataByAddress(IList list)
        {
            List <NearByLocations> lstNearByPlaces     = new List <NearByLocations>();
            AddressDecoder         _addressDecoder     = new AddressDecoder();
            NearByLocations        _addressCoordinates = null;

            foreach (var obj in list)
            {
                string entityDisplayValue = (string)obj.GetType().GetProperty("DisplayValue").GetValue(obj, null);
                long   ID            = (long)obj.GetType().GetProperty("Id").GetValue(obj, null);
                var    imageProperty = obj.GetType().GetProperty(imagePropertyName).GetValue(obj, null);
                var    coordinates   = _addressDecoder.Geocode(address, entityDisplayValue);
                double distance      = getDistance(coordinates.Latitude, coordinates.Longitude);
                _addressCoordinates = new NearByLocations(coordinates.Latitude, coordinates.Longitude, "", entityDisplayValue, imageFileType);
                if (distance > 0.0)
                {
                    _addressCoordinates.Distance = Math.Round(distance, 2);
                }
                else
                {
                    _addressCoordinates.Distance = distance;
                }
                _addressCoordinates.ID            = ID;
                _addressCoordinates.DisplayValue  = entityDisplayValue;
                _addressCoordinates.Picture       = Convert.ToString(imageProperty);
                _addressCoordinates.ImageFileType = imageFileType;
                if (distance <= range)
                {
                    lstNearByPlaces.Add(_addressCoordinates);
                }
            }
            return(lstNearByPlaces);
        }
Example #2
0
        public List <NearByLocations> GetNearByLocationsData(IList list)
        {
            List <NearByLocations> lstNearByPlaces     = new List <NearByLocations>();
            AddressDecoder         _addressDecoder     = new AddressDecoder();
            NearByLocations        _addressCoordinates = null;
            double distance = 0.0;

            foreach (var obj in list)
            {
                string entityDisplayValue = (string)obj.GetType().GetProperty("DisplayValue").GetValue(obj, null);
                long   ID            = (long)obj.GetType().GetProperty("Id").GetValue(obj, null);
                var    imageProperty = obj.GetType().GetProperty(imagePropertyName).GetValue(obj, null);
                if (!string.IsNullOrEmpty(imagePropertyName))
                {
                    var propLat = obj.GetType().GetProperty(imagePropertyName + "Latitude").GetValue(obj, null);
                    var propLng = obj.GetType().GetProperty(imagePropertyName + "Longitude").GetValue(obj, null);
                    if (address != "address" && !string.IsNullOrEmpty(address))
                    {
                        var coordinates = _addressDecoder.Geocode(address, entityDisplayValue);
                        latitudeA1  = coordinates.Latitude;
                        longitudeA1 = coordinates.Longitude;
                    }
                    distance            = getDistance(Convert.ToDouble(propLat), Convert.ToDouble(propLng));
                    _addressCoordinates = new NearByLocations(Convert.ToDouble(propLat), Convert.ToDouble(propLng), "", entityDisplayValue, imageFileType);
                    if (distance > 0.0)
                    {
                        _addressCoordinates.Distance = Math.Round(distance, 2);
                    }
                    else
                    {
                        _addressCoordinates.Distance = distance;
                    }
                    _addressCoordinates.ID            = ID;
                    _addressCoordinates.DisplayValue  = entityDisplayValue;
                    _addressCoordinates.Picture       = Convert.ToString(imageProperty);
                    _addressCoordinates.ImageFileType = imageFileType;
                    if (distance <= range)
                    {
                        lstNearByPlaces.Add(_addressCoordinates);
                    }
                }
            }
            return(lstNearByPlaces);
        }