1 | #import cElementTree as ET |
---|
2 | #import elementtree.ElementTree as etree |
---|
3 | try: #python 2.5 |
---|
4 | from xml.etree import ElementTree as etree |
---|
5 | except ImportError: |
---|
6 | try: |
---|
7 | # if you've installed it yourself it comes this way |
---|
8 | import ElementTree as etree |
---|
9 | except ImportError: |
---|
10 | # if you've egged it this is the way it comes |
---|
11 | from elementtree import ElementTree as etree |
---|
12 | |
---|
13 | try: #python 2.5 |
---|
14 | from xml.etree import cElementTree as ET |
---|
15 | except ImportError: |
---|
16 | try: |
---|
17 | # if you've installed it yourself it comes this way |
---|
18 | import cElementTree as ET |
---|
19 | except ImportError: |
---|
20 | # if you've egged it this is the way it comes |
---|
21 | from celementtree import cElementTree as ET |
---|
22 | |
---|
23 | import sys, traceback |
---|
24 | import csml |
---|
25 | import cgi #(for escaping text) |
---|
26 | '''CSML v2 Parser ''' |
---|
27 | |
---|
28 | etree._namespace_map.update({'http://www.opengis.net/om': 'om', 'http://www.opengis.net/swe': 'swe', 'http://www.opengis.net/gml': 'gml','http://ndg.nerc.ac.uk/csml' : 'csml', 'http://www.w3.org/1999/xlink':'xlink'}) |
---|
29 | |
---|
30 | nsCSML = 'http://ndg.nerc.ac.uk/csml' |
---|
31 | nsGML = 'http://www.opengis.net/gml' |
---|
32 | nsOM = 'http://www.opengis.net/om' |
---|
33 | nsXLINK = 'http://www.w3.org/1999/xlink' |
---|
34 | nsXML = 'http://ndg.nerc.ac.uk/csml' |
---|
35 | nsMOLES='http://ndg.nerc.ac.uk/moles' |
---|
36 | nsSWE='http://www.opengis.net/swe' |
---|
37 | |
---|
38 | MAINATTRIBUTELIST=[] |
---|
39 | |
---|
40 | def CSML(tag): |
---|
41 | return "{"+nsCSML+"}"+tag |
---|
42 | |
---|
43 | def GML(tag): |
---|
44 | return "{"+nsGML+"}"+tag |
---|
45 | |
---|
46 | def SWE(tag): |
---|
47 | return "{"+nsSWE+"}"+tag |
---|
48 | |
---|
49 | def XLINK(tag): |
---|
50 | return "{"+nsXLINK+"}"+tag |
---|
51 | |
---|
52 | def MOLES(tag): |
---|
53 | return "{"+nsMOLES+"}"+tag |
---|
54 | |
---|
55 | def addchildren(obj, dict): |
---|
56 | ''' merges (adds) dictionary to existing self.CHILDREN dictionary ''' |
---|
57 | dict1 = dict |
---|
58 | if 'CHILDREN' in obj.__dict__: |
---|
59 | dict2=obj.CHILDREN |
---|
60 | else: |
---|
61 | dict2={} |
---|
62 | dict3={} |
---|
63 | for item in dict1: |
---|
64 | dict3[item] =dict1[item] |
---|
65 | for item in dict2: |
---|
66 | dict3[item] =dict2[item] |
---|
67 | obj.CHILDREN=dict3 |
---|
68 | |
---|
69 | |
---|
70 | def addatts(obj, atts): |
---|
71 | ''' merges self.ATTRIBUTES of inherited classes''' |
---|
72 | if 'ATTRIBUTES' in obj.__dict__: |
---|
73 | for att in atts: |
---|
74 | obj.ATTRIBUTES.append(att) |
---|
75 | if att not in MAINATTRIBUTELIST: |
---|
76 | MAINATTRIBUTELIST.append(att) |
---|
77 | else: |
---|
78 | obj.ATTRIBUTES=atts |
---|
79 | |
---|
80 | |
---|
81 | def addelems(obj, elems): |
---|
82 | ''' merges self.elems of inherited classes''' |
---|
83 | if 'ELEMORDER' in obj.__dict__: |
---|
84 | for elem in elems: |
---|
85 | obj.ELEMORDER.append(elem) |
---|
86 | else: |
---|
87 | obj.ELEMORDER=elems |
---|
88 | |
---|
89 | |
---|
90 | #Some variable definitions: these things are often repeated so store in variables. |
---|
91 | FILEFORMATS=[CSML('NetCDFExtract'),CSML('NASAAmesExtract'), CSML('GRIBExtract'),CSML('CDMLExtract'), CSML('RawFileExtract'), CSML('ImageFileExtract'), CSML('AggregatedArray')] |
---|
92 | |
---|
93 | class csElement(object): |
---|
94 | ''' main csElement class - all other elements inherit from this baseclass |
---|
95 | all the from/to XML conversion is done by this class''' |
---|
96 | |
---|
97 | def __init__(self, **kwargs): |
---|
98 | for kw in kwargs: |
---|
99 | self.__setattr__(kw, kwargs[kw]) |
---|
100 | if not hasattr(self, 'ATTRIBUTES'): |
---|
101 | self.__dict__['ATTRIBUTES']=[] |
---|
102 | if not hasattr(self, 'ELEMORDER'): |
---|
103 | self.__dict__['ELEMORDER']=[] |
---|
104 | if not hasattr(self, 'CHILDREN'): |
---|
105 | self.__dict__['CHILDREN']={} |
---|
106 | #The __setattr__ and __getattribute__ special methods have been overridden. |
---|
107 | #This is so that attributes can be called by their fully qualified name internally |
---|
108 | #while being referenced by their short name externally. |
---|
109 | # so 'id' and {'http://www.opengis.net/gml'}id always have the same value |
---|
110 | #you can set either of them at any time and the other will be kept in sync. |
---|
111 | |
---|
112 | def __setattr__(self, name, value): |
---|
113 | if CSML(name) in self.__dict__: |
---|
114 | object.__setattr__(self, CSML(name), value) |
---|
115 | object.__setattr__(self, name, value) |
---|
116 | elif GML(name) in self.__dict__: |
---|
117 | object.__setattr__(self, GML(name), value) |
---|
118 | object.__setattr__(self, name, value) |
---|
119 | elif XLINK(name) in self.__dict__: |
---|
120 | object.__setattr__(self, XLINK(name), value) |
---|
121 | object.__setattr__(self, name, value) |
---|
122 | else: |
---|
123 | if 'ATTRIBUTES' in self.__dict__: |
---|
124 | if CSML(name) in self.__dict__['ATTRIBUTES']: |
---|
125 | object.__setattr__(self, CSML(name), value) |
---|
126 | object.__setattr__(self, name, value) |
---|
127 | elif GML(name) in self.__dict__['ATTRIBUTES']: |
---|
128 | object.__setattr__(self, GML(name), value) |
---|
129 | object.__setattr__(self, name, value) |
---|
130 | elif XLINK(name) in self.__dict__['ATTRIBUTES']: |
---|
131 | object.__setattr__(self, XLINK(name), value) |
---|
132 | object.__setattr__(self, name, value) |
---|
133 | elif name in self.__dict__['ATTRIBUTES']: |
---|
134 | object.__setattr__(self, name, value) |
---|
135 | try: |
---|
136 | name=name.split('}')[1] |
---|
137 | except IndexError: |
---|
138 | pass |
---|
139 | object.__setattr__(self, name, value) |
---|
140 | else: |
---|
141 | object.__setattr__(self, name, value) |
---|
142 | else: |
---|
143 | object.__setattr__(self, name, value) |
---|
144 | |
---|
145 | def __getattribute__(self, name): |
---|
146 | if name in MAINATTRIBUTELIST: |
---|
147 | if CSML(name) in object.__dict__: |
---|
148 | return object.__getattribute__(self,CSML(name)) |
---|
149 | elif GML(name) in object.__dict__: |
---|
150 | return object.__getattribute__(self,GML(name)) |
---|
151 | elif XLINK(name) in object.__dict__: |
---|
152 | return object.__getattribute__(self,XLINK(name)) |
---|
153 | else: |
---|
154 | return object.__getattribute__(self,name) |
---|
155 | else: |
---|
156 | return object.__getattribute__(self,name) |
---|
157 | |
---|
158 | def __removeURI(self, qname): |
---|
159 | try: |
---|
160 | attname = qname.split('}')[1] |
---|
161 | except IndexError: |
---|
162 | attname = qname |
---|
163 | return attname |
---|
164 | |
---|
165 | def _getSubstitutionType(self,tag): |
---|
166 | return tag.split('}')[1] |
---|
167 | |
---|
168 | |
---|
169 | def _getReverseSubsType(self, typename): |
---|
170 | return typename |
---|
171 | |
---|
172 | def addChildElem(self, childname, childobj): |
---|
173 | #sometimes you want to add a child element but don't know if there is one already. In which case you want to create a list of child objects. |
---|
174 | if childname in self.__dict__: |
---|
175 | currentattribute=getattr(self,childname) |
---|
176 | if type(getattr(self,childname)) is list: |
---|
177 | currentattribute.append(childobj) |
---|
178 | else: |
---|
179 | newlist=[currentattribute] |
---|
180 | newlist.append(childobj) |
---|
181 | setattr(self,childname, newlist) |
---|
182 | else: |
---|
183 | setattr(self,childname, childobj) |
---|
184 | |
---|
185 | def toXML(self, csmlfrag, **kwargs): |
---|
186 | #process self and convert to XML |
---|
187 | if 'CONTENT' in self.__dict__: |
---|
188 | if self.CONTENT is not None: csmlfrag.text=cgi.escape(self.CONTENT) |
---|
189 | if 'ATTRIBUTES' in self.__dict__: |
---|
190 | for item in self.__dict__: |
---|
191 | if item in self.ATTRIBUTES: |
---|
192 | csmlfrag.set(item, self.__dict__[item]) |
---|
193 | # self.CHILDREN (recursive - calls the toXML method of children |
---|
194 | for child in self.ELEMORDER: |
---|
195 | if not self.__dict__.has_key(child): |
---|
196 | continue |
---|
197 | appendLater=False |
---|
198 | parserobjects=[] |
---|
199 | if type(self.__dict__[child]) is list: |
---|
200 | for a in self.__dict__[child]: |
---|
201 | parserobjects.append(a) |
---|
202 | else: |
---|
203 | parserobjects.append(self.__dict__[child]) |
---|
204 | parentfrag=None |
---|
205 | if len(self.CHILDREN[child])>=3: |
---|
206 | ename2=self.CHILDREN[child][2] |
---|
207 | parentfrag=ET.Element(ename2) |
---|
208 | for po in parserobjects: |
---|
209 | if type(self.CHILDREN[child][0]) is not list: |
---|
210 | ename=self.CHILDREN[child][0] |
---|
211 | else: |
---|
212 | ename = self._getReverseSubsType(type(po).__name__) |
---|
213 | if len(self.CHILDREN[child])==3: |
---|
214 | frag=ET.Element(ename) |
---|
215 | po.toXML(frag) |
---|
216 | parentfrag.append(frag) |
---|
217 | appendLater=True |
---|
218 | elif len(self.CHILDREN[child])>=4: |
---|
219 | if self.CHILDREN[child][3]==1: |
---|
220 | frag=ET.Element(ename) |
---|
221 | po.toXML(frag) |
---|
222 | parentfrag.append(frag) |
---|
223 | csmlfrag.append(parentfrag) |
---|
224 | parentfrag=ET.Element(parentfrag.tag) |
---|
225 | appendLater=False |
---|
226 | else: |
---|
227 | frag=ET.Element(ename) |
---|
228 | try: |
---|
229 | po.toXML(frag) |
---|
230 | except: |
---|
231 | print 'PARSING ERROR - could not convert %s to XML'%frag |
---|
232 | print dir(ename) |
---|
233 | raise |
---|
234 | csmlfrag.append(frag) |
---|
235 | appendLater=True |
---|
236 | |
---|
237 | if appendLater==True and parentfrag != None: |
---|
238 | csmlfrag.append(parentfrag) |
---|
239 | |
---|
240 | return csmlfrag |
---|
241 | |
---|
242 | def fromXML(self,csmlfrag): |
---|
243 | self.elem=csmlfrag |
---|
244 | # deal with attributes, e.g. gml id's |
---|
245 | if csmlfrag.text is not None: |
---|
246 | self.CONTENT = csmlfrag.text |
---|
247 | for item in csmlfrag.items(): |
---|
248 | if item[0] in self.ATTRIBUTES: |
---|
249 | setattr(self, item[0], item[1]) |
---|
250 | #self.CHILDREN (recursive - calls the fromXML method of children |
---|
251 | for frag in csmlfrag[:]: |
---|
252 | #for each child element |
---|
253 | #iterate through expected CHILDREN to find match |
---|
254 | for child in self.CHILDREN: |
---|
255 | if len(self.CHILDREN[child])>=3: |
---|
256 | ename = self.CHILDREN[child][2] |
---|
257 | ename2 = self.CHILDREN[child][0] |
---|
258 | else: |
---|
259 | ename = self.CHILDREN[child][0] |
---|
260 | ename2=None |
---|
261 | #if there are options, then find the name that matches the frag |
---|
262 | if ename2 is not None: |
---|
263 | if frag[:] != []: |
---|
264 | for subfrag in frag[:]: |
---|
265 | etype=None |
---|
266 | if type(ename2) is list: |
---|
267 | if subfrag.tag in ename2: |
---|
268 | etype=self._getSubstitutionType(subfrag.tag) |
---|
269 | if subfrag.tag==ename2: |
---|
270 | etype=self.CHILDREN[child][1] |
---|
271 | if etype: |
---|
272 | childobj=eval(etype)() |
---|
273 | if len(self.CHILDREN[child])>=3: |
---|
274 | if frag[:] != []: |
---|
275 | childobj.fromXML(subfrag) |
---|
276 | else: |
---|
277 | childobj.fromXML(frag) |
---|
278 | #set this object to be an attribute of the 'parent' (self) object |
---|
279 | if child in self.__dict__: |
---|
280 | if type(self.__dict__[child]) is not list: |
---|
281 | tmp=self.__dict__[child] |
---|
282 | setattr(self, child, [tmp]) #convert to list |
---|
283 | self.__dict__[child].append(childobj) |
---|
284 | else: |
---|
285 | setattr(self, child, childobj) |
---|
286 | else: |
---|
287 | etype=None |
---|
288 | if type(ename) is list: |
---|
289 | if frag.tag in ename: |
---|
290 | etype=self._getSubstitutionType(frag.tag) |
---|
291 | elif frag.tag==ename: |
---|
292 | etype=self.CHILDREN[child][1] |
---|
293 | if etype: |
---|
294 | childobj=eval(etype)() |
---|
295 | if len(self.CHILDREN[child])>=3: |
---|
296 | if frag[:] != []: |
---|
297 | childobj.fromXML(frag[0]) |
---|
298 | else: |
---|
299 | childobj.fromXML(frag) |
---|
300 | |
---|
301 | #set this object to be an attribute of the 'parent' (self) object |
---|
302 | if child in self.__dict__: |
---|
303 | if type(self.__dict__[child]) is not list: |
---|
304 | tmp=self.__dict__[child] |
---|
305 | setattr(self, child, [tmp]) #convert to list |
---|
306 | self.__dict__[child].append(childobj) |
---|
307 | else: |
---|
308 | setattr(self, child, childobj) |
---|
309 | |
---|
310 | |
---|
311 | |
---|
312 | class AbstractGML(csElement): |
---|
313 | def __init__(self, **kwargs): |
---|
314 | a=[GML('id')] |
---|
315 | addatts(self,a) |
---|
316 | elems=['metaDataProperty', 'description','name'] |
---|
317 | addelems(self,elems) |
---|
318 | children={elems[0]:[GML('metaDataProperty'),'csString'],elems[1]:[GML('description'),'csString'],elems[2]:[GML('name'),'csString']} |
---|
319 | addchildren(self,children) |
---|
320 | csElement.__init__(self,**kwargs) |
---|
321 | |
---|
322 | class AssociationAttributeGroup(csElement): |
---|
323 | def __init__(self, **kwargs): |
---|
324 | a =[XLINK('href'),XLINK('role'), XLINK('arcrole'),XLINK('title'), XLINK('show'), XLINK('actuate')] |
---|
325 | addatts(self,a) |
---|
326 | csElement.__init__(self,**kwargs) |
---|
327 | |
---|
328 | class csString(AssociationAttributeGroup, csElement): |
---|
329 | def __init__(self, text=None,**kwargs): |
---|
330 | #Needed so it can use xlink |
---|
331 | addelems(self,[]) |
---|
332 | AssociationAttributeGroup.__init__(self,**kwargs) |
---|
333 | if text != None: |
---|
334 | if type(text) is not str: |
---|
335 | text=str(text) |
---|
336 | self.CONTENT=text |
---|
337 | children={} |
---|
338 | addchildren(self,children) |
---|
339 | csElement.__init__(self,**kwargs) |
---|
340 | |
---|
341 | class SRSReferenceGroup(csElement): |
---|
342 | def __init__(self, **kwargs): |
---|
343 | a =['srsName','srsDimension'] |
---|
344 | addatts(self,a) |
---|
345 | csElement.__init__(self,**kwargs) |
---|
346 | |
---|
347 | class SRSInformationGroup(csElement): |
---|
348 | def __init__(self, **kwargs): |
---|
349 | a =['uomLabels','axisLabels'] |
---|
350 | addatts(self,a) |
---|
351 | csElement.__init__(self,**kwargs) |
---|
352 | |
---|
353 | class ArrayDescriptor(csElement): |
---|
354 | def __init__(self,**kwargs): |
---|
355 | a=['id'] |
---|
356 | addatts(self,a) |
---|
357 | elems=['arraySize', 'uom', 'numericType','regExpTransform','numericTransform'] |
---|
358 | addelems(self,elems) |
---|
359 | children={elems[0]:[CSML('arraySize'), 'csString'], elems[1]:[CSML('uom'),'csString'], elems[2]:[CSML('numericType'),'csString'], elems[3]:[CSML('regExpTransform'),'csString'], elems[4]:[CSML('numericTransform'),'csString']} |
---|
360 | addchildren(self,children) |
---|
361 | csElement.__init__(self,**kwargs) |
---|
362 | |
---|
363 | class GridEnvelope(AbstractGML,SRSReferenceGroup, csElement): |
---|
364 | def __init__(self, **kwargs): |
---|
365 | SRSReferenceGroup.__init__(self,**kwargs) |
---|
366 | AbstractGML.__init__(self,**kwargs) |
---|
367 | elems=['low', 'high'] |
---|
368 | addelems(self,elems) |
---|
369 | children={elems[0]:[GML('low'), 'csString'],elems[1]:[GML('high'), 'csString']} |
---|
370 | addchildren(self,children) |
---|
371 | csElement.__init__(self,**kwargs) |
---|
372 | |
---|
373 | class Envelope(AbstractGML,SRSReferenceGroup, csElement): |
---|
374 | def __init__(self, **kwargs): |
---|
375 | SRSReferenceGroup.__init__(self,**kwargs) |
---|
376 | AbstractGML.__init__(self,**kwargs) |
---|
377 | elems=['lowerCorner','upperCorner'] |
---|
378 | addelems(self,elems) |
---|
379 | children={elems[0]:[GML('lowerCorner'), 'csString'],elems[1]:[GML('upperCorner'), 'csString']} |
---|
380 | addchildren(self,children) |
---|
381 | csElement.__init__(self,**kwargs) |
---|
382 | |
---|
383 | class EnvelopeWithTimePeriod(Envelope): |
---|
384 | def __init__(self, **kwargs): |
---|
385 | Envelope.__init__(self,**kwargs) |
---|
386 | elems=['beginPosition', 'endPosition'] |
---|
387 | addelems(self,elems) |
---|
388 | children={elems[0]:[GML('beginPosition'), 'csString'], elems[1]:[GML('endPosition'), 'csString']} |
---|
389 | addchildren(self,children) |
---|
390 | csElement.__init__(self,**kwargs) |
---|
391 | |
---|
392 | class AbstractFeature(AbstractGML,csElement): |
---|
393 | def __init__(self, **kwargs): |
---|
394 | AbstractGML.__init__(self,**kwargs) |
---|
395 | elems=['boundedBy'] |
---|
396 | addelems(self,elems) |
---|
397 | #this pattern works but can only accept EnvelopeWithTimePeriod for the boundedBy, |
---|
398 | #which is probably ok |
---|
399 | children={elems[0]:[GML('EnvelopeWithTimePeriod'), 'EnvelopeWithTimePeriod', GML('boundedBy')]} |
---|
400 | addchildren(self,children) |
---|
401 | csElement.__init__(self,**kwargs) |
---|
402 | |
---|
403 | class AbstractFeatureCollection(AbstractFeature,csElement): |
---|
404 | def __init__(self, **kwargs): |
---|
405 | AbstractFeature.__init__(self,**kwargs) |
---|
406 | csElement.__init__(self,**kwargs) |
---|
407 | |
---|
408 | class DomainSet(AbstractGML,AssociationAttributeGroup,csElement): |
---|
409 | def __init__(self, **kwargs): |
---|
410 | AbstractGML.__init__(self,**kwargs) |
---|
411 | addchildren(self,{}) |
---|
412 | csElement.__init__(self,**kwargs) |
---|
413 | |
---|
414 | class AggregatedArray(ArrayDescriptor,csElement): |
---|
415 | def __init__(self, **kwargs): |
---|
416 | ArrayDescriptor.__init__(self,**kwargs) |
---|
417 | elems=['aggType', 'aggIndex', 'components'] |
---|
418 | addelems(self,elems) |
---|
419 | children={elems[0]:[CSML('aggType'),'csString'], elems[1]:[CSML('aggIndex'),'csString'],elems[2]:[FILEFORMATS, 'ArrayDescriptor',CSML('component')]} |
---|
420 | addchildren(self,children) |
---|
421 | csElement.__init__(self,**kwargs) |
---|
422 | |
---|
423 | |
---|
424 | class MeasureOrNullList(AbstractGML,AssociationAttributeGroup, csElement): |
---|
425 | def __init__(self, **kwargs): |
---|
426 | AbstractGML.__init__(self,**kwargs) |
---|
427 | AssociationAttributeGroup.__init__(self,**kwargs) |
---|
428 | elems=['insertedExtract'] |
---|
429 | addelems(self,elems) |
---|
430 | #note insertedExtract is used in resolving xlinks and shouldn't be written to directly (except by the code which handles the xlink resolutions) |
---|
431 | children={elems[0]:[FILEFORMATS,'FileExtract',CSML('insertedExtract')]} |
---|
432 | addchildren(self,children) |
---|
433 | a =['uom'] |
---|
434 | addatts(self,a) |
---|
435 | csElement.__init__(self,**kwargs) |
---|
436 | |
---|
437 | def toXML(self,csmlfrag,**kwargs): |
---|
438 | temp=None |
---|
439 | if hasattr(self, 'insertedExtract'): |
---|
440 | temp=self.insertedExtract |
---|
441 | del self.insertedExtract #don't want to expose this in XML |
---|
442 | csmlfrag=csElement.toXML(self,csmlfrag, **kwargs) |
---|
443 | if temp is not None: |
---|
444 | self.insertedExtract=temp |
---|
445 | return csmlfrag |
---|
446 | |
---|
447 | |
---|
448 | class CompositeValue(AbstractGML,csElement): |
---|
449 | def __init__(self, **kwargs): |
---|
450 | AbstractGML.__init__(self,**kwargs) |
---|
451 | elems=['measures'] |
---|
452 | addelems(self,elems) |
---|
453 | children={elems[0]:[GML('measure'),'csString',GML('valueComponents')]} |
---|
454 | addchildren(self,children) |
---|
455 | csElement.__init__(self,**kwargs) |
---|
456 | |
---|
457 | class DataBlock(AbstractGML,csElement): |
---|
458 | #THIS IS INCOMPLETE |
---|
459 | def __init__(self, **kwargs): |
---|
460 | AbstractGML.__init__(self,**kwargs) |
---|
461 | elems=['doubleOrNullTupleList','rangeParameters'] |
---|
462 | addelems(self,elems) |
---|
463 | children={elems[0]:[GML('doubleOrNullTupleList'),'csString'],elems[1]:[GML('CompositeValue'), 'CompositeValue', GML('rangeParameters')]} |
---|
464 | addchildren(self,children) |
---|
465 | csElement.__init__(self,**kwargs) |
---|
466 | |
---|
467 | class ValueArray(AbstractGML, csElement): |
---|
468 | def __init__(self, **kwargs): |
---|
469 | AbstractGML.__init__(self,**kwargs) |
---|
470 | elems=['valueComponent'] |
---|
471 | addelems(self,elems) |
---|
472 | children=children={elems[0]:[GML('QuantityList'), 'MeasureOrNullList', GML('valueComponent')]} |
---|
473 | addchildren(self,children) |
---|
474 | csElement.__init__(self,**kwargs) |
---|
475 | |
---|
476 | def toXML(self, csmlfrag, **kwargs): |
---|
477 | csmlfrag=AbstractGML.toXML(self, csmlfrag,**kwargs) |
---|
478 | #promote XLinks up from QuantityList |
---|
479 | #this all done at the elementtree level |
---|
480 | |
---|
481 | for frag in csmlfrag: |
---|
482 | if frag.tag ==GML('valueComponent'): |
---|
483 | try: |
---|
484 | frag.set(XLINK('href'),self.valueComponent.href) |
---|
485 | for subfrag in frag: |
---|
486 | del subfrag.attrib[XLINK('href')] |
---|
487 | except: |
---|
488 | pass |
---|
489 | try: |
---|
490 | frag.set(XLINK('show'),self.valueComponent.show) |
---|
491 | for subfrag in frag: |
---|
492 | del subfrag.attrib[XLINK('show')] |
---|
493 | except: |
---|
494 | pass |
---|
495 | try: |
---|
496 | frag.set(XLINK('role'),self.valueComponent.role) |
---|
497 | for subfrag in frag: |
---|
498 | del subfrag.attrib[XLINK('role')] |
---|
499 | except: |
---|
500 | pass |
---|
501 | try: |
---|
502 | frag.set(XLINK('arcrole'),self.valueComponent.arcrole) |
---|
503 | for subfrag in frag: |
---|
504 | del subfrag.attrib[XLINK('arcrole')] |
---|
505 | except: |
---|
506 | pass |
---|
507 | return csmlfrag |
---|
508 | |
---|
509 | def fromXML(self, csmlfrag): |
---|
510 | #promote xlinks up a level to the property element |
---|
511 | for frag in csmlfrag: |
---|
512 | if frag.tag == GML('valueComponent'): |
---|
513 | for att in ['href', 'show', 'role', 'arcrole']: |
---|
514 | try: |
---|
515 | for subfrag in frag[:]: |
---|
516 | subfrag.set(XLINK(att),frag.attrib[XLINK(att)]) |
---|
517 | except: |
---|
518 | pass |
---|
519 | csElement.fromXML(self, csmlfrag) |
---|
520 | |
---|
521 | class RangeSet(AbstractGML,AssociationAttributeGroup,csElement): |
---|
522 | def __init__(self, **kwargs): |
---|
523 | AbstractGML.__init__(self,**kwargs) |
---|
524 | AssociationAttributeGroup.__init__(self,**kwargs) |
---|
525 | elems=['quantityList', 'dataBlock', 'arrayDescriptor', 'valueArray'] |
---|
526 | addelems(self,elems) |
---|
527 | children={elems[0]:[GML('QuantityList'), 'MeasureOrNullList'], elems[1]:[GML('DataBlock'),'DataBlock'],elems[2]:[FILEFORMATS, 'ArrayDescriptor'], elems[3]:[CSML('AggregatedArray'), 'AggregatedArray'], |
---|
528 | elems[3]:[GML('ValueArray'),'ValueArray']} |
---|
529 | addchildren(self,children) |
---|
530 | csElement.__init__(self,**kwargs) |
---|
531 | |
---|
532 | class MultiPoint(AbstractGML, SRSReferenceGroup,csElement): |
---|
533 | def __init__(self, **kwargs): |
---|
534 | AbstractGML.__init__(self,**kwargs) |
---|
535 | SRSReferenceGroup.__init__(self,**kwargs) |
---|
536 | elems=['pointMember','pointMembers'] |
---|
537 | addelems(self,elems) |
---|
538 | children={elems[0]:[GML('pointMember'), 'csString'],elems[1]:[GML('pointMembers'), 'csString']} |
---|
539 | addchildren(self,children) |
---|
540 | csElement.__init__(self,**kwargs) |
---|
541 | |
---|
542 | class Point(AbstractGML,SRSReferenceGroup,csElement): |
---|
543 | def __init__(self, **kwargs): |
---|
544 | AbstractGML.__init__(self,**kwargs) |
---|
545 | SRSReferenceGroup.__init__(self,**kwargs) |
---|
546 | elems=['pos','coordinates'] |
---|
547 | addelems(self,elems) |
---|
548 | children={elems[0]:[GML('pos'), 'csString'],elems[1]:[GML('coordinates'), 'csString']} |
---|
549 | addchildren(self,children) |
---|
550 | csElement.__init__(self,**kwargs) |
---|
551 | |
---|
552 | class PointDomain(DomainSet, MultiPoint,csElement): |
---|
553 | def __init__(self, **kwargs): |
---|
554 | DomainSet.__init__(self,**kwargs) |
---|
555 | MultiPoint.__init__(self,**kwargs) |
---|
556 | children={} |
---|
557 | addchildren(self,children) |
---|
558 | csElement.__init__(self,**kwargs) |
---|
559 | |
---|
560 | class ProfileDomain(DomainSet, MultiPoint,csElement): |
---|
561 | def __init__(self, **kwargs): |
---|
562 | DomainSet.__init__(self,**kwargs) |
---|
563 | MultiPoint.__init__(self,**kwargs) |
---|
564 | children={} |
---|
565 | addchildren(self,children) |
---|
566 | csElement.__init__(self,**kwargs) |
---|
567 | |
---|
568 | |
---|
569 | class AbstractCoverage(AbstractFeature, csElement): |
---|
570 | def __init__(self, **kwargs): |
---|
571 | AbstractFeature.__init__(self,**kwargs) |
---|
572 | csElement.__init__(self,**kwargs) |
---|
573 | |
---|
574 | class AbstractDiscreteCoverage(AbstractCoverage, csElement): |
---|
575 | def __init__(self, **kwargs): |
---|
576 | AbstractCoverage.__init__(self,**kwargs) |
---|
577 | addchildren(self,{}) |
---|
578 | csElement.__init__(self,**kwargs) |
---|
579 | |
---|
580 | class Definition(AbstractGML): |
---|
581 | def __init__(self, **kwargs): |
---|
582 | AbstractGML.__init__(self,**kwargs) |
---|
583 | addchildren(self,{}) |
---|
584 | csElement.__init__(self,**kwargs) |
---|
585 | |
---|
586 | class Phenomenon(Definition,AssociationAttributeGroup): |
---|
587 | def __init__(self, **kwargs): |
---|
588 | Definition.__init__(self,**kwargs) |
---|
589 | AssociationAttributeGroup.__init__(self,**kwargs) |
---|
590 | children = {'':[CSML(''), '']} |
---|
591 | addchildren(self,children) |
---|
592 | csElement.__init__(self,**kwargs) |
---|
593 | |
---|
594 | class SpatialOrTemporalPositionList(AssociationAttributeGroup, AbstractGML, csElement): |
---|
595 | def __init__(self, **kwargs): |
---|
596 | AbstractGML.__init__(self,**kwargs) |
---|
597 | AssociationAttributeGroup.__init__(self,**kwargs) |
---|
598 | elems=['coordinateList', 'timePositionList','insertedExtract'] |
---|
599 | addelems(self,elems) |
---|
600 | children={elems[0]:[CSML('coordinateList'),'csString'], elems[1]:[CSML('timePositionList'),'TimePositionList'],elems[2]:[FILEFORMATS,'FileExtract',CSML('insertedExtract')]} |
---|
601 | addchildren(self,children) |
---|
602 | csElement.__init__(self,**kwargs) |
---|
603 | |
---|
604 | def toXML(self,csmlfrag,**kwargs): |
---|
605 | temp=None |
---|
606 | if hasattr(self, 'insertedExtract'): |
---|
607 | temp=self.insertedExtract |
---|
608 | del self.insertedExtract #don't want to expose this in XML |
---|
609 | csmlfrag=csElement.toXML(self,csmlfrag, **kwargs) |
---|
610 | #This is mandatory even if empty when using xlink |
---|
611 | if not hasattr(self, 'timePositionList'): |
---|
612 | if not hasattr(self, 'coordinateList'): |
---|
613 | if csmlfrag.get(XLINK('arcrole')) is not None: |
---|
614 | if csmlfrag.get(XLINK('arcrole')).split('#')[1] == 'timePositionList': |
---|
615 | ET.SubElement(csmlfrag, CSML('timePositionList')) |
---|
616 | elif csmlfrag.get(XLINK('arcrole')).split('#')[1] =='coordinateList': |
---|
617 | ET.SubElement(csmlfrag, CSML('coordinateList')) |
---|
618 | if temp !=None: |
---|
619 | self.insertedExtract=temp |
---|
620 | return csmlfrag |
---|
621 | |
---|
622 | class GridOrdinateDescription(AbstractGML,csElement): |
---|
623 | def __init__(self, **kwargs): |
---|
624 | AbstractGML.__init__(self,**kwargs) |
---|
625 | elems=['coordAxisLabel', 'coordAxisValues', 'gridAxesSpanned', 'sequenceRule'] |
---|
626 | addelems(self,elems) |
---|
627 | children={elems[0]:[CSML('coordAxisLabel'), 'csString'], elems[1]:[CSML('SpatialOrTemporalPositionList'),'SpatialOrTemporalPositionList',CSML('coordAxisValues')], elems[2]:[CSML('gridAxesSpanned'), 'csString'], elems[3]:[CSML('sequenceRule'),'SequenceRule']} |
---|
628 | addchildren(self,children) |
---|
629 | csElement.__init__(self,**kwargs) |
---|
630 | def toXML(self, csmlfrag, **kwargs): |
---|
631 | csmlfrag=AbstractGML.toXML(self, csmlfrag,**kwargs) |
---|
632 | #promote XLinks up from SpatialOrTemporalPositionList |
---|
633 | #this all done at the elementtree level |
---|
634 | |
---|
635 | for frag in csmlfrag: |
---|
636 | if frag.tag ==CSML('coordAxisValues'): |
---|
637 | try: |
---|
638 | frag.set(XLINK('href'),self.coordAxisValues.href) |
---|
639 | for subfrag in frag: |
---|
640 | del subfrag.attrib[XLINK('href')] |
---|
641 | except: |
---|
642 | pass |
---|
643 | try: |
---|
644 | frag.set(XLINK('show'),self.coordAxisValues.show) |
---|
645 | for subfrag in frag: |
---|
646 | del subfrag.attrib[XLINK('show')] |
---|
647 | except: |
---|
648 | pass |
---|
649 | try: |
---|
650 | frag.set(XLINK('role'),self.coordAxisValues.role) |
---|
651 | for subfrag in frag: |
---|
652 | del subfrag.attrib[XLINK('role')] |
---|
653 | except: |
---|
654 | pass |
---|
655 | try: |
---|
656 | frag.set(XLINK('arcrole'),self.coordAxisValues.arcrole) |
---|
657 | for subfrag in frag: |
---|
658 | del subfrag.attrib[XLINK('arcrole')] |
---|
659 | except: |
---|
660 | pass |
---|
661 | |
---|
662 | |
---|
663 | return csmlfrag |
---|
664 | |
---|
665 | def fromXML(self, csmlfrag): |
---|
666 | #promote xlinks up a level to the coordAxisValues property element |
---|
667 | for frag in csmlfrag: |
---|
668 | if frag.tag == CSML('coordAxisValues'): |
---|
669 | for att in ['href', 'show', 'role', 'arcrole']: |
---|
670 | try: |
---|
671 | for subfrag in frag[:]: |
---|
672 | subfrag.set(XLINK(att),frag.attrib[XLINK(att)]) |
---|
673 | except: |
---|
674 | pass |
---|
675 | |
---|
676 | csElement.fromXML(self, csmlfrag) |
---|
677 | |
---|
678 | |
---|
679 | |
---|
680 | class SequenceRule(csElement): |
---|
681 | def __init__(self, **kwargs): |
---|
682 | a=['axisOrder'] |
---|
683 | addatts(self,a) |
---|
684 | children={} |
---|
685 | addchildren(self,children) |
---|
686 | csElement.__init__(self,**kwargs) |
---|
687 | |
---|
688 | class GridPointDescription(AbstractGML,csElement): |
---|
689 | def __init__(self, **kwargs): |
---|
690 | AbstractGML.__init__(self,**kwargs) |
---|
691 | elems=['posList', 'sequenceRule'] |
---|
692 | addelems(self,elems) |
---|
693 | children={elems[0]:[CSML('posList'),'csString'],elems[1]:[CSML('sequenceRule'),'SequenceRule']} |
---|
694 | addchildren(self,children) |
---|
695 | csElement.__init__(self,**kwargs) |
---|
696 | |
---|
697 | class TimePositionList(AbstractGML,csString,csElement): |
---|
698 | def __init__(self, **kwargs): |
---|
699 | AbstractGML.__init__(self,**kwargs) |
---|
700 | csString.__init__(self, **kwargs) |
---|
701 | elems=[] |
---|
702 | addelems(self,elems) |
---|
703 | a=['frame', 'calendarEraName','indeterminatePosition'] |
---|
704 | addatts(self,a) |
---|
705 | addchildren(self,{}) |
---|
706 | csElement.__init__(self,**kwargs) |
---|
707 | |
---|
708 | class GridCoordinatesTable(AbstractGML,csElement): |
---|
709 | def __init__(self,**kwargs): |
---|
710 | '''the additional value '1' in the children dictionary is used to signify that the elements must be nested as: |
---|
711 | <gml:ordinate> |
---|
712 | <gml:GridOrdinateDescription> |
---|
713 | </gml:ordinate> |
---|
714 | <gml:ordinate> |
---|
715 | <gml:GridOrdinateDescription> |
---|
716 | </gml:ordinate> |
---|
717 | |
---|
718 | not as: |
---|
719 | <gml:ordinate> |
---|
720 | <gml:GridOrdinateDescription> |
---|
721 | <gml:GridOrdinateDescription> |
---|
722 | </gml:ordinate> ''' |
---|
723 | AbstractGML.__init__(self,**kwargs) |
---|
724 | elems=['gridOrdinates' , 'gridPoints'] |
---|
725 | addelems(self,elems) |
---|
726 | children={elems[0]:[CSML('GridOrdinateDescription'), 'GridOrdinateDescription',CSML('gridOrdinate'),1], elems[1]:[CSML('GridPointDescription'),'GridPointDescription',CSML('gridPoints')]} |
---|
727 | addchildren(self,children) |
---|
728 | csElement.__init__(self,**kwargs) |
---|
729 | |
---|
730 | class Grid(AbstractGML, AssociationAttributeGroup, SRSInformationGroup, SRSReferenceGroup, csElement): |
---|
731 | def __init__(self, **kwargs): |
---|
732 | AbstractGML.__init__(self,**kwargs) |
---|
733 | AssociationAttributeGroup.__init__(self,**kwargs) |
---|
734 | SRSReferenceGroup.__init__(self,**kwargs) |
---|
735 | SRSInformationGroup.__init__(self,**kwargs) |
---|
736 | a=['dimension'] |
---|
737 | addatts(self,a) |
---|
738 | elems=['limits', 'aLabels','axisName'] |
---|
739 | addelems(self, elems) |
---|
740 | children = {elems[1]:[CSML('axisLabels'),'csString'],elems[2]:[CSML('axisName'),'csString'], elems[0]:[GML('GridEnvelope'),'GridEnvelope',CSML('limits')]} |
---|
741 | addchildren(self,children) |
---|
742 | csElement.__init__(self,**kwargs) |
---|
743 | |
---|
744 | class ReferenceableGrid(Grid, csElement): |
---|
745 | def __init__(self, **kwargs): |
---|
746 | Grid.__init__(self,**kwargs) |
---|
747 | elems=['coordTransformTable'] |
---|
748 | addelems(self,elems) |
---|
749 | children={elems[0]:[CSML('GridCoordinatesTable'), 'GridCoordinatesTable', CSML('coordTransformTable')]} |
---|
750 | addchildren(self,children) |
---|
751 | csElement.__init__(self,**kwargs) |
---|
752 | |
---|
753 | class ReferenceableGridCoverage(AbstractDiscreteCoverage, csElement): |
---|
754 | def __init__(self, **kwargs): |
---|
755 | AbstractDiscreteCoverage.__init__(self,**kwargs) |
---|
756 | elems=[referenceableGridDomain] |
---|
757 | addelems(self,elems) |
---|
758 | children={elems[0]:[CSML('ReferenceableGrid'),'ReferenceableGrid' ,CSML('referenceableGridDomain') ]} |
---|
759 | addchildren(self,children) |
---|
760 | csElement.__init__(self,**kwargs) |
---|
761 | |
---|
762 | class AlternatePointCoverage(AbstractDiscreteCoverage, csElement): |
---|
763 | def __init__(self, **kwargs): |
---|
764 | AbstractDiscreteCoverage.__init__(self,**kwargs) |
---|
765 | elems=['alternatePointDomain','rangeSet','coverageFunction'] |
---|
766 | addelems(self,elems) |
---|
767 | children={elems[0]:[GML('Point'),'Point', CSML('alternatePointDomain')], elems[1]:[GML('rangeSet'), 'RangeSet'],elems[2]:[GML('coverageFunction'),'csString']} |
---|
768 | addchildren(self,children) |
---|
769 | csElement.__init__(self,**kwargs) |
---|
770 | |
---|
771 | class ProfileCoverage(AbstractDiscreteCoverage, csElement): |
---|
772 | def __init__(self, **kwargs): |
---|
773 | AbstractDiscreteCoverage.__init__(self,**kwargs) |
---|
774 | elems=['profileDomain', 'rangeSet' ,'coverageFunction'] |
---|
775 | addelems(self,elems) |
---|
776 | children={elems[0]:[CSML('ProfileDomain'),'ProfileDomain' ,CSML('profileDomain') ], elems[1]:[GML('rangeSet'), 'RangeSet'],elems[2]:[GML('coverageFunction'),'csString']} |
---|
777 | addchildren(self,children) |
---|
778 | csElement.__init__(self,**kwargs) |
---|
779 | |
---|
780 | class PointCoverage(AbstractDiscreteCoverage, csElement): |
---|
781 | def __init__(self, **kwargs): |
---|
782 | AbstractDiscreteCoverage.__init__(self,**kwargs) |
---|
783 | elems=['pointDomain','rangeSet', 'coverageFunction'] |
---|
784 | addelems(self,elems) |
---|
785 | children={elems[0]:[CSML('PointDomain'),'PointDomain' ,CSML('pointDomain') ], elems[1]:[GML('rangeSet'), 'RangeSet'],elems[2]:[GML('coverageFunction'),'csString']} |
---|
786 | addchildren(self,children) |
---|
787 | csElement.__init__(self,**kwargs) |
---|
788 | |
---|
789 | class TimeSeries(AbstractGML, csElement): |
---|
790 | def __init__(self, **kwargs): |
---|
791 | AbstractGML.__init__(self,**kwargs) |
---|
792 | elems=['timePositionList'] |
---|
793 | addelems(self,elems) |
---|
794 | children={elems[0]:[CSML('timePositionList'), 'csString']} |
---|
795 | addchildren(self,children) |
---|
796 | csElement.__init__(self,**kwargs) |
---|
797 | |
---|
798 | class PointSeriesCoverage(AbstractDiscreteCoverage, csElement): |
---|
799 | def __init__(self, **kwargs): |
---|
800 | AbstractDiscreteCoverage.__init__(self,**kwargs) |
---|
801 | elems=['pointSeriesDomain','rangeSet','coverageFunction'] |
---|
802 | addelems(self,elems) |
---|
803 | children={elems[0]:[CSML('TimeSeries'),'TimeSeries' ,CSML('pointSeriesDomain') ], elems[1]:[GML('rangeSet'), 'RangeSet'],elems[2]:[GML('coverageFunction'),'csString']} |
---|
804 | addchildren(self,children) |
---|
805 | csElement.__init__(self,**kwargs) |
---|
806 | |
---|
807 | class ProfileSeriesDomain(ReferenceableGrid, DomainSet, csElement): |
---|
808 | def __init__(self, **kwargs): |
---|
809 | DomainSet.__init__(self,**kwargs) |
---|
810 | ReferenceableGrid.__init__(self,**kwargs) |
---|
811 | children={} |
---|
812 | addchildren(self,children) |
---|
813 | csElement.__init__(self,**kwargs) |
---|
814 | |
---|
815 | class ProfileSeriesCoverage(AbstractDiscreteCoverage,csElement): |
---|
816 | def __init__(self, **kwargs): |
---|
817 | AbstractDiscreteCoverage.__init__(self,**kwargs) |
---|
818 | elems=['profileSeriesDomain', 'rangeSet', 'coverageFunction'] |
---|
819 | addelems(self,elems) |
---|
820 | children={elems[0]:[CSML('ProfileSeriesDomain'),'ProfileSeriesDomain' ,CSML('profileSeriesDomain') ], elems[1]:[GML('rangeSet'), 'RangeSet'],elems[2]:[GML('coverageFunction'),'csString']} |
---|
821 | addchildren(self,children) |
---|
822 | csElement.__init__(self,**kwargs) |
---|
823 | |
---|
824 | class SectionDomain(ReferenceableGrid, DomainSet, csElement): |
---|
825 | def __init__(self, **kwargs): |
---|
826 | DomainSet.__init__(self,**kwargs) |
---|
827 | ReferenceableGrid.__init__(self,**kwargs) |
---|
828 | children={} |
---|
829 | addchildren(self,children) |
---|
830 | csElement.__init__(self,**kwargs) |
---|
831 | |
---|
832 | class SectionCoverage(AbstractDiscreteCoverage,csElement): |
---|
833 | def __init__(self, **kwargs): |
---|
834 | AbstractDiscreteCoverage.__init__(self,**kwargs) |
---|
835 | elems=['sectionDomain', 'rangeSet' , 'coverageFunction'] |
---|
836 | addelems(self,elems) |
---|
837 | children={elems[0]:[CSML('SectionDomain'),'SectionDomain' ,CSML('sectionDomain') ],elems[1]:[GML('rangeSet'), 'RangeSet'],elems[2]:[GML('coverageFunction'),'csString']} |
---|
838 | addchildren(self,children) |
---|
839 | csElement.__init__(self,**kwargs) |
---|
840 | |
---|
841 | class TrajectoryDomain(ReferenceableGrid, DomainSet, csElement): |
---|
842 | def __init__(self, **kwargs): |
---|
843 | DomainSet.__init__(self,**kwargs) |
---|
844 | ReferenceableGrid.__init__(self,**kwargs) |
---|
845 | children={} |
---|
846 | addchildren(self,children) |
---|
847 | csElement.__init__(self,**kwargs) |
---|
848 | |
---|
849 | class TrajectoryCoverage(AbstractDiscreteCoverage,csElement): |
---|
850 | def __init__(self, **kwargs): |
---|
851 | AbstractDiscreteCoverage.__init__(self,**kwargs) |
---|
852 | elems=['trajectoryDomain', 'rangeSet', 'coverageFunction'] |
---|
853 | addelems(self,elems) |
---|
854 | children={elems[0]:[CSML('TrajectoryDomain'),'TrajectoryDomain' ,CSML('trajectoryDomain') ], elems[1]:[GML('rangeSet'), 'RangeSet'],elems[2]:[GML('coverageFunction'),'csString']} |
---|
855 | addchildren(self,children) |
---|
856 | csElement.__init__(self,**kwargs) |
---|
857 | |
---|
858 | class ScanningRadarDomain(ReferenceableGrid, DomainSet, csElement): |
---|
859 | def __init__(self, **kwargs): |
---|
860 | DomainSet.__init__(self,**kwargs) |
---|
861 | ReferenceableGrid.__init__(self,**kwargs) |
---|
862 | children={} |
---|
863 | addchildren(self,children) |
---|
864 | csElement.__init__(self,**kwargs) |
---|
865 | |
---|
866 | class ScanningRadarCoverage(AbstractDiscreteCoverage,csElement): |
---|
867 | def __init__(self, **kwargs): |
---|
868 | AbstractDiscreteCoverage.__init__(self,**kwargs) |
---|
869 | elems=['scanningRadarDomain', 'rangeSet','coverageFunction'] |
---|
870 | addelems(self,elems) |
---|
871 | children={elems[0]:[CSML('ScanningRadarDomain'),'ScanningRadarDomain' ,CSML('scanningRadarDomain') ], elems[1]:[GML('rangeSet'), 'RangeSet'],elems[2]:[GML('coverageFunction'),'csString']} |
---|
872 | addchildren(self,children) |
---|
873 | csElement.__init__(self,**kwargs) |
---|
874 | |
---|
875 | |
---|
876 | class GridSeriesDomain(ReferenceableGrid, csElement): |
---|
877 | def __init__(self, **kwargs): |
---|
878 | #DomainSet.__init__(self,**kwargs) |
---|
879 | ReferenceableGrid.__init__(self,**kwargs) |
---|
880 | children={} |
---|
881 | addchildren(self,children) |
---|
882 | csElement.__init__(self,**kwargs) |
---|
883 | |
---|
884 | class GridSeriesCoverage(AbstractDiscreteCoverage,csElement): |
---|
885 | def __init__(self, **kwargs): |
---|
886 | elems=['gridSeriesDomain', 'rangeSet', 'coverageFunction'] |
---|
887 | addelems(self,elems) |
---|
888 | children={elems[0]:[CSML('GridSeriesDomain'),'GridSeriesDomain' ,CSML('gridSeriesDomain') ], elems[1]:[GML('rangeSet'), 'RangeSet'],elems[2]:[GML('coverageFunction'),'csString']} |
---|
889 | addchildren(self,children) |
---|
890 | AbstractDiscreteCoverage.__init__(self,**kwargs) |
---|
891 | csElement.__init__(self,**kwargs) |
---|
892 | |
---|
893 | class AlternatePointFeature(AbstractFeature, csElement): |
---|
894 | def __init__(self, **kwargs): |
---|
895 | AbstractFeature.__init__(self,**kwargs) |
---|
896 | self.featureType='AlternatePointFeature' |
---|
897 | elems=['location', 'time', 'value','parameter'] |
---|
898 | addelems(self,elems) |
---|
899 | children={elems[0]:[CSML('location'), 'csString'],elems[1]:[CSML('time'), 'csString'], elems[2]:[CSML('AlternatePointCoverage'), 'AlternatePointCoverage', CSML('value')],elems[3]:[CSML('parameter'), 'Phenomenon']} |
---|
900 | addchildren(self,children) |
---|
901 | csElement.__init__(self,**kwargs) |
---|
902 | |
---|
903 | class DirectPositionList(SRSReferenceGroup, csElement): |
---|
904 | def __init__(self, **kwargs): |
---|
905 | SRSReferenceGroup.__init__(self,**kwargs) |
---|
906 | children=[] |
---|
907 | addchildren(self,children) |
---|
908 | csElement.__init__(self,**kwargs) |
---|
909 | |
---|
910 | class PointFeature(AbstractFeature, csElement): |
---|
911 | def __init__(self, **kwargs): |
---|
912 | AbstractFeature.__init__(self,**kwargs) |
---|
913 | self.featureType='PointFeature' |
---|
914 | elems=['location', 'time', 'value','parameter'] |
---|
915 | addelems(self,elems) |
---|
916 | children={elems[0]:[CSML('location'), 'DirectPositionList'],elems[1]:[CSML('time'), 'csString'], elems[2]:[CSML('PointCoverage'), 'PointCoverage', CSML('value')], elems[3]:[CSML('parameter'), 'Phenomenon']} |
---|
917 | addchildren(self,children) |
---|
918 | csElement.__init__(self,**kwargs) |
---|
919 | |
---|
920 | class PointCollectionFeature(AbstractFeature, csElement): |
---|
921 | def __init__(self, **kwargs): |
---|
922 | AbstractFeature.__init__(self,**kwargs) |
---|
923 | self.featureType='PointCollectionFeature' |
---|
924 | elems=['time', 'value', 'parameter'] |
---|
925 | addelems(self,elems) |
---|
926 | children={elems[0]:[CSML('time'), 'csString'], elems[1]:[CSML('MultiPointCoverage'), 'MultiPointCoverage', CSML('value')], elems[2]:[CSML('parameter'), 'Phenomenon']} |
---|
927 | addchildren(self,children) |
---|
928 | csElement.__init__(self,**kwargs) |
---|
929 | |
---|
930 | |
---|
931 | class PointSeriesFeature(AbstractFeature, csElement): |
---|
932 | def __init__(self, **kwargs): |
---|
933 | AbstractFeature.__init__(self,**kwargs) |
---|
934 | self.featureType='PointSeriesFeature' |
---|
935 | elems=['location','value','parameter'] |
---|
936 | addelems(self,elems) |
---|
937 | children={elems[0]:[CSML('location'), 'csString'], elems[1]:[CSML('PointSeriesCoverage'), 'PointSeriesCoverage', CSML('value')], elems[2]:[CSML('parameter'), 'Phenomenon']} |
---|
938 | addchildren(self,children) |
---|
939 | csElement.__init__(self,**kwargs) |
---|
940 | |
---|
941 | |
---|
942 | class GridFeature(AbstractFeature, csElement): |
---|
943 | def __init__(self, **kwargs): |
---|
944 | AbstractFeature.__init__(self,**kwargs) |
---|
945 | self.featureType='GridFeature' |
---|
946 | elems=['time', 'value', 'parameter'] |
---|
947 | addelems(self,elems) |
---|
948 | children={elems[0]:[CSML('time'), 'csString'], elems[1]:[CSML('ReferenceableGridCoverage'), 'ReferenceableGridCoverage', CSML('value')], elems[2]:[CSML('parameter'), 'Phenomenon']} |
---|
949 | addchildren(self,children) |
---|
950 | csElement.__init__(self,**kwargs) |
---|
951 | |
---|
952 | class GridSeriesFeature(AbstractFeature, csElement): |
---|
953 | def __init__(self, **kwargs): |
---|
954 | AbstractFeature.__init__(self,**kwargs) |
---|
955 | self.featureType='GridSeriesFeature' |
---|
956 | elems=['value','parameter'] |
---|
957 | addelems(self,elems) |
---|
958 | children={elems[0]:[CSML('GridSeriesCoverage'), 'GridSeriesCoverage', CSML('value')],elems[1]:[CSML('parameter'), 'Phenomenon']} |
---|
959 | addchildren(self,children) |
---|
960 | csElement.__init__(self,**kwargs) |
---|
961 | |
---|
962 | class ProfileFeature(AbstractFeature, csElement): |
---|
963 | def __init__(self, **kwargs): |
---|
964 | AbstractFeature.__init__(self,**kwargs) |
---|
965 | self.featureType='ProfileFeature' |
---|
966 | elems=['location', 'time','value', 'parameter'] |
---|
967 | addelems(self,elems) |
---|
968 | children={elems[0]:[CSML('location'), 'csString'],elems[1]:[CSML('time'), 'csString'], elems[2]:[CSML('ProfileCoverage'), 'ProfileCoverage', CSML('value')], elems[3]:[CSML('parameter'), 'Phenomenon']} |
---|
969 | addchildren(self,children) |
---|
970 | csElement.__init__(self,**kwargs) |
---|
971 | |
---|
972 | class ProfileSeriesFeature(AbstractFeature, csElement): |
---|
973 | def __init__(self, **kwargs): |
---|
974 | AbstractFeature.__init__(self,**kwargs) |
---|
975 | self.featureType='ProfileSeriesFeature' |
---|
976 | elems=['location', 'value', 'parameter'] |
---|
977 | addelems(self,elems) |
---|
978 | children={elems[0]:[CSML('location'), 'csString'], elems[1]:[CSML('ProfileSeriesCoverage'), 'ProfileSeriesCoverage', CSML('value')], elems[2]:[CSML('parameter'), 'Phenomenon']} |
---|
979 | addchildren(self,children) |
---|
980 | csElement.__init__(self,**kwargs) |
---|
981 | |
---|
982 | class RaggedProfileSeriesFeature(AbstractFeature, csElement): |
---|
983 | def __init__(self, **kwargs): |
---|
984 | AbstractFeature.__init__(self,**kwargs) |
---|
985 | self.featureType='RaggedProfileSeriesFeature' |
---|
986 | elems=['location', 'profileLength', 'value', 'parameter'] |
---|
987 | addelems(self,elems) |
---|
988 | children={elems[0]:[CSML('location'), 'csString'], elems[1]:[CSML('profileLength'), 'csString'],elems[2]:[CSML('ProfileSeriesCoverage'), 'ProfileSeriesCoverage', CSML('value')], elems[3]:[CSML('parameter'), 'Phenomenon']} |
---|
989 | addchildren(self,children) |
---|
990 | csElement.__init__(self,**kwargs) |
---|
991 | |
---|
992 | class RaggedSectionFeature(AbstractFeature, csElement): |
---|
993 | def __init__(self, **kwargs): |
---|
994 | AbstractFeature.__init__(self,**kwargs) |
---|
995 | self.featureType='RaggedSectionFeature' |
---|
996 | elems=['stationLocations', 'stationTimes', 'profileLength', 'value','parameter'] |
---|
997 | addelems(self,elems) |
---|
998 | children={elems[0]:[CSML('stationLocations'), 'csString'], elems[1]:[CSML('stationTimes'), 'csString'],elems[2]:[CSML('profileLength'),'csString'],elems[3]:[CSML('SectionCoverage'), 'SectionCoverage', CSML('value')], elems[4]:[CSML('parameter'), 'Phenomenon']} |
---|
999 | addchildren(self,children) |
---|
1000 | csElement.__init__(self,**kwargs) |
---|
1001 | |
---|
1002 | class SectionFeature(AbstractFeature, csElement): |
---|
1003 | def __init__(self, **kwargs): |
---|
1004 | AbstractFeature.__init__(self,**kwargs) |
---|
1005 | self.featureType='SectionFeature' |
---|
1006 | elems=['stationLocations', 'stationTimes','value', 'parameter'] |
---|
1007 | addelems(self,elems) |
---|
1008 | children={elems[0]:[CSML('stationLocations'), 'csString'], elems[1]:[CSML('stationTimes'), 'TimePositionList'],elems[2]:[CSML('SectionCoverage'), 'SectionCoverage', CSML('value')], elems[3]:[CSML('parameter'), 'Phenomenon']} |
---|
1009 | addchildren(self,children) |
---|
1010 | csElement.__init__(self,**kwargs) |
---|
1011 | |
---|
1012 | class ScanningRadarFeature(AbstractFeature, csElement): |
---|
1013 | def __init__(self, **kwargs): |
---|
1014 | AbstractFeature.__init__(self,**kwargs) |
---|
1015 | self.featureType='ScanningRadarFeature' |
---|
1016 | elems=['elevation','value', 'parameter'] |
---|
1017 | addelems(self,elems) |
---|
1018 | children={elems[0]:[CSML('elevation'), 'csString'], elems[1]:[CSML('ScanningRadarCoverage'), 'ScanningRadarCoverage', CSML('value')], elems[2]:[CSML('parameter'), 'Phenomenon']} |
---|
1019 | addchildren(self,children) |
---|
1020 | csElement.__init__(self,**kwargs) |
---|
1021 | |
---|
1022 | |
---|
1023 | class SwathFeature(AbstractFeature, csElement): |
---|
1024 | def __init__(self, **kwargs): |
---|
1025 | AbstractFeature.__init__(self,**kwargs) |
---|
1026 | self.featureType='SwathFeature' |
---|
1027 | elems=['eqCrossLon', 'eqCrossTime', 'value', 'parameter'] |
---|
1028 | addelems(self,elems) |
---|
1029 | children={elems[0]:[CSML('eqCrossLon'), 'csString'],elems[1]:[CSML('eqCrossTime'), 'csString'], elems[2]:[CSML('ReferenceableGridCoverage'), 'ReferenceableGridCoverage', CSML('value')], elems[3]:[CSML('parameter'), 'Phenomenon']} |
---|
1030 | addchildren(self,children) |
---|
1031 | csElement.__init__(self,**kwargs) |
---|
1032 | |
---|
1033 | class TrajectoryFeature(AbstractFeature, csElement): |
---|
1034 | def __init__(self, **kwargs): |
---|
1035 | AbstractFeature.__init__(self,**kwargs) |
---|
1036 | self.featureType='TrajectoryFeature' |
---|
1037 | elems=['value', 'parameter'] |
---|
1038 | addelems(self,elems) |
---|
1039 | children={elems[0]:[CSML('TrajectoryCoverage'), 'TrajectoryCoverage', CSML('value')], elems[1]:[CSML('parameter'), 'Phenomenon']} |
---|
1040 | addchildren(self,children) |
---|
1041 | csElement.__init__(self,**kwargs) |
---|
1042 | |
---|
1043 | class FileList(AssociationAttributeGroup,csElement): |
---|
1044 | def __init__(self,**kwargs): |
---|
1045 | AssociationAttributeGroup.__init__(self,**kwargs) |
---|
1046 | a=['id'] |
---|
1047 | addatts(self,a) |
---|
1048 | elems=['fileNames'] |
---|
1049 | addelems(self,elems) |
---|
1050 | children= {elems[0]:[CSML('fileNames'), 'csString']} |
---|
1051 | addchildren(self,children) |
---|
1052 | csElement.__init__(self,**kwargs) |
---|
1053 | |
---|
1054 | class FileExtract(ArrayDescriptor, csElement): |
---|
1055 | def __init__(self,**kwargs): |
---|
1056 | ArrayDescriptor.__init__(self,**kwargs) |
---|
1057 | elems=['fileName', 'fileList', 'fileListXLINK'] |
---|
1058 | addelems(self,elems) |
---|
1059 | children= {elems[0]:[CSML('fileName'), 'csString'], elems[1]:[CSML('FileList'), 'FileList', CSML('fileList')],elems[2]:[CSML('fileList'), 'csString']} |
---|
1060 | addchildren(self,children) |
---|
1061 | csElement.__init__(self,**kwargs) |
---|
1062 | |
---|
1063 | def fromXML(self,csmlfrag): |
---|
1064 | ArrayDescriptor.fromXML(self,csmlfrag) |
---|
1065 | if hasattr(self, 'fileListXLINK'): |
---|
1066 | if hasattr(self, 'fileList'): |
---|
1067 | del self.fileListXLINK |
---|
1068 | |
---|
1069 | |
---|
1070 | class NetCDFExtract(FileExtract, csElement): |
---|
1071 | def __init__(self,**kwargs): |
---|
1072 | FileExtract.__init__(self, **kwargs) |
---|
1073 | elems=['variableName'] |
---|
1074 | addelems(self,elems) |
---|
1075 | children={elems[0]:[CSML('variableName'), 'csString']} |
---|
1076 | addchildren(self,children) |
---|
1077 | csElement.__init__(self,**kwargs) |
---|
1078 | |
---|
1079 | class NASAAmesExtract(FileExtract, csElement): |
---|
1080 | def __init__(self,**kwargs): |
---|
1081 | FileExtract.__init__(self, **kwargs) |
---|
1082 | elems=['variableName', 'index'] |
---|
1083 | addelems(self,elems) |
---|
1084 | children={elems[0]:[CSML('variableName'), 'csString'],elems[1]:[CSML('index'),'csString']} |
---|
1085 | addchildren(self,children) |
---|
1086 | csElement.__init__(self,**kwargs) |
---|
1087 | |
---|
1088 | class RawFileExtract(FileExtract, csElement): |
---|
1089 | |
---|
1090 | # Note: Unlike the other file extracts, this sets a self.dataInterface |
---|
1091 | # attribute, which is used by the overridden getData to determine which |
---|
1092 | # Data Interface is used to read the file. This is necessary because the |
---|
1093 | # getUnknownDataInterface() method determines which DI to use based on |
---|
1094 | # filename suffix (raw files could be called anything) or by inspecting |
---|
1095 | # the file (raw files have no magic numbers or other markers that could |
---|
1096 | # be used to unequivocally determine the file type). |
---|
1097 | def __init__(self,**kwargs): |
---|
1098 | FileExtract.__init__(self, **kwargs) |
---|
1099 | elems=['endianness', 'fillValue'] |
---|
1100 | addelems(self,elems) |
---|
1101 | children={elems[0]:[CSML('endianness'), 'csString'],elems[1]:[CSML('fillValue'), 'csString']} |
---|
1102 | addchildren(self,children) |
---|
1103 | csElement.__init__(self,**kwargs) |
---|
1104 | self.dataInterface = csml.csmllibs.csmldataiface.RawFileInterface |
---|
1105 | |
---|
1106 | class ImageFileExtract(RawFileExtract, csElement): |
---|
1107 | def __init__(self,**kwargs): |
---|
1108 | FileExtract.__init__(self, **kwargs) |
---|
1109 | elems=['fillValue'] |
---|
1110 | addelems(self,elems) |
---|
1111 | children={elems[0]:[CSML('fillValue'), 'csString']} |
---|
1112 | addchildren(self,children) |
---|
1113 | csElement.__init__(self,**kwargs) |
---|
1114 | self.dataInterface = csml.csmllibs.csmldataiface.ImageFileInterface |
---|
1115 | |
---|
1116 | |
---|
1117 | class SimpleCondition(csElement): |
---|
1118 | '''from moles''' |
---|
1119 | def __init__(self,**kwargs): |
---|
1120 | addatts(self, []) |
---|
1121 | elems= ['dgAttributeAuthority', 'attrauthRole'] |
---|
1122 | addelems(self,elems) |
---|
1123 | children={elems[0]:[MOLES('dgAttributeAuthority'), 'csString'],elems[1]:[MOLES('attrauthRole'), 'csString']} |
---|
1124 | addchildren(self,children) |
---|
1125 | csElement.__init__(self, **kwargs) |
---|
1126 | |
---|
1127 | |
---|
1128 | class ComplexCondition(csElement): |
---|
1129 | '''from moles (stub class)''' |
---|
1130 | def __init__(self,**kwargs): |
---|
1131 | addatts(self, []) |
---|
1132 | elems= [] |
---|
1133 | addelems(self,elems) |
---|
1134 | children={} |
---|
1135 | addchildren(self,children) |
---|
1136 | csElement.__init__(self, **kwargs) |
---|
1137 | |
---|
1138 | class DgSecurityCondition(csElement): |
---|
1139 | '''from moles''' |
---|
1140 | def __init__(self,**kwargs): |
---|
1141 | addatts(self, []) |
---|
1142 | elems=['effect', 'conditionExplanationText', 'simpleCondition', 'complexCondition'] |
---|
1143 | addelems(self,elems) |
---|
1144 | children={elems[0]:[MOLES('effect'), 'csString'],elems[1]:[MOLES('conditionExplanationText'),'csString'],elems[2]:[MOLES('simpleCondition'), 'SimpleCondition'],elems[3]:[MOLES('complexCondition'), 'ComplexCondition']} |
---|
1145 | addchildren(self,children) |
---|
1146 | csElement.__init__(self,**kwargs) |
---|
1147 | |
---|
1148 | class AccessControlPolicy(csElement): |
---|
1149 | def __init__(self,**kwargs): |
---|
1150 | addatts(self,[]) |
---|
1151 | elems=['accessControlPolicyURL', 'accessControlPolicyText', 'dgSecurityCondition'] |
---|
1152 | addelems(self,elems) |
---|
1153 | children={elems[0]:[CSML('accessControlPolicyURL'), 'csString'],elems[1]:[CSML('accessControlPolicyText'),'csString'],elems[2]:[CSML('dgSecurityCondition'), 'DgSecurityCondition']} |
---|
1154 | addchildren(self,children) |
---|
1155 | csElement.__init__(self,**kwargs) |
---|
1156 | |
---|
1157 | class CSMLStorageDescriptor(csElement): |
---|
1158 | def __init__(self,**kwargs): |
---|
1159 | addatts(self,[]) |
---|
1160 | elems=['descriptors'] |
---|
1161 | addelems(self,elems) |
---|
1162 | children={elems[0]:[[CSML('NetCDFExtract'),CSML('AggregatedArray'), CSML('RawFileExtract')], 'FileExtract', CSML('descriptor'),1]} |
---|
1163 | addchildren(self,children) |
---|
1164 | csElement.__init__(self,**kwargs) |
---|
1165 | |
---|
1166 | class CSMLFeatureCollection(AbstractFeatureCollection,csElement,): |
---|
1167 | def __init__(self,**kwargs): |
---|
1168 | AbstractFeatureCollection.__init__(self,**kwargs) |
---|
1169 | elems=['featureMembers'] |
---|
1170 | addelems(self,elems) |
---|
1171 | children={elems[0]:[[CSML('GridFeature'), CSML('GridSeriesFeature'),CSML('PointFeature'),CSML('TrajectoryFeature'),CSML('ProfileFeature'),CSML('ProfileSeriesFeature'),CSML('RaggedProfileSeriesFeature'),CSML('RaggedSectionFeature'),CSML('SectionFeature'),CSML('ScanningRadarFeature'),CSML('PointSeriesFeature'),CSML('AlternatePointFeature')], 'AbstractFeature', CSML('featureMember'),1]} |
---|
1172 | addchildren(self,children) |
---|
1173 | csElement.__init__(self,**kwargs) |
---|
1174 | def _getSubstitutionType(self,tag): |
---|
1175 | if tag==CSML('GridFeature'): |
---|
1176 | return 'GridFeature' |
---|
1177 | elif tag==CSML('GridSeriesFeature'): |
---|
1178 | return 'GridSeriesFeature' |
---|
1179 | elif tag==CSML('PointFeature'): |
---|
1180 | return 'PointFeature' |
---|
1181 | elif tag==CSML('TrajectoryFeature'): |
---|
1182 | return 'TrajectoryFeature' |
---|
1183 | elif tag==CSML('PointSeriesFeature'): |
---|
1184 | return 'PointSeriesFeature' |
---|
1185 | elif tag==CSML('ProfileFeature'): |
---|
1186 | return 'ProfileFeature' |
---|
1187 | elif tag==CSML('ProfileSeriesFeature'): |
---|
1188 | return 'ProfileSeriesFeature' |
---|
1189 | elif tag==CSML('RaggedProfileSeriesFeature'): |
---|
1190 | return 'RaggedProfileSeriesFeature' |
---|
1191 | elif tag==CSML('RaggedSectionFeature'): |
---|
1192 | return 'RaggedSectionFeature' |
---|
1193 | elif tag==CSML('SectionFeature'): |
---|
1194 | return 'SectionFeature' |
---|
1195 | elif tag==CSML('ScanningRadarFeature'): |
---|
1196 | return 'ScanningRadarFeature' |
---|
1197 | elif tag==CSML('AlternatePointFeature'): |
---|
1198 | return 'AlternatePointFeature' |
---|
1199 | else: return 'AbstractFeature' |
---|
1200 | def _getReverseSubsType(self, typename): |
---|
1201 | if typename== 'GridFeature': |
---|
1202 | return CSML('GridFeature') |
---|
1203 | elif typename == 'GridSeriesFeature': |
---|
1204 | return CSML('GridSeriesFeature') |
---|
1205 | elif typename == 'PointSeriesFeature': |
---|
1206 | return CSML('PointSeriesFeature') |
---|
1207 | elif typename == 'ProfileFeature': |
---|
1208 | return CSML('ProfileFeature') |
---|
1209 | elif typename == 'ProfileSeriesFeature': |
---|
1210 | return CSML('ProfileSeriesFeature') |
---|
1211 | elif typename == 'SectionFeature': |
---|
1212 | return CSML('SectionFeature') |
---|
1213 | elif typename == 'ScanningRadarFeature': |
---|
1214 | return CSML('ScanningRadarFeature') |
---|
1215 | elif typename == 'RaggedSectionFeature': |
---|
1216 | return CSML('RaggedSectionFeature') |
---|
1217 | elif typename == 'RaggedProfileSeriesFeature': |
---|
1218 | return CSML('RaggedProfileSeriesFeature') |
---|
1219 | elif typename == 'PointFeature': |
---|
1220 | return CSML('PointFeature') |
---|
1221 | elif typename == 'TrajectoryFeature': |
---|
1222 | return CSML('TrajectoryFeature') |
---|
1223 | elif typename == 'AlternatePointFeature': |
---|
1224 | return CSML('AlternatePointFeature') |
---|
1225 | else: return CSML('AbstractFeature') |
---|
1226 | |
---|
1227 | |
---|
1228 | class Dataset(csElement): |
---|
1229 | ''' Dataset class, needed as root of tree''' |
---|
1230 | def __init__(self, **kwargs): |
---|
1231 | a=['id'] |
---|
1232 | addatts(self,a) |
---|
1233 | elems=['name','accessControlPolicy','featureCollection','storageDescriptor'] |
---|
1234 | addelems(self,elems) |
---|
1235 | children = {elems[0]:[CSML('name') ,'csString'], elems[1]:[CSML('AccessControlPolicy') ,'AccessControlPolicy'], elems[2]:[CSML('CSMLFeatureCollection') ,'CSMLFeatureCollection'],elems[3]:[CSML('CSMLStorageDescriptor'),'CSMLStorageDescriptor']} |
---|
1236 | addchildren(self,children) |
---|
1237 | csElement.__init__(self,**kwargs) |
---|
1238 | |
---|
1239 | def toXML(self): |
---|
1240 | csmlfrag=ET.Element(CSML('Dataset')) |
---|
1241 | csElement.toXML(self, csmlfrag) |
---|
1242 | return csmlfrag |
---|
1243 | #def _getSubstitutionType(self,tag): |
---|
1244 | #if tag==CSML('NetCDFExtract'): |
---|
1245 | #return 'NetCDFExtract' |
---|
1246 | #elif tag==CSML('NASAAmesExtract'): |
---|
1247 | #return 'NASAAmesExtract' |
---|
1248 | #else: return 'ArrayDescriptor' |
---|
1249 | #def _getReverseSubsType(self, typename): |
---|
1250 | #if typename== 'NetCDFExtract': |
---|
1251 | #return CSML('NetCDFExtract') |
---|
1252 | #elif typename == 'NASAAmesExtract': |
---|
1253 | #return CSML('NASAAmesExtract') |
---|
1254 | #else: return CSML('ArrayDescriptor') |
---|
1255 | |
---|
1256 | return typename |
---|
1257 | |
---|
1258 | |
---|
1259 | def main(): |
---|
1260 | '''round trip for testing purposes:''' |
---|
1261 | import parser_extra |
---|
1262 | print '\n' |
---|
1263 | #tree=ET.ElementTree(file='/home/dom/coapec/TESTocean.xml') |
---|
1264 | tree=ET.ElementTree(file='/home/dom/CSTEST/testout.xml') |
---|
1265 | import time |
---|
1266 | time1=time.time() |
---|
1267 | #ds=Dataset() |
---|
1268 | ds=csml.parser.Dataset() |
---|
1269 | ds.fromXML(tree.getroot()) |
---|
1270 | #ds =csml.parser_extra.ParserPostProcessor(ds).resolveReferences() |
---|
1271 | print 'time=',time.time()-time1 |
---|
1272 | |
---|
1273 | csmltree=ds.toXML() |
---|
1274 | csmlout=parser_extra.PrettyPrint(csmltree) |
---|
1275 | csmlout=parser_extra.removeInlineNS(csmlout) |
---|
1276 | f=open('temp.xml', 'w') |
---|
1277 | f.write(csmlout) |
---|
1278 | f.close() |
---|
1279 | |
---|
1280 | print 'time=',time.time()-time1 |
---|
1281 | print '\n %s'% csmlout |
---|
1282 | #for member in ds.featureCollection.members: |
---|
1283 | #print dir(member.value) |
---|
1284 | |
---|
1285 | |
---|
1286 | if __name__=='__main__': |
---|
1287 | #import profile |
---|
1288 | #profile.run('main()') |
---|
1289 | main() |
---|