Class JtsHelper



  • public class JtsHelper
    extends Object
    Various utility methods for JTS.
    • Constructor Detail

      • JtsHelper

        public JtsHelper()
    • Method Detail

      • toLineString

        public static LineString toLineString(List<Double> xs,
                                              List<Double> ys)
        Create a LineString from the denoted list of coordinates. The i'th point of the string is represented by (xs[i], ys[i]).
        Parameters:
        xs - the x values.
        ys - the y values.
        Returns:
        the created LineString instance.
      • toLineString

        public static LineString toLineString(TDoubleList xs,
                                              TDoubleList ys)
        Create a LineString from the denoted list of coordinates. The i'th point of the string is represented by (xs[i], ys[i]).
        Parameters:
        xs - the x values.
        ys - the y values.
        Returns:
        the created LineString instance.
      • toLinearRing

        public static LinearRing toLinearRing(List<Double> xs,
                                              List<Double> ys,
                                              boolean doublePoint)
        Create a LinearRing from two lists of coordinates. The i'th point of the ring is represented by (xs[i], ys[i]).
        Parameters:
        xs - the list of x-coordinates.
        ys - the list of y-coordinates.
        doublePoint - whether the first point is explicitly contained in the lists a second time as the last point.
        Returns:
        the constructed ring.
      • toLinearRing

        public static LinearRing toLinearRing(TDoubleList xs,
                                              TDoubleList ys,
                                              boolean doublePoint)
        Create a LinearRing from two lists of coordinates. The i'th point of the ring is represented by (xs[i], ys[i]).
        Parameters:
        xs - the list of x-coordinates.
        ys - the list of y-coordinates.
        doublePoint - whether the first point is explicitly contained in the lists a second time as the last point.
        Returns:
        the constructed ring.
      • toGeometry

        public static Polygon toGeometry(Envelope envelope)
        Convert an envelope to a polygon.
        Parameters:
        envelope - the envelope to convert.
        Returns:
        the resulting polygon.
      • expandBy

        public static Envelope expandBy(Envelope envelope,
                                        double ratio)
        Create a copy of this envelope whose extend is in each direction bigger as much as width * ratio or height * ratio respectively.
        Parameters:
        envelope - the envelope to extend.
        ratio - the ratio with which to extend.
        Returns:
        a new envelope.
      • getEnvelope

        public static Envelope getEnvelope(Collection<Geometry> geometries)
        Calculate the bounding box of the given collection of geometries.
        Parameters:
        geometries - the geometries to calculate a bounding box for.
        Returns:
        the bounding box as an envelope
      • collection

        public static GeometryCollection collection(List<Geometry> geometries)
        Create a GeometryCollection of the specified list of geometries.
        Parameters:
        geometries - the list of geometries
        Returns:
        a new GeometryCollection