/** decodes the min value (for the defined dimension) from the encoded input byte array */ static long decodeMin(byte[] b, int dimension) { int offset = dimension*BYTES; return NumericUtils.sortableBytesToLong(b, offset); }
/** decodes the max value (for the defined dimension) from the encoded input byte array */ static long decodeMax(byte[] b, int dimension) { int offset = b.length/2 + dimension*BYTES; return NumericUtils.sortableBytesToLong(b, offset); }
/** Decode single long dimension */ public static long decodeDimension(byte value[], int offset) { return NumericUtils.sortableBytesToLong(value, offset); }
/** decodes the max value (for the defined dimension) from the encoded input byte array */ static double decodeMax(byte[] b, int dimension) { int offset = b.length/2 + dimension*BYTES; return NumericUtils.sortableLongToDouble(NumericUtils.sortableBytesToLong(b, offset)); }
/** decodes the min value (for the defined dimension) from the encoded input byte array */ static double decodeMin(byte[] b, int dimension) { int offset = dimension*BYTES; return NumericUtils.sortableLongToDouble(NumericUtils.sortableBytesToLong(b, offset)); }
/** Decode single double dimension */ public static double decodeDimension(byte value[], int offset) { return NumericUtils.sortableLongToDouble(NumericUtils.sortableBytesToLong(value, offset)); }
/** decodes the max value (for the defined dimension) from the encoded input byte array */ static long decodeMax(byte[] b, int dimension) { int offset = b.length/2 + dimension*BYTES; return NumericUtils.sortableBytesToLong(b, offset); }
/** Decode single long dimension */ public static long decodeDimension(byte value[], int offset) { return NumericUtils.sortableBytesToLong(value, offset); }
@Override final public Long to(final BytesRef bytesRef) { if (isEmpty(bytesRef)) return null; checkByteSize(bytesRef, Long.BYTES, "Cannot convert value to long"); return NumericUtils.sortableBytesToLong(bytesRef.bytes, 0); } }
/** counterpart to {@link #encodeTriangleBoxVal}; decodes encoded triangle bounding box values */ public static int decodeTriangleBoxVal(byte[] encoded, int offset) { long val = NumericUtils.sortableBytesToLong(encoded, offset); int result = (int)(val & 0x00000000FFFFFFFF); return result ^ 0x80000000; }
/** decodes the min value (for the defined dimension) from the encoded input byte array */ static long decodeMin(byte[] b, int dimension) { int offset = dimension*BYTES; return NumericUtils.sortableBytesToLong(b, offset); }
/** returns true if the query matches the encoded triangle */ @Override protected boolean queryMatches(byte[] t) { // decode indexed triangle 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); if (queryRelation == LatLonShape.QueryRelation.WITHIN) { return queryContainsTriangle(aX, aY, bX, bY, cX, cY); } return queryMatches(aX, aY, bX, bY, cX, cY); }
/** decodes the max value (for the defined dimension) from the encoded input byte array */ static double decodeMax(byte[] b, int dimension) { int offset = b.length/2 + dimension*BYTES; return NumericUtils.sortableLongToDouble(NumericUtils.sortableBytesToLong(b, offset)); }
@Override final public Double to(final BytesRef bytesRef) { if (isEmpty(bytesRef)) return null; checkByteSize(bytesRef, Double.BYTES, "Cannot convert value to double"); return NumericUtils.sortableLongToDouble(NumericUtils.sortableBytesToLong(bytesRef.bytes, 0)); } }
/** decodes the min value (for the defined dimension) from the encoded input byte array */ static double decodeMin(byte[] b, int dimension) { int offset = dimension*BYTES; return NumericUtils.sortableLongToDouble(NumericUtils.sortableBytesToLong(b, offset)); }
/** Decode single double dimension */ public static double decodeDimension(byte value[], int offset) { return NumericUtils.sortableLongToDouble(NumericUtils.sortableBytesToLong(value, offset)); }
@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 == LatLonShape.QueryRelation.WITHIN) { return line2D.relateTriangle(alon, alat, blon, blat, clon, clat) == Relation.CELL_INSIDE_QUERY; } // INTERSECTS return line2D.relateTriangle(alon, alat, blon, blat, clon, clat) != Relation.CELL_OUTSIDE_QUERY; }
@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; }