org.geotools.referencing.wkt
Class Parser

java.lang.Object
  extended byjava.text.Format
      extended byorg.geotools.referencing.wkt.AbstractParser
          extended byorg.geotools.referencing.wkt.MathTransformParser
              extended byorg.geotools.referencing.wkt.Parser
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class Parser
extends MathTransformParser

Parser for Well Known Text (WKT). This parser can parse math transform objects as well, which is part of the WKT's element.

Since:
2.0
Version:
$Id: Parser.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Remi Eve, Martin Desruisseaux
See Also:
Well Know Text specification, OGC WKT Coordinate System Issues, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
protected  org.opengis.referencing.crs.CRSFactory crsFactory
          The factory to use for creating coordinate reference systems.
protected  org.opengis.referencing.cs.CSFactory csFactory
          The factory to use for creating coordinate systems.
protected  org.opengis.referencing.datum.DatumFactory datumFactory
          The factory to use for creating datum.
 
Fields inherited from class org.geotools.referencing.wkt.MathTransformParser
mtFactory
 
Constructor Summary
Parser()
          Constructs a parser using the default set of symbols and factories.
Parser(Symbols symbols)
          Constructs a parser for the specified set of symbols using default factories.
Parser(Symbols symbols, org.opengis.referencing.datum.DatumFactory datumFactory, org.opengis.referencing.cs.CSFactory csFactory, org.opengis.referencing.crs.CRSFactory crsFactory, org.opengis.referencing.operation.MathTransformFactory mtFactory)
          Constructs a parser for the specified set of symbols using the specified factories.
Parser(Symbols symbols, FactoryGroup factories)
          Constructs a parser for the specified set of symbols using the specified set of factories.
 
Method Summary
static java.lang.Class getClassOf(java.lang.String element)
          Returns the class of the specified WKT element.
static void main(java.lang.String[] args)
          Read WKT strings from the standard input stream and reformat them to the standard output stream.
protected  java.lang.Object parse(Element element)
          Parses the next element in the specified Well Know Text (WKT) tree.
 org.opengis.referencing.crs.CoordinateReferenceSystem parseCoordinateReferenceSystem(java.lang.String text)
          Parses a coordinate reference system element.
 
Methods inherited from class org.geotools.referencing.wkt.MathTransformParser
parseMathTransform
 
Methods inherited from class org.geotools.referencing.wkt.AbstractParser
format, getAuthority, getTree, parseObject, parseObject, reformat, setAuthority
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

datumFactory

protected final org.opengis.referencing.datum.DatumFactory datumFactory
The factory to use for creating datum.


csFactory

protected final org.opengis.referencing.cs.CSFactory csFactory
The factory to use for creating coordinate systems.


crsFactory

protected final org.opengis.referencing.crs.CRSFactory crsFactory
The factory to use for creating coordinate reference systems.

Constructor Detail

Parser

public Parser()
Constructs a parser using the default set of symbols and factories.


Parser

public Parser(Symbols symbols)
Constructs a parser for the specified set of symbols using default factories.

Parameters:
symbols - The symbols for parsing and formatting numbers.
To Do:
Pass hints in argument.

Parser

public Parser(Symbols symbols,
              FactoryGroup factories)
Constructs a parser for the specified set of symbols using the specified set of factories.

Parameters:
symbols - The symbols for parsing and formatting numbers.
factories - The factories to use.

Parser

public Parser(Symbols symbols,
              org.opengis.referencing.datum.DatumFactory datumFactory,
              org.opengis.referencing.cs.CSFactory csFactory,
              org.opengis.referencing.crs.CRSFactory crsFactory,
              org.opengis.referencing.operation.MathTransformFactory mtFactory)
Constructs a parser for the specified set of symbols using the specified factories.

Parameters:
symbols - The symbols for parsing and formatting numbers.
datumFactory - The factory to use for creating datum.
csFactory - The factory to use for creating coordinate systems.
crsFactory - The factory to use for creating coordinate reference systems.
mtFactory - The factory to use for creating math transform objects.
Method Detail

parseCoordinateReferenceSystem

public org.opengis.referencing.crs.CoordinateReferenceSystem parseCoordinateReferenceSystem(java.lang.String text)
                                                                                     throws java.text.ParseException
Parses a coordinate reference system element.

Parameters:
text - The text to be parsed.
Returns:
The coordinate reference system.
Throws:
java.text.ParseException - if the string can't be parsed.

parse

protected java.lang.Object parse(Element element)
                          throws java.text.ParseException
Parses the next element in the specified Well Know Text (WKT) tree.

Overrides:
parse in class MathTransformParser
Parameters:
element - The element to be parsed.
Returns:
The object.
Throws:
java.text.ParseException - if the element can't be parsed.
To Do:
All sequences of if ("FOO".equals(keyword)) in this method and other methods of this class and subclasses, could be optimized with a statement.

getClassOf

public static java.lang.Class getClassOf(java.lang.String element)
Returns the class of the specified WKT element. For example for this method returns ProjectedCRS.class for element "".

Parameters:
element - The WKT element name.
Returns:
The GeoAPI class of the specified element, or if unknow.

main

public static void main(java.lang.String[] args)
Read WKT strings from the standard input stream and reformat them to the standard output stream. The input is read until it reach the end-of-file ( if reading from the keyboard), or until an unparsable WKT has been hit. Optional arguments are:
-authority <name>  The authority to prefer when choosing WKT entities names.
-indentation <value>  Set the indentation (0 for output on a single line)
-encoding <code>  Set the character encoding
-locale <language>  Set the language for the output (e.g. "fr" for French)



Copyright © GeoTools. All Rights Reserved.