Example #1
0
        // 绘制矩形
        public static void DrawRect(double minX, double minY, double maxX, double maxY, int r, int g, int b)
        {
            IPoint p1 = GeometryUtilities.ConstructPoint3D(minX, minY, 0);
            IPoint p2 = GeometryUtilities.ConstructPoint3D(minX, maxY, 0);
            IPoint p3 = GeometryUtilities.ConstructPoint3D(maxX, maxY, 0);
            IPoint p4 = GeometryUtilities.ConstructPoint3D(maxX, minY, 0);

            DrawLine(p1, p2, r, g, b);
            DrawLine(p2, p3, r, g, b);
            DrawLine(p3, p4, r, g, b);
            DrawLine(p4, p1, r, g, b);
        }
Example #2
0
        // 绘制矩形
        public static void DrawRect(IPoint pMin, IPoint pMax, int r, int g, int b)
        {
            IPoint p1 = GeometryUtilities.ConstructPoint3D(pMin.X, pMin.Y, 0);
            IPoint p2 = GeometryUtilities.ConstructPoint3D(pMin.X, pMax.Y, 0);
            IPoint p3 = GeometryUtilities.ConstructPoint3D(pMax.X, pMax.Y, 0);
            IPoint p4 = GeometryUtilities.ConstructPoint3D(pMax.X, pMin.Y, 0);

            DrawLine(p1, p2, r, g, b);
            DrawLine(p2, p3, r, g, b);
            DrawLine(p3, p4, r, g, b);
            DrawLine(p4, p1, r, g, b);
        }
Example #3
0
        /// <summary>
        /// 构造小区的一个立体覆盖网格
        /// </summary>
        /// <param name="cellName"></param>
        /// <param name="lac"></param>
        /// <param name="ci"></param>
        /// <param name="gxid"></param>
        /// <param name="gyid"></param>
        /// <param name="level"></param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="z"></param>
        /// <param name="recePower"></param>
        /// <param name="pathLoss"></param>
        public void constructGrid3D(string cellName, int lac, int ci, int gxid, int gyid, int level, double x1, double y1, double x2, double y2, double z, double recePower, double pathLoss)
        {
            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;

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

            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 });

            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, level);
            pFeatureBuffer.set_Value(this.eNodeBIndex, lac);
            pFeatureBuffer.set_Value(this.CIIndex, ci);
            pFeatureBuffer.set_Value(this.cellNameIndex, cellName);
            pFeatureBuffer.set_Value(this.RecePowerIndex, recePower);
            pFeatureBuffer.set_Value(this.PathLossIndex, pathLoss);
            pFeatureBuffer.set_Value(this.LongitudeIndex, lon);
            pFeatureBuffer.set_Value(this.LatitudeIndex, lat);

            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);
        }
Example #4
0
        /// <summary>
        /// 获取polygon的点集(大地坐标),如果一个点距离前一个点距离太小,则忽略掉
        /// </summary>
        /// <param name="polygon">大地坐标</param>
        /// <returns></returns>
        public static List <IPoint> GetPointListOfPolygon(IPolygon polygon)
        {
            Polygon       pPolygon = polygon as Polygon;
            int           pointCount = pPolygon.PointCount;
            List <IPoint> pointList = new List <IPoint>();
            IPoint        prePoint = GeometryUtilities.ConstructPoint2D(0, 0), curPoint;

            for (int i = 0; i < pointCount; i++)
            {
                curPoint = pPolygon.get_Point(i);
                if (curPoint == null)
                {
                    continue;
                }
                if (Math.Pow(prePoint.X - curPoint.X, 2) + Math.Pow(prePoint.Y - curPoint.Y, 2) < 9)
                {
                    continue;
                }
                prePoint = curPoint;
                pointList.Add(GeometryUtilities.ConstructPoint3D(curPoint, 0));
            }
            return(pointList);
        }
