Tabnine Logo
Formatter
Code IndexAdd Tabnine to your IDE (free)

How to use
Formatter
in
org.apache.sis.io.wkt

Best Java code snippets using org.apache.sis.io.wkt.Formatter (Showing top 20 results out of 315)

origin: apache/sis

/**
 * 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;
  }
}
origin: apache/sis

/**
 * Returns the WKT for this transform.
 */
@Override
public String toWKT() {
  final Formatter formatter = new Formatter();
  formatter.append(this);
  return formatter.toWKT();
}
origin: org.apache.sis.core/sis-referencing

/**
 * 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);
}
origin: org.apache.sis.core/sis-referencing

  @Override protected String formatTo(final Formatter formatter) {
    formatter.indent(-1);
    formatter.append(WKTUtilities.toFormattable(crs));
    formatter.indent(+1);
    return type;
  }
});
origin: org.apache.sis.core/sis-referencing

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));
origin: org.apache.sis.core/sis-referencing

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) {
origin: org.apache.sis.core/sis-referencing

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.
origin: apache/sis

/**
 * 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";
}
origin: org.apache.sis.core/sis-metadata

  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);
origin: org.apache.sis.core/sis-referencing

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);
origin: org.apache.sis.core/sis-referencing

/**
 * 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);
}
origin: org.apache.sis.core/sis-metadata

  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();
origin: org.apache.sis.core/sis-referencing

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);
origin: org.apache.sis.core/sis-referencing

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());
origin: org.apache.sis.core/sis-referencing

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 {
origin: org.apache.sis.core/sis-referencing

/**
 * 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);
}
origin: org.apache.sis.core/sis-referencing

  /** Formats the time origin. */
  @Override
  protected String formatTo(final Formatter formatter) {
    formatter.append(origin);
    return WKTKeywords.TimeOrigin;
  }
}
origin: apache/sis

  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));
origin: org.apache.sis.core/sis-referencing

  /**
   * 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;
  }
}
origin: org.apache.sis.core/sis-metadata

    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);
org.apache.sis.io.wktFormatter

Javadoc

Provides support methods for formatting a Well Known Text (WKT).

Formatter instances are created by WKTFormat and given to the FormattableObject#formatTo(Formatter) method of the object to format. Formatter provides the following services:

  • A series of append(…) methods to be invoked by the formatTo(Formatter) implementations.
  • Contextual information. In particular, the #toContextualUnit(Unit) depend on the #getEnclosingElement(int).
  • A flag for declaring the object unformattable.

Most used methods

  • append
    Appends a boolean value. The Symbols#getSeparator() will be written before the boolean if needed.
  • newLine
    Request a line separator before the next element to format. Invoking this method before any append(…
  • <init>
    Creates a new formatter instance with the specified convention, symbols and indentation.
  • appendAny
    Appends an object or an array of objects. This method performs the following choices: * If the given
  • getConvention
    Returns the convention to use for formatting the WKT. The default is Convention#WKT2.
  • getEnclosingElement
    Returns the enclosing WKT element, or null if element being formatted is the root. This method can b
  • getLocale
    Returns the locale to use for localizing InternationalString instances. This is not the locale for
  • indent
    Increases or decreases the indentation. A value of +1 increases the indentation by the amount of spa
  • setInvalidWKT
    Marks the current WKT representation of the given object as not strictly compliant with the WKT spec
  • toWKT
    Returns the WKT formatted by this object.
  • addContextualUnit
    Adds a unit to use for the next measurements of the quantity Q. The given unit will apply to all WKT
  • appendComplement
    Appends the optional complementary attributes common to many IdentifiedObject subtypes. Those attrib
  • addContextualUnit,
  • appendComplement,
  • appendElement,
  • appendExact,
  • appendForSubtypes,
  • appendOnNewLine,
  • appendPreset,
  • appendSeparator,
  • appendTemporalExtent,
  • appendValue

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (ScheduledExecutorService)
  • requestLocationUpdates (LocationManager)
  • getSharedPreferences (Context)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now