Changeset 2400


Ignore:
Timestamp:
13/04/07 12:22:03 (12 years ago)
Author:
domlowe
Message:

fixes to demoCreateV2.py and associated parser fixes

Location:
TI02-CSML/trunk/csml
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/csml/Examples/Parsing/demoCreateV2.py

    r2225 r2400  
    11import csml.parser 
    22import csml.parser_extra 
    3  
     3import csml.csmllibs.csmlextra 
    44 
    55  ######################################### 
     
    1616 
    1717#set the id attribute 
    18 ptsf.id='testbed270401' 
     18ptsf.id='pointseriesf' 
    1919 
    2020#set the description 
     
    2424#create a PointSeriesCoverage 
    2525ptscvg=csml.parser.PointSeriesCoverage() 
     26ptscvg.id=csml.csmllibs.csmlextra.getRandomID() 
    2627 
    2728#create a TimeSeriesDomain (appropriate domain for a PointSeriesFeature 
    2829ptsd=csml.parser.TimeSeries() 
     30ptsd.id=csml.csmllibs.csmlextra.getRandomID() 
    2931#create (and populate) a TimePositionList. Using keyword arguements for conciseness. 
    30 ptsd.time=csml.parser.TimePositionList(frame='#pred20060427001',CONTENT='-18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60') 
     32ptsd.timePositionList=csml.parser.TimePositionList(frame='#pred20060427001',CONTENT='-18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60') 
    3133     
    3234#create a RangeSet 
     
    5557 
    5658 
    57 #create a profile series feature 
    58 psf=csml.parser.ProfileSeriesFeature() 
    59 psf.id='profileseriesf' 
    60 psf.description=csml.parser.csString('sample profile series feature') 
    61 cvg = csml.parser.ProfileSeriesCoverage() 
    62 psd=csml.parser.ProfileSeriesDomain() 
    63 rs=csml.parser.RangeSet() 
    64 gcT=csml.parser.GridCoordinatesTable() 
    65 psd.coordTransformTable=gcT 
    66 cvg.rangeSet=rs 
    67 cvg.profileSeriesDomain=psd 
    68 psf.value=cvg 
    69 psf.parameter=param #defined earlier 
    70 fms.append(psf) 
     59#create a profile series feature  
     60            #commented out, was just an approximate template 
     61#psf=csml.parser.ProfileSeriesFeature() 
     62#psf.id='profileseriesf' 
     63#psf.description=csml.parser.csString('sample profile series feature') 
     64#cvg = csml.parser.ProfileSeriesCoverage() 
     65#cvg.id=csml.csmllibs.csmlextra.getRandomID()            
     66#psd=csml.parser.ProfileSeriesDomain() 
     67#psd.id=csml.csmllibs.csmlextra.getRandomID() 
     68#rs=csml.parser.RangeSet() 
     69#gcT=csml.parser.GridCoordinatesTable() 
     70#psd.coordTransformTable=gcT 
     71#cvg.rangeSet=rs 
     72#cvg.profileSeriesDomain=psd 
     73#psf.value=cvg 
     74#psf.parameter=param #defined earlier 
     75#fms.append(psf) 
    7176            
    7277                        
     
    7681pf.description=csml.parser.csString('sample profile feature')             
    7782cvg = csml.parser.ProfileCoverage() 
    78 cvg.profileDomain=csml.parser.csString('1000, 950, 850, 700, 600, 500, 400, 300, 250, 200, 150, 100, 50, 30, 10') 
     83cvg.id=csml.csmllibs.csmlextra.getRandomID() 
     84pd =csml.parser.ProfileDomain() 
     85pd.id=csml.csmllibs.csmlextra.getRandomID() 
     86pd.pointMembers=csml.parser.csString('1000, 950, 850, 700, 600, 500, 400, 300, 250, 200, 150, 100, 50, 30, 10') 
     87cvg.profileDomain=pd 
    7988rs=csml.parser.RangeSet() 
    8089rs.quantityList=csml.parser.MeasureOrNullList(uom='MLUnits.xml#m',CONTENT='0.27 0.25 0.25 0.23 0.22 0.22 0.21 0.17 0.17 0.14 0.14 0.12 0.10 0.08 0.08') 
     
    8392pf.parameter=param 
    8493pf.location=csml.parser.csString('75 35') 
    85 pf.time=csml.parser.csString('2003-02-02T0:0:0.0') 
     94pf.time=csml.parser.csString('2003-02-02T00:00:00.0') 
    8695fms.append(pf)             
    8796                         
     
    8998#instantiate a FeatureCollection object (and add all featureMembers) 
    9099fc=csml.parser.CSMLFeatureCollection(featureMembers=fms) 
    91  
     100fc.id=csml.csmllibs.csmlextra.getRandomID() 
    92101 
    93102########### The Dataset  ############## 
     
    114123#now add the featureCollection to the dataset 
    115124ds.featureCollection=fc 
     125                     
     126                                       
     127#dummy storage descriptor 
     128sd=csml.parser.CSMLStorageDescriptor() 
     129sd.id = csml.csmllibs.csmlextra.getRandomID() 
     130ds.storageDescriptor=sd 
     131 
     132                                       
    116133 
    117134#finished creating all the python objects! 
     
    128145 
    129146#(you could save strCSML to a file at this point) 
     147fname='ptseries.xml' 
     148f=open(fname,'w') 
     149f.write(strCSML) 
     150print 'CSML doc written to %s'%fname 
     151                                       
  • TI02-CSML/trunk/csml/parser.py

    r2396 r2400  
    465465        elems=['pointMember','pointMembers'] 
    466466        addelems(self,elems) 
    467         children={elems[0]:[GML('pointMember'), 'csString'],elems[0]:[GML('pointMember'), 'csString']} 
     467        children={elems[0]:[GML('pointMember'), 'csString'],elems[1]:[GML('pointMembers'), 'csString']} 
    468468        addchildren(self,children) 
    469469        csElement.__init__(self,**kwargs) 
     
    880880    def __init__(self, **kwargs): 
    881881        AbstractFeature.__init__(self,**kwargs) 
    882         elems=['time', 'location', 'value', 'parameter'] 
    883         addelems(self,elems) 
    884         children={elems[0]:[CSML('time'), 'csString'],elems[1]:[CSML('location'), 'csString'], elems[2]:[CSML('ProfileCoverage'), 'ProfileCoverage', CSML('value')], elems[3]:[CSML('parameter'), 'Phenomenon']} 
     882        elems=['location', 'time','value', 'parameter'] 
     883        addelems(self,elems) 
     884        children={elems[0]:[CSML('location'), 'csString'],elems[1]:[CSML('time'), 'csString'], elems[2]:[CSML('ProfileCoverage'), 'ProfileCoverage', CSML('value')], elems[3]:[CSML('parameter'), 'Phenomenon']} 
    885885        addchildren(self,children) 
    886886        csElement.__init__(self,**kwargs) 
Note: See TracChangeset for help on using the changeset viewer.