Example #5
0
        public static bool refreshInfLayer()
        {
            DataTable gridTable = IbatisHelper.ExecuteQueryForDataTable("GetInfSource", null);

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

            IRgbColor      pColor = new RgbColorClass(); //颜色
            IGraphicsLayer pLayer = ((object)GISMapApplication.Instance.Scene as IBasicMap).BasicGraphicsLayer;
            IPoint         pt     = null;

            pColor.RGB = System.Drawing.Color.FromArgb(0, 0, 255).ToArgb();

            foreach (DataRow dataRow in gridTable.Rows)
            {
                pt = GeometryUtilities.ConstructPoint3D(double.Parse(dataRow["x"].ToString()), double.Parse(dataRow["y"].ToString()), double.Parse(dataRow["z"].ToString()));
                DrawUtilities.DrawPoint(pLayer as IGraphicsContainer3D, pt, pColor, 25);
            }

            return(true);
        }
        /// <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);
        }
Example #9
0
        public bool constuctGrid3Ds(int mingxid, int maxgxid, int mingyid, int maxgyid, short type)
        {
            DataTable gridTable = new DataTable();
            Hashtable para      = new Hashtable();

            para["minGXID"] = mingxid;
            para["maxGXID"] = maxgxid;
            para["minGYID"] = mingyid;
            para["maxGYID"] = maxgyid;
            para["type"]    = type;

            gridTable = IbatisHelper.ExecuteQueryForDataTable("getDefect", para);
            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, gyid, level;
            double x1, y1, x2, y2, z;
            double recePower;
            double gbaseheight = GridHelper.getInstance().getGBaseHeight();
            double gheight     = GridHelper.getInstance().getGHeight();
            //循环添加
            int cnt = 0;

            foreach (DataRow dataRow in gridTable.Rows)
            {
                if (++cnt % 100 == 0)
                {
                    Console.WriteLine(cnt + "/" + gridTable.Rows.Count);
                }
                gxid  = int.Parse(dataRow["GXID"].ToString());
                gyid  = int.Parse(dataRow["GYID"].ToString());
                level = int.Parse(dataRow["GZID"].ToString());

                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)))
                {
                    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.LevelIndex, level);

                if (recePower > -41)
                {
                    pFeatureBuffer.set_Value(this.RecePowerIndex, -41);
                }
                else
                {
                    pFeatureBuffer.set_Value(this.RecePowerIndex, recePower);
                }
                pFeatureCursor.InsertFeature(pFeatureBuffer);
            }

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

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

            //IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;
            //pFeatureClassManage.UpdateExtent();

            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>
        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);
        }
