source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19123_2005_coverages/coverages/quadrilateral_grid/cv_referenceablegrid.py @ 8457

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19123_2005_coverages/coverages/quadrilateral_grid/cv_referenceablegrid.py@8457
Revision 8457, 2.9 KB checked in by mnagni, 7 years ago (diff)

Corrected an error in the generation of the classes "synchronize" method.

  • Property svn:mime-type set to text/plain
Line 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21from ea_model.iso_19123_2005_coverages.coverages.quadrilateral_grid.cv_grid import  CV_Grid
22from ascore.utils import has_value, collectionProofHash
23
24'''
25Created on 10-Jul-2012 14:15:07
26
27@author: mnagni
28'''
29
30class CV_ReferenceableGrid(CV_Grid):
31        '''
32                Represents a data entity defined in a UML diagram and supposed to
33                be persisted in a relational database.
34 
35                This class has been genererated automatically using the Apache Velocity project.
36        '''
37        '''
38                Please note that any access to the inner attributes should be done using
39                the given get/set methods and NOT accessing them directly.
40        '''
41        def __init__(self):
42                self._cv_grid = CV_Grid()       
43
44                self._crs_sc_singlecrs = []
45                self._crs_sc_compoundcrs = []
46                self._crs = []
47                self.dimension = None
48                self.extent = None
49                super(CV_ReferenceableGrid, self).__init__()
50        @property
51        def crs(self): 
52                try:
53                        ret = []
54                        ret.extend(self._crs_sc_singlecrs)
55                        ret.extend(self._crs_sc_compoundcrs)
56                        if not hasattr(self, '_crs'):
57                                self._crs = []
58                        if self._crs is not None:
59                                ret.extend(self._crs)
60                        del self._crs[:]
61                        self._crs.extend(set(ret))
62                except Exception as e:
63                        pass
64                return self._crs
65
66        @property
67        def cell(self):
68                return self._cv_grid.cell
69
70        @cell.setter
71        def cell(self, value): 
72                        self._cv_grid.cell = value
73        @property
74        def dimension(self):   
75                return self._cv_grid.dimension
76
77        @dimension.setter
78        def dimension(self, value):     
79                        self._cv_grid.dimension = value
80        @property
81        def intersection(self):
82                return self._cv_grid.intersection
83
84        @intersection.setter
85        def intersection(self, value): 
86                        self._cv_grid.intersection = value
87        @property
88        def axisNames(self):   
89                return self._cv_grid.axisNames
90
91        @axisNames.setter
92        def axisNames(self, value):     
93                        self._cv_grid.axisNames = value
94        @property
95        def extent(self):       
96                return self._cv_grid.extent
97
98        @extent.setter
99        def extent(self, value):       
100                        self._cv_grid.extent = value
101
102        def synchronize(self):
103                int_crs = self.crs     
104                del self._crs_sc_singlecrs[:]
105                del self._crs_sc_compoundcrs[:]
106                for item in int_crs:   
107                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
108                        if valueClass == "ea_model.iso_19111_referencing_by_coordinates.coordinate_reference_systems.sc_singlecrs.SC_SingleCRS":
109                                self._crs_sc_singlecrs.append(item)
110                                continue
111                        if valueClass == "ea_model.iso_19111_referencing_by_coordinates.coordinate_reference_systems.sc_compoundcrs.SC_CompoundCRS":
112                                self._crs_sc_compoundcrs.append(item)
113                                continue
114                pass
115
116        def __key(self):
117                return (self.crs, self.cell, self.dimension, self.intersection, self.axisNames, self.extent)
118
119        def __eq__(self, y):
120                if type(self) != type(y):
121                        return False
122                '''
123                Cannot compare classes which do not define a "__key" attribute
124                '''
125                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
126                        return self.__key() == y.__key()
127                return id(self) == id(y)
128
129        def __hash__(self):
130                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.