Esempio n. 1
0
        public void Update(double MapScale)
        {
            ESRI.ArcGIS.Geometry.IPoint pnt = new ESRI.ArcGIS.Geometry.PointClass();
            double delta = (.1 * MapScale) / 2;

            pnt.X = this._Callout.AnchorPoint.X + delta;
            pnt.Y = this._Callout.AnchorPoint.Y + delta;

            this._Element.Geometry = pnt;
        }
Esempio n. 2
0
        /// <summary>
        /// OverView地图的红框移动后,宿主地图视图发生改变
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axMapControl_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            ESRI.ArcGIS.Geometry.IPoint centerPoint = new ESRI.ArcGIS.Geometry.PointClass();
            centerPoint.PutCoords(e.mapX, e.mapY);
            ESRI.ArcGIS.Geometry.IEnvelope eleEnvelope = m_Element.Geometry.Envelope;
            eleEnvelope.CenterAt(centerPoint);
            m_Element.Geometry = (ESRI.ArcGIS.Geometry.IGeometry)eleEnvelope;

            this.m_Application.MapControl.Extent = eleEnvelope;
            this.m_Application.MapControl.ActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGraphics, null, null);
        }
        public void CreateLineFeature(IFeatureClass featureClass, IFeature sourceF, ESRI.ArcGIS.Geometry.IGeometry shape, string value1, string value2, string value3, string value4, string value5)
        {
            try
            {
                double angle = Convert.ToDouble(ConfigUtil.GetConfigValue("Angle"));
                // Build the feature.
                ESRI.ArcGIS.Geometry.IPoint pOriginPoint = shape as ESRI.ArcGIS.Geometry.IPoint;
                double dbPi = 4 * Math.Atan(1);
                ESRI.ArcGIS.Geometry.IPoint pEndPoint = new ESRI.ArcGIS.Geometry.PointClass();
                //MessageBox.Show(pOriginPoint.X.ToString() + pOriginPoint.Y.ToString());
                pEndPoint.X = pOriginPoint.X - (Math.Cos(((angle) * (dbPi / 180))) * 6);
                pEndPoint.Y = pOriginPoint.Y - (Math.Sin(((angle) * (dbPi / 180))) * 6);


                ESRI.ArcGIS.Geometry.IPointCollection pCollection = new ESRI.ArcGIS.Geometry.PolylineClass();
                pCollection.AddPoint(pOriginPoint);
                pCollection.AddPoint(pEndPoint);

                IFeature feature = featureClass.CreateFeature();
                feature.Shape = pCollection as ESRI.ArcGIS.Geometry.IPolyline;

                // Update the value on a string field that indicates who installed the feature.
                int contractorFieldIndex = featureClass.FindField("DIAMETER");
                feature.set_Value(contractorFieldIndex, Convert.ToInt16(value2));

                int diaFieldIndex = featureClass.FindField("OWNEDBY");
                feature.set_Value(diaFieldIndex, value4);

                int matFieldIndex = featureClass.FindField("SERVICELENGTHBAND");
                feature.set_Value(matFieldIndex, value3);


                int ownedbyFieldIndex = featureClass.FindField("SERVICESIDE");
                feature.set_Value(ownedbyFieldIndex, value1);

                int JBPFieldIndex = featureClass.FindField("JPNUM");
                feature.set_Value(featureClass.FindField("LENGTH"), 6);
                feature.set_Value(JBPFieldIndex, value5);
                feature.set_Value(featureClass.FindField("LOCATION"), sourceF.get_Value(sourceF.Fields.FindField(ConfigUtil.GetConfigValue("LOCATION"))));
                feature.set_Value(featureClass.FindField("LOCATIONDESCRIPTION"), ConfigUtil.GetConfigValue("LOCATIONDESCRIPTION"));
                feature.set_Value(featureClass.FindField("FACILITYID"), GenerateID(ConfigUtil.GetConfigValue("GenIDNWL")));


                // Commit the new feature to the geodatabase.
                feature.Store();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + e.StackTrace);
            }
        }
