private Projection decodeProjection() { matchesElementSeparator(); if (currentToken != CrsWktVariant.PROJECTION) { throw new WktDecodeException("Expected PROJECTION keyword, found " + currentToken.toString()); } String name = decodeName(); CrsId crsId = decodeOptionalAuthority(CrsId.UNDEFINED.getCode()); matchesCloseList(); return new Projection(crsId, name); }
private PrimeMeridian decodePrimem() { if (currentToken != CrsWktVariant.PRIMEM) { throw new WktDecodeException("Expected PRIMEM keyword, received " + currentToken.toString()); } String name = decodeName(); matchesElementSeparator(); double longitude = decodeNumber(); CrsId crsId = decodeOptionalAuthority(CrsId.UNDEFINED.getCode()); matchesCloseList(); return new PrimeMeridian(crsId, name, longitude); }
private VerticalDatum decodeVertDatum() { if (currentToken != CrsWktVariant.VERT_DATUM) { throw new WktDecodeException("Expected VERT_DATUM keyword, found " + currentToken.toString()); } String name = decodeName(); matchesElementSeparator(); int type = decodeInt(); Extension extension = decodeOptionalExtension(); CrsId authority = decodeOptionalAuthority(srid); matchesCloseList(); return new VerticalDatum(authority, name, type, extension); }
throw new WktDecodeException("Expected AXIS keyword, found " + currentToken.toString()); String name = decodeName(); matchesElementSeparator(); CoordinateSystemAxisDirection direction = CoordinateSystemAxisDirection.valueOf(currentToken.toString());
private <P extends Position> CompoundCoordinateReferenceSystem<P> decodeCompoundCrs() { String crsName = decodeName(); matchesElementSeparator(); SingleCoordinateReferenceSystem<?> head = (SingleCoordinateReferenceSystem<?>)decode(); matchesElementSeparator(); SingleCoordinateReferenceSystem<?> tail = (SingleCoordinateReferenceSystem<?>)decode(); CrsId cr = decodeOptionalAuthority(srid); return new CompoundCoordinateReferenceSystem<P>(cr, crsName, head, tail); }
private Unit decodeUnit(boolean isLinear) { if (currentToken != CrsWktVariant.UNIT) { throw new WktDecodeException("Expected UNIT keyword, found " + currentToken.toString()); } String name = decodeName(); matchesElementSeparator(); double cf = decodeNumber(); matchesElementSeparator(); CrsId crsId = decodeOptionalAuthority(CrsId.UNDEFINED.getCode()); matchesCloseList(); return isLinear ? new LinearUnit(crsId, name, cf) : new AngularUnit(crsId, name, cf); }
private CrsParameter decodeOptionalParameter() { matchesElementSeparator(); if (currentToken != CrsWktVariant.PARAMETER) { return null; } nextToken(); String name = decodeName(); matchesElementSeparator(); double value = decodeNumber(); matchesCloseList(); return new CrsParameter(name, value); }
private Ellipsoid decodeSpheroid() { if (currentToken != CrsWktVariant.SPHEROID) { throw new WktDecodeException("Expected SPHEROID keyword, but received " + currentToken.toString()); } String ellipsoidName = decodeName(); matchesElementSeparator(); double semiMajorAxis = decodeNumber(); matchesElementSeparator(); double inverseFlattening = decodeNumber(); CrsId crsId = decodeOptionalAuthority(CrsId.UNDEFINED.getCode()); matchesCloseList(); return new Ellipsoid(crsId, ellipsoidName, semiMajorAxis, inverseFlattening); }
private Datum decodeDatum() { if (currentToken != CrsWktVariant.DATUM) { throw new WktDecodeException("Expected DATUM token."); } String datumName = decodeName(); matchesElementSeparator(); Ellipsoid ellipsoid = decodeSpheroid(); double[] toWGS84 = decodeOptionalToWGS84(); CrsId crsId = decodeOptionalAuthority(CrsId.UNDEFINED.getCode()); matchesCloseList(); return new Datum(crsId, ellipsoid, datumName, toWGS84); }
private VerticalCoordinateReferenceSystem decodeVertCS() { String crsName = decodeName(); matchesElementSeparator(); VerticalDatum vdatum = decodeVertDatum(); matchesElementSeparator(); LinearUnit unit =(LinearUnit) decodeUnit(true); matchesElementSeparator(); VerticalStraightLineAxis axis = (VerticalStraightLineAxis)decodeAxis(unit, VerticalCoordinateReferenceSystem.class); CrsId id = decodeOptionalAuthority(); return new VerticalCoordinateReferenceSystem(id, crsName, vdatum, axis); }
/** e * Currently not used in Postgis and also not implemented here! * * @throws UnsupportedConversionException Geocentric CRS is currently not implemented */ private GeocentricCartesianCoordinateReferenceSystem decodeGeocentricCrs() { String crsName = decodeName(); matchesElementSeparator(); Datum datum = decodeDatum(); matchesElementSeparator(); PrimeMeridian primem = decodePrimem(); matchesElementSeparator(); Unit unit = decodeUnit(true); CoordinateSystemAxis[] axes = decodeOptionalAxes(3, unit, GeocentricCartesianCoordinateReferenceSystem.class); CrsId cr = decodeOptionalAuthority(srid); matchesCloseList(); GeocentricCartesianCoordinateReferenceSystem system = new GeocentricCartesianCoordinateReferenceSystem(cr, crsName, datum, primem, new CartesianCoordinateSystem3D((StraightLineAxis)axes[0], (StraightLineAxis)axes[1], (VerticalStraightLineAxis) axes[2]) ); return system; }
/** * Implementation to decode a Geographic CRS. * * @return The <code>GeographicCoordinateReferenceSystem</code> that is decoded from the WKT. */ private Geographic2DCoordinateReferenceSystem decodeGeographicCrs() { String crsName = decodeName(); matchesElementSeparator(); Datum datum = decodeDatum(); matchesElementSeparator(); PrimeMeridian primem = decodePrimem(); matchesElementSeparator(); Unit unit = decodeUnit(false); CoordinateSystemAxis[] twinAxes = decodeOptionalAxes(2, unit, Geographic2DCoordinateReferenceSystem.class); CrsId cr = decodeOptionalAuthority(srid); matchesCloseList(); Geographic2DCoordinateReferenceSystem system = new Geographic2DCoordinateReferenceSystem(cr, crsName, new EllipsoidalCoordinateSystem2D((EllipsoidalAxis) twinAxes[0], (EllipsoidalAxis) twinAxes[1])); system.setDatum(datum); system.setPrimeMeridian(primem); return system; }
/** * 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); }