public void SetRegionPoint()
        {
            try
            {
                if (m_workspace.Datasources[0].Datasets.Contains("New_Point3D"))
                {
                    DatasetVector datasetPoint3D = m_workspace.Datasources[0].Datasets["New_Point3D"] as DatasetVector;

                    if (m_sceneControl.Scene.Layers.Contains("New_Point3D@gongyuan"))
                    {
                        m_sceneControl.Scene.Layers.Remove("New_Point3D@gongyuan");
                    }

                    {
                        Layer3DSettingVector pointSetting = new Layer3DSettingVector();
                        pointSetting.Style.AltitudeMode      = AltitudeMode.RelativeToGround;
                        pointSetting.Style.MarkerSize        = 1;
                        pointSetting.Style.IsMarkerSizeFixed = true;
                        pointSetting.Style.MarkerScale       = 1;
                        pointSetting.Style.MarkerSymbolID    = m_marker3DIndex;
                        pointSetting.Style.IsMarker3D        = true;
                        m_layer3DRegionPoint = m_sceneControl.Scene.Layers.Add(datasetPoint3D, pointSetting, true, "New_Point3D@gongyuan");
                    }

                    m_layer3DRegionPoint.UpdateData();
                    m_sceneControl.Scene.Refresh();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        //刷新风格
        private void RefreshStyle()
        {
            if (m_layer3D == null)
            {
                return;
            }

            if (m_bSelection)
            {
                m_layer3D.Selection.Style = m_style3D;
                m_layer3D.Selection.UpdateData();
            }
            else
            {
                if (m_layer3D.Type == Layer3DType.Dataset)
                {
                    Layer3DDataset layer3DDataset = m_layer3D as Layer3DDataset;
                    //layer3DDataset.IsEditable = true;
                    Layer3DSettingVector layerSetting = layer3DDataset.AdditionalSetting as Layer3DSettingVector;
                    layerSetting.Style = m_style3D;
                    layer3DDataset.AdditionalSetting = layerSetting;
                    layer3DDataset.UpdateData();
                }
                else if (m_layer3D.Type == Layer3DType.VectorFile)
                {
                    Layer3DVectorFile    layer3DFile  = m_layer3D as Layer3DVectorFile;
                    Layer3DSettingVector layerSetting = layer3DFile.AdditionalSetting as Layer3DSettingVector;
                    layerSetting.Style            = m_style3D;
                    layer3DFile.AdditionalSetting = layerSetting;
                    layer3DFile.UpdateData();
                }
                this.m_sceneControl.Scene.Refresh();
            }
        }
        /// <summary>
        /// 设置三维点符号
        /// </summary>
        public void SettingPoint3D(int Marker3DIndex)
        {
            isDraw          = true;
            m_marker3DIndex = Marker3DIndex;

            try
            {
                flag = false;

                // 新建数据集
                if (m_workspace.Datasources[0].Datasets.Contains("Point3D"))
                {
                    DatasetVector datasetPoint3D = m_workspace.Datasources[0].Datasets["Point3D"] as DatasetVector;

                    if (m_sceneControl.Scene.Layers.Contains("stylePoint3D"))
                    {
                        m_layer3DPoint = m_sceneControl.Scene.Layers["stylePoint3D"] as Layer3DDataset;
                    }
                    else
                    {
                        m_layer3DPoint = m_sceneControl.Scene.Layers.Add(datasetPoint3D, new Layer3DSettingVector(), true, "stylePoint3D");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 /// <summary>
 /// 寻找目标点,进行飞行
 /// </summary>
 public void TargetPoint()
 {
     try
     {
         if (mFlyPoint3D.X == 0 && mFlyPoint3D.Y == 0 && mFlyPoint3D.Z == 0)
         {
             Layer3Ds       bd_3DLayers      = mSceneControl.Scene.Layers;
             Layer3DDataset bd_3DLayer       = bd_3DLayers[0] as Layer3DDataset;
             double         bd_3DLayerHeight = bd_3DLayer.Bounds.Height;
             double         bd_3DLayerWidth  = bd_3DLayer.Bounds.Width;
             int            PointX           = (int)(bd_3DLayer.Bounds.Left + bd_3DLayerWidth / 2);
             int            PointY           = (int)(bd_3DLayer.Bounds.Bottom + bd_3DLayerHeight / 2);
             Point          FlyPoint         = new Point(PointX, PointY);
             mFlyPoint3D = mSceneControl.Scene.PixelToGlobe(FlyPoint);
             FlyTo(200, mFlyPoint3D.X, mFlyPoint3D.Y, 0);
         }
         else
         {
             FlyTo(200, mFlyPoint3D.X, mFlyPoint3D.Y, 0);
         }
     }
     catch (Exception)
     {
     }
 }
Exemple #5
0
        public void AddDatasetToScene(string datasetName)
        {
            try
            {
                scontrol.Scene.Layers.Clear();
                scontrol.Scene.TerrainLayers.Clear();

                if (!String.IsNullOrEmpty(datasetName))
                {
                    Layer3DSetting layer3dSetting = new Layer3DSettingGrid();

                    //m_maxGridVaule = (m_datasource.Datasets[datasetName] as DatasetGrid).MaxValue;
                    scontrol.Scene.TerrainLayers.Add((DatasetGrid)m_datasource.Datasets[datasetName], true);
                    // m_sceneControl.Scene.TerrainExaggeration = 2;


                    Layer3DDataset layer3d = scontrol.Scene.Layers.Add(m_datasource.Datasets[datasetName], layer3dSetting, true);
                    //if (datasetName.Equals("gridAspectResult"))
                    //{
                    //    ChangeAspectResultColorTable(layer3d.Name);
                    //}
                    //else if (datasetName.Equals("gridSlopeResult"))
                    //{
                    //    ChangeSlopeResultColorTable(layer3d.Name);
                    //}
                    scontrol.Scene.EnsureVisible(m_datasource.Datasets[datasetName].Bounds);
                    scontrol.Scene.Refresh();
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
 public void OwnerBar()
 {
     try
     {
         Layer3Ds       mLayer3D = mSceneControl.Scene.Layers;
         Layer3DDataset mLayer   = null;
         Recordset      mRecord  = null;
         DatasetVector  mData    = null;
         String         str      = "";
         String         str1     = "";
         for (int i = 0; i < mOwnerStatist.GetPipeStatist.Count; i++)
         {
             mLayer = mLayer3D[mOwnerStatist.GetPipeStatist[i].ToString() + "@" + mDataSourceName] as Layer3DDataset;
             mData  = mLayer.Dataset as DatasetVector;
             for (int k = 0; k < mOwnerStatist.GetOwnerStatist.Count; k++)
             {
                 mRecord = mData.Query("OwnerShip='" + mOwnerStatist.GetOwnerStatist[k].ToString() + "'", CursorType.Dynamic);
                 mOwnerCount.Add(mRecord.RecordCount.ToString());
             }
         }
         OwnerCreate();
     }
     catch (System.Exception ex)
     {
         Trace.WriteLine(ex.Message);
     }
 }
Exemple #7
0
 private void ThemeControl_Load(object sender, EventArgs e)
 {
     try
     {
         chkTheme.Items.Clear();
         List <Label> lstData = new List <Label>();
         if (m_Application.MainForm.FormManager.ActiveForm is IFormScene formScene)
         {
             m_SceneControl = formScene.SceneControl;
             foreach (Layer3D layer in formScene.SceneControl.Scene.Layers)
             {
                 if (layer is Layer3DDataset)
                 {
                     Layer3DDataset layer3DDataset = layer as Layer3DDataset;
                     if (layer3DDataset.Theme != null && layer3DDataset.Theme is Theme3D)
                     {
                         lstData.Add(new Label {
                             Text = layer3DDataset.Caption, Tag = layer3DDataset
                         });
                     }
                 }
             }
         }
         chkTheme.DataSource    = lstData;
         chkTheme.DisplayMember = "Text";
         chkTheme.ValueMember   = "Tag";
         chkTheme.SetItemChecked(0, true);
     }
     catch (Exception ex)
     {
         Log.OutputBox(ex);
     }
 }
        /// <summary>
        /// 设置三维水面符号
        /// </summary>
        public void SettingRegion3D(int region3DIndex, bool point)
        {
            isRegion        = true;
            flag            = true;
            ispointRegion   = point;
            m_region3DIndex = region3DIndex;
            try
            {
                m_sceneControl.Action = Action3D.MeasureArea;

                // 新建数据集
                if (m_workspace.Datasources[0].Datasets.Contains("Region3D"))
                {
                    DatasetVector datasetRegion3D = m_workspace.Datasources[0].Datasets["Region3D"] as DatasetVector;

                    if (m_sceneControl.Scene.Layers.Contains("styleRegion3D"))
                    {
                        m_layer3DRegion = m_sceneControl.Scene.Layers["styleRegion3D"] as Layer3DDataset;
                    }
                    else
                    {
                        m_layer3DRegion = m_sceneControl.Scene.Layers.Add(datasetRegion3D, new Layer3DSettingVector(), true, "styleRegion3D");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #9
0
        private void GetData()
        {
            Recordset objRt = null;

            try
            {
                dg_Data.Rows.Clear();
                dg_Data.Columns.Clear();
                if (chkTheme.SelectedItem == null)
                {
                    m_Application.MessageBox.Show(Message);
                    return;
                }
                Layer3DDataset layer3DDataset = (chkTheme.SelectedItem as Label).Tag as Layer3DDataset;
                objRt = (layer3DDataset.Dataset as DatasetVector).GetRecordset(false, CursorType.Static);
                for (int i = 0; i < objRt.FieldCount; i++)
                {
                    FieldInfo fieldInfo = objRt.GetFieldInfos()[i];
                    if (fieldInfo.Caption.ToLower().Contains("sm"))
                    {
                        continue;
                    }
                    dg_Data.Columns.Add(fieldInfo.Name, fieldInfo.Caption);
                }

                objRt.MoveFirst();
                while (!objRt.IsEOF)
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.HeaderCell.Value = objRt.GetID().ToString();
                    for (int j = 0; j < dg_Data.ColumnCount; j++)
                    {
                        DataGridViewTextBoxCell textBoxCell = new DataGridViewTextBoxCell
                        {
                            Value = Convert.ToString(objRt.GetFieldValue(dg_Data.Columns[j].Name))
                        };
                        row.Cells.Add(textBoxCell);
                    }
                    dg_Data.Rows.Add(row);

                    objRt.MoveNext();
                }
            }
            catch (Exception ex)
            {
                Log.OutputBox(ex);
            }
            finally
            {
                if (objRt != null)
                {
                    objRt.Close();
                    objRt.Dispose();
                }
            }
        }
        public void BufferQuery()
        {
            try
            {
                Datasource    datasource      = mUseData.DataSource;
                DatasetVector mRegionDatasets = datasource.Datasets["New_Model"] as DatasetVector;
                mRegionDatasets.PrjCoordSys = datasource.Datasets[0].PrjCoordSys;
                String bufferName = "bufferModel";
                if (datasource.Datasets.Contains(bufferName))
                {
                    datasource.Datasets.Delete(bufferName);
                }
                mBufferDataset = (DatasetVector)datasource.Datasets.CreateFromTemplate(bufferName, mRegionDatasets);


                #region 设置矢量面初始样式

                GeoStyle3D style3D = new GeoStyle3D();

                style3D.AltitudeMode  = AltitudeMode.ClampToGround;
                style3D.FillForeColor = Color.White;
                style3D.FillMode      = FillMode3D.LineAndFill;

                Layer3DSettingVector layer3DSetting = new Layer3DSettingVector();
                layer3DSetting.Style = style3D;
                Layer3DDataset m_layerRegion = mSceneControl.Scene.Layers.Add(mRegionDatasets, layer3DSetting, true);
                #endregion



                QueryParameter para = new QueryParameter();
                para.SpatialQueryMode   = SpatialQueryMode.Intersect;
                para.SpatialQueryObject = mBufferDataset;

                Recordset recordset = mRegionDatasets.Query(para);

                List <Int32> ids = new List <int>(recordset.RecordCount);

                while (!recordset.IsEOF)
                {
                    ids.Add(recordset.GetID());
                    recordset.MoveNext();
                }
                m_layerRegion.Selection.AddRange(ids.ToArray());
                m_layerRegion.Selection.UpdateData();

                m_layerRegion.Selection.Style.FillForeColor = Color.FromArgb(180, 100, 100, 255);
                mSceneControl.Scene.Refresh();

                recordset.Dispose();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Exemple #11
0
        /// <summary>
        /// 找出横断面线与管线相交的断点
        /// </summary>
        public void CrossSecLine()
        {
            try
            {
                Layer3Ds m_layer = mSceneControl.Scene.Layers;
                foreach (Layer3D mlayer in m_layer)
                {
                    if (mlayer.Selection != null)
                    {
                        mlayer.Selection.Clear();
                    }
                }

                QueryParameter para = new QueryParameter();
                para.HasGeometry        = true;
                para.SpatialQueryMode   = SpatialQueryMode.Intersect;
                para.SpatialQueryObject = mRec2D;
                Recordset      recordset = null;
                Layer3DDataset layer     = null;

                switch (mPipeType[0].ToString())
                {
                case "排水管网":
                    recordset = mUseData.OutWaterNetWork.Query(para);
                    layer     = mUseData.OutWaterLines;
                    break;

                case "给水管网":
                    recordset = mUseData.SupplyWaterNetWork.Query(para);
                    layer     = mUseData.SupplyWaterLines;
                    break;

                case "电力管网":
                    recordset = mUseData.ElectricNetWork.Query(para);
                    layer     = mUseData.ElectricLayer;
                    break;
                }

                List <Int32> ids = new List <int>(recordset.RecordCount);
                while (!recordset.IsEOF)
                {
                    ids.Add(recordset.GetID());
                    recordset.MoveNext();
                }
                layer.Selection.AddRange(ids.ToArray());
                layer.Selection.UpdateData();
                layer.Selection.Style.LineColor = Color.GreenYellow;
                mSceneControl.Scene.Refresh();
            }
            catch (Exception ex)
            {
                Trace.Write(ex.Message);
            }
        }
Exemple #12
0
        private void DlgOSGBQuery_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.ClearResult();

            if (m_layerSrcRegion != null)
            {
                m_sceneControl.Scene.Layers.Remove(m_layerSrcRegion.Name);
                m_layerResultDataset = null;
            }
            m_sceneControl.ObjectSelected -= new SuperMap.UI.ObjectSelectedEventHandler(m_sceneControl_ObjectSelected);
        }
Exemple #13
0
        private void btn_Commit_Click(object sender, EventArgs e)
        {
            Recordset objRt = null;

            try
            {
                if (chkTheme.SelectedItem == null)
                {
                    m_Application.MessageBox.Show(Message);
                    return;
                }
                Layer3DDataset layer3DDataset = (chkTheme.SelectedItem as Label).Tag as Layer3DDataset;
                objRt = (layer3DDataset.Dataset as DatasetVector).GetRecordset(false, CursorType.Dynamic);
                foreach (DataGridViewRow row in dg_Data.Rows)
                {
                    int id = Convert.ToInt32(row.HeaderCell.Value);
                    if (objRt.SeekID(id) && objRt.Edit())
                    {
                        foreach (DataGridViewColumn column in dg_Data.Columns)
                        {
                            switch (objRt.GetFieldInfos()[column.Name].Type)
                            {
                            case FieldType.WText:
                                objRt.SetFieldValue(column.Name, Convert.ToString(row.Cells[column.Name].Value));
                                break;

                            case FieldType.Double:
                                objRt.SetFieldValue(column.Name, Convert.ToDouble(row.Cells[column.Name].Value));
                                break;

                            case FieldType.Int32:
                                objRt.SetFieldValue(column.Name, Convert.ToInt32(row.Cells[column.Name].Value));
                                break;
                            }
                        }
                        objRt.Update();
                    }
                }
                m_SceneControl.Refresh();
            }
            catch (Exception ex)
            {
                Log.OutputBox(ex);
            }
            finally
            {
                if (objRt != null)
                {
                    objRt.Close();
                    objRt.Dispose();
                }
            }
        }
Exemple #14
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            Recordset objRt = null;

            try
            {
                btn_Draw.Enabled = true;
                objRt            = (m_Application.Workspace.Datasources["Resource"].Datasets["ArtCraftTable"] as DatasetVector).GetRecordset(false, CursorType.Dynamic);
                switch (m_Type)
                {
                case WorkflowEditType.New:
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add("CraftName", txt_Name.Text.Trim());
                    dic.Add("Note", rtb_Description.Text.Equals(m_Tip) ? "" : rtb_Description.Text);
                    dic.Add("CraftID", (objRt.RecordCount + 1).ToString());
                    dic.Add("PlaySpeed", txt_PlaySpeed.Text);
                    dic.Add("Symbol", btn_SelectColor.Text + ',' + btn_SelectColor.Tag);
                    objRt.AddNew(null, dic);
                    objRt.Update();
                    break;

                case WorkflowEditType.Edit:
                    objRt.Edit();
                    objRt.SetFieldValue("CraftName", txt_Name.Text.Trim());
                    objRt.SetFieldValue("Note", rtb_Description.Text.Equals(m_Tip) ? "" : rtb_Description.Text);
                    objRt.SetFieldValue("CraftID", objRt.RecordCount + 1);
                    objRt.SetFieldValue("PlaySpeed", txt_PlaySpeed.Text);
                    objRt.SetFieldValue("Symbol", btn_SelectColor.Text + ',' + btn_SelectColor.Tag);
                    objRt.Update();
                    break;
                }

                Layer3DDataset layer = m_SceneControl.Scene.Layers[txt_Name.Text + "@SpaceData"] as Layer3DDataset;
                for (int i = 0; i < (layer.Theme as Theme3DUnique).Count; i++)
                {
                    Theme3DUniqueItem item = (layer.Theme as Theme3DUnique)[i];
                    item.IsVisible = false;
                }
                m_Application.MessageBox.Show("保存成功!");
            }
            catch (Exception ex)
            {
                Log.OutputBox(ex);
            }
            finally
            {
                if (objRt != null)
                {
                    objRt.Close();
                    objRt.Dispose();
                }
            }
        }
Exemple #15
0
        public void ClearResult()
        {
            try
            {
                if (m_selectRegion != null)
                {
                    m_selectRegion.Dispose();
                    m_selectRegion = null;
                }

                if (m_layerBufferDataset != null)
                {
                    m_sceneControl.Scene.Layers.Remove(m_layerBufferDataset.Name);
                    m_layerBufferDataset = null;
                }
                if (m_layerResultDataset != null)
                {
                    m_sceneControl.Scene.Layers.Remove(m_layerResultDataset.Name);
                    m_layerResultDataset = null;
                }

                //if (m_layerSrcRegion != null)
                //{
                //    m_sceneControl.Scene.Layers.Remove(m_layerSrcRegion.Name);
                //    m_layerResultDataset = null;
                //}
                this.tb_bufferRadius.Text = "0.0";
                Datasource datasource = m_workspace.Datasources[0];
                if (datasource.Datasets.Contains("sql_Result"))
                {
                    datasource.Datasets.Delete("sql_Result");
                }
                if (datasource.Datasets.Contains("bufferRegionDataset"))
                {
                    datasource.Datasets.Delete("bufferRegionDataset");
                }
                if (datasource.Datasets.Contains("BufferResult"))
                {
                    datasource.Datasets.Delete("BufferResult");
                }

                m_bCleared = true;
            }
            catch (System.Exception ex)
            {
                m_bCleared = false;
                MessageBox.Show(ex.ToString());
            }

            //m_sceneControl.Scene.Refresh();
        }
Exemple #16
0
        public bool SetQueryType(OSGBQueryType queryType)
        {
            m_queryType = queryType;

            m_srcDatasetVector = this.GetDataset();

            if (m_srcDatasetVector == null)
            {
                MessageBox.Show("找不到指定的面数据集!");
                return(false);
            }

            if (m_queryType == OSGBQueryType.SQL)
            {
                this.gb_SqlQuery.Enabled       = true;
                this.gb_BufferQuery.Enabled    = false;
                m_sceneControl.ObjectSelected -= new SuperMap.UI.ObjectSelectedEventHandler(m_sceneControl_ObjectSelected);
            }
            else
            {
                this.gb_SqlQuery.Enabled    = false;
                this.gb_BufferQuery.Enabled = true;

                //缓存区分析,需要先把原始数据集添加到场景中
                if (m_sceneControl.Scene.Layers.Contains(m_srcDatasetVector.Name))
                {
                    m_layerSrcRegion = m_sceneControl.Scene.Layers[m_srcDatasetVector.Name] as Layer3DDataset;
                }
                else
                {
                    m_layerSrcRegion = AddSrcRegionToScene(m_srcDatasetVector);
                }

                //将场景中其他图层设为不可见
                Layer3Ds layer3Ds = m_sceneControl.Scene.Layers;
                for (int i = 0; i < layer3Ds.Count; i++)
                {
                    Layer3D layer = layer3Ds[i];
                    if (layer.Name != m_layerSrcRegion.Name)
                    {
                        layer.IsVisible = false;
                    }
                }

                //注册事件
                m_sceneControl.ObjectSelected -= new SuperMap.UI.ObjectSelectedEventHandler(m_sceneControl_ObjectSelected);
                m_sceneControl.ObjectSelected += new SuperMap.UI.ObjectSelectedEventHandler(m_sceneControl_ObjectSelected);
            }
            return(true);
        }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sceneControl"></param>
        /// <param name="layer3D"></param>
        /// <param name="isSelection"></param>
        public void Initialize(SceneControl sceneControl, Layer3D layer3D, bool isSelection)
        {
            m_sceneControl = sceneControl;
            m_layer3D      = layer3D;
            m_bSelection   = isSelection;

            this.cb_AltitudeMode.Items.Clear();

            //初始化高度模式列表
            if (m_bSelection)
            {
                this.cb_AltitudeMode.Items.Add("贴地");
                this.cb_AltitudeMode.Items.Add("贴对象");
            }
            else
            {
                this.cb_AltitudeMode.Items.Add("贴地");
                this.cb_AltitudeMode.Items.Add("贴对象");
                this.cb_AltitudeMode.Items.Add("相对地面");
                this.cb_AltitudeMode.Items.Add("绝对高度");
                this.cb_AltitudeMode.Items.Add("相对地下");
            }

            //初始化m_style3D
            if (m_bSelection)
            {
                m_style3D = m_layer3D.Selection.Style;
            }
            else
            {
                if (m_layer3D.Type == Layer3DType.Dataset)
                {
                    Layer3DDataset       layer3DDataset = m_layer3D as Layer3DDataset;
                    Layer3DSettingVector layerSetting   = layer3DDataset.AdditionalSetting as Layer3DSettingVector;
                    m_style3D = layerSetting.Style;
                }
                else if (m_layer3D.Type == Layer3DType.VectorFile)
                {
                    Layer3DVectorFile    layer3DFile  = m_layer3D as Layer3DVectorFile;
                    Layer3DSettingVector layerSetting = layer3DFile.AdditionalSetting as Layer3DSettingVector;
                    m_style3D = layerSetting.Style;
                }
            }

            this.UpdateData();
        }
Exemple #18
0
 private void dg_Data_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     try
     {
         if (chkTheme.SelectedItem == null)
         {
             m_Application.MessageBox.Show(Message);
             return;
         }
         Layer3DDataset layer3DDataset = (chkTheme.SelectedItem as Label).Tag as Layer3DDataset;
         layer3DDataset.Selection.Add(Convert.ToInt32(dg_Data.Rows[e.RowIndex].HeaderCell.Value));
     }
     catch (Exception ex)
     {
         Log.OutputBox(ex);
     }
 }
Exemple #19
0
 private void btnDrawData_Click(object sender, EventArgs e)
 {
     try
     {
         if (chkTheme.SelectedItem == null)
         {
             m_Application.MessageBox.Show(Message);
             return;
         }
         Layer3DDataset layer3DDataset = (chkTheme.SelectedItem as Label).Tag as Layer3DDataset;
         layer3DDataset.IsEditable   = true;
         m_SceneControl.ObjectAdded += M_SceneControl_ObjectAdded;
     }
     catch (Exception ex)
     {
         Log.OutputBox(ex);
     }
 }
Exemple #20
0
        //将查询结果显示到场景中
        private Layer3D AddResultToScene(DatasetVector dataset, Color color)
        {
            Layer3Ds layer3Ds = m_sceneControl.Scene.Layers;

            //设置图层风格为依模型
            Layer3DSettingVector settingVector = new Layer3DSettingVector();
            GeoStyle3D           style3D       = new GeoStyle3D();

            style3D.AltitudeMode  = AltitudeMode.ClampToObject;
            style3D.FillForeColor = color;
            settingVector.Style   = style3D;

            //将数据添加到场景中
            Layer3DDataset layerDataset = layer3Ds.Add(dataset, settingVector, true);

            layerDataset.UpdateData();
            m_sceneControl.Scene.EnsureVisible(layerDataset);

            return(layerDataset);
        }
Exemple #21
0
        private void dg_Data_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            Recordset objRt = null;

            try
            {
                if (chkTheme.SelectedItem == null)
                {
                    m_Application.MessageBox.Show(Message);
                    return;
                }
                Layer3DDataset layer3DDataset = (chkTheme.SelectedItem as Label).Tag as Layer3DDataset;
                objRt = (layer3DDataset.Dataset as DatasetVector).GetRecordset(false, CursorType.Dynamic);
                int index = Convert.ToInt32(e.Row.HeaderCell.Value);
                if (objRt.SeekID(index))
                {
                    if (m_Application.MessageBox.Show("要删除第【" + index.ToString() + "】条数据吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        objRt.Delete();
                        objRt.Update();
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                }
                m_SceneControl.Refresh();
            }
            catch (Exception ex)
            {
                Log.OutputBox(ex);
            }
            finally
            {
                if (objRt != null)
                {
                    objRt.Close();
                    objRt.Dispose();
                }
            }
        }
Exemple #22
0
        private void M_SceneControl_ObjectAdded(object sender, ObjectAddedEventArgs e)
        {
            Recordset objRt = null;

            try
            {
                if (chkTheme.SelectedItem == null)
                {
                    m_Application.MessageBox.Show(Message);
                    return;
                }
                dg_Data.Rows.Clear();
                Layer3DDataset layer3DDataset = (chkTheme.SelectedItem as Label).Tag as Layer3DDataset;
                objRt = (layer3DDataset.Dataset as DatasetVector).GetRecordset(false, CursorType.Static);
                if (objRt.SeekID(e.ID))
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.HeaderCell.Value = objRt.GetID().ToString();
                    for (int j = 0; j < dg_Data.ColumnCount; j++)
                    {
                        DataGridViewTextBoxCell textBoxCell = new DataGridViewTextBoxCell();
                        textBoxCell.Value = Convert.ToString(objRt.GetFieldValue(dg_Data.Columns[j].Name));
                        row.Cells.Add(textBoxCell);
                    }
                    dg_Data.Rows.Add(row);
                }
            }
            catch (Exception ex)
            {
                Log.OutputBox(ex);
            }
            finally
            {
                if (objRt != null)
                {
                    objRt.Close();
                    objRt.Dispose();
                }
            }
        }
Exemple #23
0
        //将原始面数据集加载到场景中
        private Layer3DDataset AddSrcRegionToScene(DatasetVector dataset)
        {
            Layer3Ds layer3Ds = m_sceneControl.Scene.Layers;

            //设置图层风格为依模型
            Layer3DSettingVector settingVector = new Layer3DSettingVector();
            GeoStyle3D           style3D       = new GeoStyle3D();

            style3D.AltitudeMode   = AltitudeMode.RelativeToGround;
            style3D.BottomAltitude = 1;
            style3D.FillForeColor  = Color.Blue;
            settingVector.Style    = style3D;

            //将数据添加到场景中
            Layer3DDataset layerDataset = layer3Ds.Add(dataset, settingVector, true, dataset.Name);

            layerDataset.UpdateData();
            m_sceneControl.Scene.EnsureVisible(layerDataset);

            m_sceneControl.Scene.Refresh();
            return(layerDataset);
        }
Exemple #24
0
        //SQL查询
        public void SQLQuery(String queryCondition)
        {
            //清除已有查询结果
            if (m_layerResultDataset != null)
            {
                this.ClearResult();
            }
            // 构造一个查询参数对象
            QueryParameter queryParam = new QueryParameter();

            queryParam.AttributeFilter = queryCondition;
            queryParam.CursorType      = CursorType.Dynamic;
            Recordset recordset = m_srcDatasetVector.Query(queryParam);

            if (recordset.RecordCount == 0)
            {
                MessageBox.Show("查询结果为空,请重新输入查询条件!");
                return;
            }
            // 以 datasetVector 为模板创建数据集
            String retName = "sql_Result";

            if (m_workspace.Datasources[0].Datasets.Contains(retName))
            {
                m_workspace.Datasources[0].Datasets.Delete(retName);
            }
            DatasetVector dataset_result = (DatasetVector)m_workspace.Datasources[0].Datasets.CreateFromTemplate(retName, m_srcDatasetVector);

            dataset_result.Append(recordset);

            //将结果添加到场景中
            Color color = Color.FromArgb(180, 0, 233, 0);

            m_layerResultDataset = this.AddResultToScene(dataset_result, color) as Layer3DDataset;

            // 释放对象
            recordset.Dispose();
        }
Exemple #25
0
        private void CreateDatasets()
        {
            if (m_bAddedPointLayer)
            {
                return;
            }
            try
            {
                //创建点数据集
                Datasource datasource = m_workspace.Datasources[0];

                PrjCoordSys crtPrjSys;
                //if (m_workspace.Maps.Count == 0)
                {
                    crtPrjSys      = new PrjCoordSys();
                    crtPrjSys.Type = PrjCoordSysType.EarthLongitudeLatitude;
                }
                //else
                //{
                //crtPrjSys = m_MapControl.Map.Layers[UserHelper.MapLayerName].Dataset.PrjCoordSys;
                // }

                for (int iDeviceIndex = 0; iDeviceIndex < UserHelper.nDeviceNum; iDeviceIndex++)
                {
                    datasource.Datasets.Delete(UserHelper.sDeviceName[iDeviceIndex]);
                    DatasetVectorInfo pointLayerInfo = new DatasetVectorInfo(UserHelper.sDeviceName[iDeviceIndex], DatasetType.Point);
                    DatasetVector     pointDataset   = datasource.Datasets.Create(pointLayerInfo);

                    // 添加使用的字段
                    FieldInfo fieldInfo = new FieldInfo();
                    fieldInfo.Type = FieldType.Char;
                    fieldInfo.Name = m_filedName;
                    pointDataset.FieldInfos.Add(fieldInfo);
                    pointDataset.PrjCoordSys = crtPrjSys;

                    //将点数据集加入到地图中
                    LayerSettingVector setting = new LayerSettingVector();
                    setting.Style.LineColor      = Color.SeaGreen;
                    setting.Style.MarkerSize     = new Size2D(8, 8);
                    setting.Style.MarkerSymbolID = UserHelper.MarkerSymbolID[iDeviceIndex];
                    m_MapControl.Map.Layers.Add(pointDataset, setting, true);
                    m_MapControl.Map.Refresh();
                }

                datasource.Datasets.Delete(UserHelper.sTextName);
                DatasetVectorInfo textLayerInfo = new DatasetVectorInfo(UserHelper.sTextName, DatasetType.Text);
                DatasetVector     textDataset   = datasource.Datasets.Create(textLayerInfo);
                textDataset.PrjCoordSys = crtPrjSys;
                m_MapControl.Map.Layers.Add(textDataset, true);
                m_MapControl.Map.Refresh();

                //定义新数据集
                {
                    datasource.Datasets.Delete("Point3D");
                    DatasetVectorInfo Datasetinfo = new DatasetVectorInfo();
                    Datasetinfo.Type = DatasetType.CAD;
                    Datasetinfo.Name = "Point3D";
                    DatasetVector datset = datasource.Datasets.Create(Datasetinfo);

                    FieldInfo fieldInfo = new FieldInfo();
                    fieldInfo.Type = FieldType.Char;
                    fieldInfo.Name = m_filedName;
                    datset.FieldInfos.Add(fieldInfo);
                    datset.PrjCoordSys = crtPrjSys;

                    DatasetVector datasetPoint3D = datasource.Datasets["Point3D"] as DatasetVector;

                    if (m_SceneControl.Scene.Layers.Contains("stylePoint3D"))
                    {
                        m_layer3DPoint = m_SceneControl.Scene.Layers["stylePoint3D"] as Layer3DDataset;
                    }
                    else
                    {
                        m_layer3DPoint = m_SceneControl.Scene.Layers.Add(datasetPoint3D, new Layer3DSettingVector(), true, "stylePoint3D");
                    }
                    m_SceneControl.Scene.Refresh();
                }

                // 新建数据集
                {
                    datasource.Datasets.Delete("Region3D");
                    DatasetVectorInfo Datasetinfo = new DatasetVectorInfo();
                    Datasetinfo.Type = DatasetType.Region3D;
                    Datasetinfo.Name = "Region3D";
                    DatasetVector datset = datasource.Datasets.Create(Datasetinfo);
                    datset.PrjCoordSys = crtPrjSys;

                    DatasetVector m_datasetRegion3D = datasource.Datasets["Region3D"] as DatasetVector;
                    if (m_SceneControl.Scene.Layers.Contains("styleRegion3D"))
                    {
                        m_layer3DRegion = m_SceneControl.Scene.Layers["styleRegion3D"] as Layer3DDataset;
                    }
                    else
                    {
                        m_layer3DRegion = m_SceneControl.Scene.Layers.Add(m_datasetRegion3D, new Layer3DSettingVector(), true, "styleRegion3D");
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            m_bAddedPointLayer = true;
        }
        public void LineInsertQuery()
        {
            Layer3Ds m_layer = mSceneControl.Scene.Layers;

            foreach (Layer3D mlayer in m_layer)
            {
                if (mlayer.Selection != null)
                {
                    mlayer.Selection.Clear();
                }
            }

            QueryParameter para = new QueryParameter();

            para.HasGeometry        = true;
            para.SpatialQueryMode   = SpatialQueryMode.Intersect;
            para.SpatialQueryObject = mRec2D;

            Recordset      recordset        = null;
            Layer3DDataset layer            = null;
            String         m_textID         = String.Empty;
            String         m_textName       = String.Empty;
            String         m_textDepth      = String.Empty;
            String         m_textDiameter   = String.Empty;
            String         m_InfomationText = String.Empty;

            for (int i = 0; i < 3; i++)
            {
                if (i == 0)
                {
                    recordset = mUseData.OutWaterNetWork.Query(para);
                    layer     = mUseData.OutWaterLines;
                }
                else if (i == 1)
                {
                    recordset = mUseData.SupplyWaterNetWork.Query(para);
                    layer     = mUseData.SupplyWaterLines;
                }
                else if (i == 2)
                {
                    recordset = mUseData.ElectricNetWork.Query(para);
                    layer     = mUseData.ElectricLayer;
                }


                List <Int32> ids = new List <int>(recordset.RecordCount);
                while (!recordset.IsEOF)
                {
                    m_textID          = System.Convert.ToString(recordset.GetFieldValue("SmID"));
                    m_textName        = System.Convert.ToString(recordset.GetFieldValue("Name"));
                    m_textDepth       = System.Convert.ToString(recordset.GetFieldValue("BottomAltitude"));
                    m_textDiameter    = System.Convert.ToString(recordset.GetFieldValue("PipeDiameter"));
                    m_InfomationText += m_textID + "      " + m_textName + "    " + m_textDepth + "            " + m_textDiameter + "\n";
                    ids.Add(recordset.GetID());
                    recordset.MoveNext();
                }
                layer.Selection.AddRange(ids.ToArray());
                layer.Selection.UpdateData();
                layer.Selection.Style.LineColor = Color.GreenYellow;
                mSceneControl.Scene.Refresh();
            }

            //进行文本标注
            String m_text = "编号" + "  " + "管线类别" + "  " + "埋设深度" + "  " + "管径" + "\n";

            m_text += m_InfomationText;
            TextPart3D mText1 = new TextPart3D();

            mText1.Text        = m_text;
            mText1.AnchorPoint = mAnchorPoint3D;
            TextStyle mTextStyle1 = new TextStyle();

            mTextStyle1.FontName    = "微软雅黑";
            mTextStyle1.ForeColor   = Color.Red;
            mTextStyle1.FontHeight  = 7;
            mTextStyle1.IsSizeFixed = false;
            mTextStyle1.Alignment   = TextAlignment.MiddleCenter;
            GeoText3D  geoText_1  = new GeoText3D(mText1, mTextStyle1);
            GeoStyle3D geostyle_1 = new GeoStyle3D();

            geostyle_1.AltitudeMode = AltitudeMode.RelativeToGround;
            geoText_1.Style3D       = geostyle_1;
            TrackingLayer3D trackinglayer = mSceneControl.Scene.TrackingLayer;

            trackinglayer.IsEditable = true;
            trackinglayer.IsVisible  = true;
            trackinglayer.Add(geoText_1, "PullFlatLabel");
        }
        /// <summary>
        /// 由地下飞到地上
        /// </summary>
        public void FlyUndergroud()
        {
            try
            {
                // 地下飞行时,开启地下
                m_sceneControl.Scene.Underground.IsVisible = true;
                m_sceneControl.Scene.CameraFOV             = 60;
                // 加载飞行路线所需的数据和风格
                //为“北京地铁”设置风格
                DatasetVector        dataSet_ditie = m_workspace.Datasources[0].Datasets["BeijingSubway"] as DatasetVector;
                Layer3DSettingVector settingvetor  = new Layer3DSettingVector();
                settingvetor.Style.AltitudeMode   = AltitudeMode.RelativeToGround;
                settingvetor.Style.LineWidth      = 3;
                settingvetor.Style.LineSymbolID   = 962046;
                settingvetor.Style.BottomAltitude = -24;
                Layer3DDataset layer_ditie1 = m_sceneControl.Scene.Layers.Add(dataSet_ditie, settingvetor, true, "ditie");
                layer_ditie1.IsSelectable = false;

                // 加载 "Subway_Line8"数据集作为地铁八号线的站点
                DatasetVector        DataSet_ditieLine8  = m_workspace.Datasources[0].Datasets["Subway_Line8"] as DatasetVector;
                Layer3DSettingVector setvetor_ditieLine8 = new Layer3DSettingVector();
                setvetor_ditieLine8.Style = new GeoStyle3D();
                setvetor_ditieLine8.Style.AltitudeMode   = AltitudeMode.RelativeToGround;
                setvetor_ditieLine8.Style.BottomAltitude = 10;
                Layer3DDataset layer_ditieLine8 = m_sceneControl.Scene.Layers.Add(DataSet_ditieLine8, setvetor_ditieLine8, true, "地铁八号线");
                layer_ditieLine8.UpdateData();

                // 加载"BeijingSubway_Tunnel"数据集作为地铁巷道
                DatasetVector        DataSet_ditieL_2  = m_workspace.Datasources[0].Datasets["BeijingSubway_Tunnel"] as DatasetVector;
                Layer3DSettingVector setvetor_ditieL_2 = new Layer3DSettingVector();
                setvetor_ditieL_2.Style = new GeoStyle3D();
                setvetor_ditieL_2.Style.AltitudeMode   = AltitudeMode.RelativeToGround;
                setvetor_ditieL_2.Style.BottomAltitude = -26.5;
                setvetor_ditieL_2.Style.LineSymbolID   = 962047;
                setvetor_ditieL_2.Style.LineWidth      = 10;
                Layer3DDataset layer_ditieL_2 = m_sceneControl.Scene.Layers.Add(DataSet_ditieL_2, setvetor_ditieL_2, true, "地铁巷道");
                layer_ditieL_2.UpdateData();

                // 加载北京地铁动画模型KML文件到场景
                String       KMLPath      = @"..\..\SampleData\Symbol3DDisplay\Model\Subway.kml";
                Layer3DKML   layer_kml    = m_sceneControl.Scene.Layers.Add(KMLPath, Layer3DType.KML, true, "模型动画") as Layer3DKML;
                Feature3D    geofeature   = layer_kml.Features.FindFeature(1, Feature3DSearchOption.AllFeatures);
                GeoPlacemark geoplacemark = geofeature.Geometry as GeoPlacemark;
                GeoModel     geomodel     = geoplacemark.Geometry as GeoModel;
                geomodel.Animation.PlayMode = PlayMode.Once;
                layer_kml.UpdateData();

                //导入飞行路线文件
                Boolean i = flyManager.Routes.FromFile(@"..\..\SampleData\Symbol3DDisplay\flyground.fpf");
                flyManager.Routes.CurrentRouteIndex = 0;
                flyManager.Play();

                //当飞行结束后触发事件
                m_sceneControl.Focus();
                m_sceneControl.Scene.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void ContainQuery()
        {
            try
            {
                this.mDataGridView.Rows.Clear();
                this.mDataGridView.Columns.Clear();
                Layer3Ds m_layer = mSceneControl.Scene.Layers;
                foreach (Layer3D mlayer in m_layer)
                {
                    if (mlayer.Selection != null)
                    {
                        mlayer.Selection.Clear();
                    }
                }

                QueryParameter para = new QueryParameter();
                para.HasGeometry        = true;
                para.SpatialQueryMode   = SpatialQueryMode.Contain;
                para.SpatialQueryObject = m_rec;
                Recordset      recordset = null;
                Layer3DDataset layer     = null;
                for (int i = 0; i < 3; i++)
                {
                    if (i == 0)
                    {
                        recordset = mUseData.OutWaterNetWork.Query(para);
                        layer     = mUseData.OutWaterLines;
                    }
                    else if (i == 1)
                    {
                        recordset = mUseData.SupplyWaterNetWork.Query(para);
                        layer     = mUseData.SupplyWaterLines;
                    }
                    else if (i == 2)
                    {
                        recordset = mUseData.ElectricNetWork.Query(para);
                        layer     = mUseData.ElectricLayer;
                    }
                    List <Int32> ids = new List <int>(recordset.RecordCount);
                    while (!recordset.IsEOF)
                    {
                        ids.Add(recordset.GetID());
                        recordset.MoveNext();
                    }
                    layer.Selection.AddRange(ids.ToArray());
                    layer.Selection.UpdateData();
                    layer.Selection.Style.LineColor = Color.GreenYellow;
                    mSceneControl.Scene.Refresh();

                    //在DataGrid中显示表
                    recordset.MoveFirst();
                    FieldInfos fieldinfos = recordset.GetFieldInfos();
                    foreach (FieldInfo fieldInfo in fieldinfos)
                    {
                        if (i >= 1)
                        {
                            break;
                        }
                        if (!fieldInfo.IsSystemField)
                        {
                            if (fieldInfo.Name == "SmPPoint" || fieldInfo.Name == "SmNPoint")
                            {
                                continue;
                            }
                            string mCaption = fieldInfo.Caption;
                            this.mDataGridView.Columns.Add(mCaption, mCaption);
                        }
                    }
                    //初始化行
                    DataGridViewRow dataGridViewRow;
                    recordset.MoveFirst();

                    //根据选中的个数将对象的信息添加到列表中
                    while (!recordset.IsEOF)
                    {
                        dataGridViewRow = new DataGridViewRow();
                        for (int a = 0; a < recordset.FieldCount; a++)
                        {
                            if (!recordset.GetFieldInfos()[a].IsSystemField)
                            {
                                if (recordset.GetFieldInfos()[a].Name == "SmPPoint" || recordset.GetFieldInfos()[a].Name == "SmNPoint")
                                {
                                    continue;
                                }
                                //定义并获取字段值
                                object filevalue = recordset.GetFieldValue(a);

                                //添加到相应的位置
                                DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
                                if (filevalue != null)
                                {
                                    cell.ValueType = filevalue.GetType();
                                    cell.Value     = filevalue;
                                }
                                dataGridViewRow.Cells.Add(cell);
                            }
                        }
                        this.mDataGridView.Rows.Add(dataGridViewRow);
                        recordset.MoveNext();
                    }
                    this.mDataGridView.Update();
                    recordset.Dispose();
                }
                mSceneControl.Action = Action3D.Pan2;
                mSceneControl.Scene.Refresh();
            }
            catch (System.Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
        /// <summary>
        /// 加载地下管道线
        /// </summary>
        public void LoadPipeLine3D()
        {
            try
            {
                m_SelectedGeoNetwork = new List <NetworkGeometry>();
                DatasetVector dataset_PipeLine  = m_workspace.Datasources["Pipeline3D"].Datasets["PipeLine3D"] as DatasetVector;
                DatasetVector dataset_PipePoint = m_workspace.Datasources["Pipeline3D"].Datasets["PipePoint3D"] as DatasetVector;

                Layer3DSettingVector setvetor = new Layer3DSettingVector();
                setvetor.Style.AltitudeMode = AltitudeMode.RelativeToGround;
                setvetor.Style.LineSymbolID = 962048;
                setvetor.Style.LineWidth    = 0.35;


                Layer3DDataset layer_ditie     = m_sceneControl.Scene.Layers.Add(dataset_PipeLine, setvetor, true, "PipeLine3D");
                Layer3DDataset layer_pipepoint = m_sceneControl.Scene.Layers.Add(dataset_PipePoint, setvetor, true, "PipePoint3D");

                if (dataset_PipePoint != null)
                {
                    Theme3DUnique theme = new Theme3DUnique();
                    theme.UniqueExpression = "SmID";
                    GeoStyle3D style3D = new GeoStyle3D();
                    style3D.AltitudeMode   = AltitudeMode.RelativeToGround;
                    style3D.Marker3DScaleX = 2.2;
                    style3D.Marker3DScaleY = 2.2;
                    style3D.Marker3DScaleZ = 2.2;

                    style3D.IsMarker3D = true;
                    theme.DefaultStyle = style3D;
                    Recordset rs = dataset_PipePoint.Query("", CursorType.Static);
                    rs.MoveFirst();
                    while (!rs.IsEOF)
                    {
                        Theme3DUniqueItem item = new Theme3DUniqueItem();
                        item.Unique = rs.GetID().ToString();
                        item.IsModellingStyleEnabled = true;
                        GeoStyle3D tempStyle = new GeoStyle3D(style3D);
                        PickNodeToLine(rs.GetID());
                        GeoPoint3D geoPoint3D = rs.GetGeometry() as GeoPoint3D;

                        List <Vector3d> arrVector3d = new List <Vector3d>();
                        for (Int32 curIndex = 0; curIndex < m_SelectedGeoNetwork.Count; curIndex++)
                        {
                            NetworkGeometry geoNetWork = m_SelectedGeoNetwork[curIndex];

                            if (geoNetWork != null)
                            {
                                Vector3d  vec     = new Vector3d();
                                GeoLine3D geoLine = geoNetWork.geometry as GeoLine3D;
                                if (geoNetWork.bIsIn)
                                {
                                    if (geoLine != null)
                                    {
                                        Point3Ds point3D  = geoLine[0];
                                        Point3D  pntTNode = point3D[1];
                                        Point3D  pntFNode = point3D[0];
                                        Vector3d vecTNode = SphericalToCartesian(pntTNode.X * DTOR, pntTNode.Y * DTOR, pntTNode.Z);
                                        Vector3d vecFNode = SphericalToCartesian(pntFNode.X * DTOR, pntFNode.Y * DTOR, pntFNode.Z);

                                        vec = new Vector3d(vecFNode.x - vecTNode.x, vecFNode.y - vecTNode.y, vecFNode.z - vecTNode.z);
                                        vec.Normalize();
                                    }
                                }
                                else
                                {
                                    if (geoLine != null)
                                    {
                                        Point3Ds point3D  = geoLine[0];
                                        Point3D  pntFNode = point3D[0];
                                        Point3D  pntTNode = point3D[1];
                                        Vector3d vecTNode = SphericalToCartesian(pntTNode.X * DTOR, pntTNode.Y * DTOR, pntTNode.Z);
                                        Vector3d vecFNode = SphericalToCartesian(pntFNode.X * DTOR, pntFNode.Y * DTOR, pntFNode.Z);

                                        vec = new Vector3d(vecTNode.x - vecFNode.x, vecTNode.y - vecFNode.y, vecTNode.z - vecFNode.z);
                                        vec.Normalize();
                                    }
                                }

                                vec = FromAngleAxis(vec, -geoPoint3D.X * DTOR, new Vector3d(0, 1, 0));
                                vec = FromAngleAxis(vec, geoPoint3D.Y * DTOR, new Vector3d(1, 0, 0));
                                vec.Normalize();
                                arrVector3d.Add(vec);
                            }
                        }

                        Vector3d vecX = new Vector3d();
                        Vector3d vecY = new Vector3d();
                        Vector3d vecZ = new Vector3d();
                        switch (m_SelectedGeoNetwork.Count)
                        {
                        case 2:    //弯头或阀门
                        {
                            if (arrVector3d.Count == 2)
                            {
                                vecX = arrVector3d[0].Normalize().Sub();
                                vecY = arrVector3d[1].Normalize();
                            }

                            double dAngle1_2 = vecX.DotProduct(vecY);
                            if (Math.Abs(dAngle1_2) < 0.3)
                            {
                                tempStyle.MarkerSymbolID = 54441;
                            }
                            else if (-1 < dAngle1_2 && dAngle1_2 < 0.7)
                            {
                                tempStyle.MarkerSymbolID = 54442;
                            }
                            else
                            {
                                vecY.z = 0;
                                Vector3d vec = new Vector3d(0, 0, 1);
                                vecX = vecY.CrossProduct(vec);
                                tempStyle.MarkerSymbolID = 54435;
                            }
                        }
                        break;

                        case 3:    //三通
                        {
                            tempStyle.MarkerSymbolID = 54437;

                            if (arrVector3d.Count == 3)
                            {
                                Vector3d vec1 = arrVector3d[0];
                                Vector3d vec2 = arrVector3d[1];
                                Vector3d vec3 = arrVector3d[2];

                                double dAngle1_2 = vec1.DotProduct(vec2);
                                double dAngle1_3 = vec1.DotProduct(vec3);
                                double dAngle2_3 = vec2.DotProduct(vec3);
                                if (Math.Abs(dAngle1_2) < 0.3)
                                {
                                    if (Math.Abs(dAngle1_3) < 0.3)
                                    {
                                        vecX = vec1.Normalize().Sub();
                                        vecY = vec2.Normalize();
                                    }
                                    else
                                    {
                                        vecX = vec2.Normalize().Sub();
                                        vecY = vec1.Normalize();
                                    }
                                }
                                else
                                {
                                    vecX = vec3.Normalize().Sub();
                                    vecY = vec1.Normalize();
                                }
                            }
                        }
                        break;

                        case 4:    //四通
                        {
                            tempStyle.MarkerSymbolID = 54438;
                            if (arrVector3d.Count == 4)
                            {
                                Vector3d vec1 = arrVector3d[0];
                                Vector3d vec2 = arrVector3d[1];
                                Vector3d vec3 = arrVector3d[2];

                                double dAngle1_2 = vec1.DotProduct(vec2);
                                double dAngle1_3 = vec1.DotProduct(vec3);

                                vecX = vec1;
                                if (Math.Abs(dAngle1_2) < 0.3)
                                {
                                    vecY = vec2.Normalize();
                                }
                                else
                                {
                                    vecY = vec3.Normalize();
                                }
                            }
                        }
                        break;

                        default:    //结点
                        {
                            tempStyle.MarkerSymbolID = 330101;
                        }
                        break;
                        }

                        if (m_SelectedGeoNetwork.Count > 1)
                        {
                            vecZ = vecX.CrossProduct(vecY);
                            vecZ.Normalize();

                            Vector3d vecRotate = ToEulerAnglesXYZ(vecX, vecY, vecZ);

                            tempStyle.Marker3DRotateX = -vecRotate.x * RTOD;
                            tempStyle.Marker3DRotateY = -vecRotate.y * RTOD;
                            tempStyle.Marker3DRotateZ = -vecRotate.z * RTOD;
                        }
                        item.Style = tempStyle;
                        theme.Add(item);
                        rs.MoveNext();
                    }
                    rs.Dispose();
                    Layer3D layer_theme = m_sceneControl.Scene.Layers.Add(dataset_PipePoint, theme, true, "underPipeLine3D");
                    layer_theme.IsSelectable = false;
                    if (m_sceneControl.Scene.Layers.Contains("PipePoint3D"))
                    {
                        m_sceneControl.Scene.Layers.Remove("PipePoint3D");
                    }

                    Camera camera = m_sceneControl.Scene.Camera;
                    camera.AltitudeMode = AltitudeMode.RelativeToGround;
                    camera.Altitude     = 26.978640816174448;
                    camera.Latitude     = 39.992608337161023;
                    camera.Longitude    = 116.3898561529368;
                    camera.Tilt         = 59.567389444384283;
                    camera.Heading      = 300.19323029928478;
                    m_sceneControl.Scene.Fly(camera, 1);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #30
0
        //Buffer查询
        public void BufferQuery()
        {
            try
            {
                //清除已有查询结果
                if (m_layerResultDataset != null)
                {
                    this.ClearResult();
                }
                //创建结果面数据集
                String bufferName = "bufferRegionDataset";
                if (m_workspace.Datasources[0].Datasets.Contains(bufferName))
                {
                    m_workspace.Datasources[0].Datasets.Delete(bufferName);
                }
                DatasetVector bufferDataset = (DatasetVector)m_workspace.Datasources[0].Datasets.CreateFromTemplate(bufferName, m_srcDatasetVector);

                BufferAnalystParameter bufferAnalystParam = new BufferAnalystParameter();
                bufferAnalystParam.EndType      = BufferEndType.Round;
                bufferAnalystParam.LeftDistance = m_bufferRadius;

                Boolean isTrue = SuperMap.Analyst.SpatialAnalyst.BufferAnalyst.CreateBuffer(m_selectRegion, bufferDataset, bufferAnalystParam, false, true);

                m_layerBufferDataset = this.AddResultToScene(bufferDataset, Color.FromArgb(100, 255, 255, 0)) as Layer3DDataset;

                //进行叠加分析
                QueryParameter para = new QueryParameter();
                para.SpatialQueryMode   = SpatialQueryMode.Intersect;
                para.SpatialQueryObject = bufferDataset;

                Recordset recordset = m_srcDatasetVector.Query(para);

                List <Int32> ids = new List <int>(recordset.RecordCount);

                while (!recordset.IsEOF)
                {
                    ids.Add(recordset.GetID());
                    recordset.MoveNext();
                }

                String resultName = "BufferResult";
                if (m_workspace.Datasources[0].Datasets.Contains(resultName))
                {
                    m_workspace.Datasources[0].Datasets.Delete(resultName);
                }
                DatasetVector dataset_result = (DatasetVector)m_workspace.Datasources[0].Datasets.CreateFromTemplate(resultName, m_srcDatasetVector);
                Console.Write(isTrue);


                // 将空间查询结果追加到新建的数据集中
                dataset_result.Append(recordset);

                m_layerSrcRegion.IsVisible = false;
                //将结果数据集添加到场景中

                Color color = Color.FromArgb(200, 0, 233, 0);
                m_layerResultDataset = this.AddResultToScene(dataset_result, color) as Layer3DDataset;

                //如果场景中有osgb图层,设置osgb图层可见
                Layer3Ds layer3ds = m_sceneControl.Scene.Layers;
                for (int i = 0; i < layer3ds.Count; i++)
                {
                    Layer3D layer = layer3ds[i];
                    if (layer.Type == Layer3DType.OSGB)
                    {
                        layer.IsVisible = true;
                    }
                }

                recordset.Dispose();
                m_selectRegion.Dispose();
                m_selectRegion = null;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }