Rendering WMS provider output from a specific region

Hello all!

I'm still pretty new to Cesium, and I've been trying to figure out how to properly render maps coming from Web Map Service providers.

For my test, I've set up a Geoserver instance with a map of a specific region, in a local EPSG, which I intend to visualize with Cesium. I've noticed that, if I set up my ImageryLayer as such (I'm using the React.js wrapper for Cesium, by the way):

`<ImageryLayer
   key={product.id}
   imageryProvider={new WebMapServiceImageryProvider({
                      url: product.data.url,
                      layers: product.data.layers
                      }
                    )}
/>`

the resulting layer seems to be a layer covering the entire world. Since my map only exists in a very specific region, I get a lot of WMS GET requests that simply return empty tiles, followed by a console error stating:

"An error occurred in "WebMapServiceImageryProvider": Failed to obtain image tile X"

Furthermore, I'm suspicious that there might be some conversion issues among different CRSs. The HTTP requests Cesium makes seem to use the EPSG 4326 as default, which is not the EPSG my map was initially stored in the Geoserver. Should the WMS be able to handle this conversion automatically?

In conclusion, I'm trying to understand if there's a more appropriate way of achieving rendering of WMS maps in a very specific region of the globe. Is there a way to constrain the fetching area to the map's area of interest?

Any help is appreciated.
Thanks in advance.

terça-feira, 18 de Dezembro de 2018 às 10:26:26 UTC, Jpac escreveu:

Hello all!

I'm still pretty new to Cesium, and I've been trying to figure out how to properly render maps coming from Web Map Service providers.

For my test, I've set up a Geoserver instance with a map of a specific region, in a local EPSG, which I intend to visualize with Cesium. I've noticed that, if I set up my ImageryLayer as such (I'm using the React.js wrapper for Cesium, by the way):

`<ImageryLayer
   key={product.id}
   imageryProvider={new WebMapServiceImageryProvider({
                      url: product.data.url,
                      layers: product.data.layers
                      }
                    )}
/>`

the resulting layer seems to be a layer covering the entire world. Since my map only exists in a very specific region, I get a lot of WMS GET requests that simply return empty tiles, followed by a console error stating:

"An error occurred in "WebMapServiceImageryProvider": Failed to obtain image tile X"

Furthermore, I'm suspicious that there might be some conversion issues among different CRSs. The HTTP requests Cesium makes seem to use the EPSG 4326 as default, which is not the EPSG my map was initially stored in the Geoserver. Should the WMS be able to handle this conversion automatically?

In conclusion, I'm trying to understand if there's a more appropriate way of achieving rendering of WMS maps in a very specific region of the globe. Is there a way to constrain the fetching area to the map's area of interest?

Any help is appreciated.
Thanks in advance.

Just a small update on my issue:

I enabled CORS in my GeoServer instance, and the "Failed to obtain image tile" error has now disappeared. Instead, when I add my WMS provider, I now get my Cesium map completely filled with the empty white tiles.

Welcome to the Cesium community!

You should be able to constrain the area your imagery is in by passing in a “rectangle” parameter the WebMapServiceImageryProvider constructor:

https://cesiumjs.org/Cesium/Build/Documentation/Rectangle.html

which should define the area it’s expected to cover. I think there was some discussion about whether CesiumJS can guess that from the WMS’s metadata but I think the conclusion was there wasn’t a standard way to define that in the metadata so the engine leaves that up to the user.

In terms of projections, I believe (although have not personally confirmed) that the Geoserver should be able to reproject and send the right thing to Cesium. CesiumJS currently only supports Web Mercator and EPSG 4326. This GitHub issue has some discussion on supporting more:

https://github.com/AnalyticalGraphicsInc/cesium/issues/3877

terça-feira, 18 de Dezembro de 2018 às 21:47:56 UTC, Omar Shehata escreveu:

Welcome to the Cesium community!

You should be able to constrain the area your imagery is in by passing in a "rectangle" parameter the WebMapServiceImageryProvider constructor:

https://cesiumjs.org/Cesium/Build/Documentation/Rectangle.html

which should define the area it's expected to cover. I think there was some discussion about whether CesiumJS can guess that from the WMS's metadata but I think the conclusion was there wasn't a standard way to define that in the metadata so the engine leaves that up to the user.

In terms of projections, I believe (although have not personally confirmed) that the Geoserver should be able to reproject and send the right thing to Cesium. CesiumJS currently only supports Web Mercator and EPSG 4326. This GitHub issue has some discussion on supporting more:

different projections · Issue #3877 · CesiumGS/cesium · GitHub

On Tuesday, December 18, 2018 at 5:26:26 AM UTC-5, Jpac wrote:Hello all!
I'm still pretty new to Cesium, and I've been trying to figure out how to properly render maps coming from Web Map Service providers.
For my test, I've set up a Geoserver instance with a map of a specific region, in a local EPSG, which I intend to visualize with Cesium. I've noticed that, if I set up my ImageryLayer as such (I'm using the React.js wrapper for Cesium, by the way):
`<ImageryLayer
key={product.id}
imageryProvider={new WebMapServiceImageryProvider({
url: product.data.url,
layers: product.data.layers
}
)}
/>`
the resulting layer seems to be a layer covering the entire world. Since my map only exists in a very specific region, I get a lot of WMS GET requests that simply return empty tiles, followed by a console error stating:
"An error occurred in "WebMapServiceImageryProvider": Failed to obtain image tile X"
Furthermore, I'm suspicious that there might be some conversion issues among different CRSs. The HTTP requests Cesium makes seem to use the EPSG 4326 as default, which is not the EPSG my map was initially stored in the Geoserver. Should the WMS be able to handle this conversion automatically?
In conclusion, I'm trying to understand if there's a more appropriate way of achieving rendering of WMS maps in a very specific region of the globe. Is there a way to constrain the fetching area to the map's area of interest?
Any help is appreciated.
Thanks in advance.

Hello, Omar! Thank you for your reply.

I was also looking at the "rectangle" parameter as a possible way to constrain the area. I was hoping, as you mentioned, that Cesium could take some sort of WMS metadata and optimize the area of interest, since I was intending to import region data without knowing the area of interest à-priori.

I'll try and find another way around it. Thanks again!

I’m happy to help!

I found the earlier discussion I was talking about:

https://groups.google.com/d/msg/cesium-dev/2RIy0dYR1ps/NpOh7CvPAQAJ

It might be helpful to look at Kevin’s response there. Here’s the maintainer of TerriaJS which builds on Cesium and I think does have a way of obtaining the area from a WMS document.