OpenLayers OpenLayers

Ticket #100 (closed feature: fixed)

Opened 2 years ago

Last modified 10 months ago

create a WMC parser

Reported by: hobu@hobu.net Assigned to: tschaub
Priority: minor Milestone: 2.6 Release
Component: Format.WMC Version:
Keywords: Cc:
State: Complete

Description (Last modified by tschaub)

A WMC parser would allow us to restore map context, merge context with another map, or persist map context (with WMS layers).

Attachments

wmc.patch (56.9 kB) - added by tschaub on 01/24/08 19:18:07.
read/write wmc 1.0.0 and 1.1.0

Change History

06/26/06 13:54:43 changed by sderle

Steven Ottens also recommended looking at OWSContext documents (#106).

06/26/06 13:54:53 changed by sderle

  • milestone set to Farallon Islands.

08/16/06 00:23:48 changed by euzuro

  • milestone deleted.

10/25/06 06:32:56 changed by euzuro

  • owner changed.
  • component changed from general to Map.

11/16/06 15:02:15 changed by tschaub

  • owner set to tschaub.

I'll take this on unless others don't think it's a good idea. I'm already working on something similar - and it would fit nicely in OL.

03/09/07 17:31:08 changed by sderle

  • milestone set to 2.5 Release.

08/03/07 10:55:33 changed by crschmidt

  • milestone changed from 2.5 Release to 2.6 Release.

12/20/07 23:14:47 changed by crschmidt

  • state changed.
  • milestone changed from 2.6 Release to 2.7 Release.

I haven't seen much evidence that this is likely to make an (at this point arbitrarily guessed) release date for 2.6. With that in mind, I'm bumping it forward -- but not to Future, since I know it's being worked on in sandboxes.

01/03/08 02:23:57 changed by tschaub

As an update, my wmc sandbox (http://dev.openlayers.org/sandbox/tschaub/wmc) contains relatively complete WMC read/write functionality that I'm happy with. Still need to add a few features and write tests (and find some decent WMC docs to test with). The formats are laid out so that multiple versions can be parsed.

01/08/08 04:03:51 changed by tschaub

Ok, read/write of WMC 1.0.0 and 1.1.0: http://dev.openlayers.org/sandbox/tschaub/wmc/examples/wmc.html

Now I just need to find some working WMC docs to test it with.

01/09/08 03:11:55 changed by tschaub

  • description changed.
  • summary changed from Consume WMC documents as views into OGC services to create a WMC parser.

01/09/08 03:40:40 changed by crschmidt

  • milestone changed from 2.7 Release to 2.6 Release.

Pulling back to 2.6.

(follow-up: ↓ 14 ) 01/09/08 05:06:51 changed by bartvde

Tim, I am running into a javascript error when writing WMC when I have a Vector layer in my map. Those layers don't have params, and there is no check. Should there not be a check if a layer is an instanceof OpenLayers.Layer.WMS or a check for layer.params alternatively?

(in reply to: ↑ 13 ) 01/09/08 05:21:54 changed by tschaub

Replying to bartvde:

Tim, I am running into a javascript error when writing WMC when I have a Vector layer in my map. Those layers don't have params, and there is no check. Should there not be a check if a layer is an instanceof OpenLayers.Layer.WMS or a check for layer.params alternatively?

Updated in the patch now.

(follow-up: ↓ 21 ) 01/09/08 05:49:34 changed by bartvde

Tim, the xmlns setting is not correct, it should be:

<ViewContext xmlns="http://www.opengis.net/context"

(follow-up: ↓ 22 ) 01/09/08 05:55:49 changed by bartvde

The same applies to sld:

http://www.opengis.net/sld

01/09/08 06:33:35 changed by bartvde

Tim, the sequence of the XML elements is wrong under <Layer>. It should be: Server, Name, Title.

01/09/08 06:40:50 changed by bartvde

And FormatList should be before StyleList.

There are still more errors in the sequence:

Error at (file stdin, line 1, char 8225): Element 'MinScaleDenominator' is not v
alid for content model: '((Server,Name,Title,Abstract,DataURL,MetadataURL,MinSca
leDenominator,MaxScaleDenominator,SRS,FormatList,StyleList,DimensionList),Extens
ion)'

Also, it would make validation easier if we link the outputted XML to the respective schema, e.g. for 1.1:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/context http://schemas.opengis.net/context/1.1.0/context.xsd"

01/09/08 07:13:10 changed by bartvde

It will require a bit of a rewrite to get this sequence problem solved, since the sld elements are appended, and they should be inserted at the right level. For now, to continue my testing, I've commented those parts.

Some clients (like PHP/Mapscript) depend on Window in the General section so I think it's wise to add this using map.getSize(), I see the code does not set context.size right now (in function mapToContext):

<Window width="750" height="450"/>

After this change there is still the problem with visibility (should be reversed):

hidden: layer.visibility ? "true" : "false"

Note, that Mapserver 4.8 only understands hidden 0 or 1 and not true/false.

Last note: I think it might be safer to use a <Style> element with an empty Name or Name default instead of an empty Style element completely. So:

<Style>
  <Name>default</Name>
</Style>

I see now the code thinks it should be <Style>mystylename</Style> but if you look at the schema Style can have 4 children, one of them is Name.

