Select to view content in your preferred language

Setting Address Locator properties using ArcObjects

3338
1
09-17-2014 09:05 AM
GeoDecisionsEDN9GannettFleming
Deactivated User

I am creating an Address Locator using ArcObjects and assigning properties to it, primarily through the IGeocodingProperties2 interface.  I cannot find how to set two properties - “write locator specific output fields” and “write display extent output fields" - these do not seem to be exposed by this or any other interface

In the ArcMap GUI, you can set them under Address Locator -> Properties -> Outputs, as shown in the image below

locator.jpg

My locator creation code is straightforward.  It expects the feature dataset (featureDataset below) and featureclass (featureClass below) where reference data is stored - to be already known:

    

            IWorkspace workspace  = featureDataset.Workspace;

            // Open the database locator workspace for the ArcSDE workspace.

            System.Object obj = Activator.CreateInstance(Type.GetTypeFromProgID("esriLocation.LocatorManager"));

            ILocatorManager2 locatorManager2 = obj as ILocatorManager2;

            ILocatorWorkspace locatorWorkspace = locatorManager2.GetLocatorWorkspace(workspace);

            // Get the Locator Style from the client workspace

            ILocatorWorkspace clientLocatorWorkspace = locatorManager2.GetLocatorWorkspaceFromPath("");

            ILocatorStyle locatorStyle = clientLocatorWorkspace.GetLocatorStyle("US Address - Dual Ranges");

            // Given the featureclass holding the reference data.

            IDataset dataset = (IDataset) featureClass;

            IReferenceDataTables referenceDataTables = (IReferenceDataTables) locatorStyle;

            IEnumReferenceDataTable enumReferenceDataTable = referenceDataTables.Tables;

            enumReferenceDataTable.Reset();

            IReferenceDataTable referenceDataTable = enumReferenceDataTable.Next();

            IReferenceDataTableEdit referenceDataTableEdit = (IReferenceDataTableEdit) referenceDataTable;

            referenceDataTableEdit.Name_2 = (ITableName) dataset.FullName;

            // Store the locator if the reference data is properly specified.          

            ILocator locator = null;

           

            if (referenceDataTables.HasEnoughInfo)

            {

                string targetLocatorNameString = "Loc01";

                locator = locatorWorkspace.AddLocator(targetLocatorNameString, (ILocator)locatorStyle, "", null);

               

                // Set the custom geocoding properties.

                //Write locator-specific output fields : Yes, Return display extent output fields : Yes

                IGeocodingProperties2 geocodingProperties2 = locator as IGeocodingProperties2;

                geocodingProperties2.AddXYCoordsToMatchFields = true;

                geocodingProperties2.MinimumCandidateScore = 10;

                geocodingProperties2.SideOffset = 10;

                geocodingProperties2.EndOffset = 10;

               

                locatorWorkspace.UpdateLocator(locator);

            }

Any code samples would help.

Thanks!              

Tags (3)
0 Kudos
1 Reply
BradNiemand
Esri Regular Contributor

You would do it in the following way if you want to do it at runtime:

        ILocatorImpl locatorImpl = locator as ILocatorImpl;

        IPropertySet locatorProperties = locatorImpl.Properties;

        locatorProperties.SetProperty("WriteDisplayExtentFields", "True");

        locatorProperties.SetProperty("WriteLocatorSpecificFields", "True");

        locatorImpl.Properties = locatorProperties;

If you want to do it to the locator and keep them updated, you can modify the .loc file directly using a text ediitor.

Brad

0 Kudos