コード例 #1
0
ファイル: ProductMeta.cs プロジェクト: rs-sdust/GFStatistics
        /// <summary>
        /// Writes the document meta.
        /// </summary>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public bool WriteDocMeta()
        {
            StructProMeta meta = new StructProMeta();

            meta.ProductID    = DateTime.Now.ToFileTime().ToString();
            meta.SubClassName = _subClass;
            FileInfo fInfo = new FileInfo(_file);

            meta.Name           = fInfo.Name.Substring(0, fInfo.Name.LastIndexOf("."));
            meta.Format         = fInfo.Extension.Substring(1, fInfo.Extension.Length - 1);
            meta.Path           = fInfo.FullName;
            meta.Region         = _region;
            meta.ProductionDate = fInfo.CreationTime.ToString("yyyyMMdd");
            meta.Description    = _desc;
            string metaFile = _file.Substring(0, _file.LastIndexOf(".")) + ".xml";

            this.WriteDocMeta2File(metaFile, meta);
            return(true);
        }
コード例 #2
0
ファイル: ProductMeta.cs プロジェクト: rs-sdust/GFStatistics
        private void GetRasterInfo(string file, ref StructProMeta meta)
        {
            IRasterLayer      pRasterLayer         = null;
            ISpatialReference spatialReferenceInfo = null;

            try
            {
                pRasterLayer = new RasterLayerClass();
                pRasterLayer.CreateFromFilePath(_file);
                IRaster      pRaster      = pRasterLayer.Raster;
                IRasterProps pRasterProps = pRaster as IRasterProps;
                meta.Resolution       = pRasterProps.MeanCellSize().X.ToString("f1");
                spatialReferenceInfo  = pRasterProps.SpatialReference;
                meta.CoordinateSystem = spatialReferenceInfo.Name;
                if (spatialReferenceInfo is IProjectedCoordinateSystem)
                {
                    IProjectedCoordinateSystem projectedCoordinateSystem = spatialReferenceInfo as IProjectedCoordinateSystem;
                    meta.MapProjection = projectedCoordinateSystem.Projection.Name;
                    IPoint point = pRasterProps.Extent.UpperLeft;
                    point.Project(projectedCoordinateSystem.GeographicCoordinateSystem);
                    meta.UpperLeftLat = point.Y.ToString();
                    meta.UpperLeftLon = point.X.ToString();
                    point             = pRasterProps.Extent.UpperRight;
                    point.Project(projectedCoordinateSystem.GeographicCoordinateSystem);
                    meta.UpperRightLat = point.Y.ToString();
                    meta.UpperRightLon = point.X.ToString();
                    point = pRasterProps.Extent.LowerRight;
                    point.Project(projectedCoordinateSystem.GeographicCoordinateSystem);
                    meta.LowerRightLat = point.Y.ToString();
                    meta.LowerRightLon = point.X.ToString();
                    point = pRasterProps.Extent.LowerLeft;
                    point.Project(projectedCoordinateSystem.GeographicCoordinateSystem);
                    meta.LowerLeftLat = point.Y.ToString();
                    meta.LowerLeftLon = point.X.ToString();
                }
            }
            catch (Exception)
            { }
        }
コード例 #3
0
ファイル: ProductMeta.cs プロジェクト: rs-sdust/GFStatistics
        private void GetShpInfo(string file, ref StructProMeta meta)
        {
            IFeatureClass     pFeatureClass        = null;
            ISpatialReference spatialReferenceInfo = null;

            try
            {
                pFeatureClass = GFS.Common.EngineAPI.OpenFeatureClass(file);
                IGeoDataset shpDataSet = pFeatureClass as IGeoDataset;
                spatialReferenceInfo  = shpDataSet.SpatialReference;
                meta.CoordinateSystem = spatialReferenceInfo.Name;
                if (spatialReferenceInfo is IProjectedCoordinateSystem)
                {
                    IProjectedCoordinateSystem projectedCoordinateSystem = spatialReferenceInfo as IProjectedCoordinateSystem;
                    meta.MapProjection = projectedCoordinateSystem.Projection.Name;
                    IPoint point = shpDataSet.Extent.UpperLeft;
                    point.Project(projectedCoordinateSystem.GeographicCoordinateSystem);
                    meta.UpperLeftLat = point.Y.ToString();
                    meta.UpperLeftLon = point.X.ToString();
                    point             = shpDataSet.Extent.UpperRight;
                    point.Project(projectedCoordinateSystem.GeographicCoordinateSystem);
                    meta.UpperRightLat = point.Y.ToString();
                    meta.UpperRightLon = point.X.ToString();
                    point = shpDataSet.Extent.LowerRight;
                    point.Project(projectedCoordinateSystem.GeographicCoordinateSystem);
                    meta.LowerRightLat = point.Y.ToString();
                    meta.LowerRightLon = point.X.ToString();
                    point = shpDataSet.Extent.LowerLeft;
                    point.Project(projectedCoordinateSystem.GeographicCoordinateSystem);
                    meta.LowerLeftLat = point.Y.ToString();
                    meta.LowerLeftLon = point.X.ToString();
                }
            }
            catch (Exception)
            { }
        }
