source: TI02-CSML/trunk/csml/API/csmlutils.py @ 1939

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/csml/API/csmlutils.py@1939
Revision 1939, 938 bytes checked in by domlowe, 12 years ago (diff)

handling of longitude requests taken out of main module

Line 
1'''csml utils contains useful  utility functions'''
2
3
4def listify(item):
5    ''' listify checks if an item is a list, if it isn't it puts it inside a list and returns it. Always returns a list object'''
6    if type(item) is list:
7        return item
8    else:
9        return [item]
10   
11   
12   
13#deal with longitude requests
14#if the request is in -ve,+ve eg (-30,30) but the data is in (0,360) need to handle this by changing the args.
15def fixLongitude(request, kwargs):
16    for key in request.keys():
17        if key == 'longitude': #how do we test if it is longitude properly?
18            for val in dc[key]:
19                if val < 0:
20                    pass
21                else:
22                    if kwargs[key][0] < 0:
23                        kwargs[key]=(kwargs[key][0]+360,kwargs[key][1])
24                    if kwargs[key][1] < 0:
25                        kwargs[key]=(kwargs[key][0],kwargs[key][1]+360)
26        return kwargs
Note: See TracBrowser for help on using the repository browser.