- Timestamp:
- 23/01/07 14:44:07 (14 years ago)
- Location:
- TI02-CSML/trunk/csml
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TI02-CSML/trunk/csml/csmllibs/csmlbuilder.py
r2030 r2034 27 27 self.createFeatureCollection() 28 28 self.createFeatures() 29 #self.insertXlinks()29 self.insertXlinks() 30 30 #self.closeFC() 31 31 #self.closeDS() … … 107 107 108 108 def insertXlinks(self): 109 self.ds .featureCollection=csml.csmllibs.csmlxlink.createXlinks(self.ds.featureCollection)109 self.ds=csml.csmllibs.csmlxlink.createXlinks(self.ds) 110 110 111 111 -
TI02-CSML/trunk/csml/csmllibs/csmlfeaturetypes.py
r2031 r2034 201 201 varSize=csml.csmllibs.csmlextra.cleanString1(str(varSize)) 202 202 fe.arraySize=cp.csString(varSize) 203 fe.fileName=cp.csString(self.filesinDir) 203 fl=cp.FileList() 204 fl.fileNames=cp.csString(self.filesinDir) 205 fe.fileList=fl 204 206 fe.variableName=cp.csString(varName) 205 207 aa.components=[fe] -
TI02-CSML/trunk/csml/csmllibs/csmlxlink.py
r2032 r2034 1 1 2 '''csmlxlink - contains functions used for processin xlinks in csml documents. 2 3 created 23 01 2007 by Dominic Lowe, CCLRC, BADC … … 6 7 import csml 7 8 8 def createXlinks(featureCollection): 9 '''returns a featureCollection with the domains of all features reduced to xlinks to other domains where possible 10 e.g if 3 features share the same domain, the domain will be explicit in the first feature, and referenced only by xlink from the second 2 features. 11 This function compares the domains of all the features in the featureCollection and looks for matching domains''' 12 13 features = featureCollection.featureMembers 14 15 #xlinkDictionary = {axislabel_axisspanned :(values, gmlid), .... } 16 #process: 17 #go through each ordinate in each domain for each feature. 18 #if ordinate (exact match with labels, span + value) is not in dictionary add it 19 #and create a new gml id. 20 #else if it is in the dictionary, get the gml id and replace the ordinate values with an xlink. 21 22 xlinkDictionary = {} 23 for feature in features: 24 print feature.id 25 #okay, in first instance deal with GridSeries features 26 if type (feature.value) == csml.parser.GridSeriesCoverage: 27 domain = feature.value.gridSeriesDomain 28 for gO in domain.coordTransformTable.gridOrdinates: 29 if gO.coordAxisLabel.CONTENT !='': 30 xlinkID=gO.coordAxisLabel.CONTENT + '_' + gO.gridAxesSpanned.CONTENT 31 if xlinkID=='unknown_unspecified': 32 continue 33 if xlinkID in xlinkDictionary: 34 #replace content with xlink TODO 35 gmlid=xlinkDictionary[xlinkID] 36 print gmlid 9 def createXlinks(dataset): 10 '''returns a CSMLStorageDescriptor with any fileLists reduced to xlinks to other fileLists where possible. 11 e.g if 3 features share the same fileList, the fileList will be explicit in the first feature, and referenced only by xlink from the second 2 features. 12 This function compares the fileLists of all AggregatedArrays in the CSMLStorageDescriptor and looks for matching fileLists''' 13 ds=dataset 14 if not hasattr(ds, 'storageDescriptor'): 15 return None 16 else: 17 #xlinkDictionary = {axislabel_axisspanned :(values, gmlid), .... } 18 #process: 19 #go through each ordinate in each domain for each feature. 20 #if ordinate (exact match with labels, span + value) is not in dictionary add it 21 #and create a new gml id. 22 #else if it is in the dictionary, get the gml id and replace the ordinate values with an xlink. 23 xlinkDictionary = {} 24 for descriptor in ds.storageDescriptor.descriptors: 25 if type(descriptor)==csml.parser.AggregatedArray: 26 for comp in descriptor.components: 27 fID=comp.fileList.fileNames.CONTENT 28 if fID in xlinkDictionary: 29 #replace content with xlink 30 gmlid=xlinkDictionary[fID][1] 31 setattr(comp, 'fileListXLINK', csml.parser.csString()) 32 comp.fileListXLINK.href='#%s'%gmlid 33 del comp.fileList 37 34 else: 38 print 'no, adding %s to dictionary'%xlinkID 39 xlinkDictionary[xlinkID]=gO.coordAxisValues.coordinateList.CONTENT 40 #timepositionlist alternative needed.. 41 42 43 44 sys.exit() 45 46 47 #return 35 #add to dictionary & set gml:id attribute 36 newid=csml.csmllibs.csmlextra.getRandomID() 37 xlinkDictionary[fID]=(fID, newid) 38 comp.fileList.id=newid 39 return ds 40 -
TI02-CSML/trunk/csml/parser.py
r2030 r2034 270 270 271 271 272 class csString(csElement): 272 273 class AbstractGML(csElement): 274 def __init__(self, **kwargs): 275 a=[GML('id'), GML('description'), GML('name'), GML('MetaDataProperty')] 276 addatts(self,a) 277 278 class AssociationAttributeGroup(csElement): 279 def __init__(self, **kwargs): 280 a =[XLINK('href'),XLINK('role'), XLINK('arcrole'),XLINK('title'), XLINK('show'), XLINK('actuate')] 281 addatts(self,a) 282 283 class csString(AssociationAttributeGroup, csElement): 273 284 def __init__(self, text=None,**kwargs): 285 #Needed so it can use xlink 286 AssociationAttributeGroup.__init__(self,**kwargs) 274 287 if text != None: 275 288 if type(text) is not str: … … 278 291 children={} 279 292 addchildren(self,children) 280 281 class AbstractGML(csElement):282 def __init__(self, **kwargs):283 a=[GML('id'), GML('description'), GML('name'), GML('MetaDataProperty')]284 addatts(self,a)285 286 class AssociationAttributeGroup(csElement):287 def __init__(self, **kwargs):288 a =[XLINK('href'),XLINK('role'), XLINK('arcrole'),XLINK('title'), XLINK('show'), XLINK('actuate')]289 addatts(self,a)290 293 291 294 class SRSReferenceGroup(csElement): … … 700 703 addchildren(self,children) 701 704 705 class FileList(AssociationAttributeGroup,AbstractGML,csElement): 706 def __init__(self,**kwargs): 707 AssociationAttributeGroup.__init__(self,**kwargs) 708 AbstractGML.__init__(self,**kwargs) 709 addatts(self,[]) 710 children= {'fileNames':[CSML('fileNames'), 'csString']} 711 addchildren(self,children) 712 702 713 class FileExtract(ArrayDescriptor, csElement): 703 714 def __init__(self,**kwargs): 704 715 ArrayDescriptor.__init__(self,**kwargs) 705 children= {'fileName':[CSML('fileName'), 'csString'] }716 children= {'fileName':[CSML('fileName'), 'csString'], 'fileList':[CSML('FileList'), 'FileList', CSML('fileList')],'fileListXLINK':[CSML('fileList'), 'csString']} 706 717 addchildren(self,children) 707 718
Note: See TracChangeset
for help on using the changeset viewer.