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()); }
/** * 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 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 X ordinate of the i'th grid column. * * @param i the index of a grid column * @return the X ordinate of the column */ public double x(int i) { if (i >= xSize - 1) return env.getMaxX(); return env.getMinX() + i * dx; }
@Override protected Object get(ParameterMappingContext context) { return context.getBBOX().getMaxX(); } });
@Override public Object execute(GeoPkgGeomReader reader) throws IOException { return reader.getEnvelope().getMaxX(); } });
public ValueAxis getDomain() { NumberAxis domain = new NumberAxis(); domain.setRange(bounds.getMinX() - buf, bounds.getMaxX() + buf); return domain; }
public GeometryClipper(Envelope bounds) { this.xmin = bounds.getMinX(); this.ymin = bounds.getMinY(); this.xmax = bounds.getMaxX(); this.ymax = bounds.getMaxY(); this.bounds = bounds; }
public MemoryNode(Envelope envelope, int start, int end, int numSubnodes) { this.minx = (float) envelope.getMinX(); this.miny = (float) envelope.getMinY(); this.maxx = (float) envelope.getMaxX(); this.maxy = (float) envelope.getMaxY(); this.start = start; this.end = end; this.subnodes = new MemoryNode[numSubnodes]; }
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; } }
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); }
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 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 ellipse() throws Exception { Polygon p = builder.ellipse( RECT_ENV.getMinX(), RECT_ENV.getMinY(), RECT_ENV.getMaxX(), RECT_ENV.getMaxY(), getNumSides(RECT_ENV)); assertBounds(RECT_ENV, p.getEnvelopeInternal(), 0.01); }
@Test public void boxZ() throws Exception { Polygon p = builder.boxZ( RECT_ENV.getMinX(), RECT_ENV.getMinY(), RECT_ENV.getMaxX(), RECT_ENV.getMaxY(), 42); assertBounds(RECT_ENV, p.getEnvelopeInternal(), 1.0e-8); assertEquals(42, (int) p.getCoordinate().z); }
@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); }