OpenLayers OpenLayers

Ticket #1176 (closed feature: fixed)

Opened 2 years ago

Last modified 8 months ago

Add WMSCapabilities format

Reported by: tschaub Assigned to: ahocevar
Priority: minor Milestone: 2.8 Release
Component: Format Version: SVN
Keywords: Cc:
State: Complete

Description

A format to read WMS capabilities docs would be nice. Should support multiple versions.

Attachments

wms_capabilities.patch (8.0 kB) - added by tschaub on 11/27/07 13:26:48.
wms capabilities parsing
WMSCapabilities.patch (12.4 kB) - added by openlayers on 08/04/08 10:00:26.
wms capabilities parsing
Capabilities.patch (40.2 kB) - added by openlayers on 08/07/08 10:27:50.
wmscap.patch (13.2 kB) - added by tschaub on 03/23/09 17:43:53.
wms capabilities
wmscap.2.patch (204.9 kB) - added by tschaub on 04/03/09 16:52:16.
wms capabilities parsing

Change History

11/27/07 13:26:48 changed by tschaub

  • attachment wms_capabilities.patch added.

wms capabilities parsing

12/15/07 15:56:35 changed by crschmidt

  • state set to Needs More Work.
  • milestone set to 2.6 Release.

I'd prefer to have the versioned copies in a subdirectory: Format/WMSCapabiities/1.1.1.js . Other than that, this looks fine.

12/21/07 15:20:11 changed by elemoine

I'm not too sure with the inheritance logic of this patch. I don't see why WMSCapabilities_1_1_1 needs to inherit from WMSCapabilities. I'd rather see WMSCapabilities_1_1_1 inherit from XMS and WMSCapabilities.just composes WMSCapabilities_1_1_1. I might be wrong...

12/21/07 15:22:37 changed by tschaub

Yeah, I should pull this patch. The idea was that eventually we could support all versions. I thought it would make sense to have common code on the WMSCapabilities class. Then versions could first inherit from WMSCapabilities, then from a major version, then from a minor version, etc. It's not complete as is.

12/21/07 15:23:18 changed by tschaub

I'll be submitting a WMC patch soon that does a better job at this.

02/07/08 11:27:16 changed by crschmidt

  • milestone changed from 2.6 Release to 2.7 Release.

07/03/08 23:13:00 changed by euzuro

  • milestone changed from 2.7 Release to 2.8 Release.

Mass ticket move out of 2.7 in preparation for a release plan.

If you are actively working on this task, and think that you can help this ticket to get finished and closed by September 1, please move it back to 2.7.

08/04/08 10:00:26 changed by openlayers

  • attachment WMSCapabilities.patch added.

wms capabilities parsing

08/04/08 10:01:53 changed by openlayers

This patch extends the work of tschaub.

UPDATE:

  • the class is built like the OpenLayers.Format.WMC class
  • inheritance improvement
  • some new nodes are supported

TODO:

  • do not follow node order (inheritance problem)
  • WMS 1.3.0 support
  • How to support the WMF GetCapabilities whithout code duplication ? WFSCapabilities is close to WFSCapabilities

EXAMPLE:

this.request = OpenLayers.Request.GET({
    url: "http://world.freemap.in/cgi-bin/mapserv?map=/www/freemap.in/world/map/factbook.map&request=GetCapabilities&version=1.1.1&service=WMS",
    success: function(response) {
        var XMLformat = new OpenLayers.Format.XML();
        xml = XMLformat.read(response.responseText);
        
        var CAPformat = new OpenLayers.Format.WMSCapabilities();
        capabilities = CAPformat.read(xml);
        
        window.console.log(capabilities);
    }
});

08/07/08 10:27:16 changed by openlayers

  • state changed from Needs More Work to Awaiting User Feedback.
  • version changed from 2.5 to SVN.
  • summary changed from Add WMS Capabilities format to Add Capabilities format.

I add a patch with support of:

  • WMS Capabilities v1.1.1
  • WMS Capabilities v1.3.0
  • WFS Capabilities v1.0.0
  • WFS Capabilities v1.1.0

To try, you can use:

Output data schemes are described in documentation of OpenLayers.Format.WMSCapabilities and OpenLayers.Format.WFSCapabilities classes.

08/07/08 10:27:50 changed by openlayers

  • attachment Capabilities.patch added.

03/01/09 20:36:08 changed by crschmidt

  • milestone changed from 2.8 Release to 2.9 Release.

Not touched since 2.7, bumping.

03/13/09 18:42:32 changed by tschaub

  • summary changed from Add Capabilities format to Add WMSCapabilities format.

03/23/09 17:38:32 changed by tschaub

