/// <summary> /// Does batch geocoding. /// </summary> /// <param name="objects">Objects to geocoding.</param> private void _BatchGeocode(IList<AppData.DataObject> objects) { Debug.Assert(null != objects); // created Debug.Assert(0 < objects.Count); // not empty Debug.Assert(null != _checker); // inited try { // create list of addresses Address[] addresses = _CreateAddressList(objects); // start geocode App currentApp = App.Current; AddressCandidate[] candidates = null; if (objects[0] is Order) { // for orders - use local geocoding NameAddress[] namedAddress = _CreateNamedAddressList(objects); var localGeocoder = new LocalGeocoder(currentApp.Geocoder, currentApp.NameAddressStorage); candidates = localGeocoder.BatchGeocode(namedAddress); } else { // for other object - use server geocoder candidates = currentApp.Geocoder.BatchGeocode(addresses); } _checker.ThrowIfCancellationRequested(); // validate geocode _ValidateLocation(addresses, candidates); // If current geocoder is arcgiscomgeocoder - check that we got // candidates from "good" locators. var arcgisgeocoder = App.Current.Geocoder as ArcGiscomGeocoder; if (arcgisgeocoder != null) { for (int i = 0; i < candidates.Count(); i++) { var goodAddressType = arcgisgeocoder.ExactLocatorsTypesNames.Contains(candidates[i].AddressType); if (!goodAddressType) candidates[i] = new AddressCandidate(); } } // parse result _ParseBatchGeocodeResult(candidates, objects); } catch (Exception ex) { Logger.Error(ex); // store exception _detectedException = ex; } }