Changeset 1523 for TI02-CSML


Ignore:
Timestamp:
15/09/06 11:55:59 (13 years ago)
Author:
domlowe
Message:

more changes related to csmlContainer class

Location:
TI02-CSML/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/Examples/parsing/apicalls.py

    r1521 r1523  
    66 
    77#Initialise the CSML container 
    8 csmlContainer=csml.API.csmlContainer.Container("mycsmldoc", "mymetadatastring") 
     8csmlContainer=csml.API.csmlContainer.Container(csmlpath='myfile.xml',docID="mycsmldoc_1", metadata="mymetadatastring") 
    99 
    1010#Initialise and parse the dataset 
     
    5353 
    5454#request subsetted data from feature (can set paths here) 
    55 feature.subsetToGridSeries(csmlContainer, timeSelection,  csmlpath='myfile.xml', ncpath='myfile.nc',**spatialSubsetDictionary) 
     55feature.subsetToGridSeries(csmlContainer, timeSelection,  ncpath='myfile.nc',**spatialSubsetDictionary) 
    5656csmlbundle=csmlContainer.getContents() 
    5757 
    58 print csmlbundle 
     58print 'CSML %s'%csmlbundle[0] # csml document 
    5959 
    6060#parse and pretty print the result 
  • TI02-CSML/trunk/csml/API/csmlContainer.py

    r1521 r1523  
    55    '''CSMLContainer object is used to hold features before generating a CSML document. This is useful because it allows you to subset several features sequentially then build a single CSML document containing all the subsetted features ''' 
    66     
    7     def __init__(self,docID, docMetaDataProperty): 
     7    def __init__(self,csmlpath='myfile.xml',docID='none',metadata='unspecified'): 
     8        self.csmlpath=csmlpath 
    89        ''' Initialise CSML Dataset and FeatureCollection and populate with basic Metadata''' 
    910        ''' 
     
    1617        self.fc=csml.parser.FeatureCollection() 
    1718        #Set attributes of dataset 
    18         #if docMetaDataProperty is a URI, set it as href attribute if MetaDataProperty instance, 
     19        #if 'metadata' is a URI, set it as href attribute if MetaDataProperty instance, 
    1920        #else set it as a text attribute of a MetaDataProperty instance. 
    2021        mdp=csml.parser.MetaDataProperty() 
    21         if csml.parser_extra.isURI(docMetaDataProperty): 
    22             mdp.href=docMetaDataProperty 
     22        if csml.parser_extra.isURI(metadata): 
     23            mdp.href=metadata 
    2324        else:  
    24             mdp.text = [docMetaDataProperty] 
     25            mdp.text = [metadata] 
    2526        self.ds.metaDataProperty= [mdp] 
    2627        #set the id 
     
    3536        '''containerContents contains the CSML Document (first item) and then any NetCDF files that are to be delivered with the document ''' 
    3637        self.containerContents=[] 
    37          
     38        self.ncfiles=[] 
    3839     
    3940    def appendFileExtract(self, fileextract): 
     
    5152        #append NetCDF file object to containerContents 
    5253        #need to think about whether it is best to append the file object or just a path to the file 
    53         self.containerContents.append(ncfile) 
     54        self.ncfiles.append(ncfile) 
    5455     
    5556    def getContents(self): 
     
    6263        strCSML=csml.parser_extra.removeInlineNS(strCSML) 
    6364        self.containerContents.append(strCSML) 
     65        for ncfile in self.ncfiles: 
     66            self.containerContents.append(ncfile) 
    6467        return self.containerContents 
  • TI02-CSML/trunk/csml/API/ops_GridSeriesFeature.py

    r1521 r1523  
    5656    #MUST be supplied with a CSMLContainer object to store the subsetted feature in 
    5757     
    58     if csmlpath is not None: 
    59         pathToSubsetCSML = csmlpath 
    60     else: 
    61         pathToSubsetCSML='temp.xml' 
     58    pathToSubsetCSML = container.csmlpath 
    6259    if ncpath is not None: 
    6360        pathToSubsetNetCDF=ncpath 
     
    208205    nc.closeFinishedFile() 
    209206    container.attachNetCDFFile(nc) 
    210     return pathToSubsetCSML,pathToSubsetNetCDF, totalArraySize 
Note: See TracChangeset for help on using the changeset viewer.