@Test public void testWgs84BoundsFromCompoundCRS() throws Exception { try { MapProjection.SKIP_SANITY_CHECKS = true; CatalogBuilder cb = new CatalogBuilder(getCatalog()); ReferencedEnvelope3D bounds = new ReferencedEnvelope3D( 142892, 470783, 16, 142900, 470790, 20, CRS.decode("EPSG:7415")); // used to throw an exception here ReferencedEnvelope latLonBounds = cb.getLatLonBounds(bounds, bounds.getCoordinateReferenceSystem()); assertTrue( CRS.equalsIgnoreMetadata( CRS.decode("EPSG:4326"), latLonBounds.getCoordinateReferenceSystem())); // System.out.println(latLonBounds); } finally { MapProjection.SKIP_SANITY_CHECKS = false; } }
public String getSRS() { return CRS.toSRS(envelope.getCoordinateReferenceSystem()); }
/** * Creates a new envelope from an existing envelope. * * @param envelope The envelope to initialize from * @throws MismatchedDimensionException if the CRS dimension is not valid. */ public ReferencedEnvelope3D(final ReferencedEnvelope3D envelope) throws MismatchedDimensionException { init(envelope); crs = envelope.getCoordinateReferenceSystem(); checkCoordinateReferenceSystemDimension(); }
@Test public void empty() { // ensure empty can grab a default CRS when starting from nothing ReferencedEnvelope3D bbox = new ReferencedEnvelope3D(); // this is empty assertNull(bbox.getCoordinateReferenceSystem()); ReferencedEnvelope3D australia = new ReferencedEnvelope3D(DefaultGeographicCRS.WGS84_3D); australia.include(40, 110, 0); australia.include(10, 150, 10); bbox.include(australia); assertEquals(australia.getCoordinateReferenceSystem(), bbox.getCoordinateReferenceSystem()); assertEquals(0, bbox.getMinZ(), 0d); assertEquals(10, bbox.getMaxZ(), 0d); }
public Expression getExpression2() { // in this case, the 3D BBOX falls back to regular 2D bbox behaviour (until there is more // support for 3D geometries) // 3DBBOX must be run as a post-filter in order to support the third coordinate. Coordinate[] coords = new Coordinate[5]; coords[0] = new Coordinate(envelope.getMinX(), envelope.getMinY()); coords[1] = new Coordinate(envelope.getMinX(), envelope.getMaxY()); coords[2] = new Coordinate(envelope.getMaxX(), envelope.getMaxY()); coords[3] = new Coordinate(envelope.getMaxX(), envelope.getMinY()); coords[4] = new Coordinate(envelope.getMinX(), envelope.getMinY()); LinearRing ring = null; GeometryFactory gfac = new GeometryFactory(); try { ring = gfac.createLinearRing(coords); } catch (TopologyException tex) { throw new IllegalFilterException(tex.toString()); } Polygon polygon = gfac.createPolygon(ring, null); if (envelope instanceof ReferencedEnvelope3D) { ReferencedEnvelope3D refEnv = (ReferencedEnvelope3D) envelope; polygon.setUserData(refEnv.getCoordinateReferenceSystem()); } return factory.literal(polygon); }
/** * Computes the intersection of two {@link Envelope}s. * * @param env the envelope to intersect with * @return a new Envelope representing the intersection of the envelopes (this will be the null * envelope if either argument is null, or they do not intersect */ public ReferencedEnvelope3D intersection(ReferencedEnvelope3D env) { ensureCompatibleReferenceSystem(env); if (isNull() || env.isNull() || !intersects(env)) return new ReferencedEnvelope3D(); double intMinX = getMinX() > env.getMinX() ? getMinX() : env.getMinX(); double intMinY = getMinY() > env.getMinY() ? getMinY() : env.getMinY(); double intMinZ = minz > env.minz ? minz : env.minz; double intMaxX = getMaxX() < env.getMaxX() ? getMaxX() : env.getMaxX(); double intMaxY = getMaxY() < env.getMaxY() ? getMaxY() : env.getMaxY(); double intMaxZ = maxz < env.maxz ? maxz : env.maxz; return new ReferencedEnvelope3D( intMinX, intMaxX, intMinY, intMaxY, intMinZ, intMaxZ, env.getCoordinateReferenceSystem()); }