Changeset 1325
- Timestamp:
- 05/28/08 12:40:13 (6 months ago)
- Files:
-
- PleiadesEntity/trunk/geo.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
PleiadesEntity/trunk/geo.py
r1307 r1325 70 70 """Initialize adapter.""" 71 71 self.context = context 72 73 @property 74 def primary_location(self): 72 self._adapter = None 75 73 x = self.context.getRefs('hasLocation') 76 74 if len(x) == 0: 77 r eturn None75 raise Exception, "Unlocated: could not adapt %s" % str(context) 78 76 else: 79 returnIGeoreferenced(x[0])77 self._adapter = IGeoreferenced(x[0]) 80 78 81 79 @property 82 80 def type(self): 83 return self. primary_location.type81 return self._adapter.type 84 82 85 83 @property 86 84 def coordinates(self): 87 return self.primary_location.coordinates 88 # 89 #x = self.context.getRefs('hasLocation') 90 #if len(x) == 0: 91 # return () 92 #x0 = x[0] 93 #values = [float(v) for v in \ 94 # x0.getSpatialCoordinates().split()] 95 #nvalues = len(values) 96 # Our Pleiades Locations are 2D 97 #npoints = nvalues/2 98 #coords = [] 99 #for i in range(npoints): 100 # #coords.append(tuple(values[3*i:3*i+3] + [0.0])) 101 # coords.append((values[3*i+1], values[3*i], 0.0)) 102 #return coords[0] 85 return self._adapter.coordinates 103 86 104 87 @property … … 112 95 type='Feature', 113 96 id=context.getId(), 114 geometry=self. primary_location.__geo_interface__97 geometry=self._adapter.__geo_interface__ 115 98 ) 116 99 … … 125 108 """Initialize adapter.""" 126 109 self.context = context 127 self._ primary_association= None110 self._adapter = None 128 111 for ob in self.context.values(): 129 112 try: 130 self._ primary_association= IGeoreferenced(ob)113 self._adapter = IGeoreferenced(ob) 131 114 except: 132 115 continue 133 116 break 134 if not self._ primary_association:117 if not self._adapter: 135 118 raise Exception, "Could not adapt %s" % str(context) 136 119 137 120 @property 138 121 def type(self): 139 return IGeoreferenced(self._ primary_association).type122 return IGeoreferenced(self._adapter).type 140 123 141 124 @property 142 125 def coordinates(self): 143 return IGeoreferenced(self._ primary_association).coordinates126 return IGeoreferenced(self._adapter).coordinates 144 127 145 128 @property … … 149 132 @property 150 133 def __geo_interface__(self): 151 return IGeoreferenced(self._primary_association).__geo_interface__ 134 return IGeoreferenced(self._adapter).__geo_interface__ 135 152 136 153 137 def createGeoItem(context): … … 157 141 else: 158 142 return PlacefulAssociationGeoItem(context) 159 160 161
