Class TileMatrixSetFormat

All Implemented Interfaces:
Serializable, Cloneable, Localized

public class TileMatrixSetFormat extends CompoundFormat<TileMatrixSet>
Formats Tile Matrix Sets (TMS) in a tabular format. This format assumes a monospaced font and a character encoding which supports the drawing of box characters, such as UTF-8. The table contains one row for each Tile Matrix with the following columns:
  • Tile matrix identifier
  • Resolution
  • Number of tiles
  • Tile size (if available)
  • Image size (if available)

Limitations

  • The current implementation can only format tile matrices — parsing is unsupported.
  • Tile­Matrix­Set­Format, like most java​.text​.Format subclasses, is not thread-safe.
Since:
1.7
See Also:
  • Constructor Details

    • TileMatrixSetFormat

      public TileMatrixSetFormat(Locale locale, TimeZone timezone)
      Creates a new formatter using the given locale and timezone.
      Parameters:
      locale - the locale for the new Format, or null for Locale​.ROOT.
      timezone - the timezone, or null for UTC.
  • Method Details

    • getValueType

      public final Class<TileMatrixSet> getValueType()
      Returns the type of values formatted by this Format instance.
      Specified by:
      get­Value­Type in class Compound­Format<Tile­Matrix­Set>
      Returns:
      the type of values formatted by this Format instance.
    • formatHeader

      public Map<String,Object> formatHeader(TileMatrixSet matrices)
      Formats the properties of the given Tile Matrix Set for presentation before the main table. The properties are formatted as Strings using the locale given at construction time. The returned map contains the following entries if the corresponding properties were found:
      Tile Matrix Set (TMS) formatted properties
      Key Value type Description
      "identifier" String Identifier of the TMS.
      "referencing"String Name of the CRS, or reason why not available.
      "crs" CoordinateReferenceSystem The CRS.
      "bbox" DefaultGeographicBoundingBox Bounding box of the TMS.

      If the "crs" property is non-null, then the "referencing" property is the CRS name. Conversely, if the "crs" property is null, then the "referencing" property is a message saying that the CRS was not available or the reason why it was not available.

      The returned properties can be completed by a call to format­Table(Iterable, Map).
      Parameters:
      matrices - the tile matrices to format.
      Returns:
      properties of the header of the given tile matrix set.
    • formatTable

      public int formatTable(Iterable<? extends TileMatrix> matrices, Map<String,Object> addTo)
      Formats the properties of the given Tile Matrices in a way suitable for a tabular format. The properties are formatted as Strings using the locale given at construction time. The returned map contains the following entries if the corresponding properties were found:
      Tile Matrices formatted properties
      Key Value type Description
      "identifiers" String[] Column of the identifier of each Tile Matrix.
      "resolutions" String[][] Columns of the resolution of each Tile Matrix.
      "tileCounts" String[][] Columns of the number of tiles of each Tile Matrix.
      "tileSizes" String[][] Columns of the tile size of each Tile Matrix.
      "imageSizes" String[][] Columns of the image size (if available).
      "gridAxes" String[] Name of grid axes.
      The "tile­Sizes" and "image­Sizes" properties may be absent if not applicable. Implementations other than the default implementation may also choose to add or remove more properties.

      This method returns the number of rows in the table to format. The length of the "identifiers" array is that number of rows. All other arrays have a length equal to the number of columns in a group of columns, which is 2 in the usual case of two-dimensional Tile Matrix Sets. The "resolutions[i]", "tile­Counts[i]" and "tile­Sizes[i]" arrays, where i is a column index, all have a length equal to the number of rows. Some element may be null if the corresponding data could not be extracted.

      Parameters:
      matrices - the tile matrices to format.
      add­To - where to put the properties of the given tile matrix set.
      Returns:
      number of rows in the table to format.
    • format

      public String format(TileMatrixSet matrices)
      Formats a textual representation of the given tile matrices. This method delegates to format(Tile­Matrix­Set, Appendable) with a temporary buffer.
      Parameters:
      matrices - the tile matrices to format.
      Returns:
      a string representation of the given Tile Matrix Set.
    • format

      public void format(TileMatrixSet matrices, Appendable toAppendTo) throws IOException
      Formats a textual representation of the given tile matrices. First, a header is formatted with the TMS identifier, the Coordinate Reference System and the geographic bounding box. Then, each tile matrix is formatted as a row in a table.
      Specified by:
      format in class Compound­Format<Tile­Matrix­Set>
      Parameters:
      matrices - the tile matrices to format.
      to­Append­To - where to format the object.
      Throws:
      IOException - if an error occurred while writing to the given appendable.
    • getError

      public Optional<Throwable> getError()
      If an error occurred while formatting the Tile Matrix Set, returns that error.
      Returns:
      the error that occurred during formatting.
    • clear

      public void clear()
      Clears the error status. This method should be invoked if the same Tile­Matrix­Set­Format instance is used for formatting many Tile­Matrix­Set instances.