/// <summary> /// Uses the FindAddressCandidates method to geocode a single address /// </summary> /// <param name="address">Input address</param> /// <returns>IPropertySet that contains the matched address</returns> public virtual IPropertySet MatchAddress(IPropertySet address) { _log.Debug("IAddressGeocoding MatchAddress"); IPropertySet resultSet = new PropertySetClass(); try { IArray addressCandidates = FindAddressCandidates(address); if (addressCandidates.Count < 1) throw new Exception(); resultSet = addressCandidates.get_Element(0) as IPropertySet; object names; object values; // Get the name and value of all the properties in the property set resultSet.GetAllProperties(out names, out values); String[] nameArray = names as String[]; object[] valueArray = values as object[]; _log.Debug("MatchAddress Input address columns:" + string.Concat(nameArray)); // Add the Status Field to the Result List<string> matchNames = new List<string>(nameArray); List<object> matchValues = new List<object>(valueArray); matchNames.Insert(1, "Status"); matchValues.Insert(1, "M"); // Set the field names and values for the matched address names = matchNames.ToArray() as object; values = matchValues.ToArray() as object; resultSet.SetProperties(names, values); return resultSet; } catch (Exception ex) { _log.Error("An error ocurred during MatchAddress: " + ex.Message); // Return an empty address match to prevent errors IGeometry emptyPoint = new PointClass() as IGeometry; emptyPoint.SetEmpty(); resultSet.SetProperties(new string[] { "Shape", "Status", "Score", "Match_addr" }, new object[] { emptyPoint, "U", null, null }); return resultSet; } }