/** * Determines the WKT variant and calls the according method to decode the WKT. * * @return The decoded WKT as a <code>CoordinateReferenceSystem</code> object. */ private CoordinateReferenceSystem<? extends Position> decode() { if (currentToken == CrsWktVariant.PROJCS) { return decodeProjectedCrs(); } else if (currentToken == CrsWktVariant.GEOGCS) { return decodeGeographicCrs(); } else if (currentToken == CrsWktVariant.GEOCCS) { return decodeGeocentricCrs(); } else if (currentToken == CrsWktVariant.COMPD_CS) { return decodeCompoundCrs(); } else if (currentToken == CrsWktVariant.VERT_CS) { return decodeVertCS(); } throw new WktDecodeException("Expected Wkt Token PROJCS, GEOGCS, GEOCCS or COMPD_CS. Received " + currentToken); }
/** * Implementation to decode a Projected CRS. * * @return The <code>ProjectedCoordinateReferenceSystem</code> that is decoded from the WKT. */ private ProjectedCoordinateReferenceSystem decodeProjectedCrs() { String crsName = decodeName(); matchesElementSeparator(); Geographic2DCoordinateReferenceSystem geogcs = decodeGeographicCrs(); matchesElementSeparator(); Unit unit; Projection projection; List<CrsParameter> parameters; // spatial_reference.sql contains both variants of ProjCRS Wkt if (currentToken == CrsWktVariant.UNIT) { unit = decodeUnit(true); projection = decodeProjection(); parameters = decodeOptionalParameters(); } else { projection = decodeProjection(); parameters = decodeOptionalParameters(); unit = decodeUnit(true); } CoordinateSystemAxis[] twinAxes = decodeOptionalAxes(2, unit, ProjectedCoordinateReferenceSystem.class); Extension extension = decodeOptionalExtension(); CrsId crsId = decodeOptionalAuthority(srid); matchesCloseList(); return new ProjectedCoordinateReferenceSystem(crsId, crsName, geogcs, projection, parameters, new CartesianCoordinateSystem2D((StraightLineAxis)twinAxes[0], (StraightLineAxis)twinAxes[1]), extension); }