阅读:1574回复:3
如何将一个variant类型转化成geometry
<P>当我读取一个要素类中的某一个要素,读取到它的shape字段的值,是一个variant类型的值,要如何做才能把这个variant值转换成一个geometry对象</P>
|
|
1楼#
发布于:2007-05-31 22:39
<img src="images/post/smile/dvbbs/em01.gif" />
|
|
2楼#
发布于:2007-05-29 22:40
<P> Dim pFeatureLayer As IFeatureLayer<BR> Dim pFeatureClass As IFeatureClass<BR> Dim pMap As IMap<BR> Set pMap = MapControl1.Map<BR> <BR> Dim pLayer As ILayer<BR> Set pLayer = pMap.Layer(0)<BR> <BR> Set pFeatureLayer = pLayer<BR> Set pFeatureClass = pFeatureLayer.FeatureClass<BR> <BR> If pFeatureClass.ShapeType = esriGeometryPoint Then<BR> MsgBox "This is a Point feaure class"<BR> Else<BR> MsgBox "This is not a Point feature class"<BR> End If</P>
<P>这段是在VB+AE中实现的,首先要加载图层</P> |
|
3楼#
发布于:2007-05-29 20:29
<P>感觉你好像需要获取这个要素中的要素geometry类型,如果是,下面的方法可以获取</P><PRE><P>The following example shows how you can use the <B>ShapeType</B> property to determine whether or not the feature class is a polygon feature class, and if it is, then do something, otherwise skip it. <BR><BR></P><PRE> Dim pFeatcls As IFeatureClass
<BR> Dim pFeatLayer As IFeatureLayer <BR> Dim pDoc As IMxDocument <BR> Dim pMap As IMap <BR> <BR> Set pDoc = ThisDocument <BR> Set pMap = pDoc.Maps.Item(0) <BR> Set pFeatLayer = pMap.Layer(0) <BR> Set pFeatcls = pFeatLayer.FeatureClass <BR> <BR> If pFeatcls.ShapeType = esriGeometryPolygon Then <BR> ' code to do something. Here we will send a message <BR> ' to a message box <BR> MsgBox "This is a polygon feaure class" <BR> Else <BR> ' code to execute if this is not a polygon <BR> ' feature class <BR> MsgBox "This is not a polygon feature class" <BR> End If</PRE></PRE> |
|
|