Adding Custom WebMapServiceImageryProvider ,How to set the local coordinate and EPSG:3067

Hi,

I am trying to add local tiles with EPSG:3067 here is the code. The problem is it is requesting with EPSG::4326 with lat lon bbox while i want it to be in local coordinates system which EPSG:3067

**Code***
var url=‘https://ws.nls.fi/rasteriaineistot/image?service=WMS&version=1.1.1&request=GetMap&userId=testuser&format=’; //Geoserver URL
var layers = viewer.imageryLayers;
    layers.removeAll();
    layers.addImageryProvider(new Cesium.WebMapServiceImageryProvider({
        url : url,
         parameters: {
                                 
                                crs: ‘EPSG:3067’
                        } ,
        tileWidth:256,
        tileHeight:256,
        layers: ‘ortokuvat’// Here just give layer name
    }));

**error in the network tab for each tile***

Here is the error because it request for the tile as Request URL:https://ws.nls.fi/rasteriaineistot/image?crs=EPSG%3A3067&service=WMS&version=1.1.1&request=GetMap&styles=&format=image%2Fjpeg&userId=testuser&layers=ortokuvat&srs=EPSG%3A4326&bbox=24.867553710937504%2C60.30944824218751%2C24.87030029296875%2C60.31219482421875&width=256&height=256
Request Method:GET
Status Code:401 Authorization Required

************The correct format **********

https://ws.nls.fi/rasteriaineistot/image?service=WMS&version=1.1.1&request=GetMap&userId=testuser&width=256&height=256&format=image%2Fpng&layers=ortokuvat&styles=normal&srs=EPSG%3A3067&bbox=364000%2C6909000%2C366000%2C6911133

In your code sample you’re setting the parameter ‘crs’ instead of ‘srs’. I believe this is your problem. If that’s still not working you may need to define your own TileScheme that you can pass to the new Cesium.WebMapServiceImageryProvider

Hi, yes srs error is solved but now the bbox is still in wgs84 i.e in lat lon i need to be in local coordinates. could you please tell me how to specify this in code? thanks :slight_smile:

The Bounding Box is generated from the TilingScheme that is passed in during creation. EPSG:3067 is not a predefined tiling scheme so you’re going to need to create your own.

http://cesiumjs.org/Cesium/Build/Documentation/WebMapServiceImageryProvider.html?classFilter=webMap

Requesting the tiles in the right projection is only half the battle. You also need to make sure that Cesium knows how to map them onto the globe or else they will be georeferenced incorrectly. This is going to be a lot of work.

If at all possible, I recommend using a WMS server that can serve map images in geographic (EPSG:436) or Web Mercator (EPSG:3857). Pretty much all standard WMS servers can do this, and it will save you many many hours of headaches.

Kevin

If its coming from geoserver, you should be able to have the server reproject to 4326 or 3857, instead of trying to load it in its native format.

Saving many hours of headaches, does this means its possible? and has anyone come up with an example.

First part of the problem will be getting past the issue of this guard: https://github.com/AnalyticalGraphicsInc/cesium/blob/1.12/Source/Scene/WebMapTileServiceImageryProvider.js#L133

Gonna use another day try to get a custom projection running myself but hoping someone has tried and succeded.