/** * Formats the given area and its transform as a pseudo-WKT. * For {@link SpecializableTransform#formatTo(Formatter)} implementation only. */ static void format(SubArea area, final Formatter formatter) { while (area != null) { formatter.newLine(); formatter.append(area); formatter.newLine(); formatter.append(area.transform); area = area.specialization; } }
/** * Appends the given CRS (if non-null) wrapped in an element of the given name. * * @param formatter the formatter where to append the object name. * @param crs the object to append, or {@code null} if none. * @param type the keyword to write before the object. */ private static void append(final Formatter formatter, final CoordinateReferenceSystem crs, final String type) { if (crs != null) { formatter.append(new FormattableObject() { @Override protected String formatTo(final Formatter formatter) { formatter.indent(-1); formatter.append(WKTUtilities.toFormattable(crs)); formatter.indent(+1); return type; } }); formatter.newLine(); } }
/** * Appends the given CRS (if non-null) wrapped in an element of the given name. * * @param formatter the formatter where to append the object name. * @param crs the object to append, or {@code null} if none. * @param type the keyword to write before the object. */ private static void append(final Formatter formatter, final CoordinateReferenceSystem crs, final String type) { if (crs != null) { formatter.append(new FormattableObject() { @Override protected String formatTo(final Formatter formatter) { formatter.indent(-1); formatter.append(WKTUtilities.toFormattable(crs)); formatter.indent(+1); return type; } }); formatter.newLine(); } }
/** Formats this {@code Conversion} element. */ @Override protected String formatTo(final Formatter formatter) { WKTUtilities.appendName(conversion, formatter, null); formatter.newLine(); append(formatter); return WKTKeywords.Conversion; }
/** * Closes the element opened by {@link #openElement(boolean, String)}. * * @param newLine {@code true} for invoking {@link #newLine()} last. */ private void closeElement(final boolean newLine) { buffer.appendCodePoint(symbols.getClosingBracket(0)); if (newLine) { newLine(); } }
/** Formats this {@code Conversion} element. */ @Override protected String formatTo(final Formatter formatter) { WKTUtilities.appendName(conversion, formatter, null); formatter.newLine(); append(formatter); return WKTKeywords.Conversion; }
/** * Closes the element opened by {@link #openElement(boolean, String)}. * * @param newLine {@code true} for invoking {@link #newLine()} last. */ private void closeElement(final boolean newLine) { buffer.appendCodePoint(symbols.getClosingBracket(0)); if (newLine) { newLine(); } }
/** * Appends a separator if needed, then opens a new element. * * @param newLine {@code true} for invoking {@link #newLine()} first. * @param keyword the element keyword (e.g. {@code "DATUM"}, {@code "AXIS"}, <i>etc</i>). */ private void openElement(final boolean newLine, String keyword) { if (newLine && buffer.length() != elementStart) { newLine(); } appendSeparator(); if (toUpperCase != 0) { final Locale locale = symbols.getLocale(); keyword = (toUpperCase >= 0) ? keyword.toUpperCase(locale) : keyword.toLowerCase(locale); } elementStart = buffer.append(keyword).appendCodePoint(symbols.getOpeningBracket(0)).length(); }
/** * Appends a separator if needed, then opens a new element. * * @param newLine {@code true} for invoking {@link #newLine()} first. * @param keyword the element keyword (e.g. {@code "DATUM"}, {@code "AXIS"}, <i>etc</i>). */ private void openElement(final boolean newLine, String keyword) { if (newLine && buffer.length() != elementStart) { newLine(); } appendSeparator(); if (toUpperCase != 0) { final Locale locale = symbols.getLocale(); keyword = (toUpperCase >= 0) ? keyword.toUpperCase(locale) : keyword.toLowerCase(locale); } elementStart = buffer.append(keyword).appendCodePoint(symbols.getOpeningBracket(0)).length(); }
/** * Appends a {@linkplain ParameterValue parameter} in a {@code PARAMETER[…]} element. * If the supplied parameter is actually a {@linkplain ParameterValueGroup parameter group}, * all contained parameters will be flattened in a single list. * * @param parameter the parameter to append to the WKT, or {@code null} if none. * @param formatter the formatter where to append the parameter. */ public static void append(GeneralParameterValue parameter, final Formatter formatter) { if (parameter instanceof ParameterValueGroup) { boolean first = true; for (final GeneralParameterValue param : ((ParameterValueGroup) parameter).values()) { if (first) { formatter.newLine(); first = false; } append(param, formatter); } } if (parameter instanceof ParameterValue<?>) { if (!(parameter instanceof FormattableObject)) { parameter = new DefaultParameterValue<>((ParameterValue<?>) parameter); } formatter.append((FormattableObject) parameter); formatter.newLine(); } }
/** * Appends a {@linkplain ParameterValue parameter} in a {@code PARAMETER[…]} element. * If the supplied parameter is actually a {@linkplain ParameterValueGroup parameter group}, * all contained parameters will be flattened in a single list. * * @param parameter the parameter to append to the WKT, or {@code null} if none. * @param formatter the formatter where to append the parameter. */ public static void append(GeneralParameterValue parameter, final Formatter formatter) { if (parameter instanceof ParameterValueGroup) { boolean first = true; for (final GeneralParameterValue param : ((ParameterValueGroup) parameter).values()) { if (first) { formatter.newLine(); first = false; } append(param, formatter); } } if (parameter instanceof ParameterValue<?>) { if (!(parameter instanceof FormattableObject)) { parameter = new DefaultParameterValue<>((ParameterValue<?>) parameter); } formatter.append((FormattableObject) parameter); formatter.newLine(); } }
@Override protected String formatTo(final Formatter formatter) { WKTUtilities.appendName(conversion, formatter, null); formatter.newLine(); formatter.append(DefaultOperationMethod.castOrCopy(conversion.getMethod())); formatter.newLine(); for (final GeneralParameterValue param : conversion.getParameterValues().values()) { WKTUtilities.append(param, formatter); } return WKTKeywords.DerivingConversion; } });
@Override protected String formatTo(final Formatter formatter) { WKTUtilities.appendName(conversion, formatter, null); formatter.newLine(); formatter.append(DefaultOperationMethod.castOrCopy(conversion.getMethod())); formatter.newLine(); for (final GeneralParameterValue param : conversion.getParameterValues().values()) { WKTUtilities.append(param, formatter); } return WKTKeywords.DerivingConversion; } });
/** * Formats the inner part of a <cite>Well Known Text</cite> version 1 (WKT 1) element. * * <div class="note"><b>Compatibility note:</b> * The {@code SPECIALIZABLE_MT} element formatted here is an Apache SIS-specific extension.</div> * * @param formatter the formatter to use. * @return the WKT element name, which is {@code "Specializable_MT"}. */ @Override protected final String formatTo(final Formatter formatter) { formatter.newLine(); formatter.append(global); for (SubArea domain : domains) { SubArea.format(domain, formatter); } formatter.setInvalidWKT(SpecializableTransform.class, null); return "Specializable_MT"; }
/** * Formats a <cite>Well Known Text</cite> version 1 (WKT 1) element for a transform using this group of parameters. * * <div class="note"><b>Compatibility note:</b> * {@code Param_MT} is defined in the WKT 1 specification only. * If the {@linkplain Formatter#getConvention() formatter convention} is set to WKT 2, * then this method silently uses the WKT 1 convention without raising an error.</div> * * @return {@code "Param_MT"}. */ @Override protected String formatTo(final Formatter formatter) { if (inverse) { formatter.newLine(); formatter.append(new WKT(false)); return WKTKeywords.Inverse_MT; } else { WKTUtilities.appendParamMT(ContextualParameters.this, formatter); return WKTKeywords.Param_MT; } } }
/** * Formats a <cite>Well Known Text</cite> version 1 (WKT 1) element for a transform using this group of parameters. * * <div class="note"><b>Compatibility note:</b> * {@code Param_MT} is defined in the WKT 1 specification only. * If the {@linkplain Formatter#getConvention() formatter convention} is set to WKT 2, * then this method silently uses the WKT 1 convention without raising an error.</div> * * @return {@code "Param_MT"}. */ @Override protected String formatTo(final Formatter formatter) { if (inverse) { formatter.newLine(); formatter.append(new WKT(false)); return WKTKeywords.Inverse_MT; } else { WKTUtilities.appendParamMT(ContextualParameters.this, formatter); return WKTKeywords.Param_MT; } } }
/** * Formats the inner part of a <cite>Well Known Text</cite> version 1 (WKT 1) element. * If this inverse math transform has any parameter values, then this method formats * the WKT as in the {@linkplain AbstractMathTransform#formatWKT super-class method}. * Otherwise this method formats the math transform as an {@code "Inverse_MT"} entity. * * <div class="note"><b>Compatibility note:</b> * {@code Param_MT} and {@code Inverse_MT} are defined in the WKT 1 specification only.</div> * * @param formatter the formatter to use. * @return the WKT element name, which is {@code "Param_MT"} or * {@code "Inverse_MT"} in the default implementation. */ @Override protected String formatTo(final Formatter formatter) { final ParameterValueGroup parameters = getParameterValues(); if (parameters != null) { WKTUtilities.appendParamMT(parameters, formatter); return WKTKeywords.Param_MT; } else { formatter.newLine(); formatter.append((FormattableObject) AbstractMathTransform.this); return WKTKeywords.Inverse_MT; } } }
/** * Formats this coordinate operation in pseudo-WKT. This is specific to Apache SIS since * there is no concatenated operation in the Well Known Text (WKT) version 2 format. * * @param formatter the formatter to use. * @return {@code "ConcatenatedOperation"}. */ @Override protected String formatTo(final Formatter formatter) { super.formatTo(formatter); for (final CoordinateOperation component : operations) { formatter.newLine(); formatter.append(castOrCopy(component)); } formatter.setInvalidWKT(this, null); return "ConcatenatedOperation"; }
/** * Formats this coordinate operation in pseudo-WKT. This is specific to Apache SIS since * there is no concatenated operation in the Well Known Text (WKT) version 2 format. * * @param formatter the formatter to use. * @return {@code "ConcatenatedOperation"}. */ @Override protected String formatTo(final Formatter formatter) { super.formatTo(formatter); for (final CoordinateOperation component : operations) { formatter.newLine(); formatter.append(castOrCopy(component)); } formatter.setInvalidWKT(this, null); return "ConcatenatedOperation"; }
/** * Formats the inner part of a <cite>Well Known Text</cite> version 1 (WKT 1) element. * If this inverse math transform has any parameter values, then this method formats * the WKT as in the {@linkplain AbstractMathTransform#formatWKT super-class method}. * Otherwise this method formats the math transform as an {@code "Inverse_MT"} entity. * * <div class="note"><b>Compatibility note:</b> * {@code Param_MT} and {@code Inverse_MT} are defined in the WKT 1 specification only.</div> * * @param formatter the formatter to use. * @return the WKT element name, which is {@code "Param_MT"} or * {@code "Inverse_MT"} in the default implementation. */ @Override protected String formatTo(final Formatter formatter) { final ParameterValueGroup parameters = getParameterValues(); if (parameters != null) { WKTUtilities.appendParamMT(parameters, formatter); return WKTKeywords.Param_MT; } else { formatter.newLine(); formatter.append((FormattableObject) inverse()); return WKTKeywords.Inverse_MT; } } }