예제 #1
0
        /// <summary>
        /// 实现对要素类的坐标的仿射变换
        /// </summary>
        /// <param name="inFC">要素类</param>
        /// <param name="inTransformation">转换类</param>
        private void coordTransfermation(IFeatureClass inFC, ITransformation inTransformation)
        {
            IFeatureCursor pFCursor = inFC.Update(null, false);
            IFeature       pFeature = pFCursor.NextFeature();

            while (pFeature != null)
            {
                IGeometry    shpTransformed = pFeature.ShapeCopy;
                ITransform2D pTransform2D   = shpTransformed as ITransform2D;
                pTransform2D.Transform(esriTransformDirection.esriTransformForward, inTransformation);
                pFeature.Shape = shpTransformed;
                //int id = inFC.FindField("LAYER_OID");
                //if((inFC as IDataset).Name=="宗地_Project54_1")
                //pFeature.set_Value(id,"1");

                pFCursor.UpdateFeature(pFeature);
                //cursor后移
                pFeature = pFCursor.NextFeature();
            }
            Marshal.ReleaseComObject(pFCursor);//释放cursor
            ISpatialReference     unKnownSR = new UnknownCoordinateSystemClass();
            IGeoDatasetSchemaEdit pGDSE     = inFC as IGeoDatasetSchemaEdit;

            if (pGDSE.CanAlterSpatialReference)
            {
                pGDSE.AlterSpatialReference(unKnownSR);//更新要素类的投影
            }
            IFeatureClassManage pFCM = inFC as IFeatureClassManage;

            pFCM.UpdateExtent();//更新要素类的最值范围
            IGeoDataset pGD = inFC as IGeoDataset;
            IEnvelope   ppp = pGD.Extent;
        }
예제 #2
0
        public static bool UpdateExtent(IFeatureClass fc)
        {
            bool        rbc        = false;
            ISchemaLock schemaLock = (ISchemaLock)fc;

            try
            {
                IFeatureClassManage fcManage = (IFeatureClassManage)fc;
                if (fcManage != null)
                {
                    //schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
                    fcManage.UpdateExtent();
                    schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
                    //Console.WriteLine("Update finished");
                    rbc = true;
                }
            }
            catch (Exception e)
            {
                //error occured
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
                //Console.WriteLine(e.Message);
                Log.WriteLine(e);
            }
            return(rbc);
        }
예제 #3
0
        private void objectLoaderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Stopwatch myWatch = Stopwatch.StartNew();

            IObjectLoader objectLoader       = new ObjectLoaderClass();
            IFeatureClass sourceFeatureClass = getFeatureClass("esriDataSourcesGDB.FileGDBWorkspaceFactory", fileGDBPath, sourceFCName);
            IFeatureClass targetFeatureClass = getFeatureClass("esriDataSourcesGDB.SdeWorkspaceFactory", sdePath, targetFCName);

            string sInFieldList = targetFeatureClass.Fields.get_Field(0).Name;

            for (int i = 1; i < targetFeatureClass.Fields.FieldCount; i++)
            {
                sInFieldList = sInFieldList + "," + targetFeatureClass.Fields.get_Field(i).Name;
            }

            IQueryFilter queryFilter = new QueryFilterClass();

            queryFilter.WhereClause = queryClause;
            queryFilter.SubFields   = sInFieldList;

            IEnumInvalidObject invalidObject;

            objectLoader.LoadObjects(null, sourceFeatureClass as ITable, queryFilter, targetFeatureClass as ITable, targetFeatureClass.Fields, false, 0, false, false, 1000, out invalidObject);
            IFeatureClassManage targetFeatureClassManage = targetFeatureClass as IFeatureClassManage;

            targetFeatureClassManage.UpdateExtent();

            myWatch.Stop();
            string time = myWatch.Elapsed.TotalSeconds.ToString();

            MessageBox.Show(time + " Seconds");
        }
        public void SupplyResource(RefugeeSite site)
        {
            do
            {
                IFeatureClass facilityClass  = _repositoryCol.FeatureClass;
                IQueryFilter  facilityFilter = _repositoryCol.ValidFilter();

                if (facilityClass.FeatureCount(facilityFilter) == 0)
                {
                    LogHelper.Error("没有足够的" + site.ResourceName());
                    break;
                }
                _roadNetwork.SetFacilities(facilityClass, facilityFilter);

                IQueryFilter  siteFilter = _refugeSiteCol.SiteFilter(site);
                IFeatureClass siteClass  = _refugeSiteCol.FeatureClass;
                _roadNetwork.SetIncidents(siteClass, siteFilter);

                SupplyRoute route = _roadNetwork.FindRoute();
                if (route == null)
                {
                    LogHelper.Error("剩余的" + site.ResourceName() + "因为路径不通无法配送");
                    break;
                }
                Repository repo   = _repositoryCol.FindRepoByID(route.RepoID);
                int        amount = 0;
                if (repo.Remain >= site.ResourceInNeed)
                {
                    amount = site.ResourceInNeed;
                }
                else
                {
                    amount = repo.Remain;
                }

                _repositoryCol.SupplyResource(repo, amount);
                site.ReplenishResource(amount);
                //_refugeSiteCol.ReplenishResource(site, amount);

                route.SetMessagePara(site.ResourceName(), amount, site.ResourceUnit());
                route.IncidentID = site.OID;

                AddRouteFeature(route);
                _siteRoutes.Add(route);
            }while (site.ResourceInNeed > 0);

            IFeatureClassManage manage = this._outputFC as IFeatureClassManage;

            manage.UpdateExtent();
        }
