Ejemplo n.º 1
0
        private bool RedrawHengChuanPolygon(TunnelHChuan entity)
        {
            //找到导线点图层
            IMap map = new MapClass();

            map = DataEditCommon.g_pMap;
            var           layerName    = LayerNames.DEFALUT_HENGCHUAN; //“默认_导线点”图层
            IFeatureLayer featureLayer = new FeatureLayerClass();

            featureLayer = LayerHelper.GetLayerByName(map, layerName); //获得图层

            if (featureLayer == null)
            {
                MessageBox.Show("没有找到" + layerName + "图层,将不能绘制导线点。", "提示", MessageBoxButtons.OK);
                return(false);
            }

            var point1 = new PointClass {
                X = entity.X1, Y = entity.Y1, Z = entity.Z1, ZAware = true
            };
            var point2 = new PointClass {
                X = entity.X2, Y = entity.Y2, Z = entity.Z2, ZAware = true
            };
            var line = new LineClass {
                FromPoint = point1, ToPoint = point2
            };
            var polygon = new PolygonClass {
                ZAware = true
            };
            var width = entity.Width / 2;

            polygon.AddPoint(ConstructPoint(point2, line.Angle / Deg2Rad + 90, width));
            polygon.AddPoint(ConstructPoint(point2, line.Angle / Deg2Rad - 90, width));
            polygon.AddPoint(ConstructPoint(point1, line.Angle / Deg2Rad + 180 + 90, width));
            polygon.AddPoint(ConstructPoint(point1, line.Angle / Deg2Rad + 180 - 90, width));
            polygon.SimplifyPreserveFromTo();

            var list = new List <ziduan>
            {
                new ziduan("BID", entity.Id.ToString()),
                new ziduan("BID0", entity.TunnelId1.ToString()),
                new ziduan("BID1", entity.TunnelId2.ToString()),
                new ziduan("NAME", entity.NameHChuan)
            };

            var feature = DataEditCommon.ModifyFeature(featureLayer, entity.Id, polygon, list);

            return(feature != null);
        }