/** decodes the max value (for the defined dimension) from the encoded input byte array */ static int decodeMax(byte[] b, int dimension) { int offset = b.length/2 + dimension*BYTES; return NumericUtils.sortableBytesToInt(b, offset); }
/** decodes the min value (for the defined dimension) from the encoded input byte array */ static int decodeMin(byte[] b, int dimension) { int offset = dimension*BYTES; return NumericUtils.sortableBytesToInt(b, offset); }
/** Decode single integer dimension */ public static int decodeDimension(byte value[], int offset) { return NumericUtils.sortableBytesToInt(value, offset); }
/** * Turns quantized value from byte array back into a double. * @param src byte array containing 4 bytes to decode at {@code offset} * @param offset offset into {@code src} to decode from. * @return decoded latitude value. */ public static double decodeLatitude(byte[] src, int offset) { return decodeLatitude(NumericUtils.sortableBytesToInt(src, offset)); }
/** decodes the min value (for the defined dimension) from the encoded input byte array */ static float decodeMin(byte[] b, int dimension) { int offset = dimension*BYTES; return NumericUtils.sortableIntToFloat(NumericUtils.sortableBytesToInt(b, offset)); }
/** decodes the max value (for the defined dimension) from the encoded input byte array */ static float decodeMax(byte[] b, int dimension) { int offset = b.length/2 + dimension*BYTES; return NumericUtils.sortableIntToFloat(NumericUtils.sortableBytesToInt(b, offset)); }
/** * Turns quantized value from byte array back into a double. * @param src byte array containing 4 bytes to decode at {@code offset} * @param offset offset into {@code src} to decode from. * @return decoded longitude value. */ public static double decodeLongitude(byte[] src, int offset) { return decodeLongitude(NumericUtils.sortableBytesToInt(src, offset)); }
/** Decode single float dimension */ public static float decodeDimension(byte value[], int offset) { return NumericUtils.sortableIntToFloat(NumericUtils.sortableBytesToInt(value, offset)); }
int bits = NumericUtils.sortableBytesToInt(t, 6 * XLatLonShape.BYTES); triangle[0] = NumericUtils.sortableBytesToInt(t, 0 * XLatLonShape.BYTES); triangle[1] = NumericUtils.sortableBytesToInt(t, 1 * XLatLonShape.BYTES); triangle[2] = NumericUtils.sortableBytesToInt(t, 2 * XLatLonShape.BYTES); triangle[3] = NumericUtils.sortableBytesToInt(t, 3 * XLatLonShape.BYTES); triangle[4] = NumericUtils.sortableBytesToInt(t, 4 * XLatLonShape.BYTES); triangle[5] = NumericUtils.sortableBytesToInt(t, 5 * XLatLonShape.BYTES); break; case MINY_MINX_Y_X_MAXY_MAXX: triangle[0] = NumericUtils.sortableBytesToInt(t, 0 * XLatLonShape.BYTES); triangle[1] = NumericUtils.sortableBytesToInt(t, 1 * XLatLonShape.BYTES); triangle[2] = NumericUtils.sortableBytesToInt(t, 4 * XLatLonShape.BYTES); triangle[3] = NumericUtils.sortableBytesToInt(t, 5 * XLatLonShape.BYTES); triangle[4] = NumericUtils.sortableBytesToInt(t, 2 * XLatLonShape.BYTES); triangle[5] = NumericUtils.sortableBytesToInt(t, 3 * XLatLonShape.BYTES); break; case MAXY_MINX_Y_X_MINY_MAXX: triangle[0] = NumericUtils.sortableBytesToInt(t, 2 * XLatLonShape.BYTES); triangle[1] = NumericUtils.sortableBytesToInt(t, 1 * XLatLonShape.BYTES); triangle[2] = NumericUtils.sortableBytesToInt(t, 4 * XLatLonShape.BYTES); triangle[3] = NumericUtils.sortableBytesToInt(t, 5 * XLatLonShape.BYTES); triangle[4] = NumericUtils.sortableBytesToInt(t, 0 * XLatLonShape.BYTES); triangle[5] = NumericUtils.sortableBytesToInt(t, 3 * XLatLonShape.BYTES); break; case MAXY_MINX_MINY_MAXX_Y_X: triangle[0] = NumericUtils.sortableBytesToInt(t, 2 * XLatLonShape.BYTES); triangle[1] = NumericUtils.sortableBytesToInt(t, 1 * XLatLonShape.BYTES); triangle[2] = NumericUtils.sortableBytesToInt(t, 0 * XLatLonShape.BYTES);
@Override protected Relation relateRangeBBoxToQuery(int minXOffset, int minYOffset, byte[] minTriangle, int maxXOffset, int maxYOffset, byte[] maxTriangle) { double minLat = GeoEncodingUtils.decodeLatitude(NumericUtils.sortableBytesToInt(minTriangle, minYOffset)); double minLon = GeoEncodingUtils.decodeLongitude(NumericUtils.sortableBytesToInt(minTriangle, minXOffset)); double maxLat = GeoEncodingUtils.decodeLatitude(NumericUtils.sortableBytesToInt(maxTriangle, maxYOffset)); double maxLon = GeoEncodingUtils.decodeLongitude(NumericUtils.sortableBytesToInt(maxTriangle, maxXOffset)); // check internal node against query return poly2D.relate(minLat, maxLat, minLon, maxLon); }
@Override protected Relation relateRangeBBoxToQuery(int minXOffset, int minYOffset, byte[] minTriangle, int maxXOffset, int maxYOffset, byte[] maxTriangle) { double minLat = GeoEncodingUtils.decodeLatitude(NumericUtils.sortableBytesToInt(minTriangle, minYOffset)); double minLon = GeoEncodingUtils.decodeLongitude(NumericUtils.sortableBytesToInt(minTriangle, minXOffset)); double maxLat = GeoEncodingUtils.decodeLatitude(NumericUtils.sortableBytesToInt(maxTriangle, maxYOffset)); double maxLon = GeoEncodingUtils.decodeLongitude(NumericUtils.sortableBytesToInt(maxTriangle, maxXOffset)); // check internal node against query return line2D.relate(minLat, maxLat, minLon, maxLon); }
/** decodes the max value (for the defined dimension) from the encoded input byte array */ static int decodeMax(byte[] b, int dimension) { int offset = b.length/2 + dimension*BYTES; return NumericUtils.sortableBytesToInt(b, offset); }
/** decodes the min value (for the defined dimension) from the encoded input byte array */ static int decodeMin(byte[] b, int dimension) { int offset = dimension*BYTES; return NumericUtils.sortableBytesToInt(b, offset); }
@Override final public Integer to(final BytesRef bytesRef) { if (isEmpty(bytesRef)) return null; checkByteSize(bytesRef, Integer.BYTES, "Cannot convert value to int"); return NumericUtils.sortableBytesToInt(bytesRef.bytes, 0); } }
/** * Turns quantized value from byte array back into a double. * @param src byte array containing 4 bytes to decode at {@code offset} * @param offset offset into {@code src} to decode from. * @return decoded latitude value. */ public static double decodeLatitude(byte[] src, int offset) { return decodeLatitude(NumericUtils.sortableBytesToInt(src, offset)); }
@Override final public Float to(final BytesRef bytesRef) { if (isEmpty(bytesRef)) return null; checkByteSize(bytesRef, Float.BYTES, "Cannot convert value to float"); return NumericUtils.sortableIntToFloat(NumericUtils.sortableBytesToInt(bytesRef.bytes, 0)); } }
/** decodes the min value (for the defined dimension) from the encoded input byte array */ static float decodeMin(byte[] b, int dimension) { int offset = dimension*BYTES; return NumericUtils.sortableIntToFloat(NumericUtils.sortableBytesToInt(b, offset)); }
/** * Turns quantized value from byte array back into a double. * @param src byte array containing 4 bytes to decode at {@code offset} * @param offset offset into {@code src} to decode from. * @return decoded longitude value. */ public static double decodeLongitude(byte[] src, int offset) { return decodeLongitude(NumericUtils.sortableBytesToInt(src, offset)); }
/** decodes the max value (for the defined dimension) from the encoded input byte array */ static float decodeMax(byte[] b, int dimension) { int offset = b.length/2 + dimension*BYTES; return NumericUtils.sortableIntToFloat(NumericUtils.sortableBytesToInt(b, offset)); }
/** Decode single dimension */ public static double decodeDimension(byte value[], int offset) { return Geo3DUtil.decodeValue(NumericUtils.sortableBytesToInt(value, offset)); }