예제 #5
0
        public void InsertFeaturesUsingCursor(IFeatureClass sourceFeatureClass, IFeatureClass targetFeatureClass)
        {
            using (ComReleaser comReleaser = new ComReleaser())
            {
                // Create a feature buffer.
                IFeatureBuffer featureBuffer = targetFeatureClass.CreateFeatureBuffer();
                comReleaser.ManageLifetime(featureBuffer);

                // Create an insert cursor.
                IFeatureCursor insertCursor = targetFeatureClass.Insert(true);
                comReleaser.ManageLifetime(insertCursor);

                IQueryFilter queryFilter = new QueryFilterClass();
                queryFilter.WhereClause = queryClause;
                IFeatureCursor cursor = sourceFeatureClass.Search(queryFilter, true);

                IFeature sourceFeature = cursor.NextFeature();

                while (sourceFeature != null)
                {
                    //如果是线或面要素类需要执行下Simplify,这里用的点要素类,不做验证了
                    featureBuffer.Shape = sourceFeature.ShapeCopy;

                    for (int i = 0; i < sourceFeature.Fields.FieldCount; i++)
                    {
                        IField field = sourceFeature.Fields.get_Field(i);
                        if (field.Type != esriFieldType.esriFieldTypeOID && field.Type != esriFieldType.esriFieldTypeGeometry && field.Type != esriFieldType.esriFieldTypeGlobalID && field.Type != esriFieldType.esriFieldTypeGUID)
                        {
                            string fieldName = field.Name;
                            int    index     = featureBuffer.Fields.FindField(fieldName);
                            if (index > -1 && fieldName != "Shape_Length" && fieldName != "Shape_Area")
                            {
                                featureBuffer.set_Value(index, sourceFeature.get_Value(i));
                            }
                        }
                    }
                    insertCursor.InsertFeature(featureBuffer);
                    sourceFeature = cursor.NextFeature();
                }

                // Flush the buffer to the geodatabase.
                insertCursor.Flush();
                ComReleaser.ReleaseCOMObject(cursor);
            }
            IFeatureClassManage targetFeatureClassManage = targetFeatureClass as IFeatureClassManage;

            targetFeatureClassManage.UpdateExtent();
        }
        /// <summary>
        /// 构造小区的一个网格
        /// </summary>
        /// <param name="cellName"></param>
        /// <param name="gxid"></param>
        /// <param name="gyid"></param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="recePower"></param>
        /// <param name="pathLoss"></param>
        public void constructGrid(string cellName, int enodeb, int ci, int gxid, int gyid, double x1, double y1, double x2, double y2, double recePower, double pathLoss)
        {
            IDataset       dataset       = (IDataset)pFeatureLayer.FeatureClass;
            IWorkspace     workspace     = dataset.Workspace;
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true);
            IFeatureBuffer pFeatureBuffer;

            IPoint pointA = GeometryUtilities.ConstructPoint2D(x1, y1);
            IPoint pointB = GeometryUtilities.ConstructPoint2D(x2, y1);
            IPoint pointC = GeometryUtilities.ConstructPoint2D(x2, y2);
            IPoint pointD = GeometryUtilities.ConstructPoint2D(x1, y2);

            IGeometryCollection pGeometryColl = GeometryUtilities.ConstructPolygon(new IPoint[] { pointA, pointB, pointC, pointD });

            pFeatureBuffer       = pFeatureClass.CreateFeatureBuffer();
            pFeatureBuffer.Shape = pGeometryColl as IGeometry;
            pFeatureBuffer.set_Value(this.GXIDIndex, gxid);
            pFeatureBuffer.set_Value(this.GYIDIndex, gyid);
            pFeatureBuffer.set_Value(this.eNodeBIndex, enodeb);
            pFeatureBuffer.set_Value(this.CIIndex, ci);
            pFeatureBuffer.set_Value(this.cellNameIndex, cellName);
            pFeatureBuffer.set_Value(this.RecePowerIndex, recePower);
            pFeatureBuffer.set_Value(this.PathLossIndex, pathLoss);
            pFeatureCursor.InsertFeature(pFeatureBuffer);

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;

            pFeatureClassManage.UpdateExtent();

            //GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            //GISMapApplication.Instance.FullExtent(pFeatureLayer.AreaOfInterest);
        }
