private static ICoordinateSystem ReadCoordinateSystem(string coordinateSystem, WktStreamTokenizer tokenizer)
        {
            ICoordinateSystem returnCS = null;

            switch (coordinateSystem)
            {
            case "VERT_CS":
                IVerticalCoordinateSystem verticalCS = ReadVerticalCoordinateSystem(tokenizer);
                returnCS = verticalCS;
                break;

            case "GEOGCS":
                IGeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(tokenizer);
                returnCS = geographicCS;
                break;

            case "PROJCS":
                IProjectedCoordinateSystem projectedCS = ReadProjectedCoordinateSystem(tokenizer);
                returnCS = projectedCS;
                break;

            case "COMPD_CS":
                ICompoundCoordinateSystem compoundCS = ReadCompoundCoordinateSystem(tokenizer);
                returnCS = compoundCS;
                break;

            case "GEOCCS":
            case "FITTED_CS":
            case "LOCAL_CS":
                throw new InvalidOperationException(String.Format("{0} coordinate system is not recongized.", coordinateSystem));
            }
            return(returnCS);
        }
        private static void WriteCompoundCoordinateSystem(ICompoundCoordinateSystem compoundCoordinateSystem, XmlTextWriter writer)
        {
            writer.WriteStartElement("CS_CoordinateSystem");
            writer.WriteAttributeString("Dimension", compoundCoordinateSystem.Dimension.ToString());

            writer.WriteStartElement("CS_CompoundCoordinateSystem");


            WriteCSInfo(compoundCoordinateSystem, writer);
            for (int i = 0; i < compoundCoordinateSystem.Dimension; i++)
            {
                WriteAxis(compoundCoordinateSystem.GetAxis(i), writer);
            }

            writer.WriteStartElement("CS_CoordinateSystem");
            writer.WriteAttributeString("Dimension", compoundCoordinateSystem.HeadCS.Dimension.ToString());
            WriteCoordinateSystem(compoundCoordinateSystem.HeadCS, writer);
            writer.WriteEndElement();

            writer.WriteStartElement("CS_CoordinateSystem");
            writer.WriteAttributeString("Dimension", compoundCoordinateSystem.TailCS.Dimension.ToString());
            WriteCoordinateSystem(compoundCoordinateSystem.TailCS, writer);
            writer.WriteEndElement();

            writer.WriteEndElement();
            writer.WriteEndElement();
        }
        public void TestCompoundCoordinateSysem3()
        {
            ICompoundCoordinateSystem compoundsCRS = _factory.CreateCompoundCoordinateSystem("7405");

            Assertion.AssertEquals("ctor 1.", "OSGB36 / British National Grid + ODN", compoundsCRS.Name);
            Assertion.AssertEquals("ctor 2.", "OSGB 1936 / British National Grid", compoundsCRS.HeadCS.Name);
            Assertion.AssertEquals("ctor 3.", "Newlyn", compoundsCRS.TailCS.Name);
        }
        public void TestWrite2()
        {
            ICompoundCoordinateSystem compoundsCoordinateSsytem = _factory.CreateCompoundCoordinateSystem("7405");
            string wkt1 = CoordinateSystemWktWriter.Write(compoundsCoordinateSsytem);
            string wkt2 = compoundsCoordinateSsytem.WKT;

            Assertion.AssertEquals("test 1", wkt1, wkt2);
        }
        public void TestWrite1()
        {
            ICompoundCoordinateSystem compoundsCoordinateSsytem = _factory.CreateCompoundCoordinateSystem("7405");
            string wkt  = CoordinateSystemWktWriter.Write(compoundsCoordinateSsytem);
            bool   same = Compare.CompareAgainstString(Global.GetUnitTestRootDirectory() + @"\IO\CompoundCoordinateSystem.txt", wkt);

            Assertion.AssertEquals("test 1", true, same);
        }
Esempio n. 6
0
        public void TestReadCompoundCoordinateSystem2()
        {
            string testFile = Global.GetUnitTestRootDirectory() + @"\IO\CompoundCoordinateSystem.txt";
            string wkt1     = FileToString(testFile);
            ICompoundCoordinateSystem compoundCoordinateSystem = CoordinateSystemWktReader.Create(wkt1) as ICompoundCoordinateSystem;
            string wkt2 = compoundCoordinateSystem.WKT;
            bool   same = Compare.CompareAgainstString(testFile, wkt2);

            Assertion.AssertEquals("Compound coordinate system 1", true, same);
        }
        public void TestWriteCompoundCoordinateSystem()
        {
            ICompoundCoordinateSystem compoundsCoordinateSsytem = _factory.CreateCompoundCoordinateSystem("7405");
            TextWriter         textwriter         = new StringWriter();
            IndentedTextWriter indentedTextWriter = new IndentedTextWriter(textwriter);

            //CoordinateSystemWktWriter.WriteCompoundCoordinateSystem(compoundsCoordinateSsytem, indentedTextWriter);
            CoordinateSystemWktWriter.Write(compoundsCoordinateSsytem, indentedTextWriter);
            bool same = Compare.CompareAgainstString(Global.GetUnitTestRootDirectory() + @"\IO\CompoundCoordinateSystem.txt", textwriter.ToString());

            Assertion.AssertEquals("test 1", true, same);
        }
