Class WKTWriter

java.lang.Object
org.apache.sedona.common.S2Geography.WKTWriter

public class WKTWriter extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new WKTWriter with default settings
    WKTWriter(boolean isEwkt)
     
    WKTWriter(int outputDimension)
    Creates a writer that writes Geographys with the given output dimension (2 to 4).
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    format(org.locationtech.jts.geom.Coordinate p)
     
    EnumSet<org.locationtech.jts.io.Ordinate>
    Gets a bit-pattern defining which ordinates should be
    void
    setFormatted(boolean isFormatted)
    Sets whether the output will be formatted.
    void
    setMaxCoordinatesPerLine(int coordsPerLine)
    Sets the maximum number of coordinates per line written in formatted output.
    void
    setOutputOrdinates(EnumSet<org.locationtech.jts.io.Ordinate> outputOrdinates)
    Sets the Ordinate that are to be written.
    void
    setPrecisionModel(org.locationtech.jts.geom.PrecisionModel precisionModel)
    Sets a PrecisionModel that should be used on the ordinates written.
    void
    setTab(int size)
    Sets the tab size to use for indenting.
    static String
    toPoint(org.locationtech.jts.geom.Coordinate p0)
    Generates the WKT for a POINT specified by a Coordinate.
    write(Geography geography)
    Converts a Geometry to its Well-known Text representation.
    void
    write(Geography geography, Writer writer)
    Converts a geography to its Well-known Text representation.
    void
    writeSRID(Geography geography, Writer writer)
    Check if need to write SRID

    Methods inherited from class java.lang.Object

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

    • WKTWriter

      public WKTWriter()
      Creates a new WKTWriter with default settings
    • WKTWriter

      public WKTWriter(boolean isEwkt)
    • WKTWriter

      public WKTWriter(int outputDimension)
      Creates a writer that writes Geographys with the given output dimension (2 to 4). The output follows the following rules:
      • If the specified output dimension is 3 and the z is measure flag is set to true, the Z value of coordinates will be written if it is present (i.e. if it is not Double.NaN)
      • If the specified output dimension is 3 and the z is measure flag is set to false, the Measure value of coordinates will be written if it is present (i.e. if it is not Double.NaN)
      • If the specified output dimension is 4, the Z value of coordinates will be written even if it is not present when the Measure value is present. The Measure value of coordinates will be written if it is present (i.e. if it is not Double.NaN)
      See also setOutputOrdinates(EnumSet)
      Parameters:
      outputDimension - the coordinate dimension to output (2 to 4)
  • Method Details

    • toPoint

      public static String toPoint(org.locationtech.jts.geom.Coordinate p0)
      Generates the WKT for a POINT specified by a Coordinate.
      Parameters:
      p0 - the point coordinate
      Returns:
      the WKT
    • format

      public static String format(org.locationtech.jts.geom.Coordinate p)
    • setFormatted

      public void setFormatted(boolean isFormatted)
      Sets whether the output will be formatted.
      Parameters:
      isFormatted - true if the output is to be formatted
    • setMaxCoordinatesPerLine

      public void setMaxCoordinatesPerLine(int coordsPerLine)
      Sets the maximum number of coordinates per line written in formatted output. If the provided coordinate number is <= 0, coordinates will be written all on one line.
      Parameters:
      coordsPerLine - the number of coordinates per line to output.
    • setTab

      public void setTab(int size)
      Sets the tab size to use for indenting.
      Parameters:
      size - the number of spaces to use as the tab string
      Throws:
      IllegalArgumentException - if the size is non-positive
    • setOutputOrdinates

      public void setOutputOrdinates(EnumSet<org.locationtech.jts.io.Ordinate> outputOrdinates)
      Sets the Ordinate that are to be written. Possible members are:
      • Ordinate.X
      • Ordinate.Y
      • Ordinate.Z
      • Ordinate.M
      Values of Ordinate.X and Ordinate.Y are always assumed and not particularly checked for.
      Parameters:
      outputOrdinates - A set of Ordinate values
    • getOutputOrdinates

      public EnumSet<org.locationtech.jts.io.Ordinate> getOutputOrdinates()
      Gets a bit-pattern defining which ordinates should be
      Returns:
      an ordinate bit-pattern
      See Also:
    • setPrecisionModel

      public void setPrecisionModel(org.locationtech.jts.geom.PrecisionModel precisionModel)
      Sets a PrecisionModel that should be used on the ordinates written.

      If none/null is assigned, the precision model of the Geometry.getFactory() is used.

      Note: The precision model is applied to all ordinate values, not just x and y.

      Parameters:
      precisionModel - the flag indicating if Coordinate.z/{} is actually a measure value.
    • write

      public String write(Geography geography)
      Converts a Geometry to its Well-known Text representation.
      Parameters:
      geography - a Geometry to process
      Returns:
      a <Geometry Tagged Text> string (see the OpenGIS Simple Features Specification)
    • write

      public void write(Geography geography, Writer writer) throws IOException
      Converts a geography to its Well-known Text representation.
      Parameters:
      geography - a geography to process
      Throws:
      IOException
    • writeSRID

      public void writeSRID(Geography geography, Writer writer) throws IOException
      Check if need to write SRID
      Throws:
      IOException