예제 #7
0
        public void featureClassWrite(IFeatureClass sourceFeatureClass, IFeatureClass targetFeatureClass)
        {
            IQueryFilter queryFilter = new QueryFilterClass();

            queryFilter.WhereClause = queryClause;
            IFeatureCursor     cursor            = sourceFeatureClass.Search(queryFilter, true);
            IFeature           sourceFeature     = cursor.NextFeature();
            IFeatureClassWrite featureClassWrite = targetFeatureClass as IFeatureClassWrite;
            ISet setAdd = new SetClass();

            while (sourceFeature != null)
            {
                IFeature targetFeature = targetFeatureClass.CreateFeature();

                //如果是线或面要素类需要执行下Simplify,这里用的点要素类,不做验证了
                targetFeature.Shape = sourceFeature.ShapeCopy;

                for (int i = 0; i < sourceFeature.Fields.FieldCount; i++)
                {
                    IField field = sourceFeature.Fields.get_Field(i);
                    if (field.Type != esriFieldType.esriFieldTypeOID && field.Type != esriFieldType.esriFieldTypeGeometry && field.Type != esriFieldType.esriFieldTypeGlobalID && field.Type != esriFieldType.esriFieldTypeGUID)
                    {
                        string fieldName = field.Name;
                        int    index     = targetFeature.Fields.FindField(fieldName);
                        if (index > -1 && fieldName != "Shape_Length" && fieldName != "Shape_Area")
                        {
                            targetFeature.set_Value(index, sourceFeature.get_Value(i));
                        }
                    }
                }
                //setAdd.Add(targetFeature);
                featureClassWrite.WriteFeature(targetFeature);
                sourceFeature = cursor.NextFeature();
            }
            //featureClassWrite.WriteFeatures(setAdd);//与WriteFeature没啥效率上的区别
            ComReleaser.ReleaseCOMObject(cursor);

            IFeatureClassManage targetFeatureClassManage = targetFeatureClass as IFeatureClassManage;

            targetFeatureClassManage.UpdateExtent();
        }
        /// <summary>
        /// 平滑后的建筑物底边
        /// </summary>
        public bool constuctBuildingVertex()
        {
            DataTable gridTable = IbatisHelper.ExecuteQueryForDataTable("GetAllBuildingVertex", null);

            if (gridTable.Rows.Count < 1)
            {
                return(false);
            }

            IDataset       dataset       = (IDataset)pFeatureLayer.FeatureClass;
            IWorkspace     workspace     = dataset.Workspace;
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true);
            IFeatureBuffer pFeatureBuffer;

            List <IPoint> pts = new List <IPoint>();

            int    id     = Convert.ToInt32(gridTable.Rows[0]["BuildingID"]);
            float  x      = (float)Convert.ToDouble(gridTable.Rows[0]["VertexX"].ToString());
            float  y      = (float)Convert.ToDouble(gridTable.Rows[0]["VertexY"].ToString());
            IPoint pointA = GeometryUtilities.ConstructPoint3D(x, y, 0);

            pts.Add(pointA);

            int lastid = id;

            //循环添加
            for (int i = 1; i < gridTable.Rows.Count; i++)
            {
                DataRow dataRow = gridTable.Rows[i];

                id = Convert.ToInt32(dataRow["BuildingID"]);
                if (!(float.TryParse(dataRow["VertexX"].ToString(), out x) && float.TryParse(dataRow["VertexY"].ToString(), out y)))
                {
                    continue;
                }

                if (i == gridTable.Rows.Count - 1 || id != lastid)
                {
                    IGeometryCollection pGeometryColl = GeometryUtilities.ConstructMultiPath(pts);
                    pFeatureBuffer       = pFeatureClass.CreateFeatureBuffer();
                    pFeatureBuffer.Shape = pGeometryColl as IGeometry;
                    pFeatureCursor.InsertFeature(pFeatureBuffer);

                    lastid = id;
                    pts.Clear();
                }

                pointA = GeometryUtilities.ConstructPoint3D(x, y, 0);
                pts.Add(pointA);
            }

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;

            pFeatureClassManage.UpdateExtent();
            //GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            return(true);
        }
