阅读:2345回复:4
ae+vbnet向scenecontrol或者globecontrol中加载矢量数据问题
<P>我现在想要向当前的scenecontrol中加载矢量数据,首先需要将得到的矢量要素类转换为图层,调试的时候,会在m_pshlyr.FeatureClass = m_pshpefile处出现“未将对象引用设置到对象的实例”的错误信息,我在局部变量窗口检查了变量,要素类数据能够得到,但是不能够转换为图层,不知道为什么?请大家帮忙!十分感谢!</P>
<P>下面是我写的代码:</P> <P>If OpenFileDialog1.ShowDialog = DialogResult.OK Then<BR> Dim m_pshwsf As IWorkspaceFactory<BR> m_pshwsf = New ShapefileWorkspaceFactory<BR> Dim m_Pshfilename As String<BR> m_Pshfilename = 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_Pshfilename)<BR> a = GetChar(m_Pshfilename, i)<BR> If a = "\" Then<BR> j = i<BR> Exit For<BR> End If<BR> Next<BR> Dim m_Pshpath As String<BR> m_Pshpath = Mid(m_Pshfilename, j + 1) 'j<BR> m_Pshpath = StrReverse(m_Pshpath)<BR> Dim m_pshfile As String<BR> m_pshfile = StrReverse(Mid(m_Pshfilename, 1, j - 1))<BR> 'm_pshfile = Mid(OpenFileDialog1.FileName, Len(OpenFileDialog1.FileName) - j)<BR> Dim m_Pshws As IFeatureWorkspace<BR> m_Pshws = m_pshwsf.OpenFromFile(m_Pshpath, 0)<BR> 'vector is different from the raster in the add procedure<BR> Dim m_pshpefile As IFeatureClass<BR> Dim m_pshlyr As IFeatureLayer<BR> ' m_pshlyr = New FeatureLayer<BR> m_pshpefile = m_Pshws.OpenFeatureClass(m_pshfile)<BR> m_pshlyr.FeatureClass = m_pshpefile<BR> m_pshlyr.Name = m_pshpefile.AliasName</P> |
|
1楼#
发布于:2005-09-23 21:59
Set m_pshlyr.FeatureClass = m_pshpefile
|
|
|
2楼#
发布于:2005-09-24 09:30
<P>kisssy:谢谢!</P>
<P>但是我现在用的是vbnet,根本就不用set了。</P> <P>所以现在还是不知道问题在那里,大家继续帮忙啊!</P> <P>谢谢!</P> |
|
3楼#
发布于:2005-09-24 09:45
<P>Sorry!</P>
<P> ' m_pshlyr = New FeatureLayer</P> <P>这句为什么注释掉?</P> |
|
|
4楼#
发布于:2005-09-24 15:26
<P>谢谢kisssy。</P>
<P>本来我最初是直接用new featurelayer的,但是接下来发现不能够用featureclass属性,之后又改用ifeaturelayera接口,原来是忘了实例化了,呵呵!真是基础不牢,地动山摇啊!</P> <P>十分感谢!</P> |
|