/** * Returns {@code true} if the given formatter is in the process of formatting the base CRS of an * {@link AbstractDerivedCRS}. In such case, the coordinate system axes shall not be formatted. * * <p>This method should return {@code true} when {@code this} CRS is the value returned by * {@link GeneralDerivedCRS#getBaseCRS()} (typically {@link AbstractDerivedCRS#getBaseCRS()}). * Since the base CRS is the only CRS enclosed in derived CRS, we should have no ambiguity * (assuming that the user did not created some weird subclass).</p> * * <p>This method should be invoked for WKT 2 formatting only.</p> */ static boolean isBaseCRS(final Formatter formatter) { return formatter.getEnclosingElement(1) instanceof GeneralDerivedCRS; }
/** * Returns {@code true} if the given formatter is in the process of formatting the base CRS of an * {@link AbstractDerivedCRS}. In such case, the coordinate system axes shall not be formatted. * * <p>This method should return {@code true} when {@code this} CRS is the value returned by * {@link GeneralDerivedCRS#getBaseCRS()} (typically {@link AbstractDerivedCRS#getBaseCRS()}). * Since the base CRS is the only CRS enclosed in derived CRS, we should have no ambiguity * (assuming that the user did not created some weird subclass).</p> * * <p>This method should be invoked for WKT 2 formatting only.</p> */ static boolean isBaseCRS(final Formatter formatter) { return formatter.getEnclosingElement(1) instanceof GeneralDerivedCRS; }
/** * Returns {@code true} if the given formatter is in the process of formatting the prime meridian of a base CRS * of an {@code AbstractDerivedCRS}. In such case, base CRS coordinate system axes shall not be formatted, which * has the consequence of bringing the {@code UNIT[…]} element right below the {@code PRIMEM[…]} one. Example: * * {@preformat wkt * ProjectedCRS[“NTF (Paris) / Lambert zone II”, * BaseGeodCRS[“NTF (Paris)”, * Datum[“Nouvelle Triangulation Francaise”, * Ellipsoid[“NTF”, 6378249.2, 293.4660212936269]], * PrimeMeridian[“Paris”, 2.5969213], * AngleUnit[“grad”, 0.015707963267948967]], * Conversion[“Lambert zone II”, * etc... * } * * If we were not formatting a base CRS, we would have many lines between {@code PrimeMeridian[…]} and * {@code AngleUnit[…]} in the above example, which would make less obvious that the angle unit applies * also to the prime meridian. It does not bring any ambiguity from an ISO 19162 standard point of view, * but historically some other software products interpreted the {@code PRIMEM[…]} units wrongly, which * is why we try to find a compromise between keeping the WKT simple and avoiding an historical ambiguity. * * @see org.apache.sis.referencing.crs.AbstractCRS#isBaseCRS(Formatter) */ private static boolean isElementOfBaseCRS(final Formatter formatter) { return formatter.getEnclosingElement(2) instanceof GeneralDerivedCRS; }
/** * Returns {@code true} if the given formatter is in the process of formatting the prime meridian of a base CRS * of an {@code AbstractDerivedCRS}. In such case, base CRS coordinate system axes shall not be formatted, which * has the consequence of bringing the {@code UNIT[…]} element right below the {@code PRIMEM[…]} one. Example: * * {@preformat wkt * ProjectedCRS[“NTF (Paris) / Lambert zone II”, * BaseGeodCRS[“NTF (Paris)”, * Datum[“Nouvelle Triangulation Francaise”, * Ellipsoid[“NTF”, 6378249.2, 293.4660212936269]], * PrimeMeridian[“Paris”, 2.5969213], * AngleUnit[“grad”, 0.015707963267948967]], * Conversion[“Lambert zone II”, * etc... * } * * If we were not formatting a base CRS, we would have many lines between {@code PrimeMeridian[…]} and * {@code AngleUnit[…]} in the above example, which would make less obvious that the angle unit applies * also to the prime meridian. It does not bring any ambiguity from an ISO 19162 standard point of view, * but historically some other software products interpreted the {@code PRIMEM[…]} units wrongly, which * is why we try to find a compromise between keeping the WKT simple and avoiding an historical ambiguity. * * @see org.apache.sis.referencing.crs.AbstractCRS#isBaseCRS(Formatter) */ private static boolean isElementOfBaseCRS(final Formatter formatter) { return formatter.getEnclosingElement(2) instanceof GeneralDerivedCRS; }
/** * Returns the enclosing coordinate system, or {@code null} if none. In ISO 19162 compliant WKT the coordinate * <strong>reference</strong> system should be the first parent ({@code formatter.getEnclosingElement(1)}) and * the coordinate system shall be obtained from that CRS (yes, this is convolved. This is because of historical * reasons, since compatibility with WKT 1 was a requirement of WKT 2). */ private static CoordinateSystem getEnclosingCS(final Formatter formatter) { final FormattableObject e = formatter.getEnclosingElement(1); if (e instanceof CoordinateReferenceSystem) { // This is what we expect in standard WKT. return ((CoordinateReferenceSystem) e).getCoordinateSystem(); } if (e instanceof CoordinateSystem) { // Not standard WKT, but conceptually the right thing. return (CoordinateSystem) e; } return null; }
/** * Returns the enclosing coordinate system, or {@code null} if none. In ISO 19162 compliant WKT the coordinate * <strong>reference</strong> system should be the first parent ({@code formatter.getEnclosingElement(1)}) and * the coordinate system shall be obtained from that CRS (yes, this is convolved. This is because of historical * reasons, since compatibility with WKT 1 was a requirement of WKT 2). */ private static CoordinateSystem getEnclosingCS(final Formatter formatter) { final FormattableObject e = formatter.getEnclosingElement(1); if (e instanceof CoordinateReferenceSystem) { // This is what we expect in standard WKT. return ((CoordinateReferenceSystem) e).getCoordinateSystem(); } if (e instanceof CoordinateSystem) { // Not standard WKT, but conceptually the right thing. return (CoordinateSystem) e; } return null; }
final Integer code = Units.getEpsgCode(unit, getEnclosingElement(1) instanceof CoordinateSystemAxis); if (code != null) { openElement(false, isWKT1 ? WKTKeywords.Authority : WKTKeywords.Id);
final Integer code = Units.getEpsgCode(unit, getEnclosingElement(1) instanceof CoordinateSystemAxis); if (code != null) { openElement(false, isWKT1 ? WKTKeywords.Authority : WKTKeywords.Id);
final FormattableObject enclosing = formatter.getEnclosingElement(1); final boolean isRoot = formatter.getEnclosingElement(2) == null; if (isRoot || !(enclosing instanceof ParameterValue<?>)) { final String citation = org.apache.sis.internal.util.Citations.getIdentifier(authority, false);
final FormattableObject enclosing = formatter.getEnclosingElement(1); final boolean isRoot = formatter.getEnclosingElement(2) == null; if (isRoot || !(enclosing instanceof ParameterValue<?>)) { final String citation = org.apache.sis.internal.util.Citations.getIdentifier(authority, false);
final FormattableObject parent = formatter.getEnclosingElement(isWKT1 ? 1 : 2); if (parent instanceof GeneralDerivedCRS) { final Conversion conversion = ((GeneralDerivedCRS) parent).getConversionFromBase();
final FormattableObject parent = formatter.getEnclosingElement(isWKT1 ? 1 : 2); if (parent instanceof GeneralDerivedCRS) { final Conversion conversion = ((GeneralDerivedCRS) parent).getConversionFromBase();
if (!(formatter.getEnclosingElement(1) instanceof GeodeticCRS)) { return formatter.shortOrLong(WKTKeywords.Datum, WKTKeywords.GeodeticDatum);
if (!(formatter.getEnclosingElement(1) instanceof GeodeticCRS)) { return formatter.shortOrLong(WKTKeywords.Datum, WKTKeywords.GeodeticDatum);
final FormattableObject enclosing = formatter.getEnclosingElement(1); final boolean isSubOperation = (enclosing instanceof PassThroughOperation); final boolean isComponent = (enclosing instanceof ConcatenatedOperation);
final FormattableObject enclosing = formatter.getEnclosingElement(1); final boolean isSubOperation = (enclosing instanceof PassThroughOperation); final boolean isComponent = (enclosing instanceof ConcatenatedOperation);