throw new IllegalArgumentException("Illegal CRS.", e); expanded.setToNaN(); expanded.subEnvelope(0, envelope.getDimension()).setEnvelope(envelope); return expanded;
/** * Computes the envelope with the given coordinate reference system. This method is invoked from constructors. * The {@link #extent}, {@link #gridToCRS} and {@link #cornerToCRS} fields must be set before this method is invoked. * * @param specified the transform specified by the user. This is not necessarily {@link #gridToCRS}. * @param crs the coordinate reference system to declare in the envelope. * @param limits if non-null, intersect with that envelope. The CRS must be the same than {@code crs}. */ private ImmutableEnvelope computeEnvelope(final MathTransform specified, final CoordinateReferenceSystem crs, final Envelope limits) throws TransformException { final GeneralEnvelope env; if (extent != null && cornerToCRS != null) { env = extent.toCRS(cornerToCRS, specified); env.setCoordinateReferenceSystem(crs); if (limits != null) { env.intersect(limits); } } else if (crs != null) { env = new GeneralEnvelope(crs); env.setToNaN(); } else { return null; } return new ImmutableEnvelope(env); }
/** * Tests {@link SubEnvelope#setToNaN()}. */ @Test public void testSetToNaN() { final GeneralEnvelope e = create(-40, -20, +60, +30); e.setToNaN(); assertArrayEquals(new double[] {1, 4, NaN, NaN, 5, 2, 7, NaN, NaN, 9}, e.ordinates, STRICT); validate(e); }