class TransformGeometryCommand implements CommandHasRequest<TransformGeometryRequest, TransformGeometryResponse> {

	@Override
	public void execute(TransformGeometryRequest request, TransformGeometryResponse response) throws Exception {
		Crs sourceCrs = geoService.getCrs2(request.getSourceCrs());
		Crs targetCrs = geoService.getCrs2(request.getTargetCrs());
		CrsTransform transform = geoService.getCrsTransform(sourceCrs, targetCrs);

		if (request.getBounds() != null) {
			Envelope source = converter.toInternal(request.getBounds());
			Envelope target = geoService.transform(source, transform);
			response.setBounds(converter.toDto(target));
		}

		if (request.getGeometry() != null) {
			Geometry source = converter.toInternal(request.getGeometry());
			Geometry target = geoService.transform(source, transform);
			response.setGeometry(converter.toDto(target));
		}

		if (request.getGeometryCollection() != null) {
			for (org.geomajas.geometry.Geometry geometry : request.getGeometryCollection()) {
				Geometry source = converter.toInternal(geometry);
				Geometry target = geoService.transform(source, transform);
				response.getGeometryCollection().add(converter.toDto(target));
			}
		}
	}

}