class GeocoderUtilService {

	public Envelope extendPoint(Coordinate coordinate, CoordinateReferenceSystem crs,
								double width, double height) throws GeomajasException {
		double halfCrsWidth = EXTEND_MAPUNIT_TEST_LENGTH;
		double halfCrsHeight = EXTEND_MAPUNIT_TEST_LENGTH;
		double x = coordinate.x;
		double y = coordinate.y;
		for (int i = EXTEND_MAX_ITERATIONS; i > 0; i--) {
			try {
				Coordinate test;
				test = new Coordinate(x + halfCrsWidth, y);
				double deltaX = JTS.orthodromicDistance(coordinate, test, crs);
				test = new Coordinate(x, y + halfCrsHeight);
				double deltaY = JTS.orthodromicDistance(coordinate, test, crs);
				if (Math.abs(deltaX - width / 2) < DISTANCE_PRECISION &&
						Math.abs(deltaY - height / 2) < DISTANCE_PRECISION) {
					break;
				}
				halfCrsWidth = halfCrsWidth / deltaX * width / 2;
				halfCrsHeight = halfCrsHeight / deltaY * height / 2;
			} catch (TransformException te) {
				throw new GeomajasException(te, ExceptionCode.GEOMETRY_TRANSFORMATION_FAILED, crs);
			}
		}
		return new Envelope(x - halfCrsWidth, x + halfCrsWidth, y - halfCrsHeight, y + halfCrsHeight);
	}

}