Class JTSUtility


  • public class JTSUtility
    extends Object
    Author:
    Nicolas Fortin
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double TRIANGLE_INTERSECTION_EPSILON
      Intersection test for topology triangle navigation
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Double dist2D​(org.locationtech.jts.geom.Coordinate c0, org.locationtech.jts.geom.Coordinate c1)
      compute the distance between two points in two dimensions
      static double dist3D​(org.locationtech.jts.geom.Coordinate c0, org.locationtech.jts.geom.Coordinate c1)
      compute the distance between two points of dimension three
      static boolean dotInTri​(org.locationtech.jts.geom.Coordinate p, org.locationtech.jts.geom.Coordinate a, org.locationtech.jts.geom.Coordinate b, org.locationtech.jts.geom.Coordinate c)  
      static boolean dotInTri​(org.locationtech.jts.geom.Coordinate p, org.locationtech.jts.geom.Coordinate a, org.locationtech.jts.geom.Coordinate b, org.locationtech.jts.geom.Coordinate c, AtomicReference<Double> error)
      Fast dot in triangle test http://www.blackpawn.com/texts/pointinpoly/default.html
      static double[] getLinearFunction​(org.locationtech.jts.geom.Coordinate p1, org.locationtech.jts.geom.Coordinate p2)
      Compute a and b linear function of the line p1 p2
      static double[] getLinearRegressionPolyline​(List<org.locationtech.jts.geom.Coordinate> xzList)
      NFS 31-133 P.69 Annex E
      static double[] getMeanPlaneCoefficients​(org.locationtech.jts.geom.Coordinate[] profile)
      calculate the mean plane y = A.x + B for a sequence of terrain points projected on the unfolded propagation plane ; using (x,y) coordinates as in section VI.2.2.c of the JRC-2012 reference report.
      static org.locationtech.jts.geom.Coordinate getNearestPoint​(org.locationtech.jts.geom.Coordinate from, org.locationtech.jts.geom.LineString to)  
      static org.locationtech.jts.geom.Coordinate getNearestPoint​(org.locationtech.jts.geom.LineSegment segment, org.locationtech.jts.geom.Coordinate p)  
      static List<org.locationtech.jts.geom.Coordinate> getNewCoordinateSystem​(List<org.locationtech.jts.geom.Coordinate> listPoints)
      ChangeCoordinateSystem, use original coordinate in 3D to change into a new markland in 2D with new x' computed by algorithm and y' is original height of point.
      static List<org.locationtech.jts.geom.Coordinate> getNewCoordinateSystem​(List<org.locationtech.jts.geom.Coordinate> listPoints, double tolerance)
      ChangeCoordinateSystem, use original coordinate in 3D to change into a new markland in 2D with new x' computed by algorithm and y' is original height of point.
      static org.locationtech.jts.geom.Coordinate getOldCoordinateSystem​(org.locationtech.jts.geom.Coordinate Point, double angle)
      ChangeCoordinateSystem, use original coordinate in 3D to change into a new markland in 2D with new x' computed by algorithm and y' is original height of point.
      static List<org.locationtech.jts.geom.Coordinate> getOldCoordinateSystemList​(List<org.locationtech.jts.geom.Coordinate> listPoints, double angle)
      ChangeCoordinateSystem, use original coordinate in 3D to change into a new markland in 2D with new x' computed by algorithm and y' is original height of point.
      static double getSlope​(org.locationtech.jts.geom.Coordinate p0, org.locationtech.jts.geom.Coordinate p1)  
      static org.locationtech.jts.math.Vector3D getTriangleNormal​(org.locationtech.jts.geom.Coordinate p1, org.locationtech.jts.geom.Coordinate p2, org.locationtech.jts.geom.Coordinate p3)  
      static List<org.locationtech.jts.geom.Coordinate> getXAscendingHullPoints​(org.locationtech.jts.geom.Coordinate[] coordinates)  
      static org.locationtech.jts.geom.Coordinate makePointImage​(double a, double b, org.locationtech.jts.geom.Coordinate point)
      Make image (like line y=ax+b would be a mirror) of point
      static org.locationtech.jts.geom.Coordinate makeProjectedPoint​(double a, double b, org.locationtech.jts.geom.Coordinate point)
      Project point on y=ax+b plane
    • Field Detail

      • TRIANGLE_INTERSECTION_EPSILON

        public static final double TRIANGLE_INTERSECTION_EPSILON
        Intersection test for topology triangle navigation
        See Also:
        Constant Field Values
    • Method Detail

      • getLinearFunction

        public static double[] getLinearFunction​(org.locationtech.jts.geom.Coordinate p1,
                                                 org.locationtech.jts.geom.Coordinate p2)
        Compute a and b linear function of the line p1 p2
        Parameters:
        p1 - p1
        p2 - p2 with p2.x != p1.x
        Returns:
        [a,b] linear function parameters.
      • getNearestPoint

        public static org.locationtech.jts.geom.Coordinate getNearestPoint​(org.locationtech.jts.geom.LineSegment segment,
                                                                           org.locationtech.jts.geom.Coordinate p)
        Parameters:
        segment -
        p -
        Returns:
      • getNearestPoint

        public static org.locationtech.jts.geom.Coordinate getNearestPoint​(org.locationtech.jts.geom.Coordinate from,
                                                                           org.locationtech.jts.geom.LineString to)
        Parameters:
        from -
        to -
        Returns:
      • getLinearRegressionPolyline

        public static double[] getLinearRegressionPolyline​(List<org.locationtech.jts.geom.Coordinate> xzList)
        NFS 31-133 P.69 Annex E
        Parameters:
        xzList - Line coordinates in the same plan of the line formed by the first and the last point. X must be incremental.
        Returns:
        [a,b] Linear function parameters produced by least square regression of provided points.
      • makeProjectedPoint

        public static org.locationtech.jts.geom.Coordinate makeProjectedPoint​(double a,
                                                                              double b,
                                                                              org.locationtech.jts.geom.Coordinate point)
        Project point on y=ax+b plane
        Parameters:
        a - a plane parameter
        b - b plane parameter
        point - Point to project
        Returns:
        Projected point
      • makePointImage

        public static org.locationtech.jts.geom.Coordinate makePointImage​(double a,
                                                                          double b,
                                                                          org.locationtech.jts.geom.Coordinate point)
        Make image (like line y=ax+b would be a mirror) of point
        Parameters:
        a - a linear parameter
        b - b linear parameter
        point - Point to project
        Returns:
        Mirrored point position
      • dotInTri

        public static boolean dotInTri​(org.locationtech.jts.geom.Coordinate p,
                                       org.locationtech.jts.geom.Coordinate a,
                                       org.locationtech.jts.geom.Coordinate b,
                                       org.locationtech.jts.geom.Coordinate c)
      • getTriangleNormal

        public static org.locationtech.jts.math.Vector3D getTriangleNormal​(org.locationtech.jts.geom.Coordinate p1,
                                                                           org.locationtech.jts.geom.Coordinate p2,
                                                                           org.locationtech.jts.geom.Coordinate p3)
      • dotInTri

        public static boolean dotInTri​(org.locationtech.jts.geom.Coordinate p,
                                       org.locationtech.jts.geom.Coordinate a,
                                       org.locationtech.jts.geom.Coordinate b,
                                       org.locationtech.jts.geom.Coordinate c,
                                       AtomicReference<Double> error)
        Fast dot in triangle test http://www.blackpawn.com/texts/pointinpoly/default.html
        Parameters:
        p - coordinate of the point
        a - coordinate of the A vertex of triangle
        b - coordinate of the B vertex of triangle
        c - coordinate of the C vertex of triangle
        Returns:
        True if dot is in triangle
      • getNewCoordinateSystem

        public static List<org.locationtech.jts.geom.Coordinate> getNewCoordinateSystem​(List<org.locationtech.jts.geom.Coordinate> listPoints)
        ChangeCoordinateSystem, use original coordinate in 3D to change into a new markland in 2D with new x' computed by algorithm and y' is original height of point.
        Parameters:
        listPoints - X Y Z points, all should be on the same plane as first and last points.
        Returns:
        X Z projected points
      • getNewCoordinateSystem

        public static List<org.locationtech.jts.geom.Coordinate> getNewCoordinateSystem​(List<org.locationtech.jts.geom.Coordinate> listPoints,
                                                                                        double tolerance)
        ChangeCoordinateSystem, use original coordinate in 3D to change into a new markland in 2D with new x' computed by algorithm and y' is original height of point.
        Parameters:
        listPoints - X Y Z points, all should be on the same plane as first and last points.
        tolerance - Simplify the point list by not adding points where the distance from the line segments formed from the previous and the next point is inferior to this tolerance (remove intermediate collinear points)
        Returns:
        X Z projected points
      • getOldCoordinateSystemList

        public static List<org.locationtech.jts.geom.Coordinate> getOldCoordinateSystemList​(List<org.locationtech.jts.geom.Coordinate> listPoints,
                                                                                            double angle)
        ChangeCoordinateSystem, use original coordinate in 3D to change into a new markland in 2D with new x' computed by algorithm and y' is original height of point. Attention this function can just be used when the points in the same plane. "http://en.wikipedia.org/wiki/Rotation_matrix"
        Parameters:
        listPoints - X Y Z points, all should be on the same plane as first and last points.
        Returns:
        X Z projected points
      • getOldCoordinateSystem

        public static org.locationtech.jts.geom.Coordinate getOldCoordinateSystem​(org.locationtech.jts.geom.Coordinate Point,
                                                                                  double angle)
        ChangeCoordinateSystem, use original coordinate in 3D to change into a new markland in 2D with new x' computed by algorithm and y' is original height of point. Attention this function can just be used when the points in the same plane. "http://en.wikipedia.org/wiki/Rotation_matrix"
        Parameters:
        Point - X Y Z points, all should be on the same plane as first and last points.
        Returns:
        X Z projected points
      • getMeanPlaneCoefficients

        public static double[] getMeanPlaneCoefficients​(org.locationtech.jts.geom.Coordinate[] profile)
        calculate the mean plane y = A.x + B for a sequence of terrain points projected on the unfolded propagation plane ; using (x,y) coordinates as in section VI.2.2.c of the JRC-2012 reference report.
        Parameters:
        profile - u v coordinates @see {getNewCoordinateSystem(List)}
        Returns:
        Coefficient A and B
      • getXAscendingHullPoints

        public static List<org.locationtech.jts.geom.Coordinate> getXAscendingHullPoints​(org.locationtech.jts.geom.Coordinate[] coordinates)
        Parameters:
        coordinates - Coordinates
        Returns:
        Parts of the clock-wise ConvexHull where x value are increasing from the minimum X value
      • dist3D

        public static double dist3D​(org.locationtech.jts.geom.Coordinate c0,
                                    org.locationtech.jts.geom.Coordinate c1)
        compute the distance between two points of dimension three
        Parameters:
        c0 -
        c1 -
        Returns:
        the distance in double
      • dist2D

        public static Double dist2D​(org.locationtech.jts.geom.Coordinate c0,
                                    org.locationtech.jts.geom.Coordinate c1)
        compute the distance between two points in two dimensions
        Parameters:
        c0 -
        c1 -
        Returns:
        the distance in double
      • getSlope

        public static double getSlope​(org.locationtech.jts.geom.Coordinate p0,
                                      org.locationtech.jts.geom.Coordinate p1)
        Parameters:
        p0 -
        p1 -
        Returns: