Example #1
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     try
     {
         string[] a = new string[2];
         a[0] = "ClassId00";
         a[1] = "Class_Name";
         string[] b = new string[2];
         b[0] = "ClassId09";
         b[1] = "name";
         Datasource              Ds                      = SampleRun.workspace1.Datasources[0];
         string                  name_1                  = comboBoxEx2.SelectedItem.ToString();                               //图层1
         string                  name_2                  = comboBoxEx3.SelectedItem.ToString();                               //图层2
         DatasetVector           dataset                 = SampleRun.mapControl1.Map.Layers[name_1].Dataset as DatasetVector; //第一数据集
         DatasetVector           eraseDataset            = SampleRun.mapControl1.Map.Layers[name_2].Dataset as DatasetVector; //第二数据集
         OverlayAnalystParameter parameter               = new OverlayAnalystParameter();
         DatasetVectorInfo       datasetvectorInfoUpdate = new DatasetVectorInfo();
         String                  DtName                  = Ds.Datasets.GetAvailableDatasetName("new");
         datasetvectorInfoUpdate.Type      = dataset.Type;
         datasetvectorInfoUpdate.Name      = DtName;
         parameter.SourceRetainedFields    = a;
         parameter.OperationRetainedFields = b;
         DatasetVector exdv = Ds.Datasets.Create(datasetvectorInfoUpdate);
         bool          c    = OverlayAnalyst.Union(dataset, eraseDataset, exdv, parameter);
         SampleRun.layersControl1.Map.Layers.Add(exdv, true);
         SampleRun.layersControl1.Map.Refresh();
     }
     catch
     {
         MessageBox.Show("两图层不在同一坐标系中!");
     }
 }
Example #2
0
        private DatasetVector DatasetConvertRegionToLine(DatasetVector dtVector2)
        {
            DatasetVector dtVector = null;

            if (dtVector2 != null)
            {
                DatasetVectorInfo dvi = new DatasetVectorInfo();
                dvi.Name = m_selLayer.Dataset.Datasource.Datasets.GetAvailableDatasetName("C_geoLine");
                dvi.Type = DatasetType.Line;

                //DatasetVector
                dtVector = m_selLayer.Dataset.Datasource.Datasets.Create(dvi);
                foreach (FieldInfo fi in dtVector2.FieldInfos)
                {
                    if (dtVector.FieldInfos.IndexOf(fi.Name) < 0 && !fi.IsSystemField)
                    {
                        dtVector.FieldInfos.Add(fi.Clone());
                    }
                }

                Recordset recdst = dtVector.GetRecordset(true, CursorType.Dynamic);

                recdst.Batch.Begin();
                try
                {
                    Recordset recdst2 = dtVector2.GetRecordset(false, CursorType.Static);
                    while (!recdst2.IsEOF)
                    {
                        GeoRegion geoR = recdst2.GetGeometry() as GeoRegion;

                        if (geoR != null)
                        {
                            GeoLine geoLine = geoR.ConvertToLine();
                            recdst.AddNew(geoLine);
                            foreach (FieldInfo fi in dtVector2.FieldInfos)
                            {
                                if (dtVector.FieldInfos.IndexOf(fi.Name) > -1 && !fi.IsSystemField)
                                {
                                    recdst.SetFieldValue(fi.Name, recdst2.GetFieldValue(fi.Name));
                                }
                            }
                            geoR.Dispose();
                        }
                        recdst2.MoveNext();
                    }
                    recdst2.Dispose();
                }
                catch { }
                recdst.Batch.Update();
                recdst.Dispose();
            }
            return(dtVector);
        }
Example #3
0
        //根据原数据集创建新的数据集
        private DatasetVector CreateNewDataset(DatasetVector sour_dtSet, string strDatasetName)
        {
            DatasetVector destdtSet = null;

            if (sour_dtSet == null)
            {
                return(destdtSet);
            }
            try
            {
                //
                DatasetVectorInfo dtVectorInfo = new DatasetVectorInfo(strDatasetName, DatasetType.Point);
                //考虑原来有的数据集
                try
                {
                    if (sour_dtSet.Datasource.Datasets.IndexOf(strDatasetName) > -1)
                    {
                        sour_dtSet.Datasource.Datasets.Delete(strDatasetName);
                    }
                }
                catch { }
                //
                destdtSet = sour_dtSet.Datasource.Datasets.Create(dtVectorInfo) as DatasetVector;


                List <FieldInfo> arrFI = new List <FieldInfo>();
                int iDex = sour_dtSet.FieldInfos.IndexOf("Result_District_Code");
                //业务数据表属性
                for (int i = iDex; i < sour_dtSet.FieldInfos.Count; i++)
                {
                    FieldInfo sourFI = sour_dtSet.FieldInfos[i];
                    if (sourFI.Caption.Trim().Length > 0)
                    {
                        FieldInfo fi = new FieldInfo(sourFI);
                        fi.Name = sourFI.Caption;
                        arrFI.Add(fi);
                    }
                }
                //主体类型
                {
                    FieldInfo fi = new FieldInfo("ZTLX", FieldType.Text);
                    fi.Caption   = "ZTLX";
                    fi.MaxLength = 10;
                    arrFI.Add(fi);
                }
                destdtSet.FieldInfos.AddRange(arrFI.ToArray());
            }
            catch {}
            return(destdtSet);
        }
Example #4
0
        //获取天际线
        private void btn_GetSkyline_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_skyline != null)
                {
                    GeoLine3D line3D = m_skyline.GetSkyline();

                    if (m_workspace.Datasources.Count == 0)
                    {
                        MessageBox.Show("请先打开一个数据源");
                        return;
                    }
                    Datasource datasource = m_workspace.Datasources[0];
                    Datasets   datasets   = datasource.Datasets;

                    String datasetName = "NewLine3D";
                    if (datasource.Datasets.Contains(datasetName))
                    {
                        datasource.Datasets.Delete(datasetName);
                    }
                    DatasetVectorInfo datasetInfo = new DatasetVectorInfo();
                    datasetInfo.Type       = DatasetType.Line3D;
                    datasetInfo.Name       = datasetName;
                    datasetInfo.EncodeType = EncodeType.None;

                    DatasetVector newDataset = datasource.Datasets.Create(datasetInfo);
                    if (newDataset == null)
                    {
                        MessageBox.Show("创建三维面数据集失败!");
                    }
                    if (m_sceneControl.Scene.Type == SceneType.Globe)
                    {
                        newDataset.PrjCoordSys = new PrjCoordSys(PrjCoordSysType.EarthLongitudeLatitude);
                    }
                    Recordset recordset = newDataset.GetRecordset(false, CursorType.Dynamic);
                    recordset.AddNew(line3D);
                    recordset.Update();
                    recordset.Dispose();
                }
            }
            catch (System.Exception ex)
            {
                Console.Write(ex.Message);
            }
        }
