org.deegree.cs.configuration.wkt
Class WKTParser

java.lang.Object
  extended by org.deegree.cs.configuration.wkt.WKTParser

public class WKTParser
extends Object

The WKTParser class instantiates the Coordinate System given in a file, in WKT (Well Known Text) format. The extendend Backus-Naur grammar of WKT as well as a detailed reference are available at the OGC website.

Version:
$Revision: $, $Date: $
Author:
Andrei Ionita, last edited by: $Author: ionita $

Constructor Summary
WKTParser(File fileName)
           
WKTParser(String fileName)
          Constructor
 
Method Summary
protected  boolean equalsParameterVariants(String candidate, String paramName)
           
protected  String makeInvariantKey(String candidate)
           
static CRS parse(String wkt)
           
protected  CRSCodeType parseAuthority()
           
protected  Axis parseAxis()
           
protected  CompoundCRS parseCompoundCRS()
          Parses a CompoundCRS from the current WKT location.
 CRS parseCoordinateSystem()
           
protected  Ellipsoid parseEllipsoid()
           
protected  GeocentricCRS parseGeocentricCRS()
           
protected  GeodeticDatum parseGeodeticDatum()
           
protected  GeographicCRS parseGeographiCRS()
           
protected  Helmert parseHelmert()
           
protected  PrimeMeridian parsePrimeMeridian()
           
protected  ProjectedCRS parseProjectedCRS()
           
protected  String parseString()
           
protected  Unit parseUnit()
           
protected  VerticalCRS parseVerticalCRS()
           
protected  VerticalDatum parseVerticalDatum()
           
protected  void passOverChar(char ch)
          Walk a character (comma or round/square bracket).
protected  void passOverClosingBracket()
          Walk a closing bracket (round or square).
protected  void passOverOpeningBracket()
          Walk an opening bracket (round or square).
protected  void passOverWord(String s)
          Walk a WKT keyword element (e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WKTParser

public WKTParser(String fileName)
          throws IOException
Constructor

Parameters:
fileName - the file that contains a Coordinate System definition
Throws:
IOException - if the provided WKT has a syntax error

WKTParser

public WKTParser(File fileName)
          throws FileNotFoundException
Parameters:
fileName - to read a wkt from.
Throws:
FileNotFoundException
Method Detail

equalsParameterVariants

protected boolean equalsParameterVariants(String candidate,
                                          String paramName)
Parameters:
candidate -
paramName -
Returns:
true if the candidate stripped of underscores equals ignore case the param name (also stripped).

makeInvariantKey

protected String makeInvariantKey(String candidate)

passOverChar

protected void passOverChar(char ch)
                     throws IOException
Walk a character (comma or round/square bracket).

Parameters:
ch -
Throws:
IOException - if an I/O error occurs.
WKTParsingException - if the expected character is not present at this position.

passOverOpeningBracket

protected void passOverOpeningBracket()
                               throws IOException
Walk an opening bracket (round or square).

Throws:
IOException - if an I/O error occurs.
WKTParsingException - if the opening bracket is not present at this position.

passOverClosingBracket

protected void passOverClosingBracket()
                               throws IOException
Walk a closing bracket (round or square).

Throws:
IOException - if an I/O error occurs.
WKTParsingException - if the closing bracket is not present at this position.

passOverWord

protected void passOverWord(String s)
                     throws IOException
Walk a WKT keyword element (e.g. DATUM, AUTHORITY, UNIT, etc.)

Parameters:
s - the keyword element as a String
Throws:
IOException - if an I/O error occurs.
WKTParsingException - if the keyword is not present at this position.

parseAuthority

protected CRSCodeType parseAuthority()
                              throws IOException
Returns:
a CRSCodeType object based on the information in the AUTHORITY element
Throws:
IOException - if an I/O error occurs

parseString

protected String parseString()
                      throws IOException
Returns:
the string that is surrounded by double-quotes
Throws:
IOException - if an I/O error occurs
WKTParsingException - if the string does not begin with have an opening double-quote.

parseAxis

protected Axis parseAxis()
                  throws IOException
Returns:
an Axis
Throws:
IOException
WKTParsingException - if the axis orientation is not one of the values defined in the WKT reference ( NORTH | SOUTH | WEST | EAST | UP | DOWN | OTHER )

parseUnit

protected Unit parseUnit()
                  throws IOException
Returns:
a Unit.
Throws:
IOException
UnknownUnitException - if the unit name does not match any of the predefined units in the API

parsePrimeMeridian

protected PrimeMeridian parsePrimeMeridian()
                                    throws IOException
Returns:
a Prime Meridian
Throws:
IOException

parseEllipsoid

protected Ellipsoid parseEllipsoid()
                            throws IOException
Returns:
the Ellipsoid parsed from a WKT 'SPHEROID'.
Throws:
IOException

parseHelmert

protected Helmert parseHelmert()
                        throws IOException
Returns:
the Helmert transformatio parsed from the WKT 'TOWGS84'
Throws:
IOException

parseGeodeticDatum

protected GeodeticDatum parseGeodeticDatum()
                                    throws IOException
Returns:
a Geodetic Datum parsed from WKT 'DATUM'
Throws:
IOException

parseVerticalDatum

protected VerticalDatum parseVerticalDatum()
                                    throws IOException
Returns:
a Vertical Datum parsed from WKT 'VERT_DATUM'
Throws:
IOException

parseVerticalCRS

protected VerticalCRS parseVerticalCRS()
                                throws IOException
Returns:
a VerticalCRS parsed from the current reader position.
Throws:
IOException

parseGeocentricCRS

protected GeocentricCRS parseGeocentricCRS()
                                    throws IOException
Returns:
a GeocentricCRS parsed from the current reader position.
Throws:
IOException

parseGeographiCRS

protected GeographicCRS parseGeographiCRS()
                                   throws IOException
Returns:
a GeographicCRS parsed from the current reader position.
Throws:
IOException

parseProjectedCRS

protected ProjectedCRS parseProjectedCRS()
                                  throws IOException
Returns:
a ProjectedCRS parsed from the current reader position.
Throws:
IOException

parseCompoundCRS

protected CompoundCRS parseCompoundCRS()
                                throws IOException
Parses a CompoundCRS from the current WKT location.

Returns:
a CompoundCRS parsed from the current reader position.
Throws:
IOException

parseCoordinateSystem

public CRS parseCoordinateSystem()
                          throws IOException
Returns:
a Coordinate System ( Compound CRS, Projected CRS, Geographic CRS, Geocentric CRS, Vertical CRS)
Throws:
IOException - if the provided WKT has a syntax error

parse

public static CRS parse(String wkt)
                 throws IOException
Parameters:
wkt - the wkt code as a String
Returns:
the parsed CRS
Throws:
IOException - if the provided WKT has a syntax error


Copyright © 2011. All Rights Reserved.