01/09/08 07:50:26 changed by bartvde

For Style both Name and Title are required, so I changed the function to:

    write_wmc_StyleList: function(layer) {
        var node = this.createElementDefaultNS("StyleList");
        var style = this.createElementDefaultNS(
            "Style", null, {current: "1"}
        );
        node.appendChild(style);
        var stylename = '';
        if (!layer.params["STYLES"] || (layer.params["STYLES"] == '')) {
            stylename = 'default';
        } else {
            stylename = layer.params["STYLES"];
        }
        style.appendChild(this.createElementDefaultNS(
            "Name", stylename ));
        style.appendChild(this.createElementDefaultNS(
            "Title", 'Default' ));
        return node;
    },

(in reply to: ↑ 15 ) 01/09/08 12:10:26 changed by tschaub

Replying to bartvde:

Tim, the xmlns setting is not correct, it should be: {{{ <ViewContext xmlns="http://www.opengis.net/context" }}}

I was referring to the xsd for the WMC 1.1.0 spec, which reads (in part):

<?xml version="1.0" encoding="utf-8"?>
<xs:schema version="1.1.0"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.opengeospatial.net/context"
            xmlns:context="http://www.opengeospatial.net/context"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            elementFormDefault="qualified">

(Note http://www.opengeospatial.net/context instead of your http://www.opengis.net/context.)

I've noticed other inconsistencies in both the 1.0.0 and 1.1.0 specifications (examples that do not match the xsd). Where are you getting the http://www.opengis.net/context?

(in reply to: ↑ 16 ) 01/09/08 12:14:05 changed by tschaub

Replying to bartvde:

The same applies to sld: {{{ http://www.opengis.net/sld }}}

As with context, in the xsd for 1.1.0 (from the spec just downloaded), I read:

<xs:schema version="1.1.0"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://www.opengeospatial.net/context"
           xmlns:context="http://www.opengeospatial.net/context"
           xmlns:sld="http://www.opengeospatial.net/sld"
           xmlns:xlink="http://www.w3.org/1999/xlink"
           elementFormDefault="qualified">

I apologize if my poor xsd reading skills failed me here - but I took that to mean that the sld namespace URI should be http://www.opengeospatial.net/sld.

01/09/08 13:06:52 changed by bartvde

I got the schema from the official OGC repository:

http://schemas.opengis.net/context/1.1.0/context.xsd

which defines:

targetNamespace="http://www.opengis.net/context"

If you go to: http://schemas.opengeospatial.net/

they warn with:

This is NOT the official OGC schema repository and will be shut-down.
Please use schemas.opengis.net as the official OGC schema repository.

01/10/08 05:32:14 changed by bartvde

Tim, there is a fragment in here which chokes IE (the extra ,):

        layer.addOptions({
            minScale: layerInfo.minScale,
            maxScale: layerInfo.maxScale,
        });

01/24/08 15:47:39 changed by tschaub

  • state set to Review.

Ok, the updated patch addresses the above comments and adds Extension tags for displayInLayerSwitcher, transparent, and opacity.

This patch requires the patch for #1300 in order for tests to pass. Tests pass in IE6 and FF. Opera has it's own way of formatting namespace prefixes, so write tests do not pass there. Safari is worse. However, the output from FF, IE, and Opera all validate on http://www.validome.org/xml/validate/ - with the exception of the OL Extension elements for which we have no schema - looks to me like the wmc schema means to let Extension elements pass without schema (there is a bit about "any" namespace).

I've exhausted myself as far as tests go. If Safari support is a priority, someone will have to assist with troubleshooting the XML parsing there.

Thought the format will likely get the least use of all, in my mind this is the most solid parser we've got. I'd be happy to see it in the trunk (with conditions excluding Safari and Opera from the tests if that is important).

Thanks for any review or feedback.

01/24/08 19:18:07 changed by tschaub

  • attachment wmc.patch added.

read/write wmc 1.0.0 and 1.1.0

01/24/08 19:19:47 changed by tschaub

One more update on that patch. Now works in FF, IE6, Safari, and Opera. Again, tests only pass with the patch for #1300.

01/26/08 21:06:38 changed by crschmidt

  • state changed from Review to Commit.

I can confirm that:

  • The versioning setup seems sane.
  • The documentation for the functions appears to match what they do reasonably well.
  • The code 'does what it says on the tin'
  • The code does not negatively impact any tests
  • There is negligable impact on any other code
  • The code adds functionality which is generally useful for applications of OpenLayers
  • The code does not create any obviously non-forward looking changes.

One thing: We've been trying to keep copyright lines in the top of the files in lib/. If you could drop one into each of the WMC files, I'd appreciate it.

Barring that, I have no problems with this going into trunk, after #1300 is committed (so that we don't break tests). Thank you for your hard work, Tim.

01/28/08 11:39:05 changed by tschaub

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

(In [5919]) Adding Web Map Context document parsing for versions 1.0.0 and 1.1.0. This also adds a cross browser setAttributeNS to the XML format. Thanks bartvde for supporting this work. r=crschmidt (closes #100)

02/18/08 23:26:30 changed by tschaub

  • component changed from Map to Format.WMC.