shixcn
外卖仔
外卖仔
  • 注册日期2003-11-02
  • 发帖数73
  • QQ
  • 铜币180枚
  • 威望0点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
阅读:1756回复:3

[求助]那位知道AE中如何浏览Personal Geodatabase的shape格式的文件和选择打开?

楼主#
更多 发布于:2005-09-09 20:14
<P>    那位可以告诉我在AE中如何实现选择Personal Geodatabase然后打开,选择Database中的FeatureClass,然后添加到MapControl控件中?</P>
<P><BR><BR>   如果单个是shape文件 已经实现添加 ,但是如果导到数据库中 如何选择添加?那位知道,可否告知一二? 先谢谢了!</P>
<P>以下是添加选择单个shape文件的代码:</P>
<P>Public Function SelectShapeFiles() As Collection<BR>  On Error GoTo ExitFunction<BR>    <BR>  Dim sStartPath As String<BR>  sStartPath = GetSetting("ESRI Developer Samples\AddShapeFile", "Settings", "Shapefile Sticky Path", App.Path)</P>
<P>  Dim sFname As String<BR>  With Me.dlgCommon<BR>    .DialogTitle = "Select Shapefile(s) to add"<BR>    .Flags = cdlOFNFileMustExist + cdlOFNPathMustExist + cdlOFNAllowMultiselect + cdlOFNExplorer + cdlOFNHideReadOnly</P>
<P>    .DefaultExt = "shp"<BR>    .Filter = "Shapefiles files|*.shp"<BR>    .CancelError = True<BR>    .FileName = ""<BR>    .MaxFileSize = 2048<BR>    If (sStartPath <> "") Then .InitDir = sStartPath<BR>    .ShowOpen<BR>    sFname = .FileName ; vbNullChar<BR>  End With<BR>      <BR>  If (sFname = "") Then Exit Function<BR>  <BR>  ' Extract the file names from the common dialogs encoded string<BR>  Dim sFiles() As String<BR>  BuildFileArray sFname, sFiles()<BR>  <BR>  ' Create a shapefile workspace factory and workspace and<BR>  ' open all the shapefiles<BR>  Dim pWorkspaceFactory As IWorkspaceFactory<BR>  Set pWorkspaceFactory = New ShapefileWorkspaceFactory<BR>  <BR>  ' The first entry in the array is the shapefile directory (the workspace)<BR>  Dim pFeatureWorkspace As IFeatureWorkspace<BR>  Set pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(sFiles(LBound(sFiles)), 0)<BR>  <BR>  Dim pFeatureClass As IFeatureClass<BR>  Dim pClasses As New Collection<BR>  Dim i As Long<BR>  <BR>  ' display information in proper text box<BR>  For i = (LBound(sFiles) + 1) To UBound(sFiles)<BR>    Set pFeatureClass = pFeatureWorkspace.OpenFeatureClass(sFiles(i))<BR>    pClasses.Add pFeatureClass<BR>  Next i<BR>  <BR>  Set SelectShapeFiles = New Collection<BR>  ' Now add them to the collection of feature classes returned from<BR>  ' this function in geometry order - polygons first, then lines, then points<BR>  For i = 1 To pClasses.Count<BR>    Set pFeatureClass = pClasses.Item(i)<BR>    If (pFeatureClass.ShapeType = esriGeometryPolygon Or _<BR>        pFeatureClass.ShapeType = esriGeometryEnvelope) Then<BR>      SelectShapeFiles.Add pFeatureClass<BR>    End If<BR>  Next i<BR>  ' and lines<BR>  For i = 1 To pClasses.Count<BR>    Set pFeatureClass = pClasses.Item(i)<BR>    If (pFeatureClass.ShapeType = esriGeometryLine Or _<BR>        pFeatureClass.ShapeType = esriGeometryPath Or _<BR>        pFeatureClass.ShapeType = esriGeometryBezier3Curve Or _<BR>        pFeatureClass.ShapeType = esriGeometryCircularArc Or _<BR>        pFeatureClass.ShapeType = esriGeometryEllipticArc Or _<BR>        pFeatureClass.ShapeType = esriGeometryPath Or _<BR>        pFeatureClass.ShapeType = esriGeometryPolyline) Then<BR>      SelectShapeFiles.Add pFeatureClass<BR>    End If<BR>  Next i<BR>  ' last points<BR>  For i = 1 To pClasses.Count<BR>    Set pFeatureClass = pClasses.Item(i)<BR>    If (pFeatureClass.ShapeType = esriGeometryMultipoint Or _<BR>        pFeatureClass.ShapeType = esriGeometryPoint) Then<BR>      SelectShapeFiles.Add pFeatureClass<BR>    End If<BR>  Next i</P>
<P>  ' Grab the first file from the array and get the path from it<BR>  Dim lStartFileName As Long<BR>  lStartFileName = InStrRev(sFiles(LBound(sFiles)), "\")<BR>  If (lStartFileName <> 0) Then SaveSetting "ESRI Developer Samples\AddShapeFile", "Settings", "Shapefile Sticky Path", sFiles(0)</P>
<P>  Exit Function<BR>ExitFunction:<BR>  Err.Clear<BR>End Function</P>
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2005-09-09 23:27
<P>定义一个access的工作空间,就可以打开featureclass,这个和你打开shape是一样的,只是工作空间接口不同</P>
<P>另外你可以通过dataset和featureclass接口来决定你要打开的要素集或者要素类</P>
举报 回复(0) 喜欢(0)     评分
shixcn
外卖仔
外卖仔
  • 注册日期2003-11-02
  • 发帖数73
  • QQ
  • 铜币180枚
  • 威望0点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
2楼#
发布于:2005-09-10 18:16
<P>但是我还有个问题,关键Personal Geodatabase中的地理要素数目不是很确定 ,而且Personal Geodatabase本身是一个文件 打开如何的仅仅是一个文件,如何对里面的要素进行操作呢?如果方便的话,可否提供一定的代码提示呢? 先谢谢了</P>
<img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em02.gif" />
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
3楼#
发布于:2005-09-12 20:40
<P>在获取到了dataset,可以利用IEnumDatasetName和IFeatureDataset,IEnumFeatureClass等接口来获取图层<BR></P>
<P>  Dim pEnumDatasets As IEnumDatasetName<BR>  <BR>  Set pEnumDatasets = pSDEWorkSpace.DatasetNames(esriDTFeatureDataset)</P>
<P>  Dim pDatasetName As IDatasetName<BR>  Set pDatasetName = pEnumDatasets.Next  <BR>  While Not pDatasetName Is Nothing<BR>       strFeatureDataSetName = pDatasetName.Name </P>
<P>        Set pDatasetName = pEnumDatasets.Next<BR>  Wend</P>
<P>这样就获取到了数据库的所有要素集的名字</P>
<P>然后你可以通过OpenFeatureDataset打开要素集,通过类似的方法获取要素集里的文件,</P>
<P>每个对象(要素)都是可操作的,这个应该是你变成的技巧问题了,还是希望你写点代码再问吧,</P>
<P>没做之前,我相信你听再多,会更糊涂:)</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部