Class WKTFileReader

java.lang.Object
org.locationtech.jts.io.WKTFileReader

public class WKTFileReader extends Object
Reads a sequence of Geometrys in WKT format from a text file. The geometries in the file may be separated by any amount of whitespace and newlines.
Author:
Martin Davis
  • Constructor Summary

    Constructors
    Constructor
    Description
    WKTFileReader(File file, WKTReader wktReader)
    Creates a new WKTFileReader given the File to read from and a WKTReader to use to parse the geometries.
    WKTFileReader(Reader reader, WKTReader wktReader)
    Creates a new WKTFileReader, given a Reader to read from.
    WKTFileReader(String filename, WKTReader wktReader)
    Creates a new WKTFileReader, given the name of the file to read from.
  • Method Summary

    Modifier and Type
    Method
    Description
    Reads a sequence of geometries.
    void
    setLimit(int limit)
    Sets the maximum number of geometries to read.
    void
    setOffset(int offset)
    Sets the number of geometries to skip before storing.
    void
    setStrictParsing(boolean isStrict)
    Allows ignoring WKT parse errors after at least one geometry has been read, to return a partial result.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WKTFileReader

      public WKTFileReader(File file, WKTReader wktReader)
      Creates a new WKTFileReader given the File to read from and a WKTReader to use to parse the geometries.
      Parameters:
      file - the File to read from
      wktReader - the geometry reader to use
    • WKTFileReader

      public WKTFileReader(String filename, WKTReader wktReader)
      Creates a new WKTFileReader, given the name of the file to read from.
      Parameters:
      filename - the name of the file to read from
      wktReader - the geometry reader to use
    • WKTFileReader

      public WKTFileReader(Reader reader, WKTReader wktReader)
      Creates a new WKTFileReader, given a Reader to read from.
      Parameters:
      reader - the reader to read from
      wktReader - the geometry reader to use
  • Method Details

    • setLimit

      public void setLimit(int limit)
      Sets the maximum number of geometries to read.
      Parameters:
      limit - the maximum number of geometries to read
    • setStrictParsing

      public void setStrictParsing(boolean isStrict)
      Allows ignoring WKT parse errors after at least one geometry has been read, to return a partial result.
      Parameters:
      isStrict - whether to ignore parse errors
    • setOffset

      public void setOffset(int offset)
      Sets the number of geometries to skip before storing.
      Parameters:
      offset - the number of geometries to skip
    • read

      public List read() throws IOException, ParseException
      Reads a sequence of geometries. If an offset is specified, geometries read up to the offset count are skipped. If a limit is specified, no more than limit geometries are read.
      Returns:
      the list of geometries read
      Throws:
      IOException - if an I/O exception was encountered
      ParseException - if an error occurred reading a geometry