Example #1
0
        private bool updatePolygon(IFeatureClass ftrCls, int oid)
        {
            bool           x     = false;
            IGeometry      geo   = ftrCls.GetFeature(oid).ShapeCopy;
            ISpatialFilter spFlt = new SpatialFilterClass();

            spFlt.WhereClause = ftrCls.OIDFieldName + " <> " + oid.ToString();
            spFlt.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
            IQueryFilterDefinition2 qryDef2 = (IQueryFilterDefinition2)spFlt;

            qryDef2.PostfixClause = "Order by Shape_Area DESC";
            spFlt.Geometry        = geo;
            spFlt.GeometryField   = ftrCls.ShapeFieldName;
            spFlt.SearchOrder     = esriSearchOrder.esriSearchOrderSpatial;
            IFeatureCursor ftrCur         = ftrCls.Search(spFlt, false);
            int            shapeAreaIndex = ftrCur.FindField("Shape_Area");
            IFeature       ftr            = ftrCur.NextFeature();

            while (ftr != null)
            {
                IGeometry             geoMax    = ftr.ShapeCopy;
                int                   beforeCnt = ((IGeometryCollection)geoMax).GeometryCount;
                ITopologicalOperator4 tp        = (ITopologicalOperator4)geoMax;
                IGeometry             uGeo      = tp.Union(geo);
                int                   afterCnt  = ((IGeometryCollection)uGeo).GeometryCount;
                if (beforeCnt >= afterCnt)
                {
                    try
                    {
                        ftr.Shape = uGeo;
                        if (shapeAreaEdit)
                        {
                            ftr.set_Value(shapeAreaIndex, ((IArea)uGeo).Area);
                        }
                        ftr.Store();
                        x = true;
                        return(x);
                    }
                    catch (Exception e)
                    {
                        x = false;
                        Console.WriteLine(e.ToString());
                        return(x);
                    }
                }
                ftr = ftrCur.NextFeature();
            }
            return(x);
        }
Example #2
0
        public static IFeature Union(List <IFeature> list_0)
        {
            ITopologicalOperator4 shapeCopy = null;
            IGeometry             geometry  = null;
            List <IFeature>       features  = new List <IFeature>();

            foreach (IFeature list0 in list_0)
            {
                features.Add(ZDEditTools.WriteHistory(list0));
                if (shapeCopy != null)
                {
                    geometry  = shapeCopy.Union(list0.ShapeCopy);
                    shapeCopy = geometry as ITopologicalOperator4;
                }
                else
                {
                    shapeCopy = list0.ShapeCopy as ITopologicalOperator4;
                }
            }
            IFeature feature = ZDEditTools.ZDFeatureClass.CreateFeature();

            feature.Shape = geometry;
            RowOperator.CopyFeatureAttributeToFeature(list_0[0], feature);
            feature.Store();
            (ZDEditTools.ZDFeatureClass as IDataset).Name.Split(new char[] { '.' });
            ZDHistoryTable zDHistoryTable = new ZDHistoryTable();

            ZDEditTools.StartEditDateTime = DateTime.Now;
            int num = 0;

            foreach (IFeature list01 in list_0)
            {
                int num1 = num;
                num = num1 + 1;
                ZDEditTools.WriteHistoryLine(list01, feature, features[num1], 1, ZDEditTools.StartEditDateTime);
                list01.Delete();
            }
            ZDEditTools.Oids.Add(feature.OID);
            return(feature);
        }
Example #3
0
        public static IFeature Union(System.Collections.Generic.List <IFeature> list_0)
        {
            ITopologicalOperator4 topologicalOperator = null;
            IGeometry             geometry            = null;

            System.Collections.Generic.List <IFeature> list = new System.Collections.Generic.List <IFeature>();
            foreach (IFeature current in list_0)
            {
                list.Add(ZDEditTools.WriteHistory(current));
                if (topologicalOperator == null)
                {
                    topologicalOperator = (current.ShapeCopy as ITopologicalOperator4);
                }
                else
                {
                    geometry            = topologicalOperator.Union(current.ShapeCopy);
                    topologicalOperator = (geometry as ITopologicalOperator4);
                }
            }
            IFeature feature = ZDEditTools.ZDFeatureClass.CreateFeature();

            feature.Shape = geometry;
            RowOperator.CopyFeatureAttributeToFeature(list_0[0], feature);
            feature.Store();
            (ZDEditTools.ZDFeatureClass as IDataset).Name.Split(new char[]
            {
                '.'
            });
            new ZDHistoryTable();
            ZDEditTools.StartEditDateTime = System.DateTime.Now;
            int num = 0;

            foreach (IFeature current in list_0)
            {
                ZDEditTools.WriteHistoryLine(current, feature, list[num++], 1, ZDEditTools.StartEditDateTime);
                current.Delete();
            }
            ZDEditTools.Oids.Add(feature.OID);
            return(feature);
        }