source: mauRepo/CedaMolesModel/tags/0.1.0/ceda_moles_model/ea_model/iso_19123_2005_coverages/coverages/coverage_core/cv_geometryvaluepair.py @ 8398

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/tags/0.1.0/ceda_moles_model/ea_model/iso_19123_2005_coverages/coverages/coverage_core/cv_geometryvaluepair.py@8405
Revision 8398, 6.3 KB checked in by mnagni, 7 years ago (diff)

Incomplete - # 22504: CedaMoles? as python package
 http://team.ceda.ac.uk/trac/ceda/ticket/22504

  • 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 ascore.utils import has_value, collectionProofHash
22
23'''
24Created on 26-Jun-2012 10:16:30
25
26@author: mnagni
27'''
28
29class CV_GeometryValuePair(object):
30        '''
31                Represents a data entity defined in a UML diagram and supposed to
32                be persisted in a relational database.
33 
34                This class has been genererated automatically using the Apache Velocity project.
35        '''
36        '''
37                Please note that any access to the inner attributes should be done using
38                the given get/set methods and NOT accessing them directly.
39        '''
40        def __init__(self):
41
42                self._collection_cv_discretesolidcoverage = []
43                self._collection_cv_discretegridpointcoverage = []
44                self._collection_cv_discretesurfacecoverage = []
45                self._collection_cv_discretepointcoverage = []
46                self._collection_cvt_discretetimeinstantcoverage = []
47                self._collection_cv_discretecurvecoverage = []
48                self._collection = []
49                self.value = None
50                self.geometry = None
51                self._extension_cv_thiessenvaluepolygon = []
52                self._extension_cv_valuetriangle = []
53                self._extension_cv_valuecurve = []
54                self._extension_cv_valuehexagon = []
55                self._extension_cv_gridvaluecell = []
56                self._extension = []
57                super(CV_GeometryValuePair, self).__init__()
58        @property
59        def collection(self):   
60                try:
61                        ret = []
62                        ret.extend(self._collection_cv_discretesolidcoverage)
63                        ret.extend(self._collection_cv_discretegridpointcoverage)
64                        ret.extend(self._collection_cv_discretesurfacecoverage)
65                        ret.extend(self._collection_cv_discretepointcoverage)
66                        ret.extend(self._collection_cvt_discretetimeinstantcoverage)
67                        ret.extend(self._collection_cv_discretecurvecoverage)
68                        if not hasattr(self, '_collection'):
69                                self._collection = []
70                        if self._collection:
71                                ret.extend(self._collection)
72                        del self._collection[:]
73                        self._collection.extend(set(ret))
74                except Exception as e:
75                        pass
76                return self._collection
77
78        @property
79        def extension(self):   
80                try:
81                        ret = []
82                        ret.extend(self._extension_cv_thiessenvaluepolygon)
83                        ret.extend(self._extension_cv_valuetriangle)
84                        ret.extend(self._extension_cv_valuecurve)
85                        ret.extend(self._extension_cv_valuehexagon)
86                        ret.extend(self._extension_cv_gridvaluecell)
87                        if not hasattr(self, '_extension'):
88                                self._extension = []
89                        if self._extension:
90                                ret.extend(self._extension)
91                        del self._extension[:]
92                        self._extension.extend(set(ret))
93                except Exception as e:
94                        pass
95                return self._extension
96
97
98        def synchronize(self):
99                del self._collection_cv_discretesolidcoverage[:]
100                del self._collection_cv_discretegridpointcoverage[:]
101                del self._collection_cv_discretesurfacecoverage[:]
102                del self._collection_cv_discretepointcoverage[:]
103                del self._collection_cvt_discretetimeinstantcoverage[:]
104                del self._collection_cv_discretecurvecoverage[:]
105                del self._extension_cv_thiessenvaluepolygon[:]
106                del self._extension_cv_valuetriangle[:]
107                del self._extension_cv_valuecurve[:]
108                del self._extension_cv_valuehexagon[:]
109                del self._extension_cv_gridvaluecell[:]
110                for item in self.collection:   
111                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
112                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.discrete_coverages.cv_discretesolidcoverage.CV_DiscreteSolidCoverage":
113                                self._collection_cv_discretesolidcoverage.append(item)
114                                continue
115                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
116                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.discrete_coverages.cv_discretegridpointcoverage.CV_DiscreteGridPointCoverage":
117                                self._collection_cv_discretegridpointcoverage.append(item)
118                                continue
119                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
120                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.discrete_coverages.cv_discretesurfacecoverage.CV_DiscreteSurfaceCoverage":
121                                self._collection_cv_discretesurfacecoverage.append(item)
122                                continue
123                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
124                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.discrete_coverages.cv_discretepointcoverage.CV_DiscretePointCoverage":
125                                self._collection_cv_discretepointcoverage.append(item)
126                                continue
127                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
128                        if valueClass == "ea_model.iso_19156_2011_observations_and_measurements.temporal_coverage.cvt_discretetimeinstantcoverage.CVT_DiscreteTimeInstantCoverage":
129                                self._collection_cvt_discretetimeinstantcoverage.append(item)
130                                continue
131                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
132                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.discrete_coverages.cv_discretecurvecoverage.CV_DiscreteCurveCoverage":
133                                self._collection_cv_discretecurvecoverage.append(item)
134                                continue
135                for item in self.extension:     
136                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
137                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.thiessen_polygon.cv_thiessenvaluepolygon.CV_ThiessenValuePolygon":
138                                self._extension_cv_thiessenvaluepolygon.append(item)
139                                continue
140                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
141                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.tin.cv_valuetriangle.CV_ValueTriangle":
142                                self._extension_cv_valuetriangle.append(item)
143                                continue
144                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
145                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.segmented_curve.cv_valuecurve.CV_ValueCurve":
146                                self._extension_cv_valuecurve.append(item)
147                                continue
148                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
149                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.hexagonal_grid.cv_valuehexagon.CV_ValueHexagon":
150                                self._extension_cv_valuehexagon.append(item)
151                                continue
152                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
153                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.quadrilateral_grid.cv_gridvaluecell.CV_GridValueCell":
154                                self._extension_cv_gridvaluecell.append(item)
155                                continue
156                pass
157
158        def __key(self):
159                return (self.collection, self.value, self.geometry, self.extension)
160
161        def __eq__(self, y):
162                if type(self) != type(y):
163                        return False
164                '''
165                Cannot compare classes which do not define a "__key" attribute
166                '''
167                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
168                        return self.__key() == y.__key()
169                return id(self) == id(y)
170
171        def __hash__(self):
172                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.