コード例 #1
0
        private void Export(GSOPoint3d _pnt, double r)
        {
            GSOPoint3ds pnts = new GSOPoint3ds();
            GSOPoint3d  pnt  = new GSOPoint3d();

            pnt.X = _pnt.X;
            pnt.Y = _pnt.Y;
            pnt.Z = _pnt.Z;
            pnts.Add(pnt);
            pnt.X = _pnt.X;
            pnt.Y = _pnt.Y - 0.0000000005;
            pnt.Z = _pnt.Z;
            pnts.Add(pnt);
            GSOGeoPolyline3D line = new GSOGeoPolyline3D();

            line.AddPart(pnts);
            GSOGeoPolygon3D  polygon = line.CreateBuffer(r * 2, true, 5, true, false);
            GSOPoint3ds      points  = polygon[0];
            GSOGeoPolyline3D newLine = new GSOGeoPolyline3D();

            newLine.AddPart(points);
            newLine.AltitudeMode = EnumAltitudeMode.RelativeToGround;
            GSOFeature newFeature = new GSOFeature();

            newFeature.Geometry = newLine;
            globeControl1.Globe.MemoryLayer.AddFeature(newFeature);
            // globeControl1.Globe.FlyToFeature(f);
        }
コード例 #2
0
        private void makeBuffer(GSOFeature feature)
        {
            double radius        = (double)numericUpDownRadius.Value;  //缓冲区宽度
            double value         = (double)numericUpDownFenDuan.Value; //圆角角度
            bool   isRoundCorner = CBRoundCorner.Checked;              //拐角是否圆滑
            bool   isRoundEnds   = CBRoundEnds.Checked;                //两端是否圆滑

            GSOGeoPolygon3D buffer = null;                             //创建缓冲面

            if (feature.Geometry.Type == EnumGeometryType.GeoMarker)   //如果要素为点
            {
                GSOGeoMarker marker = feature.Geometry as GSOGeoMarker;
                buffer = marker.CreateBuffer(radius, value, false);
                //创建点的缓冲面(宽度,角度,false)
            }
            else if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
            {
                GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D;
                buffer = line.CreateBuffer(radius, isRoundCorner, value, isRoundEnds, false);
                //创建线的缓冲面(宽度,拐角圆滑,角度,两端圆滑,false)
            }
            else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D)
            {
                GSOGeoPolygon3D polygon = feature.Geometry as GSOGeoPolygon3D;
                buffer = polygon.CreateBuffer(radius, isRoundCorner, value, isRoundEnds, false);
                //创建面的缓冲面(宽度,拐角圆滑,角度,两端圆滑,false)
            }

            if (buffer != null)
            {
                //缓冲面颜色
                GSOSimplePolygonStyle3D style = new GSOSimplePolygonStyle3D();
                style.FillColor = Color.FromArgb(122, Color.Yellow);
                //缓冲线颜色
                GSOSimpleLineStyle3D outlineStyle = new GSOSimpleLineStyle3D();
                outlineStyle.LineColor = Color.Red;
                style.OutlineStyle     = outlineStyle;
                buffer.Style           = style;
                GSOFeature featureBuffer = new GSOFeature();
                featureBuffer.Geometry = buffer;
                featureBuffer.Name     = feature.Name + "_" + radius + "米_Buffer";
                globeControl1.Globe.MemoryLayer.AddFeature(featureBuffer);

                //重新创建原有要素,使得要素在缓冲面上方,可选择
                if (feature != null && feature.Dataset.Type == EnumDatasetType.Memory && feature.Dataset.Caption == "" && feature.Dataset.Name == "")
                {
                    GSOFeature featureSelectCopy = feature.Clone();
                    globeControl1.Globe.MemoryLayer.AddFeature(featureSelectCopy);
                    feature.Delete();
                }
                globeControl1.Refresh();
            }
        }
コード例 #3
0
 private void Export(GSOPoint3d _pnt, double r)
 {
     GSOPoint3ds pnts = new GSOPoint3ds();
     GSOPoint3d pnt = new GSOPoint3d();
     pnt.X = _pnt.X;
     pnt.Y = _pnt.Y;
     pnt.Z = _pnt.Z;
     pnts.Add(pnt);
     pnt.X = _pnt.X;
     pnt.Y = _pnt.Y - 0.0000000005;
     pnt.Z = _pnt.Z;
     pnts.Add(pnt);
     GSOGeoPolyline3D line = new GSOGeoPolyline3D();
     line.AddPart(pnts);
     GSOGeoPolygon3D polygon = line.CreateBuffer(r * 2, true, 5, true, false);
     GSOPoint3ds points = polygon[0];
     GSOGeoPolyline3D newLine = new GSOGeoPolyline3D();
     newLine.AddPart(points);
     newLine.AltitudeMode = EnumAltitudeMode.RelativeToGround;
     GSOFeature newFeature = new GSOFeature();
     newFeature.Geometry = newLine;
     globeControl1.Globe.MemoryLayer.AddFeature(newFeature);
        // globeControl1.Globe.FlyToFeature(f);
 }
