|
From: <js...@us...> - 2008-07-23 12:32:50
|
Revision: 5820
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5820&view=rev
Author: jswhit
Date: 2008-07-23 12:32:48 +0000 (Wed, 23 Jul 2008)
Log Message:
-----------
add barbs method, barbs example.
Modified Paths:
--------------
trunk/toolkits/basemap/MANIFEST.in
trunk/toolkits/basemap/examples/README
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Added Paths:
-----------
trunk/toolkits/basemap/examples/barb_demo.py
Modified: trunk/toolkits/basemap/MANIFEST.in
===================================================================
--- trunk/toolkits/basemap/MANIFEST.in 2008-07-23 03:08:41 UTC (rev 5819)
+++ trunk/toolkits/basemap/MANIFEST.in 2008-07-23 12:32:48 UTC (rev 5820)
@@ -39,6 +39,7 @@
include examples/contour_demo.py
include examples/customticks.py
include examples/quiver_demo.py
+include examples/barbs_demo.py
include examples/nytolondon.py
include examples/ortho_demo.py
include examples/geos_demo.py
Modified: trunk/toolkits/basemap/examples/README
===================================================================
--- trunk/toolkits/basemap/examples/README 2008-07-23 03:08:41 UTC (rev 5819)
+++ trunk/toolkits/basemap/examples/README 2008-07-23 12:32:48 UTC (rev 5820)
@@ -36,6 +36,8 @@
quiver_demo.py shows how to plot wind vectors on a map.
+barbs_demo.py shows how to plot wind barbs on a map.
+
randompoints.py demonstrates the use of scatter to plot randomly distributed
points on the earth.
Added: trunk/toolkits/basemap/examples/barb_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/barb_demo.py (rev 0)
+++ trunk/toolkits/basemap/examples/barb_demo.py 2008-07-23 12:32:48 UTC (rev 5820)
@@ -0,0 +1,55 @@
+from mpl_toolkits.basemap import Basemap
+import numpy as np
+import matplotlib.pyplot as plt
+
+# read in data.
+file = open('fcover.dat','r')
+ul=[];vl=[];pl=[]
+nlons=73; nlats=73
+dellat = 2.5; dellon = 5.
+for line in file.readlines():
+ l = line.replace('\n','').split()
+ ul.append(float(l[0]))
+ vl.append(float(l[1]))
+ pl.append(float(l[2]))
+u = np.reshape(np.array(ul,np.float32),(nlats,nlons))
+v = np.reshape(np.array(vl,np.float32),(nlats,nlons))
+p = np.reshape(np.array(pl,np.float32),(nlats,nlons))
+lats1 = -90.+dellat*np.arange(nlats)
+lons1 = -180.+dellon*np.arange(nlons)
+lons, lats = np.meshgrid(lons1, lats1)
+# convert from mps to knots.
+u = 1.944*u; v = 1.944*v
+
+# plot barbs in map projection coordinates.
+
+# stereogrpaphic projection.
+m = Basemap(width=10000000,height=10000000,lon_0=-90,lat_0=45.,lat_ts=45,
+ resolution='l',projection='stere')
+x,y = m(lons,lats)
+# transform from spherical to map projection coordinates (rotation
+# and interpolation).
+nxv = 25; nyv = 25
+udat, vdat, xv, yv = m.transform_vector(u,v,lons1,lats1,nxv,nyv,returnxy=True)
+# create a figure, add an axes.
+fig=plt.figure(figsize=(8,8))
+ax = fig.add_axes([0.1,0.1,0.7,0.7])
+# plot color-filled contours over map
+levs = np.arange(960,1051,4)
+cs1 = m.contour(x,y,p,levs,colors='k',linewidths=0.5)
+cs2 = m.contourf(x,y,p,levs)
+# plot barbs.
+m.barbs(xv,yv,udat,vdat,length=6,barbcolor='k',flagcolor='r',linewidth=0.5)
+# plot colorbar for pressure
+cax = plt.axes([0.875, 0.1, 0.05, 0.7]) # setup colorbar axes.
+plt.colorbar(cax=cax) # draw colorbar
+plt.axes(ax) # make the original axes current again
+# draw coastlines
+m.drawcoastlines()
+# draw parallels
+m.drawparallels(np.arange(0,81,20),labels=[1,1,0,0])
+# draw meridians
+m.drawmeridians(np.arange(-180,0,20),labels=[0,0,0,1])
+plt.title('Surface Wind Barbs and Pressure')
+plt.show()
+
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-07-23 03:08:41 UTC (rev 5819)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-07-23 12:32:48 UTC (rev 5820)
@@ -2890,6 +2890,44 @@
self.set_axes_limits(ax=ax)
return ret
+ def barbs(self, x, y, u, v, *args, **kwargs):
+ """
+ Make a wind barb plot (u, v) with on the map.
+ (see matplotlib.pyplot.barbs documentation).
+
+ Extra keyword ``ax`` can be used to override the default axis instance.
+
+ Other \*args and \**kwargs passed on to matplotlib.pyplot.barbs
+ """
+ if not kwargs.has_key('ax') and self.ax is None:
+ try:
+ ax = plt.gca()
+ except:
+ import matplotlib.pyplot as plt
+ ax = plt.gca()
+ elif not kwargs.has_key('ax') and self.ax is not None:
+ ax = self.ax
+ else:
+ ax = kwargs.pop('ax')
+ # allow callers to override the hold state by passing hold=True|False
+ b = ax.ishold()
+ h = kwargs.pop('hold',None)
+ if h is not None:
+ ax.hold(h)
+ try:
+ ret = ax.barbs(x,y,u,v,*args,**kwargs)
+ try:
+ plt.draw_if_interactive()
+ except:
+ pass
+ except:
+ ax.hold(b)
+ raise
+ ax.hold(b)
+ # set axes limits to fit map region.
+ self.set_axes_limits(ax=ax)
+ return ret
+
def drawlsmask(self,rgba_land,rgba_ocean,lsmask=None,
lsmask_lons=None,lsmask_lats=None,lakes=False,**kwargs):
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-07-29 19:59:45
|
Revision: 5925
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5925&view=rev
Author: jswhit
Date: 2008-07-29 19:59:43 +0000 (Tue, 29 Jul 2008)
Log Message:
-----------
gcc4.3 compatibility patch for geos-2.2.3 from David Huard.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/README
trunk/toolkits/basemap/geos-2.2.3/source/capi/geos_c.cpp
trunk/toolkits/basemap/geos-2.2.3/source/index/quadtree/DoubleBits.cpp
trunk/toolkits/basemap/geos-2.2.3/source/io/ByteOrderValues.cpp
trunk/toolkits/basemap/geos-2.2.3/source/io/StringTokenizer.cpp
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-07-29 18:34:11 UTC (rev 5924)
+++ trunk/toolkits/basemap/Changelog 2008-07-29 19:59:43 UTC (rev 5925)
@@ -1,4 +1,5 @@
version 0.99.1 (not yet released)
+ * geos-2.2.3 patched for compatibility with gcc 4.3.
* added "barbs" method to draw wind barbs on the map.
* added "tissot" method for generating Tissot's indicatrix
(see example plot_tissot.py).
Modified: trunk/toolkits/basemap/README
===================================================================
--- trunk/toolkits/basemap/README 2008-07-29 18:34:11 UTC (rev 5924)
+++ trunk/toolkits/basemap/README 2008-07-29 19:59:43 UTC (rev 5925)
@@ -125,5 +125,7 @@
Erik Andersen
Michael Hearne
Jesper Larsen
+Ryan May
+David Huard
for valuable contributions.
Modified: trunk/toolkits/basemap/geos-2.2.3/source/capi/geos_c.cpp
===================================================================
--- trunk/toolkits/basemap/geos-2.2.3/source/capi/geos_c.cpp 2008-07-29 18:34:11 UTC (rev 5924)
+++ trunk/toolkits/basemap/geos-2.2.3/source/capi/geos_c.cpp 2008-07-29 19:59:43 UTC (rev 5925)
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <string>
+#include <cstring>
#include <iostream>
#include <sstream>
#include <fstream>
Modified: trunk/toolkits/basemap/geos-2.2.3/source/index/quadtree/DoubleBits.cpp
===================================================================
--- trunk/toolkits/basemap/geos-2.2.3/source/index/quadtree/DoubleBits.cpp 2008-07-29 18:34:11 UTC (rev 5924)
+++ trunk/toolkits/basemap/geos-2.2.3/source/index/quadtree/DoubleBits.cpp 2008-07-29 19:59:43 UTC (rev 5925)
@@ -15,6 +15,7 @@
#include <geos/indexQuadtree.h>
#include <geos/util.h>
+#include <cstring>
namespace geos {
Modified: trunk/toolkits/basemap/geos-2.2.3/source/io/ByteOrderValues.cpp
===================================================================
--- trunk/toolkits/basemap/geos-2.2.3/source/io/ByteOrderValues.cpp 2008-07-29 18:34:11 UTC (rev 5924)
+++ trunk/toolkits/basemap/geos-2.2.3/source/io/ByteOrderValues.cpp 2008-07-29 19:59:43 UTC (rev 5925)
@@ -16,6 +16,7 @@
#include <geos/io.h>
#include <geos/util.h>
+#include <cstring>
namespace geos {
Modified: trunk/toolkits/basemap/geos-2.2.3/source/io/StringTokenizer.cpp
===================================================================
--- trunk/toolkits/basemap/geos-2.2.3/source/io/StringTokenizer.cpp 2008-07-29 18:34:11 UTC (rev 5924)
+++ trunk/toolkits/basemap/geos-2.2.3/source/io/StringTokenizer.cpp 2008-07-29 19:59:43 UTC (rev 5925)
@@ -36,7 +36,9 @@
#include <geos/io.h>
+#include <cstring>
+
namespace geos {
StringTokenizer::StringTokenizer(){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-07-30 15:20:55
|
Revision: 5928
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5928&view=rev
Author: jswhit
Date: 2008-07-30 15:20:48 +0000 (Wed, 30 Jul 2008)
Log Message:
-----------
include link to new API docs.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/README
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-07-30 12:41:04 UTC (rev 5927)
+++ trunk/toolkits/basemap/Changelog 2008-07-30 15:20:48 UTC (rev 5928)
@@ -6,7 +6,9 @@
* fixed processing of coastlines for gnomonic projection.
* don't try to use PyNIO in NetCDFFile (it was causing
too many suprises).
- * improved documentation using Sphinx/docutils.
+ * start of improved documentation using Sphinx/docutils.
+ Can be viewed at
+ http://matplotlib.sf.net/basemap/doc/html
* change default behaviour of num2date and date2num to be
the same as matplotlib counterparts.
version 0.99 (svn revision 5344)
Modified: trunk/toolkits/basemap/README
===================================================================
--- trunk/toolkits/basemap/README 2008-07-30 12:41:04 UTC (rev 5927)
+++ trunk/toolkits/basemap/README 2008-07-30 15:20:48 UTC (rev 5928)
@@ -60,7 +60,7 @@
**Documentation**
-see basemap.py docstrings.
+see docstrings and http://matplotlib.sf.net/basemap/doc/html/.
see scripts in 'examples' directory for example usage.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-01 17:58:05
|
Revision: 5948
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5948&view=rev
Author: jswhit
Date: 2008-08-01 17:57:59 +0000 (Fri, 01 Aug 2008)
Log Message:
-----------
change drawlsmask method to accept any valid matplotlib color specification.
Modified Paths:
--------------
trunk/toolkits/basemap/examples/ortho_demo.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Added Paths:
-----------
trunk/toolkits/basemap/doc/users/figures/background1.py
trunk/toolkits/basemap/doc/users/figures/background2.py
trunk/toolkits/basemap/doc/users/figures/background3.py
Added: trunk/toolkits/basemap/doc/users/figures/background1.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/background1.py (rev 0)
+++ trunk/toolkits/basemap/doc/users/figures/background1.py 2008-08-01 17:57:59 UTC (rev 5948)
@@ -0,0 +1,15 @@
+from mpl_toolkits.basemap import Basemap
+import matplotlib.pyplot as plt
+# setup Lambert Conformal basemap.
+m = Basemap(width=12000000,height=9000000,projection='lcc',
+ resolution='c',lat_1=45.,lat_2=55,lat_0=50,lon_0=-107.)
+# draw coastlines.
+m.drawcoastlines()
+# draw a boundary around the map, fill the background.
+# this background will end up being the ocean color, since
+# the continents will be drawn on top.
+m.drawmapboundary(fill_color='aqua')
+# fill continents, set lake color same as ocean color.
+m.fillcontinents(color='coral',lake_color='aqua')
+plt.title("Lambert Conformal Projection")
+plt.savefig('background1.png')
Added: trunk/toolkits/basemap/doc/users/figures/background2.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/background2.py (rev 0)
+++ trunk/toolkits/basemap/doc/users/figures/background2.py 2008-08-01 17:57:59 UTC (rev 5948)
@@ -0,0 +1,11 @@
+from mpl_toolkits.basemap import Basemap
+import matplotlib.pyplot as plt
+# setup Lambert Conformal basemap.
+# set resolution=None to skip processing of boundary datasets.
+m = Basemap(width=12000000,height=9000000,projection='lcc',
+ resolution=None,lat_1=45.,lat_2=55,lat_0=50,lon_0=-107.)
+# draw a land-sea mask for a map background.
+# lakes=True means plot inland lakes with ocean color.
+m.drawlsmask('coral','aqua',lakes=True)
+plt.title("Lambert Conformal Projection")
+plt.savefig('background2.png')
Added: trunk/toolkits/basemap/doc/users/figures/background3.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/background3.py (rev 0)
+++ trunk/toolkits/basemap/doc/users/figures/background3.py 2008-08-01 17:57:59 UTC (rev 5948)
@@ -0,0 +1,9 @@
+from mpl_toolkits.basemap import Basemap
+import matplotlib.pyplot as plt
+# setup Lambert Conformal basemap.
+# set resolution=None to skip processing of boundary datasets.
+m = Basemap(width=12000000,height=9000000,projection='lcc',
+ resolution=None,lat_1=45.,lat_2=55,lat_0=50,lon_0=-107.)
+m.bluemarble()
+plt.title("Lambert Conformal Projection")
+plt.savefig('background3.png')
Modified: trunk/toolkits/basemap/examples/ortho_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/ortho_demo.py 2008-08-01 17:10:38 UTC (rev 5947)
+++ trunk/toolkits/basemap/examples/ortho_demo.py 2008-08-01 17:57:59 UTC (rev 5948)
@@ -13,7 +13,7 @@
rgba_land = (0,255,0,255) # land green.
rgba_ocean = (0,0,255,255) # ocean blue.
# lakes=True means plot inland lakes with ocean color.
-m.drawlsmask(rgba_land, rgba_ocean, lakes=True)
+m.drawlsmask('red','blue', lakes=True)
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,420.,60.))
@@ -32,9 +32,9 @@
m.drawmapboundary(fill_color='aqua')
# add a map scale.
length = 5000
-x1,y1 = 0.2*m.xmax, 0.2*m.ymax
+x1,y1 = 0.3*m.xmax, 0.25*m.ymax
lon1,lat1 = m(x1,y1,inverse=True)
-m.drawmapscale(lon1,lat1,lon_0,lat_0,length,fontsize=8,barstyle='fancy',\
+m.drawmapscale(lon1,lat1,lon1,lat1,length,fontsize=8,barstyle='fancy',\
labelstyle='fancy',units='km')
plt.title('Orthographic Map Centered on Lon=%s, Lat=%s' % (lon_0,lat_0))
plt.show()
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-08-01 17:10:38 UTC (rev 5947)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-08-01 17:57:59 UTC (rev 5948)
@@ -2940,7 +2940,7 @@
self.set_axes_limits(ax=ax)
return retnh,retsh
- def drawlsmask(self,rgba_land,rgba_ocean,lsmask=None,
+ def drawlsmask(self,land_color,ocean_color,lsmask=None,
lsmask_lons=None,lsmask_lats=None,lakes=False,**kwargs):
"""
Draw land-sea mask image.
@@ -2955,15 +2955,8 @@
============== ====================================================
Arguments Description
============== ====================================================
- rgba_land rgba integer tuple that describes desired
- land color. For example, for green (non-transparent)
- land areas, use rgba_land = (0,255,0,255).
- rgba_ocean rgba integer tuple that describes desired
- ocean color. For example, for blue (non-transparent)
- ocean areas, use (0,0,255,255). To make transparent
- blue oceans (useful if you just want to mask land
- regions over another image), use
- rgba_ocean = (0,0,255,0).
+ land_color desired land color (color name or rgba tuple).
+ rgba_ocean desired ocean color (color name or rgba tuple).
============== ====================================================
.. tabularcolumns:: |l|L|
@@ -2995,6 +2988,22 @@
Extra keyword ``ax`` can be used to override the default axis instance.
"""
+ # convert land and ocean colors to integer rgba tuples with
+ # values between 0 and 255.
+ from matplotlib.colors import ColorConverter
+ c = ColorConverter()
+ # if conversion fails, assume it's because the color
+ # given is already an rgba tuple with values between 0 and 255.
+ try:
+ cl = c.to_rgba(land_color)
+ rgba_land = tuple([int(255*x) for x in cl])
+ except:
+ rgba_land = land_color
+ try:
+ co = c.to_rgba(ocean_color)
+ rgba_ocean = tuple([int(255*x) for x in co])
+ except:
+ rgba_ocean = ocean_color
# look for axes instance (as keyword, an instance variable
# or from plt.gca().
if not kwargs.has_key('ax') and self.ax is None:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-02 18:54:38
|
Revision: 5956
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5956&view=rev
Author: jswhit
Date: 2008-08-02 18:54:32 +0000 (Sat, 02 Aug 2008)
Log Message:
-----------
make land_color, ocean_color kwargs in drawlsmask
Modified Paths:
--------------
trunk/toolkits/basemap/doc/users/figures/background2.py
trunk/toolkits/basemap/examples/geos_demo.py
trunk/toolkits/basemap/examples/ortho_demo.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/doc/users/figures/background2.py
===================================================================
--- trunk/toolkits/basemap/doc/users/figures/background2.py 2008-08-02 12:40:17 UTC (rev 5955)
+++ trunk/toolkits/basemap/doc/users/figures/background2.py 2008-08-02 18:54:32 UTC (rev 5956)
@@ -6,5 +6,6 @@
resolution=None,lat_1=45.,lat_2=55,lat_0=50,lon_0=-107.)
# draw a land-sea mask for a map background.
# lakes=True means plot inland lakes with ocean color.
-m.drawlsmask('coral','aqua',lakes=True)
+m.drawlsmask(land_color='coral',ocean_color='aqua',lakes=True)
+plt.show()
plt.savefig('background2.png')
Modified: trunk/toolkits/basemap/examples/geos_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/geos_demo.py 2008-08-02 12:40:17 UTC (rev 5955)
+++ trunk/toolkits/basemap/examples/geos_demo.py 2008-08-02 18:54:32 UTC (rev 5956)
@@ -11,7 +11,7 @@
# plot land-sea mask.
# land red, oceans blue.
# lakes=True means plot inland lakes with ocean color.
-m.drawlsmask('red','blue',lakes=True)
+m.drawlsmask(land_color='red',ocean_color='blue',lakes=True)
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,420.,60.))
Modified: trunk/toolkits/basemap/examples/ortho_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/ortho_demo.py 2008-08-02 12:40:17 UTC (rev 5955)
+++ trunk/toolkits/basemap/examples/ortho_demo.py 2008-08-02 18:54:32 UTC (rev 5956)
@@ -11,7 +11,7 @@
m = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution=None)
# land red, oceans blue.
# lakes=True means plot inland lakes with ocean color.
-m.drawlsmask('red','blue', lakes=True)
+m.drawlsmask(land_color='red',ocean_color='blue', lakes=True)
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,420.,60.))
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-08-02 12:40:17 UTC (rev 5955)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-08-02 18:54:32 UTC (rev 5956)
@@ -2940,7 +2940,7 @@
self.set_axes_limits(ax=ax)
return retnh,retsh
- def drawlsmask(self,land_color,ocean_color,lsmask=None,
+ def drawlsmask(self,land_color="0.8",ocean_color="w",lsmask=None,
lsmask_lons=None,lsmask_lats=None,lakes=False,**kwargs):
"""
Draw land-sea mask image.
@@ -2953,17 +2953,12 @@
.. tabularcolumns:: |l|L|
============== ====================================================
- Arguments Description
+ Keywords Description
============== ====================================================
land_color desired land color (color name or rgba tuple).
+ Default gray ("0.8").
ocean_color desired ocean color (color name or rgba tuple).
- ============== ====================================================
-
- .. tabularcolumns:: |l|L|
-
- ============== ====================================================
- Keywords Description
- ============== ====================================================
+ Default white.
lakes If True, inland lakes are also colored with
ocean_color (default is lakes=False).
lsmask An array of 0's for ocean pixels, 1's for
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-07 22:13:34
|
Revision: 5998
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5998&view=rev
Author: jswhit
Date: 2008-08-07 22:13:31 +0000 (Thu, 07 Aug 2008)
Log Message:
-----------
fixes for geos 3
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
trunk/toolkits/basemap/src/_geoslib.c
trunk/toolkits/basemap/src/_geoslib.pyx
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-08-07 20:57:42 UTC (rev 5997)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-08-07 22:13:31 UTC (rev 5998)
@@ -980,6 +980,10 @@
continue
# create a GEOS geometry object.
poly = Shape(b)
+ # this is a workaround to avoid
+ # GEOS_ERROR: TopologyException: found non-noded intersection between ...
+ # with geos 3.0.0
+ poly = poly.simplify(1.e-10)[0]
# if geometry instersects map projection
# region, and doesn't have any invalid points, process it.
if goodmask.all() and poly.intersects(boundarypolyxy):
Modified: trunk/toolkits/basemap/src/_geoslib.c
===================================================================
--- trunk/toolkits/basemap/src/_geoslib.c 2008-08-07 20:57:42 UTC (rev 5997)
+++ trunk/toolkits/basemap/src/_geoslib.c 2008-08-07 22:13:31 UTC (rev 5998)
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.9.8 on Fri Jun 13 14:28:32 2008 */
+/* Generated by Cython 0.9.8 on Thu Aug 7 16:03:59 2008 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -175,12 +175,10 @@
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
+static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
+
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
-
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
-
static void __Pyx_WriteUnraisable(const char *name); /*proto*/
static INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
@@ -194,6 +192,8 @@
}
}
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+
static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
static INLINE PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i, int is_unsigned) {
@@ -228,7 +228,7 @@
/* Type declarations */
-/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":127
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":128
* initGEOS(notice_h, error_h)
*
* cdef class BaseGeometry: # <<<<<<<<<<<<<<
@@ -243,7 +243,7 @@
PyObject *boundary;
};
-/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":214
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":253
* return (self.__class__,(self.boundary,))
*
* cdef class Polygon(BaseGeometry): # <<<<<<<<<<<<<<
@@ -255,7 +255,7 @@
struct __pyx_obj_8_geoslib_BaseGeometry __pyx_base;
};
-/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":270
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":309
* return area
*
* cdef class LineString(BaseGeometry): # <<<<<<<<<<<<<<
@@ -267,7 +267,7 @@
struct __pyx_obj_8_geoslib_BaseGeometry __pyx_base;
};
-/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":302
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":341
* self.boundary = b
*
* cdef class Point(BaseGeometry): # <<<<<<<<<<<<<<
@@ -298,12 +298,11 @@
/* Implementation of _geoslib */
static char __pyx_k_1[] = "0.1";
-static char __pyx_k_2[] = "2.2.3-CAPI-1.1.1";
-static char __pyx_k_3[] = "version 2.2.3 of the geos library is required";
static char __pyx_k_is_valid[] = "is_valid";
static char __pyx_k_geom_type[] = "geom_type";
static char __pyx_k_within[] = "within";
+static char __pyx_k_simplify[] = "simplify";
static char __pyx_k_intersects[] = "intersects";
static char __pyx_k_intersection[] = "intersection";
static char __pyx_k_get_coords[] = "get_coords";
@@ -315,11 +314,11 @@
static char __pyx_k_numpy[] = "numpy";
static char __pyx_k___version__[] = "__version__";
static char __pyx_k___geos_version__[] = "__geos_version__";
-static char __pyx_k_ValueError[] = "ValueError";
static PyObject *__pyx_kp_is_valid;
static PyObject *__pyx_kp_geom_type;
static PyObject *__pyx_kp_within;
+static PyObject *__pyx_kp_simplify;
static PyObject *__pyx_kp_intersects;
static PyObject *__pyx_kp_intersection;
static PyObject *__pyx_kp_get_coords;
@@ -331,15 +330,10 @@
static PyObject *__pyx_kp_numpy;
static PyObject *__pyx_kp___version__;
static PyObject *__pyx_kp___geos_version__;
-static PyObject *__pyx_kp_ValueError;
static PyObject *__pyx_kp_1;
-static PyObject *__pyx_kp_2;
-static PyObject *__pyx_kp_3;
-static PyObject *__pyx_builtin_ValueError;
-
-/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":100
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":101
* int GEOSCoordSeq_getSize(GEOSCoordSeq *s, unsigned int *size)
*
* cdef void notice_h(char *fmt, char*msg): # <<<<<<<<<<<<<<
@@ -353,9 +347,9 @@
static PyObject *__pyx_kp_stdout;
static PyObject *__pyx_kp_write;
-static PyObject *__pyx_kp_4;
+static PyObject *__pyx_kp_2;
-static char __pyx_k_4[] = "GEOS_NOTICE: %s\n";
+static char __pyx_k_2[] = "GEOS_NOTICE: %s\n";
static void __pyx_f_8_geoslib_notice_h(char *__pyx_v_fmt, char *__pyx_v_msg) {
PyObject *__pyx_v_format;
@@ -368,31 +362,31 @@
__pyx_v_message = Py_None; Py_INCREF(Py_None);
__pyx_v_warn_msg = Py_None; Py_INCREF(Py_None);
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":101
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":102
*
* cdef void notice_h(char *fmt, char*msg):
* format = PyString_FromString(fmt) # <<<<<<<<<<<<<<
* message = PyString_FromString(msg)
* try:
*/
- __pyx_1 = PyString_FromString(__pyx_v_fmt); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = PyString_FromString(__pyx_v_fmt); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_v_format);
__pyx_v_format = __pyx_1;
__pyx_1 = 0;
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":102
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":103
* cdef void notice_h(char *fmt, char*msg):
* format = PyString_FromString(fmt)
* message = PyString_FromString(msg) # <<<<<<<<<<<<<<
* try:
* warn_msg = format % message
*/
- __pyx_1 = PyString_FromString(__pyx_v_msg); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = PyString_FromString(__pyx_v_msg); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_v_message);
__pyx_v_message = __pyx_1;
__pyx_1 = 0;
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":103
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":104
* format = PyString_FromString(fmt)
* message = PyString_FromString(msg)
* try: # <<<<<<<<<<<<<<
@@ -401,14 +395,14 @@
*/
/*try:*/ {
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":104
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":105
* message = PyString_FromString(msg)
* try:
* warn_msg = format % message # <<<<<<<<<<<<<<
* except:
* warn_msg = format
*/
- __pyx_1 = PyNumber_Remainder(__pyx_v_format, __pyx_v_message); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L2;}
+ __pyx_1 = PyNumber_Remainder(__pyx_v_format, __pyx_v_message); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L2;}
Py_DECREF(__pyx_v_warn_msg);
__pyx_v_warn_msg = __pyx_1;
__pyx_1 = 0;
@@ -417,7 +411,7 @@
__pyx_L2:;
Py_XDECREF(__pyx_1); __pyx_1 = 0;
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":105
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":106
* try:
* warn_msg = format % message
* except: # <<<<<<<<<<<<<<
@@ -426,9 +420,9 @@
*/
/*except:*/ {
__Pyx_AddTraceback("_geoslib.notice_h");
- if (__Pyx_GetException(&__pyx_1, &__pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ if (__Pyx_GetException(&__pyx_1, &__pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1;}
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":106
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":107
* warn_msg = format % message
* except:
* warn_msg = format # <<<<<<<<<<<<<<
@@ -445,23 +439,23 @@
}
__pyx_L3:;
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":107
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":108
* except:
* warn_msg = format
* sys.stdout.write('GEOS_NOTICE: %s\n' % warn_msg) # <<<<<<<<<<<<<<
*
* cdef void error_h(char *fmt, char*msg):
*/
- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_sys); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_stdout); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_sys); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_stdout); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_write); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_write); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyNumber_Remainder(__pyx_kp_4, __pyx_v_warn_msg); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1;}
- __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = PyNumber_Remainder(__pyx_kp_2, __pyx_v_warn_msg); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
__pyx_1 = 0;
- __pyx_1 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
Py_DECREF(__pyx_1); __pyx_1 = 0;
@@ -478,7 +472,7 @@
Py_DECREF(__pyx_v_warn_msg);
}
-/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":109
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":110
* sys.stdout.write('GEOS_NOTICE: %s\n' % warn_msg)
*
* cdef void error_h(char *fmt, char*msg): # <<<<<<<<<<<<<<
@@ -490,9 +484,9 @@
static PyObject *__pyx_kp_stderr;
-static PyObject *__pyx_kp_5;
+static PyObject *__pyx_kp_3;
-static char __pyx_k_5[] = "GEOS_ERROR: %s\n";
+static char __pyx_k_3[] = "GEOS_ERROR: %s\n";
static void __pyx_f_8_geoslib_error_h(char *__pyx_v_fmt, char *__pyx_v_msg) {
PyObject *__pyx_v_format;
@@ -505,31 +499,31 @@
__pyx_v_message = Py_None; Py_INCREF(Py_None);
__pyx_v_warn_msg = Py_None; Py_INCREF(Py_None);
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":110
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":111
*
* cdef void error_h(char *fmt, char*msg):
* format = PyString_FromString(fmt) # <<<<<<<<<<<<<<
* message = PyString_FromString(msg)
* try:
*/
- __pyx_1 = PyString_FromString(__pyx_v_fmt); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = PyString_FromString(__pyx_v_fmt); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_v_format);
__pyx_v_format = __pyx_1;
__pyx_1 = 0;
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":111
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":112
* cdef void error_h(char *fmt, char*msg):
* format = PyString_FromString(fmt)
* message = PyString_FromString(msg) # <<<<<<<<<<<<<<
* try:
* warn_msg = format % message
*/
- __pyx_1 = PyString_FromString(__pyx_v_msg); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = PyString_FromString(__pyx_v_msg); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_v_message);
__pyx_v_message = __pyx_1;
__pyx_1 = 0;
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":112
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":113
* format = PyString_FromString(fmt)
* message = PyString_FromString(msg)
* try: # <<<<<<<<<<<<<<
@@ -538,14 +532,14 @@
*/
/*try:*/ {
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":113
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":114
* message = PyString_FromString(msg)
* try:
* warn_msg = format % message # <<<<<<<<<<<<<<
* except:
* warn_msg = format
*/
- __pyx_1 = PyNumber_Remainder(__pyx_v_format, __pyx_v_message); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L2;}
+ __pyx_1 = PyNumber_Remainder(__pyx_v_format, __pyx_v_message); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L2;}
Py_DECREF(__pyx_v_warn_msg);
__pyx_v_warn_msg = __pyx_1;
__pyx_1 = 0;
@@ -554,7 +548,7 @@
__pyx_L2:;
Py_XDECREF(__pyx_1); __pyx_1 = 0;
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":114
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":115
* try:
* warn_msg = format % message
* except: # <<<<<<<<<<<<<<
@@ -563,9 +557,9 @@
*/
/*except:*/ {
__Pyx_AddTraceback("_geoslib.error_h");
- if (__Pyx_GetException(&__pyx_1, &__pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ if (__Pyx_GetException(&__pyx_1, &__pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1;}
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":115
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":116
* warn_msg = format % message
* except:
* warn_msg = format # <<<<<<<<<<<<<<
@@ -582,23 +576,23 @@
}
__pyx_L3:;
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":116
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":117
* except:
* warn_msg = format
* sys.stderr.write('GEOS_ERROR: %s\n' % warn_msg) # <<<<<<<<<<<<<<
*
* # check library version
*/
- __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_sys); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1;}
- __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_stderr); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_sys); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_kp_stderr); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_1); __pyx_1 = 0;
- __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_write); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_write); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyNumber_Remainder(__pyx_kp_5, __pyx_v_warn_msg); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1;}
- __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = PyNumber_Remainder(__pyx_kp_3, __pyx_v_warn_msg); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
__pyx_1 = 0;
- __pyx_1 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = PyObject_Call(__pyx_3, ((PyObject *)__pyx_2), NULL); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
Py_DECREF(__pyx_1); __pyx_1 = 0;
@@ -615,7 +609,7 @@
Py_DECREF(__pyx_v_warn_msg);
}
-/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":119
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":120
*
* # check library version
* cdef geos_version(): # <<<<<<<<<<<<<<
@@ -627,14 +621,14 @@
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":120
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":121
* # check library version
* cdef geos_version():
* return PyString_FromString(GEOSversion()) # <<<<<<<<<<<<<<
* __geos_version__ = geos_version() # module variable.
- * if __geos_version__ != "2.2.3-CAPI-1.1.1":
+ * #if __geos_version__ != "2.2.3-CAPI-1.1.1":
*/
- __pyx_1 = PyString_FromString(GEOSversion()); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = PyString_FromString(GEOSversion()); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
@@ -649,7 +643,7 @@
return __pyx_r;
}
-/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":132
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":133
* cdef public object boundary
*
* def is_valid(self): # <<<<<<<<<<<<<<
@@ -663,7 +657,7 @@
PyObject *__pyx_r;
char __pyx_1;
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":134
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":135
* def is_valid(self):
* cdef char valid
* valid = GEOSisValid(self._geom) # <<<<<<<<<<<<<<
@@ -672,7 +666,7 @@
*/
__pyx_v_valid = GEOSisValid(((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom);
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":135
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":136
* cdef char valid
* valid = GEOSisValid(self._geom)
* if valid: # <<<<<<<<<<<<<<
@@ -682,7 +676,7 @@
__pyx_1 = __pyx_v_valid;
if (__pyx_1) {
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":136
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":137
* valid = GEOSisValid(self._geom)
* if valid:
* return True # <<<<<<<<<<<<<<
@@ -696,7 +690,7 @@
}
/*else*/ {
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":138
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":139
* return True
* else:
* return False # <<<<<<<<<<<<<<
@@ -714,7 +708,7 @@
return __pyx_r;
}
-/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":140
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":141
* return False
*
* def geom_type(self): # <<<<<<<<<<<<<<
@@ -727,14 +721,14 @@
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":141
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":142
*
* def geom_type(self):
* return PyString_FromString(GEOSGeomType(self._geom)) # <<<<<<<<<<<<<<
*
* def within(self, BaseGeometry geom):
*/
- __pyx_1 = PyString_FromString(GEOSGeomType(((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = PyString_FromString(GEOSGeomType(((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
@@ -749,7 +743,7 @@
return __pyx_r;
}
-/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":143
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":144
* return PyString_FromString(GEOSGeomType(self._geom))
*
* def within(self, BaseGeometry geom): # <<<<<<<<<<<<<<
@@ -764,9 +758,9 @@
char __pyx_v_answer;
PyObject *__pyx_r;
char __pyx_1;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_8_geoslib_BaseGeometry, 1, "geom", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_8_geoslib_BaseGeometry, 1, "geom", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1;}
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":146
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":147
* cdef GEOSGeom *g1, *g2
* cdef char answer
* g1 = self._geom # <<<<<<<<<<<<<<
@@ -775,7 +769,7 @@
*/
__pyx_v_g1 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom;
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":147
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":148
* cdef char answer
* g1 = self._geom
* g2 = geom._geom # <<<<<<<<<<<<<<
@@ -784,7 +778,7 @@
*/
__pyx_v_g2 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_geom)->_geom;
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":148
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":149
* g1 = self._geom
* g2 = geom._geom
* answer = GEOSWithin(g1, g2) # <<<<<<<<<<<<<<
@@ -793,7 +787,7 @@
*/
__pyx_v_answer = GEOSWithin(__pyx_v_g1, __pyx_v_g2);
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":149
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":150
* g2 = geom._geom
* answer = GEOSWithin(g1, g2)
* if answer: # <<<<<<<<<<<<<<
@@ -803,7 +797,7 @@
__pyx_1 = __pyx_v_answer;
if (__pyx_1) {
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":150
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":151
* answer = GEOSWithin(g1, g2)
* if answer:
* return True # <<<<<<<<<<<<<<
@@ -817,12 +811,12 @@
}
/*else*/ {
- /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":152
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":153
* return True
* else:
* return False # <<<<<<<<<<<<<<
*
- * def intersects(self, BaseGeometry geom):
+ * def simplify(self, tol):
*/
Py_INCREF(Py_False);
__pyx_r = Py_False;
@@ -839,9 +833,444 @@
return __pyx_r;
}
-/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":154
+/* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":155
* return False
*
+ * def simplify(self, tol): # <<<<<<<<<<<<<<
+ * cdef GEOSGeom *g1, *g3, *gout
+ * cdef double tolerance
+ */
+
+static char __pyx_k_append[] = "append";
+static char __pyx_k_NotImplementedError[] = "NotImplementedError";
+
+static PyObject *__pyx_kp_append;
+static PyObject *__pyx_kp_NotImplementedError;
+
+static PyObject *__pyx_kp_4;
+
+static PyObject *__pyx_builtin_NotImplementedError;
+
+static char __pyx_k_4[] = "intersections of type '%s' not yet implemented";
+
+static PyObject *__pyx_pf_8_geoslib_12BaseGeometry_simplify(PyObject *__pyx_v_self, PyObject *__pyx_v_tol); /*proto*/
+static PyObject *__pyx_pf_8_geoslib_12BaseGeometry_simplify(PyObject *__pyx_v_self, PyObject *__pyx_v_tol) {
+ GEOSGeom *__pyx_v_g1;
+ GEOSGeom *__pyx_v_g3;
+ GEOSGeom *__pyx_v_gout;
+ double __pyx_v_tolerance;
+ int __pyx_v_numgeoms;
+ int __pyx_v_i;
+ int __pyx_v_typeid;
+ PyObject *__pyx_v_b;
+ PyObject *__pyx_v_p;
+ PyObject *__pyx_v_pout;
+ PyObject *__pyx_v_type;
+ PyObject *__pyx_r;
+ double __pyx_1;
+ int __pyx_2;
+ PyObject *__pyx_3 = 0;
+ PyObject *__pyx_4 = 0;
+ __pyx_v_b = Py_None; Py_INCREF(Py_None);
+ __pyx_v_p = Py_None; Py_INCREF(Py_None);
+ __pyx_v_pout = Py_None; Py_INCREF(Py_None);
+ __pyx_v_type = Py_None; Py_INCREF(Py_None);
+
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":159
+ * cdef double tolerance
+ * cdef int numgeoms, i, typeid
+ * tolerance = tol # <<<<<<<<<<<<<<
+ * g1 = self._geom
+ * g3 = GEOSSimplify(g1, tolerance)
+ */
+ __pyx_1 = __pyx_PyFloat_AsDouble(__pyx_v_tol); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_v_tolerance = __pyx_1;
+
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":160
+ * cdef int numgeoms, i, typeid
+ * tolerance = tol
+ * g1 = self._geom # <<<<<<<<<<<<<<
+ * g3 = GEOSSimplify(g1, tolerance)
+ * typeid = GEOSGeomTypeId(g3)
+ */
+ __pyx_v_g1 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom;
+
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":161
+ * tolerance = tol
+ * g1 = self._geom
+ * g3 = GEOSSimplify(g1, tolerance) # <<<<<<<<<<<<<<
+ * typeid = GEOSGeomTypeId(g3)
+ * if typeid == GEOS_POLYGON:
+ */
+ __pyx_v_g3 = GEOSSimplify(__pyx_v_g1, __pyx_v_tolerance);
+
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":162
+ * g1 = self._geom
+ * g3 = GEOSSimplify(g1, tolerance)
+ * typeid = GEOSGeomTypeId(g3) # <<<<<<<<<<<<<<
+ * if typeid == GEOS_POLYGON:
+ * b = _get_coords(g3)
+ */
+ __pyx_v_typeid = GEOSGeomTypeId(__pyx_v_g3);
+
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":163
+ * g3 = GEOSSimplify(g1, tolerance)
+ * typeid = GEOSGeomTypeId(g3)
+ * if typeid == GEOS_POLYGON: # <<<<<<<<<<<<<<
+ * b = _get_coords(g3)
+ * p = Polygon(b)
+ */
+ __pyx_2 = (__pyx_v_typeid == GEOS_POLYGON);
+ if (__pyx_2) {
+
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":164
+ * typeid = GEOSGeomTypeId(g3)
+ * if typeid == GEOS_POLYGON:
+ * b = _get_coords(g3) # <<<<<<<<<<<<<<
+ * p = Polygon(b)
+ * pout = [p]
+ */
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(__pyx_v_b);
+ __pyx_v_b = __pyx_3;
+ __pyx_3 = 0;
+
+ /* "/Volumes/User/jwhitaker/matplotlib/basemap/src/_geoslib.pyx":165
+ * if typeid == GEOS_POLYGON:
+ * b = _get_coords(g3)
+ * ...
[truncated message content] |
|
From: <js...@us...> - 2008-08-08 11:53:02
|
Revision: 6001
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6001&view=rev
Author: jswhit
Date: 2008-08-08 11:52:59 +0000 (Fri, 08 Aug 2008)
Log Message:
-----------
now works with geos version 3.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/README
trunk/toolkits/basemap/setup.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-08-08 01:46:33 UTC (rev 6000)
+++ trunk/toolkits/basemap/Changelog 2008-08-08 11:52:59 UTC (rev 6001)
@@ -1,3 +1,4 @@
+ * now works with geos version 3.
* testgdal example now uses gdal to read topo data from a raster
DEM file and ogr to read state boundaries from a shape file.
* warpimage method can now handle gray-scale images, and
Modified: trunk/toolkits/basemap/README
===================================================================
--- trunk/toolkits/basemap/README 2008-08-08 01:46:33 UTC (rev 6000)
+++ trunk/toolkits/basemap/README 2008-08-08 11:52:59 UTC (rev 6001)
@@ -11,7 +11,7 @@
numpy 1.1 (or higher)
-The GEOS (Geometry Engine - Open Source) library (version 2.2.3).
+The GEOS (Geometry Engine - Open Source) library (version 2.2.3 or higher).
Source code is included in the geos-2.2.3 directory.
setuptools (only if your are using python 2.3)
Modified: trunk/toolkits/basemap/setup.py
===================================================================
--- trunk/toolkits/basemap/setup.py 2008-08-08 01:46:33 UTC (rev 6000)
+++ trunk/toolkits/basemap/setup.py 2008-08-08 11:52:59 UTC (rev 6001)
@@ -52,7 +52,7 @@
if geos_version < '"2.2.3"':
continue
else:
- print 'GEOS lib found in %s' % direc
+ print 'GEOS lib (version %s) found in %s' % (geos_version[1:-1],direc)
GEOS_dir = direc
break
else:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-08 12:15:41
|
Revision: 6004
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6004&view=rev
Author: jswhit
Date: 2008-08-08 12:15:38 +0000 (Fri, 08 Aug 2008)
Log Message:
-----------
add __geos_major_version__ variable for checking geos version.
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
trunk/toolkits/basemap/src/_geoslib.c
trunk/toolkits/basemap/src/_geoslib.pyx
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-08-08 12:09:20 UTC (rev 6003)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-08-08 12:15:38 UTC (rev 6004)
@@ -981,9 +981,11 @@
# create a GEOS geometry object.
poly = Shape(b)
# this is a workaround to avoid
- # GEOS_ERROR: TopologyException: found non-noded intersection between ...
+ # "GEOS_ERROR: TopologyException:
+ # found non-noded intersection between ..."
# with geos 3.0.0
- poly = poly.simplify(1.e-10)[0]
+ if _geoslib.__geos_major_version__ > 2:
+ poly = poly.simplify(1.e-10)[0]
# if geometry instersects map projection
# region, and doesn't have any invalid points, process it.
if goodmask.all() and poly.intersects(boundarypolyxy):
Modified: trunk/toolkits/basemap/src/_geoslib.c
===================================================================
--- trunk/toolkits/basemap/src/_geoslib.c 2008-08-08 12:09:20 UTC (rev 6003)
+++ trunk/toolkits/basemap/src/_geoslib.c 2008-08-08 12:15:38 UTC (rev 6004)
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.9.8 on Fri Aug 8 06:05:03 2008 */
+/* Generated by Cython 0.9.8 on Fri Aug 8 06:11:34 2008 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -228,7 +228,7 @@
/* Type declarations */
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":129
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":131
* initGEOS(notice_h, error_h)
*
* cdef class BaseGeometry: # <<<<<<<<<<<<<<
@@ -243,7 +243,7 @@
PyObject *boundary;
};
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":257
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":259
* return (self.__class__,(self.boundary,))
*
* cdef class Polygon(BaseGeometry): # <<<<<<<<<<<<<<
@@ -255,7 +255,7 @@
struct __pyx_obj_8_geoslib_BaseGeometry __pyx_base;
};
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":313
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":315
* return area
*
* cdef class LineString(BaseGeometry): # <<<<<<<<<<<<<<
@@ -267,7 +267,7 @@
struct __pyx_obj_8_geoslib_BaseGeometry __pyx_base;
};
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":345
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":347
* self.boundary = b
*
* cdef class Point(BaseGeometry): # <<<<<<<<<<<<<<
@@ -314,6 +314,7 @@
static char __pyx_k_numpy[] = "numpy";
static char __pyx_k___version__[] = "__version__";
static char __pyx_k___geos_version__[] = "__geos_version__";
+static char __pyx_k_2[] = "__geos_major_version__";
static PyObject *__pyx_kp_is_valid;
static PyObject *__pyx_kp_geom_type;
@@ -330,6 +331,7 @@
static PyObject *__pyx_kp_numpy;
static PyObject *__pyx_kp___version__;
static PyObject *__pyx_kp___geos_version__;
+static PyObject *__pyx_kp_2;
static PyObject *__pyx_kp_1;
@@ -347,9 +349,9 @@
static PyObject *__pyx_kp_stdout;
static PyObject *__pyx_kp_write;
-static PyObject *__pyx_kp_2;
+static PyObject *__pyx_kp_3;
-static char __pyx_k_2[] = "GEOS_NOTICE: %s\n";
+static char __pyx_k_3[] = "GEOS_NOTICE: %s\n";
static void __pyx_f_8_geoslib_notice_h(char *__pyx_v_fmt, char *__pyx_v_msg) {
PyObject *__pyx_v_format;
@@ -451,7 +453,7 @@
Py_DECREF(__pyx_1); __pyx_1 = 0;
__pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_write); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyNumber_Remainder(__pyx_kp_2, __pyx_v_warn_msg); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = PyNumber_Remainder(__pyx_kp_3, __pyx_v_warn_msg); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1;}
__pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
__pyx_1 = 0;
@@ -484,9 +486,9 @@
static PyObject *__pyx_kp_stderr;
-static PyObject *__pyx_kp_3;
+static PyObject *__pyx_kp_4;
-static char __pyx_k_3[] = "GEOS_ERROR: %s\n";
+static char __pyx_k_4[] = "GEOS_ERROR: %s\n";
static void __pyx_f_8_geoslib_error_h(char *__pyx_v_fmt, char *__pyx_v_msg) {
PyObject *__pyx_v_format;
@@ -588,7 +590,7 @@
Py_DECREF(__pyx_1); __pyx_1 = 0;
__pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_kp_write); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_2); __pyx_2 = 0;
- __pyx_1 = PyNumber_Remainder(__pyx_kp_3, __pyx_v_warn_msg); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = PyNumber_Remainder(__pyx_kp_4, __pyx_v_warn_msg); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1;}
__pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
__pyx_1 = 0;
@@ -626,7 +628,7 @@
* cdef geos_version():
* return PyString_FromString(GEOSversion()) # <<<<<<<<<<<<<<
* __geos_version__ = geos_version() # module variable.
- * #if __geos_version__ != "2.2.3-CAPI-1.1.1":
+ * __geos_major_version__ = GEOS_VERSION_MAJOR
*/
__pyx_1 = PyString_FromString(GEOSversion()); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1;}
__pyx_r = __pyx_1;
@@ -643,7 +645,7 @@
return __pyx_r;
}
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":134
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":136
* cdef public object boundary
*
* def is_valid(self): # <<<<<<<<<<<<<<
@@ -657,7 +659,7 @@
PyObject *__pyx_r;
char __pyx_1;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":136
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":138
* def is_valid(self):
* cdef char valid
* valid = GEOSisValid(self._geom) # <<<<<<<<<<<<<<
@@ -666,7 +668,7 @@
*/
__pyx_v_valid = GEOSisValid(((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":137
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":139
* cdef char valid
* valid = GEOSisValid(self._geom)
* if valid: # <<<<<<<<<<<<<<
@@ -676,7 +678,7 @@
__pyx_1 = __pyx_v_valid;
if (__pyx_1) {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":138
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":140
* valid = GEOSisValid(self._geom)
* if valid:
* return True # <<<<<<<<<<<<<<
@@ -690,7 +692,7 @@
}
/*else*/ {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":140
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":142
* return True
* else:
* return False # <<<<<<<<<<<<<<
@@ -708,7 +710,7 @@
return __pyx_r;
}
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":142
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":144
* return False
*
* def geom_type(self): # <<<<<<<<<<<<<<
@@ -721,14 +723,14 @@
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":143
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":145
*
* def geom_type(self):
* return PyString_FromString(GEOSGeomType(self._geom)) # <<<<<<<<<<<<<<
*
* def within(self, BaseGeometry geom):
*/
- __pyx_1 = PyString_FromString(GEOSGeomType(((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_1 = PyString_FromString(GEOSGeomType(((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1;}
__pyx_r = __pyx_1;
__pyx_1 = 0;
goto __pyx_L0;
@@ -743,7 +745,7 @@
return __pyx_r;
}
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":145
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":147
* return PyString_FromString(GEOSGeomType(self._geom))
*
* def within(self, BaseGeometry geom): # <<<<<<<<<<<<<<
@@ -758,9 +760,9 @@
char __pyx_v_answer;
PyObject *__pyx_r;
char __pyx_1;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_8_geoslib_BaseGeometry, 1, "geom", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_8_geoslib_BaseGeometry, 1, "geom", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1;}
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":148
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":150
* cdef GEOSGeom *g1, *g2
* cdef char answer
* g1 = self._geom # <<<<<<<<<<<<<<
@@ -769,7 +771,7 @@
*/
__pyx_v_g1 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":149
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":151
* cdef char answer
* g1 = self._geom
* g2 = geom._geom # <<<<<<<<<<<<<<
@@ -778,7 +780,7 @@
*/
__pyx_v_g2 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_geom)->_geom;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":150
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":152
* g1 = self._geom
* g2 = geom._geom
* answer = GEOSWithin(g1, g2) # <<<<<<<<<<<<<<
@@ -787,7 +789,7 @@
*/
__pyx_v_answer = GEOSWithin(__pyx_v_g1, __pyx_v_g2);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":151
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":153
* g2 = geom._geom
* answer = GEOSWithin(g1, g2)
* if answer: # <<<<<<<<<<<<<<
@@ -797,7 +799,7 @@
__pyx_1 = __pyx_v_answer;
if (__pyx_1) {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":152
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":154
* answer = GEOSWithin(g1, g2)
* if answer:
* return True # <<<<<<<<<<<<<<
@@ -811,7 +813,7 @@
}
/*else*/ {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":154
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":156
* return True
* else:
* return False # <<<<<<<<<<<<<<
@@ -833,7 +835,7 @@
return __pyx_r;
}
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":156
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":158
* return False
*
* def simplify(self, tol): # <<<<<<<<<<<<<<
@@ -847,11 +849,11 @@
static PyObject *__pyx_kp_append;
static PyObject *__pyx_kp_NotImplementedError;
-static PyObject *__pyx_kp_4;
+static PyObject *__pyx_kp_5;
static PyObject *__pyx_builtin_NotImplementedError;
-static char __pyx_k_4[] = "intersections of type '%s' not yet implemented";
+static char __pyx_k_5[] = "intersections of type '%s' not yet implemented";
static PyObject *__pyx_pf_8_geoslib_12BaseGeometry_simplify(PyObject *__pyx_v_self, PyObject *__pyx_v_tol); /*proto*/
static PyObject *__pyx_pf_8_geoslib_12BaseGeometry_simplify(PyObject *__pyx_v_self, PyObject *__pyx_v_tol) {
@@ -876,7 +878,7 @@
__pyx_v_pout = Py_None; Py_INCREF(Py_None);
__pyx_v_type = Py_None; Py_INCREF(Py_None);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":160
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":162
* cdef double tolerance
* cdef int numgeoms, i, typeid
* g1 = self._geom # <<<<<<<<<<<<<<
@@ -885,7 +887,7 @@
*/
__pyx_v_g1 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":161
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":163
* cdef int numgeoms, i, typeid
* g1 = self._geom
* if GEOS_VERSION_MAJOR > 2: # <<<<<<<<<<<<<<
@@ -895,17 +897,17 @@
__pyx_1 = (GEOS_VERSION_MAJOR > 2);
if (__pyx_1) {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":162
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":164
* g1 = self._geom
* if GEOS_VERSION_MAJOR > 2:
* tolerance = tol # <<<<<<<<<<<<<<
* g3 = GEOSSimplify(g1, tolerance)
* else:
*/
- __pyx_2 = __pyx_PyFloat_AsDouble(__pyx_v_tol); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_2 = __pyx_PyFloat_AsDouble(__pyx_v_tol); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1;}
__pyx_v_tolerance = __pyx_2;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":163
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":165
* if GEOS_VERSION_MAJOR > 2:
* tolerance = tol
* g3 = GEOSSimplify(g1, tolerance) # <<<<<<<<<<<<<<
@@ -917,7 +919,7 @@
}
/*else*/ {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":165
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":167
* g3 = GEOSSimplify(g1, tolerance)
* else:
* g3 = g1 # <<<<<<<<<<<<<<
@@ -928,7 +930,7 @@
}
__pyx_L4:;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":166
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":168
* else:
* g3 = g1
* typeid = GEOSGeomTypeId(g3) # <<<<<<<<<<<<<<
@@ -937,7 +939,7 @@
*/
__pyx_v_typeid = GEOSGeomTypeId(__pyx_v_g3);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":167
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":169
* g3 = g1
* typeid = GEOSGeomTypeId(g3)
* if typeid == GEOS_POLYGON: # <<<<<<<<<<<<<<
@@ -947,42 +949,42 @@
__pyx_1 = (__pyx_v_typeid == GEOS_POLYGON);
if (__pyx_1) {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":168
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":170
* typeid = GEOSGeomTypeId(g3)
* if typeid == GEOS_POLYGON:
* b = _get_coords(g3) # <<<<<<<<<<<<<<
* p = Polygon(b)
* pout = [p]
*/
- __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_v_b);
__pyx_v_b = __pyx_3;
__pyx_3 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":169
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":171
* if typeid == GEOS_POLYGON:
* b = _get_coords(g3)
* p = Polygon(b) # <<<<<<<<<<<<<<
* pout = [p]
* elif typeid == GEOS_LINESTRING:
*/
- __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_INCREF(__pyx_v_b);
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
- __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
Py_DECREF(__pyx_v_p);
__pyx_v_p = __pyx_4;
__pyx_4 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":170
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":172
* b = _get_coords(g3)
* p = Polygon(b)
* pout = [p] # <<<<<<<<<<<<<<
* elif typeid == GEOS_LINESTRING:
* b = _get_coords(g3)
*/
- __pyx_3 = PyList_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyList_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_INCREF(__pyx_v_p);
PyList_SET_ITEM(__pyx_3, 0, __pyx_v_p);
Py_DECREF(__pyx_v_pout);
@@ -991,7 +993,7 @@
goto __pyx_L5;
}
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":171
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":173
* p = Polygon(b)
* pout = [p]
* elif typeid == GEOS_LINESTRING: # <<<<<<<<<<<<<<
@@ -1001,42 +1003,42 @@
__pyx_1 = (__pyx_v_typeid == GEOS_LINESTRING);
if (__pyx_1) {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":172
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":174
* pout = [p]
* elif typeid == GEOS_LINESTRING:
* b = _get_coords(g3) # <<<<<<<<<<<<<<
* p = LineString(b)
* pout = [p]
*/
- __pyx_4 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_v_b);
__pyx_v_b = __pyx_4;
__pyx_4 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":173
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":175
* elif typeid == GEOS_LINESTRING:
* b = _get_coords(g3)
* p = LineString(b) # <<<<<<<<<<<<<<
* pout = [p]
* elif typeid == GEOS_MULTIPOLYGON:
*/
- __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_INCREF(__pyx_v_b);
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
- __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
Py_DECREF(__pyx_v_p);
__pyx_v_p = __pyx_4;
__pyx_4 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":174
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":176
* b = _get_coords(g3)
* p = LineString(b)
* pout = [p] # <<<<<<<<<<<<<<
* elif typeid == GEOS_MULTIPOLYGON:
* numgeoms = GEOSGetNumGeometries(g3)
*/
- __pyx_3 = PyList_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyList_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_INCREF(__pyx_v_p);
PyList_SET_ITEM(__pyx_3, 0, __pyx_v_p);
Py_DECREF(__pyx_v_pout);
@@ -1045,7 +1047,7 @@
goto __pyx_L5;
}
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":175
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":177
* p = LineString(b)
* pout = [p]
* elif typeid == GEOS_MULTIPOLYGON: # <<<<<<<<<<<<<<
@@ -1055,7 +1057,7 @@
__pyx_1 = (__pyx_v_typeid == GEOS_MULTIPOLYGON);
if (__pyx_1) {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":176
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":178
* pout = [p]
* elif typeid == GEOS_MULTIPOLYGON:
* numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
@@ -1064,19 +1066,19 @@
*/
__pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":177
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":179
* elif typeid == GEOS_MULTIPOLYGON:
* numgeoms = GEOSGetNumGeometries(g3)
* pout = [] # <<<<<<<<<<<<<<
* for i from 0 <= i < numgeoms:
* gout = GEOSGetGeometryN(g3, i)
*/
- __pyx_4 = PyList_New(0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = PyList_New(0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_v_pout);
__pyx_v_pout = ((PyObject *)__pyx_4);
__pyx_4 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":178
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":180
* numgeoms = GEOSGetNumGeometries(g3)
* pout = []
* for i from 0 <= i < numgeoms: # <<<<<<<<<<<<<<
@@ -1085,7 +1087,7 @@
*/
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_numgeoms; __pyx_v_i++) {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":179
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":181
* pout = []
* for i from 0 <= i < numgeoms:
* gout = GEOSGetGeometryN(g3, i) # <<<<<<<<<<<<<<
@@ -1094,48 +1096,48 @@
*/
__pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, __pyx_v_i);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":180
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":182
* for i from 0 <= i < numgeoms:
* gout = GEOSGetGeometryN(g3, i)
* b = _get_coords(gout) # <<<<<<<<<<<<<<
* p = Polygon(b)
* pout.append(p)
*/
- __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_v_b);
__pyx_v_b = __pyx_3;
__pyx_3 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":181
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":183
* gout = GEOSGetGeometryN(g3, i)
* b = _get_coords(gout)
* p = Polygon(b) # <<<<<<<<<<<<<<
* pout.append(p)
* elif typeid == GEOS_MULTILINESTRING:
*/
- __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_INCREF(__pyx_v_b);
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_b);
- __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
Py_DECREF(__pyx_v_p);
__pyx_v_p = __pyx_3;
__pyx_3 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":182
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":184
* b = _get_coords(gout)
* p = Polygon(b)
* pout.append(p) # <<<<<<<<<<<<<<
* elif typeid == GEOS_MULTILINESTRING:
* numgeoms = GEOSGetNumGeometries(g3)
*/
- __pyx_4 = __Pyx_PyObject_Append(__pyx_v_pout, __pyx_v_p); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = __Pyx_PyObject_Append(__pyx_v_pout, __pyx_v_p); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_4); __pyx_4 = 0;
}
goto __pyx_L5;
}
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":183
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":185
* p = Polygon(b)
* pout.append(p)
* elif typeid == GEOS_MULTILINESTRING: # <<<<<<<<<<<<<<
@@ -1145,7 +1147,7 @@
__pyx_1 = (__pyx_v_typeid == GEOS_MULTILINESTRING);
if (__pyx_1) {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":184
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":186
* pout.append(p)
* elif typeid == GEOS_MULTILINESTRING:
* numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
@@ -1154,19 +1156,19 @@
*/
__pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":185
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":187
* elif typeid == GEOS_MULTILINESTRING:
* numgeoms = GEOSGetNumGeometries(g3)
* pout = [] # <<<<<<<<<<<<<<
* for i from 0 <= i < numgeoms:
* gout = GEOSGetGeometryN(g3, i)
*/
- __pyx_3 = PyList_New(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyList_New(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_v_pout);
__pyx_v_pout = ((PyObject *)__pyx_3);
__pyx_3 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":186
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":188
* numgeoms = GEOSGetNumGeometries(g3)
* pout = []
* for i from 0 <= i < numgeoms: # <<<<<<<<<<<<<<
@@ -1175,7 +1177,7 @@
*/
for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_numgeoms; __pyx_v_i++) {
- ...
[truncated message content] |
|
From: <js...@us...> - 2008-08-08 12:18:44
|
Revision: 6005
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6005&view=rev
Author: jswhit
Date: 2008-08-08 12:18:41 +0000 (Fri, 08 Aug 2008)
Log Message:
-----------
bump version number.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
trunk/toolkits/basemap/setup.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-08-08 12:15:38 UTC (rev 6004)
+++ trunk/toolkits/basemap/Changelog 2008-08-08 12:18:41 UTC (rev 6005)
@@ -1,3 +1,4 @@
+version 0.99.2 (not yet released)
* now works with geos version 3.
* testgdal example now uses gdal to read topo data from a raster
DEM file and ogr to read state boundaries from a shape file.
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-08-08 12:15:38 UTC (rev 6004)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-08-08 12:18:41 UTC (rev 6005)
@@ -41,7 +41,7 @@
# basemap data files now installed in lib/matplotlib/toolkits/basemap/data
basemap_datadir = os.sep.join([os.path.dirname(__file__), 'data'])
-__version__ = '0.99.1'
+__version__ = '0.99.2'
# supported map projections.
_projnames = {'cyl' : 'Cylindrical Equidistant',
Modified: trunk/toolkits/basemap/setup.py
===================================================================
--- trunk/toolkits/basemap/setup.py 2008-08-08 12:15:38 UTC (rev 6004)
+++ trunk/toolkits/basemap/setup.py 2008-08-08 12:18:41 UTC (rev 6005)
@@ -189,7 +189,7 @@
package_data = {'mpl_toolkits.basemap':pyproj_datafiles+basemap_datafiles}
setup(
name = "basemap",
- version = "0.99.1",
+ version = "0.99.2",
description = "Plot data on map projections with matplotlib",
long_description = """
An add-on toolkit for matplotlib that lets you plot data
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-09 16:18:23
|
Revision: 6013
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6013&view=rev
Author: jswhit
Date: 2008-08-09 16:18:19 +0000 (Sat, 09 Aug 2008)
Log Message:
-----------
simplify treatment of dodgy geometries in GEOS 3
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
trunk/toolkits/basemap/src/_geoslib.c
trunk/toolkits/basemap/src/_geoslib.pyx
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-08-09 14:49:42 UTC (rev 6012)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-08-09 16:18:19 UTC (rev 6013)
@@ -985,7 +985,7 @@
# found non-noded intersection between ..."
# with geos 3.0.0
if _geoslib.__geos_major_version__ > 2:
- poly = poly.simplify(1.e-10)[0]
+ poly = poly.simplify(1.e-10)
# if geometry instersects map projection
# region, and doesn't have any invalid points, process it.
if goodmask.all() and poly.intersects(boundarypolyxy):
Modified: trunk/toolkits/basemap/src/_geoslib.c
===================================================================
--- trunk/toolkits/basemap/src/_geoslib.c 2008-08-09 14:49:42 UTC (rev 6012)
+++ trunk/toolkits/basemap/src/_geoslib.c 2008-08-09 16:18:19 UTC (rev 6013)
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.9.8 on Fri Aug 8 06:11:34 2008 */
+/* Generated by Cython 0.9.8 on Sat Aug 9 10:17:12 2008 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -181,6 +181,8 @@
static void __Pyx_WriteUnraisable(const char *name); /*proto*/
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+
static INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
if (likely(PyList_CheckExact(L))) {
if (PyList_Append(L, x) < 0) return NULL;
@@ -192,8 +194,6 @@
}
}
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
-
static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
static INLINE PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i, int is_unsigned) {
@@ -243,7 +243,7 @@
PyObject *boundary;
};
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":259
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":249
* return (self.__class__,(self.boundary,))
*
* cdef class Polygon(BaseGeometry): # <<<<<<<<<<<<<<
@@ -255,7 +255,7 @@
struct __pyx_obj_8_geoslib_BaseGeometry __pyx_base;
};
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":315
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":305
* return area
*
* cdef class LineString(BaseGeometry): # <<<<<<<<<<<<<<
@@ -267,7 +267,7 @@
struct __pyx_obj_8_geoslib_BaseGeometry __pyx_base;
};
-/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":347
+/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":337
* self.boundary = b
*
* cdef class Point(BaseGeometry): # <<<<<<<<<<<<<<
@@ -843,10 +843,8 @@
* cdef double tolerance
*/
-static char __pyx_k_append[] = "append";
static char __pyx_k_NotImplementedError[] = "NotImplementedError";
-static PyObject *__pyx_kp_append;
static PyObject *__pyx_kp_NotImplementedError;
static PyObject *__pyx_kp_5;
@@ -862,421 +860,302 @@
GEOSGeom *__pyx_v_gout;
double __pyx_v_tolerance;
int __pyx_v_numgeoms;
- int __pyx_v_i;
int __pyx_v_typeid;
PyObject *__pyx_v_b;
PyObject *__pyx_v_p;
- PyObject *__pyx_v_pout;
PyObject *__pyx_v_type;
PyObject *__pyx_r;
- int __pyx_1;
- double __pyx_2;
+ double __pyx_1;
+ int __pyx_2;
PyObject *__pyx_3 = 0;
PyObject *__pyx_4 = 0;
__pyx_v_b = Py_None; Py_INCREF(Py_None);
__pyx_v_p = Py_None; Py_INCREF(Py_None);
- __pyx_v_pout = Py_None; Py_INCREF(Py_None);
__pyx_v_type = Py_None; Py_INCREF(Py_None);
/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":162
* cdef double tolerance
* cdef int numgeoms, i, typeid
* g1 = self._geom # <<<<<<<<<<<<<<
- * if GEOS_VERSION_MAJOR > 2:
- * tolerance = tol
+ * tolerance = tol
+ * g3 = GEOSSimplify(g1,tolerance)
*/
__pyx_v_g1 = ((struct __pyx_obj_8_geoslib_BaseGeometry *)__pyx_v_self)->_geom;
/* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":163
* cdef int numgeoms, i, typeid
* g1 = self._geom
- * if GEOS_VERSION_MAJOR > 2: # <<<<<<<<<<<<<<
- * tolerance = tol
- * g3 = GEOSSimplify(g1, tolerance)
+ * tolerance = tol # <<<<<<<<<<<<<<
+ * g3 = GEOSSimplify(g1,tolerance)
+ * typeid = GEOSGeomTypeId(g3)
*/
- __pyx_1 = (GEOS_VERSION_MAJOR > 2);
- if (__pyx_1) {
+ __pyx_1 = __pyx_PyFloat_AsDouble(__pyx_v_tol); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_v_tolerance = __pyx_1;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":164
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":164
* g1 = self._geom
- * if GEOS_VERSION_MAJOR > 2:
- * tolerance = tol # <<<<<<<<<<<<<<
- * g3 = GEOSSimplify(g1, tolerance)
- * else:
- */
- __pyx_2 = __pyx_PyFloat_AsDouble(__pyx_v_tol); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1;}
- __pyx_v_tolerance = __pyx_2;
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":165
- * if GEOS_VERSION_MAJOR > 2:
- * tolerance = tol
- * g3 = GEOSSimplify(g1, tolerance) # <<<<<<<<<<<<<<
- * else:
- * g3 = g1
- */
- __pyx_v_g3 = GEOSSimplify(__pyx_v_g1, __pyx_v_tolerance);
- goto __pyx_L4;
- }
- /*else*/ {
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":167
- * g3 = GEOSSimplify(g1, tolerance)
- * else:
- * g3 = g1 # <<<<<<<<<<<<<<
+ * tolerance = tol
+ * g3 = GEOSSimplify(g1,tolerance) # <<<<<<<<<<<<<<
* typeid = GEOSGeomTypeId(g3)
* if typeid == GEOS_POLYGON:
*/
- __pyx_v_g3 = __pyx_v_g1;
- }
- __pyx_L4:;
+ __pyx_v_g3 = GEOSSimplify(__pyx_v_g1, __pyx_v_tolerance);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":168
- * else:
- * g3 = g1
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":165
+ * tolerance = tol
+ * g3 = GEOSSimplify(g1,tolerance)
* typeid = GEOSGeomTypeId(g3) # <<<<<<<<<<<<<<
* if typeid == GEOS_POLYGON:
* b = _get_coords(g3)
*/
__pyx_v_typeid = GEOSGeomTypeId(__pyx_v_g3);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":169
- * g3 = g1
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":166
+ * g3 = GEOSSimplify(g1,tolerance)
* typeid = GEOSGeomTypeId(g3)
* if typeid == GEOS_POLYGON: # <<<<<<<<<<<<<<
* b = _get_coords(g3)
* p = Polygon(b)
*/
- __pyx_1 = (__pyx_v_typeid == GEOS_POLYGON);
- if (__pyx_1) {
+ __pyx_2 = (__pyx_v_typeid == GEOS_POLYGON);
+ if (__pyx_2) {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":170
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":167
* typeid = GEOSGeomTypeId(g3)
* if typeid == GEOS_POLYGON:
* b = _get_coords(g3) # <<<<<<<<<<<<<<
* p = Polygon(b)
- * pout = [p]
+ * elif typeid == GEOS_LINESTRING:
*/
- __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_v_b);
__pyx_v_b = __pyx_3;
__pyx_3 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":171
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":168
* if typeid == GEOS_POLYGON:
* b = _get_coords(g3)
* p = Polygon(b) # <<<<<<<<<<<<<<
- * pout = [p]
* elif typeid == GEOS_LINESTRING:
+ * b = _get_coords(g3)
*/
- __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_INCREF(__pyx_v_b);
PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
- __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
Py_DECREF(__pyx_v_p);
__pyx_v_p = __pyx_4;
__pyx_4 = 0;
+ goto __pyx_L4;
+ }
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":172
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":169
* b = _get_coords(g3)
* p = Polygon(b)
- * pout = [p] # <<<<<<<<<<<<<<
- * elif typeid == GEOS_LINESTRING:
- * b = _get_coords(g3)
- */
- __pyx_3 = PyList_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_INCREF(__pyx_v_p);
- PyList_SET_ITEM(__pyx_3, 0, __pyx_v_p);
- Py_DECREF(__pyx_v_pout);
- __pyx_v_pout = ((PyObject *)__pyx_3);
- __pyx_3 = 0;
- goto __pyx_L5;
- }
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":173
- * p = Polygon(b)
- * pout = [p]
* elif typeid == GEOS_LINESTRING: # <<<<<<<<<<<<<<
* b = _get_coords(g3)
* p = LineString(b)
*/
- __pyx_1 = (__pyx_v_typeid == GEOS_LINESTRING);
- if (__pyx_1) {
+ __pyx_2 = (__pyx_v_typeid == GEOS_LINESTRING);
+ if (__pyx_2) {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":174
- * pout = [p]
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":170
+ * p = Polygon(b)
* elif typeid == GEOS_LINESTRING:
* b = _get_coords(g3) # <<<<<<<<<<<<<<
* p = LineString(b)
- * pout = [p]
+ * # for multi-geom structures, just return first one.
*/
- __pyx_4 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_g3); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_v_b);
- __pyx_v_b = __pyx_4;
- __pyx_4 = 0;
+ __pyx_v_b = __pyx_3;
+ __pyx_3 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":175
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":171
* elif typeid == GEOS_LINESTRING:
* b = _get_coords(g3)
* p = LineString(b) # <<<<<<<<<<<<<<
- * pout = [p]
+ * # for multi-geom structures, just return first one.
* elif typeid == GEOS_MULTIPOLYGON:
*/
- __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_INCREF(__pyx_v_b);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
- __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_b);
+ __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
Py_DECREF(__pyx_v_p);
- __pyx_v_p = __pyx_4;
- __pyx_4 = 0;
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":176
- * b = _get_coords(g3)
- * p = LineString(b)
- * pout = [p] # <<<<<<<<<<<<<<
- * elif typeid == GEOS_MULTIPOLYGON:
- * numgeoms = GEOSGetNumGeometries(g3)
- */
- __pyx_3 = PyList_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_INCREF(__pyx_v_p);
- PyList_SET_ITEM(__pyx_3, 0, __pyx_v_p);
- Py_DECREF(__pyx_v_pout);
- __pyx_v_pout = ((PyObject *)__pyx_3);
+ __pyx_v_p = __pyx_3;
__pyx_3 = 0;
- goto __pyx_L5;
+ goto __pyx_L4;
}
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":177
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":173
* p = LineString(b)
- * pout = [p]
+ * # for multi-geom structures, just return first one.
* elif typeid == GEOS_MULTIPOLYGON: # <<<<<<<<<<<<<<
* numgeoms = GEOSGetNumGeometries(g3)
- * pout = []
+ * gout = GEOSGetGeometryN(g3, 0)
*/
- __pyx_1 = (__pyx_v_typeid == GEOS_MULTIPOLYGON);
- if (__pyx_1) {
+ __pyx_2 = (__pyx_v_typeid == GEOS_MULTIPOLYGON);
+ if (__pyx_2) {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":178
- * pout = [p]
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":174
+ * # for multi-geom structures, just return first one.
* elif typeid == GEOS_MULTIPOLYGON:
* numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
- * pout = []
- * for i from 0 <= i < numgeoms:
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout)
*/
__pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":179
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":175
* elif typeid == GEOS_MULTIPOLYGON:
* numgeoms = GEOSGetNumGeometries(g3)
- * pout = [] # <<<<<<<<<<<<<<
- * for i from 0 <= i < numgeoms:
- * gout = GEOSGetGeometryN(g3, i)
+ * gout = GEOSGetGeometryN(g3, 0) # <<<<<<<<<<<<<<
+ * b = _get_coords(gout)
+ * p = Polygon(b)
*/
- __pyx_4 = PyList_New(0); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_v_pout);
- __pyx_v_pout = ((PyObject *)__pyx_4);
- __pyx_4 = 0;
+ __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, 0);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":180
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":176
* numgeoms = GEOSGetNumGeometries(g3)
- * pout = []
- * for i from 0 <= i < numgeoms: # <<<<<<<<<<<<<<
- * gout = GEOSGetGeometryN(g3, i)
- * b = _get_coords(gout)
- */
- for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_numgeoms; __pyx_v_i++) {
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":181
- * pout = []
- * for i from 0 <= i < numgeoms:
- * gout = GEOSGetGeometryN(g3, i) # <<<<<<<<<<<<<<
- * b = _get_coords(gout)
- * p = Polygon(b)
- */
- __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, __pyx_v_i);
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":182
- * for i from 0 <= i < numgeoms:
- * gout = GEOSGetGeometryN(g3, i)
- * b = _get_coords(gout) # <<<<<<<<<<<<<<
- * p = Polygon(b)
- * pout.append(p)
- */
- __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_v_b);
- __pyx_v_b = __pyx_3;
- __pyx_3 = 0;
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":183
- * gout = GEOSGetGeometryN(g3, i)
- * b = _get_coords(gout)
- * p = Polygon(b) # <<<<<<<<<<<<<<
- * pout.append(p)
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout) # <<<<<<<<<<<<<<
+ * p = Polygon(b)
* elif typeid == GEOS_MULTILINESTRING:
*/
- __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_INCREF(__pyx_v_b);
- PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_b);
- __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
- Py_DECREF(__pyx_v_p);
- __pyx_v_p = __pyx_3;
- __pyx_3 = 0;
+ __pyx_4 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(__pyx_v_b);
+ __pyx_v_b = __pyx_4;
+ __pyx_4 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":184
- * b = _get_coords(gout)
- * p = Polygon(b)
- * pout.append(p) # <<<<<<<<<<<<<<
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":177
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout)
+ * p = Polygon(b) # <<<<<<<<<<<<<<
* elif typeid == GEOS_MULTILINESTRING:
* numgeoms = GEOSGetNumGeometries(g3)
*/
- __pyx_4 = __Pyx_PyObject_Append(__pyx_v_pout, __pyx_v_p); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_4); __pyx_4 = 0;
- }
- goto __pyx_L5;
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_INCREF(__pyx_v_b);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
+ __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_Polygon), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
+ Py_DECREF(__pyx_v_p);
+ __pyx_v_p = __pyx_4;
+ __pyx_4 = 0;
+ goto __pyx_L4;
}
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":185
- * p = Polygon(b)
- * pout.append(p)
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":178
+ * b = _get_coords(gout)
+ * p = Polygon(b)
* elif typeid == GEOS_MULTILINESTRING: # <<<<<<<<<<<<<<
* numgeoms = GEOSGetNumGeometries(g3)
- * pout = []
+ * gout = GEOSGetGeometryN(g3, 0)
*/
- __pyx_1 = (__pyx_v_typeid == GEOS_MULTILINESTRING);
- if (__pyx_1) {
+ __pyx_2 = (__pyx_v_typeid == GEOS_MULTILINESTRING);
+ if (__pyx_2) {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":186
- * pout.append(p)
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":179
+ * p = Polygon(b)
* elif typeid == GEOS_MULTILINESTRING:
* numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<<
- * pout = []
- * for i from 0 <= i < numgeoms:
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout)
*/
__pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":187
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":180
* elif typeid == GEOS_MULTILINESTRING:
* numgeoms = GEOSGetNumGeometries(g3)
- * pout = [] # <<<<<<<<<<<<<<
- * for i from 0 <= i < numgeoms:
- * gout = GEOSGetGeometryN(g3, i)
+ * gout = GEOSGetGeometryN(g3, 0) # <<<<<<<<<<<<<<
+ * b = _get_coords(gout)
+ * p = LineString(b)
*/
- __pyx_3 = PyList_New(0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_v_pout);
- __pyx_v_pout = ((PyObject *)__pyx_3);
- __pyx_3 = 0;
+ __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, 0);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":188
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":181
* numgeoms = GEOSGetNumGeometries(g3)
- * pout = []
- * for i from 0 <= i < numgeoms: # <<<<<<<<<<<<<<
- * gout = GEOSGetGeometryN(g3, i)
- * b = _get_coords(gout)
- */
- for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_numgeoms; __pyx_v_i++) {
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":189
- * pout = []
- * for i from 0 <= i < numgeoms:
- * gout = GEOSGetGeometryN(g3, i) # <<<<<<<<<<<<<<
- * b = _get_coords(gout)
- * p = LineString(b)
- */
- __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3, __pyx_v_i);
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":190
- * for i from 0 <= i < numgeoms:
- * gout = GEOSGetGeometryN(g3, i)
- * b = _get_coords(gout) # <<<<<<<<<<<<<<
- * p = LineString(b)
- * pout.append(p)
- */
- __pyx_4 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_v_b);
- __pyx_v_b = __pyx_4;
- __pyx_4 = 0;
-
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":191
- * gout = GEOSGetGeometryN(g3, i)
- * b = _get_coords(gout)
- * p = LineString(b) # <<<<<<<<<<<<<<
- * pout.append(p)
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout) # <<<<<<<<<<<<<<
+ * p = LineString(b)
* else:
*/
- __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_INCREF(__pyx_v_b);
- PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_b);
- __pyx_4 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_3), NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(((PyObject *)__pyx_3)); __pyx_3 = 0;
- Py_DECREF(__pyx_v_p);
- __pyx_v_p = __pyx_4;
- __pyx_4 = 0;
+ __pyx_3 = __pyx_f_8_geoslib__get_coords(__pyx_v_gout); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(__pyx_v_b);
+ __pyx_v_b = __pyx_3;
+ __pyx_3 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":192
- * b = _get_coords(gout)
- * p = LineString(b)
- * pout.append(p) # <<<<<<<<<<<<<<
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":182
+ * gout = GEOSGetGeometryN(g3, 0)
+ * b = _get_coords(gout)
+ * p = LineString(b) # <<<<<<<<<<<<<<
* else:
* type = PyString_FromString(GEOSGeomType(g3))
*/
- __pyx_3 = __Pyx_PyObject_Append(__pyx_v_pout, __pyx_v_p); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1;}
- Py_DECREF(__pyx_3); __pyx_3 = 0;
- }
- goto __pyx_L5;
+ __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_INCREF(__pyx_v_b);
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_b);
+ __pyx_3 = PyObject_Call(((PyObject*)__pyx_ptype_8_geoslib_LineString), ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
+ Py_DECREF(__pyx_v_p);
+ __pyx_v_p = __pyx_3;
+ __pyx_3 = 0;
+ goto __pyx_L4;
}
/*else*/ {
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":194
- * pout.append(p)
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":184
+ * p = LineString(b)
* else:
* type = PyString_FromString(GEOSGeomType(g3)) # <<<<<<<<<<<<<<
* raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
* GEOSGeom_destroy(g3)
*/
- __pyx_4 = PyString_FromString(GEOSGeomType(__pyx_v_g3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = PyString_FromString(GEOSGeomType(__pyx_v_g3)); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(__pyx_v_type);
__pyx_v_type = __pyx_4;
__pyx_4 = 0;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":195
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":185
* else:
* type = PyString_FromString(GEOSGeomType(g3))
* raise NotImplementedError("intersections of type '%s' not yet implemented" % (type)) # <<<<<<<<<<<<<<
* GEOSGeom_destroy(g3)
- * return pout
+ * return p
*/
- __pyx_3 = PyNumber_Remainder(__pyx_kp_5, __pyx_v_type); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1;}
- __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyNumber_Remainder(__pyx_kp_5, __pyx_v_type); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
- __pyx_3 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ __pyx_3 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_4), NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
Py_DECREF(((PyObject *)__pyx_4)); __pyx_4 = 0;
__Pyx_Raise(__pyx_3, 0, 0);
Py_DECREF(__pyx_3); __pyx_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1;}
}
- __pyx_L5:;
+ __pyx_L4:;
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":196
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":186
* type = PyString_FromString(GEOSGeomType(g3))
* raise NotImplementedError("intersections of type '%s' not yet implemented" % (type))
* GEOSGeom_destroy(g3) # <<<<<<<<<<<<<<
- * return pout
+ * return p
*
*/
GEOSGeom_destroy(__pyx_v_g3);
- /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":197
+ /* "/Users/jsw/python/matplotlib/trunk/toolkits/basemap/src/_geoslib.pyx":187
* raise NotImplementedError("intersections of...
[truncated message content] |
|
From: <js...@us...> - 2008-08-16 22:48:21
|
Revision: 6037
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6037&view=rev
Author: jswhit
Date: 2008-08-16 22:48:18 +0000 (Sat, 16 Aug 2008)
Log Message:
-----------
added install instructions to new docs
Modified Paths:
--------------
trunk/toolkits/basemap/README
trunk/toolkits/basemap/doc/users/index.rst
Added Paths:
-----------
trunk/toolkits/basemap/doc/users/installing.rst
Modified: trunk/toolkits/basemap/README
===================================================================
--- trunk/toolkits/basemap/README 2008-08-14 13:38:01 UTC (rev 6036)
+++ trunk/toolkits/basemap/README 2008-08-16 22:48:18 UTC (rev 6037)
@@ -14,8 +14,6 @@
The GEOS (Geometry Engine - Open Source) library (version 2.2.3 or higher).
Source code is included in the geos-2.2.3 directory.
-setuptools (only if your are using python 2.3)
-
PIL (http://pythonware.com/products/pil) is optional (only
needed for Basemap warpimage and bluemarble methods).
@@ -71,11 +69,8 @@
0) Install pre-requisite python modules numpy and matplotlib.
-1) Then download basemap-X.Y.Z.tar.gz (approx 32 mb) from
+1) Then download basemap-X.Y.Z.tar.gz (approx 100 mb) from
the sourceforge download site, unpack and cd to basemap-X.Y.Z.
-If you want the full-resolution coastline dataset (useful if you
-will be making maps of very small regions), get
-basemap-fullresdata-X.Y.Z.tar.gz (approx. 100 mb).
2) Install the GEOS library. If you already have it on your
system, just set the environment variable GEOS_DIR to point to the location
Modified: trunk/toolkits/basemap/doc/users/index.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/index.rst 2008-08-14 13:38:01 UTC (rev 6036)
+++ trunk/toolkits/basemap/doc/users/index.rst 2008-08-16 22:48:18 UTC (rev 6037)
@@ -10,6 +10,7 @@
.. toctree::
intro.rst
+ installing.rst
mapsetup.rst
geography.rst
graticule.rst
Added: trunk/toolkits/basemap/doc/users/installing.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/installing.rst (rev 0)
+++ trunk/toolkits/basemap/doc/users/installing.rst 2008-08-16 22:48:18 UTC (rev 6037)
@@ -0,0 +1,99 @@
+.. _installing:
+
+**********
+Installing
+**********
+
+Dependencies
+============
+
+**Requirements**
+
+These are external packages which you will need to install before
+installing basemap.
+
+
+matplotlib 0.98 (or later, `download <http://sf.net/projects/matplotlib/>`__)
+
+python 2.4 (or later but not python3)
+ matplotlib requires python 2.4 or later (`download <http://www.python.org/download/>`__)
+
+numpy 1.1 (or later)
+ array support for python (`download <http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103>`__)
+
+**Required libraries that ship with basemap**
+
+`GEOS <http://trac.osgeo.org/geos/>`__ (Geometry Engine - Open Source) library 2.2.3 or later (2.2.3 recommended).
+ Source code is included in the geos-2.2.3 directory.
+ When building from source, must be built and installed separately
+ from basemap (see build instructions below).
+ Included in Windows binary installers.
+
+`PROJ4 <http://trac.osgeo.org/proj/>`__ Cartographic Projections Library.
+ Patched version automatically built into basemap.
+
+`pyshapelib <http://intevation.de/pipermail/thuban-devel/2004-May/000184.html>`__
+ C library with python interface for reading ESRI shapefiles (automatically
+ built and installed with basemap).
+
+`pupnyere <http://pypi.python.org/pypi/pupynere/>`__
+ Pure python `netCDF <http://www.unidata.ucar.edu/software/netcdf/>`__
+ interface automatically installed with basemap.
+
+`pydap <http://code.google.com/p/pydap>`__
+ Pure python `OPeNDAP <http://opendap.org>`__ implementation.
+ If not present, client (not server) will be installed with basemap.
+
+`httplib2 <http://code.google.com/p/httplib2>`__ (needed for pydap client).
+ If not present, will be installed with basemap.
+
+
+**Optional libraries**
+
+PIL
+ Python Imaging Library (`download <http://www.pythonware.com/products/pil/>`__),
+ only needed for :func:`~mpl_toolkits.basemap.Basemap.bluemarble` and :func:`~mpl_toolkits.basemap.Basemap.warpimage` instance methods.
+
+Installation
+============
+
+Windows binary installers are available for
+`download <http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=142792/&abmode=1>`__.
+
+For other platforms, download the source release and follow these steps:
+
+
+* Install pre-requisite requirements.
+
+* Untar the basemap version X.Y.Z source tar.gz file, and
+ and cd to the basemap-X.Y.Z directory.
+
+* Install the GEOS library. If you already have it on your
+ system, just set the environment variable GEOS_DIR to point to the location
+ of libgeos_c and geos_c.h (if libgeos_c is in /usr/local/lib and
+ geos_c.h is in /usr/local/include, set GEOS_DIR to /usr/local).
+ Then go to next step. If you don't have it, you can build it from
+ the source code included with basemap by following these steps::
+
+ cd geos-2.2.3
+ export GEOS_DIR=<where you want the libs and headers to go>
+ # A reasonable choice on a Unix-like system is /usr/local, or
+ # if you don't have permission to write there, your home directory.
+ ./configure --prefix=$GEOS_DIR
+ make; make install
+
+* cd back to the top level basemap directory (basemap-X.Y.Z) and
+ run the usual ``python setup.py install``. Check your installation
+ by running ``from mpl_toolkits.basemap import Basemap`` at the python
+ prompt.
+
+ Basemap includes two auxilliary packages, pydap and httplib2.
+ By default, setup.py checks to
+ see if these are already installed, and if so does not try to overwrite
+ them. If you get import errors related to either of these two packages,
+ edit setup.cfg and set pydap and/or httplib2 to True to force
+ installation of the included versions.
+
+* To test, cd to the examples directory and run ``python simpletest.py``.
+ To run all the examples (except those that have extra dependencies
+ or require an internet connection), execute ``python run_all.py``.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-17 22:18:00
|
Revision: 6038
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6038&view=rev
Author: jswhit
Date: 2008-08-17 22:17:56 +0000 (Sun, 17 Aug 2008)
Log Message:
-----------
added cubed_sphere.py example
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/MANIFEST.in
trunk/toolkits/basemap/examples/README
Added Paths:
-----------
trunk/toolkits/basemap/examples/cubed_sphere.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-08-16 22:48:18 UTC (rev 6037)
+++ trunk/toolkits/basemap/Changelog 2008-08-17 22:17:56 UTC (rev 6038)
@@ -1,4 +1,5 @@
version 0.99.2 (not yet released)
+ * added cubed_sphere example.
* updated NetCDFFile to use pupynere 1.0.2 (now can write as well
as read!).
* now works with geos version 3.
Modified: trunk/toolkits/basemap/MANIFEST.in
===================================================================
--- trunk/toolkits/basemap/MANIFEST.in 2008-08-16 22:48:18 UTC (rev 6037)
+++ trunk/toolkits/basemap/MANIFEST.in 2008-08-17 22:17:56 UTC (rev 6038)
@@ -11,6 +11,7 @@
include setup.cfg
include setupegg.py
include src/*
+include examples/cubed_sphere.py
include examples/simpletest.py
include examples/hires.py
include examples/simpletest_oo.py
Modified: trunk/toolkits/basemap/examples/README
===================================================================
--- trunk/toolkits/basemap/examples/README 2008-08-16 22:48:18 UTC (rev 6037)
+++ trunk/toolkits/basemap/examples/README 2008-08-17 22:17:56 UTC (rev 6038)
@@ -111,6 +111,9 @@
plotprecip.py use nonlinear precip colormap included with basemap
to make a rainfall plot.
+cubed_sphere.py - plot a "cubed globe" suitable for cutting and folding,
+a la http://www.progonos.com/furuti/MapProj/Normal/ProjPoly/Foldout/Cube/cube.html.
+
run_all.py is a driver script that runs all the examples except fcstmaps.py,
testgdal.py, geos_demo_2.py, warpimage.py, and pnganim.py (which
rely on external dependencies and/or an internet connection).
Added: trunk/toolkits/basemap/examples/cubed_sphere.py
===================================================================
--- trunk/toolkits/basemap/examples/cubed_sphere.py (rev 0)
+++ trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-17 22:17:56 UTC (rev 6038)
@@ -0,0 +1,30 @@
+from mpl_toolkits.basemap import Basemap
+import matplotlib.pyplot as plt
+import numpy as np
+# 'cubed sphere'
+# inscribe the sphere in a cube, then separately project each cube
+# face with gnomonic projection.
+# http://www.progonos.com/furuti/MapProj/Normal/ProjPoly/Foldout/Cube/cube.html
+# suitable for cutting and folding.
+fig = plt.figure(figsize=(8,6))
+fig.subplots_adjust(bottom=0, left=0, right=1, top=1, wspace=0, hspace=0)
+rsphere = 6370997.
+width = 2.*rsphere; height=width
+npanel=0
+for lat_0 in [90,0,-90]:
+ for ncol in range(0,4):
+ npanel = npanel + 1
+ if lat_0 != 0 and ncol != 1: continue
+ ax=fig.add_subplot(3,4,npanel)
+ ax.set_frame_on(False)
+ lon_0=225 + 90*(ncol+1) - 45
+ m = Basemap(width=width,height=height,resolution=None,\
+ projection='gnom',lon_0=lon_0,lat_0=lat_0,\
+ rsphere=rsphere)
+ m.bluemarble()
+ m.drawparallels(np.arange(-90,91,10),color='0.5')
+ m.drawmeridians(np.arange(0,360,10),color='0.5')
+fig.text(0.625,0.75,\
+ 'World Map on a Cube\n Gnomonic Projection',\
+ fontsize=14)
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-09-11 19:30:44
|
Revision: 6084
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6084&view=rev
Author: jswhit
Date: 2008-09-11 19:30:39 +0000 (Thu, 11 Sep 2008)
Log Message:
-----------
patches from David Huard
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-09-11 18:47:29 UTC (rev 6083)
+++ trunk/toolkits/basemap/Changelog 2008-09-11 19:30:39 UTC (rev 6084)
@@ -1,4 +1,7 @@
version 0.99.2 (not yet released)
+ * bugfix patch for rotate_vector from David Huard. David
+ also contributed the beginnings of a test suite.
+ * _geoslib.so now installed in mpl_toolkits.basemap.
* make sure scatter method sets pyplot color mappable.
* added cubed_sphere example.
* updated NetCDFFile to use pupynere 1.0.2 (now can write as well
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-09-11 18:47:29 UTC (rev 6083)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-09-11 19:30:39 UTC (rev 6084)
@@ -2449,25 +2449,41 @@
vin = vin.filled(1)
else:
masked = False
+
+ # Map the (lon, lat) vector in the complex plane.
uvc = uin + 1j*vin
uvmag = np.abs(uvc)
- delta = 0.1 # increment in longitude
- dlon = delta*uin/uvmag
- dlat = delta*(vin/uvmag)*np.cos(lats*np.pi/180.0)
- farnorth = lats+dlat >= 90.0
+ theta = np.angle(uvc)
+
+ # Define a displacement (dlon, dlat) that moves all
+ # positions (lons, lats) a small distance in the
+ # direction of the original vector.
+ dc = 1E-5 * np.exp(theta*1j)
+ dlat = dc.imag * np.cos(np.radians(lats))
+ dlon = dc.real
+
+ # Deal with displacements that overshoot the North or South Pole.
+ farnorth = np.abs(lats+dlat) >= 90.0
somenorth = farnorth.any()
if somenorth:
dlon[farnorth] *= -1.0
dlat[farnorth] *= -1.0
+
+ # Add displacement to original location and find the native coordinates.
lon1 = lons + dlon
lat1 = lats + dlat
xn, yn = self(lon1, lat1)
+
+ # Determine the angle of the displacement in the native coordinates.
vecangle = np.arctan2(yn-y, xn-x)
if somenorth:
vecangle[farnorth] += np.pi
+
+ # Compute the x-y components of the original vector.
uvcout = uvmag * np.exp(1j*vecangle)
uout = uvcout.real
vout = uvcout.imag
+
if masked:
uout = ma.array(uout, mask=mask)
vout = ma.array(vout, mask=mask)
@@ -3793,3 +3809,54 @@
"""
cdftime = netcdftime.utime(units,calendar=calendar)
return cdftime.date2num(dates)
+
+
+
+# beginnings of a test suite.
+
+from numpy.testing import NumpyTestCase,assert_almost_equal
+class TestRotateVector(NumpyTestCase):
+ def make_array(self):
+ lat = np.array([0, 45, 75, 90])
+ lon = np.array([0,90,180,270])
+ u = np.ones((len(lat), len(lon)))
+ v = np.zeros((len(lat), len(lon)))
+ return u,v,lat,lon
+
+ def test_cylindrical(self):
+ # Cylindrical case
+ B = Basemap()
+ u,v,lat,lon=self.make_array()
+ ru, rv = B.rotate_vector(u,v, lon, lat)
+
+ # Check that the vectors are identical.
+ assert_almost_equal(ru, u)
+ assert_almost_equal(rv, v)
+
+ def test_nan(self):
+ B = Basemap()
+ u,v,lat,lon=self.make_array()
+ # Set one element to 0, so that the vector magnitude is 0.
+ u[1,1] = 0.
+ ru, rv = B.rotate_vector(u,v, lon, lat)
+ assert not np.isnan(ru).any()
+ assert_almost_equal(u, ru)
+ assert_almost_equal(v, rv)
+
+ def test_npstere(self):
+ # NP Stereographic case
+ B=Basemap(projection='npstere', boundinglat=50., lon_0=0.)
+ u,v,lat,lon=self.make_array()
+ v = np.ones((len(lat), len(lon)))
+
+ ru, rv = B.rotate_vector(u,v, lon, lat)
+
+ assert_almost_equal(ru[2, :],[1,-1,-1,1], 6)
+ assert_almost_equal(rv[2, :],[1,1,-1,-1], 6)
+
+def test():
+ import unittest
+ suite = unittest.makeSuite(TestRotateVector,'test')
+ runner = unittest.TextTestRunner()
+ runner.run(suite)
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-09-27 17:36:38
|
Revision: 6124
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6124&view=rev
Author: jswhit
Date: 2008-09-27 17:36:35 +0000 (Sat, 27 Sep 2008)
Log Message:
-----------
fix warpimage/bluemarble methods for 'cyl','robin','moll' and 'sinu' projections.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-09-26 21:52:34 UTC (rev 6123)
+++ trunk/toolkits/basemap/Changelog 2008-09-27 17:36:35 UTC (rev 6124)
@@ -1,4 +1,6 @@
version 0.99.2 (not yet released)
+ * fix warpimage and bluemarble methods for projection = 'cyl',
+ 'robin', 'moll' and 'sinu'.
* bugfix patch for rotate_vector from David Huard. David
also contributed the beginnings of a test suite.
* _geoslib.so now installed in mpl_toolkits.basemap.
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-09-26 21:52:34 UTC (rev 6123)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-09-27 17:36:35 UTC (rev 6124)
@@ -3210,15 +3210,22 @@
self._bm_lons = np.arange(-180.+0.5*delta,180.,delta)
self._bm_lats = np.arange(-90.+0.5*delta,90.,delta)
- if self.projection != 'cyl':
+ bmproj = self.projection == 'cyl' and \
+ self.llcrnrlon == -180 and self.urcrnrlon == 180
+ if not bmproj:
if newfile or not hasattr(self,'_bm_rgba_warped'):
# transform to nx x ny regularly spaced native
# projection grid.
# nx and ny chosen to have roughly the
# same horizontal res as original image.
- dx = 2.*np.pi*self.rmajor/float(nlons)
- nx = int((self.xmax-self.xmin)/dx)+1
- ny = int((self.ymax-self.ymin)/dx)+1
+ if self.projection != 'cyl':
+ dx = 2.*np.pi*self.rmajor/float(nlons)
+ nx = int((self.xmax-self.xmin)/dx)+1
+ ny = int((self.ymax-self.ymin)/dx)+1
+ else:
+ dx = 360./float(nlons)
+ nx = int((self.urcrnrlon-self.llcrnrlon)/dx)+1
+ ny = int((self.urcrnrlat-self.llcrnrlat)/dx)+1
self._bm_rgba_warped = np.ones((ny,nx,4),np.float64)
# interpolate rgba values from geographic coords (proj='cyl')
# to map projection coords.
@@ -3231,7 +3238,7 @@
# for ortho,geos mask pixels outside projection limb.
if self.projection in ['geos','ortho']:
lonsr,latsr = self(x,y,inverse=True)
- mask = ma.zeros((nx,ny,4),np.int8)
+ mask = ma.zeros((ny,nx,4),np.int8)
mask[:,:,0] = np.logical_or(lonsr>1.e20,latsr>1.e30)
for k in range(1,4):
mask[:,:,k] = mask[:,:,0]
@@ -3239,6 +3246,28 @@
ma.masked_array(self._bm_rgba_warped,mask=mask)
# make points outside projection limb transparent.
self._bm_rgba_warped = self._bm_rgba_warped.filled(0.)
+ # treat mollweide, robinson and sinusoidal.
+ elif self.projection in ['moll','robin','sinu']:
+ lonsr,latsr = self(x,y,inverse=True)
+ mask = ma.zeros((ny,nx,4),np.int8)
+ lon_0 = self.projparams['lon_0']
+ lonright = lon_0+180.
+ lonleft = lon_0-180.
+ x1 = np.array(ny*[0.5*(self.xmax + self.xmin)],np.float)
+ y1 = np.linspace(self.ymin, self.ymax, ny)
+ lons1, lats1 = self(x1,y1,inverse=True)
+ lats1 = np.where(lats1 < -89.999999, -89.999999, lats1)
+ lats1 = np.where(lats1 > 89.999999, 89.999999, lats1)
+ for j,lat in enumerate(lats1):
+ xmax,ymax = self(lonright,lat)
+ xmin,ymin = self(lonleft,lat)
+ mask[j,:,0] = np.logical_or(x[j,:]>xmax,x[j,:]<xmin)
+ for k in range(1,4):
+ mask[:,:,k] = mask[:,:,0]
+ self._bm_rgba_warped = \
+ ma.masked_array(self._bm_rgba_warped,mask=mask)
+ # make points outside projection limb transparent.
+ self._bm_rgba_warped = self._bm_rgba_warped.filled(0.)
# plot warped rgba image.
im = self.imshow(self._bm_rgba_warped,ax=ax)
else:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-09-30 17:29:25
|
Revision: 6136
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6136&view=rev
Author: jswhit
Date: 2008-09-30 17:29:03 +0000 (Tue, 30 Sep 2008)
Log Message:
-----------
added two new projections ('mbtfpq' and 'gall')
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/examples/plot_tissot.py
trunk/toolkits/basemap/examples/test.py
trunk/toolkits/basemap/examples/warpimage.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-09-30 11:18:10 UTC (rev 6135)
+++ trunk/toolkits/basemap/Changelog 2008-09-30 17:29:03 UTC (rev 6136)
@@ -1,4 +1,7 @@
version 0.99.2 (not yet released)
+ * Added McBryde-Thomas Flat Polar Quartic (projection =
+ 'mbtfpq') and Gall Stereographic Cylindrical (projection =
+ 'gall').
* fix warpimage and bluemarble methods for projection = 'cyl',
'robin', 'moll' and 'sinu'.
* bugfix patch for rotate_vector from David Huard. David
Modified: trunk/toolkits/basemap/examples/plot_tissot.py
===================================================================
--- trunk/toolkits/basemap/examples/plot_tissot.py 2008-09-30 11:18:10 UTC (rev 6135)
+++ trunk/toolkits/basemap/examples/plot_tissot.py 2008-09-30 17:29:03 UTC (rev 6136)
@@ -25,8 +25,9 @@
m5 = Basemap(lon_0=270,lat_0=90,boundinglat=10,projection='nplaea')
m6 = Basemap(lon_0=0,projection='moll')
m7 = Basemap(lon_0=0,projection='robin')
+m8 = Basemap(lon_0=0,projection='mbtfpq')
-for m in [m1,m2,m3,m4,m5,m6,m7]:
+for m in [m1,m2,m3,m4,m5,m6,m7,m8]:
# make a new figure.
fig = plt.figure()
# draw "circles" at specified longitudes and latitudes.
Modified: trunk/toolkits/basemap/examples/test.py
===================================================================
--- trunk/toolkits/basemap/examples/test.py 2008-09-30 11:18:10 UTC (rev 6135)
+++ trunk/toolkits/basemap/examples/test.py 2008-09-30 17:29:03 UTC (rev 6136)
@@ -75,6 +75,26 @@
# create new figure
fig=plt.figure()
+# setup gall stereographic cylindrical map projection.
+m = Basemap(llcrnrlon=-180.,llcrnrlat=-90,urcrnrlon=180.,urcrnrlat=90.,\
+ resolution='c',area_thresh=10000.,projection='gall')
+# transform to nx x ny regularly spaced native projection grid
+nx = len(lons); ny = len(lats)
+topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
+fig.add_axes([0.1,0.1,0.75,0.75])
+# plot image over map.
+im = m.imshow(topodat,plt.cm.jet)
+m.drawcoastlines()
+# draw parallels
+m.drawparallels(circles,labels=[1,1,1,1])
+# draw meridians
+m.drawmeridians(meridians,labels=[1,1,1,1])
+plt.title('Gall Stereographic Cylindrical',y=1.1)
+print 'plotting Gall Stereographic Cylindrical example ...'
+print m.proj4string
+
+# create new figure
+fig=plt.figure()
# setup mercator map projection (-80 to +80).
m = Basemap(llcrnrlon=-180.,llcrnrlat=-80,urcrnrlon=180.,urcrnrlat=80.,\
resolution='c',area_thresh=10000.,projection='merc',\
@@ -615,6 +635,33 @@
plt.title('Robinson')
print 'plotting Robinson example ...'
print m.proj4string
+
+# create new figure
+fig=plt.figure()
+# setup of basemap ('mbtfpq' = McBryde-Thomas Flat Polar Quartic projection)
+m = Basemap(projection='mbtfpq',
+ resolution='c',area_thresh=10000.,lon_0=0.5*(lonsin[0]+lonsin[-1]))
+ax = fig.add_axes([0.1,0.1,0.7,0.7])
+# plot image over map with pcolormesh.
+x,y = m(*np.meshgrid(lonsin,latsin))
+p = m.pcolormesh(x,y,topodatin,shading='flat')
+pos = ax.get_position()
+l, b, w, h = pos.bounds
+cax = plt.axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes.
+plt.colorbar(cax=cax) # draw colorbar
+plt.axes(ax) # make the original axes current again
+# draw coastlines and political boundaries.
+m.drawcoastlines()
+# draw parallels and meridians
+parallels = np.arange(-60.,90,30.)
+m.drawparallels(parallels,labels=[1,0,0,0])
+meridians = np.arange(0.,360.,60.)
+m.drawmeridians(meridians,labels=[0,0,0,1],fontsize=8)
+# draw boundary around map region.
+m.drawmapboundary()
+plt.title('McBryde-Thomas Flat Polar Quartic')
+print 'plotting McBryde-Thomas Flat Polar Quartic example ...'
+print m.proj4string
plt.show()
Modified: trunk/toolkits/basemap/examples/warpimage.py
===================================================================
--- trunk/toolkits/basemap/examples/warpimage.py 2008-09-30 11:18:10 UTC (rev 6135)
+++ trunk/toolkits/basemap/examples/warpimage.py 2008-09-30 17:29:03 UTC (rev 6136)
@@ -22,16 +22,16 @@
# create new figure
fig=plt.figure()
-# define orthographic projection centered on North America.
-m = Basemap(projection='robin',lon_0=-100,resolution='l')
+# define projection centered on North America.
+m = Basemap(projection='mbtfpq',lon_0=-100,resolution='l')
m.bluemarble()
# draw coastlines.
m.drawcoastlines(linewidth=0.5,color='0.5')
# draw lat/lon grid lines every 30 degrees.
m.drawmeridians(np.arange(0,360,60),color='0.5')
m.drawparallels(np.arange(-90,90,30),color='0.5')
-plt.title("Blue Marble image warped from 'cyl' to 'robinson' projection",fontsize=12)
-print 'warp to robinson map ...'
+plt.title("Blue Marble image warped from 'cyl' to 'mbtfpq' projection",fontsize=12)
+print 'warp to McBryde-Thomas Flat-Polar Quartic map ...'
# create new figure
fig=plt.figure()
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-09-30 11:18:10 UTC (rev 6135)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-09-30 17:29:03 UTC (rev 6136)
@@ -49,6 +49,7 @@
'tmerc' : 'Transverse Mercator',
'omerc' : 'Oblique Mercator',
'mill' : 'Miller Cylindrical',
+ 'gall' : 'Gall Stereographic Cylindrical',
'lcc' : 'Lambert Conformal',
'laea' : 'Lambert Azimuthal Equal Area',
'nplaea' : 'North-Polar Lambert Azimuthal',
@@ -68,6 +69,7 @@
'sinu' : 'Sinusoidal',
'moll' : 'Mollweide',
'robin' : 'Robinson',
+ 'mbtfpq' : 'McBryde-Thomas Flat-Polar Quartic',
'gnom' : 'Gnomonic',
}
supported_projections = []
@@ -75,12 +77,16 @@
supported_projections.append(" %-17s%-40s\n" % (_items))
supported_projections = ''.join(supported_projections)
+_cylproj = ['cyl','merc','mill','gall']
+_pseudocyl = ['moll','robin','sinu','mbtfpq']
+
# projection specific parameters.
projection_params = {'cyl' : 'corners only (no width/height)',
'merc' : 'corners plus lat_ts (no width/height)',
'tmerc' : 'lon_0,lat_0',
'omerc' : 'lon_0,lat_0,lat_1,lat_2,lon_1,lon_2,no_rot',
'mill' : 'corners only (no width/height)',
+ 'gall' : 'corners only (no width/height)',
'lcc' : 'lon_0,lat_0,lat_1,lat_2',
'laea' : 'lon_0,lat_0',
'nplaea' : 'bounding_lat,lon_0,lat_0,no corners or width/height',
@@ -100,6 +106,7 @@
'sinu' : 'lon_0,lat_0,no corners or width/height',
'moll' : 'lon_0,lat_0,no corners or width/height',
'robin' : 'lon_0,lat_0,no corners or width/height',
+ 'mbtfpq' : 'lon_0,lat_0,no corners or width/height',
'gnom' : 'lon_0,lat_0',
}
@@ -160,7 +167,7 @@
============== ====================================================
For ``sinu``, ``moll``, ``npstere``, ``spstere``, ``nplaea``, ``splaea``,
- ``npaeqd``, ``spaeqd`` or ``robin``, the values of
+ ``npaeqd``, ``spaeqd``, ``robin`` or ``mbtfpq``, the values of
llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, width and height are ignored
(because either they are computed internally, or entire globe is
always plotted).
@@ -588,7 +595,7 @@
self._fulldisk = False
self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat
self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat
- elif projection in ['moll','robin','sinu']:
+ elif projection in _pseudocyl:
if lon_0 is None:
raise ValueError, 'must specify lon_0 for Robinson, Mollweide, or Sinusoidal basemap'
if width is not None or height is not None:
@@ -630,7 +637,7 @@
llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams)
self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat
self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat
- elif projection == 'mill':
+ elif projection in ['mill','gall']:
if not using_corners:
llcrnrlon = -180.
llcrnrlat = -90.
@@ -710,10 +717,10 @@
self.urcrnrx = proj.urcrnrx
self.urcrnry = proj.urcrnry
# set min/max lats for projection domain.
- if projection in ['mill','cyl','merc']:
+ if projection in _cylproj:
self.latmin = self.llcrnrlat
self.latmax = self.urcrnrlat
- elif projection in ['ortho','geos','moll','robin','sinu']:
+ elif projection in ['ortho','geos'] + _pseudocyl:
self.latmin = -90.
self.latmax = 90.
else:
@@ -759,7 +766,7 @@
yd = (y[1:]-y[0:-1])**2
dist = np.sqrt(xd+yd)
split = dist > 5000000.
- if np.sum(split) and self.projection not in ['merc','cyl','mill']:
+ if np.sum(split) and self.projection not in _cylproj:
ind = (np.compress(split,np.squeeze(split*np.indices(xd.shape)))+1).tolist()
iprev = 0
ind.append(len(xd))
@@ -838,8 +845,7 @@
containsPole = hasNP or hasSP
# these projections cannot cross pole.
if containsPole and\
- self.projection in ['merc','mill','cyl','robin','moll','sinu','geos']:
- #self.projection in ['tmerc','omerc','cass','merc','mill','cyl','robin','moll','sinu','geos']:
+ self.projection in _cylproj + _pseudocyl + ['geos']:
raise ValueError('%s projection cannot cross pole'%(self.projection))
# make sure orthographic or gnomonic projection has containsPole=True
# we will compute the intersections in stereographic
@@ -1068,7 +1074,7 @@
projparms['x_0']=-llcrnrx
projparms['y_0']=-llcrnry
maptran = pyproj.Proj(projparms)
- elif self.projection in ['moll','robin','sinu']:
+ elif self.projection in _pseudocyl:
# quasi-elliptical region.
lon_0 = self.projparams['lon_0']
# left side
@@ -1110,7 +1116,7 @@
b[:,0]=[self.xmin,self.xmin,self.xmax,self.xmax]
b[:,1]=[self.ymin,self.ymax,self.ymax,self.ymin]
boundaryxy = _geoslib.Polygon(b)
- if self.projection in ['mill','merc','cyl']:
+ if self.projection in _cylproj:
# make sure map boundary doesn't quite include pole.
if self.urcrnrlat > 89.9999:
urcrnrlat = 89.9999
@@ -1127,7 +1133,7 @@
b[:,0]=x; b[:,1]=y
boundaryxy = _geoslib.Polygon(b)
else:
- if self.projection not in ['moll','robin','sinu']:
+ if self.projection not in _pseudocyl:
lons, lats = maptran(x,y,inverse=True)
# fix lons so there are no jumps.
n = 1
@@ -1198,7 +1204,7 @@
limb.set_clip_on(False)
if zorder is not None:
limb.set_zorder(zorder)
- elif self.projection in ['moll','robin','sinu']: # elliptical region.
+ elif self.projection in _pseudocyl: # elliptical region.
nx = 100; ny = 100
# quasi-elliptical region.
lon_0 = self.projparams['lon_0']
@@ -1738,7 +1744,7 @@
if xoffset is None:
xoffset = (self.urcrnrx-self.llcrnrx)/100.
- if self.projection in ['merc','cyl','mill','moll','robin','sinu']:
+ if self.projection in _cylproj + _pseudocyl:
lons = np.arange(self.llcrnrlon,self.urcrnrlon+0.01,0.01)
elif self.projection in ['tmerc']:
lon_0 = self.projparams['lon_0']
@@ -1751,7 +1757,7 @@
circlesl = circles.tolist()
except:
circlesl = circles
- if self.projection not in ['merc','cyl','mill','moll','robin','sinu']:
+ if self.projection not in _cylproj + _pseudocyl:
if max(circlesl) > 0 and latmax not in circlesl:
circlesl.append(latmax)
if min(circlesl) < 0 and -latmax not in circlesl:
@@ -1780,7 +1786,7 @@
yd = (y[1:]-y[0:-1])**2
dist = np.sqrt(xd+yd)
split = dist > 500000.
- if np.sum(split) and self.projection not in ['merc','cyl','mill','moll','robin','sinu']:
+ if np.sum(split) and self.projection not in _cylproj + _pseudocyl:
ind = (np.compress(split,np.squeeze(split*np.indices(xd.shape)))+1).tolist()
xl = []
yl = []
@@ -1816,12 +1822,12 @@
# if so, find x,y location of intersection and draw a label there.
dx = (self.xmax-self.xmin)/1000.
dy = (self.ymax-self.ymin)/1000.
- if self.projection in ['moll','robin','sinu']:
+ if self.projection in _pseudocyl:
lon_0 = self.projparams['lon_0']
for dolab,side in zip(labels,['l','r','t','b']):
if not dolab: continue
# for cylindrical projections, don't draw parallels on top or bottom.
- if self.projection in ['cyl','merc','mill','moll','robin','sinu'] and side in ['t','b']: continue
+ if self.projection in _cylproj + _pseudocyl and side in ['t','b']: continue
if side in ['l','r']:
nmax = int((self.ymax-self.ymin)/dy+1)
yy = np.linspace(self.llcrnry,self.urcrnry,nmax)
@@ -1897,14 +1903,14 @@
if n >= 0:
t = None
if side == 'l':
- if self.projection in ['moll','robin','sinu']:
+ if self.projection in _pseudocyl:
xlab,ylab = self(lon_0-179.9,lat)
else:
xlab = self.llcrnrx
xlab = xlab-xoffset
t = ax.text(xlab,yy[n],latlab,horizontalalignment='right',verticalalignment='center',**kwargs)
elif side == 'r':
- if self.projection in ['moll','robin','sinu']:
+ if self.projection in _pseudocyl:
xlab,ylab = self(lon_0+179.9,lat)
else:
xlab = self.urcrnrx
@@ -1994,7 +2000,7 @@
if xoffset is None:
xoffset = (self.urcrnrx-self.llcrnrx)/100.
- if self.projection not in ['merc','cyl','mill','moll','robin','sinu']:
+ if self.projection not in _cylproj + _pseudocyl:
lats = np.arange(-latmax,latmax+0.01,0.01)
else:
lats = np.arange(-90,90.01,0.01)
@@ -2022,7 +2028,7 @@
yd = (y[1:]-y[0:-1])**2
dist = np.sqrt(xd+yd)
split = dist > 500000.
- if np.sum(split) and self.projection not in ['merc','cyl','mill','moll','robin','sinu']:
+ if np.sum(split) and self.projection not in _cylproj + _pseudocyl:
ind = (np.compress(split,np.squeeze(split*np.indices(xd.shape)))+1).tolist()
xl = []
yl = []
@@ -2062,14 +2068,14 @@
# if so, find x,y location of intersection and draw a label there.
dx = (self.xmax-self.xmin)/1000.
dy = (self.ymax-self.ymin)/1000.
- if self.projection in ['moll','sinu','robin']:
+ if self.projection in _pseudocyl:
lon_0 = self.projparams['lon_0']
xmin,ymin = self(lon_0-179.9,-90)
xmax,ymax = self(lon_0+179.9,90)
for dolab,side in zip(labels,['l','r','t','b']):
if not dolab: continue
# for cylindrical projections, don't draw meridians on left or right.
- if self.projection in ['cyl','merc','mill','sinu','robin','moll'] and side in ['l','r']: continue
+ if self.projection in _cylproj + _pseudocyl and side in ['l','r']: continue
if side in ['l','r']:
nmax = int((self.ymax-self.ymin)/dy+1)
yy = np.linspace(self.llcrnry,self.urcrnry,nmax)
@@ -2085,7 +2091,10 @@
lons = [(lon+360) % 360 for lon in lons]
else:
nmax = int((self.xmax-self.xmin)/dx+1)
- xx = np.linspace(self.llcrnrx,self.urcrnrx,nmax)
+ if self.projection in _pseudocyl:
+ xx = np.linspace(xmin,xmax,nmax)
+ else:
+ xx = np.linspace(self.llcrnrx,self.urcrnrx,nmax)
if side == 'b':
lons,lats = self(xx,self.llcrnry*np.ones(xx.shape,np.float32),inverse=True)
lons = lons.tolist(); lats = lats.tolist()
@@ -2141,7 +2150,7 @@
for i,n in enumerate([nl,nr]):
lat = lats[n]/100.
# no meridians > latmax for projections other than merc,cyl,miller.
- if self.projection not in ['merc','cyl','mill'] and lat > latmax: continue
+ if self.projection not in _cylproj and lat > latmax: continue
# don't bother if close to the first label.
if i and abs(nr-nl) < 100: continue
if n >= 0:
@@ -2151,11 +2160,9 @@
elif side == 'r':
t = ax.text(self.urcrnrx+xoffset,yy[n],lonlab,horizontalalignment='left',verticalalignment='center',**kwargs)
elif side == 'b':
- if self.projection != 'robin' or (xx[n] > xmin and xx[n] < xmax):
- t = ax.text(xx[n],self.llcrnry-yoffset,lonlab,horizontalalignment='center',verticalalignment='top',**kwargs)
+ t = ax.text(xx[n],self.llcrnry-yoffset,lonlab,horizontalalignment='center',verticalalignment='top',**kwargs)
else:
- if self.projection != 'robin' or (xx[n] > xmin and xx[n] < xmax):
- t = ax.text(xx[n],self.urcrnry+yoffset,lonlab,horizontalalignment='center',verticalalignment='bottom',**kwargs)
+ t = ax.text(xx[n],self.urcrnry+yoffset,lonlab,horizontalalignment='center',verticalalignment='bottom',**kwargs)
if t is not None: linecolls[lon][1].append(t)
# set axes limits to fit map region.
@@ -2313,7 +2320,7 @@
if min(delon) < 0. or min(delat) < 0.:
raise ValueError, 'lons and lats must be increasing!'
# check that lons in -180,180 for non-cylindrical projections.
- if self.projection not in ['cyl','merc','mill']:
+ if self.projection not in _cylproj:
lonsa = np.array(lons)
count = np.sum(lonsa < -180.00001) + np.sum(lonsa > 180.00001)
if count > 1:
@@ -2384,7 +2391,7 @@
if min(delon) < 0. or min(delat) < 0.:
raise ValueError, 'lons and lats must be increasing!'
# check that lons in -180,180 for non-cylindrical projections.
- if self.projection not in ['cyl','merc','mill']:
+ if self.projection not in _cylproj:
lonsa = np.array(lons)
count = np.sum(lonsa < -180.00001) + np.sum(lonsa > 180.00001)
if count > 1:
@@ -2516,7 +2523,7 @@
ax.set_xlim((self.llcrnrx, self.urcrnrx))
ax.set_ylim((self.llcrnry, self.urcrnry))
# turn off axes frame for non-rectangular projections.
- if self.projection in ['moll','robin','sinu']:
+ if self.projection in _pseudocyl:
ax.set_frame_on(False)
if self.projection in ['ortho','geos'] and self._fulldisk:
ax.set_frame_on(False)
@@ -2782,7 +2789,7 @@
# print warning suggesting that the data be shifted in longitude
# with the shiftgrid function.
# only do this check for global projections.
- if self.projection in ['merc','cyl','mill','moll','robin','sinu']:
+ if self.projection in _cylproj + _pseudocyl:
xx = x[x.shape[0]/2,:]
condition = (xx >= self.xmin) & (xx <= self.xmax)
xl = xx.compress(condition).tolist()
@@ -2855,7 +2862,7 @@
# print warning suggesting that the data be shifted in longitude
# with the shiftgrid function.
# only do this check for global projections.
- if self.projection in ['merc','cyl','mill','moll','robin','sinu']:
+ if self.projection in _cylproj + _pseudocyl:
xx = x[x.shape[0]/2,:]
condition = (xx >= self.xmin) & (xx <= self.xmax)
xl = xx.compress(condition).tolist()
@@ -3101,7 +3108,7 @@
lsmask_lats,nx,ny,returnxy=True,order=0,masked=255)
# for these projections, points outside the projection
# limb have to be set to transparent manually.
- if self.projection in ['moll','robin','sinu']:
+ if self.projection in _pseudocyl:
lons, lats = self(x, y, inverse=True)
lon_0 = self.projparams['lon_0']
lats = lats[:,nx/2]
@@ -3207,7 +3214,7 @@
self._bm_lats = np.arange(-90.+0.5*delta,90.,delta)
# is it a cylindrical projection whose limits lie
# outside the limits of the image?
- cylproj = self.projection in ['mill','cyl','merc'] and \
+ cylproj = self.projection in _cylproj and \
(self.urcrnrlon > self._bm_lons[-1] or \
self.llcrnrlon < self._bm_lons[0])
# if pil_to_array returns a 2D array, it's a grayscale image.
@@ -3260,8 +3267,8 @@
ma.masked_array(self._bm_rgba_warped,mask=mask)
# make points outside projection limb transparent.
self._bm_rgba_warped = self._bm_rgba_warped.filled(0.)
- # treat mollweide, robinson and sinusoidal.
- elif self.projection in ['moll','robin','sinu']:
+ # treat pseudo-cyl projections such as mollweide, robinson and sinusoidal.
+ elif self.projection in _pseudocyl:
lonsr,latsr = self(x,y,inverse=True)
mask = ma.zeros((ny,nx,4),np.int8)
lon_0 = self.projparams['lon_0']
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py 2008-09-30 11:18:10 UTC (rev 6135)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py 2008-09-30 17:29:03 UTC (rev 6136)
@@ -6,6 +6,9 @@
_dg2rad = math.radians(1.)
_rad2dg = math.degrees(1.)
+_cylproj = ['cyl','merc','mill','gall']
+_pseudocyl = ['moll','robin','sinu','mbtfpq']
+
_upper_right_out_of_bounds = (
'the upper right corner of the plot is not in the map projection region')
@@ -67,7 +70,7 @@
self.esq = (self.rmajor**2 - self.rminor**2)/self.rmajor**2
self.llcrnrlon = llcrnrlon
self.llcrnrlat = llcrnrlat
- if self.projection not in ['cyl','ortho','geos','moll','robin','sinu']:
+ if self.projection not in ['ortho','geos','cyl'] + _pseudocyl:
self._proj4 = pyproj.Proj(projparams)
llcrnrx, llcrnry = self(llcrnrlon,llcrnrlat)
elif self.projection == 'cyl':
@@ -119,7 +122,7 @@
llcrnrx, llcrnry = self(llcrnrlon,llcrnrlat)
if llcrnrx > 1.e20 or llcrnry > 1.e20:
raise ValueError(_lower_left_out_of_bounds)
- elif self.projection in ['moll','robin','sinu']:
+ elif self.projection in _pseudocyl:
self._proj4 = pyproj.Proj(projparams)
xtmp,urcrnry = self(projparams['lon_0'],90.)
urcrnrx,xtmp = self(projparams['lon_0']+180.,0)
@@ -140,7 +143,7 @@
if urcrnrislatlon:
self.urcrnrlon = urcrnrlon
self.urcrnrlat = urcrnrlat
- if self.projection not in ['ortho','geos','moll','robin','sinu']:
+ if self.projection not in ['ortho','geos'] + _pseudocyl:
urcrnrx,urcrnry = self(urcrnrlon,urcrnrlat)
elif self.projection == 'ortho':
if self._fulldisk:
@@ -158,7 +161,7 @@
urcrnrx,urcrnry = self(urcrnrlon,urcrnrlat)
if urcrnrx > 1.e20 or urcrnry > 1.e20:
raise ValueError(_upper_right_out_of_bounds)
- elif self.projection in ['moll','robin','sinu']:
+ elif self.projection in _pseudocyl:
xtmp,urcrnry = self(projparams['lon_0'],90.)
urcrnrx,xtmp = self(projparams['lon_0']+180.,0)
else:
@@ -216,7 +219,7 @@
else:
outx,outy = self._proj4(x, y, inverse=inverse)
if inverse:
- if self.projection in ['merc','mill']:
+ if self.projection in ['merc','mill','gall']:
if self.projection == 'merc':
coslat = math.cos(math.radians(self.projparams['lat_ts']))
sinlat = math.sin(math.radians(self.projparams['lat_ts']))
@@ -234,7 +237,7 @@
except: # x a sequence
outx = [_rad2dg*(xi/rcurv) + self.llcrnrlon for xi in x]
else:
- if self.projection in ['merc','mill']:
+ if self.projection in ['merc','mill','gall']:
if self.projection == 'merc':
coslat = math.cos(math.radians(self.projparams['lat_ts']))
sinlat = math.sin(math.radians(self.projparams['lat_ts']))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-09-30 20:14:54
|
Revision: 6138
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6138&view=rev
Author: jswhit
Date: 2008-09-30 20:14:38 +0000 (Tue, 30 Sep 2008)
Log Message:
-----------
add van der Grinten ('vandg')
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/examples/test.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-09-30 20:07:54 UTC (rev 6137)
+++ trunk/toolkits/basemap/Changelog 2008-09-30 20:14:38 UTC (rev 6138)
@@ -1,9 +1,8 @@
version 0.99.2 (not yet released)
* Added McBryde-Thomas Flat Polar Quartic (projection =
- 'mbtfpq') and Gall Stereographic Cylindrical (projection =
- 'gall').
- * fix warpimage and bluemarble methods for projection = 'cyl',
- 'robin', 'moll' and 'sinu'.
+ 'mbtfpq'), Gall Stereographic Cylindrical (projection =
+ 'gall') and van der Grinten (projection = 'vandg').
+ * fix bugs in warpimage and bluemarble methods for several projections.
* bugfix patch for rotate_vector from David Huard. David
also contributed the beginnings of a test suite.
* _geoslib.so now installed in mpl_toolkits.basemap.
Modified: trunk/toolkits/basemap/examples/test.py
===================================================================
--- trunk/toolkits/basemap/examples/test.py 2008-09-30 20:07:54 UTC (rev 6137)
+++ trunk/toolkits/basemap/examples/test.py 2008-09-30 20:14:38 UTC (rev 6138)
@@ -662,7 +662,42 @@
plt.title('McBryde-Thomas Flat Polar Quartic')
print 'plotting McBryde-Thomas Flat Polar Quartic example ...'
print m.proj4string
+
+# create new figure
+fig=plt.figure()
+# create Basemap instance for van der Grinten projection.
+m = Basemap(projection='vandg',lon_0=0.5*(lonsin[0]+lonsin[-1]))
+# add poles to data.
+tmpdat = np.empty((len(latsin)+2,len(lonsin)),topodatin.dtype)
+tmpdat[1:-1,:] = topodatin
+tmpdat[0,:] = topodatin[1,:].mean()
+tmpdat[-1,:] = topodatin[-1,:].mean()
+lats2 = np.empty(len(latsin)+2,latsin.dtype)
+lats2[1:-1] = latsin
+lats2[0] = -90; latsin[-1] = 90
+ax = fig.add_axes([0.1,0.1,0.7,0.7])
+# plot image over map with pcolormesh.
+x,y = m(*np.meshgrid(lonsin,lats2))
+p = m.pcolormesh(x,y,tmpdat,shading='flat')
+pos = ax.get_position()
+l, b, w, h = pos.bounds
+cax = plt.axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes.
+plt.colorbar(cax=cax) # draw colorbar
+plt.axes(ax) # make the original axes current again
+# draw coastlines and political boundaries.
+m.drawcoastlines()
+# draw parallels and meridians
+parallels = np.arange(-80.,90,20.)
+m.drawparallels(parallels)
+meridians = np.arange(0.,360.,60.)
+m.drawmeridians(meridians)
+# draw boundary around map region.
+m.drawmapboundary()
+# add a title.
+plt.title('van der Grinten')
+print 'plotting van der Grinten example ...'
+print m.proj4string
+
plt.show()
-
print 'done'
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-09-30 20:07:54 UTC (rev 6137)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-09-30 20:14:38 UTC (rev 6138)
@@ -69,7 +69,8 @@
'sinu' : 'Sinusoidal',
'moll' : 'Mollweide',
'robin' : 'Robinson',
- 'mbtfpq' : 'McBryde-Thomas Flat-Polar Quartic',
+ 'vandg' : 'van der Grinten',
+ 'mbtfpq' : 'McBryde-Thomas Flat-Polar Quartic',
'gnom' : 'Gnomonic',
}
supported_projections = []
@@ -78,7 +79,7 @@
supported_projections = ''.join(supported_projections)
_cylproj = ['cyl','merc','mill','gall']
-_pseudocyl = ['moll','robin','sinu','mbtfpq']
+_pseudocyl = ['moll','robin','sinu','mbtfpq','vandg']
# projection specific parameters.
projection_params = {'cyl' : 'corners only (no width/height)',
@@ -106,6 +107,7 @@
'sinu' : 'lon_0,lat_0,no corners or width/height',
'moll' : 'lon_0,lat_0,no corners or width/height',
'robin' : 'lon_0,lat_0,no corners or width/height',
+ 'vandg' : 'lon_0,lat_0,no corners or width/height',
'mbtfpq' : 'lon_0,lat_0,no corners or width/height',
'gnom' : 'lon_0,lat_0',
}
@@ -546,7 +548,7 @@
self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat
self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat
if width is not None or height is not None:
- print 'warning: width and height keywords ignored for %s projection' % self.projection
+ print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection]
elif projection in ['tmerc','gnom','cass','poly'] :
if projection == 'gnom' and not projparams.has_key('R'):
raise ValueError, 'gnomonic projection only works for perfect spheres - not ellipsoids'
@@ -566,7 +568,7 @@
if lat_0 is None or lon_0 is None:
raise ValueError, 'must specify lat_0 and lon_0 for Orthographic basemap'
if width is not None or height is not None:
- print 'warning: width and height keywords ignored for %s projection' % self.projection
+ print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection]
if not using_corners:
llcrnrlon = -180.
llcrnrlat = -90.
@@ -584,7 +586,7 @@
if lon_0 is None:
raise ValueError, 'must specify lon_0 for Geostationary basemap'
if width is not None or height is not None:
- print 'warning: width and height keywords ignored for %s projection' % self.projection
+ print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection]
if not using_corners:
llcrnrlon = -180.
llcrnrlat = -90.
@@ -597,9 +599,9 @@
self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat
elif projection in _pseudocyl:
if lon_0 is None:
- raise ValueError, 'must specify lon_0 for Robinson, Mollweide, or Sinusoidal basemap'
+ raise ValueError, 'must specify lon_0 for %s projection' % _projnames[self.projection]
if width is not None or height is not None:
- print 'warning: width and height keywords ignored for %s projection' % self.projection
+ print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection]
llcrnrlon = -180.
llcrnrlat = -90.
urcrnrlon = 180
@@ -646,7 +648,7 @@
self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat
self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat
if width is not None or height is not None:
- print 'warning: width and height keywords ignored for %s projection' % self.projection
+ print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection]
elif projection == 'cyl':
if not using_corners:
llcrnrlon = -180.
@@ -656,7 +658,7 @@
self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat
self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat
if width is not None or height is not None:
- print 'warning: width and height keywords ignored for %s projection' % self.projection
+ print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection]
else:
raise ValueError(_unsupported_projection % projection)
@@ -1039,13 +1041,14 @@
"""
create map boundary polygon (in lat/lon and x/y coordinates)
"""
- nx = 100
- ny = 100
+ nx = 100; ny = 100
+ if self.projection == 'vandg':
+ nx = 10*nx; ny = 10*ny
maptran = self
if self.projection in ['ortho','geos']:
# circular region.
thetas = np.linspace(0.,2.*np.pi,2*nx*ny)[:-1]
- if self.projection == 'ortho':
+ if self.projection == 'ortho':
rminor = self.rmajor
rmajor = self.rmajor
else:
@@ -1078,17 +1081,17 @@
# quasi-elliptical region.
lon_0 = self.projparams['lon_0']
# left side
- lats1 = np.linspace(-89.9,89.9,ny).tolist()
+ lats1 = np.linspace(-89.9999,89.9999,ny).tolist()
lons1 = len(lats1)*[lon_0-179.9]
# top.
lons2 = np.linspace(lon_0-179.9,lon_0+179.9,nx).tolist()
- lats2 = len(lons2)*[89.9]
+ lats2 = len(lons2)*[89.9999]
# right side
- lats3 = np.linspace(89.9,-89.9,ny).tolist()
+ lats3 = np.linspace(89.9999,-89.9999,ny).tolist()
lons3 = len(lats3)*[lon_0+179.9]
# bottom.
lons4 = np.linspace(lon_0+179.9,lon_0-179.9,nx).tolist()
- lats4 = len(lons4)*[-89.9]
+ lats4 = len(lons4)*[-89.9999]
lons = np.array(lons1+lons2+lons3+lons4,np.float64)
lats = np.array(lats1+lats2+lats3+lats4,np.float64)
x, y = maptran(lons,lats)
@@ -1206,20 +1209,22 @@
limb.set_zorder(zorder)
elif self.projection in _pseudocyl: # elliptical region.
nx = 100; ny = 100
+ if self.projection == 'vandg':
+ nx = 10*nx; ny = 10*ny
# quasi-elliptical region.
lon_0 = self.projparams['lon_0']
# left side
- lats1 = np.linspace(-89.9,89.9,ny).tolist()
+ lats1 = np.linspace(-89.9999,89.99999,ny).tolist()
lons1 = len(lats1)*[lon_0-179.9]
# top.
- lons2 = np.linspace(lon_0-179.9,lon_0+179.9,nx).tolist()
- lats2 = len(lons2)*[89.9]
+ lons2 = np.linspace(lon_0-179.9999,lon_0+179.9999,nx).tolist()
+ lats2 = len(lons2)*[89.9999]
# right side
- lats3 = np.linspace(89.9,-89.9,ny).tolist()
- lons3 = len(lats3)*[lon_0+179.9]
+ lats3 = np.linspace(89.9999,-89.9999,ny).tolist()
+ lons3 = len(lats3)*[lon_0+179.9999]
# bottom.
- lons4 = np.linspace(lon_0+179.9,lon_0-179.9,nx).tolist()
- lats4 = len(lons4)*[-89.9]
+ lons4 = np.linspace(lon_0+179.9999,lon_0-179.9999,nx).tolist()
+ lats4 = len(lons4)*[-89.9999]
lons = np.array(lons1+lons2+lons3+lons4,np.float64)
lats = np.array(lats1+lats2+lats3+lats4,np.float64)
x, y = self(lons,lats)
@@ -1781,12 +1786,13 @@
lines = []
if len(x) > 1 and len(y) > 1:
# split into separate line segments if necessary.
- # (not necessary for mercator or cylindrical or miller).
+ # (not necessary for cylindrical or pseudocylindricl projections)
xd = (x[1:]-x[0:-1])**2
yd = (y[1:]-y[0:-1])**2
dist = np.sqrt(xd+yd)
split = dist > 500000.
- if np.sum(split) and self.projection not in _cylproj + _pseudocyl:
+ if np.sum(split) and self.projection not in \
+ ['cyl', 'merc', 'mill', 'gall', 'moll', 'robin', 'sinu', 'mbtfpq']:
ind = (np.compress(split,np.squeeze(split*np.indices(xd.shape)))+1).tolist()
xl = []
yl = []
@@ -1814,9 +1820,9 @@
linecolls[circ] = (lines,[])
# draw labels for parallels
# parallels not labelled for fulldisk orthographic or geostationary
- if self.projection in ['ortho','geos'] and max(labels):
- if self._fulldisk:
- print 'Warning: Cannot label parallels on full-disk Orthographic or Geostationary basemap'
+ if self.projection in ['ortho','geos','vandg'] and max(labels):
+ if self.projection == 'vandg' or self._fulldisk:
+ print 'Warning: Cannot label parallels on %s basemap' % _projnames[self.projection]
labels = [0,0,0,0]
# search along edges of map to see if parallels intersect.
# if so, find x,y location of intersection and draw a label there.
@@ -2057,8 +2063,8 @@
# draw labels for meridians.
# meridians not labelled for sinusoidal, mollweide, or
# or full-disk orthographic/geostationary.
- if self.projection in ['sinu','moll'] and max(labels):
- print 'Warning: Cannot label meridians on Sinusoidal or Mollweide basemap'
+ if self.projection in ['sinu','moll','vandg'] and max(labels):
+ print 'Warning: Cannot label meridians on %s basemap' % _projnames[self.projection]
labels = [0,0,0,0]
if self.projection in ['ortho','geos'] and max(labels):
if self._fulldisk:
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py 2008-09-30 20:07:54 UTC (rev 6137)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py 2008-09-30 20:14:38 UTC (rev 6138)
@@ -7,7 +7,7 @@
_rad2dg = math.degrees(1.)
_cylproj = ['cyl','merc','mill','gall']
-_pseudocyl = ['moll','robin','sinu','mbtfpq']
+_pseudocyl = ['moll','robin','sinu','mbtfpq','vandg']
_upper_right_out_of_bounds = (
'the upper right corner of the plot is not in the map projection region')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-11-07 12:36:41
|
Revision: 6370
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6370&view=rev
Author: jswhit
Date: 2008-11-07 12:36:37 +0000 (Fri, 07 Nov 2008)
Log Message:
-----------
Added masked array support to shiftgrid, fix cut and paste error in
previous commit. Patch provided by Jesper Larsen.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-11-07 12:30:08 UTC (rev 6369)
+++ trunk/toolkits/basemap/Changelog 2008-11-07 12:36:37 UTC (rev 6370)
@@ -1,4 +1,6 @@
version 0.99.2 (not yet released)
+ * Added masked array support to shiftgrid function
+ (thanks to Jesper Larsen).
* defer import of netcdf stuff till it is needed (in NetCDFFile
function).
* Added McBryde-Thomas Flat Polar Quartic (projection =
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-11-07 12:30:08 UTC (rev 6369)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-11-07 12:36:37 UTC (rev 6370)
@@ -3680,13 +3680,13 @@
raise ValueError, 'lon0 outside of range of lonsin'
i0 = np.argmin(np.fabs(lonsin-lon0))
if hasattr(datain,'mask'):
- datout = ma.zeros((nlats,nlons+1),datain.dtype)
+ dataout = ma.zeros(datain.shape,datain.dtype)
else:
- datout = np.zeros((nlats,nlons+1),datain.dtype)
+ dataout = np.zeros(datain.shape,datain.dtype)
if hasattr(lonsin,'mask'):
- lonsout = ma.zeros(nlons+1,lonsin.dtype)
+ lonsout = ma.zeros(lonsin.shape,lonsin.dtype)
else:
- lonsout = np.zeros(nlons+1,lonsin.dtype)
+ lonsout = np.zeros(lonsin.shape,lonsin.dtype)
if start:
lonsout[0:len(lonsin)-i0] = lonsin[i0:]
else:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-11-20 12:27:48
|
Revision: 6418
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6418&view=rev
Author: jswhit
Date: 2008-11-20 12:27:42 +0000 (Thu, 20 Nov 2008)
Log Message:
-----------
added new embedding_map_in_wx.py example, courtesy of Mauro Cavalcanti.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/MANIFEST.in
trunk/toolkits/basemap/README
trunk/toolkits/basemap/examples/README
trunk/toolkits/basemap/examples/run_all.py
Added Paths:
-----------
trunk/toolkits/basemap/examples/embedding_map_in_wx.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-11-19 15:16:26 UTC (rev 6417)
+++ trunk/toolkits/basemap/Changelog 2008-11-20 12:27:42 UTC (rev 6418)
@@ -1,4 +1,6 @@
version 0.99.2 (not yet released)
+ * Added embedding_map_in_wx.py example (courtesy of
+ Mauro Cavalcanti).
* Added masked array support to shiftgrid function
(thanks to Jesper Larsen).
* defer import of netcdf stuff till it is needed (in NetCDFFile
Modified: trunk/toolkits/basemap/MANIFEST.in
===================================================================
--- trunk/toolkits/basemap/MANIFEST.in 2008-11-19 15:16:26 UTC (rev 6417)
+++ trunk/toolkits/basemap/MANIFEST.in 2008-11-20 12:27:42 UTC (rev 6418)
@@ -11,6 +11,7 @@
include setup.cfg
include setupegg.py
include src/*
+include examples/embedding_map_in_wx.py
include examples/cubed_sphere.py
include examples/simpletest.py
include examples/hires.py
Modified: trunk/toolkits/basemap/README
===================================================================
--- trunk/toolkits/basemap/README 2008-11-19 15:16:26 UTC (rev 6417)
+++ trunk/toolkits/basemap/README 2008-11-20 12:27:42 UTC (rev 6418)
@@ -122,5 +122,6 @@
Jesper Larsen
Ryan May
David Huard
+Mauro Cavalcanti
for valuable contributions.
Modified: trunk/toolkits/basemap/examples/README
===================================================================
--- trunk/toolkits/basemap/examples/README 2008-11-19 15:16:26 UTC (rev 6417)
+++ trunk/toolkits/basemap/examples/README 2008-11-20 12:27:42 UTC (rev 6418)
@@ -117,3 +117,6 @@
run_all.py is a driver script that runs all the examples except fcstmaps.py,
testgdal.py, geos_demo_2.py, warpimage.py, and pnganim.py (which
rely on external dependencies and/or an internet connection).
+
+embedding_map_in_wx.py is an example of how to embed Basemap using wx or wxagg
+in a GUI application.
Added: trunk/toolkits/basemap/examples/embedding_map_in_wx.py
===================================================================
--- trunk/toolkits/basemap/examples/embedding_map_in_wx.py (rev 0)
+++ trunk/toolkits/basemap/examples/embedding_map_in_wx.py 2008-11-20 12:27:42 UTC (rev 6418)
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+"""
+An example of how to use wx or wxagg in an application with the Basemap module
+"""
+
+from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
+from matplotlib.backends.backend_wx import NavigationToolbar2Wx
+from matplotlib.figure import Figure
+
+from mpl_toolkits.basemap import Basemap
+
+from wx import *
+
+class CanvasFrame(Frame):
+
+ def __init__(self):
+ Frame.__init__(self,None,-1,
+ 'CanvasFrame',size=(550,350))
+
+ self.SetBackgroundColour(NamedColor("WHITE"))
+
+ self.figure = Figure()
+
+ self.canvas = FigureCanvas(self, -1, self.figure)
+ self.ax = self.figure.add_subplot(111)
+
+ self.sizer = BoxSizer(VERTICAL)
+ self.sizer.Add(self.canvas, 1, LEFT | TOP | GROW)
+ self.SetSizer(self.sizer)
+ self.Fit()
+
+ self.add_toolbar() # comment this out for no toolbar
+
+ self.plot_map()
+
+ def add_toolbar(self):
+ self.toolbar = NavigationToolbar2Wx(self.canvas)
+ self.toolbar.Realize()
+ if Platform == '__WXMAC__':
+ # Mac platform (OSX 10.3, MacPython) does not seem to cope with
+ # having a toolbar in a sizer. This work-around gets the buttons
+ # back, but at the expense of having the toolbar at the top
+ self.SetToolBar(self.toolbar)
+ else:
+ # On Windows platform, default window size is incorrect, so set
+ # toolbar width to figure width.
+ tw, th = self.toolbar.GetSizeTuple()
+ fw, fh = self.canvas.GetSizeTuple()
+ # By adding toolbar in sizer, we are able to put it at the bottom
+ # of the frame - so appearance is closer to GTK version.
+ # As noted above, doesn't work for Mac.
+ self.toolbar.SetSize(Size(fw, th))
+ self.sizer.Add(self.toolbar, 0, LEFT | EXPAND)
+ # update the axes menu on the toolbar
+ self.toolbar.update()
+
+ def plot_map(self):
+ map = Basemap(ax=self.ax)
+ map.drawcoastlines()
+ map.drawcountries()
+ map.drawmapboundary()
+ map.fillcontinents(color='lime', lake_color='aqua')
+ map.drawmapboundary(fill_color='aqua')
+ self.figure.canvas.draw()
+
+class App(App):
+
+ def OnInit(self):
+ 'Create the main window and insert the custom frame'
+ frame = CanvasFrame()
+ frame.Show(True)
+ return True
+
+app = App(0)
+app.MainLoop()
Modified: trunk/toolkits/basemap/examples/run_all.py
===================================================================
--- trunk/toolkits/basemap/examples/run_all.py 2008-11-19 15:16:26 UTC (rev 6417)
+++ trunk/toolkits/basemap/examples/run_all.py 2008-11-20 12:27:42 UTC (rev 6418)
@@ -6,6 +6,7 @@
test_files.remove('pnganim.py')
test_files.remove('geos_demo_2.py')
test_files.remove('plotsst.py')
+test_files.remove('embedding_map_in_wx.py')
print test_files
py_path = os.environ.get('PYTHONPATH')
if py_path is None:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-11-20 13:08:54
|
Revision: 6419
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6419&view=rev
Author: jswhit
Date: 2008-11-20 13:08:44 +0000 (Thu, 20 Nov 2008)
Log Message:
-----------
example showing how to re-use a map background.
Modified Paths:
--------------
trunk/toolkits/basemap/MANIFEST.in
trunk/toolkits/basemap/examples/README
Added Paths:
-----------
trunk/toolkits/basemap/examples/save_background.py
Modified: trunk/toolkits/basemap/MANIFEST.in
===================================================================
--- trunk/toolkits/basemap/MANIFEST.in 2008-11-20 12:27:42 UTC (rev 6418)
+++ trunk/toolkits/basemap/MANIFEST.in 2008-11-20 13:08:44 UTC (rev 6419)
@@ -11,6 +11,7 @@
include setup.cfg
include setupegg.py
include src/*
+include examples/save_background.py
include examples/embedding_map_in_wx.py
include examples/cubed_sphere.py
include examples/simpletest.py
Modified: trunk/toolkits/basemap/examples/README
===================================================================
--- trunk/toolkits/basemap/examples/README 2008-11-20 12:27:42 UTC (rev 6418)
+++ trunk/toolkits/basemap/examples/README 2008-11-20 13:08:44 UTC (rev 6419)
@@ -120,3 +120,6 @@
embedding_map_in_wx.py is an example of how to embed Basemap using wx or wxagg
in a GUI application.
+
+save_background.py shows how to save a map background and reuse it in another
+figure (without having to redraw coastlines).
Added: trunk/toolkits/basemap/examples/save_background.py
===================================================================
--- trunk/toolkits/basemap/examples/save_background.py (rev 0)
+++ trunk/toolkits/basemap/examples/save_background.py 2008-11-20 13:08:44 UTC (rev 6419)
@@ -0,0 +1,36 @@
+import matplotlib
+matplotlib.use('Agg')
+from mpl_toolkits.basemap import Basemap
+import matplotlib.pyplot as plt
+
+# this example shows how to save a map background and
+# reuse it in another figure.
+
+# make sure we have all the same properties on all figs
+figprops = dict(figsize=(8,6), dpi=100, facecolor='white')
+
+# generate the first figure.
+fig1 = plt.figure(1,**figprops)
+ax1 = fig1.add_subplot(111)
+# create basemap instance, plot coastlines.
+map = Basemap(projection='moll',lon_0=0)
+map.drawcoastlines()
+map.drawmapboundary(fill_color='aqua')
+map.fillcontinents(color='coral',lake_color='aqua')
+fig1.canvas.draw()
+background = fig1.canvas.copy_from_bbox(fig1.bbox)
+fig1.savefig('figure1.png', dpi=100)
+
+
+# generate the second figure, re-using the background
+# from figure 1.
+fig2 = plt.figure(2,frameon=False,**figprops)
+ax2 = fig2.add_subplot(111, frameon=False, xticks=[], yticks=[])
+# restore previous background.
+fig2.canvas.restore_region(background)
+# draw parallels and meridians on existing background.
+map.drawparallels(range(-90,90,30))
+map.drawmeridians(range(-180,180,60))
+fig2.savefig('figure2.png', dpi=100)
+
+print 'images saved in figure1.png and figure2.png'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-12-08 12:44:46
|
Revision: 6507
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6507&view=rev
Author: jswhit
Date: 2008-12-08 12:44:41 +0000 (Mon, 08 Dec 2008)
Log Message:
-----------
now can specify just lon_0 to define global cylindrical projection
centered on lon_0.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-12-08 12:31:06 UTC (rev 6506)
+++ trunk/toolkits/basemap/Changelog 2008-12-08 12:44:41 UTC (rev 6507)
@@ -1,4 +1,6 @@
version 0.99.2 (not yet released)
+ * Now can specify just lon_0 for all cylindrical projections
+ (to produce global map centered on lon_0).
* Added save_background.py example, showing how to re-use
a map background without redrawing coastlines.
* Added embedding_map_in_wx.py example (courtesy of
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-08 12:31:06 UTC (rev 6506)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-08 12:44:41 UTC (rev 6507)
@@ -261,8 +261,9 @@
================ ====================================================
Keyword Description
================ ====================================================
- lat_ts latitude of true scale for mercator projection,
+ lat_ts latitude of true scale.
optional for stereographic projection.
+ mandatory for mercator projection.
lat_1 first standard parallel for lambert conformal,
albers equal area and equidistant conic.
Latitude of one of the two points on the projection
@@ -532,24 +533,6 @@
llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams)
self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat
self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat
- elif projection == 'merc':
- if lat_ts is None:
- raise ValueError, 'must specify lat_ts for Mercator basemap'
- # clip plot region to be within -89.99S to 89.99N
- # (mercator is singular at poles)
- if not using_corners:
- llcrnrlon = -180.
- llcrnrlat = -90.
- urcrnrlon = 180
- urcrnrlat = 90.
- if llcrnrlat < -89.99: llcrnrlat = -89.99
- if llcrnrlat > 89.99: llcrnrlat = 89.99
- if urcrnrlat < -89.99: urcrnrlat = -89.99
- if urcrnrlat > 89.99: urcrnrlat = 89.99
- self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat
- self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat
- if width is not None or height is not None:
- print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection]
elif projection in ['tmerc','gnom','cass','poly'] :
if projection == 'gnom' and not projparams.has_key('R'):
raise ValueError, 'gnomonic projection only works for perfect spheres - not ellipsoids'
@@ -640,26 +623,29 @@
llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams)
self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat
self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat
- elif projection in ['mill','gall']:
+ elif projection in _cylproj:
if not using_corners:
- llcrnrlon = -180.
llcrnrlat = -90.
- urcrnrlon = 180
urcrnrlat = 90.
+ if lon_0 is not None:
+ llcrnrlon = lon_0-180.
+ urcrnrlon = lon_0+180.
+ else:
+ llcrnrlon = -180.
+ urcrnrlon = 180
+ if projection == 'merc':
+ if lat_ts is None:
+ raise ValueError, 'must specify lat_ts for Mercator basemap'
+ # clip plot region to be within -89.99S to 89.99N
+ # (mercator is singular at poles)
+ if llcrnrlat < -89.99: llcrnrlat = -89.99
+ if llcrnrlat > 89.99: llcrnrlat = 89.99
+ if urcrnrlat < -89.99: urcrnrlat = -89.99
+ if urcrnrlat > 89.99: urcrnrlat = 89.99
self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat
self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat
if width is not None or height is not None:
print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection]
- elif projection == 'cyl':
- if not using_corners:
- llcrnrlon = -180.
- llcrnrlat = -90.
- urcrnrlon = 180
- urcrnrlat = 90.
- self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat
- self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat
- if width is not None or height is not None:
- print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection]
else:
raise ValueError(_unsupported_projection % projection)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-12-08 12:52:33
|
Revision: 6508
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6508&view=rev
Author: jswhit
Date: 2008-12-08 12:52:29 +0000 (Mon, 08 Dec 2008)
Log Message:
-----------
lat_ts now defaults to 0 for mercator.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-12-08 12:44:41 UTC (rev 6507)
+++ trunk/toolkits/basemap/Changelog 2008-12-08 12:52:29 UTC (rev 6508)
@@ -1,4 +1,5 @@
version 0.99.2 (not yet released)
+ * Made lat_ts default to 0 for mercator.
* Now can specify just lon_0 for all cylindrical projections
(to produce global map centered on lon_0).
* Added save_background.py example, showing how to re-use
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-08 12:44:41 UTC (rev 6507)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-08 12:52:29 UTC (rev 6508)
@@ -261,9 +261,10 @@
================ ====================================================
Keyword Description
================ ====================================================
- lat_ts latitude of true scale.
- optional for stereographic projection.
- mandatory for mercator projection.
+ lat_ts latitude of true scale. Optional for stereographic
+ and mercator projections.
+ default is lat_0 for stereographic projection.
+ default is 0 for mercator projection.
lat_1 first standard parallel for lambert conformal,
albers equal area and equidistant conic.
Latitude of one of the two points on the projection
@@ -285,7 +286,7 @@
not be rotated to true North. Default is False
(projection coordinates are automatically rotated).
lat_0 central latitude (y-axis origin) - used by all
- projections, Must be equator for mercator projection.
+ projections.
lon_0 central meridian (x-axis origin) - used by all
projections.
boundinglat bounding latitude for pole-centered projections
@@ -624,6 +625,10 @@
self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat
self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat
elif projection in _cylproj:
+ if projection == 'merc':
+ if lat_ts is None:
+ lat_ts = 0.
+ projparams['lat_ts']=lat_ts
if not using_corners:
llcrnrlat = -90.
urcrnrlat = 90.
@@ -634,8 +639,7 @@
llcrnrlon = -180.
urcrnrlon = 180
if projection == 'merc':
- if lat_ts is None:
- raise ValueError, 'must specify lat_ts for Mercator basemap'
+ if lat_ts is None: lat_ts = 0.
# clip plot region to be within -89.99S to 89.99N
# (mercator is singular at poles)
if llcrnrlat < -89.99: llcrnrlat = -89.99
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-12-08 14:53:59
|
Revision: 6509
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6509&view=rev
Author: jswhit
Date: 2008-12-08 14:53:55 +0000 (Mon, 08 Dec 2008)
Log Message:
-----------
added low resolution option for blue marble background.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Added Paths:
-----------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/data/bmng_low.jpg
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-12-08 12:52:29 UTC (rev 6508)
+++ trunk/toolkits/basemap/Changelog 2008-12-08 14:53:55 UTC (rev 6509)
@@ -1,4 +1,5 @@
version 0.99.2 (not yet released)
+ * added half resolution blue marble image (resolution='low')
* Made lat_ts default to 0 for mercator.
* Now can specify just lon_0 for all cylindrical projections
(to produce global map centered on lon_0).
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-08 12:52:29 UTC (rev 6508)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-08 14:53:55 UTC (rev 6509)
@@ -3135,17 +3135,17 @@
im = self.imshow(rgba,interpolation='nearest',ax=ax,**kwargs)
return im
- def bluemarble(self,ax=None):
+ def bluemarble(self,ax=None,resolution='high'):
"""
display blue marble image (from http://visibleearth.nasa.gov)
as map background.
"""
if ax is not None:
- self.warpimage(image='bluemarble',ax=ax)
+ self.warpimage(image='bluemarble',ax=ax,resolution=resolution)
else:
- self.warpimage(image='bluemarble')
+ self.warpimage(image='bluemarble',resolution=resolution)
- def warpimage(self,image="bluemarble",**kwargs):
+ def warpimage(self,image="bluemarble",resolution='high',**kwargs):
"""
Display an image (filename given by ``image`` keyword) as a map background.
If image is a URL (starts with 'http'), it is downloaded to a temp
@@ -3181,7 +3181,10 @@
# default image file is blue marble next generation
# from NASA (http://visibleearth.nasa.gov).
if image == "bluemarble":
- file = os.path.join(basemap_datadir,'bmng.jpg')
+ if resolution == 'low':
+ file = os.path.join(basemap_datadir,'bmng_low.jpg')
+ else:
+ file = os.path.join(basemap_datadir,'bmng.jpg')
else:
file = image
# if image is same as previous invocation, used cached data.
Added: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/data/bmng_low.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/data/bmng_low.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-12-08 16:31:53
|
Revision: 6513
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6513&view=rev
Author: jswhit
Date: 2008-12-08 16:31:48 +0000 (Mon, 08 Dec 2008)
Log Message:
-----------
added 'scale' keyword to bluemarble and warpimage to downsample background
image (replaces 'resolution' keyword from previous commit).
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/examples/warpimage.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Removed Paths:
-------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/data/bmng_low.jpg
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-12-08 16:10:50 UTC (rev 6512)
+++ trunk/toolkits/basemap/Changelog 2008-12-08 16:31:48 UTC (rev 6513)
@@ -1,5 +1,6 @@
version 0.99.2 (not yet released)
- * added half resolution blue marble image (resolution='low')
+ * added 'scale' keyword to bluemarble and warpimage methods to
+ downsample image background.
* Made lat_ts default to 0 for mercator.
* Now can specify just lon_0 for all cylindrical projections
(to produce global map centered on lon_0).
Modified: trunk/toolkits/basemap/examples/warpimage.py
===================================================================
--- trunk/toolkits/basemap/examples/warpimage.py 2008-12-08 16:10:50 UTC (rev 6512)
+++ trunk/toolkits/basemap/examples/warpimage.py 2008-12-08 16:31:48 UTC (rev 6513)
@@ -24,7 +24,7 @@
fig=plt.figure()
# define projection centered on North America.
m = Basemap(projection='mbtfpq',lon_0=-100,resolution='l')
-m.bluemarble(resolution='low')
+m.bluemarble(scale=0.5)
# draw coastlines.
m.drawcoastlines(linewidth=0.5,color='0.5')
# draw lat/lon grid lines every 30 degrees.
@@ -38,7 +38,7 @@
# define cylindrical equidistant projection.
m = Basemap(projection='cyl',llcrnrlon=-180,llcrnrlat=-90,urcrnrlon=180,urcrnrlat=90,resolution='l')
# plot (unwarped) rgba image.
-im = m.bluemarble(resolution='low')
+im = m.bluemarble(scale=0.5)
# draw coastlines.
m.drawcoastlines(linewidth=0.5,color='0.5')
# draw lat/lon grid lines.
@@ -52,7 +52,7 @@
# define cylindrical equidistant projection.
m = Basemap(projection='cyl',llcrnrlon=0,llcrnrlat=-60,urcrnrlon=360,urcrnrlat=60,resolution='l')
# plot (unwarped) rgba image.
-im = m.bluemarble(resolution='low')
+im = m.bluemarble(scale=0.5)
# draw coastlines.
m.drawcoastlines(linewidth=0.5,color='0.5')
# draw lat/lon grid lines.
@@ -81,7 +81,7 @@
m = Basemap(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
rsphere=(6378137.00,6356752.3142),lat_1=50.,lon_0=-107.,\
resolution='i',area_thresh=1000.,projection='lcc')
-im = m.bluemarble(resolution='low')
+im = m.bluemarble(scale=0.5)
# draw coastlines.
m.drawcoastlines(linewidth=0.5,color='0.5')
# draw parallels and meridians.
@@ -100,7 +100,7 @@
resolution=None,projection='omerc',\
lon_0=-100,lat_0=15,lon_2=-120,lat_2=65,lon_1=-50,lat_1=-55)
# plot warped rgba image.
-im = m.bluemarble(resolution='low')
+im = m.bluemarble(scale=0.5)
# draw lat/lon grid lines every 20 degrees.
m.drawmeridians(np.arange(0,360,20),color='0.5')
m.drawparallels(np.arange(-80,81,20),color='0.5')
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-08 16:10:50 UTC (rev 6512)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-08 16:31:48 UTC (rev 6513)
@@ -3135,17 +3135,20 @@
im = self.imshow(rgba,interpolation='nearest',ax=ax,**kwargs)
return im
- def bluemarble(self,ax=None,resolution='high'):
+ def bluemarble(self,ax=None,scale=None):
"""
display blue marble image (from http://visibleearth.nasa.gov)
as map background.
+ Default image size is 5400x2700, which can be quite slow and
+ use quite a bit of memory. The ``scale`` keyword can be used
+ to downsample the image (``scale=0.5`` downsamples to 2700x1350).
"""
if ax is not None:
- self.warpimage(image='bluemarble',ax=ax,resolution=resolution)
+ self.warpimage(image='bluemarble',ax=ax,scale=scale)
else:
- self.warpimage(image='bluemarble',resolution=resolution)
+ self.warpimage(image='bluemarble',scale=scale)
- def warpimage(self,image="bluemarble",resolution='high',**kwargs):
+ def warpimage(self,image="bluemarble",scale=None,**kwargs):
"""
Display an image (filename given by ``image`` keyword) as a map background.
If image is a URL (starts with 'http'), it is downloaded to a temp
@@ -3159,6 +3162,10 @@
Works with the global images from
http://earthobservatory.nasa.gov/Features/BlueMarble/BlueMarble_monthlies.php.
+ The ``scale`` keyword can be used to downsample (rescale) the image.
+ Values less than 1.0 will speed things up at the expense of image
+ resolution.
+
Extra keyword ``ax`` can be used to override the default axis instance.
\**kwargs passed on to :meth:`imshow`.
@@ -3181,10 +3188,7 @@
# default image file is blue marble next generation
# from NASA (http://visibleearth.nasa.gov).
if image == "bluemarble":
- if resolution == 'low':
- file = os.path.join(basemap_datadir,'bmng_low.jpg')
- else:
- file = os.path.join(basemap_datadir,'bmng.jpg')
+ file = os.path.join(basemap_datadir,'bmng.jpg')
else:
file = image
# if image is same as previous invocation, used cached data.
@@ -3206,6 +3210,11 @@
# read in jpeg image to rgba array of normalized floats.
if not hasattr(self,'_bm_rgba') or newfile:
pilImage = Image.open(self._bm_file)
+ if scale is not None:
+ w, h = pilImage.size
+ width = int(np.round(w*scale))
+ height = int(np.round(h*scale))
+ pilImage = pilImage.resize((width,height),Image.ANTIALIAS)
self._bm_rgba = pil_to_array(pilImage)
# define lat/lon grid that image spans.
nlons = self._bm_rgba.shape[1]; nlats = self._bm_rgba.shape[0]
Deleted: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/data/bmng_low.jpg
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-12-08 17:00:15
|
Revision: 6514
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6514&view=rev
Author: jswhit
Date: 2008-12-08 17:00:12 +0000 (Mon, 08 Dec 2008)
Log Message:
-----------
fix drawlsmask so it works for cylindrical projections that have limits
outside -180,180
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-12-08 16:31:48 UTC (rev 6513)
+++ trunk/toolkits/basemap/Changelog 2008-12-08 17:00:12 UTC (rev 6514)
@@ -1,4 +1,6 @@
version 0.99.2 (not yet released)
+ * fix drawlsmask method so that it works for cylindrical
+ projections with limits outside (-180,180).
* added 'scale' keyword to bluemarble and warpimage methods to
downsample image background.
* Made lat_ts default to 0 for mercator.
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-08 16:31:48 UTC (rev 6513)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-08 17:00:12 UTC (rev 6514)
@@ -3082,12 +3082,25 @@
lsmask_lats = np.arange(-90.+0.5*delta,90.,delta)
lsmask = np.reshape(np.fromstring(lsmaskf.read(),np.uint8),(nlats,nlons))
lsmaskf.close()
- # instance variable lsmask is set on first invocation,
- # it contains the land-sea mask interpolated to the native
- # projection grid. Further calls to drawlsmask will not
- # redo the interpolation (unless a new land-sea mask is passed
- # in via the lsmask, lsmask_lons, lsmask_lats keywords).
+ # instance variable lsmask is set on first invocation,
+ # it contains the land-sea mask interpolated to the native
+ # projection grid. Further calls to drawlsmask will not
+ # redo the interpolation (unless a new land-sea mask is passed
+ # in via the lsmask, lsmask_lons, lsmask_lats keywords).
+ # is it a cylindrical projection whose limits lie
+ # outside the limits of the image?
+ cylproj = self.projection in _cylproj and \
+ (self.urcrnrlon > lsmask_lons[-1] or \
+ self.llcrnrlon < lsmask_lons[0])
+ if cylproj:
+ # stack grids side-by-side (in longitiudinal direction), so
+ # any range of longitudes may be plotted on a world map.
+ lsmask_lons = \
+ np.concatenate((lsmask_lons,lsmask_lons+360),1)
+ lsmask = \
+ np.concatenate((lsmask,lsmask),1)
+
# transform mask to nx x ny regularly spaced native projection grid
# nx and ny chosen to have roughly the same horizontal
# resolution as mask.
@@ -3097,7 +3110,7 @@
if self.projection == 'cyl':
dx = lsmask_lons[1]-lsmask_lons[0]
else:
- dx = 2.*math.pi*self.rmajor/float(nlons)
+ dx = (np.pi/180.)*(lsmask_lons[1]-lsmask_lons[0])*self.rmajor
nx = int((self.xmax-self.xmin)/dx)+1; ny = int((self.ymax-self.ymin)/dx)+1
# interpolate rgba values from proj='cyl' (geographic coords)
# to a rectangular map projection grid.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-12-12 12:22:20
|
Revision: 6576
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6576&view=rev
Author: jswhit
Date: 2008-12-12 12:22:15 +0000 (Fri, 12 Dec 2008)
Log Message:
-----------
bump version number, have bluemarble pass kwargs to imshow, return
Image instance.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
trunk/toolkits/basemap/setup.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-12-12 03:33:51 UTC (rev 6575)
+++ trunk/toolkits/basemap/Changelog 2008-12-12 12:22:15 UTC (rev 6576)
@@ -1,3 +1,5 @@
+version 0.99.3 (not yet released)
+ * bluemarble: pass kwargs to imshow, return Image instance.
version 0.99.2 (svn revision 6541)
* fix drawlsmask method so that it works for cylindrical
projections with limits outside (-180,180).
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-12 03:33:51 UTC (rev 6575)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-12 12:22:15 UTC (rev 6576)
@@ -41,7 +41,7 @@
# basemap data files now installed in lib/matplotlib/toolkits/basemap/data
basemap_datadir = os.sep.join([os.path.dirname(__file__), 'data'])
-__version__ = '0.99.2'
+__version__ = '0.99.3'
# supported map projections.
_projnames = {'cyl' : 'Cylindrical Equidistant',
@@ -3148,7 +3148,7 @@
im = self.imshow(rgba,interpolation='nearest',ax=ax,**kwargs)
return im
- def bluemarble(self,ax=None,scale=None):
+ def bluemarble(self,ax=None,scale=None,**kwargs):
"""
display blue marble image (from http://visibleearth.nasa.gov)
as map background.
@@ -3157,9 +3157,9 @@
to downsample the image (``scale=0.5`` downsamples to 2700x1350).
"""
if ax is not None:
- self.warpimage(image='bluemarble',ax=ax,scale=scale)
+ return self.warpimage(image='bluemarble',ax=ax,scale=scale,**kwargs)
else:
- self.warpimage(image='bluemarble',scale=scale)
+ return self.warpimage(image='bluemarble',scale=scale,**kwargs)
def warpimage(self,image="bluemarble",scale=None,**kwargs):
"""
@@ -3312,10 +3312,10 @@
# make points outside projection limb transparent.
self._bm_rgba_warped = self._bm_rgba_warped.filled(0.)
# plot warped rgba image.
- im = self.imshow(self._bm_rgba_warped,ax=ax)
+ im = self.imshow(self._bm_rgba_warped,ax=ax,**kwargs)
else:
# bmproj True, no interpolation necessary.
- im = self.imshow(self._bm_rgba,ax=ax)
+ im = self.imshow(self._bm_rgba,ax=ax,**kwargs)
return im
def drawmapscale(self,lon,lat,lon0,lat0,length,barstyle='simple',\
Modified: trunk/toolkits/basemap/setup.py
===================================================================
--- trunk/toolkits/basemap/setup.py 2008-12-12 03:33:51 UTC (rev 6575)
+++ trunk/toolkits/basemap/setup.py 2008-12-12 12:22:15 UTC (rev 6576)
@@ -182,7 +182,7 @@
print 'will not install httplib2'
# Specify all the required mpl data
-pyproj_datafiles = ['data/epsg', 'data/esri', 'data/esri.extra', 'data/GL27', 'data/nad.lst', 'data/nad27', 'data/nad83', 'data/ntv2_out.dist', 'data/other.extra', 'data/pj_out27.dist', 'data/pj_out83.dist', 'data/proj_def.dat', 'data/README', 'data/td_out.dist', 'data/test27', 'data/test83', 'data/testntv2', 'data/testvarious', 'data/world','data/bmng.jpg']
+pyproj_datafiles = ['data/epsg', 'data/esri', 'data/esri.extra', 'data/GL27', 'data/nad.lst', 'data/nad27', 'data/nad83', 'data/ntv2_out.dist', 'data/other.extra', 'data/pj_out27.dist', 'data/pj_out83.dist', 'data/proj_def.dat', 'data/README', 'data/td_out.dist', 'data/test27', 'data/test83', 'data/testntv2', 'data/testvarious', 'data/world','data/bmng.jpg','data/bmng_low.jpg']
boundaryfiles = []
for resolution in ['c','l','i','h','f']:
boundaryfiles = boundaryfiles + glob.glob("lib/mpl_toolkits/basemap/data/*_"+resolution+".dat")
@@ -191,7 +191,7 @@
package_data = {'mpl_toolkits.basemap':pyproj_datafiles+basemap_datafiles}
setup(
name = "basemap",
- version = "0.99.2",
+ version = "0.99.3",
description = "Plot data on map projections with matplotlib",
long_description = """
An add-on toolkit for matplotlib that lets you plot data
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|