longfeng
路人甲
路人甲
  • 注册日期2004-12-08
  • 发帖数17
  • QQ
  • 铜币202枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1162回复:1

[求助]ArcObjects Geocoding

楼主#
更多 发布于:2006-04-28 23:46
<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>
喜欢0 评分0
longfeng
路人甲
路人甲
  • 注册日期2004-12-08
  • 发帖数17
  • QQ
  • 铜币202枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-04-29 06:13
<P>Got the answer:</P>
<P>//pReferenceDataTableEdit.Name = (ITableName)pDataset.FullName;<BR></P>
<P>change t</P>
<P>pReferenceDataTableEdit.Name_2 = (ITableName)pDataset.FullName;<BR></P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部