예제 #9
0
        /// <summary>
        /// 构造 TIN
        /// </summary>
        public bool constuctTIN1()
        {
            double minX = 0, minY = 0, maxX = 0, maxY = 0;

            InternalInterference.Grid.GridHelper.getInstance().getMinXY(ref minX, ref minY);
            InternalInterference.Grid.GridHelper.getInstance().getMaxXY(ref maxX, ref maxY);

            Hashtable ht = new Hashtable();

            ht["minX"] = minX;
            ht["maxX"] = maxX;
            ht["minY"] = minY;
            ht["maxY"] = maxY;
            DataTable gridTable = IbatisHelper.ExecuteQueryForDataTable("GetTINVertexByArea", ht);

            if (gridTable.Rows.Count < 1)
            {
                return(false);
            }

            IDataset       dataset       = (IDataset)pFeatureLayer.FeatureClass;
            IWorkspace     workspace     = dataset.Workspace;
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true);
            IFeatureBuffer pFeatureBuffer;

            float         x, y, z;
            List <IPoint> pts = new List <IPoint>();
            //循环添加
            int cnt = 0;
            //初始化进度信息
            LoadInfo loadInfo = new LoadInfo();

            loadInfo.count = gridTable.Rows.Count;
            loadInfo.loadCreate();
            //循环添加
            foreach (DataRow dataRow in gridTable.Rows)
            {
                if (cnt++ % 1000 == 0)
                {
                    loadInfo.cnt = cnt;
                    loadInfo.loadUpdate();
                    Console.WriteLine("已计算  " + cnt + "/" + gridTable.Rows.Count);
                }
                if (!(float.TryParse(dataRow["VertexX"].ToString(), out x) && float.TryParse(dataRow["VertexY"].ToString(), out y) && float.TryParse(dataRow["VertexHeight"].ToString(), out z)))
                {
                    continue;
                }

                IPoint pointA = GeometryUtilities.ConstructPoint3D(x, y, z);
                pts.Add(pointA);

                if (pts.Count >= 3)
                {
                    IGeometryCollection pGeometryColl = GeometryUtilities.ConstructMultiPath(pts);
                    pFeatureBuffer       = pFeatureClass.CreateFeatureBuffer();
                    pFeatureBuffer.Shape = pGeometryColl as IGeometry;
                    pFeatureCursor.InsertFeature(pFeatureBuffer);

                    pts.Clear();
                }
            }

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;

            pFeatureClassManage.UpdateExtent();

            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureClassManage);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(dataset);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(workspace);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);

            //更新完成进度信息
            loadInfo.cnt = cnt;
            loadInfo.loadUpdate();
            //GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            return(true);
        }
        /// <summary>
        /// 区域覆盖
        /// </summary>
        /// <param name="mingxid"></param>
        /// <param name="mingyid"></param>
        /// <param name="maxgxid"></param>
        /// <param name="maxgyid"></param>
        public bool constuctAreaGrids(int mingxid, int mingyid, int maxgxid, int maxgyid, string layerName)
        {
            DataTable gridTable = new DataTable();
            Hashtable ht        = new Hashtable();

            ht["MinGXID"] = mingxid;
            ht["MaxGXID"] = maxgxid;
            ht["MinGYID"] = mingyid;
            ht["MaxGYID"] = maxgyid;
            gridTable     = IbatisHelper.ExecuteQueryForDataTable("GetSpecifiedAreaGrids", ht);
            if (gridTable.Rows.Count < 1)
            {
                return(false);
            }

            /*
             *<select id="GetSpecifiedAreaGrids" parameterClass="Hashtable">
             *          select a.GXID, a.GYID, a.eNodeB, a.CI, d.MinLong, d.MinLat, d.MaxLong, d.MaxLat, a.ReceivedPowerdbm, a.PathLoss from tbGridPathloss a ,
             *          (select c.GXID, c.GYID, c.eNodeB, c.CI, max(c.ReceivedPowerdbm) ReceivedPowerdbm from tbGridPathloss c where c.GXID between '$MinGXID$' and '$MaxGXID$' and c.GYID between '$MinGYID$' and '$MaxGYID$'  group by c.gxid, c.gyid, c.eNodeB, c.ci having max(c.ReceivedPowerdbm) > -130 ) b,
             *          tbGridDem d
             *          where a.gxid = b.gxid and a.gyid = b.gyid and a.eNodeB = b.eNodeB and a.ci = b.ci and a.gxid = d.gxid and a.gyid = d.gyid
             *      </select>
             */
            IFeatureWorkspace featureWorkspace = MapWorkSpace.getWorkSpace();
            IFeatureClass     fclass           = featureWorkspace.OpenFeatureClass(layerName);

            //IFeatureLayer flayer = new FeatureLayer();
            pFeatureLayer.FeatureClass = pFeatureClass;

            //IFeatureLayer flayer = GISMapApplication.Instance.GetLayer(LayerNames.AreaCoverGrids) as IFeatureLayer;
            //FeatureUtilities.DeleteFeatureLayerFeatrues(flayer);

            //IFeatureClass fclass = flayer.FeatureClass;

            IDataset   dataset   = (IDataset)fclass;
            IWorkspace workspace = dataset.Workspace;
            //Cast for an IWorkspaceEdit
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            //start an edit session and operation
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = fclass.Insert(true);
            IFeatureBuffer pFeatureBuffer;

            //int gxid, gyid, lac, ci;
            //float x1, y1, x2, y2;
            //float recePower, pathLoss;
            int    lac, ci, gxid, gyid, level;
            double x1, y1, x2, y2, z;
            double recePower, pathLoss;
            double gbaseheight = GridHelper.getInstance().getGBaseHeight();
            double gheight     = GridHelper.getInstance().getGHeight();

            //循环添加
            int cnt = 0;

            //循环添加
            foreach (DataRow dataRow in gridTable.Rows)
            {
                if (cnt++ % 1000 == 0)
                {
                    Console.WriteLine("已计算  " + cnt + "/" + gridTable.Rows.Count);
                }
                gxid  = int.Parse(dataRow["GXID"].ToString());
                gyid  = int.Parse(dataRow["GYID"].ToString());
                level = int.Parse(dataRow["Level"].ToString());
                Geometric.Point p   = GridHelper.getInstance().GridToGeo(gxid, gyid);
                double          lon = p.X;
                double          lat = p.Y;
                //lac = int.Parse(dataRow["eNodeB"].ToString());
                //ci = int.Parse(dataRow["CI"].ToString());
                recePower = double.Parse(dataRow["ReceivedPowerdbm"].ToString());
                pathLoss  = double.Parse(dataRow["PathLoss"].ToString());

                if (!(double.TryParse(dataRow["MinX"].ToString(), out x1) &&
                      double.TryParse(dataRow["MinY"].ToString(), out y1) &&
                      double.TryParse(dataRow["MaxX"].ToString(), out x2) &&
                      double.TryParse(dataRow["MaxY"].ToString(), out y2)))
                {
                    continue;
                }

                z = gheight * (level - 1) + gbaseheight;

                IPoint pointA = GeometryUtilities.ConstructPoint3D(x1, y1, z);
                IPoint pointB = GeometryUtilities.ConstructPoint3D(x2, y1, z);
                IPoint pointC = GeometryUtilities.ConstructPoint3D(x2, y2, z);
                IPoint pointD = GeometryUtilities.ConstructPoint3D(x1, y2, z);

                IGeometryCollection pGeometryColl = GeometryUtilities.ConstructPolygon(new IPoint[] { pointA, pointB, pointC, pointD });
                GeometryUtilities.MakeZAware(pGeometryColl as IGeometry);

                pFeatureBuffer       = pFeatureClass.CreateFeatureBuffer();
                pFeatureBuffer.Shape = pGeometryColl as IGeometry;
                pFeatureBuffer.set_Value(this.GXIDIndex, gxid);
                pFeatureBuffer.set_Value(this.GYIDIndex, gyid);
                pFeatureBuffer.set_Value(this.eNodeBIndex, 0);
                pFeatureBuffer.set_Value(this.CIIndex, 0);
                pFeatureBuffer.set_Value(this.cellNameIndex, "");
                pFeatureBuffer.set_Value(this.LongitudeIndex, lon);
                pFeatureBuffer.set_Value(this.LatitudeIndex, lat);
                pFeatureBuffer.set_Value(this.LevelIndex, level);
                if (recePower > -41)
                {
                    pFeatureBuffer.set_Value(this.RecePowerIndex, -41);
                }
                //else if(recePower < -110)
                //    pFeatureBuffer.set_Value(this.RecePowerIndex, -110);
                else
                {
                    pFeatureBuffer.set_Value(this.RecePowerIndex, recePower);
                }
                pFeatureBuffer.set_Value(this.PathLossIndex, pathLoss);
                pFeatureCursor.InsertFeature(pFeatureBuffer);
            }

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;

            pFeatureClassManage.UpdateExtent();

            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureClassManage);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(dataset);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(workspace);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);

            //GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            return(true);
        }
        /// <summary>
        /// 构造小区覆盖网格
        /// </summary>
        /// <param name="cellname"></param>
        /// <param name="enodeb"></param>
        /// <param name="ci"></param>
        public bool constuctCellGrids(string cellname, int enodeb, int ci)
        {
            DataTable gridTable = new DataTable();
            Hashtable ht        = new Hashtable();

            ht["eNodeB"] = enodeb;
            ht["CI"]     = ci;
            gridTable    = IbatisHelper.ExecuteQueryForDataTable("GetSpecifiedCellGrids", ht);
            if (gridTable.Rows.Count < 1)
            {
                return(false);
            }

            IDataset       dataset       = (IDataset)pFeatureLayer.FeatureClass;
            IWorkspace     workspace     = dataset.Workspace;
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true);
            IFeatureBuffer pFeatureBuffer;

            int    gxid, gyid, level;
            double x1, y1, x2, y2, z;
            double recePower, pathLoss;
            double gheight = GridHelper.getInstance().getGHeight();
            //循环添加
            int cnt = 0;
            //初始化进度信息
            LoadInfo loadInfo = new LoadInfo();

            loadInfo.count = gridTable.Rows.Count;
            loadInfo.loadCreate();

            foreach (DataRow dataRow in gridTable.Rows)
            {
                if (cnt++ % 1000 == 0)
                {
                    loadInfo.cnt = cnt;
                    loadInfo.loadUpdate();
                    Console.WriteLine("已计算  " + cnt + "/" + gridTable.Rows.Count);
                }
                gxid  = int.Parse(dataRow["Gxid"].ToString());
                gyid  = int.Parse(dataRow["Gyid"].ToString());
                level = int.Parse(dataRow["Level"].ToString());

                Geometric.Point p   = GridHelper.getInstance().GridToGeo(gxid, gyid);
                double          lon = p.X;
                double          lat = p.Y;

                //if (!(float.TryParse(dataRow["MinX"].ToString(), out x1) && float.TryParse(dataRow["MinY"].ToString(), out y1) && float.TryParse(dataRow["MaxX"].ToString(), out x2) && float.TryParse(dataRow["MaxY"].ToString(), out y2) && float.TryParse(dataRow["ReceivedPowerdbm"].ToString(), out recePower) && float.TryParse(dataRow["PathLoss"].ToString(), out pathLoss)))
                //    continue;

                if (!(double.TryParse(dataRow["MinX"].ToString(), out x1) && double.TryParse(dataRow["MinY"].ToString(), out y1)))
                {
                    continue;
                }
                if (!(double.TryParse(dataRow["MaxX"].ToString(), out x2) && double.TryParse(dataRow["MaxY"].ToString(), out y2)))
                {
                    continue;
                }
                if (!(double.TryParse(dataRow["ReceivedPowerdbm"].ToString(), out recePower) && double.TryParse(dataRow["PathLoss"].ToString(), out pathLoss)))
                {
                    continue;
                }
                z = gheight * level;

                IPoint pointA = GeometryUtilities.ConstructPoint3D(x1, y1, z);
                IPoint pointB = GeometryUtilities.ConstructPoint3D(x2, y1, z);
                IPoint pointC = GeometryUtilities.ConstructPoint3D(x2, y2, z);
                IPoint pointD = GeometryUtilities.ConstructPoint3D(x1, y2, z);

                IGeometryCollection pGeometryColl = GeometryUtilities.ConstructPolygon(new IPoint[] { pointA, pointB, pointC, pointD });
                GeometryUtilities.MakeZAware(pGeometryColl as IGeometry);

                pFeatureBuffer       = pFeatureClass.CreateFeatureBuffer();
                pFeatureBuffer.Shape = pGeometryColl as IGeometry;
                pFeatureBuffer.set_Value(this.GXIDIndex, gxid);
                pFeatureBuffer.set_Value(this.GYIDIndex, gyid);
                pFeatureBuffer.set_Value(this.eNodeBIndex, enodeb);
                pFeatureBuffer.set_Value(this.CIIndex, ci);
                pFeatureBuffer.set_Value(this.cellNameIndex, cellname);
                pFeatureBuffer.set_Value(this.LevelIndex, level);
                pFeatureBuffer.set_Value(this.LongitudeIndex, lon);
                pFeatureBuffer.set_Value(this.LatitudeIndex, lat);


                if (recePower > -41)
                {
                    pFeatureBuffer.set_Value(this.RecePowerIndex, -41);
                }
                //else if(recePower < -110)
                //    pFeatureBuffer.set_Value(this.RecePowerIndex, -110);
                else
                {
                    pFeatureBuffer.set_Value(this.RecePowerIndex, recePower);
                }
                pFeatureBuffer.set_Value(this.PathLossIndex, pathLoss);
                pFeatureCursor.InsertFeature(pFeatureBuffer);

                //释放AO对象
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureBuffer);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pGeometryColl);
            }

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;

            pFeatureClassManage.UpdateExtent();

            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureClassManage);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(dataset);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(workspace);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);

            //更新完成进度信息
            loadInfo.cnt = cnt;
            loadInfo.loadUpdate();
            //GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            return(true);
        }
