Class StoreFormat

All Implemented Interfaces:
Serializable, Cloneable, Localized

public final class StoreFormat extends WKTFormat
Helper class for reading and writing WKT in the metadata of a data store. This is provided as a separated class for allowing reuse by other data stores. For example, WKT may also appear in some global attributes of CF-netCDF files.
Since:
0.8
Version:
1.2
See Also:
  • Field Details

    • library

      private final GeometryLibrary library
      The geometry library, or null for the default.
    • listeners

      private final StoreListeners listeners
      Where to send warnings.
  • Constructor Details

    • StoreFormat

      public StoreFormat(Locale locale, TimeZone timezone, GeometryLibrary library, StoreListeners listeners)
      Creates a new WKT parser and encoder. The given locale will be used for InternationalString localization; this is not the locale for number format.
      Parameters:
      locale - the locale for the new Format, or null for Locale.ROOT.
      timezone - the timezone, or null for UTC.
      library - the geometry library, or null for the default.
      listeners - where to send warnings.
  • Method Details

    • parseGeometry

      public org.opengis.geometry.Geometry parseGeometry(String geometry, String crs, String additionalCRS)
      Parses a geometry together with its coordinate reference system, all in Well Known Text (WKT).
      Parameters:
      geometry - the geometry to parse, or null if none.
      crs - the horizontal part of the WKT (2D or 3D), or null if none.
      additionalCRS - the vertical or temporal part of the WKT, or null if none.
      Returns:
      the geometry, or null if none or unparseable.
    • parseCRS

      public org.opengis.referencing.crs.CoordinateReferenceSystem parseCRS(String... wkt)
      Parses the given WKTs as a coordinate reference system. The given array may contain two elements if, for example, vertical CRS is specified separately from horizontal CRS. If an exception occurs during parsing, it will be reported as a data store warning.
      Parameters:
      wkt - the Well Known Texts to parse. Null elements are ignored.
      Returns:
      the parsed coordinate reference system, or null if none.
    • validate

      public void validate(Object parsed)
      Reports pending warnings and verifies if the parsed WKT is conform with the authority definition (if an authority code has been specified). This verification is not really necessary since we will use the WKT definition anyway even if we find discrepancies. But non-conform WKT definitions happen so often in practice that we are better to check and warn users.

      This method does not need to be invoked after parseGeometry(…) or parseCRS(…) since it is already done.

      Parameters:
      parsed - the object parsed from WKT, or null if none.
    • log

      private void log(Exception e)
      Reports a warning for a WKT that cannot be read. This method should be invoked only when the CRS cannot be created at all; it should not be invoked if the CRS has been created with some warnings.
    • log

      private void log(LogRecord record)
      Reports a warning in the "org.apache.sis.io.wkt" logger. This method pretends that the warning come from getMetadata() method, which is the public facade for the parsing method.
      Parameters:
      record - the warning to report.