Class PostGisUtil


  • @NonNullByDefault
    public final class PostGisUtil
    extends java.lang.Object
    Class for helper functions.
    Author:
    Sebastian Baumhekel
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static byte BIG_ENDIAN
      Big endian encoding.
      static byte LITTLE_ENDIAN
      Little endian encoding.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double calcAreaSigned​(java.lang.Iterable<Point> points)
      Calculates the area of the outer ring of the given polygon (signed).
      static <T extends Geometry>
      boolean
      checkConsistency​(java.lang.Iterable<T> geoms)
      Do some internal consistency checks on the given geometries.
      static boolean equalsDouble​(double a, double b)
      Compares two double values respecting Double.NaN values.
      static <T,​U>
      boolean
      equalsIterable​(java.lang.Iterable<T> la, java.lang.Iterable<U> lb)
      Checks, if the given Iterables contain the same elements (in the same order).
      static <T> T firstOrDefault​(java.lang.Iterable<T> elements)
      Returns the first or a default element of the given collection.
      static <T> T lastOrDefault​(java.lang.Iterable<T> elements)
      Gets the last element of the given Iterable.
      static java.lang.String removeBrackets​(java.lang.String s)
      Removes brackets from the given String.
      static <T> int size​(java.lang.Iterable<T> col)
      Returns the number of elements in this collection.
      static java.util.List<java.lang.String> split​(java.lang.String value, char separator)
      Splits a string like String.split(String) without any support for regular expressions, but faster.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LITTLE_ENDIAN

        public static final byte LITTLE_ENDIAN
        Little endian encoding.
        See Also:
        Constant Field Values
    • Method Detail

      • calcAreaSigned

        public static double calcAreaSigned​(java.lang.Iterable<Point> points)
        Calculates the area of the outer ring of the given polygon (signed).
        Parameters:
        points - points
        Returns:
        area (signed depending on direction)
      • checkConsistency

        public static <T extends Geometry> boolean checkConsistency​(java.lang.Iterable<T> geoms)
        Do some internal consistency checks on the given geometries. Currently, all Geometries must have a valid dimension (2 or 3) and a valid type. Composed geometries must have all equal SRID, dimensionality and measures, as well as that they do not contain NULL or inconsistent subgeometries. BinaryParser and WKTParser should only generate consistent geometries. BinaryWriter may produce invalid results on inconsistent geometries.
        Parameters:
        geoms - geometries
        Returns:
        true if all checks are passed.
      • equalsDouble

        public static boolean equalsDouble​(double a,
                                           double b)
        Compares two double values respecting Double.NaN values.
        Parameters:
        a - Double
        b - Double
        Returns:
        true if they are equal, else false
      • equalsIterable

        public static <T,​U> boolean equalsIterable​(@Nullable
                                                         java.lang.Iterable<T> la,
                                                         @Nullable
                                                         java.lang.Iterable<U> lb)
        Checks, if the given Iterables contain the same elements (in the same order).
        Parameters:
        la - Iterable (can be null)
        lb - Iterable (can be null)
        Returns:
        true on success, else false
      • firstOrDefault

        @Nullable
        public static <T> T firstOrDefault​(java.lang.Iterable<T> elements)
        Returns the first or a default element of the given collection.
        Parameters:
        elements - collection
        Returns:
        first element if it exists, else default element
      • lastOrDefault

        @Nullable
        public static <T> T lastOrDefault​(java.lang.Iterable<T> elements)
        Gets the last element of the given Iterable.
        Parameters:
        elements - elements
        Returns:
        last element on success, else null
      • removeBrackets

        public static java.lang.String removeBrackets​(java.lang.String s)
        Removes brackets from the given String.
        Parameters:
        s - String
        Returns:
        String without brackets
      • size

        public static <T> int size​(java.lang.Iterable<T> col)
        Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
        Parameters:
        col - collection
        Returns:
        the number of elements in this collection
        See Also:
        Collection.size()
      • split

        public static java.util.List<java.lang.String> split​(java.lang.String value,
                                                             char separator)
        Splits a string like String.split(String) without any support for regular expressions, but faster.
        Parameters:
        value - String to split.
        separator - separator
        Returns:
        the array of strings computed by splitting this string