private boolean testReferencePoint(Envelope probeEnvelope, OGCGeometry buildGeometry, int partition) { Envelope buildEnvelope = getEnvelope(buildGeometry); Envelope intersection = buildEnvelope.intersection(probeEnvelope); if (intersection.isNull()) { return false; } Rectangle extent = partitions.get(partition); double x = intersection.getMinX(); double y = intersection.getMinY(); return x >= extent.getXMin() && x < extent.getXMax() && y >= extent.getYMin() && y < extent.getYMax(); }
/** * Converts the specified {@code Envelope} to a {@code Polygon} having the specified srid. * * @param env The envelope to convert * @param srid The srid for the polygon * * @return The Polygon */ public static Polygon toPolygon(Envelope env, int srid) { final Coordinate[] coords = new Coordinate[5]; coords[0] = new Coordinate( env.getMinX(), env.getMinY() ); coords[1] = new Coordinate( env.getMinX(), env.getMaxY() ); coords[2] = new Coordinate( env.getMaxX(), env.getMaxY() ); coords[3] = new Coordinate( env.getMaxX(), env.getMinY() ); coords[4] = new Coordinate( env.getMinX(), env.getMinY() ); final LinearRing shell = geomFactory.createLinearRing( coords ); final Polygon pg = geomFactory.createPolygon( shell, null ); pg.setSRID( srid ); return pg; }
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()); }
/** * Computes the Y ordinate of the i'th grid row. * * @param j the index of a grid row * @return the Y ordinate of the row */ public double y(int j) { if (j >= ySize - 1) return env.getMaxY(); return env.getMinY() + j * dy; }
public ValueAxis getRange() { NumberAxis range = new NumberAxis(); range.setRange(bounds.getMinY() - buf, bounds.getMaxY() + buf); return range; } }
public GeometryClipper(Envelope bounds) { this.xmin = bounds.getMinX(); this.ymin = bounds.getMinY(); this.xmax = bounds.getMaxX(); this.ymax = bounds.getMaxY(); this.bounds = bounds; }
public Object getProperty(Object object, QName name) throws Exception { Envelope e = (Envelope) object; if (GML.coord.equals(name)) { return new Coordinate[] { new Coordinate(e.getMinX(), e.getMinY()), new Coordinate(e.getMaxX(), e.getMaxY()) }; } else if ("srsName".equals(name.getLocalPart()) && e instanceof ReferencedEnvelope) { return GML2EncodingUtils.toURI(((ReferencedEnvelope) e).getCoordinateReferenceSystem()); } return null; } }
private Rectangle2D getCurvedLabelBounds( LineStringCursor cursor, double startOrdinate, double endOrdinate, double bufferSize) { LineString cut = cursor.getSubLineString(startOrdinate, endOrdinate); Envelope e = cut.getEnvelopeInternal(); e.expandBy(bufferSize); return new Rectangle2D.Double(e.getMinX(), e.getMinY(), e.getWidth(), e.getHeight()); }
public boolean get(Envelope envelope) throws TransformException { if (!canSimplify(envelope)) { return false; } point[0] = (envelope.getMinX() + envelope.getMaxX()) / 2; point[1] = (envelope.getMinY() + envelope.getMaxY()) / 2; mt.transform(point, 0, point, 0, 1); int r = (int) point[0]; int c = (int) point[1]; return get(r, c); }
@Override public void encode(Envelope e, AttributesImpl atts, GMLWriter handler) throws Exception { handler.startElement(box, atts); handler.coordinates( new LiteCoordinateSequence(e.getMinX(), e.getMinY(), e.getMaxX(), e.getMaxY())); handler.endElement(box); } }
private BBOX bboxFilter(Envelope bbox) { return ff.bbox( wrapped.getSchema().getGeometryDescriptor().getLocalName(), bbox.getMinX(), bbox.getMinY(), bbox.getMaxX(), bbox.getMaxY(), null); }
@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); }
private void assertBounds(Envelope e1, Envelope e2, double tol) { if (e1.isNull()) { assertTrue(e2.isNull()); } assertEquals(e1.getMinX(), e2.getMinX(), tol); assertEquals(e1.getMinY(), e2.getMinY(), tol); assertEquals(e1.getMaxX(), e2.getMaxX(), tol); assertEquals(e1.getMaxY(), e2.getMaxY(), tol); }
@Test public void circle() throws Exception { double radius = SQUARE_ENV.getWidth() / 2; Polygon p = builder.circle( SQUARE_ENV.getMinX() + radius, SQUARE_ENV.getMinY() + radius, radius, getNumSides(SQUARE_ENV)); assertBounds(SQUARE_ENV, p.getEnvelopeInternal(), 0.01); }
@Test public void toGeometry_BoundingBox() { BoundingBox bbox = new ReferencedEnvelope(-10, 10, -5, 5, null); Geometry geom = JTS.toGeometry(bbox); assertTrue(geom instanceof org.locationtech.jts.geom.Polygon); Envelope geomEnv = geom.getEnvelopeInternal(); assertEquals(-10.0, geomEnv.getMinX(), TOL); assertEquals(10.0, geomEnv.getMaxX(), TOL); assertEquals(-5.0, geomEnv.getMinY(), TOL); assertEquals(5.0, geomEnv.getMaxY(), TOL); }
@Test public void toGeometry_Envelope() { Envelope refEnv = new Envelope(-10, 10, -5, 5); Geometry geom = JTS.toGeometry(refEnv); assertTrue(geom instanceof org.locationtech.jts.geom.Polygon); Envelope geomEnv = geom.getEnvelopeInternal(); assertEquals(-10.0, geomEnv.getMinX(), TOL); assertEquals(10.0, geomEnv.getMaxX(), TOL); assertEquals(-5.0, geomEnv.getMinY(), TOL); assertEquals(5.0, geomEnv.getMaxY(), TOL); }