Exemplo n.º 1
0
 //绘制面
 void mGlobeControl_TrackPolygonAnalysisEndEvent(object sender, TrackPolygonEndEventArgs e)
 {
     if (e.Polygon != null)
     {
         if (layer != null && isSelectObject)
         {
             GSOFeatures feats = layer.FindFeaturesInPolygon(e.Polygon, false);
             if (feats != null && feats.Length > 0)
             {
                 SetDataTable(feats);
             }
             else
             {
                 MessageBox.Show("框选查询结果为空!", "提示");
             }
             globeControl1.Globe.ClearLastTrackPolygon();
             globeControl1.Globe.Refresh();
             return;
         }
     }
 }
        private void buttonOK_Click(object sender, EventArgs e)
        {
            string   filename = textbox1.Text.Trim();
            GSOLayer newlayer = mGlobeControl.Globe.Layers.Add(filename);

            int    indexCount      = filename.LastIndexOf('.') - filename.LastIndexOf('\\') - 1;
            string newlayerCaption = "";

            if (indexCount > 0)
            {
                newlayerCaption  = filename.Substring(filename.LastIndexOf('\\') + 1, indexCount);
                newlayer.Caption = newlayerCaption;
            }

            for (int i = 0; i < mListPolygon.Count; i++)
            {
                GSOGeoPolygon3D polygon = mListPolygon[i];
                string          caption = "";
                if (comboBoxLayerName.SelectedIndex >= 0)
                {
                    caption = comboBoxLayerName.SelectedItem.ToString().Trim();
                }
                GSOLayer    layer = mGlobeControl.Globe.Layers.GetLayerByCaption(caption);
                GSOFeatures feats = new GSOFeatures();
                if (layer != null)
                {
                    feats = layer.FindFeaturesInPolygon(polygon, false);
                }
                if (feats != null)
                {
                    newlayer.AddFeatures(feats);
                }
            }
            if (newlayer != null)
            {
                newlayer.SaveAs(filename);
                MessageBox.Show("导出成功!", "提示");
            }
            this.Close();
        }
        //应用
        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();
        }
Exemplo n.º 4
0
 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;
 }