Class Rectangle2D


  • public class Rectangle2D
    extends java.lang.Object
    2D rectangle implementation containing geo spatial logic.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected byte[] bbox  
      protected int maxX  
      protected int maxY  
      protected int minX  
      protected int minY  
      private byte[] west  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Rectangle2D​(double minLat, double maxLat, double minLon, double maxLon)  
      protected Rectangle2D​(int minX, int maxX, int minY, int maxY)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static boolean bboxContainsPoint​(int x, int y, int minX, int maxX, int minY, int maxY)
      static utility method to check if a bounding box contains a point
      private static boolean bboxContainsTriangle​(int ax, int ay, int bx, int by, int cx, int cy, int minX, int maxX, int minY, int maxY)
      static utility method to check if a bounding box contains a triangle
      private static boolean boxesAreDisjoint​(int aMinX, int aMaxX, int aMinY, int aMaxY, int bMinX, int bMaxX, int bMinY, int bMaxY)
      utility method to check if two boxes are disjoint
      private static PointValues.Relation compareBBoxToRangeBBox​(byte[] bbox, int minXOffset, int minYOffset, byte[] minTriangle, int maxXOffset, int maxYOffset, byte[] maxTriangle)
      static utility method to compare a bbox with a range of triangles (just the bbox of the triangle collection)
      boolean containsTriangle​(int ax, int ay, int bx, int by, int cx, int cy)
      Checks if the rectangle contains the provided triangle
      static Rectangle2D create​(Rectangle rectangle)
      Builds a Rectangle2D from rectangle
      boolean crossesDateline()  
      private static boolean disjoint​(byte[] bbox, int minXOffset, int minYOffset, byte[] minTriangle, int maxXOffset, int maxYOffset, byte[] maxTriangle)
      static utility method to check a bbox is disjoint with a range of triangles
      private static boolean edgeIntersectsBox​(int ax, int ay, int bx, int by, int minX, int maxX, int minY, int maxY)
      returns true if the edge (defined by (ax, ay) (bx, by)) intersects the query
      private boolean edgeIntersectsQuery​(int ax, int ay, int bx, int by)
      returns true if the edge (defined by (ax, ay) (bx, by)) intersects the query
      private static void encode​(int minX, int maxX, int minY, int maxY, byte[] b)
      encodes a bounding box into the provided byte array
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      private static PointValues.Relation intersectBBoxWithRangeBBox​(byte[] bbox, int minXOffset, int minYOffset, byte[] minTriangle, int maxXOffset, int maxYOffset, byte[] maxTriangle)
      static utility method to compare a bbox with a range of triangles (just the bbox of the triangle collection) for intersection
      PointValues.Relation intersectRangeBBox​(int minXOffset, int minYOffset, byte[] minTriangle, int maxXOffset, int maxYOffset, byte[] maxTriangle)
      intersects this to a provided range bounding box
      boolean intersectsTriangle​(int aX, int aY, int bX, int bY, int cX, int cY)
      Checks if the rectangle intersects the provided triangle
      boolean queryContainsPoint​(int x, int y)
      Checks if the rectangle contains the provided point
      private boolean queryIntersects​(int ax, int ay, int bx, int by, int cx, int cy)
      returns true if the query intersects the provided triangle (in encoded space)
      PointValues.Relation relateRangeBBox​(int minXOffset, int minYOffset, byte[] minTriangle, int maxXOffset, int maxYOffset, byte[] maxTriangle)
      compare this to a provided range bounding box
      Component2D.WithinRelation withinTriangle​(int ax, int ay, boolean ab, int bx, int by, boolean bc, int cx, int cy, boolean ca)
      Returns the Within relation to the provided triangle
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • bbox

        protected final byte[] bbox
      • west

        private final byte[] west
      • minX

        protected final int minX
      • maxX

        protected final int maxX
      • minY

        protected final int minY
      • maxY

        protected final int maxY
    • Constructor Detail

      • Rectangle2D

        protected Rectangle2D​(double minLat,
                              double maxLat,
                              double minLon,
                              double maxLon)
      • Rectangle2D

        protected Rectangle2D​(int minX,
                              int maxX,
                              int minY,
                              int maxY)
    • Method Detail

      • create

        public static Rectangle2D create​(Rectangle rectangle)
        Builds a Rectangle2D from rectangle
      • crossesDateline

        public boolean crossesDateline()
      • queryContainsPoint

        public boolean queryContainsPoint​(int x,
                                          int y)
        Checks if the rectangle contains the provided point
      • relateRangeBBox

        public PointValues.Relation relateRangeBBox​(int minXOffset,
                                                    int minYOffset,
                                                    byte[] minTriangle,
                                                    int maxXOffset,
                                                    int maxYOffset,
                                                    byte[] maxTriangle)
        compare this to a provided range bounding box
      • intersectRangeBBox

        public PointValues.Relation intersectRangeBBox​(int minXOffset,
                                                       int minYOffset,
                                                       byte[] minTriangle,
                                                       int maxXOffset,
                                                       int maxYOffset,
                                                       byte[] maxTriangle)
        intersects this to a provided range bounding box
      • intersectsTriangle

        public boolean intersectsTriangle​(int aX,
                                          int aY,
                                          int bX,
                                          int bY,
                                          int cX,
                                          int cY)
        Checks if the rectangle intersects the provided triangle
      • withinTriangle

        public Component2D.WithinRelation withinTriangle​(int ax,
                                                         int ay,
                                                         boolean ab,
                                                         int bx,
                                                         int by,
                                                         boolean bc,
                                                         int cx,
                                                         int cy,
                                                         boolean ca)
        Returns the Within relation to the provided triangle
      • containsTriangle

        public boolean containsTriangle​(int ax,
                                        int ay,
                                        int bx,
                                        int by,
                                        int cx,
                                        int cy)
        Checks if the rectangle contains the provided triangle
      • compareBBoxToRangeBBox

        private static PointValues.Relation compareBBoxToRangeBBox​(byte[] bbox,
                                                                   int minXOffset,
                                                                   int minYOffset,
                                                                   byte[] minTriangle,
                                                                   int maxXOffset,
                                                                   int maxYOffset,
                                                                   byte[] maxTriangle)
        static utility method to compare a bbox with a range of triangles (just the bbox of the triangle collection)
      • intersectBBoxWithRangeBBox

        private static PointValues.Relation intersectBBoxWithRangeBBox​(byte[] bbox,
                                                                       int minXOffset,
                                                                       int minYOffset,
                                                                       byte[] minTriangle,
                                                                       int maxXOffset,
                                                                       int maxYOffset,
                                                                       byte[] maxTriangle)
        static utility method to compare a bbox with a range of triangles (just the bbox of the triangle collection) for intersection
      • disjoint

        private static boolean disjoint​(byte[] bbox,
                                        int minXOffset,
                                        int minYOffset,
                                        byte[] minTriangle,
                                        int maxXOffset,
                                        int maxYOffset,
                                        byte[] maxTriangle)
        static utility method to check a bbox is disjoint with a range of triangles
      • encode

        private static void encode​(int minX,
                                   int maxX,
                                   int minY,
                                   int maxY,
                                   byte[] b)
        encodes a bounding box into the provided byte array
      • queryIntersects

        private boolean queryIntersects​(int ax,
                                        int ay,
                                        int bx,
                                        int by,
                                        int cx,
                                        int cy)
        returns true if the query intersects the provided triangle (in encoded space)
      • edgeIntersectsQuery

        private boolean edgeIntersectsQuery​(int ax,
                                            int ay,
                                            int bx,
                                            int by)
        returns true if the edge (defined by (ax, ay) (bx, by)) intersects the query
      • bboxContainsPoint

        private static boolean bboxContainsPoint​(int x,
                                                 int y,
                                                 int minX,
                                                 int maxX,
                                                 int minY,
                                                 int maxY)
        static utility method to check if a bounding box contains a point
      • bboxContainsTriangle

        private static boolean bboxContainsTriangle​(int ax,
                                                    int ay,
                                                    int bx,
                                                    int by,
                                                    int cx,
                                                    int cy,
                                                    int minX,
                                                    int maxX,
                                                    int minY,
                                                    int maxY)
        static utility method to check if a bounding box contains a triangle
      • edgeIntersectsBox

        private static boolean edgeIntersectsBox​(int ax,
                                                 int ay,
                                                 int bx,
                                                 int by,
                                                 int minX,
                                                 int maxX,
                                                 int minY,
                                                 int maxY)
        returns true if the edge (defined by (ax, ay) (bx, by)) intersects the query
      • boxesAreDisjoint

        private static boolean boxesAreDisjoint​(int aMinX,
                                                int aMaxX,
                                                int aMinY,
                                                int aMaxY,
                                                int bMinX,
                                                int bMaxX,
                                                int bMinY,
                                                int bMaxY)
        utility method to check if two boxes are disjoint
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object