Package org.geolatte.geom.codec
Class CrsWktDecoder
- java.lang.Object
-
- org.geolatte.geom.codec.CrsWktDecoder
-
public class CrsWktDecoder extends Object
A decoder forCoordinateReferenceSystemdefinitions in WKT.The current implementation ensures that the postgis CRS WKT's are correctly interpreted. There are some minor differences with the OGC specification: "Coordinate Transformation Services (rev. 1.00)".
The implementation uses a recursive-decent parsing approach.
This class is not thread-safe.
- Author:
- Karel Maesen, Geovise BVBA creation-date: 8/2/11
-
-
Field Summary
Fields Modifier and Type Field Description protected org.geolatte.geom.codec.WktTokencurrentToken
-
Constructor Summary
Constructors Constructor Description CrsWktDecoder()Initiates a newCrsWktDecoderthat uses theCrsWktVariant.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CoordinateReferenceSystem<? extends Position>decode(String wkt, int srid)Decodes a WKT representation of aCoordinateReferenceSystem.protected intdecodeInt()protected doubledecodeNumber()Returns the value of the current token and moves to the next token if the current token matches a number.protected StringdecodeText()Returns the text and moves to the next token if the current token matches text, otherwise throws an exception.protected intgetTokenizerPosition()Reports the current position of the tokenizer.protected org.geolatte.geom.codec.WktVariantgetWktVariant()Returns theWktVariantfor this decoder.protected booleanmatchesCloseList()Returns true and moves to the next token if the current token matches the close list token.protected booleanmatchesElementSeparator()Returns true and moves to the next token if the current token matches the element separator token.protected booleanmatchesOpenList()Returns true and moves to the next token if the current token matches the open list token.protected voidnextToken()Advances the decoding to the next token.protected voidsetTokenizer(org.geolatte.geom.codec.AbstractWktTokenizer tokenizer)
-
-
-
Method Detail
-
decode
public CoordinateReferenceSystem<? extends Position> decode(String wkt, int srid)
Decodes a WKT representation of aCoordinateReferenceSystem.- Parameters:
wkt- the WKT string to decode- Returns:
- The
CoordinateReferenceSystemthat is encoded in the input WKT.
-
setTokenizer
protected void setTokenizer(org.geolatte.geom.codec.AbstractWktTokenizer tokenizer)
-
decodeText
protected String decodeText()
Returns the text and moves to the next token if the current token matches text, otherwise throws an exception.- Returns:
- the matched text
- Throws:
WktDecodeException- when the current token does not match text.
-
decodeInt
protected int decodeInt()
-
nextToken
protected void nextToken()
Advances the decoding to the next token.
-
matchesOpenList
protected boolean matchesOpenList()
Returns true and moves to the next token if the current token matches the open list token.- Returns:
- True if the current token matches the open list token, false otherwise.
-
matchesCloseList
protected boolean matchesCloseList()
Returns true and moves to the next token if the current token matches the close list token.- Returns:
- True if the current token matches the close list token, false otherwise.
-
matchesElementSeparator
protected boolean matchesElementSeparator()
Returns true and moves to the next token if the current token matches the element separator token.- Returns:
- True if the current token matches the element separator token, false otherwise.
-
decodeNumber
protected double decodeNumber()
Returns the value of the current token and moves to the next token if the current token matches a number.- Returns:
- The value of the current token if the current token matches a number.
- Throws:
WktDecodeException- if the current token does not match a number.
-
getWktVariant
protected org.geolatte.geom.codec.WktVariant getWktVariant()
Returns theWktVariantfor this decoder.- Returns:
- the
WktVariantfor this decoder.
-
getTokenizerPosition
protected int getTokenizerPosition()
Reports the current position of the tokenizer.- Returns:
- the current position of the tokenizer.
-
-