Class GeoComputation



  • public class GeoComputation
    extends java.lang.Object
    GeoComputation class
    • Constructor Detail

      • GeoComputation

        public GeoComputation​()
    • Method Detail

      • isClockwise

        public static boolean isClockwise​(java.util.List<? extends PointD> pointList)
        Determine if a point array is clockwise
        Parameters:
        pointList - point list
        Returns:
        boolean
      • isClockwise

        public static boolean isClockwise​(PointD[] points)
        Determine if a point array is clockwise
        Parameters:
        points - point array
        Returns:
        boolean
      • pointInPolygon

        public static boolean pointInPolygon​(java.util.List<? extends PointD> poly,
                                             PointD aPoint)
        Determine if a point is in a polygon
        Parameters:
        poly - Polygon border points
        aPoint - The point
        Returns:
        If the point is in the polygon
      • pointInPolygon

        public static boolean pointInPolygon​(PolygonShape aPolygon,
                                             PointD aPoint)
        Determine if a point is in a polygon
        Parameters:
        aPolygon - The polygon
        aPoint - The point
        Returns:
        Boolean
      • pointInPolygon

        public static boolean pointInPolygon​(PolygonShape aPolygon,
                                             double x,
                                             double y)
        Determine if a point is in a polygon
        Parameters:
        aPolygon - The polygon
        x - X
        y - Y
        Returns:
        Boolean
      • pointInPolygon

        public static boolean pointInPolygon​(Polygon aPolygon,
                                             PointD aPoint)
        Determine if a point is in a polygon
        Parameters:
        aPolygon - The polygon
        aPoint - The point
        Returns:
        Boolean
      • pointInPolygons

        public static boolean pointInPolygons​(java.util.List<PolygonShape> polygons,
                                              PointD aPoint)
        Determine if a point located in polygons
        Parameters:
        polygons - The polygons
        aPoint - The point
        Returns:
        Boolean
      • pointInPolygonLayer

        public static boolean pointInPolygonLayer​(VectorLayer aLayer,
                                                  PointD aPoint,
                                                  boolean onlySel)
        Determine if a point loacted in a polygon layer
        Parameters:
        aLayer - The polygon layer
        aPoint - The point
        onlySel - If check only selected shapes
        Returns:
        Inside or outside
      • dis_PointToLine

        public static double dis_PointToLine​(PointD point,
                                             PointD pt1,
                                             PointD pt2)
        Calculate the distance between point and a line segment
        Parameters:
        point - The point
        pt1 - End point of the line segment
        pt2 - End point of the line segment
        Returns:
        Distance
      • distance

        public static double distance​(PointD pt1,
                                      PointD pt2)
        Get distance between two points
        Parameters:
        pt1 - Point one
        pt2 - Point two
        Returns:
        Distance
      • selectPolylineShape

        public static java.lang.Object selectPolylineShape​(PointD sp,
                                                           PolylineShape aPLS,
                                                           double buffer)
        Select polyline shape by a point
        Parameters:
        sp - The point
        aPLS - The polyline shape
        buffer - Buffer
        Returns:
        Is the polyline shape selected
      • selectPolyline

        public static java.lang.Object selectPolyline​(PointD sp,
                                                      java.util.List<PointD> points,
                                                      double buffer)
        Select polyline shape by a point
        Parameters:
        sp - The point
        points - The point list
        buffer - Buffer
        Returns:
        Is the polyline shape selected
      • getArea

        public static double getArea​(java.util.List<java.lang.Number> x,
                                     java.util.List<java.lang.Number> y,
                                     boolean isLonLat)
        Get polygon area
        Parameters:
        x - X coordinates
        y - Y coordinates
        isLonLat - If is on earth surface (lon/lat)
        Returns:
        Area
      • getArea

        public static double getArea​(java.util.List<? extends PointD> points,
                                     boolean isLonLat)
        Get polygon area on earth surface
        Parameters:
        points - point list
        isLonLat - if is lon/lat
        Returns:
        area
      • getArea

        public static double getArea​(java.util.List<? extends PointD> points)
        Get polygon area on earth surface
        Parameters:
        points - point list
        Returns:
        area
      • calArea

        public static double calArea​(java.util.List<PointD> points)
        Get polygon area on earth surface
        Parameters:
        points - point list
        Returns:
        area
      • sphericalPolygonArea

        public static double sphericalPolygonArea​(java.util.List<? extends PointD> points)
        Compute the Area of a Spherical Polygon
        Parameters:
        points - lon/lat point list
        Returns:
        area
      • sphericalPolygonArea

        public static double sphericalPolygonArea​(java.util.List<? extends PointD> points,
                                                  double r)
        Compute the Area of a Spherical Polygon
        Parameters:
        points - lon/lat point list
        r - spherical radius
        Returns:
        area
      • haversine

        public static double haversine​(double x)
        Haversine function : hav(x) = (1-cos(x))/2
        Parameters:
        x -
        Returns:
        Returns the value of Haversine function
      • sphericalPolygonArea

        public static double sphericalPolygonArea​(double[] lat,
                                                  double[] lon,
                                                  double r)
        Compute the Area of a Spherical Polygon
        Parameters:
        lat - the latitudes of all vertices(in radian)
        lon - the longitudes of all vertices(in radian)
        r - spherical radius
        Returns:
        Returns the area of a spherical polygon
      • getDistance

        public static double getDistance​(java.util.List<? extends PointD> points,
                                         boolean isLonLat)
        Get distance
        Parameters:
        points - Point list
        isLonLat - If is lon/lat
        Returns:
        Distance
      • getDistance

        public static double getDistance​(java.util.List<java.lang.Number> xx,
                                         java.util.List<java.lang.Number> yy,
                                         boolean isLonLat)
        Get distance
        Parameters:
        xx - X coordinates
        yy - Y coordinates
        isLonLat - If is lon/lat
        Returns:
        Distance
      • clipLayer

        public static java.util.List<Shape> clipLayer​(VectorLayer subjectLayer,
                                                      java.lang.Object clipObject)
        Clip a vector layer by a polygon shape
        Parameters:
        subjectLayer - Subject vector layer
        clipObject - Cipping object
        Returns:
        Result clipped shapes
      • clipLayer

        public static VectorLayer clipLayer​(VectorLayer subjectLayer,
                                            java.util.List<java.lang.Object> clipObjects)
        Clip a vector layer by polygon shape list
        Parameters:
        subjectLayer - Subject vector layer
        clipObjects - Cipping object list
        Returns:
        Result clipped layer
      • clipShape

        public static Shape clipShape​(Shape aShape,
                                      java.lang.Object clipObj)
        Clip a shape
        Parameters:
        aShape - The shape
        clipObj - Clipping object
        Returns:
        Clipped shape
      • clipPointShape

        public static PointShape clipPointShape​(PointShape aPS,
                                                java.lang.Object clipObj)
        Clip point shape with a clipping object
        Parameters:
        aPS - The point shape
        clipObj - Clipping object
        Returns:
        Clipped point shape
      • clipPolylineShape

        public static PolylineShape clipPolylineShape​(PolylineShape aPLS,
                                                      java.lang.Object clipObj)
        Clip polyline shape with a clipping object
        Parameters:
        aPLS - The polyline shape
        clipObj - Clipping object
        Returns:
        Clipped polyline shape
      • clipPolylineShape_Lon

        public static PolylineShape clipPolylineShape_Lon​(PolylineShape aPLS,
                                                          double lon)
        Clip polyline shape with a longitude
        Parameters:
        aPLS - Polyline shape
        lon - Longitude
        Returns:
        Clipped polyline shape
      • clipPolylineShape_Lat

        public static PolylineShape clipPolylineShape_Lat​(PolylineShape aPLS,
                                                          double lat)
        Clip polyline shape with a longitude
        Parameters:
        aPLS - Polyline shape
        lat - The latitude
        Returns:
        Clipped polyline shape
      • clipPolylineShape_Lat

        public static PolylineShape clipPolylineShape_Lat​(PolylineShape aPLS,
                                                          double lat,
                                                          boolean isTop)
        Clip polyline shape with a longitude
        Parameters:
        aPLS - Polyline shape
        lat - Latitude
        isTop - If is top
        Returns:
        Clipped polyline shape
      • clipPolygonShape

        public static PolygonShape clipPolygonShape​(PolygonShape aPGS,
                                                    java.lang.Object clipObj)
        Clip polygon shape with a clipping object
        Parameters:
        aPGS - Polygon shape
        clipObj - Clipping object
        Returns:
        Clipped polygon shape
      • clipPolygonShape_Lon

        public static PolygonShape clipPolygonShape_Lon​(PolygonShape aPGS,
                                                        double lon)
        Clip polygon shape with a longitude
        Parameters:
        aPGS - Polygon shape
        lon - Longitude
        Returns:
        Clipped polygon shape
      • clipPolygonShape_Lat

        public static PolygonShape clipPolygonShape_Lat​(PolygonShape aPGS,
                                                        double lat)
        Clip polygon shape with a latitude
        Parameters:
        aPGS - Polygon shape
        lat - Latitude
        Returns:
        Clipped polygon shape
      • clipPolygonShape_Lat

        public static PolygonShape clipPolygonShape_Lat​(PolygonShape aPGS,
                                                        double lat,
                                                        boolean isTop)
        Clip polygon shape with a latitude
        Parameters:
        aPGS - Polygon shape
        lat - Latitude
        isTop - If is top
        Returns:
        Clipped polygon shape
      • crossProduct

        public static double crossProduct​(PointD p1,
                                          PointD p2,
                                          PointD p3)
        Finds the cross product of the 2 vectors created by the 3 vertices. Vector 1 = v1 -> v2, Vector 2 = v2 -> v3 The vectors make a "right turn" if the sign of the cross product is negative. The vectors make a "left turn" if the sign of the cross product is positive. The vectors are colinear (on the same line) if the cross product is zero.
        Parameters:
        p1 - Point 1
        p2 - Point 2
        p3 - Piont 3
        Returns:
        Cross product of the two vectors
      • pointProduct

        public static double pointProduct​(PointD p1,
                                          PointD p2,
                                          PointD p3)
        Finds the point product of the 2 vectors created by the 3 vertices.
        Parameters:
        p1 - Point 1
        p2 - Point 2
        p3 - Piont 3
        Returns:
        Cross product of the two vectors
      • getGridLabels

        public static java.util.List<GridLabel> getGridLabels​(Polyline inPolyLine,
                                                              Extent clipExtent,
                                                              boolean isVertical)
        Get grid labels of a polyline
        Parameters:
        inPolyLine - Polyline
        clipExtent - Clipping object
        isVertical - If is vertical
        Returns:
        Clip points
      • getGridLabels_StraightLine

        public static java.util.List<GridLabel> getGridLabels_StraightLine​(Polyline inPolyLine,
                                                                           Extent clipExtent,
                                                                           boolean isVertical)
        Get grid labels of a straight line
        Parameters:
        inPolyLine - Polyline
        clipExtent - Clipping object
        isVertical - If is vertical
        Returns:
        Clip points