(In [9125]) parsing queryable attribute from capabilities (diff from r8992). (see #1176)

03/23/09 17:43:53 changed by tschaub

  • attachment wmscap.patch added.

wms capabilities

03/31/09 17:17:38 changed by tschaub

  • status changed from new to assigned.
  • milestone changed from 2.9 Release to 2.8 Release.

04/03/09 16:52:16 changed by tschaub

  • attachment wmscap.2.patch added.

wms capabilities parsing

04/03/09 16:54:56 changed by tschaub

  • state changed from Awaiting User Feedback to Review.

Here's what I think about this: this format could be enhanced. I'd like to rewrite it to the new style. It could use more options. It could maintain a representation of the layer hierarchy in the capabilities doc by having a "parents" property (array) or other. It could parse srs (and have an option not to).

All of those things can come later. Until then, I think this makes a good addition.

Tests pass in FF3. Will report on IE later. Thanks for any review.

04/03/09 18:55:08 changed by tschaub

  • owner changed from tschaub to ahocevar.
  • status changed from assigned to new.

Tests pass in IE6 as well (though the browser nearly kicks the bucket while parsing that doc). Will happily commit with review. (Only assigning to ahocevar in hopes of a review. If anybody else can review, please do.)

(follow-up: ↓ 16 ) 04/04/09 18:37:49 changed by rdewit

Hi Tim,

The naming convention you use seems a bit odd to me (compared to other OL Classes): read_cap_Capability, read_cap_Request, etc. Wouldn't it be more intuitive to have something like below?

readers: {
  Capability: function () ..,
  Request: function ()...
}

And then you'd use something like this:

processor = this.readers[childNode.nodeName]; 

'readers' is probably not the correct term (I stole it from GML), but you get my point.

(in reply to: ↑ 15 ) 04/05/09 21:23:11 changed by tschaub

Replying to rdewit:

Hi Tim, The naming convention you use seems a bit odd to me (compared to other OL Classes): read_cap_Capability, read_cap_Request, etc. Wouldn't it be more intuitive to have something like below? {{{ readers: { Capability: function () .., Request: function ()... } }}} And then you'd use something like this: {{{ processor = this.readers[childNode.nodeName]; }}} 'readers' is probably not the correct term (I stole it from GML), but you get my point.

Yeah, this is what I meant by wanting to rewrite this in the "new style." I originally wrote things this way for the WMC format. And continued this style for a couple other formats. Then decided that having readers and writers objects with properties for each namespace made for more reusable code. So, yes, the new GML formats, the Filter formats, and the SLD format all have the style that I'd like to continue using for XML based formats. This is particularly useful for formats that might be extended/mixed. Less important for something like the WMS capabilities format - but the format could share some of the base XML methods if it were rewritten.

Anyway, that's the part that can come later. These aren't API methods.

04/06/09 13:50:11 changed by ahocevar

  • state changed from Review to Commit.

Looks good! Please commit.

04/06/09 13:55:21 changed by tschaub

  • status changed from new to closed.
  • state changed from Commit to Complete.
  • resolution set to fixed.

(In [9212]) Adding a format for parsing WMS capabilities docs. r=ahocevar (closes #1176)

(follow-up: ↓ 21 ) 07/18/09 16:47:06 changed by overstdr

All,

Just a minor bug I found while working with the min/max scales for the WMSCapabilities. It looks like they are being reversed within the function read_cap_ScaleHint.

Should be able to just swap line 182 and 185.

layer.maxScale = parseFloat(
     ((rad2 * min) * ipm * OpenLayers.DOTS_PER_INCH).toPrecision(13)
);
layer.minScale = parseFloat(
     ((rad2 * max) * ipm * OpenLayers.DOTS_PER_INCH).toPrecision(13)
);

The min is just being applied to the max. Simple fix below:

layer.maxScale = parseFloat(
     ((rad2 * min) * ipm * OpenLayers.DOTS_PER_INCH).toPrecision(13)
);
layer.minScale = parseFloat(
     ((rad2 * max) * ipm * OpenLayers.DOTS_PER_INCH).toPrecision(13)
);

Thanks,

Dave O

07/18/09 16:47:59 changed by overstdr

And by simple fix, I mean:

layer.maxScale = parseFloat(
     ((rad2 * max) * ipm * OpenLayers.DOTS_PER_INCH).toPrecision(13)
);
layer.minScale = parseFloat(
     ((rad2 * min) * ipm * OpenLayers.DOTS_PER_INCH).toPrecision(13)
);

(in reply to: ↑ 19 ) 07/19/09 05:12:52 changed by bartvde

Replying to overstdr:

All, Just a minor bug I found while working with the min/max scales for the WMSCapabilities. It looks like they are being reversed within the function read_cap_ScaleHint. Should be able to just swap line 182 and 185. {{{ layer.maxScale = parseFloat( ((rad2 * min) * ipm * OpenLayers.DOTS_PER_INCH).toPrecision(13) ); layer.minScale = parseFloat( ((rad2 * max) * ipm * OpenLayers.DOTS_PER_INCH).toPrecision(13) ); }}} The min is just being applied to the max. Simple fix below: {{{ layer.maxScale = parseFloat( ((rad2 * min) * ipm * OpenLayers.DOTS_PER_INCH).toPrecision(13) ); layer.minScale = parseFloat( ((rad2 * max) * ipm * OpenLayers.DOTS_PER_INCH).toPrecision(13) ); }}} Thanks, Dave O

Nope, that is the way it should be. OGC minScaleDenominator should map to OL maxScale. In OGC maxScaleDenominator is > minScaleDenominator, but in OL minScale is > maxScale (see e.g. http://trac.openlayers.org/wiki/SettingZoomLevels)

07/20/09 09:02:09 changed by overstdr

Ahh...good call! Ignore my previous comments. I thought they were supposed to match the OGC denominators. Thank you for pointing this out bartvde.