/// <summary> /// Provides a list of parcel id with associated address in the formatted string /// </summary> /// <param name="topologyGraph">The topology graph of the area of interest. <see cref="ITopologyGraph"/></param> /// <param name="parcelsToCentroidMap">A dictionary object containing the parcel id and its centroid</param> /// <returns>A formatted list of parcel and its address information</returns> private List <string> GetParcelsWithAddress(ITopologyGraph topologyGraph, Dictionary <int, IPoint> parcelsToCentroidMap) { List <string> parcelWithAddressList = new List <string>(); if (topologyGraph == null || parcelsToCentroidMap.Count < 1) { return(null); } // Iterating parcels to fetch the address node from the topology graph foreach (KeyValuePair <int, IPoint> keyValuePair in parcelsToCentroidMap) { int parcelID = keyValuePair.Key; IPoint parcelCentroid = keyValuePair.Value; ITopologyElement addressToplogyElement; double hitRadius; // Find a topology element that is closest to the parcel centroid and with in the search radius of 10.0. If success the method will return the address topology node bool isElementFound = topologyGraph.HitTest((int)esriTopologyElementType.esriTopologyNode, parcelCentroid, 10.0, null, out hitRadius, out addressToplogyElement); if (addressToplogyElement != null && isElementFound) { IEnumTopologyParent addressElementParents = addressToplogyElement.Parents; addressElementParents.Reset(); //Iterate over topology element parents for (int addressElementCount = 0; addressElementCount < addressElementParents.Count; addressElementCount++) { esriTopologyParent addressElementParent = addressElementParents.Next(); int addressFID = addressElementParent.m_FID; IFeatureClass addressFC = addressElementParent.m_pFC; // Fetch address feature IFeature addressFeature = GetFeature(addressFC, addressFID); // Get parcel address index int addressIndex = addressFeature.Fields.FindField("ADDRESS"); if (addressIndex >= 0) { // Get parcel address value string addressValue = addressFeature.Value[addressIndex].ToString(); // Add parcel ID and address value parcelWithAddressList.Add($"Parcel ID: {parcelID} / Address Coordinates: {addressValue}"); } } } } return(parcelWithAddressList); }