Esempio n. 8
0
 private static void WriteCompoundCoordinateSystem(ICompoundCoordinateSystem compoundCoordinateSystem, IndentedTextWriter writer)
 {
     writer.WriteLine("COMPD_CS[");
     writer.Indent = writer.Indent + 1;
     writer.WriteLine(String.Format("\"{0}\",", compoundCoordinateSystem.Name));
     WriteCoordinateSystem(compoundCoordinateSystem.HeadCS, writer);
     writer.WriteLine(",");
     WriteCoordinateSystem(compoundCoordinateSystem.TailCS, writer);
     writer.WriteLine(",");
     writer.WriteLine(String.Format("AUTHORITY[\"{0}\",\"{1}\"]", compoundCoordinateSystem.Authority, compoundCoordinateSystem.AuthorityCode));
     writer.Indent = writer.Indent - 1;
     writer.WriteLine("]");
 }
Esempio n. 9
0
        private static ICoordinateSystem ReadCoordinateSystem(XmlTextReader reader)
        {
            //reader.Read();
            ICoordinateSystem returnCS = null;

            switch (reader.Name)
            {
            case "CS_VerticalCoordinateSystem":
                IVerticalCoordinateSystem verticalCS = ReadVerticalCoordinateSystem(reader);
                returnCS = verticalCS;
                break;

            case "CS_GeographicCoordinateSystem":
                IGeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(reader);
                returnCS = geographicCS;
                break;

            case "CS_ProjectedCoordinateSystem":
                IProjectedCoordinateSystem projectedCS = ReadProjectedCoordinateSystem(reader);
                returnCS = projectedCS;
                break;

            case "CS_CompoundCoordinateSystem":
                ICompoundCoordinateSystem compoundCS = ReadCompoundCoordinateSystem(reader);
                returnCS = compoundCS;
                break;

            case "GEOCCS":
            case "FITTED_CS":
            case "LOCAL_CS":
                throw new InvalidOperationException(String.Format("{0} coordinate system is not recongized.", reader.Name));
                //default:
                //	throw new ParseException(String.Format("Coordinate System {0} was not understoon.",reader.Name));
            }
            //reader.Read();
            return(returnCS);
        }
        /// <summary>
        /// Creates the appropriate object given a string containing XML.
        /// </summary>
        /// <param name="wkt">String containing XML.</param>
        /// <returns>Object representation of the XML.</returns>
        /// <exception cref="ParseException">If a token is not recognised.</exception>
        public static object Create(string wkt)
        {
            object             returnObject = null;
            StringReader       reader       = new StringReader(wkt);
            WktStreamTokenizer tokenizer    = new WktStreamTokenizer(reader);

            tokenizer.NextToken();
            string objectName = tokenizer.GetStringValue();

            switch (objectName)
            {
            case "UNIT":
                IUnit unit = ReadUnit(tokenizer);
                returnObject = unit;
                break;

            case "VERT_DATUM":
                IVerticalDatum verticalDatum = ReadVerticalDatum(tokenizer);
                returnObject = verticalDatum;
                break;

            case "SPHEROID":
                IEllipsoid ellipsoid = ReadEllipsoid(tokenizer);
                returnObject = ellipsoid;
                break;

            case "TOWGS84":
                WGS84ConversionInfo wgsInfo = ReadWGS84ConversionInfo(tokenizer);
                returnObject = wgsInfo;
                break;

            case "DATUM":
                IHorizontalDatum horizontalDatum = ReadHorizontalDatum(tokenizer);
                returnObject = horizontalDatum;
                break;

            case "PRIMEM":
                IPrimeMeridian primeMeridian = ReadPrimeMeridian(tokenizer);
                returnObject = primeMeridian;
                break;

            case "VERT_CS":
                IVerticalCoordinateSystem verticalCS = ReadVerticalCoordinateSystem(tokenizer);
                returnObject = verticalCS;
                break;

            case "GEOGCS":
                IGeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(tokenizer);
                returnObject = geographicCS;
                break;

            case "PROJCS":
                IProjectedCoordinateSystem projectedCS = ReadProjectedCoordinateSystem(tokenizer);
                returnObject = projectedCS;
                break;

            case "COMPD_CS":
                ICompoundCoordinateSystem compoundCS = ReadCompoundCoordinateSystem(tokenizer);
                returnObject = compoundCS;
                break;

            case "GEOCCS":
            case "FITTED_CS":
            case "LOCAL_CS":
                throw new NotSupportedException(String.Format("{0} is not implemented.", objectName));

            default:
                throw new ParseException(String.Format("'{0'} is not recongnized.", objectName));
            }
            reader.Close();
            return(returnObject);
        }
