/// <summary> /// Finds address by geographical location. Asynchronous method. /// </summary> /// <param name="location">Location point.</param> /// <param name="userToken">Geocoding operation token.</param> /// <exception cref="ESRI.ArcLogistics.AuthenticationException"> /// Is thrown if server state is unauthorized.</exception> public override void ReverseGeocodeAsync(ESRI.ArcLogistics.Geometry.Point location, object userToken) { _ValidateGeocoderState(); try { PointN point = new PointN(); point.X = location.X; point.Y = location.Y; // REV: we should pass WPG84 since we store our points in this spatial reference SpatialReference sr = new ESRI.ArcLogistics.GeocodeService.GeographicCoordinateSystem(); sr.WKID = GeometryConst.WKID_WGS84; //point.SpatialReference = sr; PropertySet propMods = new PropertySet(); propMods.PropertyArray = new PropertySetProperty[2]; // distance units propMods.PropertyArray[1] = _CreateProp("ReverseDistanceUnits", REV_DISTANCE_UNITS); // distance value propMods.PropertyArray[0] = _CreateProp("ReverseDistance", SNAP_TOL); _client.ReverseGeocodeAsync(point, false, propMods, userToken); } catch (System.ServiceModel.FaultException ex) { Logger.Info(ex); } // eat FaultException if location cannot be reverse geocoded }
/// <summary> /// Finds address by geographical location. /// </summary> /// <param name="location">Location point.</param> /// <returns>Returns found address.</returns> /// <exception cref="ESRI.ArcLogistics.AuthenticationException"> /// Is thrown if server state is unauthorized.</exception> public override Address ReverseGeocode(ESRI.ArcLogistics.Geometry.Point location) { _ValidateGeocoderState(); Address res = null; try { PointN point = new PointN(); point.X = location.X; point.Y = location.Y; // REV: we should pass WPG84 since we store our points in this spatial reference SpatialReference sr = new ESRI.ArcLogistics.GeocodeService.GeographicCoordinateSystem(); sr.WKID = GeometryConst.WKID_WGS84; //point.SpatialReference = sr; // Set properties for reverse geocoder. PropertySet propMods = new PropertySet(); propMods.PropertyArray = new PropertySetProperty[2]; // Distance units. propMods.PropertyArray[1] = _CreateProp("ReverseDistanceUnits", REV_DISTANCE_UNITS); // Distance value. propMods.PropertyArray[0] = _CreateProp("ReverseDistance", SNAP_TOL); // REV: we should ask server to return point in WGS84 // First try reverse geocode intersection. PropertySet pSet = _ReverseGeocode(point, false, propMods); if (pSet != null && pSet.PropertyArray != null) res = _GetAddress(pSet); } catch (System.ServiceModel.FaultException ex) { Logger.Error(ex); } return res; }