Project

General

Profile

Download (5.55 KB) Statistics
| Branch: | Tag: | Revision:
1
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
2
 * full list of contributors). Published under the 2-clause BSD license.
3
 * See license.txt in the OpenLayers distribution or repository for the
4
 * full text of the license. */
5

    
6
/**
7
 * @requires OpenLayers/Format/SOSCapabilities.js
8
 * @requires OpenLayers/Format/OWSCommon/v1_1_0.js
9
 * @requires OpenLayers/Format/GML/v3.js
10
 */
11

    
12
/**
13
 * Class: OpenLayers.Format.SOSCapabilities.v1_0_0
14
 * Read SOS Capabilities version 1.0.0.
15
 * 
16
 * Inherits from:
17
 *  - <OpenLayers.Format.SOSCapabilities>
18
 */
19
OpenLayers.Format.SOSCapabilities.v1_0_0 = OpenLayers.Class(
20
    OpenLayers.Format.SOSCapabilities, {
21

    
22
    /**
23
     * Property: namespaces
24
     * {Object} Mapping of namespace aliases to namespace URIs.
25
     */
26
    namespaces: {
27
        ows: "http://www.opengis.net/ows/1.1",
28
        sos: "http://www.opengis.net/sos/1.0",
29
        gml: "http://www.opengis.net/gml",
30
        xlink: "http://www.w3.org/1999/xlink"
31
    },
32

    
33
    /**
34
     * Property: regExes
35
     * Compiled regular expressions for manipulating strings.
36
     */
37
    regExes: {
38
        trimSpace: (/^\s*|\s*$/g),
39
        removeSpace: (/\s*/g),
40
        splitSpace: (/\s+/),
41
        trimComma: (/\s*,\s*/g)
42
    },
43
    
44
    /**
45
     * Constructor: OpenLayers.Format.SOSCapabilities.v1_0_0
46
     * Create a new parser for SOS capabilities version 1.0.0. 
47
     *
48
     * Parameters:
49
     * options - {Object} An optional object whose properties will be set on
50
     *     this instance.
51
     */
52
    initialize: function(options) {
53
        OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
54
        this.options = options;
55
    },
56

    
57
    /**
58
     * APIMethod: read
59
     * Read capabilities data from a string, and return info about the SOS.
60
     * 
61
     * Parameters: 
62
     * data - {String} or {DOMElement} data to read/parse.
63
     *
64
     * Returns:
65
     * {Object} Information about the SOS service.
66
     */
67
    read: function(data) {
68
        if(typeof data == "string") {
69
            data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
70
        }
71
        if(data && data.nodeType == 9) {
72
            data = data.documentElement;
73
        }
74
        var capabilities = {};
75
        this.readNode(data, capabilities);
76
        return capabilities;
77
    },
78

    
79
    /**
80
     * Property: readers
81
     * Contains public functions, grouped by namespace prefix, that will
82
     *     be applied when a namespaced node is found matching the function
83
     *     name.  The function will be applied in the scope of this parser
84
     *     with two arguments: the node being read and a context object passed
85
     *     from the parent.
86
     */
87
    readers: {
88
        "gml": OpenLayers.Util.applyDefaults({
89
            "name": function(node, obj) {
90
                obj.name = this.getChildValue(node);
91
            },
92
            "TimePeriod": function(node, obj) {
93
                obj.timePeriod = {};
94
                this.readChildNodes(node, obj.timePeriod);
95
            },
96
            "beginPosition": function(node, timePeriod) {
97
                timePeriod.beginPosition = this.getChildValue(node);
98
            },
99
            "endPosition": function(node, timePeriod) {
100
                timePeriod.endPosition = this.getChildValue(node);
101
            }
102
        }, OpenLayers.Format.GML.v3.prototype.readers["gml"]),
103
        "sos": {
104
            "Capabilities": function(node, obj) {
105
                this.readChildNodes(node, obj);
106
            },
107
            "Contents": function(node, obj) {
108
                obj.contents = {};
109
                this.readChildNodes(node, obj.contents);
110
            },
111
            "ObservationOfferingList": function(node, contents) {
112
                contents.offeringList = {};
113
                this.readChildNodes(node, contents.offeringList);
114
            },
115
            "ObservationOffering": function(node, offeringList) {
116
                var id = this.getAttributeNS(node, this.namespaces.gml, "id");
117
                offeringList[id] = {
118
                    procedures: [],
119
                    observedProperties: [],
120
                    featureOfInterestIds: [],
121
                    responseFormats: [],
122
                    resultModels: [],
123
                    responseModes: []
124
                };
125
                this.readChildNodes(node, offeringList[id]);
126
            },
127
            "time": function(node, offering) {
128
                offering.time = {};
129
                this.readChildNodes(node, offering.time);
130
            },
131
            "procedure": function(node, offering) {
132
                offering.procedures.push(this.getAttributeNS(node, 
133
                    this.namespaces.xlink, "href"));
134
            },
135
            "observedProperty": function(node, offering) {
136
                offering.observedProperties.push(this.getAttributeNS(node, 
137
                    this.namespaces.xlink, "href"));
138
            },
139
            "featureOfInterest": function(node, offering) {
140
                offering.featureOfInterestIds.push(this.getAttributeNS(node, 
141
                    this.namespaces.xlink, "href"));
142
            },
143
            "responseFormat": function(node, offering) {
144
                offering.responseFormats.push(this.getChildValue(node));
145
            },
146
            "resultModel": function(node, offering) {
147
                offering.resultModels.push(this.getChildValue(node));
148
            },
149
            "responseMode": function(node, offering) {
150
                offering.responseModes.push(this.getChildValue(node));
151
            }
152
        },
153
        "ows": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers["ows"]
154
    },    
155
    
156
    CLASS_NAME: "OpenLayers.Format.SOSCapabilities.v1_0_0" 
157

    
158
});
    (1-1/1)