source: TI01-discovery/branches/ingestAutomation-upgrade/OAIBatch/SpatioTemporalData.py @ 3847

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery/branches/ingestAutomation-upgrade/OAIBatch/SpatioTemporalData.py@3847
Revision 3847, 1.4 KB checked in by cbyrom, 11 years ago (diff)

Create new object, SpatioTemporalData?, to wrapper temporal and spatial data
+ change PostgresRecord? to include all spatiotemporal data from a moles file
using this new object.

  • Property svn:executable set to *
Line 
1'''
2Representation of the temporal and spatial data extractable from a moles record
3C Byrom Apr 08
4'''
5import logging
6
7class SpatioTemporalData:
8    '''
9    Simple wrapper with utitility methods for holding spatio-temporal data
10    - NB, can handle arrays of either or both spatial and temporal data
11    '''
12    def __init__(self, timeArray=None, coordArray=None):
13        # the data is stored in a 2D array; first array for time, second for coords
14        self.data = [[],[]]
15       
16        if timeArray:
17            self.data[0] = timeArray
18           
19        if coordArray:
20            self.data[1] = coordArray
21           
22           
23    def addCoords(self, north, south, east, west):
24        self.data[1].append(Coords(north, south, east, west))
25       
26    def addTimeRange(self, start, end):
27        self.data[0].append(TimeRange(start, end))
28
29
30class Coords:
31    '''
32    Simple struct for handling NSEW coords
33    '''
34    def __init__(self, north, south, east, west):
35        logging.debug('Adding coords: N %s, S %s, E %s, W %s' %(north, south, east, west))
36        self.north = north
37        self.south = south
38        self.east = east
39        self.west = west
40       
41       
42class TimeRange:
43    '''
44    Simple struct representing a time range
45    '''
46    def __init__(self, start, end):
47        logging.debug('Adding time range: %s -> %s' %(start, end))
48        self.start = start
49        self.end = end
Note: See TracBrowser for help on using the repository browser.