Changeset 1307
- Timestamp:
- 05/06/08 17:05:00 (7 months ago)
- Files:
-
- PleiadesEntity/trunk/Extensions/batching.py (modified) (1 diff)
- PleiadesEntity/trunk/Extensions/loader.py (modified) (3 diffs)
- PleiadesEntity/trunk/configure.zcml (modified) (1 diff)
- PleiadesEntity/trunk/content/Location.py (modified) (2 diffs)
- PleiadesEntity/trunk/geo.py (modified) (3 diffs)
- PleiadesEntity/trunk/models/PleiadesEntity.zargo (modified) (previous)
- PleiadesEntity/trunk/profiles/default/import_steps.xml (modified) (3 diffs)
- PleiadesEntity/trunk/tests/Entities.txt (modified) (3 diffs)
- PleiadesEntity/trunk/tests/LoadEntity.txt (modified) (1 diff)
- PleiadesEntity/trunk/tests/LocationViews.txt (modified) (2 diffs)
- PleiadesEntity/trunk/version.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
PleiadesEntity/trunk/Extensions/batching.py
r581 r1307 106 106 if len(values) == 2: 107 107 values.append('0.0') 108 en.set SpatialCoordinates(' '.join(values))108 en.setGeometry('Point:[%s,%s]' % (values[1], values[0]) #SpatialCoordinates(' '.join(values)) 109 109 110 110 # add any names as children of the entity PleiadesEntity/trunk/Extensions/loader.py
r1249 r1307 67 67 coords = xmlcontext.xpath( 68 68 "adlgaz:spatialLocation/georss:point", 69 {'adlgaz': ADLGAZ, 'georss': GEORSS}69 namespaces={'adlgaz': ADLGAZ, 'georss': GEORSS} 70 70 )[0].text.split() 71 71 … … 201 201 srs = xmlcontext.find("{%s}secondaryReferences" % AWMC) 202 202 if srs: 203 bibls = srs.xpath('tei:bibl', {'tei': TEI})203 bibls = srs.xpath('tei:bibl', namespaces={'tei': TEI}) 204 204 if not bibls: 205 205 raise EntityLoadError, "Encountered an empty secondaryReferences" 206 206 else: 207 207 for bibl in bibls: 208 title_elem = bibl.xpath('tei:title', {'tei': TEI})208 title_elem = bibl.xpath('tei:title', namespaces={'tei': TEI}) 209 209 if not title_elem: 210 210 continue … … 376 376 377 377 for e in root.findall("{%s}spatialLocation" % ADLGAZ): 378 coords = e.findall("{%s}point" % GEORSS)[0].text 378 coords = e.findall("{%s}point" % GEORSS)[0].text.split() 379 379 380 380 lid = portalcontext.invokeFactory('Location', 381 geometryType='Point', 382 spatialCoordinates=str(coords), 381 geometry='Point:[%s,%s]' % (coords[1], coords[0]), 383 382 creators=creators, 384 383 contributors=contributors, PleiadesEntity/trunk/configure.zcml
r1295 r1307 6 6 7 7 <!-- ##code-section configure.zcml --> 8 <adapter 9 for="Products.PleiadesEntity.content.Location.Location" 10 provides="zgeo.geographer.interfaces.IGeoreferenced" 11 factory=".geo.LocationGeoItem" 12 /> 13 8 14 <adapter 9 15 for="Products.PleiadesEntity.content.PlacefulAssociation.PlacefulAssociation" PleiadesEntity/trunk/content/Location.py
r1244 r1307 29 29 30 30 StringField( 31 name='geometryType', 32 default="Point", 33 widget=SelectionWidget( 34 label="Geometry Type", 35 label_msgid='PleiadesEntity_label_geometryType', 36 i18n_domain='PleiadesEntity', 37 ), 38 enforceVocabulary=1, 39 vocabulary=['Point'], 40 ), 41 StringField( 42 name='spatialCoordinates', 31 name='geometry', 43 32 widget=StringField._properties['widget']( 44 label=" Spatial Coordinates",45 description=" Use GeoRSS-Simple representation.",46 label_msgid='PleiadesEntity_label_ spatialCoordinates',47 description_msgid='PleiadesEntity_help_ spatialCoordinates',33 label="Geometry", 34 description="""Geometry using GeoJSON shorthand representation such as "Point: (-105.0, 40.0)" for a point""", 35 label_msgid='PleiadesEntity_label_geometry', 36 description_msgid='PleiadesEntity_help_geometry', 48 37 i18n_domain='PleiadesEntity', 49 38 ), … … 82 71 """Return a title string derived from the geometry type.""" 83 72 try: 84 return "%s %s" % (self.getGeometry Type(), self.getId())73 return "%s %s" % (self.getGeometry().split(':')[0], self.getId()) 85 74 except AttributeError: 86 75 return 'Unidentified Location' PleiadesEntity/trunk/geo.py
r1245 r1307 29 29 30 30 from zope.interface import implements 31 from zgeo.geographer.interfaces import IGeoreferenced 31 from zgeo.geographer.interfaces import IGeoreferenced, IWriteGeoreferenced 32 import simplejson 32 33 33 34 import logging 34 35 log = logging.getLogger('PleiadesEntity.geo') 36 37 38 class LocationGeoItem(object): 39 implements(IGeoreferenced) 40 41 def __init__(self, context): 42 self.context = context 43 44 @property 45 def __geo_interface__(self): 46 """Expect getGeometry() returns a string like 47 'Point:[-105.0, 40.0]' 48 """ 49 d = self.context.getGeometry().split(':') 50 x = simplejson.loads('{"type": "%s", "coordinates": %s}' % (d[0], d[1])) 51 return dict(type=str(x['type']), coordinates=x['coordinates']) 52 53 @property 54 def type(self): 55 return self.__geo_interface__['type'] 56 57 @property 58 def coordinates(self): 59 return self.__geo_interface__['coordinates'] 60 61 @property 62 def crs(self): 63 return None 64 35 65 36 66 class PlacefulAssociationGeoItem(object): … … 42 72 43 73 @property 74 def primary_location(self): 75 x = self.context.getRefs('hasLocation') 76 if len(x) == 0: 77 return None 78 else: 79 return IGeoreferenced(x[0]) 80 81 @property 44 82 def type(self): 45 return 'Point'83 return self.primary_location.type 46 84 47 85 @property 48 86 def coordinates(self): 49 x = self.context.getRefs('hasLocation') 50 if len(x) == 0: 51 return () 52 x0 = x[0] 53 values = [float(v) for v in \ 54 x0.getSpatialCoordinates().split()] 55 nvalues = len(values) 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) 56 96 # Our Pleiades Locations are 2D 57 npoints = nvalues/258 coords = []59 for i in range(npoints):60 #coords.append(tuple(values[3*i:3*i+3] + [0.0]))61 coords.append((values[3*i+1], values[3*i], 0.0))62 return coords[0]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] 63 103 64 104 @property … … 69 109 def __geo_interface__(self): 70 110 context = self.context 71 return {72 'type':'Feature',73 'id':context.getId(),74 'geometry': {'type': self.type, 'coordinates': self.coordinates}75 }111 return dict( 112 type='Feature', 113 id=context.getId(), 114 geometry=self.primary_location.__geo_interface__ 115 ) 76 116 77 117 PleiadesEntity/trunk/profiles/default/import_steps.xml
r1270 r1307 7 7 handler="Products.PleiadesEntity.setuphandlers.installVocabularies" 8 8 title="Install Vocabularies for PleiadesEntity" 9 version="2008-0 3-26T14:25:35.985572">9 version="2008-05-05T16:43:15.936158"> 10 10 <dependency step="PleiadesEntity-QI-dependencies"/> 11 11 Installs the vocabulary files into vocabulary library for PleiadesEntity … … 16 16 handler="Products.PleiadesEntity.setuphandlers.updateRoleMappings" 17 17 title="Update Workflow role mappings for PleiadesEntity" 18 version="2008-0 3-26T14:25:35.985572">18 version="2008-05-05T16:43:15.936158"> 19 19 <dependency step="PleiadesEntity-QI-dependencies"/> 20 20 updates the workflow role mappings for PleiadesEntity … … 25 25 handler="Products.PleiadesEntity.setuphandlers.postInstall" 26 26 title="manual coded post-install for PleiadesEntity" 27 version="2008-0 3-26T14:25:35.985572">27 version="2008-05-05T16:43:15.936158"> 28 28 <dependency step="PleiadesEntity-QI-dependencies"/> 29 29 manual coded post-install for PleiadesEntity PleiadesEntity/trunk/tests/Entities.txt
r1249 r1307 31 31 Set location coordinates 32 32 33 >>> _ = x.set SpatialCoordinates('34.769722222222 -86.4808333333333 0.0')33 >>> _ = x.setGeometry('Point:[-86.4808333333333, 34.769722222222]') 34 34 35 35 Test the geo adapters … … 47 47 'Point' 48 48 >>> g.coordinates 49 (-86.480833333333294, 34.769722222222001, 0.0)49 [-86.480833333333294, 34.769722222222001] 50 50 51 51 Place … … 58 58 'Point' 59 59 >>> g.coordinates 60 (-86.480833333333294, 34.769722222222001, 0.0) 61 60 [-86.480833333333294, 34.769722222222001] PleiadesEntity/trunk/tests/LoadEntity.txt
r1249 r1307 146 146 >>> lid = r['location_ids'][0] 147 147 >>> l = getattr(folder.locations, lid) 148 >>> l.geometryType 149 u'Point' 150 >>> l.getGeometryType() 151 'Point' 152 >>> l.spatialCoordinates 153 u'37.7145 28.7289' 154 >>> l.getSpatialCoordinates() 155 '37.7145 28.7289' 148 >>> l.getGeometry() 149 'Point:[28.7289,37.7145]' 156 150 >>> l.title_or_id() == "Point %s" % lid 157 151 True PleiadesEntity/trunk/tests/LocationViews.txt
r1249 r1307 8 8 >>> lid = folder.locations.invokeFactory('Location') 9 9 >>> x = getattr(folder.locations, lid) 10 >>> _ = x.setSpatialCoordinates('34.769722222222 -86.4808333333333 0.0') 11 >>> _ = x.setGeometryType('Point') 10 >>> _ = x.setGeometry('Point:[-86.4808333333333,34.769722222222]') 12 11 13 12 … … 75 74 76 75 >>> browser.contents 77 '... Spatial Coordinates...34.769722222222 -86.4808333333333 0.0...'76 '...Geometry...Point:[-86.4808...' 78 77 PleiadesEntity/trunk/version.txt
r1244 r1307 1 0.2 build 2 791 0.2 build 280
