@Test public void testBboxInPolygon() { Polygon p = FastPointInPolygonTest.createPolygon(); FastBboxInPolygon bip = new FastBboxInPolygon(p); assertEquals(bip.test(new OSHDBBoundingBox(-0.6,-0.1,-0.4,0.1)), true); assertEquals(bip.test(new OSHDBBoundingBox(-1.5,-0.1,-0.4,0.1)), false); assertEquals(bip.test(new OSHDBBoundingBox(-0.6,-0.1,1.4,0.1)), false); assertEquals(bip.test(new OSHDBBoundingBox(-0.6,-1.1,-0.4,0.1)), false); assertEquals(bip.test(new OSHDBBoundingBox(-0.6,-0.1,-0.4,1.1)), false); assertEquals(bip.test(new OSHDBBoundingBox(0.4,-0.1,0.6,0.1)), false); assertEquals(bip.test(new OSHDBBoundingBox(0.4,-0.9,0.6,-0.8)), true); assertEquals(bip.test(new OSHDBBoundingBox(0.4,0.8,0.6,0.9)), true); assertEquals(bip.test(new OSHDBBoundingBox(0.4,-0.9,0.6,0.9)), false); assertEquals(bip.test(new OSHDBBoundingBox(1.4,-0.1,1.6,0.1)), false); assertEquals(bip.test(new OSHDBBoundingBox(-11,-10,10,10)), false); }
@Override public boolean test(OSHDBBoundingBox boundingBox) { GeometryFactory gf = new GeometryFactory(); Point p1 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMinLat())); if (crossingNumber(p1, true) % 2 == 0) { return false; } Point p2 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMinLat())); Point p3 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMaxLat())); Point p4 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMaxLat())); if (crossingNumber(p1, true) != crossingNumber(p2, true) || crossingNumber(p3, true) != crossingNumber(p4, true) || crossingNumber(p2, false) != crossingNumber(p3, false) || crossingNumber(p4, false) != crossingNumber(p1, false)) { return false; } for (Envelope innerBBox : innerBboxes) { if (boundingBox.getMinLat() <= innerBBox.getMinY() && boundingBox.getMaxLat() >= innerBBox.getMaxY() && boundingBox.getMinLon() <= innerBBox.getMinX() && boundingBox.getMaxLon() >= innerBBox.getMaxX()) { return false; } } return true; }
FastBboxInPolygon extends FastInPolygon implements Predicate<OSHDBBoundingBox>,
    Serializable { @Override public boolean test(OSHDBBoundingBox boundingBox) { GeometryFactory gf = new GeometryFactory(); Point p1 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMinLat())); if (crossingNumber(p1, true) % 2 == 0) { return false; } Point p2 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMinLat())); Point p3 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMaxLat())); Point p4 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMaxLat())); if (crossingNumber(p1, true) != crossingNumber(p2, true) || crossingNumber(p3, true) != crossingNumber(p4, true) || crossingNumber(p2, false) != crossingNumber(p3, false) || crossingNumber(p4, false) != crossingNumber(p1, false)) { return false; } for (Envelope innerBBox : innerBboxes) { if (boundingBox.getMinLat() <= innerBBox.getMinY() && boundingBox.getMaxLat() >= innerBBox.getMaxY() && boundingBox.getMinLon() <= innerBBox.getMinX() && boundingBox.getMaxLon() >= innerBBox.getMaxX()) { return false; } } return true; } }
FastBboxInPolygon extends FastInPolygon implements Predicate<OSHDBBoundingBox>,
    Serializable { @Override public boolean test(OSHDBBoundingBox boundingBox) { GeometryFactory gf = new GeometryFactory(); Point p1 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMinLat())); if (crossingNumber(p1, true) % 2 == 0) { return false; } Point p2 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMinLat())); Point p3 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMaxLat())); Point p4 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMaxLat())); if (crossingNumber(p1, true) != crossingNumber(p2, true) || crossingNumber(p3, true) != crossingNumber(p4, true) || crossingNumber(p2, false) != crossingNumber(p3, false) || crossingNumber(p4, false) != crossingNumber(p1, false)) { return false; } for (Envelope innerBBox : innerBboxes) { if (boundingBox.getMinLat() <= innerBBox.getMinY() && boundingBox.getMaxLat() >= innerBBox.getMaxY() && boundingBox.getMinLon() <= innerBBox.getMinX() && boundingBox.getMaxLon() >= innerBBox.getMaxX()) { return false; } } return true; } <P extends Geometry & Polygonal> FastBboxInPolygon(P geom); }
FastBboxInPolygon extends FastInPolygon implements Predicate<OSHDBBoundingBox>,
    Serializable { @Override public boolean test(OSHDBBoundingBox boundingBox) { GeometryFactory gf = new GeometryFactory(); Point p1 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMinLat())); if (crossingNumber(p1, true) % 2 == 0) { return false; } Point p2 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMinLat())); Point p3 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMaxLat())); Point p4 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMaxLat())); if (crossingNumber(p1, true) != crossingNumber(p2, true) || crossingNumber(p3, true) != crossingNumber(p4, true) || crossingNumber(p2, false) != crossingNumber(p3, false) || crossingNumber(p4, false) != crossingNumber(p1, false)) { return false; } for (Envelope innerBBox : innerBboxes) { if (boundingBox.getMinLat() <= innerBBox.getMinY() && boundingBox.getMaxLat() >= innerBBox.getMaxY() && boundingBox.getMinLon() <= innerBBox.getMinX() && boundingBox.getMaxLon() >= innerBBox.getMaxX()) { return false; } } return true; } <P extends Geometry & Polygonal> FastBboxInPolygon(P geom); @Override boolean test(OSHDBBoundingBox boundingBox); }
FastBboxInPolygon extends FastInPolygon implements Predicate<OSHDBBoundingBox>,
    Serializable { @Override public boolean test(OSHDBBoundingBox boundingBox) { GeometryFactory gf = new GeometryFactory(); Point p1 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMinLat())); if (crossingNumber(p1, true) % 2 == 0) { return false; } Point p2 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMinLat())); Point p3 = gf.createPoint(new Coordinate(boundingBox.getMaxLon(), boundingBox.getMaxLat())); Point p4 = gf.createPoint(new Coordinate(boundingBox.getMinLon(), boundingBox.getMaxLat())); if (crossingNumber(p1, true) != crossingNumber(p2, true) || crossingNumber(p3, true) != crossingNumber(p4, true) || crossingNumber(p2, false) != crossingNumber(p3, false) || crossingNumber(p4, false) != crossingNumber(p1, false)) { return false; } for (Envelope innerBBox : innerBboxes) { if (boundingBox.getMinLat() <= innerBBox.getMinY() && boundingBox.getMaxLat() >= innerBBox.getMaxY() && boundingBox.getMinLon() <= innerBBox.getMinX() && boundingBox.getMaxLon() >= innerBBox.getMaxX()) { return false; } } return true; } <P extends Geometry & Polygonal> FastBboxInPolygon(P geom); @Override boolean test(OSHDBBoundingBox boundingBox);  }