Class GeometryUtils


  • public class GeometryUtils
    extends Object
    Utilities for Geometry objects
    Since:
    1.0.3
    Author:
    osbornb
    • Constructor Detail

      • GeometryUtils

        public GeometryUtils()
    • Method Detail

      • getDimension

        public static int getDimension​(Geometry geometry)
        Get the dimension of the Geometry, 0 for points, 1 for curves, 2 for surfaces. If a collection, the largest dimension is returned.
        Parameters:
        geometry - geometry object
        Returns:
        dimension (0, 1, or 2)
      • distance

        public static double distance​(Point point1,
                                      Point point2)
        Get the Pythagorean theorem distance between two points
        Parameters:
        point1 - point 1
        point2 - point 2
        Returns:
        distance
      • distance

        public static double distance​(Line line)
        Get the Pythagorean theorem distance between the line end points
        Parameters:
        line - line
        Returns:
        distance
        Since:
        2.2.0
      • distanceHaversine

        public static double distanceHaversine​(Point point1,
                                               Point point2)
        Get the distance in meters between two points in degrees using the Haversine formula
        Parameters:
        point1 - point 1
        point2 - point 2
        Returns:
        distance in meters
        Since:
        2.2.2
      • distanceHaversine

        public static double distanceHaversine​(Line line)
        Get the distance in meters between the end points of a line in degrees using the Haversine formula
        Parameters:
        line - line
        Returns:
        distance in meters
        Since:
        2.2.2
      • bearing

        public static double bearing​(Point point1,
                                     Point point2)
        Get the bearing heading in degrees between two points in degrees
        Parameters:
        point1 - point 1
        point2 - point 2
        Returns:
        bearing angle in degrees between 0 and 360
        Since:
        2.2.0
      • bearing

        public static double bearing​(Line line)
        Get the bearing heading in degrees between line end points in degrees
        Parameters:
        line - line
        Returns:
        bearing angle in degrees between 0 inclusively and 360 exclusively
        Since:
        2.2.0
      • isNorthBearing

        public static boolean isNorthBearing​(double bearing)
        Determine if the bearing is in any north direction
        Parameters:
        bearing - bearing angle in degrees
        Returns:
        true if north bearing
        Since:
        2.2.0
      • isEastBearing

        public static boolean isEastBearing​(double bearing)
        Determine if the bearing is in any east direction
        Parameters:
        bearing - bearing angle in degrees
        Returns:
        true if east bearing
        Since:
        2.2.0
      • isSouthBearing

        public static boolean isSouthBearing​(double bearing)
        Determine if the bearing is in any south direction
        Parameters:
        bearing - bearing angle in degrees
        Returns:
        true if south bearing
        Since:
        2.2.0
      • isWestBearing

        public static boolean isWestBearing​(double bearing)
        Determine if the bearing is in any west direction
        Parameters:
        bearing - bearing angle in degrees
        Returns:
        true if west bearing
        Since:
        2.2.0
      • geodesicMidpoint

        public static Point geodesicMidpoint​(Point point1,
                                             Point point2)
        Get the geodesic midpoint in degrees between two points in degrees
        Parameters:
        point1 - point 1
        point2 - point 2
        Returns:
        geodesic midpoint in degrees
        Since:
        2.2.2
      • geodesicMidpointRadians

        public static Point geodesicMidpointRadians​(Point point1,
                                                    Point point2)
        Get the geodesic midpoint in radians between two points in radians
        Parameters:
        point1 - point 1
        point2 - point 2
        Returns:
        geodesic midpoint in radians
        Since:
        2.2.2
      • degreesToRadians

        public static double degreesToRadians​(double degrees)
        Convert degrees to radians
        Parameters:
        degrees - degrees
        Returns:
        radians
        Since:
        2.2.0
      • radiansToDegrees

        public static double radiansToDegrees​(double radians)
        Convert radians to degrees
        Parameters:
        radians - radians
        Returns:
        degrees
        Since:
        2.2.0
      • degreesToRadians

        public static Point degreesToRadians​(Point point)
        Convert point in degrees to radians
        Parameters:
        point - point in degrees
        Returns:
        point in radians
        Since:
        2.2.2
      • radiansToDegrees

        public static Point radiansToDegrees​(Point point)
        Convert point in radians to degrees
        Parameters:
        point - point in radians
        Returns:
        point in degrees
        Since:
        2.2.2
      • getCentroid

        public static Point getCentroid​(Geometry geometry)
        Get the centroid point of a 2 dimensional representation of the Geometry (balancing point of a 2d cutout of the geometry). Only the x and y coordinate of the resulting point are calculated and populated. The resulting Point.getZ() and Point.getM() methods will always return null.
        Parameters:
        geometry - geometry object
        Returns:
        centroid point
      • getDegreesCentroid

        public static Point getDegreesCentroid​(Geometry geometry)
        Get the geographic centroid point of a 2 dimensional representation of the degree unit Geometry. Only the x and y coordinate of the resulting point are calculated and populated. The resulting Point.getZ() and Point.getM() methods will always return null.
        Parameters:
        geometry - geometry object
        Returns:
        centroid point
        Since:
        2.0.5
      • minimizeWGS84

        public static void minimizeWGS84​(Geometry geometry)
        Minimize the WGS84 geometry using the shortest x distance between each connected set of points. Resulting x values will be in the range: -540.0 <= x <= 540.0
        Parameters:
        geometry - geometry
        Since:
        2.2.0
      • minimizeWebMercator

        public static void minimizeWebMercator​(Geometry geometry)
        Minimize the Web Mercator geometry using the shortest x distance between each connected set of points. Resulting x values will be in the range: -60112525.028367732 <= x <= 60112525.028367732
        Parameters:
        geometry - geometry
        Since:
        2.2.0
      • minimizeGeometry

        public static void minimizeGeometry​(Geometry geometry,
                                            double maxX)
        Minimize the geometry using the shortest x distance between each connected set of points. The resulting geometry point x values will be in the range: (3 * min value <= x <= 3 * max value Example: For WGS84 provide a max x of GeometryConstants.WGS84_HALF_WORLD_LON_WIDTH. Resulting x values will be in the range: -540.0 <= x <= 540.0 Example: For web mercator provide a world width of GeometryConstants.WEB_MERCATOR_HALF_WORLD_WIDTH. Resulting x values will be in the range: -60112525.028367732 <= x <= 60112525.028367732
        Parameters:
        geometry - geometry
        maxX - max positive x value in the geometry projection
      • minimize

        public static void minimize​(Geometry geometry,
                                    double maxX)
        Minimize the geometry using the shortest x distance between each connected set of points. The resulting geometry point x values will be in the range: (3 * min value <= x <= 3 * max value Example: For WGS84 provide a max x of GeometryConstants.WGS84_HALF_WORLD_LON_WIDTH. Resulting x values will be in the range: -540.0 <= x <= 540.0 Example: For web mercator provide a world width of GeometryConstants.WEB_MERCATOR_HALF_WORLD_WIDTH. Resulting x values will be in the range: -60112525.028367732 <= x <= 60112525.028367732
        Parameters:
        geometry - geometry
        maxX - max positive x value in the geometry projection
        Since:
        2.2.0
      • normalizeWGS84

        public static void normalizeWGS84​(Geometry geometry)
        Normalize the WGS84 geometry using the shortest x distance between each connected set of points. Resulting x values will be in the range: -180.0 <= x <= 180.0
        Parameters:
        geometry - geometry
        Since:
        2.2.0
      • normalizeWebMercator

        public static void normalizeWebMercator​(Geometry geometry)
        Normalize the Web Mercator geometry using the shortest x distance between each connected set of points. Resulting x values will be in the range: -20037508.342789244 <= x <= 20037508.342789244
        Parameters:
        geometry - geometry
        Since:
        2.2.0
      • normalizeGeometry

        public static void normalizeGeometry​(Geometry geometry,
                                             double maxX)
        Normalize the geometry so all points outside of the min and max value range are adjusted to fall within the range. Example: For WGS84 provide a max x of GeometryConstants.WGS84_HALF_WORLD_LON_WIDTH. Resulting x values will be in the range: -180.0 <= x <= 180.0 Example: For web mercator provide a world width of GeometryConstants.WEB_MERCATOR_HALF_WORLD_WIDTH. Resulting x values will be in the range: -20037508.342789244 <= x <= 20037508.342789244
        Parameters:
        geometry - geometry
        maxX - max positive x value in the geometry projection
      • normalize

        public static void normalize​(Geometry geometry,
                                     double maxX)
        Normalize the geometry so all points outside of the min and max value range are adjusted to fall within the range. Example: For WGS84 provide a max x of GeometryConstants.WGS84_HALF_WORLD_LON_WIDTH. Resulting x values will be in the range: -180.0 <= x <= 180.0 Example: For web mercator provide a world width of GeometryConstants.WEB_MERCATOR_HALF_WORLD_WIDTH. Resulting x values will be in the range: -20037508.342789244 <= x <= 20037508.342789244
        Parameters:
        geometry - geometry
        maxX - max positive x value in the geometry projection
        Since:
        2.2.0
      • simplifyPoints

        public static List<Point> simplifyPoints​(List<Point> points,
                                                 double tolerance)
        Simplify the ordered points (representing a line, polygon, etc) using the Douglas Peucker algorithm to create a similar curve with fewer points. Points should be in a meters unit type projection. The tolerance is the minimum tolerated distance between consecutive points.
        Parameters:
        points - geometry points
        tolerance - minimum tolerance in meters for consecutive points
        Returns:
        simplified points
        Since:
        1.0.4
      • geodesicPath

        public static List<Point> geodesicPath​(LineString lineString,
                                               double maxDistance)
        Create a geodesic path of a line string in degrees with a max distance between any two path points
        Parameters:
        lineString - line string in degrees
        maxDistance - max distance allowed between path points
        Returns:
        geodesic path of points
        Since:
        2.2.2
      • geodesicPath

        public static List<Point> geodesicPath​(List<Point> points,
                                               double maxDistance)
        Create a geodesic path of points in degrees with a max distance between any two path points
        Parameters:
        points - points in degrees
        maxDistance - max distance allowed between path points
        Returns:
        geodesic path of points
        Since:
        2.2.2
      • geodesicPath

        public static List<Point> geodesicPath​(Point point1,
                                               Point point2,
                                               double maxDistance)
        Create a geodesic path between the two points in degrees with a max distance between any two path points
        Parameters:
        point1 - point 1
        point2 - point 2
        maxDistance - max distance allowed between path points
        Returns:
        geodesic path of points
        Since:
        2.2.2
      • geodesicEnvelope

        public static GeometryEnvelope geodesicEnvelope​(GeometryEnvelope envelope)
        Expand the vertical bounds of a geometry envelope in degrees by including geodesic bounds
        Parameters:
        envelope - geometry envelope in degrees
        Returns:
        geodesic expanded geometry envelope in degrees
        Since:
        2.2.2
      • perpendicularDistance

        public static double perpendicularDistance​(Point point,
                                                   Point lineStart,
                                                   Point lineEnd)
        Calculate the perpendicular distance between the point and the line represented by the start and end points. Points should be in a meters unit type projection.
        Parameters:
        point - point
        lineStart - point representing the line start
        lineEnd - point representing the line end
        Returns:
        distance in meters
        Since:
        1.0.4
      • pointInPolygon

        public static boolean pointInPolygon​(Point point,
                                             Polygon polygon)
        Check if the point is in the polygon
        Parameters:
        point - point
        polygon - polygon
        Returns:
        true if in the polygon
        Since:
        1.0.5
      • pointInPolygon

        public static boolean pointInPolygon​(Point point,
                                             Polygon polygon,
                                             double epsilon)
        Check if the point is in the polygon
        Parameters:
        point - point
        polygon - polygon
        epsilon - epsilon line tolerance
        Returns:
        true if in the polygon
        Since:
        1.0.5
      • pointInPolygon

        public static boolean pointInPolygon​(Point point,
                                             LineString ring)
        Check if the point is in the polygon ring
        Parameters:
        point - point
        ring - polygon ring
        Returns:
        true if in the polygon
        Since:
        1.0.5
      • pointInPolygon

        public static boolean pointInPolygon​(Point point,
                                             LineString ring,
                                             double epsilon)
        Check if the point is in the polygon ring
        Parameters:
        point - point
        ring - polygon ring
        epsilon - epsilon line tolerance
        Returns:
        true if in the polygon
        Since:
        1.0.5
      • pointInPolygon

        public static boolean pointInPolygon​(Point point,
                                             List<Point> points)
        Check if the point is in the polygon points
        Parameters:
        point - point
        points - polygon points
        Returns:
        true if in the polygon
        Since:
        1.0.5
      • pointInPolygon

        public static boolean pointInPolygon​(Point point,
                                             List<Point> points,
                                             double epsilon)
        Check if the point is in the polygon points
        Parameters:
        point - point
        points - polygon points
        epsilon - epsilon line tolerance
        Returns:
        true if in the polygon
        Since:
        1.0.5
      • pointOnPolygonEdge

        public static boolean pointOnPolygonEdge​(Point point,
                                                 Polygon polygon)
        Check if the point is on the polygon edge
        Parameters:
        point - point
        polygon - polygon
        Returns:
        true if on the polygon edge
        Since:
        1.0.5
      • pointOnPolygonEdge

        public static boolean pointOnPolygonEdge​(Point point,
                                                 Polygon polygon,
                                                 double epsilon)
        Check if the point is on the polygon edge
        Parameters:
        point - point
        polygon - polygon
        epsilon - epsilon line tolerance
        Returns:
        true if on the polygon edge
        Since:
        1.0.5
      • pointOnPolygonEdge

        public static boolean pointOnPolygonEdge​(Point point,
                                                 LineString ring)
        Check if the point is on the polygon ring edge
        Parameters:
        point - point
        ring - polygon ring
        Returns:
        true if on the polygon edge
        Since:
        1.0.5
      • pointOnPolygonEdge

        public static boolean pointOnPolygonEdge​(Point point,
                                                 LineString ring,
                                                 double epsilon)
        Check if the point is on the polygon ring edge
        Parameters:
        point - point
        ring - polygon ring
        epsilon - epsilon line tolerance
        Returns:
        true if on the polygon edge
        Since:
        1.0.5
      • pointOnPolygonEdge

        public static boolean pointOnPolygonEdge​(Point point,
                                                 List<Point> points)
        Check if the point is on the polygon ring edge points
        Parameters:
        point - point
        points - polygon points
        Returns:
        true if on the polygon edge
        Since:
        1.0.5
      • pointOnPolygonEdge

        public static boolean pointOnPolygonEdge​(Point point,
                                                 List<Point> points,
                                                 double epsilon)
        Check if the point is on the polygon ring edge points
        Parameters:
        point - point
        points - polygon points
        epsilon - epsilon line tolerance
        Returns:
        true if on the polygon edge
        Since:
        1.0.5
      • closedPolygon

        public static boolean closedPolygon​(Polygon polygon)
        Check if the polygon outer ring is explicitly closed, where the first and last point are the same
        Parameters:
        polygon - polygon
        Returns:
        true if the first and last points are the same
        Since:
        1.0.5
      • closedPolygon

        public static boolean closedPolygon​(LineString ring)
        Check if the polygon ring is explicitly closed, where the first and last point are the same
        Parameters:
        ring - polygon ring
        Returns:
        true if the first and last points are the same
        Since:
        1.0.5
      • closedPolygon

        public static boolean closedPolygon​(List<Point> points)
        Check if the polygon ring points are explicitly closed, where the first and last point are the same
        Parameters:
        points - polygon ring points
        Returns:
        true if the first and last points are the same
        Since:
        1.0.5
      • pointOnLine

        public static boolean pointOnLine​(Point point,
                                          LineString line)
        Check if the point is on the line
        Parameters:
        point - point
        line - line
        Returns:
        true if on the line
        Since:
        1.0.5
      • pointOnLine

        public static boolean pointOnLine​(Point point,
                                          LineString line,
                                          double epsilon)
        Check if the point is on the line
        Parameters:
        point - point
        line - line
        epsilon - epsilon line tolerance
        Returns:
        true if on the line
        Since:
        1.0.5
      • pointOnLine

        public static boolean pointOnLine​(Point point,
                                          List<Point> points)
        Check if the point is on the line represented by the points
        Parameters:
        point - point
        points - line points
        Returns:
        true if on the line
        Since:
        1.0.5
      • pointOnLine

        public static boolean pointOnLine​(Point point,
                                          List<Point> points,
                                          double epsilon)
        Check if the point is on the line represented by the points
        Parameters:
        point - point
        points - line points
        epsilon - epsilon line tolerance
        Returns:
        true if on the line
        Since:
        1.0.5
      • pointOnPath

        public static boolean pointOnPath​(Point point,
                                          Point point1,
                                          Point point2)
        Check if the point is on the path between point 1 and point 2
        Parameters:
        point - point
        point1 - path point 1
        point2 - path point 2
        Returns:
        true if on the path
        Since:
        1.0.5
      • pointOnPath

        public static boolean pointOnPath​(Point point,
                                          Point point1,
                                          Point point2,
                                          double epsilon)
        Check if the point is on the path between point 1 and point 2
        Parameters:
        point - point
        point1 - path point 1
        point2 - path point 2
        epsilon - epsilon line tolerance
        Returns:
        true if on the path
        Since:
        1.0.5
      • intersection

        public static Point intersection​(Line line1,
                                         Line line2)
        Get the point intersection between two lines
        Parameters:
        line1 - first line
        line2 - second line
        Returns:
        intersection point or null if no intersection
        Since:
        2.1.0
      • intersection

        public static Point intersection​(Point line1Point1,
                                         Point line1Point2,
                                         Point line2Point1,
                                         Point line2Point2)
        Get the point intersection between end points of two lines
        Parameters:
        line1Point1 - first point of the first line
        line1Point2 - second point of the first line
        line2Point1 - first point of the second line
        line2Point2 - second point of the second line
        Returns:
        intersection point or null if no intersection
        Since:
        2.1.0
      • degreesToMeters

        public static Geometry degreesToMeters​(Geometry geometry)
        Convert a geometry in degrees to a geometry in meters
        Parameters:
        geometry - geometry in degrees
        Returns:
        geometry in meters
        Since:
        2.2.0
      • degreesToMeters

        public static Point degreesToMeters​(Point point)
        Convert a point in degrees to a point in meters
        Parameters:
        point - point in degrees
        Returns:
        point in meters
        Since:
        2.1.0
      • degreesToMeters

        public static Point degreesToMeters​(double x,
                                            double y)
        Convert a coordinate in degrees to a point in meters
        Parameters:
        x - x value in degrees
        y - y value in degrees
        Returns:
        point in meters
        Since:
        2.1.0
      • degreesToMeters

        public static MultiPoint degreesToMeters​(MultiPoint multiPoint)
        Convert a multi point in degrees to a multi point in meters
        Parameters:
        multiPoint - multi point in degrees
        Returns:
        multi point in meters
        Since:
        2.2.0
      • degreesToMeters

        public static LineString degreesToMeters​(LineString lineString)
        Convert a line string in degrees to a line string in meters
        Parameters:
        lineString - line string in degrees
        Returns:
        line string in meters
        Since:
        2.2.0
      • degreesToMeters

        public static Line degreesToMeters​(Line line)
        Convert a line in degrees to a line in meters
        Parameters:
        line - line in degrees
        Returns:
        line in meters
        Since:
        2.2.0
      • degreesToMeters

        public static MultiLineString degreesToMeters​(MultiLineString multiLineString)
        Convert a multi line string in degrees to a multi line string in meters
        Parameters:
        multiLineString - multi line string in degrees
        Returns:
        multi line string in meters
        Since:
        2.2.0
      • degreesToMeters

        public static Polygon degreesToMeters​(Polygon polygon)
        Convert a polygon in degrees to a polygon in meters
        Parameters:
        polygon - polygon in degrees
        Returns:
        polygon in meters
        Since:
        2.2.0
      • degreesToMeters

        public static MultiPolygon degreesToMeters​(MultiPolygon multiPolygon)
        Convert a multi polygon in degrees to a multi polygon in meters
        Parameters:
        multiPolygon - multi polygon in degrees
        Returns:
        multi polygon in meters
        Since:
        2.2.0
      • degreesToMeters

        public static CircularString degreesToMeters​(CircularString circularString)
        Convert a circular string in degrees to a circular string in meters
        Parameters:
        circularString - circular string in degrees
        Returns:
        circular string in meters
        Since:
        2.2.0
      • degreesToMeters

        public static CompoundCurve degreesToMeters​(CompoundCurve compoundCurve)
        Convert a compound curve in degrees to a compound curve in meters
        Parameters:
        compoundCurve - compound curve in degrees
        Returns:
        compound curve in meters
        Since:
        2.2.0
      • degreesToMeters

        public static CurvePolygon<Curve> degreesToMeters​(CurvePolygon<Curve> curvePolygon)
        Convert a curve polygon in degrees to a curve polygon in meters
        Parameters:
        curvePolygon - curve polygon in degrees
        Returns:
        curve polygon in meters
        Since:
        2.2.0
      • degreesToMeters

        public static PolyhedralSurface degreesToMeters​(PolyhedralSurface polyhedralSurface)
        Convert a polyhedral surface in degrees to a polyhedral surface in meters
        Parameters:
        polyhedralSurface - polyhedral surface in degrees
        Returns:
        polyhedral surface in meters
        Since:
        2.2.0
      • degreesToMeters

        public static TIN degreesToMeters​(TIN tin)
        Convert a TIN in degrees to a TIN in meters
        Parameters:
        tin - TIN in degrees
        Returns:
        TIN in meters
        Since:
        2.2.0
      • degreesToMeters

        public static Triangle degreesToMeters​(Triangle triangle)
        Convert a triangle in degrees to a triangle in meters
        Parameters:
        triangle - triangle in degrees
        Returns:
        triangle in meters
        Since:
        2.2.0
      • metersToDegrees

        public static Geometry metersToDegrees​(Geometry geometry)
        Convert a geometry in meters to a geometry in degrees
        Parameters:
        geometry - geometry in meters
        Returns:
        geometry in degrees
        Since:
        2.2.0
      • metersToDegrees

        public static Point metersToDegrees​(Point point)
        Convert a point in meters to a point in degrees
        Parameters:
        point - point in meters
        Returns:
        point in degrees
        Since:
        2.1.0
      • metersToDegrees

        public static Point metersToDegrees​(double x,
                                            double y)
        Convert a coordinate in meters to a point in degrees
        Parameters:
        x - x value in meters
        y - y value in meters
        Returns:
        point in degrees
        Since:
        2.1.0
      • metersToDegrees

        public static MultiPoint metersToDegrees​(MultiPoint multiPoint)
        Convert a multi point in meters to a multi point in degrees
        Parameters:
        multiPoint - multi point in meters
        Returns:
        multi point in degrees
        Since:
        2.2.0
      • metersToDegrees

        public static LineString metersToDegrees​(LineString lineString)
        Convert a line string in meters to a line string in degrees
        Parameters:
        lineString - line string in meters
        Returns:
        line string in degrees
        Since:
        2.2.0
      • metersToDegrees

        public static Line metersToDegrees​(Line line)
        Convert a line in meters to a line in degrees
        Parameters:
        line - line in meters
        Returns:
        line in degrees
        Since:
        2.2.0
      • metersToDegrees

        public static MultiLineString metersToDegrees​(MultiLineString multiLineString)
        Convert a multi line string in meters to a multi line string in degrees
        Parameters:
        multiLineString - multi line string in meters
        Returns:
        multi line string in degrees
        Since:
        2.2.0
      • metersToDegrees

        public static Polygon metersToDegrees​(Polygon polygon)
        Convert a polygon in meters to a polygon in degrees
        Parameters:
        polygon - polygon in meters
        Returns:
        polygon in degrees
        Since:
        2.2.0
      • metersToDegrees

        public static MultiPolygon metersToDegrees​(MultiPolygon multiPolygon)
        Convert a multi polygon in meters to a multi polygon in degrees
        Parameters:
        multiPolygon - multi polygon in meters
        Returns:
        multi polygon in degrees
        Since:
        2.2.0
      • metersToDegrees

        public static CircularString metersToDegrees​(CircularString circularString)
        Convert a circular string in meters to a circular string in degrees
        Parameters:
        circularString - circular string in meters
        Returns:
        circular string in degrees
        Since:
        2.2.0
      • metersToDegrees

        public static CompoundCurve metersToDegrees​(CompoundCurve compoundCurve)
        Convert a compound curve in meters to a compound curve in degrees
        Parameters:
        compoundCurve - compound curve in meters
        Returns:
        compound curve in degrees
        Since:
        2.2.0
      • metersToDegrees

        public static CurvePolygon<Curve> metersToDegrees​(CurvePolygon<Curve> curvePolygon)
        Convert a curve polygon in meters to a curve polygon in degrees
        Parameters:
        curvePolygon - curve polygon in meters
        Returns:
        curve polygon in degrees
        Since:
        2.2.0
      • metersToDegrees

        public static PolyhedralSurface metersToDegrees​(PolyhedralSurface polyhedralSurface)
        Convert a polyhedral surface in meters to a polyhedral surface in degrees
        Parameters:
        polyhedralSurface - polyhedral surface in meters
        Returns:
        polyhedral surface in degrees
        Since:
        2.2.0
      • metersToDegrees

        public static TIN metersToDegrees​(TIN tin)
        Convert a TIN in meters to a TIN in degrees
        Parameters:
        tin - TIN in meters
        Returns:
        TIN in degrees
        Since:
        2.2.0
      • metersToDegrees

        public static Triangle metersToDegrees​(Triangle triangle)
        Convert a triangle in meters to a triangle in degrees
        Parameters:
        triangle - triangle in meters
        Returns:
        triangle in degrees
        Since:
        2.2.0
      • wgs84Envelope

        public static GeometryEnvelope wgs84Envelope()
        Get a WGS84 bounded geometry envelope
        Returns:
        geometry envelope
        Since:
        2.2.0
      • wgs84TransformableEnvelope

        public static GeometryEnvelope wgs84TransformableEnvelope()
        Get a WGS84 bounded geometry envelope used for projection transformations (degrees to meters)
        Returns:
        geometry envelope
        Since:
        2.2.0
      • webMercatorEnvelope

        public static GeometryEnvelope webMercatorEnvelope()
        Get a Web Mercator bounded geometry envelope
        Returns:
        geometry envelope
        Since:
        2.2.0
      • wgs84EnvelopeWithWebMercator

        public static GeometryEnvelope wgs84EnvelopeWithWebMercator()
        Get a WGS84 geometry envelope with Web Mercator bounds
        Returns:
        geometry envelope
        Since:
        2.2.0
      • cropWebMercator

        public static Geometry cropWebMercator​(Geometry geometry)
        Crop the geometry in meters by web mercator world bounds. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        geometry - geometry in meters
        Returns:
        cropped geometry in meters or null
        Since:
        2.2.0
      • crop

        public static Geometry crop​(Geometry geometry,
                                    GeometryEnvelope envelope)
        Crop the geometry in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        geometry - geometry in meters
        envelope - envelope in meters
        Returns:
        cropped geometry in meters or null
        Since:
        2.2.0
      • crop

        public static Point crop​(Point point,
                                 GeometryEnvelope envelope)
        Crop the point by the envelope bounds.
        Parameters:
        point - point
        envelope - envelope
        Returns:
        cropped point or null
        Since:
        2.2.0
      • crop

        public static List<Point> crop​(List<Point> points,
                                       GeometryEnvelope envelope)
        Crop the list of consecutive points in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        points - consecutive points
        envelope - envelope in meters
        Returns:
        cropped points in meters or null
        Since:
        2.2.0
      • crop

        public static MultiPoint crop​(MultiPoint multiPoint,
                                      GeometryEnvelope envelope)
        Crop the multi point by the envelope bounds.
        Parameters:
        multiPoint - multi point
        envelope - envelope
        Returns:
        cropped multi point or null
        Since:
        2.2.0
      • crop

        public static LineString crop​(LineString lineString,
                                      GeometryEnvelope envelope)
        Crop the line string in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        lineString - line string in meters
        envelope - envelope in meters
        Returns:
        cropped line string in meters or null
        Since:
        2.2.0
      • crop

        public static Line crop​(Line line,
                                GeometryEnvelope envelope)
        Crop the line in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        line - line in meters
        envelope - envelope in meters
        Returns:
        cropped line in meters or null
        Since:
        2.2.0
      • crop

        public static MultiLineString crop​(MultiLineString multiLineString,
                                           GeometryEnvelope envelope)
        Crop the multi line string in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        multiLineString - multi line string in meters
        envelope - envelope in meters
        Returns:
        cropped multi line string in meters or null
        Since:
        2.2.0
      • crop

        public static Polygon crop​(Polygon polygon,
                                   GeometryEnvelope envelope)
        Crop the polygon in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        polygon - polygon in meters
        envelope - envelope in meters
        Returns:
        cropped polygon in meters or null
        Since:
        2.2.0
      • crop

        public static MultiPolygon crop​(MultiPolygon multiPolygon,
                                        GeometryEnvelope envelope)
        Crop the multi polygon in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        multiPolygon - multi polygon in meters
        envelope - envelope in meters
        Returns:
        cropped multi polygon in meters or null
        Since:
        2.2.0
      • crop

        public static CircularString crop​(CircularString circularString,
                                          GeometryEnvelope envelope)
        Crop the circular string in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        circularString - circular string in meters
        envelope - envelope in meters
        Returns:
        cropped circular string in meters or null
        Since:
        2.2.0
      • crop

        public static CompoundCurve crop​(CompoundCurve compoundCurve,
                                         GeometryEnvelope envelope)
        Crop the compound curve in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        compoundCurve - compound curve in meters
        envelope - envelope in meters
        Returns:
        cropped compound curve in meters or null
        Since:
        2.2.0
      • crop

        public static CurvePolygon<Curve> crop​(CurvePolygon<Curve> curvePolygon,
                                               GeometryEnvelope envelope)
        Crop the curve polygon in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        curvePolygon - curve polygon in meters
        envelope - envelope in meters
        Returns:
        cropped curve polygon in meters or null
        Since:
        2.2.0
      • crop

        public static PolyhedralSurface crop​(PolyhedralSurface polyhedralSurface,
                                             GeometryEnvelope envelope)
        Crop the polyhedral surface in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        polyhedralSurface - polyhedral surface in meters
        envelope - envelope in meters
        Returns:
        cropped polyhedral surface in meters or null
        Since:
        2.2.0
      • crop

        public static TIN crop​(TIN tin,
                               GeometryEnvelope envelope)
        Crop the TIN in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        tin - TIN in meters
        envelope - envelope in meters
        Returns:
        cropped TIN in meters or null
        Since:
        2.2.0
      • crop

        public static Triangle crop​(Triangle triangle,
                                    GeometryEnvelope envelope)
        Crop the triangle in meters by the envelope bounds in meters. Cropping removes points outside the envelope and creates new points on the line intersections with the envelope.
        Parameters:
        triangle - triangle in meters
        envelope - envelope in meters
        Returns:
        cropped triangle in meters or null
        Since:
        2.2.0
      • isEqual

        public static boolean isEqual​(Point point1,
                                      Point point2,
                                      double epsilon)
        Determine if the points are equal within the tolerance. For exact equality, use Point.equals(Object).
        Parameters:
        point1 - point 1
        point2 - point 2
        epsilon - epsilon equality tolerance
        Returns:
        true if equal
        Since:
        2.2.0
      • boundWGS84Transformable

        public static void boundWGS84Transformable​(Geometry geometry)
        Bound all points in the geometry to be within WGS84 projection transformable (degrees to meters) limits. To perform a geometry crop using line intersections, see degreesToMeters(Geometry) and crop(Geometry, GeometryEnvelope).
        Parameters:
        geometry - geometry
        Since:
        2.2.0
      • boundWebMercator

        public static void boundWebMercator​(Geometry geometry)
        Bound all points in the geometry to be within Web Mercator limits. To perform a geometry crop using line intersections, see cropWebMercator(Geometry).
        Parameters:
        geometry - geometry
        Since:
        2.2.0
      • boundWGS84WithWebMercator

        public static void boundWGS84WithWebMercator​(Geometry geometry)
        Bound all points in the WGS84 geometry to be within degree Web Mercator limits. To perform a geometry crop using line intersections, see degreesToMeters(Geometry) and cropWebMercator(Geometry).
        Parameters:
        geometry - geometry
        Since:
        2.2.0
      • bound

        public static void bound​(Geometry geometry,
                                 GeometryEnvelope envelope)
        Bound all points in the geometry to be within the geometry envelope. Point x and y values are bounded by the min and max envelope values. To perform a geometry crop using line intersections, see crop(Geometry, GeometryEnvelope) (requires geometry in meters).
        Parameters:
        geometry - geometry
        envelope - geometry envelope
        Since:
        2.2.0
      • hasZ

        public static <T extends Geometry> boolean hasZ​(List<T> geometries)
        Determine if the geometries contain a Z value
        Type Parameters:
        T - geometry type
        Parameters:
        geometries - list of geometries
        Returns:
        true if has z
      • hasM

        public static <T extends Geometry> boolean hasM​(List<T> geometries)
        Determine if the geometries contain a M value
        Type Parameters:
        T - geometry type
        Parameters:
        geometries - list of geometries
        Returns:
        true if has m
      • parentHierarchy

        public static List<GeometryType> parentHierarchy​(GeometryType geometryType)
        Get the parent type hierarchy of the provided geometry type starting with the immediate parent. If the argument is GEOMETRY, an empty list is returned, else the final type in the list will be GEOMETRY.
        Parameters:
        geometryType - geometry type
        Returns:
        list of increasing parent types
        Since:
        2.0.1
      • parentType

        public static GeometryType parentType​(GeometryType geometryType)
        Get the parent Geometry Type of the provided geometry type
        Parameters:
        geometryType - geometry type
        Returns:
        parent geometry type or null if argument is GEOMETRY (no parent type)
        Since:
        2.0.1
      • childHierarchy

        public static Map<GeometryType,​Map<GeometryType,​?>> childHierarchy​(GeometryType geometryType)
        Get the child type hierarchy of the provided geometry type.
        Parameters:
        geometryType - geometry type
        Returns:
        child type hierarchy, null if no children
        Since:
        2.0.1
      • childTypes

        public static List<GeometryType> childTypes​(GeometryType geometryType)
        Get the immediate child Geometry Types of the provided geometry type
        Parameters:
        geometryType - geometry type
        Returns:
        child geometry types, empty list if no child types
        Since:
        2.0.1
      • serialize

        public static byte[] serialize​(Geometry geometry)
        Serialize the geometry to bytes
        Parameters:
        geometry - geometry
        Returns:
        serialized bytes
        Since:
        2.0.1
      • deserialize

        public static Geometry deserialize​(byte[] bytes)
        Deserialize the bytes into a geometry
        Parameters:
        bytes - serialized bytes
        Returns:
        geometry
        Since:
        2.0.1