Example #11
0
        /// <summary>
        /// 构造小区立体顶面覆盖网格
        /// </summary>
        /// <param name="cellname"></param>
        /// <param name="lac"></param>
        /// <param name="ci"></param>
        public void constuctCellGrid3Dtops(string cellname, int eNodeB, int ci)
        {
            DataTable gridTable = new DataTable();
            Hashtable ht        = new Hashtable();

            ht["eNodeB"] = eNodeB;
            ht["CI"]     = ci;
            gridTable    = IbatisHelper.ExecuteQueryForDataTable("GetSpecifiedCellGrid3Ds", ht);
            //gridTable = IbatisHelper.ExecuteQueryForDataTable("GetAreaGrid3Ds", null);

            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, gyid, level;
            double x1, y1, x2, y2, z;
            double recePower, pathLoss;
            double gbaseheight = GridHelper.getInstance().getGBaseHeight();
            double gheight     = GridHelper.getInstance().getGHeight();

            //循环添加
            foreach (DataRow dataRow in gridTable.Rows)
            {
                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 (!(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) && double.TryParse(dataRow["ReceivedPowerdbm"].ToString(), out recePower) && double.TryParse(dataRow["PathLoss"].ToString(), out pathLoss)))
                {
                    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.LevelIndex, level);
                pFeatureBuffer.set_Value(this.eNodeBIndex, eNodeB);
                pFeatureBuffer.set_Value(this.CIIndex, ci);
                pFeatureBuffer.set_Value(this.cellNameIndex, cellname);
                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);
            }

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

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

            //IFeatureClassManage pFeatureClassManage = (IFeatureClassManage)pFeatureClass;
            //pFeatureClassManage.UpdateExtent();

            GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            //GISMapApplication.Instance.FullExtent(pFeatureLayer.AreaOfInterest);
        }
        /// <summary>
        /// 刷新GSM900小区图层
        /// </summary>
        public bool RefreshGSM900Cell()
        {
            IList <CELL> GSM900CellData = IbatisHelper.ExecuteQueryForList <CELL>("GetGSM900CellLayerData", null);

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

            IFeatureWorkspace featureWorkspace = MapWorkSpace.getWorkSpace();
            IFeatureClass     pFeatureClass    = featureWorkspace.OpenFeatureClass(LayerNames.GSM900Cell);
            IFeatureLayer     pFeatureLayer    = new FeatureLayer();

            pFeatureLayer.FeatureClass = pFeatureClass;

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

            FeatureUtilities.DeleteFeatureLayerFeatrues(pFeatureLayer);

            //IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;

            #region 测试
            //设置字段
            //IField pField = new FieldClass();
            //IFieldEdit pFieldEdit = (IFieldEdit)pField;

            //添加新的zhcellname
            //pField = new FieldClass();
            //pFieldEdit = (IFieldEdit)pField;
            //pFieldEdit.Name_2 = System.DateTime.Now.Month.ToString()+System.DateTime.Now.Millisecond.ToString();
            //pFeatureClass.AddField(pField);

            //清除旧的field(从第三个开始删除,前面两个是必须字段,不能删除,第三个删除不了,下面作更新第三个)
            //while (pFeatureClass.Fields.FieldCount > 3)
            //{
            //    string fieldName = pFeatureClass.Fields.get_Field(2).Name;

            // FeatureUtilities.DeletField(pFeatureClass, fieldName);
            //}

            ////增加新的field

            ////因最后一个删除不了,这里作修改,cell_name
            //pField = new FieldClass();
            //pFieldEdit = (IFieldEdit)pField;
            //pFieldEdit.Name_2 = "cell_name";
            //pFeatureClass.AddField(pField);



            ////添加新的zhcellname
            //pField = new FieldClass();
            //pFieldEdit = (IFieldEdit)pField;
            //pFieldEdit.Name_2 = "zhcellname";
            //pFeatureClass.AddField(pField);

            ////添加新的longitude
            //pField = new FieldClass();
            //pFieldEdit = (IFieldEdit)pField;
            //pFieldEdit.Name_2 = "longitude";
            //pFeatureClass.AddField(pField);

            ////添加新的latitude
            //pField = new FieldClass();
            //pFieldEdit = (IFieldEdit)pField;
            //pFieldEdit.Name_2 = "latitude";
            //pFeatureClass.AddField(pField);

            ////添加新的height
            //pField = new FieldClass();
            //pFieldEdit = (IFieldEdit)pField;
            //pFieldEdit.Name_2 = "height";
            //pFeatureClass.AddField(pField);

            ////添加新的tilt
            //pField = new FieldClass();
            //pFieldEdit = (IFieldEdit)pField;
            //pFieldEdit.Name_2 = "tilt";
            //pFeatureClass.AddField(pField);
            #endregion 测试

            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 = 60;//小区900生成的半径大小
            double every      = 1;

            foreach (CELL gsm900Cell in GSM900CellData)
            {
                if ((!gsm900Cell.x.HasValue) || (!gsm900Cell.y.HasValue) || (!gsm900Cell.AntHeight.HasValue) || (!gsm900Cell.Azimuth.HasValue) || (!gsm900Cell.Tilt.HasValue))
                {
                    continue;
                }
                int    lac         = gsm900Cell.eNodeB.Value;
                int    ci          = gsm900Cell.CI.Value;
                string cellName    = gsm900Cell.CellName;
                string cellNameChs = gsm900Cell.CellNameChs;
                double longitude   = Convert.ToDouble(gsm900Cell.Longitude.Value);
                double latitude    = Convert.ToDouble(gsm900Cell.Latitude.Value);
                double antHeight   = Convert.ToDouble(gsm900Cell.AntHeight.Value);
                double azimuth     = gsm900Cell.Azimuth.Value;
                double tilt        = gsm900Cell.Tilt.Value;
                int    EARFCN      = gsm900Cell.EARFCN.Value;
                double EIRP        = gsm900Cell.EIRP.Value;
                double radius      = gsm900Cell.CoverageRadius.Value;
                tilt = tilt > 0 ? tilt : 7;

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

                double Direction = (450 - azimuth) % 360;

                double x          = Convert.ToDouble(gsm900Cell.x.Value);
                double y          = Convert.ToDouble(gsm900Cell.y.Value);
                IPoint startPoint = GeometryUtilities.ConstructPoint3D(x, y, antHeight);
                IPoint leftPoint  = GeometryUtilities.ConstructPoint3D(circRadius * Math.Cos((Direction - 18 * every) * Math.PI / 180) + x, y + circRadius * Math.Sin((Direction - 18 * every) * Math.PI / 180), antHeight);
                IPoint rightPoint = GeometryUtilities.ConstructPoint3D(circRadius * Math.Cos((Direction + 18 * every) * Math.PI / 180) + x, y + circRadius * Math.Sin((Direction + 9 * every) * Math.PI / 180), 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("EARFCN"), EARFCN);
                pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("EIRP"), EIRP);
                pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("Tilt"), tilt);
                pFeatureBuffer.set_Value(pFeatureBuffer.Fields.FindField("Radius"), radius);
                pFeatureCursor.InsertFeature(pFeatureBuffer);
            }

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

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

            //GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            //GISMapApplication.Instance.FullExtent(pFeatureLayer.AreaOfInterest);
            return(true);
        }
        /// <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);
        }
        ///<summary>在地图上绘制指定颜色的图形</summary>
        ///<param name="scene">地图</param>
        ///<param name="geometry">feature 的shape</param>
        ///<param name="rgbColor">颜色</param>
        ///<param name="outlineRgbColor">边框颜色</param>
        ///<param name="OffsetZs">Z偏值</param>
        ///
        ///<remarks>Calling this function will not automatically make the graphics appear in the map area. Refresh the map area after after calling this function with Methods like IActiveView.Refresh or IActiveView.PartialRefresh.</remarks>
        internal static IElement AddGraphicToScene(IScene scene, ESRI.ArcGIS.Geometry.IGeometry geometry, ESRI.ArcGIS.Display.IRgbColor rgbColor, ESRI.ArcGIS.Display.IRgbColor outlineRgbColor, double OffsetZs)
        {
            //ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = (ESRI.ArcGIS.Carto.IGraphicsContainer)map; //IGraphicsContainer接口能删除
            IGraphicsContainer3D graphicsContainer3D = (IGraphicsContainer3D)scene.BasicGraphicsLayer;

            ESRI.ArcGIS.Carto.IElement element = null;
            if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
            {
                IPoint point = (Point)geometry;

                try
                {
                    double X = point.X;
                    double Y = point.Y;
                }
                catch
                {
                    return(null);
                }
                point = GeometryUtilities.ConstructPoint3D(point, OffsetZs);
                // Marker symbols
                ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
                simpleMarkerSymbol.Color        = rgbColor;
                simpleMarkerSymbol.Outline      = true;
                simpleMarkerSymbol.OutlineColor = rgbColor;
                simpleMarkerSymbol.Size         = 12;
                simpleMarkerSymbol.Style        = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCircle;

                ESRI.ArcGIS.Carto.IMarkerElement markerElement = new ESRI.ArcGIS.Carto.MarkerElementClass();
                markerElement.Symbol = simpleMarkerSymbol;
                element = (ESRI.ArcGIS.Carto.IElement)markerElement; // Explicit Cast

                if (!(element == null))
                {
                    element.Geometry = point;

                    graphicsContainer3D.AddElement(element);
                }
            }
            else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
            {
                // Marker symbols
                ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
                simpleLineSymbol.Color = rgbColor;
                simpleLineSymbol.Style = ESRI.ArcGIS.Display.esriSimpleLineStyle.esriSLSSolid;
                simpleLineSymbol.Width = 1;

                ESRI.ArcGIS.Carto.ILineElement lineElement = new ESRI.ArcGIS.Carto.LineElementClass();
                lineElement.Symbol = simpleLineSymbol;
                element            = (ESRI.ArcGIS.Carto.IElement)lineElement; // Explicit Cast

                if (!(element == null))
                {
                    element.Geometry = geometry;
                    graphicsContainer3D.AddElement(element);
                }
            }
            else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
            {
                IZ iz = (IZ)geometry;
                iz.OffsetZs(OffsetZs);//z值向上偏移

                // Polygon elements
                ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
                simpleFillSymbol.Color = rgbColor;
                simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSForwardDiagonal;
                ESRI.ArcGIS.Carto.IFillShapeElement fillShapeElement = new ESRI.ArcGIS.Carto.PolygonElementClass();
                fillShapeElement.Symbol = simpleFillSymbol;
                element = (ESRI.ArcGIS.Carto.IElement)fillShapeElement; // Explicit Cast

                if (!(element == null))
                {
                    element.Geometry = geometry;
                    graphicsContainer3D.AddElement(element);
                }
            }



            return(element);
        }
        /// <summary>
        /// 刷新虚拟干扰源图层
        /// </summary>
        public bool ConstuctSelectPoints(string fromname)
        {
            Hashtable ht = new Hashtable();

            ht["fromName"] = fromname;
            DataTable virTable = IbatisHelper.ExecuteQueryForDataTable("GetSelectedPoint", ht);

            if (virTable.Rows.Count < 2)
            {
                return(false);
            }
            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 = 60;//扇区生成的半径大小
            double every      = 1;


            foreach (DataRow vir in virTable.Rows)
            {
                int    ci        = Convert.ToInt32(vir["CI"]);
                string fromName  = Convert.ToString(vir["fromName"]);
                double ReceivePW = Convert.ToDouble(vir["ReceivePW"]);
                double azimuth   = Convert.ToDouble(vir["Azimuth"]);



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


                double x = Convert.ToDouble(vir["x"]);
                double y = Convert.ToDouble(vir["y"]);

                IPoint startPoint = GeometryUtilities.ConstructPoint3D(x, y, 0);

                LTE.Geometric.Point p = new Geometric.Point(x, y, 0);
                PointConvertByProj.Instance.GetGeoPoint(p);

                double Direction = (450 - azimuth) % 360;

                IPoint leftPoint  = GeometryUtilities.ConstructPoint3D(circRadius * Math.Cos((Direction - 18 * every) * Math.PI / 180) + x, y + circRadius * Math.Sin((Direction - 18 * every) * Math.PI / 180), 0);
                IPoint rightPoint = GeometryUtilities.ConstructPoint3D(circRadius * Math.Cos((Direction + 18 * every) * Math.PI / 180) + x, y + circRadius * Math.Sin((Direction + 9 * every) * Math.PI / 180), 0);

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

                ///暂时没添加经纬度

                pFeatureBuffer.Shape = pGeometryColl as IGeometry;
                pFeatureBuffer.set_Value(CIIndex, ci);
                pFeatureBuffer.set_Value(FromIndex, fromName);
                pFeatureBuffer.set_Value(AziIndex, azimuth);
                pFeatureBuffer.set_Value(LonIndex, p.X);
                pFeatureBuffer.set_Value(LatIndex, p.Y);
                pFeatureBuffer.set_Value(RecPwIndex, 10 * (Math.Log10(ReceivePW) + 3));
                pFeatureCursor.InsertFeature(pFeatureBuffer);
            }

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

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

            GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            return(true);
            //GISMapApplication.Instance.FullExtent(pFeatureLayer.AreaOfInterest);
        }
        /// <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);
        }
        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);
        }