예제 #12
0
        /// <summary>
        /// 刷新GSM1800小区图层
        /// </summary>
        public void RefreshGSM1800Cell()
        {
            IList <CELL> GSM1800CellData = IbatisHelper.ExecuteQueryForList <CELL>("GetGSM1800CellLayerData", null);

            IFeatureLayer pFeatureLayer = GISMapApplication.Instance.GetLayer(LayerNames.GSM1800Cell) as IFeatureLayer;

            FeatureUtilities.DeleteFeatureLayerFeatrues(pFeatureLayer);

            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;


            IDataset   dataset   = (IDataset)pFeatureClass;
            IWorkspace workspace = dataset.Workspace;
            //Cast for an IWorkspaceEdit
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            //start an edit session and operation
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true);
            IFeatureBuffer pFeatureBuffer;

            //循环添加
            double circRadius = 0.00025;//小区1800生成的半径大小
            double every      = 1;


            foreach (CELL gsm1800Cell in GSM1800CellData)
            {
                if ((!gsm1800Cell.Longitude.HasValue) || (!gsm1800Cell.Latitude.HasValue) || (!gsm1800Cell.AntHeight.HasValue) || (!gsm1800Cell.Azimuth.HasValue) || (!gsm1800Cell.Tilt.HasValue))
                {
                    continue;
                }

                int    lac         = gsm1800Cell.eNodeB.Value;
                int    ci          = gsm1800Cell.CI.Value;
                string cellName    = gsm1800Cell.CellName;
                string cellNameChs = gsm1800Cell.CellNameChs;
                double longitude   = Convert.ToDouble(gsm1800Cell.Longitude.Value);
                double latitude    = Convert.ToDouble(gsm1800Cell.Latitude.Value);
                double antHeight   = Convert.ToDouble(gsm1800Cell.AntHeight.Value);
                double azimuth     = gsm1800Cell.Azimuth.Value;
                double tilt        = gsm1800Cell.Tilt.Value;
                tilt = tilt > 0 ? tilt : 7;

                pFeatureBuffer = pFeatureClass.CreateFeatureBuffer();//创建图元缓冲

                double Direction = (450 - azimuth) % 360;

                IPoint startPoint = GeometryUtilities.ConstructPoint3D(longitude, latitude, antHeight);
                IPoint leftPoint  = GeometryUtilities.ConstructPoint3D(circRadius * Math.Cos((Direction - 18 * every) * Math.PI / 180) + longitude, latitude + circRadius * Math.Sin((Direction - 18 * every) * Math.PI / 180), antHeight);
                IPoint rightPoint = GeometryUtilities.ConstructPoint3D(circRadius * Math.Cos((Direction + 18 * every) * Math.PI / 180) + longitude, latitude + circRadius * Math.Sin((Direction + 9 * every) * Math.PI / 180), antHeight);

                //startPoint = PointConvert.Instance.GetProjectPoint(startPoint);
                //startPoint = GeometryUtilities.ConstructPoint3D(startPoint, antHeight);//增加高度
                //leftPoint = PointConvert.Instance.GetProjectPoint(leftPoint);
                //leftPoint = GeometryUtilities.ConstructPoint3D(leftPoint, antHeight);//增加高度
                //rightPoint = PointConvert.Instance.GetProjectPoint(rightPoint);
                //rightPoint = GeometryUtilities.ConstructPoint3D(rightPoint, antHeight);//增加高度

                IGeometryCollection pGeometryColl = GeometryUtilities.ConstructPolygon(new IPoint[] { startPoint, leftPoint, rightPoint });
                GeometryUtilities.MakeZAware(pGeometryColl as IGeometry);

                pFeatureBuffer.Shape = pGeometryColl as IGeometry;
                pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("eNodeB"), lac);
                pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("CI"), ci);
                pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("CellName"), cellName);
                pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("CellNameCN"), cellNameChs);
                pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("Longitude"), longitude);
                pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("Latitude"), latitude);
                pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("AntHeight"), antHeight);
                pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("Azimuth"), azimuth);
                pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("Tilt"), tilt);
                pFeatureCursor.InsertFeature(pFeatureBuffer);
            }

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;

            pFeatureClassManage.UpdateExtent();
            //GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
        }
