Exemplo n.º 1
0
 /// <summary>
 /// 几何检查的错误类型信息
 /// </summary>
 /// <param name="eType">几何错误类型</param>
 /// <param name="name">几何错误名称</param>
 /// <param name="aliasName">几何错误别名</param>
 /// <param name="description">几何错误描述</param>
 public GeometryCheckInfo(esriNonSimpleReasonEnum eType, string name, string aliasName, string description)
 {
     this.eType  = eType;
     Name        = name;
     AliasName   = aliasName;
     Description = description;
 }
Exemplo n.º 2
0
        public bool CheckFeature(IFeature pFeature, ref object pErrFeatureInf)
        {
            IFieldEdit        edit             = this._layer.FeatureClass.Fields.get_Field(this._layer.FeatureClass.Fields.FindField(this._layer.FeatureClass.ShapeFieldName)) as IFieldEdit;
            ISpatialReference spatialReference = edit.GeometryDef.SpatialReference;
            bool                flag           = true;
            List <double[]>     list           = (List <double[]>)pErrFeatureInf;
            IGeometryCollection shape          = pFeature.Shape as IGeometryCollection;

            for (int i = 0; i < shape.GeometryCount; i++)
            {
                esriNonSimpleReasonEnum enum2     = esriNonSimpleReasonEnum.esriNonSimpleOK;
                IPointCollection        newPoints = shape.get_Geometry(i) as IPointCollection;
                PolylineClass           o         = new PolylineClass();
                o.AddPointCollection(newPoints);
                o.SpatialReference = spatialReference;
                ITopologicalOperator3 ioperator = o as ITopologicalOperator3;
                ioperator.IsKnownSimple_2 = false;
                if (!ioperator.get_IsSimpleEx(out enum2))
                {
                    IRing ring = newPoints as IRing;
                    int   num2 = 0;
                    if (ring.IsClosed)
                    {
                        num2 = 1;
                    }
                    flag = false;
                    List <string> list2 = new List <string>();
                    List <string> list3 = new List <string>();
                    for (int j = num2; j < newPoints.PointCount; j++)
                    {
                        IPoint point = newPoints.get_Point(j);
                        string item  = point.X.ToString() + "," + point.Y.ToString();
                        if (list2.Contains(item))
                        {
                            if (!list3.Contains(item))
                            {
                                double[] numArray = new double[] { point.X, point.Y };
                                list.Add(numArray);
                                list3.Add(item);
                            }
                        }
                        else
                        {
                            list2.Add(item);
                        }
                    }
                }
                Marshal.ReleaseComObject(o);
                o = null;
            }
            return(flag);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 判断图形是否存在几何错误,
        /// <para>True表示存在错误,False表示未检查出错误,</para>
        /// <para>esriNonSimpleReasonEnum参数表示检查出的错误类型(自相交、非闭合环、不正确环走向、不正确线段方向、短线段等)</para>
        /// </summary>
        /// <param name="geometry"></param>
        /// <param name="eNonSimpleReason">几何错误类型,参考:http://resources.arcgis.com/zh-cn/help/main/10.2/index.html#//001700000034000000 ,或参考<see cref="GeometryCheckInfo.GetGeometryCheckInfos"/></param>
        /// <returns>True表示存在指定几何错误,False表示不存在指定几何错误</returns>
        public static bool Check(this IGeometry geometry, out esriNonSimpleReasonEnum eNonSimpleReason)
        {
            ITopologicalOperator3 topologicalOperator = (ITopologicalOperator3)geometry;

            topologicalOperator.IsKnownSimple_2 = false;//布尔型,指示此几何图形是否是已知的(或假设)是拓扑正确。这里赋值false,就是非已知的几何图形

            eNonSimpleReason = esriNonSimpleReasonEnum.esriNonSimpleOK;
            if (!topologicalOperator.get_IsSimpleEx(out var reason))//返回布尔值,指示该几何图形是否为简单的。如果返回的是false,则可以对输出的"reason"参数检查审查
            {
                eNonSimpleReason = reason;
            }

            return(eNonSimpleReason != esriNonSimpleReasonEnum.esriNonSimpleOK);
        }
Exemplo n.º 4
0
 public bool get_IsSimpleGeometry(IGeometry geometry,
                                  out esriNonSimpleReasonEnum reason)
 {
     return(((IFeatureSimplify2)_feature).get_IsSimpleGeometry(geometry, out reason));
 }