Esempio n. 11
0
        public static object Create(XmlTextReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            // we don't want to handle whitespace
            reader.WhitespaceHandling = WhitespaceHandling.None;
            object returnObject = null;

            reader.Read();


            // skip declarions and comments.
            while (reader.NodeType != XmlNodeType.Element)
            {
                reader.Read();
            }

            if (reader.NodeType == XmlNodeType.Element)
            {
                switch (reader.Name)
                {
                case "CS_LinearUnit":
                    ILinearUnit linearUnit = ReadLinearUnit(reader);
                    returnObject = linearUnit;
                    break;

                case "CS_AngularUnit":
                    IAngularUnit angularUnit = ReadAngularUnit(reader);
                    returnObject = angularUnit;
                    break;

                case "CS_VerticalDatum":
                    IVerticalDatum verticalDatum = ReadVerticalDatum(reader);
                    returnObject = verticalDatum;
                    break;

                case "CS_Ellipsoid":
                    IEllipsoid ellipsoid = ReadEllipsoid(reader);
                    returnObject = ellipsoid;
                    break;

                case "CS_WGS84ConversionInfo":
                    WGS84ConversionInfo wgsInfo = ReadWGS84ConversionInfo(reader);
                    returnObject = wgsInfo;
                    break;

                case "CS_HorizontalDatum":
                    IHorizontalDatum horizontalDatum = ReadHorizontalDatum(reader);
                    returnObject = horizontalDatum;
                    break;

                case "CS_PrimeMeridian":
                    IPrimeMeridian primeMeridian = ReadPrimeMeridian(reader);
                    returnObject = primeMeridian;
                    break;

                case "CS_VerticalCoordinateSystem":
                    IVerticalCoordinateSystem verticalCS = ReadVerticalCoordinateSystem(reader);
                    returnObject = verticalCS;
                    break;

                case "CS_GeographicCoordinateSystem":
                    IGeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(reader);
                    returnObject = geographicCS;
                    break;

                case "CS_ProjectedCoordinateSystem":
                    IProjectedCoordinateSystem projectedCS = ReadProjectedCoordinateSystem(reader);
                    returnObject = projectedCS;
                    break;

                case "CS_CompoundCoordinateSystem":
                    ICompoundCoordinateSystem compoundCS = ReadCompoundCoordinateSystem(reader);
                    returnObject = compoundCS;
                    break;

                case "CS_Projection":
                    IProjection projection = ReadProjection(reader);
                    returnObject = projection;
                    break;

                case "CS_CoordinateSystem":
                    // must be a compound coord sys since all other coord system should have been
                    // taken care of by now.
                    reader.Read();
                    ICoordinateSystem coordinateSystem = ReadCompoundCoordinateSystem(reader);
                    reader.Read();
                    returnObject = coordinateSystem;
                    break;

                case "CS_GEOCCS":
                case "CS_FITTED_CS":
                case "CS_LOCAL_CS":
                    throw new NotSupportedException(String.Format("{0} is not implemented.", reader.Name));

                default:
                    throw new ParseException(String.Format("Element type {0} was is not understoon.", reader.Name));
                }
            }

            return(returnObject);
        }
Esempio n. 12
0
 public void TestCompoundCoordinateSystem()
 {
     ICompoundCoordinateSystem compoundCoordinateSystem = _factory.CreateCompoundCoordinateSystem("7405");
     string test1 = CoordinateSystemXmlWriter.Write(compoundCoordinateSystem);
 }
Esempio n. 13
0
 private static void WriteCompoundCoordinateSystem(ICompoundCoordinateSystem compoundCoordinateSystem, IndentedTextWriter writer)
 {
     writer.WriteLine("COMPD_CS[");
     writer.Indent=writer.Indent+1;
     writer.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture,"\"{0}\",", compoundCoordinateSystem.Name));
     WriteCoordinateSystem(compoundCoordinateSystem.HeadCS, writer);
     writer.WriteLine(",");
     WriteCoordinateSystem(compoundCoordinateSystem.TailCS, writer);
     writer.WriteLine(",");
     writer.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "AUTHORITY[\"{0}\",\"{1}\"]", compoundCoordinateSystem.Authority, compoundCoordinateSystem.AuthorityCode));
     writer.Indent=writer.Indent-1;
     writer.WriteLine("]");
 }