/** * Initialize the bounding box with another bounding box. * * @since 2.4 */ public void setBounds(final BoundingBox bbox) { ensureCompatibleReferenceSystem(bbox); super.init(getJTSEnvelope(bbox)); }
@Override public BoundingBox getBounds() { Object o = getDefaultGeometry(); if (o instanceof Geometry) { CoordinateReferenceSystem crs = featureType.getCoordinateReferenceSystem(); if (crs == null) { crs = DefaultGeographicCRS.WGS84; } Envelope bounds = ReferencedEnvelope.create(crs); bounds.init(JTS.bounds((Geometry) o, crs)); return (BoundingBox) bounds; } return null; }
/** Sets this envelope to the specified bounding box. */ public void init(BoundingBox bounds) { super.init( bounds.getMinimum(0), bounds.getMaximum(0), bounds.getMinimum(1), bounds.getMaximum(1)); this.crs = bounds.getCoordinateReferenceSystem(); }
public BoundingBox getBounds() { // TODO: cache this value CoordinateReferenceSystem crs = featureType.getCoordinateReferenceSystem(); Envelope bounds = ReferencedEnvelope.create(crs); for (Object o : values) { if (o instanceof Geometry) { Geometry g = (Geometry) o; // TODO: check userData for crs... and ensure its of the same // crs as the feature type if (bounds.isNull()) { bounds.init(JTS.bounds(g, crs)); } else { bounds.expandToInclude(JTS.bounds(g, crs)); } } } return (BoundingBox) bounds; }
/** * Creates a null <code>Envelope</code>. */ public Envelope() { init(); }
/** * Creates an <code>Envelope</code> for a region defined by maximum and minimum values. * *@param x1 the first x-value *@param x2 the second x-value *@param y1 the first y-value *@param y2 the second y-value */ public Envelope(double x1, double x2, double y1, double y2) { init(x1, x2, y1, y2); }
/** * Creates an <code>Envelope</code> for a region defined by a single Coordinate. * *@param p the Coordinate */ public Envelope(Coordinate p) { init(p.x, p.x, p.y, p.y); }
/** * Initialize an <code>Envelope</code> to a region defined by a single Coordinate. * *@param p the coordinate */ public void init(Coordinate p) { init(p.x, p.x, p.y, p.y); }
/** * Creates an <code>Envelope</code> for a region defined by two Coordinates. * *@param p1 the first Coordinate *@param p2 the second Coordinate */ public Envelope(Coordinate p1, Coordinate p2) { init(p1.x, p2.x, p1.y, p2.y); }
/** * Create an <code>Envelope</code> from an existing Envelope. * *@param env the Envelope to initialize from */ public Envelope(Envelope env) { init(env); }
/** * Initialize an <code>Envelope</code> to a region defined by two Coordinates. * *@param p1 the first Coordinate *@param p2 the second Coordinate */ public void init(Coordinate p1, Coordinate p2) { init(p1.x, p2.x, p1.y, p2.y); }
private void computeKey(int level, Envelope itemEnv) { double quadSize = DoubleBits.powerOf2(level); pt.x = Math.floor(itemEnv.getMinX() / quadSize) * quadSize; pt.y = Math.floor(itemEnv.getMinY() / quadSize) * quadSize; env.init(pt.x, pt.x + quadSize, pt.y, pt.y + quadSize); } }
public ScreenMapPredicate optimizeForSingleThreadedCalls() { this.lock = new NoOpLock(); final Envelope reuse = new Envelope(); this.envelope = () -> { reuse.init(); return reuse; }; return this; }
/** * Initialize the bounding box with another bounding box. * * @since 2.4 */ @Override public void setBounds(final BoundingBox bbox) { ensureCompatibleReferenceSystem(bbox); super.init(getJTSEnvelope(bbox)); }
private static void toFloat32(Coordinate center, Envelope target) { float centerX = (float) center.x; float centerY = (float) center.y; float xmin = Math.nextAfter(centerX, Double.NEGATIVE_INFINITY); float ymin = Math.nextAfter(centerY, Double.NEGATIVE_INFINITY); float xmax = Math.nextAfter(centerX, Double.POSITIVE_INFINITY); float ymax = Math.nextAfter(centerY, Double.POSITIVE_INFINITY); target.init(xmin, xmax, ymin, ymax); } }
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); }
/** * Translates this envelope by given amounts in the X and Y direction. * * @param transX the amount to translate along the X axis * @param transY the amount to translate along the Y axis */ public void translate(double transX, double transY) { if (isNull()) { return; } init(getMinX() + transX, getMaxX() + transX, getMinY() + transY, getMaxY() + transY); }
/** * Sets this envelope to the specified bounding box. */ public void init(final BoundingBox bounds) { super.init(bounds.getMinimum(0), bounds.getMaximum(0), bounds.getMinimum(1), bounds.getMaximum(1)); this.crs = bounds.getCoordinateReferenceSystem(); }
public static int findMaxDepth(Envelope maxBounds, final int absoluteMaxDepth) { // choose the quad that tends to the biggest abs value maxBounds = RevObjects.makePrecise(maxBounds); final Quadrant testQuad = findBiggestMagnitudeQuad(maxBounds); Envelope parent = new Envelope(maxBounds); Envelope child = new Envelope(); Envelope float32Center = new Envelope(); for (int d = 0; d < absoluteMaxDepth; d++) { testQuad.slice(parent, child); Coordinate center = child.centre(); toFloat32(center, float32Center); if (!child.contains(float32Center)) { return d; } parent.init(child); } return absoluteMaxDepth; }
public void testEmpty() { assertEquals(0, new Envelope().getHeight(), 0); assertEquals(0, new Envelope().getWidth(), 0); assertEquals(new Envelope(), new Envelope()); Envelope e = new Envelope(100, 101, 100, 101); e.init(new Envelope()); assertEquals(new Envelope(), e); }