/** * 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; } }
/** * Formats this datum as a <cite>Well Known Text</cite> {@code ParametricDatum[…]} element. * * <div class="note"><b>Compatibility note:</b> * {@code ParametricDatum} is defined in the WKT 2 specification only.</div> * * @return {@code "ParametricDatum"}. * * @see <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#83">WKT 2 specification</a> */ @Override protected String formatTo(final Formatter formatter) { super.formatTo(formatter); if (formatter.getConvention().majorVersion() == 1) { formatter.setInvalidWKT(this, null); } return formatter.shortOrLong(WKTKeywords.PDatum, WKTKeywords.ParametricDatum); }
WKTUtilities.appendName(this, formatter, null); CoordinateSystem cs = getCoordinateSystem(); final Convention convention = formatter.getConvention(); final boolean isWKT1 = (convention.majorVersion() == 1); final boolean isGeographicWKT1 = isWKT1 && (cs instanceof EllipsoidalCS); formatter.newLine(); formatter.append(WKTUtilities.toFormattable(first)); formatter.newLine(); formatter.append(WKTUtilities.toFormattable(second)); formatter.newLine(); return WKTKeywords.Compd_CS; formatter.newLine(); formatter.append(WKTUtilities.toFormattable(datum)); formatter.newLine(); final PrimeMeridian pm = datum.getPrimeMeridian(); final Unit<Angle> angularUnit = AxisDirections.getAngularUnit(cs, null); final Unit<Angle> oldUnit = formatter.addContextualUnit(angularUnit); formatter.indent(1); formatter.append(WKTUtilities.toFormattable(pm)); formatter.indent(-1); formatter.newLine(); formatter.restoreContextualUnit(angularUnit, oldUnit); cs = Legacy.forGeocentricCRS((CartesianCS) cs, true); } else { formatter.setInvalidWKT(cs, null); // SphericalCS was not supported in WKT 1. formatter.append(formatter.toContextualUnit(angularUnit));
protected String formatTo(final Formatter formatter) { super.formatTo(formatter); formatter.newLine(); final FormattableObject enclosing = formatter.getEnclosingElement(1); final boolean isSubOperation = (enclosing instanceof PassThroughOperation); final boolean isComponent = (enclosing instanceof ConcatenatedOperation); formatter.append(DefaultOperationMethod.castOrCopy(method)); ParameterValueGroup parameters; try { } catch (UnsupportedOperationException e) { final IdentifiedObject c = getParameterDescriptors(); formatter.setInvalidWKT(c != null ? c : this, e); parameters = null; Constants.EPSG.equalsIgnoreCase(Citations.getCodeSpace(formatter.getNameAuthority())); formatter.newLine(); formatter.indent(+1); for (final GeneralParameterValue param : parameters.values()) { if (!filter || WKTUtilities.isEPSG(param.getDescriptor(), true)) { formatter.indent(-1); final double accuracy = getLinearAccuracy(); if (accuracy > 0) { formatter.append(new FormattableObject() { @Override protected String formatTo(final Formatter formatter) {
assert (formatter.getConvention().majorVersion() == 1) == isWKT1 : isWKT1; assert isWKT1 || !isBaseCRS(formatter) || formatter.getConvention() == Convention.INTERNAL; // Condition documented in javadoc. final Unit<?> oldUnit = formatter.addContextualUnit(unit); if (isWKT1) { // WKT 1 writes unit before axes, while WKT 2 writes them after axes. formatter.append(unit); if (unit == null) { formatter.setInvalidWKT(this, null); formatter.append(toFormattable(cs)); // WKT2 only, since the concept of CoordinateSystem was not explicit in WKT 1. formatter.indent(+1); if (!isWKT1 || formatter.getConvention() != Convention.WKT1_IGNORE_AXES) { if (cs != null) { // Should never be null, except sometime temporarily during construction. final int dimension = cs.getDimension(); for (int i=0; i<dimension; i++) { formatter.newLine(); formatter.append(toFormattable(cs.getAxis(i))); formatter.newLine(); formatter.append(unit); formatter.indent(-1); formatter.restoreContextualUnit(unit, oldUnit); formatter.newLine(); // For writing the ID[…] element on its own line.
/** * 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"; }
keyword = WKTKeywords.ParametricUnit; openElement(false, keyword); setColor(ElementKind.UNIT); final int fromIndex = buffer.appendCodePoint(symbols.getOpeningQuote(0)).length(); unitFormat.format(unit, buffer, dummy); closeQuote(fromIndex); resetColor(); final double conversion = Units.toStandardUnit(unit); if (Double.isNaN(conversion) && Units.isAngular(unit)) { appendExact(Math.PI / 180); // Presume that we have sexagesimal degrees (see below). } else { appendExact(conversion); final Integer code = Units.getEpsgCode(unit, getEnclosingElement(1) instanceof CoordinateSystemAxis); if (code != null) { openElement(false, isWKT1 ? WKTKeywords.Authority : WKTKeywords.Id); append(Constants.EPSG, null); if (isWKT1) { append(code.toString(), null); } else { append(code); closeElement(false); closeElement(false); setInvalidWKT(Unit.class, null);
final boolean isWKT1 = formatter.getConvention().majorVersion() == 1; final Citation authority = formatter.getNameAuthority(); String name = IdentifiedObjects.getName(this, authority); ElementKind kind = ElementKind.METHOD; final FormattableObject parent = formatter.getEnclosingElement(isWKT1 ? 1 : 2); if (parent instanceof GeneralDerivedCRS) { final Conversion conversion = ((GeneralDerivedCRS) parent).getConversionFromBase(); name = IdentifiedObjects.getName(this, null); if (name == null) { name = Vocabulary.getResources(formatter.getLocale()).getString(Vocabulary.Keys.Unnamed); formatter.append(name, kind); if (isWKT1) { return WKTKeywords.Projection; formatter.setInvalidWKT(this, null);
/** * Formats this datum as a <cite>Well Known Text</cite> {@code ImageDatum[…]} element. * * <div class="note"><b>Compatibility note:</b> * {@code ImageDatum} is defined in the WKT 2 specification only.</div> * * @return {@code "ImageDatum"}. * * @see <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#81">WKT 2 specification §12.2</a> */ @Override protected String formatTo(final Formatter formatter) { super.formatTo(formatter); final Convention convention = formatter.getConvention(); if (convention == Convention.INTERNAL) { formatter.append(getPixelInCell()); // This is an extension compared to ISO 19162. } else if (convention.majorVersion() == 1) { formatter.setInvalidWKT(this, null); } return formatter.shortOrLong(WKTKeywords.IDatum, WKTKeywords.ImageDatum); }
formatter = new Formatter(); formatter.configure(convention, null, colorize ? Colors.DEFAULT : null, convention.toUpperCase ? (byte) +1 : 0, (convention.majorVersion() == 1) ? (byte) -1 : 0, final String wkt; try { formatter.append(this); if (strict) { final Warnings warnings = formatter.getWarnings(); if (warnings != null) { final int n = warnings.getNumMessages() - 1; formatter.appendWarnings(); wkt = formatter.toWKT(); } catch (IOException e) { throw new UnformattableObjectException(e); // Should never happen since we write to a StringBuffer. } finally { formatter.clear();
protected String formatTo(final Formatter formatter) { super.formatTo(formatter); formatter.newLine(); formatter.append(toFormattable(getEllipsoid())); final boolean isWKT1 = formatter.getConvention().majorVersion() == 1; if (isWKT1) { for (final BursaWolfParameters candidate : bursaWolf) { if (candidate.isToWGS84()) { formatter.newLine(); formatter.append(candidate); break; formatter.newLine(); // For writing the ID[…] element on its own line. if (!isWKT1) { if (!(formatter.getEnclosingElement(1) instanceof GeodeticCRS)) { return formatter.shortOrLong(WKTKeywords.Datum, WKTKeywords.GeodeticDatum);
protected String formatTo(final Formatter formatter) { super.formatTo(formatter); formatter.setInvalidWKT(this, null); if (this instanceof ParameterDescriptorGroup) { for (GeneralParameterDescriptor parameter : ((ParameterDescriptorGroup) this).descriptors()) { formatter.newLine(); formatter.append((FormattableObject) parameter); final Object defaultValue = ((ParameterDescriptor<?>) this).getDefaultValue(); if (defaultValue != null) { formatter.appendAny(defaultValue); formatter.append(((ParameterDescriptor<?>) this).getUnit());
final ParameterDescriptor<T> descriptor = getDescriptor(); // Gives to users a chance to override this property. WKTUtilities.appendName(descriptor, formatter, ElementKind.PARAMETER); final Convention convention = formatter.getConvention(); final boolean isWKT1 = convention.majorVersion() == 1; final T value = getValue(); // Gives to users a chance to override this property. if (!isWKT1 && isFile(value)) { formatter.append(value.toString(), null); return WKTKeywords.ParameterFile; } else { formatter.appendAny(value); contextualUnit = formatter.toContextualUnit(contextualUnit); boolean ignoreUnits; if (isWKT1) { formatter.setInvalidWKT(descriptor, exception); } else { formatter.setInvalidWKT(DefaultParameterValue.class, exception); formatter.append(value); formatter.append(unit); } else if (!ignoreUnits) { if (descriptor != null) { formatter.setInvalidWKT(descriptor, null); } else {
/** * Formats this datum as a <cite>Well Known Text</cite> {@code EngineeringDatum[…]} element. * * @return {@code "EngineeringDatum"} (WKT 2) or {@code "Local_Datum"} (WKT 1). * * @see <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#76">WKT 2 specification §11.2</a> */ @Override protected String formatTo(final Formatter formatter) { super.formatTo(formatter); if (formatter.getConvention().majorVersion() == 1) { /* * Datum type was provided for all kind of datum in the legacy OGC 01-009 specification. * Datum types became provided only for vertical datum in the ISO 19111:2003 specification, * then removed completely in the ISO 19111:2007 revision. We are supposed to format them * in WKT 1, but do not have any indication about what the values should be. */ formatter.append(0); return WKTKeywords.Local_Datum; } return formatter.shortOrLong(WKTKeywords.EDatum, WKTKeywords.EngineeringDatum); }
/** Formats the time origin. */ @Override protected String formatTo(final Formatter formatter) { formatter.append(origin); return WKTKeywords.TimeOrigin; } }
final Number number = (Number) value; if (Numbers.isInteger(number.getClass())) { append(number.longValue()); } else { append(number.doubleValue()); else if (value instanceof CodeList<?>) append((CodeList<?>) value); else if (value instanceof Date) append((Date) value); else if (value instanceof Boolean) append((Boolean) value); else if (value instanceof CharSequence) { append((value instanceof InternationalString) ? ((InternationalString) value).toString(locale) : value.toString(), null); } else if (value.getClass().isArray()) { appendSeparator(); elementStart = buffer.appendCodePoint(symbols.getOpenSequence()).length(); final int length = Array.getLength(value); setColor(ElementKind.REMARKS); buffer.append(Resources.forLocale(locale).getString(Resources.Keys.ElementsOmitted_1, skip)); resetColor(); i += skip; setInvalidWKT(value.getClass().getSimpleName(), null); appendAny(Array.get(value, i));
/** * Formats this formula as a pseudo-<cite>Well Known Text</cite> element. * * <div class="note"><b>Compatibility note:</b> * ISO 19162 does not define a WKT representation for {@code Formula} objects. * The text formatted by this method is SIS-specific and causes the text to be * flagged as {@linkplain Formatter#setInvalidWKT(Class, Exception) invalid WKT}. * The WKT content of this element may change in any future SIS version.</div> * * @return {@code "Formula"}. */ @Override protected String formatTo(final Formatter formatter) { InternationalString text = null; final Citation citation = getCitation(); // Gives to users a chance to override properties. if (citation != null) { text = citation.getTitle(); } if (text == null) { text = getFormula(); } if (text != null) { formatter.append(text.toString(formatter.getLocale()), ElementKind.REMARKS); } formatter.setInvalidWKT(Formula.class, null); return WKTKeywords.Formula; } }
org.apache.sis.internal.util.Citations.getIdentifier(authority, true); if (cs != null) { final Convention convention = formatter.getConvention(); if (convention.majorVersion() == 1) { keyword = WKTKeywords.Authority; formatter.append(cs, ElementKind.IDENTIFIER); formatter.append(code, ElementKind.IDENTIFIER); } else { keyword = WKTKeywords.Id; formatter.append(cs, ElementKind.IDENTIFIER); appendCode(formatter, code); final String version = getVersion(); 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); if (citation != null && !citation.equals(cs)) { formatter.append(new Cite(citation)); final String urn = NameMeaning.toURN(enclosing.getClass(), cs, version, code); if (urn != null) { formatter.append(new FormattableObject() { @Override protected String formatTo(final Formatter formatter) { formatter.append(urn, null);