Revision: 8587
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8587&view=rev
Author:   jswhit
Date:     2010-07-28 18:37:26 +0000 (Wed, 28 Jul 2010)

Log Message:
-----------
update to new version from pyproj svn

Modified Paths:
--------------
    trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pyproj.py

Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pyproj.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pyproj.py   2010-07-28 
18:35:18 UTC (rev 8586)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pyproj.py   2010-07-28 
18:37:26 UTC (rev 8587)
@@ -80,13 +80,15 @@
     degrees. If optional keyword 'errcheck' is True (default is
     False) an exception is raised if the transformation is invalid.
     If errcheck=False and the transformation is invalid, no
-    exception is raised and 1.e30 is returned.
+    exception is raised and 1.e30 is returned. If the optional keyword
+    'preserve_units' is True, the units in map projection coordinates
+    are not forced to be meters.
 
     Works with numpy and regular python array objects, python
     sequences and scalars.
     """
 
-    def __new__(self, projparams=None, **kwargs):
+    def __new__(self, projparams=None, preserve_units=False, **kwargs):
         """
         initialize a Proj class instance.
 
@@ -121,6 +123,12 @@
         >>> x,y = p2(-120.108, 34.36116666)
         >>> print 'x=%9.3f y=%11.3f' % (x,y)
         x=765975.641 y=3805993.134
+        >>> p = Proj(init="epsg:32667")
+        >>> print 'x=%12.3f y=%12.3f (meters)' % p(-114.057222, 51.045)
+        x=-1783486.760 y= 6193833.196 (meters)
+        >>> p = Proj("+init=epsg:32667",preserve_units=True)
+        >>> print 'x=%12.3f y=%12.3f (feet)' % p(-114.057222, 51.045)
+        x=-5851322.810 y=20320934.409 (feet)
         """
         # if projparams is None, use kwargs.
         if projparams is None:
@@ -133,13 +141,13 @@
             projstring = projparams
         else: # projparams a dict
             projstring = _dict2string(projparams)
-        # make sure units are meters.
-        if not  projstring.count('+units='):
+        # make sure units are meters if preserve_units is False.
+        if not projstring.count('+units=') and not preserve_units:
             projstring = '+units=m '+projstring
         else:
             kvpairs = []
             for kvpair in projstring.split():
-                if kvpair.startswith('+units'):
+                if kvpair.startswith('+units') and not preserve_units:
                     k,v = kvpair.split('=')
                     kvpairs.append(k+'=m ')
                 else:
@@ -370,9 +378,9 @@
         initialize a Geod class instance.
 
         Geodetic parameters for specifying the ellipsoid
-        can be given in a dictionary 'initparams', as keyword arguments,
+        can be given in a dictionary 'initparams', as keyword arguments, 
         or as as proj4 geod initialization string.
-        Following is a list of the ellipsoids that may be defined using the
+        Following is a list of the ellipsoids that may be defined using the 
         'ellps' keyword:
 
            MERIT a=6378137.0      rf=298.257       MERIT 1983
@@ -486,6 +494,9 @@
                 else:
                     kvpairs.append(kvpair+' ')
             initstring = ''.join(kvpairs)
+        # first try a Proj class (catches errors properly)
+        projstring = initstring + ' +proj=latlon'
+        p = Proj(projstring) # this is never used
         return _Geod.__new__(self, initstring)
 
     def fwd(self, lons, lats, az, dist, radians=False):


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to