public static AddressSuggestion [] GetAddressesSuggestions(string Country, string City, string Street, int MaxItemsCount, AddressTargetType TargetType) { _lastQueryContext = IsGoogleKing(Country + City + Street) ? AddressInfoContextType.Google : AddressInfoContextType.Yandex; IAddressQuery query = LastQueryContext == AddressInfoContextType.Google ? (IAddressQuery)new GoogleAddressQuery() : (IAddressQuery)new YandexAddressQuery(); return query.GetAddressesSuggestions(Country, City, Street, MaxItemsCount, TargetType); }
public void ParseStreet(string StreetName, AddressInfoContextType ContextType) { this.Street = new StreetInfo(); string region = null; string city = null; string street = null; string[] strs = StreetName.Split(','); if (ContextType == AddressInfoContextType.Google) { if (strs.Length >= 3) { region = strs[0].Trim(); city = strs[1].Trim(); street = strs[2].Trim(); } else if (strs.Length == 2) { city = strs[0].Trim(); street = strs[1].Trim(); } else { street = strs[0]; } } else if (ContextType == AddressInfoContextType.Yandex) { if (strs.Length >= 2) { city = strs[1].Trim(); street = strs[0].Trim(); } else { street = strs[0]; } } if (!string.IsNullOrEmpty(region)) this.AdministrativeArea = ParseAdministrativeArea(region); if (!string.IsNullOrEmpty(city)) this.City = ParseCityStatic(city); if (!string.IsNullOrEmpty(street)) this.Street = ParseStreetStatic(street); this.Building = null; }
public static AddressInfo GetAddressInfo(string AddressString) { IAddressQuery gc = new GoogleAddressQuery(); IAddressQuery yc = new YandexAddressQuery(); AddressInfo gai = null; try { gai = gc.GetAddressInfo(AddressString); } catch { } AddressInfo yai = null; try { yai = yc.GetAddressInfo(AddressString); } catch { } bool isGoogleKing = IsGoogleKing(AddressString); _lastQueryContext = isGoogleKing ? AddressInfoContextType.Google : AddressInfoContextType.Yandex; AddressInfo mainAi = isGoogleKing ? gai : yai; AddressInfo subAi = isGoogleKing ? yai : gai; if (mainAi != null) { if (subAi != null) mainAi.Merge(subAi); return mainAi; } else { return subAi; } }