TerriaJS / terriajs

A library for building rich, web-based geospatial data platforms.
https://terria.io
Apache License 2.0
1.18k stars 362 forks source link

Generalize test for ncWMS service #1976

Closed rsignell-usgs closed 8 years ago

rsignell-usgs commented 8 years ago

Right now we test for a ncWMS service by seeing if a boxfill/rainbow style is available: https://github.com/TerriaJS/terriajs/blob/c8141034ba1025bcc115a0e2b5b4323b1ee94611/lib/Models/WebMapServiceCatalogItem.js#L367-L368

The thinking was that all ncWMS services would advertise this style, but ncWMS2 (which will be included in the THREDDS Data Server 5.0 when it is officially released) has dropped this style.

Here's an example of a ncWMS2 getCapabilities from a development THREDDS Data Server 5.0:

Perhaps it would be wise to distinguish between ncWMS and ncWMS2 and add a check for a style named default-scalar/default, something like:

            if (!defined(this.isNcWMS2) && myLayer.Style[j].Name && myLayer.Style[j].Name.match(/default\-scalar\/default/i)) {
              this.isNcWMS2 = true;

It seems prudent to identify ncWMS and ncWMS2 separately rather than just represent both as ncWMS, as their capabilities may be different.

@guygriffiths, do you agree?

guygriffiths commented 8 years ago

It sounds like a good idea to keep ncWMS and ncWMS2 separate. There are a few differences and I can't guarantee that ncWMS2 is backwards compatible in every case (e.g. we handle animations differently), so it's probably for the best.

rsignell-usgs commented 8 years ago

@guygriffiths , thanks for chiming in. Is there a better way to distinguish ncWMS and ncWMS2 from other WMS services than just checking for the presence of a specific style?

guygriffiths commented 8 years ago

As far as I'm aware, there isn't anything in the capabilities document which will distinguish ncWMS/ncWMS2 from other WMS services, but you could fire a request to: http://server/ncWMS/wms?SERVICE=WMS&REQUEST=GetMetadata&item=menu That downloads a JSON representation of the of available layers, and is ncWMS-specific - I'd expect an error from any other WMS service.

rsignell-usgs commented 8 years ago

@guygriffiths, ah okay, like this: http://www.smast.umassd.edu:8080/ncWMS2/wms?SERVICE=WMS&REQUEST=GetMetadata&item=menu I'll leave this up to @kring as to whether this is a more or less desirable method.

rsignell-usgs commented 8 years ago

@guygriffiths, could that "GetMetadata" request be advertised in the getCapabilities from ncWMS2?

From section 6.9.5 "Extended capabilities and operations" in http://portal.opengeospatial.org/files/?artifact_id=14416 it seems that's an okay thing to do...

kring commented 8 years ago

@guygriffiths, could that "GetMetadata" request be advertised in the getCapabilities from ncWMS2?

This would be really handy, because then we could detect ncWMS2 much more reliably without needing to do an extra request that will return an error on other WMS servers.

Better yet, that section 6.9.5 leads me to believe there's a way to advertise that the GetMap service allows additional parameters. If the GetCapabilities could tell us that there's a COLORSCALERANGE parameter available, our client could make use of it, and it would work with any (hypothetical) WMS server that supports that parameter, not just ncWMS.

guygriffiths commented 8 years ago

OK, this certainly looks possible, but there doesn't seem to be a standard for describing extended capabilities which would fit (INSPIRE has one, but I don't think it's suitable for describing these extensions). I'll have a think about coming up with an XML schema which we can use and then link to, unless either of you are aware of a standard we can use?

guygriffiths commented 8 years ago

OK, I have implemented this using a custom capabilities extension, which is defined here: http://reading-escience-centre.github.io/edal-java/wms/edal_extended_capabilities.xsd

Testing on a capabilities document, it validates against the OGC schema, and it doesn't seem to have any adverse effect on QGIS. Do either of you use any other WMS clients which parse the GetCapabilities which you could test against (ArcGIS would be ideal, but I don't have a licence)? I'd like to be reasonably confident this isn't going to screw up anyone's system before we release it. Obviously it's in the WMS spec so it should be fine, but it's so rarely used that clients' non-compliance could easily have gone unnoticed up to now.

rsignell-usgs commented 8 years ago

@guygriffiths , is there also an endpoint we could test against?
Or if we deploy the latest war file, will it have these capabilities?

guygriffiths commented 8 years ago

@rsignell-usgs I've just deployed it to our demo server. It only works with 1.3.0 GetCapabilities. You can find it here:

http://godiva.rdg.ac.uk/ncWMS2/wms?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0

rsignell-usgs commented 8 years ago

@kring , can we add this to the logic in TerriaJS?
I say add because it will be a while before all the ncWMS services out there will have this capability...

kring commented 8 years ago

Yes, definitely @rsignell-usgs . Thanks for adding that @guygriffiths, that's fantastic!

rsignell-usgs commented 6 years ago

@guygriffiths I'm looking for an example getcaps that implements this, and http://godiva.rdg.ac.uk/ncWMS2/wms?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0 doesn't seem to be responding anymore. Do you have another URL handy?