Example #5
0
        private void CreateDataset_Click(object sender, RoutedEventArgs e)
        {
            Workspace workspace           = null;
            DatasourceConnectionInfo info = null;

            try
            {
                Toolkit.SetDtNameAsTableName(true);

                var datasetName = "test222";

                workspace = new Workspace();
                info      = new DatasourceConnectionInfo();
                Datasource datasource = GetDbDatasource(workspace, info);
                Datasets   datasets   = datasource.Datasets;
                if (!datasets.IsAvailableDatasetName(datasetName))
                {
                    datasets.Delete(datasetName);
                }
                DatasetVectorInfo vectorInfo = new DatasetVectorInfo();
                vectorInfo.Name = datasetName;
                vectorInfo.Type = DatasetType.Point;
                var result = datasets.Create(vectorInfo);
                if (result != null)
                {
                    MessageBox.Show("添加数据集成功");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (info != null)
                {
                    info.Dispose();
                }
                if (workspace != null)
                {
                    workspace.Dispose();
                }
            }
        }
        /// <summary>
        /// 删除临时数据集,并创建新数据
        /// Delete the temporary dataset and create new data
        /// </summary>
        private void CopyDataset(String name)
        {
            try
            {
                m_dataset.Datasource.Datasets.Delete(name);

                DatasetVectorInfo datasetVectorInfo = new DatasetVectorInfo();
                datasetVectorInfo.Type        = DatasetType.Region;
                datasetVectorInfo.IsFileCache = true;
                datasetVectorInfo.Name        = name;

                // 创建矢量数据集
                m_bufferDataset = m_dataset.Datasource.Datasets.Create(datasetVectorInfo);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
        /// <summary>
        /// 创建数据集
        /// </summary>
        private void CreateDatasets()
        {
            try
            {
                //创建点、线、面、文本数据集
                Datasource datasource = mWorkspace.Datasources[0];
                //数据源集合对象存储工作空间下的数据源的逻辑信息, 如数据源数据的连接信息,位置等,并不存储实际的数据源数据。
                //实际的数据源数据存储在关系型数据库或UDB文件中。 工作空间的数据源集合对象主要用来管理该工作空间中的数据源,
                //包括打开、创建、关闭等操作。

                datasource.Datasets.Delete("point");                                                  //若 有点集合 则 删除...因为不重复创建
                DatasetVectorInfo pointLayerInfo = new DatasetVectorInfo("point", DatasetType.Point); //数据集类型--点
                //根据指定的参数来构造一个 DatasetVectorInfo 的新对象(数据集名称,数据集类型),返回一个DatasetVectorInfo类型
                //DatasetVectorInfo矢量数据集信息类。包括了矢量数据集的信息,如矢量数据集的名称,数据集的类型,编码方式,是否选用文件缓存等。
                //文件缓存只针对图库索引而言。

                DatasetVector pointDataset = datasource.Datasets.Create(pointLayerInfo);//根据矢量数据集信息 构造矢量数据集
                //DatasetVector描述矢量数据集,并提供相应的管理和操作。对矢量数据集的操作主要包括数据查询、修改、删除、建立索引等。
                //思路: ① 利用工作空间构造数据源集合对象datasource ②根据指定参数构造数据集信息对象 ③ 根据数据源集合对象 利用矢量数据集信息 构造矢量数据集
                //同上
                datasource.Datasets.Delete("line");
                DatasetVectorInfo lineLayerInfo = new DatasetVectorInfo("line", DatasetType.Line);//数据集类型--线
                DatasetVector     lineDataset   = datasource.Datasets.Create(lineLayerInfo);
                //同上
                datasource.Datasets.Delete("region");
                DatasetVectorInfo regionLayerInfo = new DatasetVectorInfo("region", DatasetType.Region);//数据集类型--多边形
                DatasetVector     regionDataset   = datasource.Datasets.Create(regionLayerInfo);
                //同上
                datasource.Datasets.Delete("text");
                DatasetVectorInfo textLayerInfo = new DatasetVectorInfo("text", DatasetType.Text);//数据集类型--文本
                DatasetVector     textDataset   = datasource.Datasets.Create(textLayerInfo);
                //将点、线、面、文本数据集加入到地图中
                mPointLayer  = mMapControl.Map.Layers.Add(pointDataset, true);  //把点数据集添加到点图层
                mLineLayer   = mMapControl.Map.Layers.Add(lineDataset, true);   //把线数据集添加到线图层
                mRegionLayer = mMapControl.Map.Layers.Add(regionDataset, true); //把多边形数据集添加到多边形图层
                mTextLayer   = mMapControl.Map.Layers.Add(textDataset, true);   //把文本数据集添加到文本图层
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
            }
        }
        // 新建要素集
        public DatasetVector DatasetVectorInfoSample(Datasource datasource, string tableName)
        {
            try
            {
                this.tempDatasetName = datasource.Datasets.GetAvailableDatasetName(tableName);

                // 设置矢量数据集的信息
                DatasetVectorInfo datasetVectorInfo = new DatasetVectorInfo();
                datasetVectorInfo.Type = DatasetType.Point;
                datasetVectorInfo.IsFileCache = true;
                datasetVectorInfo.Name = tempDatasetName;
                this.MyLog("矢量数据集的信息为:" + datasetVectorInfo.ToString());

                // 创建矢量数据集
                DatasetVector ds = datasource.Datasets.Create(datasetVectorInfo);

                //add field info
                FieldInfos fields = ds.FieldInfos;
                FieldInfo fieldInfo = new FieldInfo("ID", FieldType.Text);
                fields.Add(fieldInfo);
                fieldInfo = new FieldInfo("NAME", FieldType.Text);
                fields.Add(fieldInfo);
                fieldInfo = new FieldInfo("XBH", FieldType.Text);
                fields.Add(fieldInfo);

                fieldInfo = new FieldInfo("X", FieldType.Double);
                fields.Add(fieldInfo);
                fieldInfo = new FieldInfo("Y", FieldType.Double);
                fields.Add(fieldInfo);

                ds.Close();

                return ds;

            }
            catch (Exception)
            {

                return null;
            }
        }
Example #9
0
        // 新建要素集
        public DatasetVector DatasetVectorInfoSample(Datasource datasource, string tableName)
        {
            try
            {
                this.tempDatasetName = datasource.Datasets.GetAvailableDatasetName(tableName);

                // 设置矢量数据集的信息
                DatasetVectorInfo datasetVectorInfo = new DatasetVectorInfo();
                datasetVectorInfo.Type        = DatasetType.Point;
                datasetVectorInfo.IsFileCache = true;
                datasetVectorInfo.Name        = tempDatasetName;
                this.MyLog("矢量数据集的信息为:" + datasetVectorInfo.ToString());

                // 创建矢量数据集
                DatasetVector ds = datasource.Datasets.Create(datasetVectorInfo);

                //add field info
                FieldInfos fields    = ds.FieldInfos;
                FieldInfo  fieldInfo = new FieldInfo("ID", FieldType.Text);
                fields.Add(fieldInfo);
                fieldInfo = new FieldInfo("NAME", FieldType.Text);
                fields.Add(fieldInfo);
                fieldInfo = new FieldInfo("XBH", FieldType.Text);
                fields.Add(fieldInfo);

                fieldInfo = new FieldInfo("X", FieldType.Double);
                fields.Add(fieldInfo);
                fieldInfo = new FieldInfo("Y", FieldType.Double);
                fields.Add(fieldInfo);

                ds.Close();

                return(ds);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public void CreateLineDataset()
        {
            try
            {
                //新建线数据集,用于临时绘制线形符号
                if (m_workspace.Datasources[0].Datasets.Contains("Line3D"))
                {
                    m_workspace.Datasources[0].Datasets.Delete("Line3D");
                }

                //定义新数据集
                DatasetVectorInfo Datasetinfo = new DatasetVectorInfo();
                Datasetinfo.Type = DatasetType.CAD;
                Datasetinfo.Name = "Line3D";
                m_workspace.Datasources[0].Datasets.Create(Datasetinfo);


                m_datasetLine3D = m_workspace.Datasources[0].Datasets["Line3D"] as DatasetVector;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// 设置三维线符号
        /// </summary>
        public void SettingLine3D(int Line3DIndex)
        {
            flag          = true;
            isRegion      = false;
            m_line3DIndex = Line3DIndex;
            //新建数据集

            switch (m_line3DIndex)
            {
            case 0:
            {
                if (!m_sceneControl.Scene.Layers.Contains("ditie3"))
                {
                    comBoxDisplayLine3D(0);
                }

                break;
            }

            case 1:
            {
                if (!m_sceneControl.Scene.Layers.Contains("underPipeLine3D"))
                {
                    comBoxDisplayLine3D(1);
                }

                break;
            }

            case 2:
            {
                m_sceneControl.Scene.Underground.IsVisible = false;
                if (!m_sceneControl.Scene.Layers.Contains("Ground@OlympicGreen"))
                {
                    m_sceneControl.Scene.Layers.Clear();
                    LoadOlympicGreen();
                    Camera camera = m_sceneControl.Scene.Camera;
                    camera.Altitude  = 341.96175131294876;
                    camera.Tilt      = 63.988040332277215;
                    camera.Heading   = 4.18128919038237;
                    camera.Longitude = 116.3842976377199;
                    camera.Latitude  = 39.986785637662514;
                    m_sceneControl.Scene.Fly(camera, 1);
                    PointLineCamera = true;
                }
                if (!PointLineCamera)
                {
                    Camera camera = m_sceneControl.Scene.Camera;
                    camera.Altitude  = 341.96175131294876;
                    camera.Tilt      = 63.988040332277215;
                    camera.Heading   = 4.18128919038237;
                    camera.Longitude = 116.3842976377199;
                    camera.Latitude  = 39.986785637662514;
                    m_sceneControl.Scene.Fly(camera, 1);
                    PointLineCamera = true;
                }
                break;
            }
            }

            try
            {
                m_sceneControl.Action = Action3D.MeasureDistance;
                // 新建数据集
                if (m_workspace.Datasources[0].Datasets.Contains("Line3D"))
                {
                    m_workspace.Datasources[0].Datasets.Delete("Line3D");
                }
                //定义新数据集
                DatasetVectorInfo Datasetinfo = new DatasetVectorInfo();
                Datasetinfo.Type = DatasetType.CAD;
                Datasetinfo.Name = "Line3D";
                m_workspace.Datasources[0].Datasets.Create(Datasetinfo);
                m_datasetLine3D = m_workspace.Datasources[0].Datasets["Line3D"] as DatasetVector;

                if (m_sceneControl.Scene.Layers.Contains("styleLine3D"))
                {
                    m_layer3DLine = m_sceneControl.Scene.Layers["styleLine3D"] as Layer3DDataset;
                }
                else
                {
                    m_layer3DLine = m_sceneControl.Scene.Layers.Add(m_datasetLine3D, new Layer3DSettingVector(), true, "styleLine3D");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #12
0
        /// <summary>
        /// 创建数据集
        /// Create the dataset
        /// </summary>
        public Boolean CreateDataset(Datasource datasource, DatasetType datasetType, String datasetName)
        {
            Boolean result = false;

            if (datasource == null)
            {
                return(result);
            }

            // 首先要判断输入的名字是否可用
            // Judge that whether the input name is usable or not
            if (!datasource.Datasets.IsAvailableDatasetName(datasetName))
            {
                MessageBox.Show($"名称为{datasetName}的数据集已存在");
                return(result);
            }

            Datasets          datasets   = datasource.Datasets;
            DatasetVectorInfo vectorInfo = new DatasetVectorInfo();

            vectorInfo.Name = datasetName;

            try
            {
                // Point等为Vector类型,类型是一样的,可以统一处理
                // Data such as Point,Line,etc can be operated as the same method as they are all vector type
                switch (datasetType)
                {
                case DatasetType.Point:
                case DatasetType.Line:
                case DatasetType.CAD:
                case DatasetType.Region:
                case DatasetType.Text:
                case DatasetType.Tabular:
                {
                    vectorInfo.Type = datasetType;
                    if (datasets.Create(vectorInfo) != null)
                    {
                        result = true;
                    }
                }
                break;

                case DatasetType.Grid:
                {
                    DatasetGridInfo datasetGridInfo = new DatasetGridInfo();
                    datasetGridInfo.Name        = datasetName;
                    datasetGridInfo.Height      = 200;
                    datasetGridInfo.Width       = 200;
                    datasetGridInfo.NoValue     = 1.0;
                    datasetGridInfo.PixelFormat = SuperMap.Data.PixelFormat.Single;
                    datasetGridInfo.EncodeType  = EncodeType.LZW;

                    if (datasets.Create(datasetGridInfo) != null)
                    {
                        result = true;
                    }
                }
                break;

                case DatasetType.Image:
                {
                    DatasetImageInfo datasetImageInfo = new DatasetImageInfo();
                    datasetImageInfo.Name            = datasetName;
                    datasetImageInfo.BlockSizeOption = BlockSizeOption.BS_128;
                    datasetImageInfo.Height          = 200;
                    datasetImageInfo.Width           = 200;
                    //datasetImageInfo.Palette = Colors.MakeRandom(10);
                    datasetImageInfo.EncodeType = EncodeType.None;

                    if (datasets.Create(datasetImageInfo) != null)
                    {
                        result = true;
                    }
                }
                break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }

            return(result);
        }
Example #13
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;
        }
Example #14
0
        private void button2_Click(object sender, EventArgs e)
        {
            splashScreenManager1.ShowWaitForm();
            splashScreenManager1.SetWaitFormCaption("正在叠加图层");
            splashScreenManager1.SetWaitFormDescription("请等待...");
            //年份选择
            string strYear = "T" + comboBox5.Text;


            DatasetVector datasetOperated = importDatasource.Datasets[strYear] as DatasetVector;
            Recordset     recordset2      = datasetOperated.GetRecordset(false, CursorType.Dynamic);

            //创建一个面矢量数据集,用于存储相交分析获得的结果
            importDatasource.Datasets.Delete("JBNTsuperposition");
            String            resultDatasetInteresectName = importDatasource.Datasets.GetAvailableDatasetName("JBNTsuperposition");
            DatasetVectorInfo datasetvectorInfoIntersect  = new DatasetVectorInfo();

            datasetvectorInfoIntersect.Type       = DatasetType.Region;
            datasetvectorInfoIntersect.Name       = resultDatasetInteresectName;
            datasetvectorInfoIntersect.EncodeType = EncodeType.None;
            DatasetVector resultDatasetIntersect = importDatasource.Datasets.Create(datasetvectorInfoIntersect);

            //设置投影信息 不设置 报投影不一致错误
            resultDatasetIntersect.Datasource.Datasets["JBNTsuperposition"].PrjCoordSys = importDatasource.Datasets[strYear].PrjCoordSys;
            //设置叠加分析参数
            OverlayAnalystParameter overlayAnalystParamIntersect = new OverlayAnalystParameter();

            overlayAnalystParamIntersect.Tolerance = 0.0000011074;
            //  overlayAnalystParamIntersect.SourceRetainedFields= {"FKXMMC";"DLMC";"DLBM"};
            string[] gk = { "FKXMMC", "DLMC", "DLBM" };
            overlayAnalystParamIntersect.SourceRetainedFields = gk;
            // overlayAnalystParamIntersect.SourceRetainedFields= [ "TBBH"];
            string[] languages = { "ZYMJ" };
            //  overlayAnalystParamIntersect.OperationRetainedFields= {"GD";"LD"};
            overlayAnalystParamIntersect.OperationRetainedFields = languages;
            //调用相交叠加分析方法实相交分析
            bool flag = OverlayAnalyst.Intersect(recordset2, recordset, resultDatasetIntersect, overlayAnalystParamIntersect);

            if (flag)
            {
                StringBuilder sqlQuery = new StringBuilder();
                sqlQuery.Append("SELECT * FROM JBNTsuperposition");
                gkfqd.Common.DbUse.GetOleDbconnection().Close();
                gkfqd.Common.DbUse.GetOleDbconnection().Open();
                dataSetIntersectTemp.Clear();
                OleDbDataAdapter MyAdapter = new OleDbDataAdapter(sqlQuery.ToString(), gkfqd.Common.DbUse.GetOleDbconnection());
                MyAdapter.Fill(dataSetIntersectTemp);
                gkfqd.Common.DbUse.GetOleDbconnection().Close();
                if (flag == true)
                {
                    MessageBox.Show("图层叠加完成");
                    this.reportViewer1.RefreshReport();
                    this.gHDLTBTableAdapter.Fill(this.gK0441.GHDLTB);
                    this.reportViewer1.RefreshReport();
                }

                splashScreenManager1.CloseWaitForm();
                // TODO: 这行代码将数据加载到表“gK0441.所属乡镇与面积”中。您可以根据需要移动或删除它。
                this.所属乡镇与面积TableAdapter.Fill(this.gK0441.所属乡镇与面积);
                // TODO: 这行代码将数据加载到表“gK0441.规划地类与面积”中。您可以根据需要移动或删除它。
                this.规划地类与面积TableAdapter.Fill(this.gK0441.规划地类与面积);
                // TODO: 这行代码将数据加载到表“gK0441.地类名称与面积”中。您可以根据需要移动或删除它。
                this.地类名称与面积TableAdapter.Fill(this.gK0441.地类名称与面积);
                // TODO: 这行代码将数据加载到表“gK0441.GHDLTB”中。您可以根据需要移动或删除它。
                this.gHDLTBTableAdapter.Fill(this.gK0441.GHDLTB);

                this.reportViewer1.RefreshReport();
            }
            else
            {
                MessageBox.Show("叠加失败");
                return;
            }
            // this.reportViewer1.RefreshReport();
        }
Example #15
0
        private void button2_Click(object sender, EventArgs e)
        {
            //复垦图层
            string tableName1 = gkfqd.Common.DbUse.FXGetTownCode(comboBox3.Text) + "_" + comboBox5.Text;
            //现状图层
            string tableName2 = gkfqd.Common.DbUse.XZGetTownCode(comboBox3.Text) + "_" + comboBox5.Text;

            splashScreenManager1.ShowWaitForm();
            splashScreenManager1.SetWaitFormCaption("正在叠加图层");
            splashScreenManager1.SetWaitFormDescription("请等待...");
            //年份选择,即现状图层
            string        strYear         = tableName2;
            DatasetVector datasetOperated = importDatasource.Datasets[strYear] as DatasetVector;

            if (datasetOperated == null)
            {
                MessageBox.Show("请选择有效的叠加年份");
                splashScreenManager1.CloseWaitForm();
                return;
            }

            if (datasetOperated == null)
            {
                MessageBox.Show("请选择有效的叠加年份");
                splashScreenManager1.CloseWaitForm();
                return;
            }
            Recordset recordset2 = datasetOperated.GetRecordset(false, CursorType.Dynamic);

            //缩小地图查找范围
            mapControl1.Map.EnsureVisible(recordset2.GetGeometry(), 0.6);
            mapControl1.Refresh();
            mapControl1.Map.Refresh();

            //创建一个面矢量数据集,用于存储相交分析获得的结果
            importDatasource.Datasets.Delete("ZYsuperposition");
            String            resultDatasetInteresectName = importDatasource.Datasets.GetAvailableDatasetName("ZYsuperposition");
            DatasetVectorInfo datasetvectorInfoIntersect  = new DatasetVectorInfo();

            datasetvectorInfoIntersect.Type       = DatasetType.Region;
            datasetvectorInfoIntersect.Name       = resultDatasetInteresectName;
            datasetvectorInfoIntersect.EncodeType = EncodeType.None;
            DatasetVector resultDatasetIntersect = importDatasource.Datasets.Create(datasetvectorInfoIntersect);

            //设置投影信息 不设置 报投影不一致错误
            resultDatasetIntersect.Datasource.Datasets["ZYsuperposition"].PrjCoordSys = importDatasource.Datasets[strYear].PrjCoordSys;
            //设置叠加分析参数
            OverlayAnalystParameter overlayAnalystParamIntersect = new OverlayAnalystParameter();

            overlayAnalystParamIntersect.Tolerance = 0.0000011074;
            FieldInfos fieldInfos = datasetOperated.FieldInfos;

            string[] mFiels = new string[fieldInfos.Count];
            for (int i = 0; i < fieldInfos.Count; i++)
            {
                mFiels[i] = fieldInfos[i].Name;
            }
            overlayAnalystParamIntersect.SourceRetainedFields = mFiels;
            string[] languages = { tableName1 };
            //  overlayAnalystParamIntersect.OperationRetainedFields= {"GD";"LD"};
            overlayAnalystParamIntersect.OperationRetainedFields = languages;


            //调用相交叠加分析方法实相交分析
            bool flag = OverlayAnalyst.Intersect(recordset2, recordset, resultDatasetIntersect, overlayAnalystParamIntersect);

            if (flag)
            {
                // TODO: 这行代码将数据加载到表“gK0411.GKFQD”中。您可以根据需要移动或删除它。
                this.gKFQDTableAdapter.Fill(this.gK0411.GKFQD);
                this.reportViewer1.RefreshReport();
                splashScreenManager1.CloseWaitForm();
            }
            else
            {
                MessageBox.Show("叠加失败");
                return;
            }
        }
Example #16
0
        private void button3_Click(object sender, EventArgs e)
        {
            string[] arrayYear = { "2014", "2015", "2016" };
            // string[] arrayYear = { "GHDLTB" };
            for (int i = 0; i < arrayYear.Length; i++)
            {
                //此处写循环 每个年份数据 现在执行一个年份数据 并手动选择 自动执行多个年份数据
                //不用手动选择  年份和图层对应
                splashScreenManager1.ShowWaitForm();
                splashScreenManager1.SetWaitFormCaption("正在查重" + arrayYear[i] + "年份数据");
                splashScreenManager1.SetWaitFormDescription("请等待...");
                //年份选择
                //string strYear = "T" + comboBox4.Text;
                string strYear = "T" + arrayYear[i];
                //string strYear = arrayYear[i];

                //面积查询前不显示
                label7.Text    = "";
                label7.Name    = "";
                label7.Visible = false;

                DatasetVector datasetOperated = importDatasource.Datasets[strYear] as DatasetVector;
                Recordset     recordset2      = datasetOperated.GetRecordset(false, CursorType.Dynamic);
                //创建一个面矢量数据集,用于存储相交分析获得的结果
                importDatasource.Datasets.Delete("IntersectTemp");
                String            resultDatasetIntersectName = importDatasource.Datasets.GetAvailableDatasetName("IntersectTemp");
                DatasetVectorInfo datasetvectorInfoIntersect = new DatasetVectorInfo();
                datasetvectorInfoIntersect.Type       = DatasetType.Region;
                datasetvectorInfoIntersect.Name       = resultDatasetIntersectName;
                datasetvectorInfoIntersect.EncodeType = EncodeType.None;
                DatasetVector resultDatasetIntersect = importDatasource.Datasets.Create(datasetvectorInfoIntersect);
                //设置投影信息 不设置 报投影不一致错误
                resultDatasetIntersect.Datasource.Datasets["IntersectTemp"].PrjCoordSys = importDatasource.Datasets[strYear].PrjCoordSys;
                //设置叠加分析参数
                OverlayAnalystParameter overlayAnalystParamIntersect = new OverlayAnalystParameter();
                overlayAnalystParamIntersect.Tolerance = 0.0000011074;
                //调用相交叠加分析方法实相交分析
                bool flag = OverlayAnalyst.Intersect(recordset2, recordset, resultDatasetIntersect, overlayAnalystParamIntersect);
                if (flag)
                {
                    StringBuilder sqlQuery = new StringBuilder();
                    sqlQuery.Append("SELECT SUM(SMAREA) AS SMAREA");
                    sqlQuery.Append(" FROM       IntersectTemp ");
                    gkfqd.Common.DbUse.GetOleDbconnection().Close();
                    gkfqd.Common.DbUse.GetOleDbconnection().Open();
                    dataSetIntersectTemp.Clear();
                    OleDbDataAdapter MyAdapter = new OleDbDataAdapter(sqlQuery.ToString(), gkfqd.Common.DbUse.GetOleDbconnection());
                    MyAdapter.Fill(dataSetIntersectTemp);
                    gkfqd.Common.DbUse.GetOleDbconnection().Close();
                    if (dataSetIntersectTemp.Tables[0].Rows[0]["SMAREA"].ToString().Trim() != "")
                    {
                        label7.Text    = "重叠面积:" + dataSetIntersectTemp.Tables[0].Rows[0]["SMAREA"].ToString().Trim();
                        label7.Visible = true;
                        //MessageBox.Show(label7.Text);
                        //弹出重叠面积叠加后图形

                        gk03b frmgk03b = new gk03b();
                        frmgk03b.Owner           = this;
                        frmgk03b.FormBorderStyle = FormBorderStyle.FixedSingle;    //固定窗体大小不变
                        frmgk03b.StartPosition   = FormStartPosition.CenterScreen; //窗体居中
                        frmgk03b.ShowDialog();
                    }
                    else
                    {
                        label7.Text    = "没有重叠地块";
                        label7.Visible = true;
                        MessageBox.Show(label7.Text);
                    }
                }
                splashScreenManager1.CloseWaitForm();
            }
        }
Example #17
0
        private void button2_Click(object sender, EventArgs e)
        {
            //建新图层
            string tableName1 = gkfqd.Common.DbUse.JXGetTownCode(comboBox3.Text) + "_" + comboBox5.Text;
            //现状图层
            string tableName2 = gkfqd.Common.DbUse.GHGetTownCode(comboBox3.Text) + "_" + comboBox5.Text;

            splashScreenManager1.ShowWaitForm();
            splashScreenManager1.SetWaitFormCaption("正在叠加图层");
            splashScreenManager1.SetWaitFormDescription("请等待...");
            //年份选择
            string        strYear         = tableName2;
            DatasetVector datasetOperated = importDatasource.Datasets[strYear] as DatasetVector;

            if (datasetOperated == null)
            {
                MessageBox.Show("请选择有效的叠加年份");
                splashScreenManager1.CloseWaitForm();
                return;
            }
            Recordset recordset2 = datasetOperated.GetRecordset(false, CursorType.Dynamic);

            //创建一个面矢量数据集,用于存储相交分析获得的结果
            importDatasource.Datasets.Delete("JXsuperposition");
            String            resultDatasetInteresectName = importDatasource.Datasets.GetAvailableDatasetName("JXsuperposition");
            DatasetVectorInfo datasetvectorInfoIntersect  = new DatasetVectorInfo();

            datasetvectorInfoIntersect.Type       = DatasetType.Region;
            datasetvectorInfoIntersect.Name       = resultDatasetInteresectName;
            datasetvectorInfoIntersect.EncodeType = EncodeType.None;
            DatasetVector resultDatasetIntersect = importDatasource.Datasets.Create(datasetvectorInfoIntersect);

            //设置投影信息 不设置 报投影不一致错误
            resultDatasetIntersect.Datasource.Datasets["JXsuperposition"].PrjCoordSys = importDatasource.Datasets[strYear].PrjCoordSys;
            //设置叠加分析参数
            OverlayAnalystParameter overlayAnalystParamIntersect = new OverlayAnalystParameter();

            overlayAnalystParamIntersect.Tolerance = 0.0000011074;
            //  overlayAnalystParamIntersect.SourceRetainedFields= {"FKXMMC";"DLMC";"DLBM"};
            // 现状图层 jxtc
            FieldInfos fieldInfos = datasetOperated.FieldInfos;

            string[] mFiels = new string[fieldInfos.Count];
            for (int i = 0; i < fieldInfos.Count; i++)
            {
                mFiels[i] = fieldInfos[i].Name;
            }
            //string[] gk = { "ZYMJ", "DLMC", "DLBM" };
            overlayAnalystParamIntersect.SourceRetainedFields = mFiels;
            // overlayAnalystParamIntersect.SourceRetainedFields= [ "TBBH"];
            //工矿废弃地图层
            string[] languages = { tableName1 };
            //  overlayAnalystParamIntersect.OperationRetainedFields= {"GD";"LD"};
            overlayAnalystParamIntersect.OperationRetainedFields = languages;
            //调用相交叠加分析方法实相交分析
            bool flag = OverlayAnalyst.Intersect(recordset2, recordset, resultDatasetIntersect, overlayAnalystParamIntersect);

            if (flag)
            {
                this.v_XJQKTableAdapter.Fill(this.gk0431.V_XJQK);
                this.reportViewer1.RefreshReport();
                splashScreenManager1.CloseWaitForm();
            }
            else
            {
                MessageBox.Show("叠加失败");
                return;
            }
        }
Example #18
0
        public Boolean CreateDataset(DatasetType datasetType, String datasetName)
        {
            Boolean result = false;

            if (m_datasource == null)
            {
                return(result);
            }

            // 首先要判断输入的名字是否可用
            if (!m_datasource.Datasets.IsAvailableDatasetName(datasetName))
            {
                MessageBox.Show("该名字已经存在或不合法");
                return(result);
            }

            Datasets          datasets   = m_datasource.Datasets;
            DatasetVectorInfo vectorInfo = new DatasetVectorInfo();

            vectorInfo.Name = datasetName;

            try
            {
                // Point等为Vector类型,类型是一样的,可以统一处理
                switch (datasetType)
                {
                case DatasetType.Point:
                case DatasetType.Line:
                case DatasetType.CAD:
                case DatasetType.Region:
                case DatasetType.Text:
                case DatasetType.Tabular:
                {
                    vectorInfo.Type = datasetType;
                    if (datasets.Create(vectorInfo) != null)
                    {
                        result = true;
                    }
                }
                break;

                case DatasetType.Grid:
                {
                    DatasetGridInfo datasetGridInfo = new DatasetGridInfo();
                    datasetGridInfo.Name        = datasetName;
                    datasetGridInfo.BlockSize   = 125;
                    datasetGridInfo.Height      = 200;
                    datasetGridInfo.Width       = 200;
                    datasetGridInfo.NoValue     = 1.0;
                    datasetGridInfo.PixelFormat = PixelFormat.Single;
                    datasetGridInfo.EncodeType  = EncodeType.LZW;

                    if (datasets.Create(datasetGridInfo) != null)
                    {
                        result = true;
                    }
                }
                break;

                case DatasetType.Image:
                {
                    DatasetImageInfo datasetImageInfo = new DatasetImageInfo();
                    datasetImageInfo.Name       = datasetName;
                    datasetImageInfo.Height     = 200;
                    datasetImageInfo.Width      = 200;
                    datasetImageInfo.Palette    = Colors.MakeRandom(10);
                    datasetImageInfo.EncodeType = EncodeType.None;

                    if (datasets.Create(datasetImageInfo) != null)
                    {
                        result = true;
                    }
                }
                break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }

            return(result);
        }
Example #19
0
        private void button2_Click(object sender, EventArgs e)
        {
            //复垦图层
            string tableName1 = gkfqd.Common.DbUse.FXGetTownCode(comboBox3.Text) + "_" + comboBox5.Text;
            //规划图层
            string tableName2 = gkfqd.Common.DbUse.GHGetTownCode(comboBox3.Text) + "_" + comboBox5.Text;

            splashScreenManager1.ShowWaitForm();
            splashScreenManager1.SetWaitFormCaption("正在叠加图层");
            splashScreenManager1.SetWaitFormDescription("请等待...");
            //年份选择

            string strYear = tableName2;

            //string strYear = "T" + comboBox5.Text;
            //string strYear = "XZ150426_2017";


            //string strYear = tableName2;



            DatasetVector datasetOperated = importDatasource.Datasets[strYear] as DatasetVector;

            if (datasetOperated == null)
            {
                MessageBox.Show("请选择有效的叠加年份");
                splashScreenManager1.CloseWaitForm();
                return;
            }
            Recordset recordset2 = datasetOperated.GetRecordset(false, CursorType.Dynamic);

            //创建一个面矢量数据集,用于存储相交分析获得的结果
            importDatasource.Datasets.Delete("FKHsuperposition");
            String            resultDatasetInteresectName = importDatasource.Datasets.GetAvailableDatasetName("FKHsuperposition");
            DatasetVectorInfo datasetvectorInfoIntersect  = new DatasetVectorInfo();

            datasetvectorInfoIntersect.Type       = DatasetType.Region;
            datasetvectorInfoIntersect.Name       = resultDatasetInteresectName;
            datasetvectorInfoIntersect.EncodeType = EncodeType.None;
            DatasetVector resultDatasetIntersect = importDatasource.Datasets.Create(datasetvectorInfoIntersect);

            //设置投影信息 不设置 报投影不一致错误
            resultDatasetIntersect.Datasource.Datasets["FKHsuperposition"].PrjCoordSys = importDatasource.Datasets[strYear].PrjCoordSys;
            //设置叠加分析参数
            OverlayAnalystParameter overlayAnalystParamIntersect = new OverlayAnalystParameter();

            overlayAnalystParamIntersect.Tolerance = 0.0000011074;
            FieldInfos fieldInfos = datasetOperated.FieldInfos;

            string[] mFiels = new string[fieldInfos.Count];
            for (int i = 0; i < fieldInfos.Count; i++)
            {
                mFiels[i] = fieldInfos[i].Name;
            }
            overlayAnalystParamIntersect.SourceRetainedFields = mFiels;
            string[] languages = { tableName1 };
            overlayAnalystParamIntersect.OperationRetainedFields = languages;
            //调用相交叠加分析方法实相交分析
            bool flag = OverlayAnalyst.Intersect(recordset2, recordset, resultDatasetIntersect, overlayAnalystParamIntersect);

            if (flag)
            {
                StringBuilder sqlQuery = new StringBuilder();
                sqlQuery.Append("SELECT * FROM FKHsuperposition");
                gkfqd.Common.DbUse.GetOleDbconnection().Close();
                gkfqd.Common.DbUse.GetOleDbconnection().Open();
                dataSetIntersectTemp.Clear();
                OleDbDataAdapter MyAdapter = new OleDbDataAdapter(sqlQuery.ToString(), gkfqd.Common.DbUse.GetOleDbconnection());
                MyAdapter.Fill(dataSetIntersectTemp);
                gkfqd.Common.DbUse.GetOleDbconnection().Close();
                if (flag == true)
                {
                    MessageBox.Show("图层叠加完成");
                    this.reportViewer1.RefreshReport();
                    this.xZDLTBTableAdapter.Fill(this.gK0451.XZDLTB);
                    this.reportViewer1.RefreshReport();
                }

                splashScreenManager1.CloseWaitForm();
                // TODO: 这行代码将数据加载到表“gK0451.XZDLTB”中。您可以根据需要移动或删除它。
                this.xZDLTBTableAdapter.Fill(this.gK0451.XZDLTB);

                this.reportViewer1.RefreshReport();
            }
            else
            {
                MessageBox.Show("叠加失败");
                return;
            }
        }
 /// <summary>
 /// 拷贝构造函数。
 /// </summary>
 /// <param name="datasetVectorInfo">矢量数据集对象。</param>
 /// <exception cref="ArgumentNullException">当影像数据集信息对象为 Null 时抛出异常。</exception>
 public DatasetVectorInfo(DatasetVectorInfo datasetVectorInfo)
     : base(datasetVectorInfo)
 {
     if (datasetVectorInfo == null) throw new ArgumentNullException("datasetVectorInfo", Resources.ArgumentIsNotNull);
     this.Charset = datasetVectorInfo.Charset;
     this.IsFileCache = datasetVectorInfo.IsFileCache;
     this.RecordCount = datasetVectorInfo.RecordCount;
 }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            Dictionary<string, object> datasetInfoValues = serializer.Deserialize<Dictionary<string, object>>(reader);
            if (datasetInfoValues == null) return null;
            DatasetInfo datasetInfo = null;
            if (datasetInfoValues.ContainsKey("recordCount"))
            {
                datasetInfo = new DatasetVectorInfo();
                DatasetVectorInfo datasetVectorInfo = datasetInfo as DatasetVectorInfo;
                int recordCount = 0;
                if (datasetInfoValues.ContainsKey("recordCount") && datasetInfoValues["recordCount"] != null)
                {
                    recordCount = int.Parse(datasetInfoValues["recordCount"].ToString());
                }
                datasetVectorInfo.RecordCount = recordCount;
                bool isFileCache = false;
                if (datasetInfoValues.ContainsKey("isFileCache") && datasetInfoValues["isFileCache"] != null)
                {
                    isFileCache = bool.Parse(datasetInfoValues["isFileCache"].ToString());
                }
                datasetVectorInfo.IsFileCache = isFileCache;
                Charset charset = Charset.ANSI;
                if (datasetInfoValues.ContainsKey("charset") && datasetInfoValues["charset"] != null)
                {
                    charset = (Charset)Enum.Parse(typeof(Charset), datasetInfoValues["charset"].ToString(), false);
                }
                datasetVectorInfo.Charset = charset;
            }
            else if (datasetInfoValues.ContainsKey("isMultiBand"))
            {
                datasetInfo = new DatasetImageInfo();
                DatasetImageInfo datasetImageInfo = datasetInfo as DatasetImageInfo;
                int blockSize = 0;
                if (datasetInfoValues.ContainsKey("blockSize") && datasetInfoValues["blockSize"] != null)
                {
                    blockSize = int.Parse(datasetInfoValues["blockSize"].ToString());
                }
                datasetImageInfo.BlockSize = blockSize;
                int height = 0;
                if (datasetInfoValues.ContainsKey("height") && datasetInfoValues["height"] != null)
                {
                    height = int.Parse(datasetInfoValues["height"].ToString());
                }
                datasetImageInfo.Height = height;
                bool isMultiBand = false;
                if (datasetInfoValues.ContainsKey("isMultiBand") && datasetInfoValues["isMultiBand"] != null)
                {
                    isMultiBand = bool.Parse(datasetInfoValues["isMultiBand"].ToString());
                }
                datasetImageInfo.IsMultiBand = isMultiBand;

                datasetImageInfo.Palette = datasetInfoValues.ContainsKey("palette") && datasetInfoValues["palette"] != null ?
                    JsonConvert.DeserializeObject<Color[]>(datasetInfoValues["palette"].ToString()) : null;
                PixelFormat pixelFormat = PixelFormat.SINGLE;
                if (datasetInfoValues.ContainsKey("pixelFormat") && datasetInfoValues["pixelFormat"] != null)
                {
                    pixelFormat = (PixelFormat)Enum.Parse(typeof(PixelFormat), datasetInfoValues["pixelFormat"].ToString(), false);
                }
                datasetImageInfo.PixelFormat = pixelFormat;
                int width = 0;
                if (datasetInfoValues.ContainsKey("width") && datasetInfoValues["width"] != null)
                {
                    width = int.Parse(datasetInfoValues["width"].ToString());
                }
                datasetImageInfo.Width = width;
            }
            else if (datasetInfoValues.ContainsKey("noValue"))
            {
                datasetInfo = new DatasetGridInfo();
                DatasetGridInfo datasetGridInfo = datasetInfo as DatasetGridInfo;
                int blockSize = 0;
                if (datasetInfoValues.ContainsKey("blockSize") && datasetInfoValues["blockSize"] != null)
                {
                    blockSize = int.Parse(datasetInfoValues["blockSize"].ToString());
                }
                datasetGridInfo.BlockSize = blockSize;
                int height = 0;
                if (datasetInfoValues.ContainsKey("height") && datasetInfoValues["height"] != null)
                {
                    height = int.Parse(datasetInfoValues["height"].ToString());
                }
                datasetGridInfo.Height = height;
                double maxValue = 0.0;
                if (datasetInfoValues.ContainsKey("maxValue") && datasetInfoValues["maxValue"] != null)
                {
                    maxValue = double.Parse(datasetInfoValues["maxValue"].ToString());
                }
                datasetGridInfo.MaxValue = maxValue;
                double minValue = 0.0;
                if (datasetInfoValues.ContainsKey("minValue") && datasetInfoValues["minValue"] != null)
                {
                    maxValue = double.Parse(datasetInfoValues["minValue"].ToString());
                }
                datasetGridInfo.MinValue = minValue;
                double noValue = 0.0;
                if (datasetInfoValues.ContainsKey("noValue") && datasetInfoValues["noValue"] != null)
                {
                    noValue = double.Parse(datasetInfoValues["noValue"].ToString());
                }
                datasetGridInfo.NoValue = noValue;
                PixelFormat pixelFormat = PixelFormat.SINGLE;
                if (datasetInfoValues.ContainsKey("pixelFormat") && datasetInfoValues["pixelFormat"] != null)
                {
                    pixelFormat = (PixelFormat)Enum.Parse(typeof(PixelFormat), datasetInfoValues["pixelFormat"].ToString(), false);
                }
                datasetGridInfo.PixelFormat = pixelFormat;
                int width = 0;
                if (datasetInfoValues.ContainsKey("width") && datasetInfoValues["width"] != null)
                {
                    width = int.Parse(datasetInfoValues["width"].ToString());
                }
                datasetGridInfo.Width = width;
            }
            else
            {
                datasetInfo = new DatasetInfo();
            }
            datasetInfo.Bounds = datasetInfoValues.ContainsKey("bounds") && datasetInfoValues["bounds"] != null ?
                JsonConvert.DeserializeObject<Rectangle2D>(datasetInfoValues["bounds"].ToString()) : null;
            datasetInfo.DataSourceName = datasetInfoValues.ContainsKey("dataSourceName") && datasetInfoValues["dataSourceName"] != null ? datasetInfoValues["dataSourceName"].ToString() : "";
            datasetInfo.Description = datasetInfoValues.ContainsKey("description") && datasetInfoValues["description"] != null ? datasetInfoValues["description"].ToString() : "";
            EncodeType encodeType = EncodeType.NONE;
            if (datasetInfoValues.ContainsKey("encodeType") && datasetInfoValues["encodeType"] != null)
            {
                encodeType = (EncodeType)Enum.Parse(typeof(EncodeType), datasetInfoValues["encodeType"].ToString(), false);
            }
            datasetInfo.EncodeType = encodeType;
            bool isReadOnly = true;
            if (datasetInfoValues.ContainsKey("isReadOnly") && datasetInfoValues["isReadOnly"] != null)
            {
                isReadOnly = bool.Parse(datasetInfoValues["isReadOnly"].ToString());
            }
            datasetInfo.IsReadOnly = isReadOnly;
            datasetInfo.Name = datasetInfoValues.ContainsKey("name") && datasetInfoValues["name"] != null ? datasetInfoValues["name"].ToString() : "";
            datasetInfo.PrjCoordSys = datasetInfoValues.ContainsKey("prjCoordSys") && datasetInfoValues["prjCoordSys"] != null ?
                JsonConvert.DeserializeObject<PrjCoordSys>(datasetInfoValues["prjCoordSys"].ToString()) : null;
            datasetInfo.TableName = datasetInfoValues.ContainsKey("tableName") && datasetInfoValues["tableName"] != null ?
                datasetInfoValues["tableName"].ToString() : "";
            DatasetType type = DatasetType.UNDEFINED;
            if (datasetInfoValues.ContainsKey("type") && datasetInfoValues["type"] != null)
            {
                type = (DatasetType)Enum.Parse(typeof(DatasetType), datasetInfoValues["type"].ToString(), false);
            }
            datasetInfo.Type = type;

            return datasetInfo;
        }
Example #22
0
        private void txt_Name_Leave(object sender, EventArgs e)
        {
            try
            {
                if (!m_Application.Workspace.Datasources["SpaceData"].Datasets.IsAvailableDatasetName(txt_Name.Text.Trim(), DatasetType.Line3D))
                {
                    m_Application.MessageBox.Show("该流程已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txt_Name.Text    = "";
                    btn_Save.Enabled = false;
                }
                else
                {
                    switch (m_Type)
                    {
                    case WorkflowEditType.New:
                        SymbolRibbonTrail trail = new SymbolRibbonTrail((m_Application.Workspace.Resources.LineLibrary.FindSymbol("Workflow")) as SymbolRibbonTrail)
                        {
                            Name = string.IsNullOrEmpty(txt_Name.Text.Trim()) ? "Workflow_default" : "Workflow_" + txt_Name.Text.Trim()
                        };
                        m_Application.Workspace.Resources.LineLibrary.Add(trail);
                        m_Application.Workspace.Save();
                        btn_SelectColor.Text = trail.Name;
                        btn_SelectColor.Tag  = trail.ID;


                        DatasetVectorInfo info = new DatasetVectorInfo
                        {
                            Name = txt_Name.Text.Trim(),
                            Type = DatasetType.Line3D,
                        };
                        DatasetVector objDtV = m_Application.Workspace.Datasources["SpaceData"].Datasets.Create(info);
                        objDtV.PrjCoordSys = m_Application.Workspace.Datasources["SpaceData"].PrjCoordSys;
                        for (int i = 0; i < 6; i++)
                        {
                            FieldInfo fieldInfo = new FieldInfo();
                            fieldInfo.Type = FieldType.Text;
                            switch (i)
                            {
                            case 0:
                                fieldInfo.Name    = "Longitude";
                                fieldInfo.Caption = "经度";
                                break;

                            case 1:
                                fieldInfo.Name    = "Latitude";
                                fieldInfo.Caption = "纬度";
                                break;

                            case 2:
                                fieldInfo.Name    = "Altitude";
                                fieldInfo.Caption = "高度";
                                break;

                            case 3:
                                fieldInfo.Name    = "Tilt";
                                fieldInfo.Caption = "俯仰角";
                                break;

                            case 4:
                                fieldInfo.Name    = "Heading";
                                fieldInfo.Caption = "视角";
                                break;

                            case 5:
                                fieldInfo.Name    = "Time";
                                fieldInfo.Caption = "时长";
                                break;
                            }
                            objDtV.FieldInfos.Add(fieldInfo);
                        }
                        GeoStyle3D style = new GeoStyle3D
                        {
                            LineSymbolID = Convert.ToInt32(btn_SelectColor.Tag)
                        };

                        Theme3DUnique theme = new Theme3DUnique
                        {
                            DefaultStyle     = style,
                            UniqueExpression = "SmID"
                        };
                        for (int i = 0; i < theme.Count; i++)
                        {
                            Theme3DUniqueItem item = theme[i];
                            item.Style = style;
                        }
                        Layer3DDataset layer = m_SceneControl.Scene.Layers.Add(objDtV, theme, true);

                        m_lstWorkflow.Add(new Label {
                            Text = txt_Name.Text.Trim(), Tag = cmb_Workflow.Items.Count + 1
                        });
                        cmb_Workflow.DataSource    = null;
                        cmb_Workflow.DataSource    = m_lstWorkflow;
                        cmb_Workflow.DisplayMember = "Text";
                        if (cmb_Workflow.Items.Count > 0)
                        {
                            cmb_Workflow.SelectedIndex = cmb_Workflow.Items.Count - 1;
                        }
                        break;
                    }
                    btn_Save.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                Log.OutputBox(ex);
            }
        }