Class CoordinateSequences

java.lang.Object
org.locationtech.jts.geom.CoordinateSequences

public class CoordinateSequences extends Object
Utility functions for manipulating CoordinateSequences
Version:
1.7
  • Constructor Details

    • CoordinateSequences

      public CoordinateSequences()
  • Method Details

    • reverse

      public static void reverse(CoordinateSequence seq)
      Reverses the coordinates in a sequence in-place.
    • swap

      public static void swap(CoordinateSequence seq, int i, int j)
      Swaps two coordinates in a sequence.
      Parameters:
      seq - the sequence to modify
      i - the index of a coordinate to swap
      j - the index of a coordinate to swap
    • copy

      public static void copy(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos, int length)
      Copies a section of a CoordinateSequence to another CoordinateSequence. The sequences may have different dimensions; in this case only the common dimensions are copied.
      Parameters:
      src - the sequence to copy from
      srcPos - the position in the source sequence to start copying at
      dest - the sequence to copy to
      destPos - the position in the destination sequence to copy to
      length - the number of coordinates to copy
    • copyCoord

      public static void copyCoord(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos)
      Copies a coordinate of a CoordinateSequence to another CoordinateSequence. The sequences may have different dimensions; in this case only the common dimensions are copied.
      Parameters:
      src - the sequence to copy from
      srcPos - the source coordinate to copy
      dest - the sequence to copy to
      destPos - the destination coordinate to copy to
    • isRing

      public static boolean isRing(CoordinateSequence seq)
      Tests whether a CoordinateSequence forms a valid LinearRing, by checking the sequence length and closure (whether the first and last points are identical in 2D). Self-intersection is not checked.
      Parameters:
      seq - the sequence to test
      Returns:
      true if the sequence is a ring
      See Also:
    • ensureValidRing

      public static CoordinateSequence ensureValidRing(CoordinateSequenceFactory fact, CoordinateSequence seq)
      Ensures that a CoordinateSequence forms a valid ring, returning a new closed sequence of the correct length if required. If the input sequence is already a valid ring, it is returned without modification. If the input sequence is too short or is not closed, it is extended with one or more copies of the start point.
      Parameters:
      fact - the CoordinateSequenceFactory to use to create the new sequence
      seq - the sequence to test
      Returns:
      the original sequence, if it was a valid ring, or a new sequence which is valid.
    • createClosedRing

      private static CoordinateSequence createClosedRing(CoordinateSequenceFactory fact, CoordinateSequence seq, int size)
    • extend

      public static CoordinateSequence extend(CoordinateSequenceFactory fact, CoordinateSequence seq, int size)
    • isEqual

      public static boolean isEqual(CoordinateSequence cs1, CoordinateSequence cs2)
      Tests whether two CoordinateSequences are equal. To be equal, the sequences must be the same length. They do not need to be of the same dimension, but the ordinate values for the smallest dimension of the two must be equal. Two NaN ordinates values are considered to be equal.
      Parameters:
      cs1 - a CoordinateSequence
      cs2 - a CoordinateSequence
      Returns:
      true if the sequences are equal in the common dimensions
    • toString

      public static String toString(CoordinateSequence cs)
      Creates a string representation of a CoordinateSequence. The format is:
         ( ord0,ord1.. ord0,ord1,...  ... )
       
      Parameters:
      cs - the sequence to output
      Returns:
      the string representation of the sequence