Ejemplo n.º 1
0
        /// <summary>
        /// Finds address by geographical location.
        /// </summary>
        /// <param name="location">The point to find address for.</param>
        /// <returns>An address corresponding to the specified point.</returns>
        private Address _ReverseGeocode(Point location)
        {
            var result = default(Address);

            try
            {
                result = App.Current.Geocoder.ReverseGeocode(location);
            }
            catch (Exception e)
            {
                var canHandle =
                    e is AuthenticationException ||
                    e is CommunicationException;
                if (!canHandle)
                {
                    throw;
                }

                var serviceName = App.Current.FindString(GEOCODING_SERVICE_NAME_KEY);
                CommonHelpers.AddServiceMessage(serviceName, e);

                Logger.Error(e);
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Make reverse geocode request and fill geocodable object with new address fields values.
        /// </summary>
        /// <param name="geocodable">Geocodable to fill.</param>
        /// <param name="location">Geolocation point for request.</param>
        /// <returns>Is responce was received.</returns>
        private bool _ProcessReverseGeocode(IGeocodable geocodable, ESRI.ArcLogistics.Geometry.Point location)
        {
            bool result = false;

            try
            {
                Address geocodedAddress = App.Current.Geocoder.ReverseGeocode(location);

                // In case of not empty response - fill address.
                if (geocodedAddress != null)
                {
                    geocodedAddress.CopyTo(geocodable.Address);
                }
                else
                {
                    geocodable.Address.MatchMethod = (string)App.Current.FindResource(MANUALLY_EDITED_XY_FAR_FROM_NEAREST_ROAD_RESOURCE_NAME);
                }

                result = true;
            }
            catch (Exception ex)
            {
                if (ex is AuthenticationException || ex is CommunicationException)
                {
                    string service = (string)App.Current.FindResource(GEOCODING_SERVICE_NAME_RESOURCE_NAME);
                    CommonHelpers.AddServiceMessage(service, ex);
                }
                else
                {
                    throw;
                }
            }

            return(result);
        }