Beispiel #1
0
 public override bool CheckPermission()
 {
     return(WorkSpaceServices.Instance().HasMenuAuth(this.CommandID));
 }
Beispiel #2
0
        private void HorizontalSectionAnalysis()
        {
            ILineString line = this._drawTool.GetGeo2D() as ILineString;

            if (line.Length > _maxLength)
            {
                XtraMessageBox.Show(string.Format("断面长度不超过{0}米!", _maxLength), "提示");
                return;
            }
            ICoord2D startCoord = null;

            if (line.Points.Count == 2)
            {
                IPoint startPt = line.StartPoint;
                startCoord = RenderControlServices.Instance().CovertCoord(startPt.X, startPt.Y);
            }
            else
            {
                return;
            }
            WaitForm.Start("正在进行横断面分析...", "请稍后", false);
            List <InterPointInfo> listInter = new List <InterPointInfo>();

            foreach (Layer l in WorkSpaceServices.Instance().PipeLineLayers)
            {
                if (!l.Show && l.ShpLayer == null)
                {
                    continue;
                }
                l.ShowShp = true;
                Field fDiameter = WorkSpaceServices.Instance().GetFieldBySysField(l, SystemField.PIPELINE_DIAMETER[1]);
                Field fClassify = WorkSpaceServices.Instance().GetFieldBySysField(l, SystemField.CLASSIFY[1]);
                Field fMaterial = WorkSpaceServices.Instance().GetFieldBySysField(l, SystemField.MATERIAL[1]);
                Field fHlb      = WorkSpaceServices.Instance().GetFieldBySysField(l, SystemField.HLB[1]);
                if (fDiameter == null || fMaterial == null || fHlb == null)
                {
                    continue;
                }

                IFeatures65 fs = l.ShpLayer.ExecuteSpatialQuery(line, IntersectionType.IT_INTERSECT);
                for (int i = 0; i < fs.Count; i++)
                {
                    IFeature65 f   = fs[i] as IFeature65;
                    IGeometry  geo = f.Geometry;

                    IGeometry inter = line.SpatialOperator.Intersection(geo);// 平面相交
                    if (inter.GeometryType == SGGeometryTypeId.SG_POINT)
                    {
                        IPoint   pt         = inter as IPoint;
                        ICoord2D coordInter = RenderControlServices.Instance().CovertCoord(pt.X, pt.Y);
                        double   height     = 0.0;
                        if (geo.GeometryType == SGGeometryTypeId.SG_LINESTRING)
                        {
                            ILineString geoLine = geo as ILineString;
                            if (geoLine.Points.Count == 2)
                            {
                                double   startPtH = geoLine.StartPoint.Z;
                                double   endPtH   = geoLine.EndPoint.Z;
                                ICoord2D sc       = RenderControlServices.Instance().CovertCoord(geoLine.StartPoint.X, geoLine.StartPoint.Y);
                                ICoord2D ec       = RenderControlServices.Instance().CovertCoord(geoLine.EndPoint.X, geoLine.EndPoint.Y);
                                height = GetInterectPointHeight(sc, startPtH, ec, endPtH, coordInter);
                            }
                            else
                            {
                                continue;
                            }
                        }

                        IWorldPointInfo65 wpi = RenderControlServices.Instance().SGWorld.Terrain.GetGroundHeightInfo(pt.X, pt.Y, AccuracyLevel.ACCURACY_NORMAL, false);

                        InterPointInfo interPtInfo = new InterPointInfo();
                        interPtInfo.pt              = pt;
                        interPtInfo.terrainHeight   = wpi.Position.Altitude;
                        interPtInfo.height          = height;
                        interPtInfo.coordInter      = coordInter;
                        interPtInfo.distance        = Math.Sqrt((coordInter.X - startCoord.X) * (coordInter.X - startCoord.X) + (coordInter.Y - startCoord.Y) * (coordInter.Y - startCoord.Y));
                        interPtInfo.color.abgrColor = Convert.ToUInt32(l.ShpLayer.FeatureGroups.Polyline.GetProperty("Line Color").ToString());
                        interPtInfo.layerName       = l.Name;
                        interPtInfo.diameter        = f.FeatureAttributes.GetFeatureAttribute(fDiameter.Name).Value;
                        interPtInfo.classify        = f.FeatureAttributes.GetFeatureAttribute(fClassify.Name).Value;
                        interPtInfo.material        = f.FeatureAttributes.GetFeatureAttribute(fMaterial.Name).Value;
                        interPtInfo.hlb             = f.FeatureAttributes.GetFeatureAttribute(fHlb.Name).Value;
                        listInter.Add(interPtInfo);
                    }
                }
                l.ShowShp = false;
            }
            WaitForm.Stop();

            if (listInter.Count > 0)
            {
                listInter.Sort(new ComparerInterPointInfo());

                for (int i = 0; i < listInter.Count; i++)
                {
                    InterPointInfo info = listInter[i];
                    info.no = (i + 1);
                    if (info.no > 1)
                    {
                        info.interHDist = info.distance - listInter[i - 1].distance;
                    }

                    IPosition65   pos    = RenderControlServices.Instance().SGWorld.Creator.CreatePosition(info.pt.X, info.pt.Y);
                    ILabelStyle65 lStyle = RenderControlServices.Instance().SGWorld.Creator.CreateLabelStyle();
                    lStyle.TextColor        = info.color;
                    lStyle.FontSize         = 10;
                    lStyle.MaxViewingHeight = 1000;
                    ITerrainLabel65 label = RenderControlServices.Instance().SGWorld.Creator.CreateTextLabel(pos, info.no.ToString(), lStyle);
                    label.Visibility.MaxVisibilityDistance = 1000;
                    this._listLabel.Add(label);
                }
                DrawHorizontalSection(listInter);
            }
        }