Select to view content in your preferred language

How do I get the name of an address locator's reference data?

550
2
01-11-2013 05:53 AM
MelodyMeinhardt
Deactivated User
In a .NET project I have a composite locator that is made up of three different address locators.  One locator is built against an address point feature, one is built against a parcel feature, and one is built against a centerline/street feature.  I need to determine in code the name of the feature dataset each of these individual address locators is built against.  I have the list of the locators and I see IEnumReferenceDataTable and IReferenceDataTable but haven't been able to get any further. Thank you!
0 Kudos
2 Replies
Jan-Tschada
Esri Contributor
If you have a valid locator instance you should iterate through the reference tables. Each reference table has a name property. This name instance should implement IDatasetName. Using IDatasetName you have the information of the dataset and its workspace and you can open the dataset if necessary. Keep in mind, this will throw an exception if the dataset is not accessible.

internal static void WriteReferenceTableNamesToConsole(ILocator locator)
{
 var addressLocator = locator as IReferenceDataTables;
 if (null == addressLocator)
  return;

 var referenceDataTables = addressLocator.Tables;
 IReferenceDataTable referenceDataTable;
 while (null != (referenceDataTable = referenceDataTables.Next()))
 {
  var tableName = (IDatasetName) referenceDataTable.Name;
  Console.WriteLine(tableName.WorkspaceName.PathName + Environment.NewLine + tableName.Name);

  try
  {
   var referenceTable = (IFeatureClass) ((IName) tableName).Open();
   // ...
  }
  catch (COMException)
  {
   Console.Error.WriteLine(string.Format("Reference data '{0}' for locator '{1}' not accessible!", tableName, locator.Name));
  }
 }
}


Regards from Germany
Product Manager
Developers and Location Services
Germany and Switzerland
0 Kudos
MelodyMeinhardt
Deactivated User
That worked, thank you very much!
0 Kudos