You are right, if i change the CRS with the GUI to EPSG:4326, it works. So
i thought, what's the difference between doing it there and
programmatically, where it did not work.
And i found out that apparently DefaultGeographicCRS.WGS84 is not the same
as EPSG:4326. And it does not work with DefaultGeographicCRS.WGS84. At
least there i get an invisible layer.
But now i changed
from 
mapcontent.getViewport().setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);
to 
mapcontent.getViewport().setCoordinateReferenceSystem(CRS.decode("EPSG:4326"));
and now it works perfectly.
Do you know, why this would make a difference and
why DefaultGeographicCRS.WGS84 could result in an invisible layer?

Greeting, Jones

Am Mi., 10. Feb. 2021 um 09:52 Uhr schrieb Ian Turton <ijtur...@gmail.com>:

>
>
> On Tue, 9 Feb 2021 at 18:30, Jonas Schrottenbaum via GeoTools-GT2-Users <
> geotools-gt2-users@lists.sourceforge.net> wrote:
>
>> 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.
>>
>>
> You shouldn't need to do anything to transform the layers, once you change
> the map/viewport crs the layer will automatically change to the new SRS.
> I've just done a quick test and that URL seems to display in all of the
> supported CRS and a few that are not on that list (3875)
>
> Ian
>
>
>> --
> Ian Turton
>
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to