Re: [Geotools-gt2-users] Transforming incoming layers
So i tried it with Swing and Quickstart and it works fine with Shapefiles. With WMSLayer on the other hand, i can't get it to work, even with Swing. For some reason i need the line mapcontent.getViewport.setBounds(displaylayer.getBounds()), so the WMSLayer is rendered without exceptions. Without it, the CRS doesn't change, but also the WMSLayer isn't displayed, and it crashes after clicking zoom extent. If you would be so kind, and have a look at this, maybe you can tell me how to be able to render the wmslayer without changing the CRS, which i assume setting the bounds of the viewport to the layerbounds does. public class WMSLab extends JFrame { public static void main(String[] args) throws Exception { WebMapServer wms = new WebMapServer(new URL(" https://sgx.geodatenzentrum.de/wms_clc5_2018";)); List wmsLayers = WMSLayerChooser.showSelectLayer(wms); if (wmsLayers == null) { JOptionPane.showMessageDialog(null, "Could not connect - check url"); System.exit(0); } MapContent mapContent = new MapContent(); mapContent.setTitle(wms.getCapabilities().getService().getTitle()); mapContent.getViewport().setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); System.out.println("before adding layer " + mapcontent.getViewport().getCoordinateReferenceSystem()); for (Layer wmsLayer : wmsLayers) { WMSLayer displayLayer = new WMSLayer(wms, wmsLayer); mapContent.addLayer(displayLayer); //try with and without this line mapContent.getViewport().setBounds(displayLayer.getBounds()); } System.out.println("after adding layer " + mapcontent.getViewport().getCoordinateReferenceSystem()); JMapFrame.showMap(mapContent); } } Am Mi., 9. Dez. 2020 um 15:40 Uhr schrieb Ian Turton : > Sorry, I always assume people are using the supported modules unless they > say otherwise. I've no idea what SWT does. > > Ian > > On Wed, 9 Dec 2020 at 14:38, Jonas Schrottenbaum < > jonesang...@googlemail.com> wrote: > >> The quickstart is with the swing module, right? I'm using SWT, so maybe >> there is the problem. Thanks for your help so far. Have to look into that. >> >> Am Mi., 9. Dez. 2020 um 15:37 Uhr schrieb Ian Turton > >: >> >>> I've just experimented with adding the line >>> >>> >>> map.getViewport().setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); >>> >>> at line 53 of the GeoTools quickstart and opening a shapefile in >>> EPSG:27700, the map is displayed in EPSG:4326 when the display is made >>> visible. >>> >>> Ian >>> >>> On Wed, 9 Dec 2020 at 14:19, Jonas Schrottenbaum < >>> jonesang...@googlemail.com> wrote: >>> So i also tried mapPane.setCrs(CRS.decode("EPSG:4326")) and mapContent.getViewport().setCoordinateReferenceSystem(CRS.decode("EPSG:4326")), which both change the CRS you get by calling mapContent.getCoordinateReferenceSystem(), but as soon as the first layer comes, it overwrites it with it's own (EPSG:23700) Am Mi., 9. Dez. 2020 um 14:50 Uhr schrieb Jonas Schrottenbaum < jonesang...@googlemail.com>: > Oh, how do i set the map CRS? I thought it was > mapPane.setCRS(DefaultGeographicCRS.WGS84) but that had no effect. > > Am Mi., 9. Dez. 2020 um 14:43 Uhr schrieb Ian Turton < > ijtur...@gmail.com>: > >> You can set the map CRS to what ever you want, if you don't specify >> it then it defaults to the first layer's CRS >> >> Ian >> >> On Wed, 9 Dec 2020 at 13:33, Jonas Schrottenbaum via >> GeoTools-GT2-Users wrote: >> >>> Hello, >>> >>> is it possible to transform all incoming layers into for example >>> epsg:4326? >>> So no matter what the CRS of a WMSLayer, or FeatureLayer is, they >>> can always be overlaid? >>> >>> Default seems to be that the first incoming layer specifies which >>> CRS is used, and all other layers coming after that are transformed into >>> the CRS of the first one. >>> >>> Best regards >>> ___ >>> GeoTools-GT2-Users mailing list >>> GeoTools-GT2-Users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >>> >> >> >> -- >> Ian Turton >> > >>> >>> -- >>> Ian Turton >>> >> > > -- > Ian Turton > ___ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] Transforming incoming layers
Sorry, I always assume people are using the supported modules unless they say otherwise. I've no idea what SWT does. Ian On Wed, 9 Dec 2020 at 14:38, Jonas Schrottenbaum wrote: > The quickstart is with the swing module, right? I'm using SWT, so maybe > there is the problem. Thanks for your help so far. Have to look into that. > > Am Mi., 9. Dez. 2020 um 15:37 Uhr schrieb Ian Turton : > >> I've just experimented with adding the line >> >> >> map.getViewport().setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); >> >> at line 53 of the GeoTools quickstart and opening a shapefile in >> EPSG:27700, the map is displayed in EPSG:4326 when the display is made >> visible. >> >> Ian >> >> On Wed, 9 Dec 2020 at 14:19, Jonas Schrottenbaum < >> jonesang...@googlemail.com> wrote: >> >>> So i also tried mapPane.setCrs(CRS.decode("EPSG:4326")) >>> and >>> mapContent.getViewport().setCoordinateReferenceSystem(CRS.decode("EPSG:4326")), >>> which both change the CRS you get by >>> calling mapContent.getCoordinateReferenceSystem(), but as soon as the first >>> layer comes, it overwrites it with it's own (EPSG:23700) >>> >>> Am Mi., 9. Dez. 2020 um 14:50 Uhr schrieb Jonas Schrottenbaum < >>> jonesang...@googlemail.com>: >>> Oh, how do i set the map CRS? I thought it was mapPane.setCRS(DefaultGeographicCRS.WGS84) but that had no effect. Am Mi., 9. Dez. 2020 um 14:43 Uhr schrieb Ian Turton < ijtur...@gmail.com>: > You can set the map CRS to what ever you want, if you don't specify it > then it defaults to the first layer's CRS > > Ian > > On Wed, 9 Dec 2020 at 13:33, Jonas Schrottenbaum via > GeoTools-GT2-Users wrote: > >> Hello, >> >> is it possible to transform all incoming layers into for example >> epsg:4326? >> So no matter what the CRS of a WMSLayer, or FeatureLayer is, they can >> always be overlaid? >> >> Default seems to be that the first incoming layer specifies which CRS >> is used, and all other layers coming after that are transformed into the >> CRS of the first one. >> >> Best regards >> ___ >> GeoTools-GT2-Users mailing list >> GeoTools-GT2-Users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >> > > > -- > Ian Turton > >> >> -- >> Ian Turton >> > -- Ian Turton ___ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] Transforming incoming layers
The quickstart is with the swing module, right? I'm using SWT, so maybe there is the problem. Thanks for your help so far. Have to look into that. Am Mi., 9. Dez. 2020 um 15:37 Uhr schrieb Ian Turton : > I've just experimented with adding the line > > map.getViewport().setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); > > at line 53 of the GeoTools quickstart and opening a shapefile in > EPSG:27700, the map is displayed in EPSG:4326 when the display is made > visible. > > Ian > > On Wed, 9 Dec 2020 at 14:19, Jonas Schrottenbaum < > jonesang...@googlemail.com> wrote: > >> So i also tried mapPane.setCrs(CRS.decode("EPSG:4326")) >> and >> mapContent.getViewport().setCoordinateReferenceSystem(CRS.decode("EPSG:4326")), >> which both change the CRS you get by >> calling mapContent.getCoordinateReferenceSystem(), but as soon as the first >> layer comes, it overwrites it with it's own (EPSG:23700) >> >> Am Mi., 9. Dez. 2020 um 14:50 Uhr schrieb Jonas Schrottenbaum < >> jonesang...@googlemail.com>: >> >>> Oh, how do i set the map CRS? I thought it was >>> mapPane.setCRS(DefaultGeographicCRS.WGS84) but that had no effect. >>> >>> Am Mi., 9. Dez. 2020 um 14:43 Uhr schrieb Ian Turton >> >: >>> You can set the map CRS to what ever you want, if you don't specify it then it defaults to the first layer's CRS Ian On Wed, 9 Dec 2020 at 13:33, Jonas Schrottenbaum via GeoTools-GT2-Users wrote: > Hello, > > is it possible to transform all incoming layers into for example > epsg:4326? > So no matter what the CRS of a WMSLayer, or FeatureLayer is, they can > always be overlaid? > > Default seems to be that the first incoming layer specifies which CRS > is used, and all other layers coming after that are transformed into the > CRS of the first one. > > Best regards > ___ > GeoTools-GT2-Users mailing list > GeoTools-GT2-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > -- Ian Turton >>> > > -- > Ian Turton > ___ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] Transforming incoming layers
I've just experimented with adding the line map.getViewport().setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); at line 53 of the GeoTools quickstart and opening a shapefile in EPSG:27700, the map is displayed in EPSG:4326 when the display is made visible. Ian On Wed, 9 Dec 2020 at 14:19, Jonas Schrottenbaum wrote: > So i also tried mapPane.setCrs(CRS.decode("EPSG:4326")) > and > mapContent.getViewport().setCoordinateReferenceSystem(CRS.decode("EPSG:4326")), > which both change the CRS you get by > calling mapContent.getCoordinateReferenceSystem(), but as soon as the first > layer comes, it overwrites it with it's own (EPSG:23700) > > Am Mi., 9. Dez. 2020 um 14:50 Uhr schrieb Jonas Schrottenbaum < > jonesang...@googlemail.com>: > >> Oh, how do i set the map CRS? I thought it was >> mapPane.setCRS(DefaultGeographicCRS.WGS84) but that had no effect. >> >> Am Mi., 9. Dez. 2020 um 14:43 Uhr schrieb Ian Turton > >: >> >>> You can set the map CRS to what ever you want, if you don't specify it >>> then it defaults to the first layer's CRS >>> >>> Ian >>> >>> On Wed, 9 Dec 2020 at 13:33, Jonas Schrottenbaum via GeoTools-GT2-Users < >>> geotools-gt2-users@lists.sourceforge.net> wrote: >>> Hello, is it possible to transform all incoming layers into for example epsg:4326? So no matter what the CRS of a WMSLayer, or FeatureLayer is, they can always be overlaid? Default seems to be that the first incoming layer specifies which CRS is used, and all other layers coming after that are transformed into the CRS of the first one. Best regards ___ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >>> >>> >>> -- >>> Ian Turton >>> >> -- Ian Turton ___ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] Transforming incoming layers
Now i set the viewport to be non-editable, which finally results in the CRS staying epsg:4326, but also results in the WMSLayer not being able to render with this exception: Dez. 09, 2020 3:26:38 PM org.geotools.renderer.lite.StreamingRenderer$RenderCoverageReaderRequest execute WARNING: "Scale" operation`s value for parameter "xScale" is invalid. java.lang.IllegalArgumentException: "Scale" operation`s value for parameter "xScale" is invalid. at javax.media.jai.JAI.createNS(JAI.java:1087) at javax.media.jai.JAI.create(JAI.java:973) at org.geotools.image.ImageWorker.scale(ImageWorker.java:4612) at org.geotools.image.ImageWorker.affine(ImageWorker.java:4549) at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRendererUtilities.affine(GridCoverageRendererUtilities.java:688) at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.affine(GridCoverageRenderer.java:515) at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.symbolize(GridCoverageRenderer.java:442) at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.renderImage(GridCoverageRenderer.java:761) at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.paint(GridCoverageRenderer.java:910) at org.geotools.renderer.lite.StreamingRenderer$RenderCoverageReaderRequest.execute(StreamingRenderer.java:3900) at org.geotools.renderer.lite.StreamingRenderer$PainterThread.run(StreamingRenderer.java:4011) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) at java.base/java.lang.Thread.run(Thread.java:832) Dez. 09, 2020 3:26:38 PM org.geotools.renderer.lite.StreamingRenderer fireErrorEvent SEVERE: "Scale" operation`s value for parameter "xScale" is invalid. java.lang.IllegalArgumentException: "Scale" operation`s value for parameter "xScale" is invalid. at javax.media.jai.JAI.createNS(JAI.java:1087) at javax.media.jai.JAI.create(JAI.java:973) at org.geotools.image.ImageWorker.scale(ImageWorker.java:4612) at org.geotools.image.ImageWorker.affine(ImageWorker.java:4549) at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRendererUtilities.affine(GridCoverageRendererUtilities.java:688) at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.affine(GridCoverageRenderer.java:515) at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.symbolize(GridCoverageRenderer.java:442) at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.renderImage(GridCoverageRenderer.java:761) at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.paint(GridCoverageRenderer.java:910) at org.geotools.renderer.lite.StreamingRenderer$RenderCoverageReaderRequest.execute(StreamingRenderer.java:3900) at org.geotools.renderer.lite.StreamingRenderer$PainterThread.run(StreamingRenderer.java:4011) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) at java.base/java.lang.Thread.run(Thread.java:832) Am Mi., 9. Dez. 2020 um 15:18 Uhr schrieb Jonas Schrottenbaum < jonesang...@googlemail.com>: > So i also tried mapPane.setCrs(CRS.decode("EPSG:4326")) > and > mapContent.getViewport().setCoordinateReferenceSystem(CRS.decode("EPSG:4326")), > which both change the CRS you get by > calling mapContent.getCoordinateReferenceSystem(), but as soon as the first > layer comes, it overwrites it with it's own (EPSG:23700) > > Am Mi., 9. Dez. 2020 um 14:50 Uhr schrieb Jonas Schrottenbaum < > jonesang...@googlemail.com>: > >> Oh, how do i set the map CRS? I thought it was >> mapPane.setCRS(DefaultGeographicCRS.WGS84) but that had no effect. >> >> Am Mi., 9. Dez. 2020 um 14:43 Uhr schrieb Ian Turton > >: >> >>> You can set the map CRS to what ever you want, if you don't specify it >>> then it defaults to the first layer's CRS >>> >>> Ian >>> >>> On Wed, 9 Dec 2020 at 13:33, Jonas Schrottenbaum via GeoTools-GT2-Users < >>> geotools-gt2-users@lists.sourceforge.net> wrote: >>> Hello, is it possible to transform all incoming layers into for example epsg:4326? So no matter what the CRS of a WMSLayer, or FeatureLayer is, they can always be overlaid? Default seems to be that the first incoming layer specifies which CRS is used, and all other layers coming after that are transformed into the CRS of the first one. Best regards ___ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinf
Re: [Geotools-gt2-users] Transforming incoming layers
So i also tried mapPane.setCrs(CRS.decode("EPSG:4326")) and mapContent.getViewport().setCoordinateReferenceSystem(CRS.decode("EPSG:4326")), which both change the CRS you get by calling mapContent.getCoordinateReferenceSystem(), but as soon as the first layer comes, it overwrites it with it's own (EPSG:23700) Am Mi., 9. Dez. 2020 um 14:50 Uhr schrieb Jonas Schrottenbaum < jonesang...@googlemail.com>: > Oh, how do i set the map CRS? I thought it was > mapPane.setCRS(DefaultGeographicCRS.WGS84) but that had no effect. > > Am Mi., 9. Dez. 2020 um 14:43 Uhr schrieb Ian Turton : > >> You can set the map CRS to what ever you want, if you don't specify it >> then it defaults to the first layer's CRS >> >> Ian >> >> On Wed, 9 Dec 2020 at 13:33, Jonas Schrottenbaum via GeoTools-GT2-Users < >> geotools-gt2-users@lists.sourceforge.net> wrote: >> >>> Hello, >>> >>> is it possible to transform all incoming layers into for example >>> epsg:4326? >>> So no matter what the CRS of a WMSLayer, or FeatureLayer is, they can >>> always be overlaid? >>> >>> Default seems to be that the first incoming layer specifies which CRS is >>> used, and all other layers coming after that are transformed into the CRS >>> of the first one. >>> >>> Best regards >>> ___ >>> GeoTools-GT2-Users mailing list >>> GeoTools-GT2-Users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >>> >> >> >> -- >> Ian Turton >> > ___ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] Transforming incoming layers
I usually use something like map.getViewport().setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84); Looking at JCRSPopupMenu shows that they use mapPane.getMapContent().getViewport().setCoordinateReferenceSystem(newCRS); which I suspect boils down to the same thing. Ian On Wed, 9 Dec 2020 at 13:51, Jonas Schrottenbaum wrote: > Oh, how do i set the map CRS? I thought it was > mapPane.setCRS(DefaultGeographicCRS.WGS84) but that had no effect. > > Am Mi., 9. Dez. 2020 um 14:43 Uhr schrieb Ian Turton : > >> You can set the map CRS to what ever you want, if you don't specify it >> then it defaults to the first layer's CRS >> >> Ian >> >> On Wed, 9 Dec 2020 at 13:33, Jonas Schrottenbaum via GeoTools-GT2-Users < >> geotools-gt2-users@lists.sourceforge.net> wrote: >> >>> Hello, >>> >>> is it possible to transform all incoming layers into for example >>> epsg:4326? >>> So no matter what the CRS of a WMSLayer, or FeatureLayer is, they can >>> always be overlaid? >>> >>> Default seems to be that the first incoming layer specifies which CRS is >>> used, and all other layers coming after that are transformed into the CRS >>> of the first one. >>> >>> Best regards >>> ___ >>> GeoTools-GT2-Users mailing list >>> GeoTools-GT2-Users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >>> >> >> >> -- >> Ian Turton >> > -- Ian Turton ___ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] Transforming incoming layers
Oh, how do i set the map CRS? I thought it was mapPane.setCRS(DefaultGeographicCRS.WGS84) but that had no effect. Am Mi., 9. Dez. 2020 um 14:43 Uhr schrieb Ian Turton : > You can set the map CRS to what ever you want, if you don't specify it > then it defaults to the first layer's CRS > > Ian > > On Wed, 9 Dec 2020 at 13:33, Jonas Schrottenbaum via GeoTools-GT2-Users < > geotools-gt2-users@lists.sourceforge.net> wrote: > >> Hello, >> >> is it possible to transform all incoming layers into for example >> epsg:4326? >> So no matter what the CRS of a WMSLayer, or FeatureLayer is, they can >> always be overlaid? >> >> Default seems to be that the first incoming layer specifies which CRS is >> used, and all other layers coming after that are transformed into the CRS >> of the first one. >> >> Best regards >> ___ >> GeoTools-GT2-Users mailing list >> GeoTools-GT2-Users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >> > > > -- > Ian Turton > ___ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] Transforming incoming layers
You can set the map CRS to what ever you want, if you don't specify it then it defaults to the first layer's CRS Ian On Wed, 9 Dec 2020 at 13:33, Jonas Schrottenbaum via GeoTools-GT2-Users < geotools-gt2-users@lists.sourceforge.net> wrote: > Hello, > > is it possible to transform all incoming layers into for example epsg:4326? > So no matter what the CRS of a WMSLayer, or FeatureLayer is, they can > always be overlaid? > > Default seems to be that the first incoming layer specifies which CRS is > used, and all other layers coming after that are transformed into the CRS > of the first one. > > Best regards > ___ > GeoTools-GT2-Users mailing list > GeoTools-GT2-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > -- Ian Turton ___ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
[Geotools-gt2-users] Transforming incoming layers
Hello, is it possible to transform all incoming layers into for example epsg:4326? So no matter what the CRS of a WMSLayer, or FeatureLayer is, they can always be overlaid? Default seems to be that the first incoming layer specifies which CRS is used, and all other layers coming after that are transformed into the CRS of the first one. Best regards ___ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users