阅读:1159回复:0
[求助]用AO做Geocoding的Locator?
<P>我想用AO生成自己的Locator (C#). 可是 pReferenceDataTables.HasEnoughInfo 总是 false. 请哪位高手指教. 多谢!</P>
<P> private ILocator CreateLocator()<BR> {<BR> //adds a new locator to the default local locator workspace<BR> //ILocatorManager2 pLocatorManager;<BR> ILocatorManager pLocatorManager;<BR> ILocatorWorkspace pLocatorWorkspace;<BR> ILocatorStyle pLocatorStyle;<BR> //IWorkspaceFactory2 pWorkspaceFactory;<BR> IWorkspaceFactory pWorkspaceFactory;<BR> IFeatureWorkspace pFeatureWorkspace;<BR> IDataset pDataset;<BR> IReferenceDataTables pReferenceDataTables;<BR> IEnumReferenceDataTable pEnumReferenceDataTable;<BR> IReferenceDataTableEdit pReferenceDataTableEdit;<BR> ILocator pLocator=null;</P> <P> //open the default local locator workspace<BR> pLocatorManager = new LocatorManagerClass();<BR> pLocatorWorkspace = pLocatorManager.GetLocatorWorkspaceFromPath("");</P> <P> //get a locator style on which to base the new locator<BR> //pLocatorStyle = pLocatorWorkspace.GetLocatorStyle("US Streets with Zone (GDB)");<BR> pLocatorStyle = pLocatorWorkspace.GetLocatorStyle("US Streets (GDB)");</P> <P> pLocator = (ILocator)pLocatorStyle;<BR> pLocator.Description = "This is a test description of geocoding service";</P> <P> //open the feature workspace containing the reference data<BR> pWorkspaceFactory = (IWorkspaceFactory) new ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactory();<BR> pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile("C:\\mydoc\\geocoding\\Atlanta.mdb", 0);</P> <P> //set the reference data on the new locator<BR> pDataset = (IDataset)pFeatureWorkspace.OpenFeatureClass("Streets");<BR> //pDataset = (IDataset)pFeatureWorkspace.OpenFeatureClass("streets_StandardizeAddresses1"); <BR> pReferenceDataTables = (IReferenceDataTables)pLocatorStyle;<BR> pEnumReferenceDataTable = pReferenceDataTables.Tables;<BR> pEnumReferenceDataTable.Reset();<BR> for (int j = 0; j < pEnumReferenceDataTable.Count; j++)<BR> {<BR> pReferenceDataTableEdit = (IReferenceDataTableEdit)pEnumReferenceDataTable.Next();<BR> if (pReferenceDataTableEdit.DisplayName == "Primary table")<BR> {<BR> //pReferenceDataTableEdit.Name = (ITableName)pDataset.FullName;<BR> String thedatasetname = pDataset.FullName.NameString;<BR> }<BR> }</P> <P> ////store the locator if the reference data are properly specified<BR> if (pReferenceDataTables.HasEnoughInfo)<BR> {<BR> pLocator = (ILocator)pLocatorWorkspace.AddLocator("My New US Streets Locator", pLocator, "", null);<BR> }<BR> else<BR> {<BR> System.Windows.Forms.MessageBox.Show("Check the feature class to see if it contains the required fields for this geocoding service style.");<BR> }<BR> return pLocator;<BR> }</P> <P> }</P> |
|