码迷,mamicode.com
首页 > 其他好文 > 详细

The Geometry has no Z values 解决办法

时间:2015-03-09 12:34:18      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

from:http://dufan20086.blog.163.com/blog/static/6616452320145269343675/

 

我们在创建要素时,简单的IFeatureClass.CreateFeature之后,然后把IGeometry对象赋给Feature.shape,会引发“The Geometry has no Z values”的错误提示。类似的错误在做地图标注过程中也会出现。

本文所采用的解决办法参考了网上的一些资料:
http://blog.sina.com.cn/s/blog_6faf711d010138vq.html
http://hi.baidu.com/luoyuonline/item/2994bafc08e10f0dd99e7256
基本思路就是在CreateFeature之后,设置Z值(顺带将M值也一并设置)。
/// <summary>
        /// 设置Z值和M值,解决The Geometry has no Z values错误
        /// </summary>
        /// <param name="pF">要素</param>
        /// <param name="pGeo">几何</param>
        public static void SetZValue(IFeature pF, IGeometry pGeo)
        {
            int index;
            index = pF.Fields.FindField("Shape");
            IGeometryDef pGeometryDef;
            pGeometryDef = pF.Fields.get_Field(index).GeometryDef as IGeometryDef;
            if (pGeometryDef.HasZ)
            {
                IZAware pZAware = (IZAware)pGeo;
                pZAware.ZAware = true;
                //IZ iz1 = (IZ)pGeo;
                //iz1.SetConstantZ(0);  //将Z值设置为0
//在ArcEngine10.2中用下面的两行代码来设置
                IPoint point = (IPoint)pGeo;
                point.Z = 0;
            }
            else
            {
                IZAware pZAware = (IZAware)pGeo;
                pZAware.ZAware = false;
            }
            //M值
            if (pGeometryDef.HasM)
            {
                IMAware pMAware = (IMAware)pGeo;
                pMAware.MAware = true;
            }
            else
            {
                IMAware pMAware = (IMAware)pGeo;
                pMAware.MAware = false;
            }
        }//function

 

The Geometry has no Z values 解决办法

标签:

原文地址:http://www.cnblogs.com/94cool/p/4323136.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!