Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="header1024"></param>
        /// <param name="driver"></param>
        /// <param name="args">
        /// 可扩展的参数信息,每对参数都采用key=value的形式。
        /// 1、数据集,采用逗号分隔的形式加入默认所选择的波段。
        /// 例如:datasets=VIRR_1Km_LST[,...]
        /// 2、投影方式,采用proj4字符串的形式
        /// 例如:proj4=
        /// 3、其他待扩展的参数信息
        /// 坐标信息:geoinfo=1,2,3,4,5,6//其中1,2,3,4,5,6分辨代表:minX,maxX,minY,maxY,resolutionX,resolutionY;
        /// 经纬度数据集:geodatasets=Longitude,Latitude//该数据对轨道数据有效。
        /// </param>
        public HdfRasterDataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, params object[] args)
            : base(fileName, driver)
            //: base(fileName, driver)
        {
            _args = args;
            TryParseArgs();
            using (Dataset _dataset = Gdal.Open(fileName, Access.GA_ReadOnly))
            {
                GDALHelper.GetDatasetAttributes(_dataset, _attributes);
                //数据集仅有一个数据集,一个通道
                if (_dataset.RasterCount == 1)
                {
                    //GDAL对于只有一个数据集的HDF数据,SUBDATASETS属性值是空的,这里尝试手动设置下
                    TrySetGDALSUBDATASETS(_datasets);
                }
            }

            //...可以在此添加投影等信息
            TryCreateBandProvider(fileName, header1024, _datasets, _attributes.GetAttributeDomain("SUBDATASETS"));

            //_bandCount = _dataset.RasterCount;

            _bandCount = _rasterBands.Count;

            TryGetDatTypeOfProvider();

            TryGetSizeOfProvider();

            TryCreateSpatialRef();
            TryCreateCoordTransform();
            TrySetEnvelopeAndResolutions();
        }
