//---------------------------------------------------------------------- private static IntSet <PartyId> SearchByCity( Timer t, AddressParserResult searchLocale, int desiredResultCount, int maxResultCount, double nonGeoMatchAbsDensity, out Location centroid, out double?maxRadiusMi) { maxRadiusMi = null; if (desiredResultCount == ExactMatchResultCount) { IntSet <PartyId> partiesInCity = null; t.Measure("Search by City", delegate() { partiesInCity = Snap.Cache.Cache.City(searchLocale); }); centroid = null; return(partiesInCity); } else { IGeoCoder geocoder = GeoCoderFactory.CreateGeoCoder(); centroid = geocoder.GeoCode( searchLocale.City, searchLocale.StateCode); return(SearchNearLocation( t, desiredResultCount, centroid, nonGeoMatchAbsDensity, out maxRadiusMi)); } }
//---------------------------------------------------------------------- private static IntSet <PartyId> SearchNearStreetAddress( Timer t, AddressParserResult searchLocale, int desiredResultCount, int maxResultCount, double nonGeoMatchAbsDensity, out Location centroid, out double?maxRadiusMi) { if (null == searchLocale.Location) { IGeoCoder geocoder = GeoCoderFactory.CreateGeoCoder(); Location[] ls = geocoder.GeoCode( searchLocale.StreetAddress, searchLocale.City, searchLocale.StateCode, searchLocale.PostalCode); if (ls.Length == 0) { throw new ArgumentException("unknown address"); } if (ls.Length > 1) { throw new ArgumentException("ambiguous address"); } centroid = ls[0]; } else { centroid = searchLocale.Location; } maxRadiusMi = null; return(SearchNearLocation( t, desiredResultCount, centroid, nonGeoMatchAbsDensity, out maxRadiusMi)); }