/** * Reproject the specified bbox string From the sourceCRS to the targetCRS. * * @param targetCRSName The coordinate reference system in which we have to reproject the geometry. * @param sourceCRSName The current coordinate reference system of the geometry. * @param boundingBox the bbox object to reproject as a string. * * @return The geometric object reprojected in the target coordinate reference system. * * @throws org.opengis.referencing.NoSuchAuthorityCodeException * @throws org.opengis.util.FactoryException * @throws org.opengis.referencing.operation.TransformException */ public static Object reprojectBbox2DString(final String sourceCRSName, final String targetCRSName, final String boundingBox) throws NoSuchAuthorityCodeException, FactoryException, TransformException { final String[] bbox = boundingBox.split(","); double[] lowerCorner ={Double.parseDouble(bbox[1]),Double.parseDouble(bbox[0])}; double[] upperCorner ={Double.parseDouble(bbox[3]),Double.parseDouble(bbox[2])}; GeneralEnvelope env = new GeneralEnvelope(lowerCorner,upperCorner); env.setCoordinateReferenceSystem(AbstractCRS.castOrCopy(CRS.forCode(sourceCRSName)).forConvention(AxesConvention.RIGHT_HANDED)); env = (GeneralEnvelope) reprojectGeometry(targetCRSName, sourceCRSName, env); lowerCorner = env.getLowerCorner().getCoordinate(); upperCorner = env.getUpperCorner().getCoordinate(); return lowerCorner[0]+","+lowerCorner[1]+","+upperCorner[0]+","+upperCorner[1]; }
/** * Tests modifying the corner of an envelope. */ @Test public void testCornerModifications() { final GeneralEnvelope e = create(2, -4, 3, -3); e.getLowerCorner().setOrdinate(0, 1); e.getUpperCorner().setOrdinate(1, -1); assertEquals( 1, e.getLower(0), STRICT); assertEquals(-4, e.getLower(1), STRICT); assertEquals( 3, e.getUpper(0), STRICT); assertEquals(-1, e.getUpper(1), STRICT); verifyInvariants(e); }
final boolean wrapOnX = genv.getLowerCorner().getOrdinate(0) > genv.getUpperCorner().getOrdinate(0); final boolean wrapOnY = genv.getLowerCorner().getOrdinate(1) > genv.getUpperCorner().getOrdinate(1); final double axisMax = axis.getMaximumValue(); final double wrapRange = axis.getMaximumValue() - axis.getMinimumValue() ; final DirectPosition lowerCorner = genv.getLowerCorner(); final DirectPosition upperCorner = genv.getUpperCorner();
assertTrue (e1.isEmpty()); assertFalse (e1.isAllNaN()); assertEquals(e1.getLowerCorner(), e1.getUpperCorner()); assertFalse(e1.getLowerCorner().equals(e1.getUpperCorner())); assertPositionEquals(e1.getLowerCorner(), e2.getLowerCorner()); assertPositionEquals(e1.getUpperCorner(), e2.getUpperCorner()); assertTrue (e1.contains(e2, true ));