Hello, how can i transform a WMSLayer, or Layer from a WMS into a different CRS? I read how to transform JTS Geometries and how to transform GridCoverages, but could not find any information on how to do this with WMSLayers.
So i start by getting the Layers from the service and setting the desired CRS at the viewport. But how do i transform the layers now? I already heard, that the transformation should be done if the CRS is set, before the Layer is added. But trying this results in an invisible layer, so i assume no transformation was done. I could only fix visibility by adding mapcontent.getViewport().setBounds(displayLayer.getBounds()); but this sets the CRS right back to the original CRS of the WMS Layer. WebMapServer wms = new WebMapServer(new URL(" https://www.geoportal-gruenheide.de/isk/grue_fp01?")); List<Layer> wmsLayers = WMSLayerChooser.showSelectLayer(wms); MapContent mapcontent = new MapContent(); mapcontent.getViewport().setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); for (Layer wmsLayer : wmsLayers) { WMSLayer displayLayer = new WMSLayer(wms, wmsLayer); final CoordinateReferenceSystem targetCRS = DefaultGeographicCRS.WGS84; // transform the displayLayer, so it is in the targetCRS mapcontent.addLayer(displayLayer); } JMapFrame.showMap(mapcontent); I also tried to transform the Geometries, but that did not work at all: final SimpleFeatureIterator sFeatureIt = displayLayer.toFeatureCollection().features(); while (sFeatureIt.hasNext()) { final SimpleFeature sFeature = sFeatureIt.next(); final Geometry geometry = JTS.transform((Geometry) sFeature.getDefaultGeometry(), CRS.findMathTransform(displayLayer.getCoordinateReferenceSystem(), targetCRS)); sFeature.setDefaultGeometry(geometry); } I thought about getting the GridCoverage from the Layer, to transform it via resample, but could not find a way to do that either. Or do i need to write a custom getMap request to set the CRS parameter to what i want, because transformation afterwards is not possible? Greetings, Jones
_______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users