Exemplo n.º 1
0
        /// <summary>
        /// Reads the reference system stored in the metafile stream.
        /// </summary>
        /// <returns>The reference system.</returns>
        protected override IReferenceSystem ReadReferenceSystemInternal()
        {
            IReferenceSystem referenceSystem        = null;
            XElement         referenceSystemElement = _document.Element("Dimap_Document").Element("Coordinate_Reference_System");

            if (referenceSystemElement == null)
            {
                return(null);
            }

            // horizontal reference system based on type
            XElement codeElement = referenceSystemElement.Element("Horizontal_CS").Element("HORIZONTAL_CS_CODE");
            XElement nameElement = referenceSystemElement.Element("Horizontal_CS").Element("HORIZONTAL_CS_NAME");

            switch (referenceSystemElement.Element("Horizontal_CS").Element("HORIZONTAL_CS_TYPE").Value)
            {
            case "GEOGRAPHIC":
                if (codeElement == null)
                {
                    codeElement = referenceSystemElement.Element("Horizontal_CS").Element("Geographic_CS").Element("GEOGRAPHIC_CS_CODE");
                }
                if (nameElement == null)
                {
                    nameElement = referenceSystemElement.Element("Horizontal_CS").Element("Geographic_CS").Element("GEOGRAPHIC_CS_NAME");
                }

                if (codeElement != null)
                {
                    referenceSystem = Geographic2DCoordinateReferenceSystems.FromIdentifier(codeElement.Value).FirstOrDefault();
                }
                if (referenceSystem == null && nameElement != null)
                {
                    referenceSystem = Geographic2DCoordinateReferenceSystems.FromName(nameElement.Value).FirstOrDefault();
                }

                // TODO: process custom datums
                break;

            case "PROJECTED":
                if (codeElement != null)
                {
                    referenceSystem = ProjectedCoordinateReferenceSystems.FromIdentifier(codeElement.Value).FirstOrDefault();
                }
                if (referenceSystem == null && nameElement != null)
                {
                    referenceSystem = ProjectedCoordinateReferenceSystems.FromName(nameElement.Value).FirstOrDefault();
                }

                // TODO: process custom projections
                break;
                // TODO: process other horizontal reference system information
            }

            // TODO: process vertical reference system information

            return(referenceSystem);
        }
        /// <summary>
        /// Reads the reference system stored in the metafile stream.
        /// </summary>
        /// <returns>The reference system.</returns>
        protected override IReferenceSystem ReadReferenceSystemInternal()
        {
            ReadContent();

            if (_metadata.ContainsKey("MAP_PROJECTION"))
            {
                return(ProjectedCoordinateReferenceSystems.FromName(_metadata["MAP_PROJECTION"]).FirstOrDefault());
            }

            return(Geographic2DCoordinateReferenceSystems.FromName(_metadata["DATUM"]).FirstOrDefault());
        }