@Test public void testOverlap() { OSHDBBoundingBox a = new OSHDBBoundingBox(0.1, 89.1, 0.9, 89.9); OSHDBBoundingBox b = new OSHDBBoundingBox(0.0, 89.0, 1.0, 90.0); OSHDBBoundingBox.OVERLAP expResult = OSHDBBoundingBox.OVERLAP.A_COMPLETE_IN_B; OSHDBBoundingBox.OVERLAP result = OSHDBBoundingBox.overlap(a, b); assertEquals(expResult, result); }
public static OVERLAP overlap(OSHDBBoundingBox a, OSHDBBoundingBox b) { if (b.minLon >= a.maxLon || b.maxLon <= a.minLon || b.minLat >= a.maxLat || b.maxLat <= a.minLat) { return OVERLAP.NONE; } if (a.minLon >= b.minLon && a.maxLon <= b.maxLon && a.minLat >= b.minLat && a.maxLat <= b.maxLat) { return OVERLAP.A_COMPLETE_IN_B; } if (b.minLon >= a.minLon && b.maxLon <= a.maxLon && b.minLat >= a.minLat && b.maxLat <= a.maxLat) { return OVERLAP.B_COMPLETE_IN_A; } return OVERLAP.OVERLAPPING; }
OSHDBBoundingBox implements Serializable { public static OVERLAP overlap(OSHDBBoundingBox a, OSHDBBoundingBox b) { if (b.minLon >= a.maxLon || b.maxLon <= a.minLon || b.minLat >= a.maxLat || b.maxLat <= a.minLat) { return OVERLAP.NONE; } if (a.minLon >= b.minLon && a.maxLon <= b.maxLon && a.minLat >= b.minLat && a.maxLat <= b.maxLat) { return OVERLAP.A_COMPLETE_IN_B; } if (b.minLon >= a.minLon && b.maxLon <= a.maxLon && b.minLat >= a.minLat && b.maxLat <= a.maxLat) { return OVERLAP.B_COMPLETE_IN_A; } return OVERLAP.OVERLAPPING; } }
OSHDBBoundingBox implements Serializable { public static OVERLAP overlap(OSHDBBoundingBox a, OSHDBBoundingBox b) { if (b.minLon >= a.maxLon || b.maxLon <= a.minLon || b.minLat >= a.maxLat || b.maxLat <= a.minLat) { return OVERLAP.NONE; } if (a.minLon >= b.minLon && a.maxLon <= b.maxLon && a.minLat >= b.minLat && a.maxLat <= b.maxLat) { return OVERLAP.A_COMPLETE_IN_B; } if (b.minLon >= a.minLon && b.maxLon <= a.maxLon && b.minLat >= a.minLat && b.maxLat <= a.maxLat) { return OVERLAP.B_COMPLETE_IN_A; } return OVERLAP.OVERLAPPING; } OSHDBBoundingBox(long minLon, long minLat, long maxLon, long maxLat);  OSHDBBoundingBox(double minLon, double minLat, double maxLon, double maxLat);  OSHDBBoundingBox(int minLon, int minLat, int maxLon, int maxLat); }
OSHDBBoundingBox implements Serializable { public static OVERLAP overlap(OSHDBBoundingBox a, OSHDBBoundingBox b) { if (b.minLon >= a.maxLon || b.maxLon <= a.minLon || b.minLat >= a.maxLat || b.maxLat <= a.minLat) { return OVERLAP.NONE; } if (a.minLon >= b.minLon && a.maxLon <= b.maxLon && a.minLat >= b.minLat && a.maxLat <= b.maxLat) { return OVERLAP.A_COMPLETE_IN_B; } if (b.minLon >= a.minLon && b.maxLon <= a.maxLon && b.minLat >= a.minLat && b.maxLat <= a.maxLat) { return OVERLAP.B_COMPLETE_IN_A; } return OVERLAP.OVERLAPPING; } OSHDBBoundingBox(long minLon, long minLat, long maxLon, long maxLat);  OSHDBBoundingBox(double minLon, double minLat, double maxLon, double maxLat);  OSHDBBoundingBox(int minLon, int minLat, int maxLon, int maxLat); static OSHDBBoundingBox intersect(OSHDBBoundingBox first, OSHDBBoundingBox second); static OVERLAP overlap(OSHDBBoundingBox a, OSHDBBoundingBox b); void set(long minLon, long minLat, long maxLon, long maxLat); void set(OSHDBBoundingBox bbox); void add(OSHDBBoundingBox bbox); double getMinLon(); long getMinLonLong(); double getMaxLon(); long getMaxLonLong(); double getMinLat(); long getMinLatLong(); double getMaxLat(); long getMaxLatLong(); long[] getLon(); long[] getLat(); boolean intersects(OSHDBBoundingBox otherBbox); boolean isInside(OSHDBBoundingBox otherBbox); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); boolean isPoint(); boolean isValid(); }
OSHDBBoundingBox implements Serializable { public static OVERLAP overlap(OSHDBBoundingBox a, OSHDBBoundingBox b) { if (b.minLon >= a.maxLon || b.maxLon <= a.minLon || b.minLat >= a.maxLat || b.maxLat <= a.minLat) { return OVERLAP.NONE; } if (a.minLon >= b.minLon && a.maxLon <= b.maxLon && a.minLat >= b.minLat && a.maxLat <= b.maxLat) { return OVERLAP.A_COMPLETE_IN_B; } if (b.minLon >= a.minLon && b.maxLon <= a.maxLon && b.minLat >= a.minLat && b.maxLat <= a.maxLat) { return OVERLAP.B_COMPLETE_IN_A; } return OVERLAP.OVERLAPPING; } OSHDBBoundingBox(long minLon, long minLat, long maxLon, long maxLat);  OSHDBBoundingBox(double minLon, double minLat, double maxLon, double maxLat);  OSHDBBoundingBox(int minLon, int minLat, int maxLon, int maxLat); static OSHDBBoundingBox intersect(OSHDBBoundingBox first, OSHDBBoundingBox second); static OVERLAP overlap(OSHDBBoundingBox a, OSHDBBoundingBox b); void set(long minLon, long minLat, long maxLon, long maxLat); void set(OSHDBBoundingBox bbox); void add(OSHDBBoundingBox bbox); double getMinLon(); long getMinLonLong(); double getMaxLon(); long getMaxLonLong(); double getMinLat(); long getMinLatLong(); double getMaxLat(); long getMaxLatLong(); long[] getLon(); long[] getLat(); boolean intersects(OSHDBBoundingBox otherBbox); boolean isInside(OSHDBBoundingBox otherBbox); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); boolean isPoint(); boolean isValid(); static final OSHDBBoundingBox EMPTY; static final OSHDBBoundingBox INVALID; }