예제 #1
0
        public static IEnumerable <Address> Search(string searchAddress, bool geocode)
        {
            var addressLookup = new AddressLookup();
            var addresses     = new List <Address>();

            if (ZoneLookup.IsZone(searchAddress))
            {
                foreach (var zip in ZoneLookup.GetZipCodes(searchAddress))
                {
                    addresses.Add(addressLookup.GetAddressFromZipCode(zip));
                }
            }
            else if (ZipCodeList.IsZipCode(searchAddress))
            {
                ZipCode zipCode = ZipCodeList.GetZipCode(searchAddress);
                addresses.Add(addressLookup.GetAddressFromZipCode(zipCode));
            }
            else if (CityList.IsCityAndState(searchAddress))
            {
                var city = CityList.GetCity(searchAddress);
                addresses.Add(addressLookup.GetAddressFromCity(city));
            }
            else if (geocode)
            {
                var response = Geocoder.Search(searchAddress);
                addresses.Add(response);
            }
            else
            {
                addresses.Add(new UnknownAddress(searchAddress));
            }

            return(addresses);
        }
예제 #2
0
        public static IEnumerable <Address> Search(string streetAddress, string city, string state, string zipCode, bool geocode)
        {
            var addressLookup = new AddressLookup();
            var addresses     = new List <Address>();

            if (string.IsNullOrEmpty(streetAddress))
            {
                if (!string.IsNullOrEmpty(city) && !string.IsNullOrEmpty(state) && CityList.IsCity(city, new State(state)))
                {
                    var citySearched = CityList.GetCity(city, new State(state));
                    var address      = addressLookup.GetAddressFromCity(citySearched);

                    if (!string.IsNullOrEmpty(zipCode))
                    {
                        address.ZipCode = ZipCodeList.GetZipCode(zipCode);
                    }
                    addresses.Add(address);
                }
                else if (!string.IsNullOrEmpty(zipCode) && ZipCodeList.IsZipCode(zipCode))
                {
                    ZipCode zipCodeSearched = ZipCodeList.GetZipCode(zipCode);
                    addresses.Add(addressLookup.GetAddressFromZipCode(zipCodeSearched));
                }
            }
            if (addresses.Count == 0)
            {
                if (geocode)
                {
                    var response = Geocoder.Search(FormatAddress(streetAddress, city, state, zipCode));
                    addresses.Add(response);
                }
                else
                {
                    addresses.AddRange(Address.Search(FormatAddress(streetAddress, city, state, zipCode), geocode));
                }
            }
            return(addresses);
        }
        public static IEnumerable<Address> Search(string searchAddress, bool geocode)
        {
            var addressLookup = new AddressLookup();
            var addresses = new List<Address>();

            if (ZoneLookup.IsZone(searchAddress))
            {
                foreach (var zip in ZoneLookup.GetZipCodes(searchAddress))
                {
                    addresses.Add(addressLookup.GetAddressFromZipCode(zip));
                }
            }
            else if (ZipCodeList.IsZipCode(searchAddress))
            {
                ZipCode zipCode = ZipCodeList.GetZipCode(searchAddress);
                addresses.Add(addressLookup.GetAddressFromZipCode(zipCode));
            }
            else if (CityList.IsCityAndState(searchAddress))
            {
                var city = CityList.GetCity(searchAddress);
                addresses.Add(addressLookup.GetAddressFromCity(city));
            }
            else if (geocode)
            {
                var response = Geocoder.Search(searchAddress);
                addresses.Add(response);
            }
            else
            {
                addresses.Add(new UnknownAddress(searchAddress));
            }

            return addresses;
        }
        public static IEnumerable<Address> Search(string streetAddress, string city, string state, string zipCode, bool geocode)
        {
            var addressLookup = new AddressLookup();
            var addresses = new List<Address>();

            if (string.IsNullOrEmpty(streetAddress))
            {
                if (!string.IsNullOrEmpty(city) && !string.IsNullOrEmpty(state) && CityList.IsCity(city, new State(state)))
                {
                    var citySearched = CityList.GetCity(city, new State(state));
                    var address = addressLookup.GetAddressFromCity(citySearched);

                    if (!string.IsNullOrEmpty(zipCode))
                    {
                        address.ZipCode = ZipCodeList.GetZipCode(zipCode);
                    }
                    addresses.Add(address);
                }
                else if (!string.IsNullOrEmpty(zipCode) && ZipCodeList.IsZipCode(zipCode))
                {
                    ZipCode zipCodeSearched = ZipCodeList.GetZipCode(zipCode);
                    addresses.Add(addressLookup.GetAddressFromZipCode(zipCodeSearched));
                }
            }
            if (addresses.Count == 0)
            {
                if (geocode)
                {
                    var response = Geocoder.Search(FormatAddress(streetAddress, city, state, zipCode));
                    addresses.Add(response);
                }
                else
                {
                    addresses.AddRange(Address.Search(FormatAddress(streetAddress, city, state, zipCode), geocode));
                }
            }
            return addresses;
        }