Class PlanitJtsCrsUtils


  • public class PlanitJtsCrsUtils
    extends Object
    General geographic JTS utilities that rely on a known Coordinate Reference system (CRS). Uses geodetic distance when possible. In case the CRS is not based on an ellipsoid (2d plane) it will simply compute the distance between coordinates using Pythagoras with the unit distance in meters, consistent with the CartesianAuthorityFactory.GENERIC_2D It is assumed that x coordinate refers to latitude and y coordinate refers to longitude
    Author:
    markr
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static org.opengis.referencing.crs.CoordinateReferenceSystem CARTESIANCRS
      In absence of a geographic crs we can also use cartesian: GENERIC_2D
      protected org.opengis.referencing.crs.CoordinateReferenceSystem crs
      the crs to use
      static org.geotools.referencing.crs.DefaultGeographicCRS DEFAULT_GEOGRAPHIC_CRS
      Default Coordinate Reference System: WGS84
      protected org.geotools.referencing.GeodeticCalculator geoCalculator
      geodetic calculator to use in tandem with the used CRS
      protected static org.locationtech.jts.geom.GeometryFactory jtsGeometryFactory
      jts geometry factory, jts geometry differs from opengis implementation by not carrying the crs and being more lightweight
    • Constructor Summary

      Constructors 
      Constructor Description
      PlanitJtsCrsUtils()
      Constructor Uses default coordinate reference system
      PlanitJtsCrsUtils​(org.opengis.referencing.crs.CoordinateReferenceSystem coordinateReferenceSystem)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.locationtech.jts.geom.Envelope createBoundingBox​(double centrePointX, double centrePointY, double lengthMeters)
      create a square bounding box envelope instance based on the passed in reference point and length in meters of each of the legs, with the point residing in the middle
      org.locationtech.jts.geom.Envelope createBoundingBox​(double minX, double minY, double maxX, double maxY, double lengthMeters)
      create a square bounding box envelope instance based on the passed in bounding box coordinates and buffer length in meters resulting in a larger bounding box returned
      org.locationtech.jts.geom.Envelope createBoundingBox​(org.locationtech.jts.geom.Envelope boundingBox, double lengthMeters)
      create a square bounding box envelope instance based on an existing envelope bounding box and and buffer length in meters resulting in a larger bounding box returned
      org.locationtech.jts.geom.LineSegment createExtendedLineSegment​(org.locationtech.jts.geom.LineSegment source, double extensionInMeters, boolean extendStart, boolean extendEnd)
      extend the given line segment in one or two directions with a given distance in meters.
      double getAzimuthInDegrees​(org.locationtech.jts.geom.Coordinate coordinate1, org.locationtech.jts.geom.Coordinate coordinate2)
      Collect the azimuth heading between the two coordinates in decimal degrees between -180 and 180, from location 1 to location 2
      double getClosestDistanceInMeters​(org.locationtech.jts.geom.Point referencePoint, org.locationtech.jts.geom.Geometry geometry)
      find the closest distance in meters from the point to the geometry.
      double getClosestDistanceInMetersMultiLineString​(org.locationtech.jts.geom.Point referencePoint, org.locationtech.jts.geom.MultiLineString geometry)
      find the closest distance in meters from the point to the geometry.Here we project onto the geometry, so we find the actual closest distance instead of merely finding the closest modelled coordinated within the geometry.
      double getClosestDistanceInMetersToPolygon​(org.locationtech.jts.geom.Point referencePoint, org.locationtech.jts.geom.Polygon geometry)
      find the closest distance in meters from the point to the geometry.Here we project onto the geometry, so we find the actual closest distance instead of merely finding the closest modelled coordinated within the geometry.
      double getClosestExistingCoordinateDistanceInMeters​(org.locationtech.jts.geom.Point point, org.locationtech.jts.geom.Geometry geometry)
      find the distance between the closest coordinate on the geometry's coordinates.
      org.locationtech.jts.geom.Coordinate getClosestExistingCoordinateToPoint​(org.locationtech.jts.geom.Point point, org.locationtech.jts.geom.Geometry geometry)
      find the coordinate on the geometry with the closest distance to the reference point.
      <T extends org.locationtech.jts.geom.LineString>
      org.locationtech.jts.geom.Coordinate
      getClosestExistingLineStringCoordinateToGeometry​(org.locationtech.jts.geom.Geometry referenceGeometry, T lineString)
      Find the coordinate on the line string with the closest distance to the reference referenceGeometry.
      org.locationtech.jts.linearref.LinearLocation getClosestGeometryExistingCoordinateToProjectedLinearLocationOnLineString​(org.locationtech.jts.geom.Geometry referenceGeometry, org.locationtech.jts.geom.LineString linearGeometry)
      find the closest location from any existing coordinate of the reference geometry to the line string geometry as a linear location.
      org.locationtech.jts.geom.Coordinate getClosestPojectedCoordinateOnPolygon​(org.locationtech.jts.geom.Point referencePoint, org.locationtech.jts.geom.Polygon polygon)
      find the closest location from the reference coordinate to the polygon expressed as a linear location.
      org.locationtech.jts.geom.Coordinate getClosestProjectedCoordinateOnGeometry​(org.locationtech.jts.geom.Point referencePoint, org.locationtech.jts.geom.Geometry geometry)
      find the closest projected coordinate from the reference point to the geometry.
      org.locationtech.jts.geom.Coordinate getClosestProjectedCoordinateOnLineString​(org.locationtech.jts.geom.Point referencePoint, org.locationtech.jts.geom.LineString lineString)
      find the closest projected coordinate from the reference point to the line string.
      double getClosestProjectedDistanceInMetersToLineString​(org.locationtech.jts.geom.Point referencePoint, org.locationtech.jts.geom.LineString geometry)
      find the closest distance in meters from the point to the geometry.Here we project onto the geometry, so we find the actual closest distance instead of merely finding the closest modelled coordinated within the geometry.
      org.locationtech.jts.linearref.LinearLocation getClosestProjectedLinearLocationOnGeometry​(org.locationtech.jts.geom.Point referencePoint, org.locationtech.jts.geom.Geometry geometry)
      find the closest location from the reference point to the geometry expressed as a linear location.
      org.locationtech.jts.linearref.LinearLocation getClosestProjectedLinearLocationOnLineString​(org.locationtech.jts.geom.Coordinate referenceCoordinate, org.locationtech.jts.geom.LineString lineString)
      Find the closest location from the reference coordinate to the line string expressed as a linear location.
      org.locationtech.jts.linearref.LinearLocation getClosestProjectedLinearLocationOnPolygon​(org.locationtech.jts.geom.Coordinate referenceCoordinate, org.locationtech.jts.geom.Polygon polygon)
      Find the closest location from the reference coordinate to the polygon expressed as a linear location.
      org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
      collect the crs used by this instance of the utils class
      double getDistanceInKilometres​(Vertex vertex1, Vertex vertex2)
      Compute the distance in kilometres between two vertices assuming the positions are set and based on the same crs as registered on this class instance
      double getDistanceInKilometres​(org.locationtech.jts.geom.LineString geometry)
      Compute the length of the line string by traversing all nodes and computing the segment by segment distances TODO: find out if a faster way is possible
      double getDistanceInKilometres​(org.locationtech.jts.geom.Point startPosition, org.locationtech.jts.geom.Point endPosition)
      Compute the distance in kilometres between two positions assuming the positions are provided in the same crs as registered on this class instance
      double getDistanceInMetres​(org.locationtech.jts.geom.Coordinate startCoordinate, org.locationtech.jts.geom.Coordinate endCoordinate)
      Compute the distance in metres between two (JTS) coordinates assuming the positions are provided in the same crs as registered on this class instance
      double getDistanceInMetres​(org.locationtech.jts.geom.Point startPosition, org.locationtech.jts.geom.Point endPosition)
      Compute the distance in metres between two (JTS) points assuming the positions are provided in the same crs as registered on this class instance
      boolean isGeometryLeftOf​(org.locationtech.jts.geom.Geometry geometry, org.locationtech.jts.geom.Coordinate coordA, org.locationtech.jts.geom.Coordinate coordB)
      Verify if the provided geometry resides left of the line defined from coordA to coordB.
      boolean isGeometryNearBoundingBox​(org.locationtech.jts.geom.Geometry geometry, org.locationtech.jts.geom.Envelope boundingBox, double maxDistanceMeters)
      Verify if any existing coordinate on the passed in geometry is within the maximum provided distance of the also provided bounding box
    • Field Detail

      • crs

        protected final org.opengis.referencing.crs.CoordinateReferenceSystem crs
        the crs to use
      • geoCalculator

        protected final org.geotools.referencing.GeodeticCalculator geoCalculator
        geodetic calculator to use in tandem with the used CRS
      • jtsGeometryFactory

        protected static final org.locationtech.jts.geom.GeometryFactory jtsGeometryFactory
        jts geometry factory, jts geometry differs from opengis implementation by not carrying the crs and being more lightweight
      • DEFAULT_GEOGRAPHIC_CRS

        public static final org.geotools.referencing.crs.DefaultGeographicCRS DEFAULT_GEOGRAPHIC_CRS
        Default Coordinate Reference System: WGS84
      • CARTESIANCRS

        public static final org.opengis.referencing.crs.CoordinateReferenceSystem CARTESIANCRS
        In absence of a geographic crs we can also use cartesian: GENERIC_2D
    • Constructor Detail

      • PlanitJtsCrsUtils

        public PlanitJtsCrsUtils()
        Constructor Uses default coordinate reference system
      • PlanitJtsCrsUtils

        public PlanitJtsCrsUtils​(org.opengis.referencing.crs.CoordinateReferenceSystem coordinateReferenceSystem)
        Constructor
        Parameters:
        coordinateReferenceSystem - OpenGIS CoordinateReferenceSystem object containing geometry
    • Method Detail

      • getClosestExistingCoordinateDistanceInMeters

        public double getClosestExistingCoordinateDistanceInMeters​(org.locationtech.jts.geom.Point point,
                                                                   org.locationtech.jts.geom.Geometry geometry)
                                                            throws PlanItException
        find the distance between the closest coordinate on the geometry's coordinates. Note that this is likely NOT the closest point to the geometry as this likely lies on the line connecting the two closest points.
        Parameters:
        point - reference
        geometry - to check against, explore all its coordinates
        Returns:
        closest coordinate distance
        Throws:
        PlanItException - thrown if error
      • getClosestExistingCoordinateToPoint

        public org.locationtech.jts.geom.Coordinate getClosestExistingCoordinateToPoint​(org.locationtech.jts.geom.Point point,
                                                                                        org.locationtech.jts.geom.Geometry geometry)
                                                                                 throws PlanItException
        find the coordinate on the geometry with the closest distance to the reference point. Note that this is likely NOT the closest point to the geometry as this likely lies on the line connecting the two closest points.
        Parameters:
        point - reference
        geometry - to check against, explore all its coordinates
        Returns:
        closest coordinate distance
        Throws:
        PlanItException - thrown if error
      • getClosestExistingLineStringCoordinateToGeometry

        public <T extends org.locationtech.jts.geom.LineString> org.locationtech.jts.geom.Coordinate getClosestExistingLineStringCoordinateToGeometry​(org.locationtech.jts.geom.Geometry referenceGeometry,
                                                                                                                                                      T lineString)
                                                                                                                                               throws PlanItException
        Find the coordinate on the line string with the closest distance to the reference referenceGeometry. Note that this is likely NOT the closest point to the geometry as this likely lies on the line connecting the two closest points.
        Type Parameters:
        T - type of line string
        Parameters:
        referenceGeometry - to use
        lineString - to verify closest coordinate
        Returns:
        closest existing coordinate on line string to find coordinate on
        Throws:
        PlanItException - thrown if error
      • getClosestProjectedLinearLocationOnGeometry

        public org.locationtech.jts.linearref.LinearLocation getClosestProjectedLinearLocationOnGeometry​(org.locationtech.jts.geom.Point referencePoint,
                                                                                                         org.locationtech.jts.geom.Geometry geometry)
                                                                                                  throws PlanItException
        find the closest location from the reference point to the geometry expressed as a linear location. Here we project onto the geometry, so we find the location with the actual closest distance and create a linear location regardless if this coordinate is part of the geometry as a predefined coordinate at an extreme point. It is therefore more accurate than getClosestExistingCoordinateDistanceInMeters(org.locationtech.jts.geom.Point,org.locationtech.jts.geom.Geometry)
        Parameters:
        referencePoint - the reference point
        geometry - to find closest distance to point to
        Returns:
        linearLocation found
        Throws:
        PlanItException - thrown if error
      • getClosestProjectedLinearLocationOnLineString

        public org.locationtech.jts.linearref.LinearLocation getClosestProjectedLinearLocationOnLineString​(org.locationtech.jts.geom.Coordinate referenceCoordinate,
                                                                                                           org.locationtech.jts.geom.LineString lineString)
                                                                                                    throws PlanItException
        Find the closest location from the reference coordinate to the line string expressed as a linear location. Here we project onto the geometry, so we find the location with the actual closest distance and create a linear location regardless if this coordinate is part of the geometry as a predefined coordinate at an extreme point. It is therefore more accurate than getClosestExistingCoordinateDistanceInMeters(org.locationtech.jts.geom.Point,org.locationtech.jts.geom.Geometry)
        Parameters:
        referenceCoordinate - the reference point
        lineString - to find closest distance to point to (must be a linear geometry)
        Returns:
        linearLocation found
        Throws:
        PlanItException - thrown if error
      • getClosestProjectedLinearLocationOnPolygon

        public org.locationtech.jts.linearref.LinearLocation getClosestProjectedLinearLocationOnPolygon​(org.locationtech.jts.geom.Coordinate referenceCoordinate,
                                                                                                        org.locationtech.jts.geom.Polygon polygon)
                                                                                                 throws PlanItException
        Find the closest location from the reference coordinate to the polygon expressed as a linear location. Here we project onto the geometry, so we find the location with the actual closest distance and create a linear location regardless if this coordinate is part of the geometry as a predefined coordinate at an extreme point. It is therefore more accurate than getClosestExistingCoordinateDistanceInMeters(org.locationtech.jts.geom.Point,org.locationtech.jts.geom.Geometry)
        Parameters:
        referenceCoordinate - the reference point
        polygon - to find closest distance to point to (must be a linear geometry)
        Returns:
        linearLocation found
        Throws:
        PlanItException - thrown if error
      • getClosestGeometryExistingCoordinateToProjectedLinearLocationOnLineString

        public org.locationtech.jts.linearref.LinearLocation getClosestGeometryExistingCoordinateToProjectedLinearLocationOnLineString​(org.locationtech.jts.geom.Geometry referenceGeometry,
                                                                                                                                       org.locationtech.jts.geom.LineString linearGeometry)
                                                                                                                                throws PlanItException
        find the closest location from any existing coordinate of the reference geometry to the line string geometry as a linear location. Here we project onto the geometry, so we find the location with the actual closest distance and extract the linear location regardless if this coordinate is part of the geometry as a predefined coordinate at an extreme point. It is therefore more accurate than getClosestExistingCoordinateDistanceInMeters(org.locationtech.jts.geom.Point,org.locationtech.jts.geom.Geometry)
        Parameters:
        referenceGeometry - the reference geometry
        linearGeometry - to find closest distance to point to (must be a linear geometry)
        Returns:
        linearLocation found
        Throws:
        PlanItException - thrown if error
      • getClosestProjectedCoordinateOnGeometry

        public org.locationtech.jts.geom.Coordinate getClosestProjectedCoordinateOnGeometry​(org.locationtech.jts.geom.Point referencePoint,
                                                                                            org.locationtech.jts.geom.Geometry geometry)
                                                                                     throws PlanItException
        find the closest projected coordinate from the reference point to the geometry. Here we project onto the geometry, so we find the location with the actual closest distance and create a coordinate at this location regardless if this coordinate is part of the geometry as a predefined coordinate at an extreme point. It is therefore more accurate than getClosestExistingCoordinateDistanceInMeters(org.locationtech.jts.geom.Point,org.locationtech.jts.geom.Geometry)
        Parameters:
        referencePoint - the reference point
        geometry - to find closest distance to point to
        Returns:
        distance found in meters
        Throws:
        PlanItException - thrown if error
      • getClosestProjectedCoordinateOnLineString

        public org.locationtech.jts.geom.Coordinate getClosestProjectedCoordinateOnLineString​(org.locationtech.jts.geom.Point referencePoint,
                                                                                              org.locationtech.jts.geom.LineString lineString)
                                                                                       throws PlanItException
        find the closest projected coordinate from the reference point to the line string. Here we project onto the geometry, so we find the location with the actual closest distance and create a coordinate at this location regardless if this coordinate is part of the geometry as a predefined coordinate at an extreme point. It is therefore more accurate than getClosestExistingCoordinateDistanceInMeters(org.locationtech.jts.geom.Point,org.locationtech.jts.geom.Geometry)
        Parameters:
        referencePoint - the reference point
        lineString - to find closest distance to point to
        Returns:
        distance found in meters
        Throws:
        PlanItException - thrown if error
      • getClosestPojectedCoordinateOnPolygon

        public org.locationtech.jts.geom.Coordinate getClosestPojectedCoordinateOnPolygon​(org.locationtech.jts.geom.Point referencePoint,
                                                                                          org.locationtech.jts.geom.Polygon polygon)
                                                                                   throws PlanItException
        find the closest location from the reference coordinate to the polygon expressed as a linear location. Here we project onto the polygon, so we find the location with the actual closest distance and create a linear location regardless if this coordinate is part of the polygon as a predefined coordinate at an extreme point. It is therefore more accurate than getClosestExistingCoordinateDistanceInMeters(org.locationtech.jts.geom.Point,org.locationtech.jts.geom.Geometry)
        Parameters:
        referencePoint - the reference point
        polygon - to find closest distance to point to using its exterior ring
        Returns:
        linearLocation found
        Throws:
        PlanItException - thrown if error
      • getClosestProjectedDistanceInMetersToLineString

        public double getClosestProjectedDistanceInMetersToLineString​(org.locationtech.jts.geom.Point referencePoint,
                                                                      org.locationtech.jts.geom.LineString geometry)
                                                               throws PlanItException
        find the closest distance in meters from the point to the geometry.Here we project onto the geometry, so we find the actual closest distance instead of merely finding the closest modelled coordinated within the geometry.
        Parameters:
        referencePoint - the reference point
        geometry - to find closest distance to point to
        Returns:
        distance found in meters
        Throws:
        PlanItException - thrown if error
      • getClosestDistanceInMetersMultiLineString

        public double getClosestDistanceInMetersMultiLineString​(org.locationtech.jts.geom.Point referencePoint,
                                                                org.locationtech.jts.geom.MultiLineString geometry)
                                                         throws PlanItException
        find the closest distance in meters from the point to the geometry.Here we project onto the geometry, so we find the actual closest distance instead of merely finding the closest modelled coordinated within the geometry.
        Parameters:
        referencePoint - the reference point
        geometry - to find closest distance to point to
        Returns:
        distance found in meters
        Throws:
        PlanItException - thrown if error
      • getClosestDistanceInMetersToPolygon

        public double getClosestDistanceInMetersToPolygon​(org.locationtech.jts.geom.Point referencePoint,
                                                          org.locationtech.jts.geom.Polygon geometry)
                                                   throws PlanItException
        find the closest distance in meters from the point to the geometry.Here we project onto the geometry, so we find the actual closest distance instead of merely finding the closest modelled coordinated within the geometry.
        Parameters:
        referencePoint - the reference point
        geometry - to find closest distance to point to
        Returns:
        distance found in meters
        Throws:
        PlanItException - thrown if error
      • getClosestDistanceInMeters

        public double getClosestDistanceInMeters​(org.locationtech.jts.geom.Point referencePoint,
                                                 org.locationtech.jts.geom.Geometry geometry)
                                          throws PlanItException
        find the closest distance in meters from the point to the geometry. Here we project onto the geometry, so we find the actual closest distance instead of merely finding the closest modelled coordinated within the geometry.
        Parameters:
        referencePoint - the reference point
        geometry - to find closest distance to point to
        Returns:
        distance found in meters
        Throws:
        PlanItException - thrown if error
      • getDistanceInMetres

        public double getDistanceInMetres​(org.locationtech.jts.geom.Point startPosition,
                                          org.locationtech.jts.geom.Point endPosition)
                                   throws PlanItException
        Compute the distance in metres between two (JTS) points assuming the positions are provided in the same crs as registered on this class instance
        Parameters:
        startPosition - location of the start point
        endPosition - location of the end point
        Returns:
        distance in metres between the points
        Throws:
        PlanItException - thrown if there is an error
      • getDistanceInMetres

        public double getDistanceInMetres​(org.locationtech.jts.geom.Coordinate startCoordinate,
                                          org.locationtech.jts.geom.Coordinate endCoordinate)
                                   throws PlanItException
        Compute the distance in metres between two (JTS) coordinates assuming the positions are provided in the same crs as registered on this class instance
        Parameters:
        startCoordinate - location of the start point
        endCoordinate - location of the end point
        Returns:
        distance in metres between the points
        Throws:
        PlanItException - thrown if there is an error
      • getDistanceInKilometres

        public double getDistanceInKilometres​(org.locationtech.jts.geom.Point startPosition,
                                              org.locationtech.jts.geom.Point endPosition)
                                       throws PlanItException
        Compute the distance in kilometres between two positions assuming the positions are provided in the same crs as registered on this class instance
        Parameters:
        startPosition - location of the start point
        endPosition - location of the end point
        Returns:
        distance in kilometres between the points
        Throws:
        PlanItException - thrown if there is an error
      • getDistanceInKilometres

        public double getDistanceInKilometres​(Vertex vertex1,
                                              Vertex vertex2)
                                       throws PlanItException
        Compute the distance in kilometres between two vertices assuming the positions are set and based on the same crs as registered on this class instance
        Parameters:
        vertex1 - vertex with location
        vertex2 - vertex with location
        Returns:
        distance in kilometres between the points
        Throws:
        PlanItException - thrown if there is an error
      • createBoundingBox

        public org.locationtech.jts.geom.Envelope createBoundingBox​(double centrePointX,
                                                                    double centrePointY,
                                                                    double lengthMeters)
        create a square bounding box envelope instance based on the passed in reference point and length in meters of each of the legs, with the point residing in the middle
        Parameters:
        centrePointX - x (longitude) coord of centre
        centrePointY - y (latitude) coord of centre
        lengthMeters - in meters
        Returns:
        envelope with appropriate square bounding box
      • createBoundingBox

        public org.locationtech.jts.geom.Envelope createBoundingBox​(org.locationtech.jts.geom.Envelope boundingBox,
                                                                    double lengthMeters)
        create a square bounding box envelope instance based on an existing envelope bounding box and and buffer length in meters resulting in a larger bounding box returned
        Parameters:
        boundingBox - original bounding box
        lengthMeters - buffer length in meters
        Returns:
        envelope with appropriate square bounding box
      • createBoundingBox

        public org.locationtech.jts.geom.Envelope createBoundingBox​(double minX,
                                                                    double minY,
                                                                    double maxX,
                                                                    double maxY,
                                                                    double lengthMeters)
        create a square bounding box envelope instance based on the passed in bounding box coordinates and buffer length in meters resulting in a larger bounding box returned
        Parameters:
        minX - x (longitude) coord of minimum extreme point
        minY - y (latitude) coord of minimum extreme point
        maxX - x (longitude) coord of maximum extreme point
        maxY - y (latitude) coord of maximum extreme point
        lengthMeters - buffer length in meters
        Returns:
        envelope with appropriate square bounding box
      • getDistanceInKilometres

        public double getDistanceInKilometres​(org.locationtech.jts.geom.LineString geometry)
                                       throws PlanItException
        Compute the length of the line string by traversing all nodes and computing the segment by segment distances TODO: find out if a faster way is possible
        Parameters:
        geometry - to extract length from
        Returns:
        length in km
        Throws:
        PlanItException - thrown if error
      • createExtendedLineSegment

        public org.locationtech.jts.geom.LineSegment createExtendedLineSegment​(org.locationtech.jts.geom.LineSegment source,
                                                                               double extensionInMeters,
                                                                               boolean extendStart,
                                                                               boolean extendEnd)
                                                                        throws PlanItException
        extend the given line segment in one or two directions with a given distance in meters. One can also extend on both sides at the same time. Note that this is not correcting for the curvature of the earth in case one uses a geodetic crs.
        Parameters:
        source - original line segment
        extensionInMeters - desired extension in meters
        extendStart - when true extend from start coordinate onwards
        extendEnd - when true extend further from end coordinate onwards
        Returns:
        extended line segment based on the passed in parameters
        Throws:
        PlanItException - thrown if error
      • getCoordinateReferenceSystem

        public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
        collect the crs used by this instance of the utils class
        Returns:
        crs used by instance
      • getAzimuthInDegrees

        public double getAzimuthInDegrees​(org.locationtech.jts.geom.Coordinate coordinate1,
                                          org.locationtech.jts.geom.Coordinate coordinate2)
        Collect the azimuth heading between the two coordinates in decimal degrees between -180 and 180, from location 1 to location 2
        Parameters:
        coordinate1 - first Coordinate
        coordinate2 - second Coordinate
        Returns:
        azimuth in degrees
      • isGeometryLeftOf

        public boolean isGeometryLeftOf​(org.locationtech.jts.geom.Geometry geometry,
                                        org.locationtech.jts.geom.Coordinate coordA,
                                        org.locationtech.jts.geom.Coordinate coordB)
                                 throws PlanItException
        Verify if the provided geometry resides left of the line defined from coordA to coordB. If the geometry is not a point, we first find the closest location on the geometry to coordinate B and use that as a reference instead.
        Parameters:
        geometry - to check
        coordA - of line
        coordB - of line
        Returns:
        true when left, false otherwise
        Throws:
        PlanItException - thrown if error
      • isGeometryNearBoundingBox

        public boolean isGeometryNearBoundingBox​(org.locationtech.jts.geom.Geometry geometry,
                                                 org.locationtech.jts.geom.Envelope boundingBox,
                                                 double maxDistanceMeters)
                                          throws PlanItException
        Verify if any existing coordinate on the passed in geometry is within the maximum provided distance of the also provided bounding box
        Parameters:
        geometry - to check
        boundingBox - to consider
        maxDistanceMeters - to consider
        Returns:
        true when within maximum distance of bounding box, false otherwise
        Throws:
        PlanItException - thrown if error