TerriaJS / nationalmap

Australia's NationalMap
https://nationalmap.gov.au
122 stars 45 forks source link

Add support for subsets of WMS datasets #341

Closed adamsteer closed 1 month ago

adamsteer commented 8 years ago

Hi, I just tried to view some data in nationalmap from a WMS service, with a bunch of query parameters to limit the extent and colour scale range:

http://dapds00.nci.org.au/thredds/wms/wx7/aster/vnir/Aus_Mainland/Aus_Mainland_Ferrous_iron_content_in_MgOH_reprojected.nc4?service=WMS&version=1.3.0&request=GetMap&Layers=Ferrous_iron_content_in_MgOH&bbox=-33,147,-32,149&crs=epsg:4326&styles=boxfill/occam&width=512&height=512&format=image/png&colorscalerange=0.1,2&abovemaxcolor=transparent&belowmincolor=transparent

Nationalmaps' interface stripped the query string, and tried to load a 'dumb WMS request'. Please add support for viewing WMS subsets using OGC request protocols (and well known vendor extensions, ie ncwms). Thanks! And congratulations, it's a really cool tool!

adamsteer commented 8 years ago

ps - happy to try and fix it, if anybody can point me at the relevant part of terria.js. Thanks!

kring commented 8 years ago

Hi @adamsteer, thanks for the report and the offer to fix it.

TerriaJS does allow you to specify arbitrary parameters to a WMS, but you need to do it through a JSON init file. The "Add Data" UI does strip all the query parameters before building the URL back up. For example, save this content to a .json file and then drag it onto any TerriaJS map:

{
    "catalog": [
        {
            "type": "group",
            "name": "My Datasets",
            "isPromoted": true,
            "isOpen": true,
            "items": [
                {
                    "name": "Ferrous Iron Content",
                    "type": "wms",
                    "url": "http://dapds00.nci.org.au/thredds/wms/wx7/aster/vnir/Aus_Mainland/Aus_Mainland_Ferrous_iron_content_in_MgOH_reprojected.nc4",
                    "layers": "Ferrous_iron_content_in_MgOH",
                    "parameters": {
                        "styles": "boxfill/occam",
                        "colorscalerange": "0.1,2",
                        "abovemaxcolor": "transparent",
                        "belowmincolor": "transparent"
                    },
                    "isEnabled": true
                }
            ]
        }
    ]
}

Recent versions of TerriaJS also will show UI controls to set the color scale range. And in an upcoming version (soon), the UI will allow you to select the style as well.

Now making this work when you enter a URL in the UI, rather than using the JSON file, is a not entirely trivial because we have to distinguish parameters that the user probably really wants to include (like styles, colorscalerange, etc.) from parameters that will break things if we include them (like bbox, width, and height). We also need to make sure that the user has given us the right type of request. For example, if they've supplied a GetCapabilities URL, we of course wouldn't want to include request=GetCapabilities when requesting map tiles.

So currently we just strip the URL down to its base and then build back up a WMS URL that we are pretty confident will work (even if it misses some of the parameters the user would like to supply). The code that does this is the cleanAndProxyUrl function in WebMapServiceCatalogItem.

If you want to tackle this, we'd certainly consider a pull request!

adamsteer commented 8 years ago

Thanks for the detailed explanation Kevin - all understood.

I have a need to get a national map instance running for testing, and a key capacity is controlling at least the bounding box for some of our curlier datasets - which is tricky since cesium/leaflet calculate their own! Or maybe we can just learn to work within that :)

If I get a solution, very happy to submit a pull request.

Cheers, looking forward to seeing how this develops.

Adam

On 24 Sep 2016 21:39, "Kevin Ring" notifications@github.com wrote:

Hi @adamsteer https://github.com/adamsteer, thanks for the report and the offer to fix it.

TerriaJS does allow you to specify arbitrary parameters to a WMS, but you need to do it through a JSON init file. The "Add Data" UI does strip all the query parameters before building the URL back up. For example, save this content to a .json file and then drag it onto any TerriaJS map:

{ "catalog": [ { "type": "group", "name": "My Datasets", "isPromoted": true, "isOpen": true, "items": [ { "name": "Ferrous Iron Content", "type": "wms", "url": "http://dapds00.nci.org.au/thredds/wms/wx7/aster/vnir/Aus_Mainland/Aus_Mainland_Ferrous_iron_content_in_MgOH_reprojected.nc4", "layers": "Ferrous_iron_content_in_MgOH", "parameters": { "styles": "boxfill/occam", "colorscalerange": "0.1,2", "abovemaxcolor": "transparent", "belowmincolor": "transparent" }, "isEnabled": true } ] } ] }

Recent versions of TerriaJS also will show UI controls to set the color scale range. And in an upcoming version (soon), the UI will allow you to select the style as well.

Now making this work when you enter a URL in the UI, rather than using the JSON file, is a not entirely trivial because we have to distinguish parameters that the user probably really wants to include (like styles, colorscalerange, etc.) from parameters that will break things if we include them (like bbox, width, and height). We also need to make sure that the user has given us the right type of request. For example, if they've supplied a GetCapabilities URL, we of course wouldn't want to include request=GetCapabilities when requesting map tiles.

So currently we just strip the URL down to its base and then build back up a WMS URL that we are pretty confident will work (even if it misses some of the parameters the user would like to supply). The code that does this is the cleanAndProxyUrl function in WebMapServiceCatalogItem https://github.com/TerriaJS/terriajs/blob/master/lib/Models/WebMapServiceCatalogItem.js .

If you want to tackle this, we'd certainly consider a pull request!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TerriaJS/nationalmap/issues/341#issuecomment-249360476, or mute the thread https://github.com/notifications/unsubscribe-auth/AMel1kvOMDt3IMBcNj69ejM6fBcrpdOAks5qtQv7gaJpZM4KEg5v .