@Test public void testTransformBounds() throws Exception { TransformGeometryRequest request = new TransformGeometryRequest(); Bbox origin = new Bbox(10, 30, 10, 10); request.setBounds(origin); request.setSourceCrs(MERCATOR); request.setTargetCrs(LONLAT); TransformGeometryResponse response = (TransformGeometryResponse) dispatcher.execute( TransformGeometryRequest.COMMAND, request, null, "en"); Bbox transformed = response.getBounds(); Assert.assertEquals(8.983152841195215E-5, transformed.getX(), DELTA); Assert.assertEquals(2.6949458522981454E-4, transformed.getY(), DELTA); Assert.assertEquals(1.796630568239043E-4, transformed.getMaxX(), DELTA); Assert.assertEquals(3.593261136397527E-4, transformed.getMaxY(), DELTA); }
@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)); } } }
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)); } } } }
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)); } } }  }
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)); } } }  @Override TransformGeometryRequest getEmptyCommandRequest(); @Override TransformGeometryResponse getEmptyCommandResponse(); @Override void execute(TransformGeometryRequest request, TransformGeometryResponse response); }
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)); } } }  @Override TransformGeometryRequest getEmptyCommandRequest(); @Override TransformGeometryResponse getEmptyCommandResponse(); @Override void execute(TransformGeometryRequest request, TransformGeometryResponse response);  }