public static @Nullable Envelope makePrecise(@Nullable Envelope bounds) { Envelope float32Bounds = Float32Bounds.valueOf(bounds).asEnvelope(); return float32Bounds.isNull() ? null : float32Bounds; } }
public @Override void expand(Envelope env) { bounds.expand(env); }
public @Override boolean intersects(Envelope env) { return bounds.intersects(env); }
public @Override Optional<Envelope> bounds() { return fromNullable(bounds.isNull() ? null : bounds.asEnvelope()); }
@Test public void testSimple() { // 1,1 is the same in float4 and float8 Coordinate coord = new Coordinate(1, 1); Float32Bounds bounds = Float32Bounds.valueOf(new Envelope(coord)); assertTrue(bounds.asEnvelope().contains(coord)); assertTrue(bounds.intersects(new Envelope(coord))); Envelope testEnvelope = new Envelope(); bounds.expand(testEnvelope); assertTrue(testEnvelope.covers(bounds.asEnvelope())); coord = new Coordinate(Math.PI, Math.E); bounds = Float32Bounds.valueOf(new Envelope(coord)); assertNotEquals(bounds, new Envelope(coord)); assertTrue(bounds.asEnvelope().contains(coord)); assertTrue(bounds.intersects(new Envelope(coord))); testEnvelope = new Envelope(); bounds.expand(testEnvelope); assertTrue(testEnvelope.covers(bounds.asEnvelope())); }
public void expand(Envelope env) { if (isNull()) return; env.expandToInclude(xmin, ymin); env.expandToInclude(xmax, ymax); Float32Bounds newEnv = Float32Bounds.valueOf(env); Envelope float32Version = newEnv.asEnvelope(); env.init(float32Version); }
private Float32Bounds boundsInternal() { return Float32Bounds.valueOf(bounds_x1, bounds_x2, bounds_y1, bounds_y2); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof Float32Bounds)) { return false; } if (obj == this) { return true; } Float32Bounds other = (Float32Bounds) obj; if (other.isNull() && this.isNull()) return true; if (other.isNull() != this.isNull()) return false; return other.xmin == this.xmin && other.ymin == this.ymin && other.xmax == this.xmax && other.ymax == this.ymax; }
private Float32Bounds(Envelope doublePrecisionEnv) { if ((doublePrecisionEnv == null) || (doublePrecisionEnv.isNull())) { return; // done! } set(doublePrecisionEnv); }
static Float32Bounds valueOf(float x1, float x2, float y1, float y2) { return new Float32Bounds(x1, x2, y1, y2); } }
@Override public Optional<Envelope> bounds() { return fromNullable(boundsInternal().isNull() ? null : boundsInternal().asEnvelope()); }
public @Override Bucket createBucket(final @NonNull ObjectId bucketTree, @Nonnegative int bucketIndex, final @Nullable Envelope bounds) { if (bucketIndex < 0) { throw new IllegalArgumentException( "Bucket cannot have a negative index: " + bucketIndex); } Float32Bounds b32 = Float32Bounds.valueOf(bounds); return new BucketImpl(bucketTree, bucketIndex, b32); }
@Override public int hashCode() { if (isNull()) return 1; return Float.floatToRawIntBits(xmin) ^ Float.floatToRawIntBits(ymin) ^ Float.floatToRawIntBits(xmax) ^ Float.floatToRawIntBits(ymax); }
public Float32Bounds(double x, double y) { set(new Envelope(new Coordinate(x, y))); }
/** * Factory method, returns an empty Float32Bounds if {@code bounds} is {@code null} or * {@link Envelope#isNull() empty}, otherwise a Float32Bounds that's guaranteed to contain * {@code bounds} */ public static Float32Bounds valueOf(@Nullable Envelope bounds) { return bounds == null || bounds.isNull() ? EMPTY : new Float32Bounds(bounds); }
public BaseNodeImpl(final String name, final ObjectId oid, final ObjectId metadataId, @Nullable Envelope bounds, @Nullable Map<String, Object> extraData) { checkNotNull(name); checkNotNull(oid); checkNotNull(metadataId); this.name = name; this.objectId_h1 = RevObjects.h1(oid); this.objectId_h2 = RevObjects.h2(oid); this.objectId_h3 = RevObjects.h3(oid); this.metadataId = metadataId.isNull() ? null : metadataId; this.extraData = ExtraData.of(extraData); Float32Bounds bbox = Float32Bounds.valueOf(bounds); bounds_x1 = bbox.xmin; bounds_x2 = bbox.xmax; bounds_y1 = bbox.ymin; bounds_y2 = bbox.ymax; }
@Override public void expand(Envelope env) { if (!isBoundsNull()) { boundsInternal().expand(env); } }
@Override public boolean intersects(Envelope env) { if (isBoundsNull() || env.isNull()) { return false; } return boundsInternal().intersects(env); }
public Envelope asEnvelope() { if (isNull()) return new Envelope(); return new Envelope(xmin, xmax, ymin, ymax); }
public boolean intersects(Envelope env) { if (isNull() || env.isNull()) { return false; } // make the intersects check here matching the logic in Envelope and avoid creating lots of // Envelope objects since this method is going to be called for each Node in a tree // traversal return !(env.getMinX() > xmax || // env.getMaxX() < xmin || // env.getMinY() > ymax || // env.getMaxY() < ymin); }