@Override protected Relation componentRelateTriangle(double ax, double ay, double bx, double by, double cx, double cy) { // check any holes if (holes != null) { Relation holeRelation = holes.relateTriangle(ax, ay, bx, by, cx, cy); if (holeRelation == Relation.CELL_CROSSES_QUERY) { return Relation.CELL_CROSSES_QUERY; } else if (holeRelation == Relation.CELL_INSIDE_QUERY) { return Relation.CELL_OUTSIDE_QUERY; } } // check each corner: if < 3 are present, its cheaper than crossesSlowly int numCorners = numberOfTriangleCorners(ax, ay, bx, by, cx, cy); if (numCorners == 3) { if (tree.crossesTriangle(ax, ay, bx, by, cx, cy)) { return Relation.CELL_CROSSES_QUERY; } return Relation.CELL_INSIDE_QUERY; } else if (numCorners > 0) { return Relation.CELL_CROSSES_QUERY; } return null; }
@Override protected boolean queryMatches(byte[] t, int[] scratchTriangle) { XLatLonShape.decodeTriangle(t, scratchTriangle); double alat = GeoEncodingUtils.decodeLatitude(scratchTriangle[0]); double alon = GeoEncodingUtils.decodeLongitude(scratchTriangle[1]); double blat = GeoEncodingUtils.decodeLatitude(scratchTriangle[2]); double blon = GeoEncodingUtils.decodeLongitude(scratchTriangle[3]); double clat = GeoEncodingUtils.decodeLatitude(scratchTriangle[4]); double clon = GeoEncodingUtils.decodeLongitude(scratchTriangle[5]); if (queryRelation == QueryRelation.WITHIN) { return poly2D.relateTriangle(alon, alat, blon, blat, clon, clat) == Relation.CELL_INSIDE_QUERY; } // INTERSECTS return poly2D.relateTriangle(alon, alat, blon, blat, clon, clat) != Relation.CELL_OUTSIDE_QUERY; }
@Override protected Relation componentRelateTriangle(double ax, double ay, double bx, double by, double cx, double cy) { // check any holes if (holes != null) { Relation holeRelation = holes.relateTriangle(ax, ay, bx, by, cx, cy); if (holeRelation == Relation.CELL_CROSSES_QUERY) { return Relation.CELL_CROSSES_QUERY; } else if (holeRelation == Relation.CELL_INSIDE_QUERY) { return Relation.CELL_OUTSIDE_QUERY; } } // check each corner: if < 3 are present, its cheaper than crossesSlowly int numCorners = numberOfTriangleCorners(ax, ay, bx, by, cx, cy); if (numCorners == 3) { if (tree.crossesTriangle(ax, ay, bx, by, cx, cy)) { return Relation.CELL_CROSSES_QUERY; } return Relation.CELL_INSIDE_QUERY; } else if (numCorners > 0) { return Relation.CELL_CROSSES_QUERY; } return null; }
@Override protected boolean queryMatches(byte[] t) { long a = NumericUtils.sortableBytesToLong(t, 4 * LatLonShape.BYTES); long b = NumericUtils.sortableBytesToLong(t, 5 * LatLonShape.BYTES); long c = NumericUtils.sortableBytesToLong(t, 6 * LatLonShape.BYTES); int aX = (int)((a >>> 32) & 0x00000000FFFFFFFFL); int bX = (int)((b >>> 32) & 0x00000000FFFFFFFFL); int cX = (int)((c >>> 32) & 0x00000000FFFFFFFFL); int aY = (int)(a & 0x00000000FFFFFFFFL); int bY = (int)(b & 0x00000000FFFFFFFFL); int cY = (int)(c & 0x00000000FFFFFFFFL); double alat = GeoEncodingUtils.decodeLatitude(aY); double alon = GeoEncodingUtils.decodeLongitude(aX); double blat = GeoEncodingUtils.decodeLatitude(bY); double blon = GeoEncodingUtils.decodeLongitude(bX); double clat = GeoEncodingUtils.decodeLatitude(cY); double clon = GeoEncodingUtils.decodeLongitude(cX); if (queryRelation == QueryRelation.WITHIN) { return poly2D.relateTriangle(alon, alat, blon, blat, clon, clat) == Relation.CELL_INSIDE_QUERY; } // INTERSECTS return poly2D.relateTriangle(alon, alat, blon, blat, clon, clat) != Relation.CELL_OUTSIDE_QUERY; }