expanded.subEnvelope(0, envelope.getDimension()).setEnvelope(envelope); return expanded;
/** * Creates a new geographic envelope for the given ordinate values. * This method is overridden by {@link SubEnvelopeTest}. */ GeneralEnvelope create(final double xmin, final double ymin, final double xmax, final double ymax) { final GeneralEnvelope envelope = new GeneralEnvelope(2); envelope.setCoordinateReferenceSystem(WGS84); envelope.setEnvelope(xmin, ymin, xmax, ymax); if (!skipValidation) { validate(envelope); } return envelope; }
/** * Tests {@link GeneralEnvelope#setEnvelope(double...)} with valid ranges, * then with a range which is known to be invalid. */ @Test public void testSetEnvelope() { final GeneralEnvelope e = create(2, -4, 3, -3); e.setEnvelope(3, -5, -8, 2); try { e.setEnvelope(1, -10, 2, -20); fail("Invalid range shall not be allowed."); } catch (IllegalArgumentException ex) { // This is the expected exception. final String message = ex.getMessage(); assertTrue(message, message.contains(AxisNames.GEODETIC_LATITUDE)); } // Verify that the envelope still have the old values. assertEnvelopeEquals(e, 3, -5, -8, 2); verifyInvariants(e); }
/** * Tests {@link GeneralEnvelope#setEnvelope(Envelope)}. */ @Test public void testCopy() { final GeneralEnvelope e = create(2, -4, 3, -3); e.setEnvelope(create(3, -5, -8, 2)); assertEnvelopeEquals(e, 3, -5, -8, 2); verifyInvariants(e); /* * Tests with a different implementation, for testing another code path. * Constructor argument are (x, y, width, height). */ e.setEnvelope(new Envelope2D(null, -2, 3, 8, 5)); assertEnvelopeEquals(e, -2, 3, 6, 8); verifyInvariants(e); }
/** * Creates a new sub-envelope envelope for the given ordinate values. */ @Override GeneralEnvelope create(final double xmin, final double ymin, final double xmax, final double ymax) { final GeneralEnvelope envelope = new GeneralEnvelope(5); envelope.setEnvelope(1, 4, xmin, ymin, 5, 2, 7, xmax, ymax, 9); if (!skipValidation) { validate(envelope); } final GeneralEnvelope sub = envelope.subEnvelope(2, 4); sub.setCoordinateReferenceSystem(WGS84); if (!skipValidation) { validate(sub); } return sub; }
destination.subEnvelope(destLowerAxis, destLowerAxis+ srcSubEnvelope.getDimension()).setEnvelope(srcSubEnvelope); usedCRS.add(destCurrent); continue browseSource; try { final Envelope tmp = Envelopes.transform(srcSubEnvelope, destCurrent); destination.subEnvelope(destLowerAxis, destLowerAxis + tmp.getDimension()).setEnvelope(tmp); } catch (TransformException e) {
int tmpDimNumber = tmpSubCRS.getCoordinateSystem().getDimension(); final GeneralEnvelope subTmp = tmpResult.subEnvelope(tmpOffset, tmpOffset + tmpDimNumber); resultEnvelope.subEnvelope(srcOffset, srcOffset+tmpResult.getDimension()).setEnvelope(subTmp); break;
final Envelope env = components[i]; final int dim = env.getDimension(); compound.subEnvelope(firstAffectedOrdinate, firstAffectedOrdinate += dim).setEnvelope(env); if (i == 0) { final CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
e1.setEnvelope(20, -20, 80, 12); e2.setEnvelope(40, -10, 100, 30); final double ymin=-20, ymax=30; // Will not change anymore assertUnionEquals(e1, e2, 20, ymin, 100, ymax, false, false);
ei.setEnvelope(e2); ei.add(e1); if (inf && exactlyOneAntiMeridianSpan) {
e1.setEnvelope(20, -20, 80, 12); e2.setEnvelope(40, -10, 100, 30); final double ymin=-10, ymax=12; // Will not change anymore assertIntersectEquals(e1, e2, 40, ymin, 80, ymax);
expanded.subEnvelope(0, 2).setEnvelope(srcEnvelope); expanded.setRange(2, 1000, 2000); matrix = Matrices.createTransform(expanded, dstEnvelope); expanded.subEnvelope(0, 2).setEnvelope(dstEnvelope); matrix = Matrices.createTransform(srcEnvelope, expanded); assertEquals("numRow", 4, matrix.getNumRow());
/** * Asserts that the intersection of the two following envelopes is equals to the given rectangle. * First, this method tests using the {@link Envelope2D} implementation. Then, it tests using the * {@link GeneralEnvelope} implementation. */ private static void assertIntersectEquals(final GeneralEnvelope e1, final GeneralEnvelope e2, final double xmin, final double ymin, final double xmax, final double ymax) { final Envelope2D r1 = new Envelope2D(e1); final Envelope2D r2 = new Envelope2D(e2); final Envelope2D ri = r1.createIntersection(r2); assertFalse("isEmpty", r1.isEmpty()); assertEnvelopeEquals(ri, xmin, ymin, xmax, ymax); assertEquals("Interchanged arguments.", ri, r2.createIntersection(r1)); // Compares with GeneralEnvelope. final GeneralEnvelope ei = new GeneralEnvelope(e1); ei.intersect(e2); assertFalse("isEmpty", e1.isEmpty()); assertEnvelopeEquals(ei, xmin, ymin, xmax, ymax); assertTrue("Using GeneralEnvelope.", ei.equals(ri, STRICT, false)); // Interchanges arguments. ei.setEnvelope(e2); ei.intersect(e1); assertFalse("isEmpty", e1.isEmpty()); assertEnvelopeEquals(ei, xmin, ymin, xmax, ymax); assertTrue("Using GeneralEnvelope.", ei.equals(ri, STRICT, false)); }
expanded.subEnvelope(0, 2).setEnvelope(srcEnvelope); expanded.setRange(2, 1000, 2000); matrix = Matrices.createTransform(