c# AE 创建的shp 在arcmap中放大不显示处理

29 篇文章 0 订阅

ArcEngine中shp中先加入要素然后删除一部分要素后,放大图形后不显示的问题解决方法

(一)问题描述如下:

shp中先加入要素然后删除一部分要素后,图形为什么显示不正常了
//------------------
我遇到这个问题,请问大家是怎么解决的?
我的操作是:
往shp文件加入要素,
然后,再删除一部分要素,
显示就不正常了:
现象如下所示:
"这种情况全图显示时能看到所有图形,放大到某个范围后,某些图形就看不到了",

其加入要素代码如下所示:

  1. 操作加入要素的代码如下所示: 
  2. IFeatureCursor InsertCursor = null
  3. InsertCursor = Polygonfc.Insert(true); 
  4. IGeometry newgeo = null
  5. ComUnionOperator cuOp = new ComUnionOperator(); 
  6. newgeo = cuOp.Union(FeatList.ToArray());   // 
  7. if (newgeo != null
  8.                                                 (newgeo as ITopologicalOperator).Simplify(); 
  9.                                                 newgeo.SpatialReference = sr; 
  10.                                                 //创建一个新图斑 
  11.                                                 IFeatureBuffer featBuf = Polygonfc.CreateFeatureBuffer(); 
  12.                                                 featBuf.Shape = newgeo;         //设置几何对象  
  13.                                                 zhfeat = new ZHFeaturePolygon(p_feat); 
  14.                                                 zhfeat.CopyField(ref featBuf);  //设置属性值 
  15.                                                 ZhFeatureBuffer zhfeatBuf = new ZhFeatureBuffer(featBuf); 
  16.                                                 zhfeatBuf.setFieldValue("xp_bh", ""); //设为空以防被删除 
  17.                                                 //插入新图斑到空间数据库中 
  18.                                                 InsertCursor.InsertFeature(featBuf); 
  19.                                                 //记录要删除的原地物 
  20.                                                 del_xp_bh_List.Add(xp_bh_str); 
  21.                                                 del_xp_bh_List.Add(xp_bh_s_str); 
  22.                                                 //                                             
  23. //保存到空间库中 
  24.                         if (InsertCursor != null
  25.                         { 
  26.                             InsertCursor.Flush(); 
  27.                             TokayWorkspace.ComRelease(InsertCursor); 
  28.                             InsertCursor = null
  29.                         } 
操作加入要素的代码如下所示:
IFeatureCursor InsertCursor = null;
InsertCursor = Polygonfc.Insert(true);
IGeometry newgeo = null;
ComUnionOperator cuOp = new ComUnionOperator();
newgeo = cuOp.Union(FeatList.ToArray());   //
if (newgeo != null)
{
                                                (newgeo as ITopologicalOperator).Simplify();
                                                newgeo.SpatialReference = sr;
                                                //创建一个新图斑
                                                IFeatureBuffer featBuf = Polygonfc.CreateFeatureBuffer();
                                                featBuf.Shape = newgeo;         //设置几何对象 
                                                zhfeat = new ZHFeaturePolygon(p_feat);
                                                zhfeat.CopyField(ref featBuf);  //设置属性值
                                                ZhFeatureBuffer zhfeatBuf = new ZhFeatureBuffer(featBuf);
                                                zhfeatBuf.setFieldValue("xp_bh", ""); //设为空以防被删除
                                                //插入新图斑到空间数据库中
                                                InsertCursor.InsertFeature(featBuf);
                                                //记录要删除的原地物
                                                del_xp_bh_List.Add(xp_bh_str);
                                                del_xp_bh_List.Add(xp_bh_s_str);
                                                //                                            
}
//保存到空间库中
                        if (InsertCursor != null)
                        {
                            InsertCursor.Flush();
                            TokayWorkspace.ComRelease(InsertCursor);
                            InsertCursor = null;
                        }

  1. 操作删除要素的代码如下所示: 
  2. #region//删除碎小地物操作 
  3.                         string t_del_wc = ""
  4.                         for (int i = 0; i < del_xp_bh_List.Count; i++) 
  5.                         { 
  6.                             if (t_del_wc.Trim() == ""
  7.                             { 
  8.                                 t_del_wc = "'" + del_xp_bh_List[i] + "'"
  9.                             } 
  10.                             else 
  11.                             { 
  12.                                 t_del_wc += ",'" + del_xp_bh_List[i] + "'"
  13.                             } 
  14.                         } 
  15.                         if (t_del_wc.Trim() != ""//??? 
  16.                         { 
  17.                             IQueryFilter t_del_qf = new QueryFilterClass(); 
  18.                             t_del_qf.WhereClause = "xp_bh in(" + t_del_wc + ")"
  19.                             IFeatureCursor del_featcur = Polygonfc.Update(t_del_qf, false); 
  20.                             IFeature del_feat = del_featcur.NextFeature(); 
  21.                             while (del_feat != null
  22.                             { 
  23.                                 del_featcur.DeleteFeature(); 
  24.                                 del_feat = del_featcur.NextFeature(); 
  25.                             } 
  26.                             del_featcur.Flush(); 
  27.                             TokayWorkspace.ComRelease(del_featcur); 
  28.                             del_featcur = null
  29.                             // 
  30.                             //TokayWorkspace.DeleteFeatures(Polygonfc, t_del_qf); 
  31.                         } 
  32.                         #endregion 
操作删除要素的代码如下所示:
#region//删除碎小地物操作
                        string t_del_wc = "";
                        for (int i = 0; i < del_xp_bh_List.Count; i++)
                        {
                            if (t_del_wc.Trim() == "")
                            {
                                t_del_wc = "'" + del_xp_bh_List[i] + "'";
                            }
                            else
                            {
                                t_del_wc += ",'" + del_xp_bh_List[i] + "'";
                            }
                        }
                        if (t_del_wc.Trim() != "")  //???
                        {
                            IQueryFilter t_del_qf = new QueryFilterClass();
                            t_del_qf.WhereClause = "xp_bh in(" + t_del_wc + ")";
                            IFeatureCursor del_featcur = Polygonfc.Update(t_del_qf, false);
                            IFeature del_feat = del_featcur.NextFeature();
                            while (del_feat != null)
                            {
                                del_featcur.DeleteFeature();
                                del_feat = del_featcur.NextFeature();
                            }
                            del_featcur.Flush();
                            TokayWorkspace.ComRelease(del_featcur);
                            del_featcur = null;
                            //
                            //TokayWorkspace.DeleteFeatures(Polygonfc, t_del_qf);
                        }
                        #endregion

经测试,加入要素没有问题,不删除操作,显示是正常的,
问题出在当执行删除操作时,显示就不正常了,
但另存为shp或其他格式的数据显示就正常;

搜索网上的解决办法的url地址:
http://hi.baidu.com/supu_beauty/ ... 98ff54242df26f.html
http://www.cnblogs.com/sxw_cug/archive/2010/08/27/1810345.html
ARCMAP中数据放大不显示问题
2010-07-19 21:08
     最近发现在ARCMAP中矢量数据放大不显示问题,暴露问题状况为:全屏状态下数据正常显示,放大后反而数据不显示了,但是可以选择的到。一般用如下三种方法解决问题:

     1、用ArcToolbox中的Datamanagement工具下的Features中的Repair Geometry修复数据。

     2、修改文件名,尽量用英文,同时修改路径,尽量使其短,而且尽量使用英文。

     3、如果上面两种方法无效的情况下,在ARCMAP中打开数据,然后Editor菜单下Start Editing,然后再Stop Editing,这样放大就可显示,至于原因正在查找中,原理也不是太明白,待以后更新补充。
//-------------------------------------------------------
我使用第三种方法这样放大就可显示了!原因我也不清楚!

如果是自定义编写的应用软件的话,需要重启应用软件,再开始编辑然后停止编辑,显示就可以了!

执行完先加入要素,然后删除一部分要素后
再执行下面的代码:显示问题依然存在!
//开始编辑然后再停止编辑
            IWorkspace ws = (this.Polygonfc as IDataset).Workspace;
            IWorkspaceEdit wsEdit = ws as IWorkspaceEdit;
            if (wsEdit.IsBeingEdited() == true)
            {
                wsEdit.StopEditing(true);
            }
            wsEdit.StartEditing(false);
            wsEdit.StopEditing(true);
            //
需要重启应用软件,再开始编辑然后停止编辑,显示就可以了!

各位兄弟姐妹们,这个问题已经解决了。
解决方法如下代码所示:
问题是删除要素的时候出现的放大显示现象,
我对删除要素的代码作如下形式的修改,这个现象就没有了:
#region//删除碎小地物操作
                        string t_del_wc = "";
                        for (int i = 0; i < del_xp_bh_List.Count; i++)
                        {
                            if (t_del_wc.Trim() == "")
                            {
                                t_del_wc = "'" + del_xp_bh_List[i] + "'";
                            }
                            else
                            {
                                t_del_wc += ",'" + del_xp_bh_List[i] + "'";
                            }
                        }
                        if (t_del_wc.Trim() != "") 
                        {
                            //开始编辑然后再停止编辑以处理放大不能显示的问题
                            IWorkspace ws = (this.Polygonfc as IDataset).Workspace;
                            IWorkspaceEdit wsEdit = ws as IWorkspaceEdit;
                            if (wsEdit.IsBeingEdited() == true)
                            {
                                wsEdit.StopEditing(true);
                            }
                            wsEdit.StartEditing(false);
                            wsEdit.StartEditOperation();
                            //----

                            IQueryFilter t_del_qf = new QueryFilterClass();
                            t_del_qf.WhereClause = "xp_bh in(" + t_del_wc + ")";
                            IFeatureCursor del_featcur = Polygonfc.Update(t_del_qf, false);
                            IFeature del_feat = del_featcur.NextFeature();
                            while (del_feat != null)
                            {
                                del_featcur.DeleteFeature();
                                del_feat = del_featcur.NextFeature();
                            }
                            del_featcur.Flush();
                            TokayWorkspace.ComRelease(del_featcur);
                            del_featcur = null;
                            //----
                            wsEdit.StopEditOperation();
                            wsEdit.StopEditing(true);
                            //TokayWorkspace.DeleteFeatures(Polygonfc, t_del_qf);
                        }
                        #endregion

----the----end-----

vp:hsg

create date:2012-03-07  10:57

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值