コード例 #4
0
ファイル: ProductMeta.cs プロジェクト: rs-sdust/GFStatistics
        private void WriteDocMeta2File(string file, StructProMeta meta)
        {
            XmlTextWriter xmlWriter = null;

            try
            {
                xmlWriter            = new XmlTextWriter(file, Encoding.UTF8);
                xmlWriter.Formatting = Formatting.Indented;
                xmlWriter.WriteStartDocument();
                xmlWriter.WriteStartElement("Production")
                ;
                xmlWriter.WriteStartElement("ProductID");
                xmlWriter.WriteString(meta.ProductID);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("ClassName");
                xmlWriter.WriteString(meta.ClassName);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("SubClassName");
                xmlWriter.WriteString(meta.SubClassName);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Name");
                xmlWriter.WriteString(meta.Name);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Format");
                xmlWriter.WriteString(meta.Format);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Path");
                xmlWriter.WriteString(meta.Path);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Unit");
                xmlWriter.WriteString(meta.Unit);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Region");
                xmlWriter.WriteString(meta.Region);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("ProductionDate");
                xmlWriter.WriteString(meta.ProductionDate);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Description");
                xmlWriter.WriteString(meta.Description);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteEndElement();
            }
            catch (Exception ex)
            {
                GFS.BLL.Log.WriteLog(typeof(TaskHistory), ex);
            }
            finally
            {
                xmlWriter.Flush();
                xmlWriter.Close();
            }
        }
コード例 #5
0
ファイル: ProductMeta.cs プロジェクト: rs-sdust/GFStatistics
        private void Write2File(string file, StructProMeta meta)
        {
            XmlTextWriter xmlWriter = null;

            try
            {
                xmlWriter            = new XmlTextWriter(file, Encoding.UTF8);
                xmlWriter.Formatting = Formatting.Indented;
                xmlWriter.WriteStartDocument();
                xmlWriter.WriteStartElement("Production")
                ;
                xmlWriter.WriteStartElement("ProductID");
                xmlWriter.WriteString(meta.ProductID);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("ClassName");
                xmlWriter.WriteString(meta.ClassName);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("SubClassName");
                xmlWriter.WriteString(meta.SubClassName);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Name");
                xmlWriter.WriteString(meta.Name);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Format");
                xmlWriter.WriteString(meta.Format);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Path");
                xmlWriter.WriteString(meta.Path);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Unit");
                xmlWriter.WriteString(meta.Unit);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("SatelliteSource");
                xmlWriter.WriteString(meta.SatelliteSource);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Resolution");
                xmlWriter.WriteString(meta.Resolution);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("CoordinateSystem");
                xmlWriter.WriteString(meta.CoordinateSystem);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("MapProjection");
                xmlWriter.WriteString(meta.MapProjection);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("UpperLeftLat");
                xmlWriter.WriteString(meta.UpperLeftLat);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("UpperLeftLon");
                xmlWriter.WriteString(meta.UpperLeftLon);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("UpperRightLat");
                xmlWriter.WriteString(meta.UpperRightLat);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("UpperRightLon");
                xmlWriter.WriteString(meta.UpperRightLon);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("LowerRightLat");
                xmlWriter.WriteString(meta.LowerRightLat);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("LowerRightLon");
                xmlWriter.WriteString(meta.LowerRightLon);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("LowerLeftLat");
                xmlWriter.WriteString(meta.LowerLeftLat);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("LowerLeftLon");
                xmlWriter.WriteString(meta.LowerLeftLon);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Region");
                xmlWriter.WriteString(meta.Region);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("ProductionDate");
                xmlWriter.WriteString(meta.ProductionDate);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("Description");
                xmlWriter.WriteString(meta.Description);
                xmlWriter.WriteEndElement();

                xmlWriter.WriteEndElement();
            }
            catch (Exception ex)
            {
                GFS.BLL.Log.WriteLog(typeof(TaskHistory), ex);
            }
            finally
            {
                xmlWriter.Flush();
                xmlWriter.Close();
            }
        }