private static CoordinateSystem ReadCoordinateSystem(string coordinateSystem, WktStreamTokenizer tokenizer, bool includeAuthority) { CoordinateSystem returnCS = null; switch (coordinateSystem) { case "VERT_CS": VerticalCoordinateSystem verticalCS = ReadVerticalCoordinateSystem(tokenizer, includeAuthority); returnCS = verticalCS; break; case "GEOGCS": GeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(tokenizer, includeAuthority); returnCS = geographicCS; break; case "PROJCS": ProjectedCoordinateSystem projectedCS = ReadProjectedCoordinateSystem(tokenizer, includeAuthority); returnCS = projectedCS; break; case "COMPD_CS": CompoundCoordinateSystem compoundCS = ReadCompoundCoordinateSystem(tokenizer, includeAuthority); 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(CompoundCoordinateSystem compoundCoordinateSystem, bool esri, IndentedTextWriter writer) { writer.WriteLine("COMPD_CS["); writer.Indent = writer.Indent + 1; writer.WriteLine(String.Format("\"{0}\",", compoundCoordinateSystem.Name)); WriteCoordinateSystem(compoundCoordinateSystem.HeadCS, esri, writer); writer.WriteLine(","); WriteCoordinateSystem(compoundCoordinateSystem.TailCS, esri, writer); writer.WriteLine(","); //writer.WriteLine(String.Format("AUTHORITY[\"{0}\",\"{1}\"]", compoundCoordinateSystem.Authority, compoundCoordinateSystem.AuthorityCode)); WriteAuthority(compoundCoordinateSystem, esri, writer); writer.Indent = writer.Indent - 1; writer.WriteLine("]"); }
private static CompoundCoordinateSystem ReadCompoundCoordinateSystem(WktStreamTokenizer tokenizer, bool includeAuthority) { //COMPD_CS[ //"OSGB36 / British National Grid + ODN", //PROJCS[] //VERT_CS[] //AUTHORITY["EPSG","7405"] //] //TODO add a ReadCoordinateSystem - that determines the correct coordinate system to //read. Right now this hard coded for a projected and a vertical coord sys - so the UK //national grid works. tokenizer.ReadToken("["); string name = tokenizer.ReadDoubleQuotedWord(); tokenizer.ReadToken(","); tokenizer.NextToken(); string headCSCode = tokenizer.GetStringValue(); CoordinateSystem headCS = ReadCoordinateSystem(headCSCode, tokenizer, includeAuthority); tokenizer.ReadToken(","); tokenizer.NextToken(); string tailCSCode = tokenizer.GetStringValue(); CoordinateSystem tailCS = ReadCoordinateSystem(tailCSCode, tokenizer, includeAuthority); string authority = String.Empty; string authorityCode = String.Empty; if (includeAuthority) { tokenizer.ReadToken(","); tokenizer.ReadAuthority(ref authority, ref authorityCode); } tokenizer.ReadToken("]"); CompoundCoordinateSystem compoundCS = new CompoundCoordinateSystem(headCS, tailCS, String.Empty, authority, authorityCode, name, String.Empty, String.Empty); return(compoundCS); }
public static object Create(string wkt) { object returnObject = null; bool includeAuthority = (wkt.ToLower().IndexOf("authority") != -1); StringReader reader = new StringReader(wkt); WktStreamTokenizer tokenizer = new WktStreamTokenizer(reader); tokenizer.NextToken(); string objectName = tokenizer.GetStringValue(); switch (objectName) { case "UNIT": Unit unit = ReadUnit(tokenizer, includeAuthority); returnObject = unit; break; case "VERT_DATUM": VerticalDatum verticalDatum = ReadVerticalDatum(tokenizer, includeAuthority); returnObject = verticalDatum; break; case "SPHEROID": Ellipsoid ellipsoid = ReadEllipsoid(tokenizer, includeAuthority); returnObject = ellipsoid; break; case "TOWGS84": WGS84ConversionInfo wgsInfo = ReadWGS84ConversionInfo(tokenizer, includeAuthority); returnObject = wgsInfo; break; case "DATUM": HorizontalDatum horizontalDatum = ReadHorizontalDatum(tokenizer, includeAuthority); returnObject = horizontalDatum; break; case "PRIMEM": PrimeMeridian primeMeridian = ReadPrimeMeridian(tokenizer, includeAuthority); returnObject = primeMeridian; break; case "VERT_CS": VerticalCoordinateSystem verticalCS = ReadVerticalCoordinateSystem(tokenizer, includeAuthority); returnObject = verticalCS; break; case "GEOGCS": GeographicCoordinateSystem geographicCS = ReadGeographicCoordinateSystem(tokenizer, includeAuthority); returnObject = geographicCS; break; case "PROJCS": ProjectedCoordinateSystem projectedCS = ReadProjectedCoordinateSystem(tokenizer, includeAuthority); returnObject = projectedCS; break; case "COMPD_CS": CompoundCoordinateSystem compoundCS = ReadCompoundCoordinateSystem(tokenizer, includeAuthority); 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); }