Class StoreFormat
java.lang.Object
java.text.Format
org.apache.sis.io.CompoundFormat<Object>
org.apache.sis.io.wkt.WKTFormat
org.apache.sis.internal.storage.wkt.StoreFormat
- All Implemented Interfaces:
Serializable
,Cloneable
,Localized
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.text.Format
Format.Field
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final GeometryLibrary
The geometry library, ornull
for the default.private final StoreListeners
Where to send warnings.Fields inherited from class org.apache.sis.io.wkt.WKTFormat
SINGLE_LINE
-
Constructor Summary
ConstructorsConstructorDescriptionStoreFormat
(Locale locale, TimeZone timezone, GeometryLibrary library, StoreListeners listeners) Creates a new WKT parser and encoder. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Reports a warning for a WKT that cannot be read.private void
Reports a warning in the"org.apache.sis.io.wkt"
logger.org.opengis.referencing.crs.CoordinateReferenceSystem
Parses the given WKTs as a coordinate reference system.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).void
Reports pending warnings and verifies if the parsed WKT is conform with the authority definition (if an authority code has been specified).Methods inherited from class org.apache.sis.io.wkt.WKTFormat
addFragment, clone, createFormat, format, getColors, getConvention, getFactory, getFragmentNames, getIndentation, getKeywordCase, getKeywordStyle, getLocale, getMaximumListElements, getNameAuthority, getSymbols, getTransliterator, getValueType, getWarnings, parse, setColors, setConvention, setFactory, setIndentation, setKeywordCase, setKeywordStyle, setMaximumListElements, setNameAuthority, setSymbols, setTransliterator
Methods inherited from class org.apache.sis.io.CompoundFormat
format, getFormat, getLocale, getTimeZone, parseObject, parseObject
Methods inherited from class java.text.Format
format, formatToCharacterIterator
-
Field Details
-
library
The geometry library, ornull
for the default. -
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 forinvalid reference
InternationalString
- Parameters:
locale
- the locale for the newFormat
, ornull
forLocale.ROOT
.timezone
- the timezone, ornull
for UTC.library
- the geometry library, ornull
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, ornull
if none.crs
- the horizontal part of the WKT (2D or 3D), ornull
if none.additionalCRS
- the vertical or temporal part of the WKT, ornull
if none.- Returns:
- the geometry, or
null
if none or unparseable.
-
parseCRS
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
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(…)
orparseCRS(…)
since it is already done.- Parameters:
parsed
- the object parsed from WKT, ornull
if none.
-
log
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
Reports a warning in the"org.apache.sis.io.wkt"
logger. This method pretends that the warning come fromgetMetadata()
method, which is the public facade for the parsing method.- Parameters:
record
- the warning to report.
-