예제 #13
0
        public void LoadOnlyModeInsert(IFeatureClass sourceFeatureClass, IFeatureClass targetFeatureClass)
        {
            // Cast the feature class to the IFeatureClassLoad interface.
            IFeatureClassLoad featureClassLoad = (IFeatureClassLoad)targetFeatureClass;

            // Acquire an exclusive schema lock for the class.
            ISchemaLock schemaLock = (ISchemaLock)targetFeatureClass;

            try
            {
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);

                // Enable load-only mode on the feature class.
                featureClassLoad.LoadOnlyMode = true;
                using (ComReleaser comReleaser = new ComReleaser())
                {
                    // Create the feature buffer.
                    IFeatureBuffer featureBuffer = targetFeatureClass.CreateFeatureBuffer();
                    comReleaser.ManageLifetime(featureBuffer);

                    // Create an insert cursor.
                    IFeatureCursor insertCursor = targetFeatureClass.Insert(true);
                    comReleaser.ManageLifetime(insertCursor);

                    IQueryFilter queryFilter = new QueryFilterClass();
                    queryFilter.WhereClause = queryClause;
                    IFeatureCursor cursor = sourceFeatureClass.Search(queryFilter, true);

                    IFeature sourceFeature = cursor.NextFeature();

                    while (sourceFeature != null)
                    {
                        //如果是线或面要素类需要执行下Simplify,这里用的点要素类,不做验证了
                        featureBuffer.Shape = sourceFeature.ShapeCopy;

                        for (int i = 0; i < sourceFeature.Fields.FieldCount; i++)
                        {
                            IField field = sourceFeature.Fields.get_Field(i);
                            if (field.Type != esriFieldType.esriFieldTypeOID && field.Type != esriFieldType.esriFieldTypeGeometry && field.Type != esriFieldType.esriFieldTypeGlobalID && field.Type != esriFieldType.esriFieldTypeGUID)
                            {
                                string fieldName = field.Name;
                                int    index     = featureBuffer.Fields.FindField(fieldName);
                                if (index > -1 && fieldName != "Shape_Length" && fieldName != "Shape_Area")
                                {
                                    featureBuffer.set_Value(index, sourceFeature.get_Value(i));
                                }
                            }
                        }
                        insertCursor.InsertFeature(featureBuffer);
                        sourceFeature = cursor.NextFeature();
                    }

                    // Flush the buffer to the geodatabase.
                    insertCursor.Flush();
                    ComReleaser.ReleaseCOMObject(cursor);
                    IFeatureClassManage targetFeatureClassManage = targetFeatureClass as IFeatureClassManage;
                    targetFeatureClassManage.UpdateExtent();
                }
            }
            catch (Exception)
            {
                // Handle the failure in a way appropriate to the application.
                MessageBox.Show("无法获取该要素类的排它锁,检查ArcMap是否打开了该要素类,建议关闭!");
            }
            finally
            {
                // Disable load-only mode on the feature class.
                featureClassLoad.LoadOnlyMode = false;

                // Demote the exclusive schema lock to a shared lock.
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
            }
        }
        /// <summary>
        /// 建筑物  高度+海拔
        /// </summary>
        public bool constuctBuilding()
        {
            DataTable gridTable = IbatisHelper.ExecuteQueryForDataTable("getBuildingInfo", null);

            if (gridTable.Rows.Count < 1)
            {
                return(false);
            }

            IDataset       dataset       = (IDataset)pFeatureLayer.FeatureClass;
            IWorkspace     workspace     = dataset.Workspace;
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true);
            IFeatureBuffer pFeatureBuffer;

            List <IPoint> pts = new List <IPoint>();

            int    id       = Convert.ToInt32(gridTable.Rows[0]["BuildingID"]);
            double x        = Convert.ToDouble(gridTable.Rows[0]["VertexX"]);
            double y        = Convert.ToDouble(gridTable.Rows[0]["VertexY"]);
            double height   = Convert.ToDouble(gridTable.Rows[0]["BHeight"]);
            double altitude = Convert.ToDouble(gridTable.Rows[0]["BAltitude"]);
            IPoint pointA   = GeometryUtilities.ConstructPoint3D(x, y, 0);

            pts.Add(pointA);

            int lastid = id;

            //循环添加
            for (int i = 1; i < gridTable.Rows.Count; i++)
            {
                DataRow dataRow = gridTable.Rows[i];

                id = Convert.ToInt32(gridTable.Rows[i]["BuildingID"]);

                if (i == gridTable.Rows.Count - 1 || id != lastid)
                {
                    IGeometryCollection pGeometryColl = GeometryUtilities.ConstructPolygon(pts);
                    GeometryUtilities.MakeZAware(pGeometryColl as IGeometry);
                    pFeatureBuffer       = pFeatureClass.CreateFeatureBuffer();
                    pFeatureBuffer.Shape = pGeometryColl as IGeometry;
                    pFeatureBuffer.set_Value(this.bidIndex, lastid);
                    pFeatureBuffer.set_Value(this.heightIndex, height + altitude);
                    pFeatureCursor.InsertFeature(pFeatureBuffer);

                    lastid = id;
                    pts.Clear();
                }

                x        = Convert.ToDouble(gridTable.Rows[i]["VertexX"]);
                y        = Convert.ToDouble(gridTable.Rows[i]["VertexY"]);
                height   = Convert.ToDouble(gridTable.Rows[i]["BHeight"]);
                altitude = Convert.ToDouble(gridTable.Rows[i]["BAltitude"]);
                pointA   = GeometryUtilities.ConstructPoint3D(x, y, 0);
                pts.Add(pointA);
            }

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;

            pFeatureClassManage.UpdateExtent();
            //GISMapApplication.Instance.RefreshLayer(pFeatureLayer);

            return(true);
        }
