Parser and formatter for
Well Known Text (WKT) objects. This format handles a pair of {@link Parser} and {@link Formatter}, to be used by {@code parse} and {@code format} methods respectively.{@code WKTFormat} objects allow the following configuration:
- The {@linkplain Symbols symbols} to use (curly braces or brackets, etc).
- The preferred authority of {@linkplain IdentifiedObject#getName() object name} toformat (see {@link Formatter#getNameAuthority()} for more information).
- Whatever ANSI X3.64 colors are allowed or not (default is not).
- The indentation.
{@section String expansion}Because the strings to be parsed by this class are long and tend to contain repetitive substrings, {@code WKTFormat} provides a mechanism for performing string substitutions before the parsing take place.Long strings can be assigned short names by calls to the
{@linkplain #definitions()}.put(key,value)
method. After definitions have been added, any call to a parsing method will replace all occurrences of a short name by the associated long string.
The short names must comply with the rules of Java identifiers. It is recommended, but not required, to prefix the names by some symbol like {@code "$"} in order to avoid ambiguity.Note however that this class doesn't replace occurrences between quoted text, so string expansion still relatively safe even when used with non-prefixed identifiers.
Example: In the example below, the {@code $WGS84} substring which appear in the argument given to the{@code parseObject(…)} method will be expanded into the full {@code GEOGCS["WGS84", …]} stringbefore the parsing proceed.
{@linkplain #definitions()}.put("$WGS84", "GEOGCS[\"WGS84\", DATUM[
…etc… ]]);
Object crs = {@linkplain #parseObject(String) parseObject}("PROJCS[\"Mercator_1SP\", $WGS84, PROJECTION[
…etc… ]]");
{@section Thread safety}{@code WKTFormat}s are not synchronized. It is recommended to create separated format instances for each thread. If multiple threads access a {@code WKTFormat} concurrently, it must be synchronized externally.
@author Martin Desruisseaux (Geomatys)
@author Rémi Eve (IRD)
@since 0.4 (derived from geotk-3.20)
@version 0.4
@module