source: TI02-CSML/trunk/csml/API/ops_Dataset.py @ 2215

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/csml/API/ops_Dataset.py@2215
Revision 2215, 2.2 KB checked in by domlowe, 13 years ago (diff)

adding online parser to svn

Line 
1''' ops_Dataset  contains operations for root Dataset class'''
2
3import codecs
4import csml.csmllibs.xmlEncoding
5import csml.parser_extra
6
7def testmethod(self):
8    print 'testmethod for dataset'
9    return 'testmethod dataset'
10
11def parse(self,csmlfile):
12    """must be provided with csmlfile   parses the csmlfile into self """
13    #determine encoding
14    f = open(csmlfile)
15    startoffile=f.readline()
16    encoding=csml.csmllibs.xmlEncoding.autoDetectXMLEncoding(startoffile)
17    f.close()
18    #parse with correct encoding
19    tree = csml.parser_extra.encodingParser(csmlfile,encoding)
20    self.fromXML(tree.getroot())
21    self =csml.parser_extra.ParserPostProcessor(self).resolveReferences()
22   
23def getSecurity(self):
24    """ returns a dictonary containing attributeAuthority: role"""
25    security=[]
26    if hasattr(self, 'accessControlPolicy'):
27        if hasattr(self.accessControlPolicy,'dgSecurityConditions'):
28            for condition in self.accessControlPolicy.dgSecurityConditions:
29                #need to test for these but ok for alpha.
30                cond=[]
31                cond.append(condition.effect)
32                cond.append(condition.simpleCondition.dgAttributeAuthority)
33                cond.append(condition.simpleCondition.attrauthRole)
34                cond.append(condition.conditionExplanationText)
35                security.append(cond)
36    return security
37
38def getFeatureList(self):
39    #returns a list of feature ids for the dataset
40    self.featureList = []
41    for member in csml.csmllibs.csmlextra.listify(self.featureCollection.featureMembers):
42            self.featureList.append(member.id)
43    return self.featureList
44   
45def getFeature(self, featureID):
46    """ returns a single feature object """
47    for member in csml.csmllibs.csmlextra.listify(self.featureCollection.featureMembers):
48            if member.id == featureID:
49                return member   
50
51def getFileExtract(self,extractID):
52        for extract in csml.csmllibs.csmlextra.listify(self.dataset.arrayDescriptors):
53            if  extract.id==extractID:
54                return extract
55
56def getBoundingBox(self):
57    ''' get boundingBox, returns the boundingBox of the CSMLFeatureCollection (assumes there is only one...)'''
58    print self.CSMLFeatureCollection.boundedBy
Note: See TracBrowser for help on using the repository browser.