예제 #15
0
        private void Deal()
        {
            IWorkspace        pWorkspace      = default(IWorkspace);
            string            sDesFeatClsName = null;
            IFeatureClass     pDesFeatCls     = default(IFeatureClass);
            string            sInfo           = null;
            ISpatialReference pSpatRef        = null;

            int i = 0;

            string sTxtPath = "";
            bool   bExist   = false;

            //判断Log文件夹是否存在

            //印骅 20081201 是否选择了要素类
            if (dgvData.Rows.Count == 0)
            {
                //g_clsErrorHandle.DisplayInformation("没有添加任何数据,请添加数据!", false);
                MessageBoxEx.Show("没有添加任何数据,请添加数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //是否进行投影转换,只有选择路径和投影参数以后才可转换
            if (m_bHasSpatRef == false)
            {
                if (string.IsNullOrEmpty(txtSaveFileRoute.Text.Trim()))
                {
                    MessageBoxEx.Show("请设置提取路径!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    //g_clsErrorHandle.DisplayInformation("没有设置投影参数!请选择*.prj文件!", false);
                    MessageBoxEx.Show("没有设置投影参数!请选择*.prj文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            pWorkspace = GetWorkspace();

            if (pWorkspace == null)
            {
                return;
            }

            this.ProgressBar.Visible = true;

            // 创建PrjLog.txt到bin\Log文件夹
            sTxtPath = System.Windows.Forms.Application.StartupPath.Replace("\\bin", "");
            bExist   = Directory.Exists(sTxtPath + "\\Log");
            if (!bExist)
            {
                Directory.CreateDirectory(sTxtPath + "\\Log");
            }
            FileStream   fsStream = new FileStream(sTxtPath + "\\Log" + "\\PrjLog.txt", FileMode.Append, FileAccess.Write);
            StreamWriter swWriter = new StreamWriter(fsStream);

            swWriter.WriteLine("下列要素类不能投影到指定坐标系,转换失败,要素类创建错误!");
            swWriter.WriteLine("记录数" + Strings.Chr(9) + "要素类路径");

            ////批量投影转换并提取
            for (i = 0; i <= m_PathCollection.Count - 1; i++)
            {
                //// 获得要素类
                m_pFeatureCls     = (IFeatureClass)m_FeatClsCollection[i];
                sDesFeatClsName   = m_pFeatureCls.AliasName;
                sInfo             = "当前操作层:" + m_pFeatureCls.AliasName;
                this.lblInfo.Text = sInfo;
                Application.DoEvents();
                if (!string.IsNullOrEmpty(sDesFeatClsName.Trim()))
                {
                    if (m_pFeatureCls != null)
                    {
                        this.lblInfo.Text = sInfo + "正在获得目标要素类,请稍候....";
                        lblInfo.Refresh();
                        Application.DoEvents();
                        ////读prj,获得空间参考
                        if (m_bHasSpatRef == true)
                        {
                            pSpatRef = ClsPublicFunction.LoadPRJ(txtPreDefinedPrj.Text);
                            if (sDesFeatClsName.Contains("."))
                            {
                                int dotIndex = 0;
                                dotIndex        = sDesFeatClsName.IndexOf(".");
                                sDesFeatClsName = sDesFeatClsName.Substring(dotIndex + 1, sDesFeatClsName.Length - dotIndex - 1);
                            }
                            IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWorkspace;
                            IFields           pFields           = m_pFeatureCls.Fields;
                            pDesFeatCls = ClsCreatAndGetDataset.CreatOrOpenFeatClsByName(ref pFeatureWorkspace, sDesFeatClsName, ref pFields, pSpatRef, null);
                            pWorkspace  = (IWorkspace)pFeatureWorkspace;
                            //m_pFeatureCls.Fields = pFields;
                        }
                        else
                        {
                            if (sDesFeatClsName.Contains("."))
                            {
                                int dotIndex = 0;
                                dotIndex        = sDesFeatClsName.IndexOf(".");
                                sDesFeatClsName = sDesFeatClsName.Substring(dotIndex + 1, sDesFeatClsName.Length - dotIndex - 1);
                            }
                            IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWorkspace;
                            IFields           pFields           = m_pFeatureCls.Fields;
                            pDesFeatCls = ClsCreatAndGetDataset.CreatOrOpenFeatClsByName(ref pFeatureWorkspace, sDesFeatClsName, ref pFields, null, null);
                            pWorkspace  = (IWorkspace)pFeatureWorkspace;
                            //m_pFeatureCls.Fields = pFields;
                        }
                        if (pDesFeatCls != null)
                        {
                            //如果不剪切的,则使用该方法,需要剪切,则使用选择集,分位于内部要素和位于外部要素或直接使用pfeatcls搜索二遍
                            //如果数据量大的话,搜索二遍的方法是不可行的
                            m_lResult = 0;
                            if (m_bHasSpatRef == true)
                            {
                                m_lResult = ClsCreateFeat.OutPutFeat(ref pDesFeatCls, ref m_pFeatureCls, "", null, false, ref pSpatRef, null, ref this.ProgressBar, ref this.lblInfo, sInfo);
                            }
                            else
                            {
                                ISpatialReference pSpatialReference = null;
                                ClsCreateFeat.OutPutFeat(ref pDesFeatCls, ref m_pFeatureCls, "", null, false, ref pSpatialReference, null, ref this.ProgressBar, ref this.lblInfo, sInfo);
                            }

                            // 投影转换失败则将日志写入PrjLog.txt
                            if (m_lResult == -1)
                            {
                                m_bAllTransferDone = false;

                                swWriter.WriteLine(Convert.ToInt32(m_iTNum).ToString() + Strings.Chr(9).ToString() + Strings.Chr(9).ToString() + m_PathCollection[i].ToString());
                                m_iTNum += 1;
                            }

                            ////  更新featureclass的范围
                            ISchemaLock schemaLock = default(ISchemaLock);
                            schemaLock = (ISchemaLock)pDesFeatCls;

                            IFeatureClassManage featureClassManage = default(IFeatureClassManage);
                            featureClassManage = (IFeatureClassManage)pDesFeatCls;
                            featureClassManage.UpdateExtent();
                            schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
                        }
                    }
                }
            }
            lblInfo.Text = "投影转换完成";
            m_iTNum      = 1;
            //要素类记录数归1

            this.Refresh();
            Application.DoEvents();

            this.ProgressBar.Visible = false;

            MessageBoxEx.Show("投影转换完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            txtSaveFileRoute.Text = "";


            //写入转换完成时间
            DateTime Now = DateTime.Now;

            swWriter.Write("转换完成时间:" + Strings.Chr(9));
            swWriter.Write(Strings.Chr(9) + Now.ToString() + Constants.vbCrLf);
            swWriter.WriteLine();
            swWriter.Close();
            fsStream.Close();
            // 有转换不成功时,弹出提示信息
            if (m_bAllTransferDone == false)
            {
                MessageBoxEx.Show("有要素类投影转换失败!详情请查看\"Log\\PrjLog.txt\"!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            m_bAllTransferDone = true;
        }
        public bool constuctGrid3Ds()
        {
            DataTable gridTable = IbatisHelper.ExecuteQueryForDataTable("GetInfSource", null);

            if (gridTable.Rows.Count < 1)
            {
                return(false);
            }

            IDataset   dataset   = (IDataset)pFeatureLayer.FeatureClass;
            IWorkspace workspace = dataset.Workspace;
            //Cast for an IWorkspaceEdit
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            //start an edit session and operation
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true);
            IFeatureBuffer pFeatureBuffer;

            int    gxid = 0, gyid = 0;
            double x, y, r = 10, x1, y1, x2, y2, z;

            //循环添加
            foreach (DataRow dataRow in gridTable.Rows)
            {
                x = double.Parse(dataRow["x"].ToString());
                y = double.Parse(dataRow["y"].ToString());
                z = double.Parse(dataRow["z"].ToString());

                GridHelper.getInstance().XYToGGrid(x, y, ref gxid, ref gyid);

                x1 = x - r;
                x2 = x + r;
                y1 = y - r;
                y2 = y + r;

                IPoint pointA = GeometryUtilities.ConstructPoint3D(x1, y1, z);
                IPoint pointB = GeometryUtilities.ConstructPoint3D(x2, y1, z);
                IPoint pointC = GeometryUtilities.ConstructPoint3D(x2, y2, z);
                IPoint pointD = GeometryUtilities.ConstructPoint3D(x1, y2, z);

                IGeometryCollection pGeometryColl = GeometryUtilities.ConstructPolygon(new IPoint[] { pointA, pointB, pointC, pointD });
                GeometryUtilities.MakeZAware(pGeometryColl as IGeometry);

                pFeatureBuffer       = pFeatureClass.CreateFeatureBuffer();
                pFeatureBuffer.Shape = pGeometryColl as IGeometry;
                pFeatureBuffer.set_Value(this.GXIDIndex, gxid);
                pFeatureBuffer.set_Value(this.GYIDIndex, gyid);
                pFeatureBuffer.set_Value(this.LevelIndex, z);

                pFeatureBuffer.set_Value(this.RecePowerIndex, -41);
                pFeatureCursor.InsertFeature(pFeatureBuffer);
            }

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;

            pFeatureClassManage.UpdateExtent();

            //GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            return(true);
        }