|
阅读:1718回复:5
ae+vb.net开发三维可视化界面,请高手指教!
<P >问题一:如何向<FONT face="Times New Roman">globecontrol</FONT>中加载<FONT face="Times New Roman">grid</FONT>栅格高程数据?我尝试了用<FONT face="Times New Roman">addlayertype</FONT>方法加载一个固定路径的<FONT face="Times New Roman">grid</FONT>文件,调试后,能够在<FONT face="Times New Roman">toc</FONT>列表中显示这个图层,但是在<FONT face="Times New Roman">globecontrol</FONT>中却没有显示。而我最终是想用户通过<FONT face="Times New Roman">opendialog</FONT>对话框选择加载<FONT face="Times New Roman">grid</FONT>数据,但是由于<FONT face="Times New Roman">grid</FONT>是没有后缀名的数据格式,所以不知道该如何设置才能够使用户自由加载。如何才能够在<FONT face="Times New Roman">globecontrol</FONT>中显示?</P>
<P >问题二:如何实现当鼠标在<FONT face="Times New Roman">globecontrol</FONT>视窗中移动的时候,在状态栏上显示相应位置的三维坐标信息?</P> <P>问题三:如何构建用于查询栅格数据的identify工具,我查了msdn,需要用到iidentify,irasterobj接口,但是现在思路比较模糊,不知道正确的思路是什么?</P> <P>关于问题一,我的代码如下:</P> <P>'add elevation data to the active globe viewer , as the base height layer<BR> Private Sub mnu_addelev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_addelev.Click<BR> OpenFileDialog1.Filter = "ESRI GRID(<GRID>)|<GRID>|USGS DEM(*.dem)|*.dem"<BR> OpenFileDialog1.Title = "select the elevation data to add"<BR> OpenFileDialog1.Multiselect = True<BR> OpenFileDialog1.InitialDirectory = "c:\"<BR> OpenFileDialog1.ShowDialog()<BR> If OpenFileDialog1.ShowDialog() = DialogResult.OK Then 'when the user event happen<BR> Dim m_prwsf As IWorkspaceFactory<BR> m_prwsf = New RasterWorkspaceFactory<BR> Dim m_pfiledr As String<BR> m_pfiledr = StrReverse(OpenFileDialog1.FileName)<BR> Dim i As Integer<BR> Dim j As Integer<BR> Dim a As Char<BR> For i = 1 To Len(m_pfiledr)<BR> a = GetChar(m_pfiledr, i)<BR> If a = "\" Then<BR> j = i<BR> Exit For<BR> End If<BR> Next<BR> Dim m_prdr As String<BR> Dim p_dir As String<BR> p_dir = Mid(m_pfiledr, j)<BR> m_prdr = StrReverse(p_dir)<BR> Dim m_prfilename As String<BR> m_prfilename = StrReverse(Mid(m_pfiledr, 1, j - 1))<BR> ' m_prfilename = Mid(OpenFileDialog1.FileName, Len(OpenFileDialog1.FileName) - j + 2)<BR> Dim m_Prws As IRasterWorkspace<BR> m_Prws = DirectCast(m_prwsf.OpenFromFile(m_prdr, 0), IRasterWorkspace)<BR> Dim m_prdts As IRasterDataset<BR> m_prdts = m_Prws.OpenRasterDataset(m_prfilename)<BR> If m_prdts Is Nothing Then 'check whether the raster dataset is existing or not <BR> MsgBox("please select the correct dataset!", MsgBoxStyle.RetryCancel, "error of adding elevation data")<BR> End If<BR> Dim m_pglobe As IGlobe<BR> m_pglobe = AxGlobeControl1.Globe<BR> Dim m_prlyr As IRasterLayer<BR> Dim m_pr As IRaster<BR> m_prlyr = New RasterLayer<BR> m_prlyr.CreateFromRaster(m_prdts)<BR> Dim m_prbands As IRasterBandCollection<BR> m_prbands = m_prdts<BR> Dim m_prband As IRasterBand<BR> m_prband = m_prbands.Item(0)<BR> Dim m_pdt As IDataset<BR> m_pdt = m_prband.RasterDataset<BR> m_prlyr.Name = m_pdt.BrowseName<BR> Dim m_plyr As ILayer<BR> m_plyr = New RasterLayer<BR> m_plyr = m_prlyr<BR> Dim m_Pelevlyrprop As IGlobeLayerProperties<BR> m_Pelevlyrprop = New GlobeLayerProperties<BR> m_Pelevlyrprop.Type = esriGlobeDataType.esriGlobeDataElevation<BR> Dim m_Plyrex As ILayerExtensions<BR> m_Plyrex = m_plyr<BR> m_Plyrex.AddExtension(m_Pelevlyrprop) 'i can not see what effect this does!<BR> Dim m_Pelevhprop As IGlobeHeightProperties<BR> m_Pelevhprop = New GlobeHeightProperties<BR> m_Pelevhprop.BaseOption = esriGlobeLayerBaseOption.esriGlobeLayerBaseSelf<BR> m_Pelevlyrprop.HeightProperties = m_Pelevhprop<BR> m_Pelevhprop.Apply(m_pglobe, m_plyr)<BR> If Not m_plyr Is Nothing Then<BR> m_pglobe.AddLayerType(m_plyr, esriGlobeLayerType.esriGlobeLayerTypeElevation, True)<BR> m_pglobe.GlobeDisplay.RefreshViewers()<BR> Else<BR> MsgBox("the elevation data is null!please retry!")<BR> End If<BR> Else<BR> Exit Sub<BR> End If<BR> End Sub</P> <P>调试的时候,当点击菜单中的加载高程数据的选项之后,打开文件对话框总是出现两次,而且当选择了数据之后,就会被挂起,在自动窗口中显示:rasterdataset和rasterlayer都为空,请高手帮忙啊!</P> |
|
|
1楼#
发布于:2005-08-29 20:59
<P>多谢gis,但是上面你写的代码是往globe中添加栅格数据,能够成功添加?</P>
|
|
|
2楼#
发布于:2005-08-29 16:44
<P>你先定义一个ibasicmap,就有addlayer方法,先用函数</P>
<P>Public Function OpenRasterDataset(sPath As String, sFileName As String) As IRasterDataset<BR> ' sPath: directory where dataset resides<BR> ' sFileName: name of the raster dataset<BR> On Error GoTo ErrorHandler<BR> <BR> ' Create RasterWorkSpaceFactory<BR> Dim pWSF As IWorkspaceFactory<BR> Set pWSF = New RasterWorkspaceFactory<BR> <BR> ' Get RasterWorkspace<BR> Dim pRasWS As IRasterWorkspace<BR> If pWSF.IsWorkspace(sPath) Then<BR> Set pRasWS = pWSF.OpenFromFile(sPath, 0)<BR> Set OpenRasterDataset = pRasWS.OpenRasterDataset(sFileName)<BR> End If<BR> <BR> ' Release memeory<BR> Set pRasWS = Nothing<BR> Set pWSF = Nothing<BR> Exit Function<BR>ErrorHandler:<BR> Set OpenRasterDataset = Nothing<BR>End Function</P> <P>这样返回了一个raster数据集,就可以加了</P> |
|
|
|
3楼#
发布于:2005-08-29 16:39
三维坐标信息只要把你的坐标转换过来就行,在帮助查看LocateMultiple方法
|
|
|
|
4楼#
发布于:2005-08-29 15:53
谢谢gis,但是我的代码也是这样的,为什么就是有问题呢?帮忙看看吧!
|
|
|
5楼#
发布于:2005-08-29 14:56
<P>' 函数从开发帮助里弄来的,呵呵,打开raster数据应该没问题</P>
<P>Public Function OpenRasterDataset(sPath As String, sFileName As String) As IRasterDataset<BR> ' sPath: directory where dataset resides<BR> ' sFileName: name of the raster dataset<BR> On Error GoTo ErrorHandler<BR> <BR> ' Create RasterWorkSpaceFactory<BR> Dim pWSF As IWorkspaceFactory<BR> Set pWSF = New RasterWorkspaceFactory<BR> <BR> ' Get RasterWorkspace<BR> Dim pRasWS As IRasterWorkspace<BR> If pWSF.IsWorkspace(sPath) Then<BR> Set pRasWS = pWSF.OpenFromFile(sPath, 0)<BR> Set OpenRasterDataset = pRasWS.OpenRasterDataset(sFileName)<BR> End If<BR> <BR> ' Release memeory<BR> Set pRasWS = Nothing<BR> Set pWSF = Nothing<BR> Exit Function<BR>ErrorHandler:<BR> Set OpenRasterDataset = Nothing<BR>End Function</P> |
|
|