source: TI02-CSML/trunk/parser/oldapi/callstoapi.py @ 1011

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/parser/oldapi/callstoapi.py@1178
Revision 1011, 1.6 KB checked in by domlowe, 14 years ago (diff)

moving files

Line 
1#!/usr/bin/env python
2
3#callstoapi.py
4#This document contains example calls to Parser csml api
5#Dominic Lowe 17th May 2006
6
7#import csml interface module:
8from csmldoc import *
9
10def main():
11    #opens (and parses) a csml file:
12    csml=CSMLDataset('example.xml')
13   
14    #csml.getFeature is the method to  get a particular feature by name.
15    #try and call the test method on different types of feature
16
17    feature=csml.getFeature('feat01') #this happens to be a Point feature
18    print "\n POINT FEATURE:  " + 'feat01'
19    print 'Test method: ' + feature.testMethod()
20   
21    #Get another feature
22    feature=csml.getFeature('feat02') #this happens to be a PointSeries feature
23    print "\n POINTSERIES FEATURE " + 'feat02'
24    print 'Test method: ' + feature.testMethod()
25   
26    #and another - this time, the testMethod is not overwritten (see csmldoc.py for details)
27    feature=csml.getFeature('feat03') #this happens to be a Profile feature
28    print "\n PROFILE FEATURE " + 'feat03'
29    print 'Test method: ' + feature.testMethod()
30
31    #if these calls to getFeature have worked you should see different results for feature.testMethod() depending on the type of feature.
32       
33    '''Note:feature also has an attribute 'parsedFeature' which enables lower level access direct to Parser attributes/methods if required - although hopefully this will be avoided and access will usually be via higher level methods'''
34    print '\n And to show you can do it here is something extracted from the low level parser objects:'
35    print feature.parsedFeature.rangeSet.dataBlock.rangeParameters.valueComponents[0].uom
36    print '\n'
37main()
Note: See TracBrowser for help on using the repository browser.