コード例 #4
0
        //应用
        private void buttonApply_Click(object sender, EventArgs e)
        {
            if (comboBoxLayerCaption.SelectedItem == null)
            {
                MessageBox.Show("请选择一个管线图层!", "提示");
                return;
            }
            if (comboBoxLayerValveCaption.SelectedItem == null)
            {
                MessageBox.Show("请选择一个工井图层!", "提示");
                return;
            }
            if (textBoxValueIndented.Text.Trim() == "")
            {
                MessageBox.Show("请输入缩进距离!", "提示");
                return;
            }
            if (textBoxAllowance.Text.Trim() == "")
            {
                MessageBox.Show("请输入容限值!", "提示");
                return;
            }

            double valueAllowance = 0.0;
            if (double.TryParse(textBoxAllowance.Text.Trim(), out valueAllowance) == false)
            {
                MessageBox.Show("请输入一个正确的容限值!", "提示");
                return;
            }

            float valueIndented = 0.0f;
            if (float.TryParse(textBoxValueIndented.Text.Trim(), out valueIndented) == false)
            {
                MessageBox.Show("请输入一个正确的缩进值!", "提示");
                return;
            }

            string layerCaption = comboBoxLayerCaption.SelectedItem.ToString().Trim();
            string valveLayerCaption = comboBoxLayerValveCaption.SelectedItem.ToString().Trim();
            GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerCaption);
            GSOLayer valveLayer = globeControl1.Globe.Layers.GetLayerByCaption(valveLayerCaption);
            if (layer != null && valveLayerCaption != null)
            {
                featuresIndented.RemoveAll();
                cancelHighLight(layer.GetAllFeatures());

                for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                {
                    GSOFeature feature = layer.GetAt(i);
                    if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
                    {
                        GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D;
                        double lineLenght = line.GetSpaceLength(false, 6378137.0);
                        if (lineLenght <= valueIndented * 2)
                        {
                            continue;
                        }

                        featuresIndented.Add(feature);//缩进的管线集合
                        featuresInit.Add(feature.Clone());

                        //头缩进
                        GSOPoint3d headPoint = line[0][0];
                        GSOGeoPolyline3D newline = new GSOGeoPolyline3D();
                        GSOPoint3ds part = new GSOPoint3ds();
                        part.Add(headPoint);
                        headPoint.X = headPoint.X - 0.0000000005;
                        part.Add(headPoint);
                        newline.AddPart(part);
                        GSOGeoPolygon3D buffer = newline.CreateBuffer(valueAllowance, true, 5, true, false);
                        GSOFeatures features = valveLayer.FindFeaturesInPolygon(buffer, false);
                        if (features.Length > 0)
                        {
                            feature.HighLight = true;
                            if (line.Style != null && line.Style is GSOPipeLineStyle3D)
                            {
                                GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D;
                                style.HeadJointParam = new GSOPipeJointParam();
                                style.HeadJointParam.Extent = -valueIndented;
                            }
                        }

                        //尾缩进
                        GSOPoint3d tailPoint = line[line.PartCount - 1][line[line.PartCount - 1].Count - 1];
                        newline = new GSOGeoPolyline3D();
                        part = new GSOPoint3ds();
                        part.Add(tailPoint);
                        tailPoint.X = tailPoint.X - 0.0000000005;
                        part.Add(tailPoint);
                        newline.AddPart(part);
                        buffer = newline.CreateBuffer(valueAllowance, true, 5, true, false);
                        features = valveLayer.FindFeaturesInPolygon(buffer, false);
                        if (features.Length > 0)
                        {
                            feature.HighLight = true;
                            if (line.Style != null && line.Style is GSOPipeLineStyle3D)
                            {
                                GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D;
                                style.TailJointParam = new GSOPipeJointParam();
                                style.TailJointParam.Extent = -valueIndented;
                            }
                        }
                    }
                }
            }
            globeControl1.Globe.Refresh();
        }
