Changeset 1432
- Timestamp:
- 09/18/08 17:07:12 (2 months ago)
- Files:
-
- pleiades.openlayers/trunk/pleiades/openlayers/browser.py (modified) (3 diffs)
- pleiades.openlayers/trunk/pleiades/openlayers/configure.zcml (modified) (2 diffs)
- pleiades.openlayers/trunk/pleiades/openlayers/proj.py (added)
- pleiades.openlayers/trunk/pleiades/openlayers/tests.py (deleted)
- pleiades.openlayers/trunk/setup.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pleiades.openlayers/trunk/pleiades/openlayers/browser.py
r1429 r1432 1 1 import os 2 2 from shapely.geometry import asShape 3 from pyproj import Proj 3 4 from zope.publisher.browser import BrowserPage 4 5 from zgeo.geographer.interfaces import IGeoreferenced 5 6 6 7 7 class PlaceOLJS(BrowserPage): 8 PROJ_900913 = """ 9 +proj=merc +a=6378137 +b=6378137 10 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 11 +units=m +nadgrids=@null +no_defs 12 """ 8 13 14 class OLSphericalMercatorJS(BrowserPage): 15 """Returns coordinates projected to Spherical Mercator for use with 16 Google Maps. 17 """ 9 18 def __call__(self): 10 19 response = self.request.response 11 20 geo = IGeoreferenced(self.context) 21 22 # Project the geo coordinates 23 proj_sm = Proj(PROJ_900913) 12 24 if geo.type == 'Point': 13 centroid = geo 25 x, y = proj_sm(*tuple(geo.coordinates)) 26 where = dict(type=geo.type, coordinates=[x, y]) 27 centroid = where 14 28 else: 15 shape = asShape(geo) 16 centroid = shape.centroid 29 #shape = asShape(geo) 30 #centroid = shape.centroid 31 raise NotImplemented, "Points only in this version" 32 17 33 response.setHeader('Content-Type', 'text/javascript') 18 34 return """ … … 21 37 """ % dict( 22 38 uid=self.context.UID(), 23 where= dict(type=geo.type, coordinates=geo.coordinates),24 centroid=centroid .__geo_interface__['geometry']39 where=where, 40 centroid=centroid 25 41 ) 26 42 … … 32 48 def __call__(self): 33 49 return GMAPS_KEY 50 51 52 class EditGeo(BrowserPage): 53 pass 54 pleiades.openlayers/trunk/pleiades/openlayers/configure.zcml
r1429 r1432 10 10 for="Products.PleiadesEntity.content.interfaces.IPlace" 11 11 name="ol.js" 12 class=".browser. PlaceOLJS"12 class=".browser.OLSphericalMercatorJS" 13 13 permission="zope2.View" 14 14 /> … … 21 21 /> 22 22 23 <browser:page 24 for="Products.PleiadesEntity.content.interfaces.ILocation" 25 name="edit-geo" 26 class=".browser.EditGeo" 27 permission="cmf.ModifyPortalContent" 28 /> 29 23 30 </configure> pleiades.openlayers/trunk/setup.py
r1429 r1432 27 27 install_requires=[ 28 28 'setuptools', 29 # -*- Extra requirements: -*- 29 'geojson', 30 'pyproj' 30 31 ], 31 32 entry_points="""
