/** * Test if this geometry envelope intersects with the other geometry * envelope. * * @param r the other geometry * @return true if the two overlap */ public boolean intersectsBoundingBox(ValueGeometry r) { // the Geometry object caches the envelope return getGeometryNoCopy().getEnvelopeInternal().intersects( r.getGeometryNoCopy().getEnvelopeInternal()); }
/** * Get the union. * * @param r the other geometry * @return the union of this geometry envelope and another geometry envelope */ public Value getEnvelopeUnion(ValueGeometry r) { GeometryFactory gf = new GeometryFactory(); Envelope mergedEnvelope = new Envelope(getGeometryNoCopy().getEnvelopeInternal()); mergedEnvelope.expandToInclude(r.getGeometryNoCopy().getEnvelopeInternal()); return get(gf.toGeometry(mergedEnvelope)); }
private static void writeEnvelope(Geometry geometry, SliceOutput output) { if (geometry.isEmpty()) { for (int i = 0; i < 4; i++) { output.writeDouble(NaN); } return; } Envelope envelope = geometry.getEnvelopeInternal(); output.writeDouble(envelope.getMinX()); output.writeDouble(envelope.getMinY()); output.writeDouble(envelope.getMaxX()); output.writeDouble(envelope.getMaxY()); }
private SpatialKey getKey(SearchRow row) { if (row == null) { return null; } Value v = row.getValue(columnIds[0]); if (v == ValueNull.INSTANCE) { return null; } Geometry g = ((ValueGeometry) v.convertTo(Value.GEOMETRY)).getGeometryNoCopy(); Envelope env = g.getEnvelopeInternal(); return new SpatialKey(row.getKey(), (float) env.getMinX(), (float) env.getMaxX(), (float) env.getMinY(), (float) env.getMaxY()); }
private SpatialKey getKey(SearchRow row) { Value v = row.getValue(columnIds[0]); if (v == ValueNull.INSTANCE) { return new SpatialKey(row.getKey()); } Geometry g = ((ValueGeometry) v.convertTo(Value.GEOMETRY)).getGeometryNoCopy(); Envelope env = g.getEnvelopeInternal(); return new SpatialKey(row.getKey(), (float) env.getMinX(), (float) env.getMaxX(), (float) env.getMinY(), (float) env.getMaxY()); }
@Override protected boolean basicEvaluate(Geometry left, Geometry right) { Envelope envLeft = left.getEnvelopeInternal(); Envelope envRight = right.getEnvelopeInternal(); if (envRight.contains(envLeft)) return left.within(right); else return false; } }
@Override protected boolean basicEvaluate(Geometry left, Geometry right) { Envelope envLeft = left.getEnvelopeInternal(); Envelope envRight = right.getEnvelopeInternal(); if (envRight.intersects(envLeft)) return left.disjoint(right); return true; }
@Override public Envelope decodeGeometryEnvelope(ResultSet rs, int column, Connection cx) throws SQLException, IOException { Geometry g = geometry(rs.getBytes(column)); return g != null ? g.getEnvelopeInternal() : null; }
@Override public int hashCode() { //FYI if geometry.equalsExact(that.geometry), then their envelopes are the same. return geom.getEnvelopeInternal().hashCode(); }
@Override public Envelope decodeGeometryEnvelope(ResultSet rs, int column, Connection cx) throws SQLException, IOException { Geometry geom = readGeometry(rs, column, new GeometryFactory(), cx); return geom != null ? geom.getEnvelopeInternal() : null; }
public boolean evaluate(Object feature) { if (feature == null) return false; Geometry other = (Geometry) property.evaluate(feature); if (other == null) return false; return other.getEnvelopeInternal().intersects(envelope); }
private SimpleFeatureCollection getCollection(Attributes attrs, ElementValue[] value) { String id = ""; id = attrs.getValue("", "ID"); if (id == null) id = attrs.getValue(GMLSchema.NAMESPACE.toString(), "ID"); Object value2 = value[0].getValue(); Envelope envelopeInternal = ((Geometry) value2).getEnvelopeInternal(); // bbox slot GMLFeatureCollection fc = new GMLFeatureCollection(id, envelopeInternal); for (int i = 1; i < value.length; i++) // bbox is slot 0 fc.add((SimpleFeature) value[i].getValue()); return fc; }
@Override public BoundingBox getBounds() { ReferencedEnvelope bounds = new ReferencedEnvelope(featureType.getCoordinateReferenceSystem()); Object value = getAttribute(index); if (value instanceof Geometry) { bounds.init(((Geometry) value).getEnvelopeInternal()); } return bounds; }
@Override public Envelope decodeGeometryEnvelope(ResultSet rs, int column, Connection cx) throws SQLException, IOException { Geometry envelope = getWkbReader(null).read(rs, column); if (envelope != null) { return envelope.getEnvelopeInternal(); } else { // empty one return new Envelope(); } }
protected Envelope extractBboxForSpatialIndexQuery(BinarySpatialOperator filter) { org.opengis.filter.expression.Expression leftGeom = filter.getExpression1(); org.opengis.filter.expression.Expression rightGeom = filter.getExpression2(); Geometry g; if (leftGeom instanceof org.opengis.filter.expression.Literal) { g = (Geometry) ((org.opengis.filter.expression.Literal) leftGeom).getValue(); } else { g = (Geometry) ((org.opengis.filter.expression.Literal) rightGeom).getValue(); } return g.getEnvelopeInternal(); }
public Envelope getEnvelope() throws IOException { if (getHeader().getFlags().getEnvelopeIndicator() == EnvelopeType.NONE) { return get().getEnvelopeInternal(); } else { return getHeader().getEnvelope(); } }
@Override public ROI intersect(ROI roi) { final Geometry geom = getGeometry(roi); // is it a rectangle? if (geom != null && geom.equalsExact(geom.getEnvelope())) { GeometryClipper clipper = new GeometryClipper(geom.getEnvelopeInternal()); Geometry intersect = clipper.clip(getAsGeometry(), true); return new ROIGeometry(intersect); } else { return super.intersect(roi); } }
@Test public void testHorizontalSegmentPositiveOffset() throws ParseException { Geometry offset = simpleOffsetTest("LINESTRING(0 0, 10 0)", 2); assertTrue(offset.getEnvelopeInternal().getMinY() == 2); }
@Test public void testHorizontalSegmentNegativeOffset() throws ParseException { Geometry offset = simpleOffsetTest("LINESTRING(0 0, 10 0)", -2); assertTrue(offset.getEnvelopeInternal().getMinY() == -2); }
@Test public void smoothPolygon() { Coordinate[] coords = getPolyCoords(); Polygon poly = factory.createPolygon(factory.createLinearRing(coords), null); Geometry smoothed = JTS.smooth(poly, 0); assertTrue(smoothed instanceof Polygon); CoordList list = new CoordList(smoothed.getCoordinates()); assertTrue(list.containsAll(coords)); Envelope polyEnv = poly.getEnvelopeInternal(); Envelope smoothEnv = smoothed.getEnvelopeInternal(); assertTrue(smoothEnv.covers(polyEnv)); }