Search code examples
angularcesiumjs

How to get boundary box corner in CRS units in Cesium?


For my project, I am using cesium to display on a map WMS layers (On 2D map). To increase performances, I use the provider SingleTileImageryProvider to request an only tile.

The point is : the request need a parameter called "BBOX" which corresponds to boundary box corner in CRS units.

I am wondering how can I get these values to request the entire shown part of the map.

For instance, I was using WebMapServiceImageryProvider before and Cesium was attributing this BBOX automaticaly to each tile. But it does not work with SingleTileImageryProvider.

An other solution could be requesting the entire WMS Layer, in spite of hidden parts.

I saw a lot of things on internet, but nothing to answer my question.

I someone could help me, please.

Thank you all.


Solution

  • I've finally found a solution. If the entire screen is covered by visible map area, i am using upper rigth and lower left corner to find coordinates. First I get my points in pixel on the screen. Then, I use

      `viewer.camera.getPickRay(position)`
    

    which creates a ray from camera and pixel point. Finally, I get intersection between both ray and globe and get a 3D points in WGS84 by using

     `viewer.scene.globe.pick(ray, viewer.scene)`
    

    Otherwise, if the visible map area does not covered entire screen, I am using the limit bounding box of the chosen layer, given by the GetCapabilities, to create Cesium.Rectangle and use it.

    It is working fine for 2D and 3D. and for SingleTileImageryProvider use