source: TI02-CSML/trunk/csml/csmllibs/csmlxlink.py @ 2030

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

storage descriptor code working in scanner

Line 
1
2'''csmlxlink - contains functions used for processin xlinks in csml documents.
3created 23 01 2007 by Dominic Lowe, CCLRC, BADC
4'''
5
6import sys
7import csml
8
9def createXlinks(featureCollection):
10    '''returns a featureCollection with the domains of all features reduced to xlinks to other domains where possible
11    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.
12    This function compares the domains of all the features in the featureCollection and looks for matching domains'''
13   
14    features = featureCollection.featureMembers
15   
16    #xlinkDictionary = {axislabel_axisspanned :(values, gmlid), .... }
17    #process:
18    #go through each ordinate in each domain for each feature.
19    #if ordinate (exact match with labels, span + value) is not in dictionary add it
20    #and create a new gml id.
21    #else if it is in the dictionary, get the gml id and replace the ordinate values with an xlink.
22       
23    xlinkDictionary = {}
24    for feature in features:
25        print feature.id
26        #okay, in first instance deal with GridSeries features
27        if type (feature.value) == csml.parser.GridSeriesCoverage:
28            domain = feature.value.gridSeriesDomain           
29            for gO in domain.coordTransformTable.gridOrdinates:
30                if gO.coordAxisLabel.CONTENT !='':
31                    xlinkID=gO.coordAxisLabel.CONTENT + '_' + gO.gridAxesSpanned.CONTENT   
32                    if xlinkID=='unknown_unspecified':
33                        continue
34                    if xlinkID in xlinkDictionary:
35                        #replace content with xlink TODO
36                        gmlid=xlinkDictionary[xlinkID]
37                        print gmlid
38                    else:
39                        print 'no, adding %s to dictionary'%xlinkID
40                        xlinkDictionary[xlinkID]=(gO.coordAxisValues.coordinateList.CONTENT, csml.csmllibs.csmlextra.getRandomID())
41                       
42                       
43           
44    sys.exit()
45   
46   
47    #return
Note: See TracBrowser for help on using the repository browser.