Esempio n. 4
0
        private static ESRI.ArcGIS.Geometry.IPointCollection PathToPoint(System.Drawing.PointF[] arrPoints)
        {
            ESRI.ArcGIS.Geometry.IPointCollection pointColl = new ESRI.ArcGIS.Geometry.MultipointClass();
            ESRI.ArcGIS.Geometry.IPoint           point     = new ESRI.ArcGIS.Geometry.PointClass();

            foreach (System.Drawing.PointF pointf in arrPoints)
            {
                // switching coords - ESRI and Microsoft use a different 'paper space'.
                point.X = pointf.Y;
                point.Y = pointf.X;

                pointColl.AddPoint(point);
                point = new ESRI.ArcGIS.Geometry.PointClass();
            }

            return(pointColl);
        }
Esempio n. 5
0
        /// <summary>
        /// 创建等高线*.shp文件的主方法
        /// </summary>
        /// <param name="lux">左上投影x坐标</param>
        /// <param name="luy">左上投影y坐标</param>
        /// <param name="luz">左上投影z坐标</param>
        /// <param name="rlx">右下投影x坐标</param>
        /// <param name="rly">右下投影y坐标</param>
        /// <param name="rlz">右下投影z坐标</param>
        /// <param name="m_interval">采样间隔</param>
        /// <returns>等高线*.shp文件的文件名</returns>
        public string CreateContourShape(ISGWorld61 sgworld, double lux, double luy, double luz, double rlx, double rly, double rlz, double m_interval)
        {
            double width = sgworld.CoordServices.GetDistance(lux, luy, rlx, luy);
            double hight = sgworld.CoordServices.GetDistance(lux, luy, lux, rly);

            if (width < 5 || hight < 10)
            {
                MessageBox.Show("范围过小!", "SUNZ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(null);
            }
            if ((width / 1000) * (hight / 1000) > 40)
            {
                if (MessageBox.Show("范围超出40平分公里,系统计算时间比较长,是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                }
                else
                {
                    return(null);
                }
            }
            this.Interval = m_interval;
            this.Random   = System.Guid.NewGuid().ToString().Substring(0, 6).ToLower();
            CopyFolder(Application.StartupPath + "\\Convert\\TemPoints", Application.StartupPath + "\\Convert\\PointsResult\\" + this.Random);
            IWorkspaceFactory  pWorkspaceFactory = new ShapefileWorkspaceFactory();
            IWorkspace         pWorkspace        = pWorkspaceFactory.OpenFromFile(Application.StartupPath + "\\Convert\\PointsResult\\" + this.Random, 0);
            IFeatureWorkspace  pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
            IFeatureClass      pFeatureClass     = pFeatureWorkspace.OpenFeatureClass(System.IO.Path.GetFileNameWithoutExtension(Application.StartupPath + "\\Convert\\PointsResult\\" + Random + "\\TemPointLayer.shp"));
            IFeatureClassWrite fr = (IFeatureClassWrite)pFeatureClass;
            IWorkspaceEdit     w  = (pFeatureClass as IDataset).Workspace as IWorkspaceEdit;
            IFeature           f;

            w.StartEditing(true);
            w.StartEditOperation();
            int EastPointCount = (int)(width / 5);
            int NothPointCount = (int)(hight / 5);

            for (int j = 0; j < NothPointCount; j++)
            {
                ESRI.ArcGIS.Geometry.IPoint p;
                p = new ESRI.ArcGIS.Geometry.PointClass();
                ESRI.ArcGIS.Geometry.IZAware iz = p as ESRI.ArcGIS.Geometry.IZAware;
                iz.ZAware = true;
                p.X       = lux;
                p.Y       = luy;
                p.Z       = luz;

                ESRI.ArcGIS.Geometry.IGeometry peo;
                peo     = p;
                f       = pFeatureClass.CreateFeature();
                f.Shape = peo;
                f.set_Value(3, p.Z);
                f.Store();
                fr.WriteFeature(f);

                for (int i = 0; i < EastPointCount; i++)
                {
                    IPosition61 positionLU = null;
                    ICoord2D    pPoint     = null;
                    if ((j + 2) % 2 == 0)
                    {
                        pPoint = sgworld.CoordServices.MoveCoord(lux, luy, 5, 0);
                    }
                    else
                    {
                        pPoint = sgworld.CoordServices.MoveCoord(lux, luy, -5, 0);
                    }

                    IWorldPointInfo61 pW = sgworld.Terrain.GetGroundHeightInfo(pPoint.X, pPoint.Y, AccuracyLevel.ACCURACY_BEST_FROM_MEMORY, true);
                    positionLU = pW.Position;
                    luz        = positionLU.Altitude;
                    lux        = positionLU.X;
                    luy        = positionLU.Y;
                    p          = new ESRI.ArcGIS.Geometry.PointClass();
                    iz         = p as ESRI.ArcGIS.Geometry.IZAware;
                    iz.ZAware  = true;
                    p.X        = lux;
                    p.Y        = luy;
                    p.Z        = luz;
                    peo        = p;
                    f          = pFeatureClass.CreateFeature();
                    f.Shape    = peo;
                    f.set_Value(3, p.Z);
                    f.Store();
                    fr.WriteFeature(f);
                }
                ICoord2D          pPointL = sgworld.CoordServices.MoveCoord(lux, luy, 0, -5);
                IWorldPointInfo61 pWL     = sgworld.Terrain.GetGroundHeightInfo(pPointL.X, pPointL.Y, AccuracyLevel.ACCURACY_FORCE_BEST_RENDERED, true);
                luz = pWL.Position.Altitude;
                lux = pWL.Position.X;
                luy = pWL.Position.Y;
            }
            w.StopEditOperation();
            w.StopEditing(true);
            CreateTinFromFeature(pFeatureClass);
            return(this.Random);
        }
Esempio n. 6
0
        /// <summary>
        /// 创建等高线*.shp文件的主方法
        /// </summary>
        /// <param name="lux">左上投影x坐标</param>
        /// <param name="luy">左上投影y坐标</param>
        /// <param name="luz">左上投影z坐标</param>
        /// <param name="rlx">右下投影x坐标</param>
        /// <param name="rly">右下投影y坐标</param>
        /// <param name="rlz">右下投影z坐标</param>
        /// <param name="m_interval">采样间隔</param>
        /// <returns>等高线*.shp文件的文件名</returns>
        public string CreateContourShape(ISGWorld61 sgworld, double lux, double luy, double luz, double rlx, double rly, double rlz,double m_interval)
        {
            double width = sgworld.CoordServices.GetDistance(lux, luy, rlx, luy);
            double hight = sgworld.CoordServices.GetDistance(lux, luy, lux, rly);
            if (width<5||hight<10)
            {
                MessageBox.Show("范围过小!","SUNZ",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                return null;

            }
            if ((width/1000)*(hight/1000)>40)
            {
                if (MessageBox.Show("范围超出40平分公里,系统计算时间比较长,是否继续?","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) == DialogResult.OK)
                {

                }
                else
                {
                    return null;
                }
            }
            this.Interval = m_interval;
            this.Random = System.Guid.NewGuid().ToString().Substring(0, 6).ToLower();
            CopyFolder(Application.StartupPath + "\\Convert\\TemPoints", Application.StartupPath + "\\Convert\\PointsResult\\" + this.Random);
            IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory();
            IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(Application.StartupPath + "\\Convert\\PointsResult\\" + this.Random, 0);
            IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
            IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(System.IO.Path.GetFileNameWithoutExtension(Application.StartupPath + "\\Convert\\PointsResult\\" + Random + "\\TemPointLayer.shp"));
            IFeatureClassWrite fr = (IFeatureClassWrite)pFeatureClass;
            IWorkspaceEdit w = (pFeatureClass as IDataset).Workspace as IWorkspaceEdit;
            IFeature f;
            w.StartEditing(true);
            w.StartEditOperation();
            int EastPointCount = (int)(width / 5);
            int NothPointCount = (int)(hight / 5);
            for (int j = 0; j < NothPointCount; j++)
            {
                ESRI.ArcGIS.Geometry.IPoint p;
                p = new ESRI.ArcGIS.Geometry.PointClass();
                ESRI.ArcGIS.Geometry.IZAware iz = p as ESRI.ArcGIS.Geometry.IZAware;
                iz.ZAware = true;
                p.X = lux;
                p.Y = luy;
                p.Z = luz;

                ESRI.ArcGIS.Geometry.IGeometry peo;
                peo = p;
                f = pFeatureClass.CreateFeature();
                f.Shape = peo;
                f.set_Value(3, p.Z);
                f.Store();
                fr.WriteFeature(f);

                for (int i = 0; i < EastPointCount; i++)
                {

                    IPosition61 positionLU = null;
                    ICoord2D pPoint = null;
                    if ((j + 2) % 2 == 0)
                    {
                        pPoint = sgworld.CoordServices.MoveCoord(lux, luy, 5, 0);
                    }
                    else
                    {
                        pPoint = sgworld.CoordServices.MoveCoord(lux, luy, -5, 0);
                    }

                    IWorldPointInfo61 pW = sgworld.Terrain.GetGroundHeightInfo(pPoint.X, pPoint.Y, AccuracyLevel.ACCURACY_BEST_FROM_MEMORY, true);
                    positionLU = pW.Position;
                    luz = positionLU.Altitude;
                    lux = positionLU.X;
                    luy = positionLU.Y;
                    p = new ESRI.ArcGIS.Geometry.PointClass();
                    iz = p as ESRI.ArcGIS.Geometry.IZAware;
                    iz.ZAware = true;
                    p.X = lux;
                    p.Y = luy;
                    p.Z = luz;
                    peo = p;
                    f = pFeatureClass.CreateFeature();
                    f.Shape = peo;
                    f.set_Value(3, p.Z);
                    f.Store();
                    fr.WriteFeature(f);

                }
                ICoord2D pPointL = sgworld.CoordServices.MoveCoord(lux, luy, 0, -5);
                IWorldPointInfo61 pWL = sgworld.Terrain.GetGroundHeightInfo(pPointL.X, pPointL.Y, AccuracyLevel.ACCURACY_FORCE_BEST_RENDERED, true);
                luz = pWL.Position.Altitude;
                lux = pWL.Position.X;
                luy = pWL.Position.Y;

            }
            w.StopEditOperation();
            w.StopEditing(true);
            CreateTinFromFeature(pFeatureClass);
            return this.Random;
        }
Esempio n. 7
0
        private void LampAnalysis()
        {
            try
            {
                if (m_Model == null)
                {
                    MessageBox.Show("请先安放信号灯!");
                    return;
                }

                this.txtResult.Clear();
                Application.DoEvents();

                SendMessage("正在获取路口信息...");

                string lyr   = ConfigurationManager.AppSettings["CrossLayer"];
                int    lyrID = m_Hook.ProjectTree.FindItem(lyr);
                if (lyrID < 0)
                {
                    MessageBox.Show("您的配置有问题或者路口图层没有加载");
                    return;
                }

                ILayer61 teLayer = m_Hook.ProjectTree.GetLayer(lyrID);
                if (teLayer == null)
                {
                    return;
                }
                //IFeature61 tefCurrent = teLayer.FeatureGroups.Point[0] as IFeature61;

                // 严格来说要根据所点的位置来确定是哪个路口
                // 取第一个作为路口信息

                // 先直接从数据库中读取,模拟计算
                string   strOld = teLayer.DataSourceInfo.ConnectionString;
                string[] strs   = strOld.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                strOld = strs[0];
                strOld = strOld.Substring(strOld.IndexOf("=") + 1);
                string strFolder = System.IO.Path.GetDirectoryName(strOld);
                string strName   = System.IO.Path.GetFileNameWithoutExtension(strOld);

                IWorkspaceFactory wsf    = new ShapefileWorkspaceFactoryClass();
                IWorkspace        wsShp  = wsf.OpenFromFile(strFolder, 0);
                IFeatureClass     fClass = (wsShp as IFeatureWorkspace).OpenFeatureClass(strName);

                IPosition61 position = m_Model.Position;
                ESRI.ArcGIS.Geometry.IPoint pModel = new ESRI.ArcGIS.Geometry.PointClass();
                pModel.SpatialReference = (fClass as IGeoDataset).SpatialReference;
                pModel.PutCoords(position.X, position.Y);

                ESRI.ArcGIS.Geometry.ITopologicalOperator topoOperator = pModel as ESRI.ArcGIS.Geometry.ITopologicalOperator;
                ESRI.ArcGIS.Geometry.IGeometry            geoModel     = topoOperator.Buffer(50);

                ISpatialFilter qFilter = new SpatialFilterClass();
                qFilter.Geometry   = geoModel;
                qFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                IFeatureCursor fCursor = fClass.Search(qFilter, false);
                IFeature       fCross  = fCursor.NextFeature();
                if (fCross == null)
                {
                    SendMessage("在当前位置的50米范围内没有找到路口信息。");
                    SendMessage("若您的路口信息是全面的,则您所安放的位置偏离了路口过多,理论上不适合安放信号灯!");
                    SendMessage("分析结束");
                    return;
                }

                double lampHeight       = (double)spinEdit1.Value;
                double carHeight        = (double)spinEdit2.Value;
                double setHeight        = (double)spinEdit3.Value;
                double carLength        = (double)spinEdit4.Value;
                double lampMustDistance = (double)spinEdit5.Value;
                double roadWidth        = 30;

                roadWidth = Convert.ToDouble(fCross.get_Value(fClass.FindField("NorthWidth")));

                System.Threading.Thread.Sleep(1000);
                SendMessage("正在计算有大车情况下是否能在规定的最小必须可见距离内看到信号灯...");
                System.Threading.Thread.Sleep(1000);
                double lampMustHeight = (carHeight - setHeight) * lampMustDistance / (carLength + roadWidth) + setHeight;
                if (lampHeight < lampMustHeight)
                {
                    SendMessage(string.Format("  信号灯在有大车情况下不能在规定的最小距离内看到信号灯,必须在路对面增加辅助信号灯。"));
                    SendMessage("当前位置不合适安放信号灯或必须添加辅助信号灯!");
                    SendMessage("分析结束。");
                    return;
                }

                SendMessage("正在计算是否会因为建筑物及绿化带等引起信号灯盲区...");

                //int tempGroup = this.m_Hook.ProjectTree.FindItem(m_TempGroup);
                //if (tempGroup < 0)
                //{
                //    tempGroup = this.m_Hook.ProjectTree.CreateGroup(m_TempGroup);
                //}

                //IPosition61 position = m_Model.Position;
                //m_Hook.CoordServices.MoveCoordEx(ref position, 0, 0, lampHeight);
                //int analysisGroup = m_Hook.Analysis.CreateViewshed(position, 360, 1, roadWidth + lampMustDistance, setHeight, null, null, tempGroup, m_TempAnalysisName);
                //int invisibleItem = m_Hook.ProjectTree.FindItem(string.Format(@"{0}\{1}\Invisible Area",m_TempGroup,m_TempAnalysisName));
                //object obj = m_Hook.ProjectTree.GetObject(invisibleItem);

                System.Threading.Thread.Sleep(5000);
                if (Convert.ToInt32(fCross.get_Value(fClass.FindField("Flag"))) > 0)
                {
                    SendMessage("   由于建筑物及绿化带等将引起信号灯盲区,必须在路对面增加辅助信号灯.");
                    SendMessage("当前位置不合适安放信号灯或必须添加辅助信号灯!");
                    SendMessage("分析结束。");
                    return;
                }

                SendMessage("当前位置安放信号灯后不需要添加辅助信号灯!");
                SendMessage("分析结束。");
            }
            catch
            {
                SendMessage("分析过程出错了,分析结束");
            }
        }
Esempio n. 8
0
        private void LampAnalysis()
        {
            try
            {
                if (m_Model == null)
                {
                    MessageBox.Show("请先安放信号灯!");
                    return;
                }

                this.txtResult.Clear();
                Application.DoEvents();

                SendMessage("正在获取路口信息...");

                string lyr = ConfigurationManager.AppSettings["CrossLayer"];
                int lyrID = m_Hook.ProjectTree.FindItem(lyr);
                if (lyrID < 0)
                {
                    MessageBox.Show("您的配置有问题或者路口图层没有加载");
                    return;
                }

                ILayer61 teLayer = m_Hook.ProjectTree.GetLayer(lyrID);
                if (teLayer == null)
                {
                    return;
                }
                //IFeature61 tefCurrent = teLayer.FeatureGroups.Point[0] as IFeature61;

                // 严格来说要根据所点的位置来确定是哪个路口
                // 取第一个作为路口信息

                // 先直接从数据库中读取,模拟计算
                string strOld = teLayer.DataSourceInfo.ConnectionString;
                string[] strs = strOld.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                strOld = strs[0];
                strOld = strOld.Substring(strOld.IndexOf("=") + 1);
                string strFolder = System.IO.Path.GetDirectoryName(strOld);
                string strName = System.IO.Path.GetFileNameWithoutExtension(strOld);

                IWorkspaceFactory wsf = new ShapefileWorkspaceFactoryClass();
                IWorkspace wsShp= wsf.OpenFromFile(strFolder, 0);
                IFeatureClass fClass = (wsShp as IFeatureWorkspace).OpenFeatureClass(strName);

                IPosition61 position = m_Model.Position;
                ESRI.ArcGIS.Geometry.IPoint pModel = new ESRI.ArcGIS.Geometry.PointClass();
                pModel.SpatialReference = (fClass as IGeoDataset).SpatialReference;
                pModel.PutCoords(position.X, position.Y);

                ESRI.ArcGIS.Geometry.ITopologicalOperator topoOperator=pModel as ESRI.ArcGIS.Geometry.ITopologicalOperator;
                ESRI.ArcGIS.Geometry.IGeometry geoModel=topoOperator.Buffer(50);

                ISpatialFilter qFilter=new SpatialFilterClass();
                qFilter.Geometry=geoModel;
                qFilter.SpatialRel=esriSpatialRelEnum.esriSpatialRelIntersects;
                IFeatureCursor fCursor = fClass.Search(qFilter,false);
                IFeature fCross = fCursor.NextFeature();
                if (fCross == null)
                {
                    SendMessage("在当前位置的50米范围内没有找到路口信息。");
                    SendMessage("若您的路口信息是全面的,则您所安放的位置偏离了路口过多,理论上不适合安放信号灯!");
                    SendMessage("分析结束");
                    return;
                }

                double lampHeight = (double)spinEdit1.Value;
                double carHeight = (double)spinEdit2.Value;
                double setHeight = (double)spinEdit3.Value;
                double carLength = (double)spinEdit4.Value;
                double lampMustDistance = (double)spinEdit5.Value;
                double roadWidth = 30;

                roadWidth = Convert.ToDouble(fCross.get_Value(fClass.FindField("NorthWidth")));

                System.Threading.Thread.Sleep(1000);
                SendMessage("正在计算有大车情况下是否能在规定的最小必须可见距离内看到信号灯...");
                System.Threading.Thread.Sleep(1000);
                double lampMustHeight = (carHeight - setHeight) * lampMustDistance / (carLength + roadWidth) + setHeight;
                if (lampHeight < lampMustHeight)
                {
                    SendMessage(string.Format("  信号灯在有大车情况下不能在规定的最小距离内看到信号灯,必须在路对面增加辅助信号灯。"));
                    SendMessage("当前位置不合适安放信号灯或必须添加辅助信号灯!");
                    SendMessage("分析结束。");
                    return;
                }

                SendMessage("正在计算是否会因为建筑物及绿化带等引起信号灯盲区...");

                //int tempGroup = this.m_Hook.ProjectTree.FindItem(m_TempGroup);
                //if (tempGroup < 0)
                //{
                //    tempGroup = this.m_Hook.ProjectTree.CreateGroup(m_TempGroup);
                //}

                //IPosition61 position = m_Model.Position;
                //m_Hook.CoordServices.MoveCoordEx(ref position, 0, 0, lampHeight);
                //int analysisGroup = m_Hook.Analysis.CreateViewshed(position, 360, 1, roadWidth + lampMustDistance, setHeight, null, null, tempGroup, m_TempAnalysisName);
                //int invisibleItem = m_Hook.ProjectTree.FindItem(string.Format(@"{0}\{1}\Invisible Area",m_TempGroup,m_TempAnalysisName));
                //object obj = m_Hook.ProjectTree.GetObject(invisibleItem);

                System.Threading.Thread.Sleep(5000);
                if (Convert.ToInt32(fCross.get_Value(fClass.FindField("Flag"))) > 0)
                {
                    SendMessage("   由于建筑物及绿化带等将引起信号灯盲区,必须在路对面增加辅助信号灯.");
                    SendMessage("当前位置不合适安放信号灯或必须添加辅助信号灯!");
                    SendMessage("分析结束。");
                    return;
                }

                SendMessage("当前位置安放信号灯后不需要添加辅助信号灯!");
                SendMessage("分析结束。");
            }
            catch
            {
                SendMessage("分析过程出错了,分析结束");
            }
        }
Esempio n. 9
0
        // FeatureDataTablet to shapefile
        private void WriteFeatureDataTable2shp(GeometryType gtype, FeatureDataTable ftable, IFeatureClass fc, String shapefilePath)
        {
            int rowCount = ftable.Rows.Count;
            int colCount = ftable.Columns.Count;
            int geometryColIndex = ftable.GeometryColumnIndex;
            //GeometryType gtype = selLayer.GeometryType;
            toolStripProgressBar1.Maximum = rowCount;
            toolStripProgressBar1.Value = 0;
            toolStripProgressBar1.Visible = true;

            // for each selected features
            for (int i = 0; i < rowCount; i++)
            {
                toolStripProgressBar1.Value = i + 1;
                selectionStripStatusLabel1.Text = toolStripProgressBar1.Value.ToString() + "/" + rowCount.ToString() + " features exported .";
                toolStripStatusLabel2.Text = shapefilePath;
                Application.DoEvents();

                // create a new feature
                IFeature feature = fc.CreateFeature();
                DataRow arow = ftable.Rows[i];
                string globalid;
                if (arow.Table.Columns.Contains("GlobalID"))
                {
                    globalid = arow["GlobalID"].ToString();
                }
                else
                {
                    globalid = arow["OBJECTID"].ToString();
                }

                // geometry
                ESRI.ArcGIS.Mobile.Geometries.Geometry mobileGeometry = arow[geometryColIndex] as ESRI.ArcGIS.Mobile.Geometries.Geometry;
                byte[] mobileGeometryByteArray = mobileGeometry.ExportToEsriShape();
                int len = mobileGeometryByteArray.Length;
                switch (gtype)
                {
                    case GeometryType.Point:
                        ESRI.ArcGIS.Geometry.IPoint aoShape = new ESRI.ArcGIS.Geometry.PointClass();
                        ((ESRI.ArcGIS.Geometry.IESRIShape)aoShape).ImportFromESRIShape(ref len, ref mobileGeometryByteArray[0]);
                        feature.Shape = aoShape;
                        break;

                    case GeometryType.Multipoint:
                        ESRI.ArcGIS.Geometry.IMultipoint aoShape2 = new ESRI.ArcGIS.Geometry.MultipointClass();
                        ((ESRI.ArcGIS.Geometry.IESRIShape)aoShape2).ImportFromESRIShape(ref len, ref mobileGeometryByteArray[0]);
                        feature.Shape = aoShape2;
                        break;

                    case GeometryType.Polyline:
                        ESRI.ArcGIS.Geometry.IPolyline aoShape3 = new ESRI.ArcGIS.Geometry.PolylineClass();
                        ((ESRI.ArcGIS.Geometry.IESRIShape)aoShape3).ImportFromESRIShape(ref len, ref mobileGeometryByteArray[0]);
                        feature.Shape = aoShape3;
                        break;

                    case GeometryType.Polygon:
                        ESRI.ArcGIS.Geometry.IPolygon aoShape4 = new ESRI.ArcGIS.Geometry.PolygonClass();
                        ((ESRI.ArcGIS.Geometry.IESRIShape)aoShape4).ImportFromESRIShape(ref len, ref mobileGeometryByteArray[0]);
                        feature.Shape = aoShape4;
                        break;
                }

                // insert other attributes
                // in mobile cache, the last col is for geometry
                // in shapefile, fid and shape fields are first two, for other fields index = +2
                for (int col = 0; col < colCount - 1; col++)
                {
                    // type
                    DataColumn dc = ftable.Columns[col];
                    Type dt = dc.DataType;

                    // guid or globalid, change to string
                    if (dt == typeof(Guid) || (dt == typeof(ESRI.ArcGIS.Mobile.GlobalId)))
                    {
                        feature.set_Value(col + 2, arow[col].ToString());
                        //feature.Store();
                        continue;
                    }

                    // if blob field, write to file
                    if (dt == typeof(Byte[]))
                    {
                        continue;
                    }
                    // raster field, write to jpg files
                    if (dt == typeof(Bitmap))
                    {
                        string photofoldername = shapefilePath + "\\" + dc.ColumnName;
                        if (!Directory.Exists(photofoldername))
                            continue;

                        // get bitmap from a raster field, save to ImageSource
                        System.Windows.Media.ImageSource imgsrc = null;
                        Bitmap bitmap = arow[col] as Bitmap;
                        if (bitmap == null)
                            continue;

                        System.Windows.Int32Rect rect = new System.Windows.Int32Rect(0, 0, bitmap.Width, bitmap.Height);
                        IntPtr hBitmap = IntPtr.Zero;
                        try
                        {
                            hBitmap = bitmap.GetHbitmap();
                            imgsrc = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                                     hBitmap, IntPtr.Zero, rect, BitmapSizeOptions.FromEmptyOptions());

                            // write the ImageSource to jpg
                            if (imgsrc == null)
                                continue;
                            JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                            encoder.Frames.Add(BitmapFrame.Create(imgsrc as BitmapSource));
                            string fileName = photofoldername + "\\" + globalid + ".jpg";
                            using (System.IO.FileStream file = File.OpenWrite(fileName))
                            {
                                encoder.Save(file);
                            }

                            continue;

                        }
                        finally
                        {
                            if (hBitmap != IntPtr.Zero)
                                DeleteObject(hBitmap);
                        }
                    }  // end of bitmap

                    // other data types, just set the value
                    if (arow[col].ToString() != "")
                        feature.set_Value(col + 2, arow[col]);
                    else
                        feature.set_Value(col + 2, 0);

                }

                feature.Store();
            }

            //MessageBox.Show(rowCount.ToString() + " features saved into a shapefile at: " + shapefilePath);
            toolStripProgressBar1.Value = 0;
            selectionStripStatusLabel1.Text = "";
            toolStripProgressBar1.Visible = false;

            return;
        }
Esempio n. 10
0
        public BetterMarker(ESRI.ArcGIS.Geometry.IPoint mapPoint, string Text, double MapScale)
        {
            _Callout = new BalloonCallout();

            _Callout.AnchorPoint = mapPoint;

            ITextElement         pTextElement = new TextElementClass();
            IElement             pElement;
            IFillSymbol          pFill        = new SimpleFillSymbolClass();
            ILineSymbol          pLine        = new SimpleLineSymbolClass();
            IFormattedTextSymbol pLabelSymbol = new TextSymbolClass();

            IRgbColor c = new RgbColorClass();

            c.Red   = 0;
            c.Green = 0;
            c.Blue  = 0;

            IRgbColor d = new RgbColorClass();

            d.Red   = 255;
            d.Green = 255;
            d.Blue  = 255;

            IRgbColor e = new RgbColorClass();

            e.Red   = 205;
            e.Green = 192;
            e.Blue  = 176;

            pLine.Color   = c;
            pFill.Color   = d;
            pFill.Outline = pLine;

            this._Callout.Symbol = pFill;
            this._Callout.Style  = esriBalloonCalloutStyle.esriBCSRoundedRectangle;


            pLabelSymbol.Background    = this._Callout as ITextBackground;
            pLabelSymbol.Size          = 10.5d;
            pLabelSymbol.ShadowColor   = e;
            pLabelSymbol.ShadowXOffset = 1.0d;
            pLabelSymbol.ShadowYOffset = 1.0d;

            pTextElement.Text   = Text;
            pTextElement.Symbol = pLabelSymbol as ITextSymbol;

            pElement = pTextElement as IElement;
            double delta = (.1 * MapScale) / 2;

            //switch (mMap.MapScale)
            //{
            //    case
            //}

            ESRI.ArcGIS.Geometry.IPoint p1 = new ESRI.ArcGIS.Geometry.PointClass();
            p1.X = mapPoint.X + delta;
            p1.Y = mapPoint.Y + delta;


            pElement.Geometry = p1;

            this._Element = pElement;
        }