コード例 #5
0
        //应用
        private void buttonApply_Click(object sender, EventArgs e)
        {
            if (comboBoxLayerCaption.SelectedItem == null)
            {
                MessageBox.Show("请选择一个管线图层!", "提示");
                return;
            }
            if (comboBoxLayerValveCaption.SelectedItem == null)
            {
                MessageBox.Show("请选择一个工井图层!", "提示");
                return;
            }
            if (textBoxValueIndented.Text.Trim() == "")
            {
                MessageBox.Show("请输入缩进距离!", "提示");
                return;
            }
            if (textBoxAllowance.Text.Trim() == "")
            {
                MessageBox.Show("请输入容限值!", "提示");
                return;
            }

            double valueAllowance = 0.0;

            if (double.TryParse(textBoxAllowance.Text.Trim(), out valueAllowance) == false)
            {
                MessageBox.Show("请输入一个正确的容限值!", "提示");
                return;
            }

            float valueIndented = 0.0f;

            if (float.TryParse(textBoxValueIndented.Text.Trim(), out valueIndented) == false)
            {
                MessageBox.Show("请输入一个正确的缩进值!", "提示");
                return;
            }

            string   layerCaption      = comboBoxLayerCaption.SelectedItem.ToString().Trim();
            string   valveLayerCaption = comboBoxLayerValveCaption.SelectedItem.ToString().Trim();
            GSOLayer layer             = globeControl1.Globe.Layers.GetLayerByCaption(layerCaption);
            GSOLayer valveLayer        = globeControl1.Globe.Layers.GetLayerByCaption(valveLayerCaption);

            if (layer != null && valveLayerCaption != null)
            {
                featuresIndented.RemoveAll();
                cancelHighLight(layer.GetAllFeatures());


                for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                {
                    GSOFeature feature = layer.GetAt(i);
                    if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
                    {
                        GSOGeoPolyline3D line       = feature.Geometry as GSOGeoPolyline3D;
                        double           lineLenght = line.GetSpaceLength(false, 6378137.0);
                        if (lineLenght <= valueIndented * 2)
                        {
                            continue;
                        }

                        featuresIndented.Add(feature);//缩进的管线集合
                        featuresInit.Add(feature.Clone());

                        //头缩进
                        GSOPoint3d       headPoint = line[0][0];
                        GSOGeoPolyline3D newline   = new GSOGeoPolyline3D();
                        GSOPoint3ds      part      = new GSOPoint3ds();
                        part.Add(headPoint);
                        headPoint.X = headPoint.X - 0.0000000005;
                        part.Add(headPoint);
                        newline.AddPart(part);
                        GSOGeoPolygon3D buffer   = newline.CreateBuffer(valueAllowance, true, 5, true, false);
                        GSOFeatures     features = valveLayer.FindFeaturesInPolygon(buffer, false);
                        if (features.Length > 0)
                        {
                            feature.HighLight = true;
                            if (line.Style != null && line.Style is GSOPipeLineStyle3D)
                            {
                                GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D;
                                style.HeadJointParam        = new GSOPipeJointParam();
                                style.HeadJointParam.Extent = -valueIndented;
                            }
                        }

                        //尾缩进
                        GSOPoint3d tailPoint = line[line.PartCount - 1][line[line.PartCount - 1].Count - 1];
                        newline = new GSOGeoPolyline3D();
                        part    = new GSOPoint3ds();
                        part.Add(tailPoint);
                        tailPoint.X = tailPoint.X - 0.0000000005;
                        part.Add(tailPoint);
                        newline.AddPart(part);
                        buffer   = newline.CreateBuffer(valueAllowance, true, 5, true, false);
                        features = valveLayer.FindFeaturesInPolygon(buffer, false);
                        if (features.Length > 0)
                        {
                            feature.HighLight = true;
                            if (line.Style != null && line.Style is GSOPipeLineStyle3D)
                            {
                                GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D;
                                style.TailJointParam        = new GSOPipeJointParam();
                                style.TailJointParam.Extent = -valueIndented;
                            }
                        }
                    }
                }
            }
            globeControl1.Globe.Refresh();
        }
コード例 #6
0
ファイル: MainFrm.cs プロジェクト: StarU/qkKL6Dgf12
 private GSOFeatures getFeatureByPolygon(GSOLayer layer,GSOFeatures features, GSOPoint3d point, double allowValue)
 {
     if (layer == null || point == null || allowValue <= 0)
     {
         return null;
     }
     GSOGeoPolyline3D bufferLine = new GSOGeoPolyline3D();
     GSOPoint3ds points = new GSOPoint3ds();
     points.Add(point);
     GSOPoint3d newPoint = new GSOPoint3d();
     newPoint.X = point.X + 0.00001;
     newPoint.Y = point.Y;
     newPoint.Z = point.Z;
     points.Add(newPoint);
     bufferLine.AddPart(points);
     GSOGeoPolygon3D polygon = bufferLine.CreateBuffer(allowValue, true, 12, false, false);
     layer.RemoveAllFeature();
     layer.AddFeatures(features);
     GSOFeatures featuresInPolygon = layer.FindFeaturesInPolygon(polygon, false);
     return featuresInPolygon;
 }