Class CrsWktDecoder


  • public class CrsWktDecoder
    extends Object
    A decoder for CoordinateReferenceSystem definitions 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.WktToken currentToken  
    • Constructor Summary

      Constructors 
      Constructor Description
      CrsWktDecoder()
      Initiates a new CrsWktDecoder that uses the CrsWktVariant.
    • Field Detail

      • currentToken

        protected org.geolatte.geom.codec.WktToken currentToken
    • Constructor Detail

      • CrsWktDecoder

        public CrsWktDecoder()
        Initiates a new CrsWktDecoder that uses the CrsWktVariant.
    • Method Detail

      • decode

        public CoordinateReferenceSystem<? extends Position> decode​(String wkt,
                                                                    int srid)
        Decodes a WKT representation of a CoordinateReferenceSystem.
        Parameters:
        wkt - the WKT string to decode
        Returns:
        The CoordinateReferenceSystem that 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 the WktVariant for this decoder.
        Returns:
        the WktVariant for this decoder.
      • getTokenizerPosition

        protected int getTokenizerPosition()
        Reports the current position of the tokenizer.
        Returns:
        the current position of the tokenizer.