Exemplo n.º 2
0
        public FY3AASOandASLProvider(string fileName, byte[] header1024, IGeoDataDriver driver, params object[] args)
            : base(fileName, driver)
        {
            _fileName = fileName;
            _args     = args;
            using (Dataset dataset = Gdal.Open(fileName, Access.GA_ReadOnly))
            {
                GDALHelper.GetDatasetAttributes(dataset, _attributes);
            }
            Dictionary <string, string> allGdalSubDatasets = this.Attributes.GetAttributeDomain("SUBDATASETS");

            _allGdalSubDatasets = RecordAllSubDatasetNames(allGdalSubDatasets);
            _coordEnvelope      = TrySetGeoInfo();
            _selectedsets       = TryGetSelectedSets();
            TryCreateBandProvider();
            _bandCount   = _rasterBands.Count;
            _dataType    = _rasterBands[0].DataType;
            _width       = _rasterBands[0].Width;
            _height      = _rasterBands[0].Height;
            _spatialRef  = SpatialReference.GetDefault();
            _coordType   = _spatialRef.ProjectionCoordSystem != null ? enumCoordType.PrjCoord : enumCoordType.GeoCoord;
            _resolutionX = (float)(_coordEnvelope.Width / (_width));
            _resolutionY = (float)(_coordEnvelope.Height / (_height));
            if (_dataIdentify != null)
            {
                _dataIdentify.OrbitDateTime = IceConDataProvider.TryGetFileDate(Path.GetFileName(fileName));
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 这里增加一个判断一个文件是否该驱动支持的静态方法
 /// </summary>
 /// <param name="fileName"></param>
 /// <returns></returns>
 internal static bool IsSupport(string fileName)
 {
     try
     {
         AttributeManager attributes = new AttributeManager();
         using (Dataset dataset = Gdal.Open(fileName, Access.GA_ReadOnly))
         {
             GDALHelper.GetDatasetAttributes(dataset, attributes);
         }
         Dictionary <string, string> allGdalSubDatasets = attributes.GetAttributeDomain("SUBDATASETS");
         string[] allGdalSubDatasetArray = RecordAllSubDatasetNames(allGdalSubDatasets);
         if (allGdalSubDatasetArray == null || allGdalSubDatasetArray.Length != 6)
         {
             return(false);
         }
         using (Hdf5Operator hdf = new Hdf5Operator(fileName))
         {
             allGdalSubDatasetArray = hdf.GetDatasetNames;
         }
         string[] DATASETS = new string[] { "icecon_north_asc", "icecon_north_avg", "icecon_north_des", "icecon_south_asc", "icecon_south_avg", "icecon_south_des" };
         for (int i = 0; i < 6; i++)
         {
             if (!allGdalSubDatasetArray[i].Contains(DATASETS[i]))//数据集必须完全匹配,才能用此数据集
             {
                 return(false);
             }
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="header1024"></param>
        /// <param name="driver"></param>
        /// <param name="access"></param>
        /// <param name="args">
        /// selectedband=1,2,3
        ///
        /// </param>
        public SICRasterDataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, enumDataProviderAccess access, params object[] args)
            : base(fileName, driver)
        {
            _access = (access == enumDataProviderAccess.ReadOnly ? Access.GA_ReadOnly : Access.GA_Update);
            TryParseArgs(args);
            //通过GDAL获取GDAL识别的通道
            using (Dataset _dataset = Gdal.Open(fileName, Access.GA_ReadOnly))
            {
                GDALHelper.GetDatasetAttributes(_dataset, _attributes);
            }
            Dictionary <string, string> allGdalSubDatasets = _attributes.GetAttributeDomain("SUBDATASETS");

            _allGdalSubDatasets = RecordAllSubDatasetNames(allGdalSubDatasets);

            //...根据参数取得当前需要的数据集
            //如果是北极
            string[] currentDsNames = new string[] { _allGdalSubDatasets[0], _allGdalSubDatasets[1], _allGdalSubDatasets[2] };
            //如果是南极
            currentDsNames = new string[] { _allGdalSubDatasets[3], _allGdalSubDatasets[4], _allGdalSubDatasets[5] };
            //设置_rasterBands
            List <IRasterBand> rasterBands = new List <IRasterBand>();

            foreach (string dsName in currentDsNames)
            {
                //这里测试时候看dsName是否是全路径,如果不是需要用全路径
                string        dsFullPath   = dsName;
                Dataset       ds           = Gdal.Open(dsFullPath, _access);
                IRasterBand[] gdalDatasets = ReadBandsFromDataset(ds, this);
                rasterBands.AddRange(gdalDatasets);
            }
            _rasterBands = rasterBands;
            _bandCount   = 3;
            _dataType    = rasterBands[0].DataType;
            _width       = rasterBands[0].Width;
            _height      = rasterBands[0].Height;
            _resolutionX = 12500f;
            _resolutionY = 12500f;
            //设置坐标
            _coordType = enumCoordType.PrjCoord;
            //如果是北极
            _coordEnvelope = new Core.DF.CoordEnvelope(-3850000, 3750000, -5350000, 5850000);
            _spatialRef    = SpatialReference.FromProj4(NORTH_PROJ4);
            //如果是南极
            _coordEnvelope = new Core.DF.CoordEnvelope(-3950000, 3950000, -3950000, 4350000);
            _spatialRef    = SpatialReference.FromProj4(SOUTH_PROJ4);
        }
Exemplo n.º 5
0
        public FY3HDFL2ProductProvider(string fileName, byte[] header1024, IGeoDataDriver driver, params object[] args)
            : base(fileName, driver)
        {
            L2ProductDefind[] l2Pros = L2ProductDefindParser.GetL2ProductDefs(Path.GetFileName(_fileName));
            if (l2Pros == null)
            {
                return;
            }
            _fileName = fileName;
            _args     = args;
            L2ProductDefind verifyL2Pro = l2Pros.Length == 1 ? l2Pros[0] : VerifyL2ProDef(l2Pros);

            if (verifyL2Pro == null)
            {
                return;
            }
            using (Dataset dataset = Gdal.Open(fileName, Access.GA_ReadOnly))
            {
                GDALHelper.GetDatasetAttributes(dataset, _attributes);
            }
            Dictionary <string, string> allGdalSubDatasets = this.Attributes.GetAttributeDomain("SUBDATASETS");

            _allGdalSubDatasets = RecordAllSubDatasetNames(allGdalSubDatasets);
            _coordEnvelope      = TrySetGeoInfo(verifyL2Pro);
            _selectedsets       = TryGetSelectedSets(verifyL2Pro);
            TryCreateBandProvider();
            _bandCount   = _rasterBands.Count;
            _dataType    = _rasterBands[0].DataType;
            _width       = _rasterBands[0].Width;
            _height      = _rasterBands[0].Height;
            _coordType   = _spatialRef.ProjectionCoordSystem != null ? enumCoordType.PrjCoord : enumCoordType.GeoCoord;
            _resolutionX = (float)(_coordEnvelope.Width / (_width));
            _resolutionY = (float)(_coordEnvelope.Height / (_height));
            if (_dataIdentify != null && _dataIdentify.OrbitDateTime == DateTime.MinValue)
            {
                _dataIdentify.OrbitDateTime = IceConDataProvider.TryGetFileDate(Path.GetFileName(fileName));
            }
        }
Exemplo n.º 6
0
 public FYSnowPrdDataProvider(string fileName, byte[] header1024, IGeoDataDriver driver, params object[] args)
     : base(fileName, driver)
 {
     _args = args;
     TryParseArgs();
     using (Dataset dataset = Gdal.Open(fileName, Access.GA_ReadOnly))
     {
         GDALHelper.GetDatasetAttributes(dataset, _attributes);
     }
     TryCreateBandProvider();
     _bandCount = _rasterBands.Count;
     TryGetDatTypeOfProvider();
     TryGetSizeOfProvider();
     //TryCreateSpatialRef();
     _coordType   = enumCoordType.PrjCoord;
     _resolutionX = (float)(_coordEnvelope.Width / (_width));
     _resolutionY = (float)(_coordEnvelope.Height / (_height));
     if (_dataIdentify != null)
     {
         _dataIdentify.Sensor        = "MWRI";
         _dataIdentify.OrbitDateTime = IceConDataProvider.TryGetFileDate(Path.GetFileName(fileName));
     }
 }
Exemplo n.º 7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string name      = this.tbxName.Text;
            string address   = this.tbxAddress.Text;
            string manager   = this.tbxManager.Text;
            string phone     = this.tbxPhone.Text;
            double longitude = Convert.ToDouble(this.tbxLongitude.Text);
            double latitude  = Convert.ToDouble(this.tbxLatitude.Text);

            double height    = Convert.ToDouble(this.tbxHeight.Text);
            double elevation = Convert.ToDouble(this.tbxElevation.Text);
            double h_offset  = Convert.ToDouble(this.tbx_h_offset.Text);
            double v_offset  = Convert.ToDouble(this.tbx_v_offset.Text);
            string deviceid  = this.tbx_deviceid.Text.Trim();

            if (this.pacControl1.LocalPac == null || this.pacControl1.LocalPac == "" || this.pacControl1.LocalPac.EndsWith("00"))
            {
                MessageBox.Show(this, "请选择正确的行政区名称", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.tabControl1.SelectedTab = this.tabPage2;
                this.pacControl1.CbxCounty.Focus();
                return;
            }
            if (height == 0)
            {
                MessageBox.Show(this, "请选择正确的云台高度", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.tabControl1.SelectedTab = this.tabPage3;
                this.tbxHeight.Focus();
                this.tbxHeight.SelectAll();
                return;
            }

            #region 可见光


            string ip1       = "";
            int    port1     = 0;
            int    channel1  = 0;
            string user1     = "";
            string password1 = "";

            ip1 = this.tbxIp1.Value;
            if (string.IsNullOrEmpty(ip1))
            {
                MessageBox.Show(this, "请输入可见光IP地址", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                tabControl1.SelectedTab = this.tabPage4;
                this.tbxIp1.Focus();
                return;
            }

            try
            {
                if (string.IsNullOrEmpty(this.tbxPort1.Text))
                {
                    MessageBox.Show(this, "请输入可见光连接端口", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    tabControl1.SelectedTab = this.tabPage4;

                    this.tbxPort1.SelectAll();
                    this.tbxPort1.Focus();

                    return;
                }

                port1 = Convert.ToInt32(this.tbxPort1.Text.Trim());
            }
            catch
            {
            }

            channel1 = Convert.ToInt32(this.cbxChannel1.SelectedValue);

            user1 = this.tbxUser1.Text.Trim();
            if (string.IsNullOrEmpty(user1))
            {
                MessageBox.Show(this, "请输入可见光连接用户名", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                tabControl1.SelectedTab = this.tabPage4;

                this.tbxUser1.SelectAll();
                this.tbxUser1.Focus();
                return;
            }

            password1 = this.tbxPassword1.Text.Trim();
            if (string.IsNullOrEmpty(password1))
            {
                MessageBox.Show(this, "请输入可见光连接密码", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                tabControl1.SelectedTab = this.tabPage4;

                this.tbxPassword1.SelectAll();
                this.tbxPassword1.Focus();
                return;
            }

            #endregion

            #region 近红外



            string ip2       = " ";
            int    port2     = 0;
            int    channel2  = 1;
            string user2     = " ";
            string password2 = " ";



            if (this.checkBox1.Checked)
            {
                ip2 = this.tbxIp2.Value;
                if (string.IsNullOrEmpty(ip2))
                {
                    MessageBox.Show(this, "请输入近红外IP地址", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    tabControl1.SelectedTab = this.tabPage5;
                    this.tbxIp2.Focus();
                    return;
                }

                try
                {
                    if (string.IsNullOrEmpty(this.tbxPort2.Text))
                    {
                        MessageBox.Show(this, "请输入可见光连接端口", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                        tabControl1.SelectedTab = this.tabPage5;

                        this.tbxPort2.SelectAll();
                        this.tbxPort2.Focus();

                        return;
                    }

                    port2 = Convert.ToInt32(this.tbxPort2.Text.Trim());
                }
                catch
                {
                }

                channel2 = Convert.ToInt32(this.cbxChannel2.SelectedValue);

                user2 = this.tbxUser2.Text.Trim();
                if (string.IsNullOrEmpty(user2))
                {
                    MessageBox.Show(this, "请输入可见光连接用户名", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    tabControl1.SelectedTab = this.tabPage5;

                    this.tbxUser2.SelectAll();
                    this.tbxUser2.Focus();
                    return;
                }

                password2 = this.tbxPassword2.Text.Trim();
                if (string.IsNullOrEmpty(password2))
                {
                    MessageBox.Show(this, "请输入可见光连接密码", "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    tabControl1.SelectedTab = this.tabPage5;

                    this.tbxPassword2.SelectAll();
                    this.tbxPassword2.Focus();
                    return;
                }
            }

            #endregion

            if (m_OperationType == OperationType.Add)
            {
                this.m_Monitor = new Fire_ForestRemoteMonitoring();
            }

            m_Monitor.name      = name;
            m_Monitor.address   = address;
            m_Monitor.manager   = manager;
            m_Monitor.phone     = phone;
            m_Monitor.pac       = this.pacControl1.LocalPac;
            m_Monitor.longitude = longitude;
            m_Monitor.latitude  = latitude;
            m_Monitor.shape     = GDALHelper.LngLatToWktPoint(this.m_Monitor.longitude, this.m_Monitor.latitude);
            m_Monitor.county    = this.pacControl1.CbxCounty.Text;
            m_Monitor.deviceid  = this.tbx_deviceid.Text;

            m_Monitor.height    = height;
            m_Monitor.elevation = elevation;
            m_Monitor.h_offset  = h_offset;
            m_Monitor.v_offset  = v_offset;
            m_Monitor.deviceid  = deviceid;


            m_Monitor.ip       = ip1;
            m_Monitor.Port     = port1;
            m_Monitor.channel  = channel1;
            m_Monitor.user_    = user1;
            m_Monitor.username = user1;
            m_Monitor.password = password1;

            if (this.m_OperationType == OperationType.Add)
            {
                //m_Monitor.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                m_Monitor.cre_pers = GlobeHelper.Instance.User.name;

                this.m_MonitoringController.Add(m_Monitor);
            }
            else
            {
                //m_Monitor.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                m_Monitor.mod_pers = GlobeHelper.Instance.User.name;

                this.m_MonitoringController.Edit(m_Monitor);
            }
        }