14
14
*
15
15
* Inherits from:
16
16
* - <OpenLayers.Format.WCSCapabilities.v1>
17
+ * - <OpenLayers.Format.GML.v3>
17
18
*/
18
19
OpenLayers . Format . WCSCapabilities . v1_0_0 = OpenLayers . Class (
19
- OpenLayers . Format . WCSCapabilities . v1 , {
20
-
20
+ OpenLayers . Format . GML . v3 , OpenLayers . Format . WCSCapabilities . v1 , {
21
+
21
22
/**
22
23
* Constructor: OpenLayers.Format.WCSCapabilities.v1_0_0
23
24
* Create a new parser for WCS capabilities version 1.0.0.
@@ -45,55 +46,61 @@ OpenLayers.Format.WCSCapabilities.v1_0_0 = OpenLayers.Class(
45
46
* errorProperty is undefined on the returned object, the document will be
46
47
* run through an OGCExceptionReport parser.
47
48
*/
48
- errorProperty : "service " ,
49
+ errorProperty : "serviceIdentification " ,
49
50
50
51
/**
51
52
* Property: readers
52
53
* Contains public functions, grouped by namespace prefix, that will
53
54
* be applied when a namespaced node is found matching the function
54
55
* name. The function will be applied in the scope of this parser
55
56
* with two arguments: the node being read and a context object passed
56
- * from the parent.
57
+ * from the parent. Where possible, the 1.0.0 readers attempt to make
58
+ * their output compatible with 1.1.0 to reduce client complexity.
57
59
*/
58
60
readers : {
59
61
"wcs" : {
60
- "WCS_Capabilities" : function ( node , obj ) {
62
+ "WCS_Capabilities" : function ( node , obj ) {
61
63
this . readChildNodes ( node , obj ) ;
62
64
} ,
63
65
"Service" : function ( node , obj ) {
64
- obj . service = { } ;
65
- this . readChildNodes ( node , obj . service ) ;
66
- } ,
67
- "name" : function ( node , service ) {
68
- service . name = this . getChildValue ( node ) ;
69
- } ,
70
- "label" : function ( node , service ) {
71
- service . label = this . getChildValue ( node ) ;
66
+ var children = { } ;
67
+ this . readChildNodes ( node , children ) ;
68
+
69
+ // Rearrange things a little to get a tree that is
70
+ // compatible with 1.1.0
71
+ var providerName = children . serviceContact . providerName ;
72
+ delete children . serviceContact . providerName ;
73
+
74
+ obj . serviceProvider = {
75
+ providerName : providerName ,
76
+ serviceContact : children . serviceContact } ;
77
+ children . serviceContact = undefined ;
78
+ obj . serviceIdentification = children ;
72
79
} ,
73
- "keywords" : function ( node , service ) {
74
- service . keywords = [ ] ;
75
- this . readChildNodes ( node , service . keywords ) ;
80
+ "keywords" : function ( node , serviceIdentification ) {
81
+ serviceIdentification . keywords = [ ] ;
82
+ this . readChildNodes ( node , serviceIdentification . keywords ) ;
76
83
} ,
77
84
"keyword" : function ( node , keywords ) {
78
85
// Append the keyword to the keywords list
79
86
keywords . push ( this . getChildValue ( node ) ) ;
80
87
} ,
81
- "responsibleParty" : function ( node , service ) {
82
- service . responsibleParty = { } ;
83
- this . readChildNodes ( node , service . responsibleParty ) ;
88
+ "responsibleParty" : function ( node , serviceIdentification ) {
89
+ serviceIdentification . serviceContact = { } ;
90
+ this . readChildNodes ( node , serviceIdentification . serviceContact ) ;
84
91
} ,
85
- "individualName" : function ( node , responsibleParty ) {
86
- responsibleParty . individualName = this . getChildValue ( node ) ;
92
+ "individualName" : function ( node , serviceContact ) {
93
+ serviceContact . individualName = this . getChildValue ( node ) ;
87
94
} ,
88
- "organisationName" : function ( node , responsibleParty ) {
89
- responsibleParty . organisationName = this . getChildValue ( node ) ;
95
+ "organisationName" : function ( node , serviceContact ) {
96
+ serviceContact . providerName = this . getChildValue ( node ) ;
90
97
} ,
91
- "positionName" : function ( node , responsibleParty ) {
92
- responsibleParty . positionName = this . getChildValue ( node ) ;
98
+ "positionName" : function ( node , serviceContact ) {
99
+ serviceContact . positionName = this . getChildValue ( node ) ;
93
100
} ,
94
- "contactInfo" : function ( node , responsibleParty ) {
95
- responsibleParty . contactInfo = { } ;
96
- this . readChildNodes ( node , responsibleParty . contactInfo ) ;
101
+ "contactInfo" : function ( node , serviceContact ) {
102
+ serviceContact . contactInfo = { } ;
103
+ this . readChildNodes ( node , serviceContact . contactInfo ) ;
97
104
} ,
98
105
"phone" : function ( node , contactInfo ) {
99
106
contactInfo . phone = { } ;
@@ -124,11 +131,11 @@ OpenLayers.Format.WCSCapabilities.v1_0_0 = OpenLayers.Class(
124
131
"electronicMailAddress" : function ( node , address ) {
125
132
address . electronicMailAddress = this . getChildValue ( node ) ;
126
133
} ,
127
- "fees" : function ( node , service ) {
128
- service . fees = this . getChildValue ( node ) ;
134
+ "fees" : function ( node , serviceIdentification ) {
135
+ serviceIdentification . fees = this . getChildValue ( node ) ;
129
136
} ,
130
- "accessConstraints" : function ( node , service ) {
131
- service . accessConstraints = this . getChildValue ( node ) ;
137
+ "accessConstraints" : function ( node , serviceIdentification ) {
138
+ serviceIdentification . accessConstraints = this . getChildValue ( node ) ;
132
139
} ,
133
140
"ContentMetadata" : function ( node , obj ) {
134
141
obj . contentMetadata = [ ] ;
@@ -139,11 +146,27 @@ OpenLayers.Format.WCSCapabilities.v1_0_0 = OpenLayers.Class(
139
146
this . readChildNodes ( node , coverageOfferingBrief ) ;
140
147
contentMetadata . push ( coverageOfferingBrief ) ;
141
148
} ,
142
- "name" : function ( node , coverageOfferingBrief ) {
143
- coverageOfferingBrief . name = this . getChildValue ( node ) ;
149
+ "name" : function ( node , serviceOrCoverageOfferingBrief ) {
150
+ // split/pop used to strip off any namespace prefixes
151
+ if ( node . parentNode . nodeName . split ( ':' ) . pop ( ) === "Service" ) {
152
+ // We're parsing a service description
153
+ serviceOrCoverageOfferingBrief . title = this . getChildValue ( node ) ;
154
+ }
155
+ else { // node.parentNode.nodeName === "CoverageOfferingBrief"
156
+ // We're parsing a dataset
157
+ serviceOrCoverageOfferingBrief . identifier = this . getChildValue ( node ) ;
158
+ }
144
159
} ,
145
- "label" : function ( node , coverageOfferingBrief ) {
146
- coverageOfferingBrief . label = this . getChildValue ( node ) ;
160
+ "label" : function ( node , serviceOrCoverageOfferingBrief ) {
161
+ // split/pop used to strip off any namespace prefixes
162
+ if ( node . parentNode . nodeName . split ( ':' ) . pop ( ) === "Service" ) {
163
+ // We're parsing a service description
164
+ serviceOrCoverageOfferingBrief . abstract = this . getChildValue ( node ) ;
165
+ }
166
+ else { // node.parentNode.nodeName === "CoverageOfferingBrief"
167
+ // We"re parsing a dataset
168
+ serviceOrCoverageOfferingBrief . title = this . getChildValue ( node ) ;
169
+ }
147
170
} ,
148
171
"lonLatEnvelope" : function ( node , coverageOfferingBrief ) {
149
172
var nodeList = this . getElementsByTagNameNS ( node , "http://www.opengis.net/gml" , "pos" ) ;
@@ -153,16 +176,18 @@ OpenLayers.Format.WCSCapabilities.v1_0_0 = OpenLayers.Class(
153
176
var min = { } ;
154
177
var max = { } ;
155
178
156
- OpenLayers . Format . GML . v3 . prototype . readers [ "gml" ] . pos . apply ( this , [ nodeList [ 0 ] , min ] ) ;
157
- OpenLayers . Format . GML . v3 . prototype . readers [ "gml" ] . pos . apply ( this , [ nodeList [ 1 ] , max ] ) ;
179
+ this . xy = true ; // Affirm we don't want our coordinates switched around
180
+ this . readers . gml . pos . apply ( this , [ nodeList [ 0 ] , min ] ) ;
181
+ this . readers . gml . pos . apply ( this , [ nodeList [ 1 ] , max ] ) ;
158
182
159
183
coverageOfferingBrief . lonLatEnvelope = { } ;
160
184
coverageOfferingBrief . lonLatEnvelope . srsName = node . getAttribute ( "srsName" ) ;
161
185
coverageOfferingBrief . lonLatEnvelope . min = min . points [ 0 ] ;
162
186
coverageOfferingBrief . lonLatEnvelope . max = max . points [ 0 ] ;
163
187
}
164
188
}
165
- }
189
+ } ,
190
+ "gml" : OpenLayers . Format . GML . v3 . prototype . readers [ "gml" ]
166
191
} ,
167
192
168
193
CLASS_NAME : "OpenLayers.Format.WCSCapabilities.v1_0_0"
0 commit comments