From: <js...@us...> - 2007-11-13 22:23:35
|
Revision: 4257 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4257&view=rev Author: jswhit Date: 2007-11-13 14:23:33 -0800 (Tue, 13 Nov 2007) Log Message: ----------- fixes so Basemap instance can be pickled again Modified Paths: -------------- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py trunk/toolkits/basemap-testing/setup.py Added Paths: ----------- trunk/toolkits/basemap-testing/src/_geos.c trunk/toolkits/basemap-testing/src/_geos.pyx Removed Paths: ------------- trunk/toolkits/basemap-testing/src/geos.c trunk/toolkits/basemap-testing/src/geos.pyx Modified: trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-13 21:29:33 UTC (rev 4256) +++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-13 22:23:33 UTC (rev 4257) @@ -14,9 +14,7 @@ from numpy import linspace, squeeze, ma from matplotlib.cbook import popd, is_scalar from shapelib import ShapeFile -from geos import Polygon as PolygonShape -from geos import LineString as LineShape -from geos import Point as PointShape +import _geos # basemap data files now installed in lib/matplotlib/toolkits/basemap/data basemap_datadir = os.sep.join([os.path.dirname(__file__), 'data']) @@ -31,7 +29,7 @@ transverse mercator, miller cylindrical, lambert conformal conic, azimuthal equidistant, equidistant conic, lambert azimuthal equal area, albers equal area conic, gnomonic, orthographic, sinusoidal, mollweide, - geostationary, robinson, cassini-soldner or stereographic). + _geostationary, robinson, cassini-soldner or stereographic). Doesn't actually draw anything, but sets up the map projection class and creates the coastline, lake river and political boundary data structures in native map projection coordinates. @@ -42,7 +40,7 @@ projection - map projection ('cyl','merc','mill','lcc','eqdc','aea', 'laea', 'nplaea', 'splaea', 'tmerc', 'omerc', 'cass', 'gnom', 'poly', 'sinu', 'moll', 'ortho', 'robin', 'aeqd', 'npaeqd', 'spaeqd', 'stere', - 'geos', 'npstere' or 'spstere') + '_geos', 'npstere' or 'spstere') (projections prefixed with 'np' or 'sp' are special case polar-centric versions of the parent projection) aspect - map aspect ratio (size of y dimension / size of x dimension). @@ -112,7 +110,7 @@ 'cass' - cassini-soldner (transverse cylindrical equidistant), 'poly' - polyconic, 'omerc' - oblique mercator, 'ortho' - orthographic, 'sinu' - sinusoidal, 'moll' - mollweide, 'robin' - robinson, - 'geos' - geostationary, and 'gnom' - gnomonic are currently available. + '_geos' - _geostationary, and 'gnom' - gnomonic are currently available. Default is 'cyl'. The map projection region can either be specified by setting these keywords: @@ -135,9 +133,9 @@ either they are computed internally, or entire globe is always plotted). For the cylindrical projections ('cyl','merc' and 'mill'), the default is to use llcrnrlon=-180,llcrnrlat=-90, urcrnrlon=180 and urcrnrlat=90). For all other - projections except 'ortho' and 'geos', either the lat/lon values of the + projections except 'ortho' and '_geos', either the lat/lon values of the corners or width and height must be specified by the user. - For 'ortho' and 'geos', the lat/lon values of the corners may be specified, + For 'ortho' and '_geos', the lat/lon values of the corners may be specified, but if they are not, the entire globe is plotted. resolution - resolution of boundary database to use. Can be 'c' (crude), @@ -210,7 +208,7 @@ on the north or south pole. The longitude lon_0 is at 6-o'clock, and the latitude circle boundinglat is tangent to the edge of the map at lon_0. satellite_height - height of satellite (in m) above equator - - only relevant for geostationary projections ('geos'). + only relevant for _geostationary projections ('_geos'). """ @@ -504,7 +502,7 @@ # FIXME: won't work for points exactly on equator?? if npy.abs(lat_0) < 1.e-2: lat_0 = 1.e-2 projparams['lat_0'] = lat_0 - elif projection == 'geos': + elif projection == '_geos': if lon_0 is None and satellite_height is None: raise ValueError, 'must specify lon_0 and satellite_height for Geostationary basemap' if width is not None or height is not None: @@ -593,7 +591,7 @@ 'splaea' - lambert azimuthal, special case centered on south pole, 'cass' - cassini-soldner (transverse cylindrical equidistant), 'poly' - polyconic, 'omerc' - oblique mercator, 'ortho' - orthographic, - 'geos' - geostationary, 'sinu' - sinusoidal, 'moll' - mollweide, + '_geos' - _geostationary, 'sinu' - sinusoidal, 'moll' - mollweide, 'robin' - robinson, or 'gnom' - gnomonic. You tried '%s'""" % projection # initialize proj4 @@ -608,7 +606,7 @@ atts = ['rmajor','rminor','esq','flattening','ellipsoid','projparams'] for att in atts: self.__dict__[att] = proj.__dict__[att] - # these only exist for geostationary projection. + # these only exist for _geostationary projection. if hasattr(proj,'_width'): self.__dict__['_width'] = proj.__dict__['_width'] if hasattr(proj,'_height'): @@ -647,7 +645,7 @@ if projection in ['mill','cyl','merc']: self.latmin = self.llcrnrlat self.latmax = self.urcrnrlat - elif projection in ['ortho','geos','moll','robin','sinu']: + elif projection in ['ortho','_geos','moll','robin','sinu']: self.latmin = -90. self.latmax = 90. else: @@ -748,12 +746,12 @@ polygon_types = [] # coastlines are polygons, other boundaries are line segments. if name == 'gshhs': - Shape = PolygonShape + Shape = _geos.Polygon else: - Shape = LineShape + Shape = _geos.LineString # see if map projection region polygon contains a pole. - NPole = PointShape(self(0.,90.)) - SPole = PointShape(self(0.,-90.)) + NPole = _geos.Point(self(0.,90.)) + SPole = _geos.Point(self(0.,-90.)) boundarypolyxy = self._boundarypolyxy boundarypolyll = self._boundarypolyll hasNP = NPole.within(boundarypolyxy) @@ -761,7 +759,7 @@ containsPole = hasNP or hasSP # these projections cannot cross pole. if containsPole and\ - self.projection in ['tmerc','cass','omerc','merc','mill','cyl','robin','moll','sinu','geos']: + self.projection in ['tmerc','cass','omerc','merc','mill','cyl','robin','moll','sinu','_geos']: raise ValueError('%s projection cannot cross pole'%(self.projection)) # make sure orthographic projection has containsPole=True @@ -777,7 +775,7 @@ b = self._boundarypolyll.get_coords() blons = b[:,0]; blats = b[:,1] b[:,0], b[:,1] = maptran(blons, blats) - boundarypolyxy = PolygonShape(b) + boundarypolyxy = _geos.Polygon(b) for line in bdatmetafile: linesplit = line.split() area = float(linesplit[1]) @@ -824,7 +822,7 @@ lats.append(-90.) b = npy.empty((len(lons),2),npy.float64) b[:,0] = lons; b[:,1] = lats - poly = PolygonShape(b) + poly = _geos.Polygon(b) antart = True else: poly = Shape(b) @@ -934,7 +932,7 @@ nx = 100 ny = 100 maptran = self - if self.projection in ['ortho','geos']: + if self.projection in ['ortho','_geos']: # circular region. thetas = linspace(0.,2.*npy.pi,2*nx*ny)[:-1] if self.projection == 'ortho': @@ -947,7 +945,7 @@ y = rminor*npy.sin(thetas) + rminor b = npy.empty((len(x),2),npy.float64) b[:,0]=x; b[:,1]=y - boundaryxy = PolygonShape(b) + boundaryxy = _geos.Polygon(b) # compute proj instance for full disk, if necessary. if not self._fulldisk: projparms = self.projparams @@ -986,7 +984,7 @@ x, y = maptran(lons,lats) b = npy.empty((len(x),2),npy.float64) b[:,0]=x; b[:,1]=y - boundaryxy = PolygonShape(b) + boundaryxy = _geos.Polygon(b) else: # all other projections are rectangular. # left side (x = xmin, ymin <= y <= ymax) yy = linspace(self.ymin, self.ymax, ny)[:-1] @@ -1007,7 +1005,7 @@ b = npy.empty((4,2),npy.float64) b[:,0]=[self.xmin,self.xmin,self.xmax,self.xmax] b[:,1]=[self.ymin,self.ymax,self.ymax,self.ymin] - boundaryxy = PolygonShape(b) + boundaryxy = _geos.Polygon(b) if self.projection in ['mill','merc','cyl']: # make sure map boundary doesn't quite include pole. if self.urcrnrlat > 89.9999: @@ -1023,7 +1021,7 @@ x, y = self(lons, lats) b = npy.empty((len(x),2),npy.float64) b[:,0]=x; b[:,1]=y - boundaryxy = PolygonShape(b) + boundaryxy = _geos.Polygon(b) else: if self.projection not in ['moll','robin','sinu']: lons, lats = maptran(x,y,inverse=True) @@ -1041,7 +1039,7 @@ n = n + 1 b = npy.empty((len(lons),2),npy.float64) b[:,0]=lons; b[:,1]=lats - boundaryll = PolygonShape(b) + boundaryll = _geos.Polygon(b) return boundaryll, boundaryxy @@ -1067,7 +1065,7 @@ circle.set_edgecolor(color) circle.set_linewidth(linewidth) circle.set_clip_on(False) - elif self.projection == 'geos' and self._fulldisk: # elliptical region + elif self.projection == '_geos' and self._fulldisk: # elliptical region # define an Ellipse patch, add it to axes instance. ellps = Ellipse((self._width,self._height),2.*self._width,2.*self._height) ax.add_patch(ellps) @@ -1509,8 +1507,8 @@ l.set_zorder(zorder) ax.add_line(l) # draw labels for parallels - # parallels not labelled for fulldisk orthographic or geostationary - if self.projection in ['ortho','geos'] and max(labels): + # 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' labels = [0,0,0,0] @@ -1716,11 +1714,11 @@ ax.add_line(l) # draw labels for meridians. # meridians not labelled for sinusoidal, mollweide, or - # or full-disk orthographic/geostationary. + # or full-disk orthographic/_geostationary. if self.projection in ['sinu','moll'] and max(labels): print 'Warning: Cannot label meridians on Sinusoidal or Mollweide basemap' labels = [0,0,0,0] - if self.projection in ['ortho','geos'] and max(labels): + if self.projection in ['ortho','_geos'] and max(labels): if self._fulldisk: print 'Warning: Cannot label meridians on full-disk Geostationary or Orthographic basemap' labels = [0,0,0,0] @@ -2074,7 +2072,7 @@ # turn off axes frame for non-rectangular projections. if self.projection in ['moll','robin','sinu']: ax.set_frame_on(False) - if self.projection in ['ortho','geos'] and self._fulldisk: + if self.projection in ['ortho','_geos'] and self._fulldisk: ax.set_frame_on(False) # make sure aspect ratio of map preserved. # plot is re-centered in bounding rectangle. Modified: trunk/toolkits/basemap-testing/setup.py =================================================================== --- trunk/toolkits/basemap-testing/setup.py 2007-11-13 21:29:33 UTC (rev 4256) +++ trunk/toolkits/basemap-testing/setup.py 2007-11-13 22:23:33 UTC (rev 4257) @@ -37,16 +37,19 @@ geos_include_dirs=[os.path.join(GEOS_dir,'include'),numpy.get_include()] geos_library_dirs=[os.path.join(GEOS_dir,'lib')] +# proj4 and geos extensions. deps = glob.glob('src/*.c') deps.remove(os.path.join('src','_proj.c')) deps.remove(os.path.join('src','_geod.c')) -deps.remove(os.path.join('src','geos.c')) +deps.remove(os.path.join('src','_geos.c')) packages = ['matplotlib.toolkits.basemap'] package_dirs = {'':'lib'} extensions = [Extension("matplotlib.toolkits.basemap._proj",deps+['src/_proj.c'],include_dirs = ['src'],)] extensions.append(Extension("matplotlib.toolkits.basemap._geod",deps+['src/_geod.c'],include_dirs = ['src'],)) -extensions.append(Extension("matplotlib.toolkits.basemap.geos",deps+['src/geos.c'],library_dirs=geos_library_dirs,include_dirs=geos_include_dirs,runtime_library_dirs=geos_library_dirs,libraries=['geos_c'])) +# for some reason, pickling won't work if this extension is installed +# as "matplotlib.toolkits.basemap._geos" +extensions.append(Extension("_geos",deps+['src/_geos.c'],library_dirs=geos_library_dirs,include_dirs=geos_include_dirs,runtime_library_dirs=geos_library_dirs,libraries=['geos_c'])) # install shapelib and dbflib. packages = packages + ['shapelib','dbflib'] Added: trunk/toolkits/basemap-testing/src/_geos.c =================================================================== --- trunk/toolkits/basemap-testing/src/_geos.c (rev 0) +++ trunk/toolkits/basemap-testing/src/_geos.c 2007-11-13 22:23:33 UTC (rev 4257) @@ -0,0 +1,3230 @@ +/* Generated by Cython 0.9.6.7 on Tue Nov 13 15:19:22 2007 */ + +#define PY_SSIZE_T_CLEAN +#include "Python.h" +#include "structmember.h" +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#if PY_VERSION_HEX < 0x02050000 + typedef int Py_ssize_t; + #define PY_SSIZE_T_MAX INT_MAX + #define PY_SSIZE_T_MIN INT_MIN + #define PyInt_FromSsize_t(z) PyInt_FromLong(z) + #define PyInt_AsSsize_t(o) PyInt_AsLong(o) + #define PyNumber_Index(o) PyNumber_Int(o) + #define PyIndex_Check(o) PyNumber_Check(o) +#endif +#ifdef __cplusplus +#define __PYX_EXTERN_C extern "C" +#else +#define __PYX_EXTERN_C extern +#endif +__PYX_EXTERN_C double pow(double, double); +#include "numpy/arrayobject.h" +#include "geos_c.h" + + +#ifdef __GNUC__ +#define INLINE __inline__ +#elif _WIN32 +#define INLINE __inline +#else +#define INLINE +#endif + +typedef struct {const char *s; const void **p;} __Pyx_CApiTabEntry; /*proto*/ +typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ +typedef struct {PyObject **p; char *s; long n; int is_unicode;} __Pyx_StringTabEntry; /*proto*/ + +#define __pyx_PyIndex_AsSsize_t(b) PyInt_AsSsize_t(PyNumber_Index(b)) + +#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) +static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + if (x == Py_True) return 1; + else if (x == Py_False) return 0; + else return PyObject_IsTrue(x); +} + + +#ifdef __GNUC__ +/* Test for GCC > 2.95 */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) +#else /* __GNUC__ > 2 ... */ +#define likely(x) (x) +#define unlikely(x) (x) +#endif /* __GNUC__ > 2 ... */ +#else /* __GNUC__ */ +#define likely(x) (x) +#define unlikely(x) (x) +#endif /* __GNUC__ */ + +static PyObject *__pyx_m; +static PyObject *__pyx_b; +static int __pyx_lineno; +static char *__pyx_filename; +static char **__pyx_f; + +static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/ + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ + +static PyObject *__Pyx_GetExcValue(void); /*proto*/ + +static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ + +static void __Pyx_WriteUnraisable(char *name); /*proto*/ + +static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ + +static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ + +static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/ + +static void __Pyx_AddTraceback(char *funcname); /*proto*/ + +/* Declarations from _geos */ + + +struct __pyx_obj_5_geos_BaseGeometry { + PyObject_HEAD + GEOSGeom (*_geom); + unsigned int _npts; + PyObject *boundary; +}; + + +struct __pyx_obj_5_geos_Polygon { + struct __pyx_obj_5_geos_BaseGeometry __pyx_base; +}; + + +struct __pyx_obj_5_geos_LineString { + struct __pyx_obj_5_geos_BaseGeometry __pyx_base; +}; + + +struct __pyx_obj_5_geos_Point { + struct __pyx_obj_5_geos_BaseGeometry __pyx_base; + PyObject *x; + PyObject *y; +}; + +static PyTypeObject *__pyx_ptype_5_geos_ndarray = 0; +static PyTypeObject *__pyx_ptype_5_geos_BaseGeometry = 0; +static PyTypeObject *__pyx_ptype_5_geos_Polygon = 0; +static PyTypeObject *__pyx_ptype_5_geos_LineString = 0; +static PyTypeObject *__pyx_ptype_5_geos_Point = 0; +static PyArrayObject *__pyx_k4; +static PyArrayObject *__pyx_k5; +static PyObject *__pyx_k6; +static void (__pyx_f_5_geos_notice_h(char (*),char (*))); /*proto*/ +static void (__pyx_f_5_geos_error_h(char (*),char (*))); /*proto*/ +static PyObject *(__pyx_f_5_geos__add_geom(struct __pyx_obj_5_geos_BaseGeometry *,GEOSGeom (*))); /*proto*/ +static PyObject *(__pyx_f_5_geos__get_coords(GEOSGeom (*))); /*proto*/ + + +/* Implementation of _geos */ + +static char (__pyx_k3[]) = "0.1"; + +static PyObject *__pyx_n_sys; +static PyObject *__pyx_n_numpy; +static PyObject *__pyx_n___version__; +static PyObject *__pyx_n_is_valid; +static PyObject *__pyx_n_geom_type; +static PyObject *__pyx_n_within; +static PyObject *__pyx_n_intersects; +static PyObject *__pyx_n_intersection; +static PyObject *__pyx_n_get_coords; +static PyObject *__pyx_n___dealloc__; +static PyObject *__pyx_n___reduce__; +static PyObject *__pyx_n___init__; +static PyObject *__pyx_n_area; + +static PyObject *__pyx_k3p; + +static PyObject *__pyx_n_stdout; +static PyObject *__pyx_n_write; + +static PyObject *__pyx_k7p; + +static char (__pyx_k7[]) = "GEOS_NOTICE: %s\n"; + +static void __pyx_f_5_geos_notice_h(char (*__pyx_v_fmt),char (*__pyx_v_msg)) { + PyObject *__pyx_v_format; + PyObject *__pyx_v_message; + PyObject *__pyx_v_warn_msg; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + __pyx_v_format = Py_None; Py_INCREF(Py_None); + __pyx_v_message = Py_None; Py_INCREF(Py_None); + __pyx_v_warn_msg = Py_None; Py_INCREF(Py_None); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":100 + * + * 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 = 100; goto __pyx_L1;} + Py_DECREF(__pyx_v_format); + __pyx_v_format = __pyx_1; + __pyx_1 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":101 + * 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 = 101; goto __pyx_L1;} + Py_DECREF(__pyx_v_message); + __pyx_v_message = __pyx_1; + __pyx_1 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":102 + * format = PyString_FromString(fmt) + * message = PyString_FromString(msg) + * try: # <<<<<<<<<<<<<< + * warn_msg = format % message + * except: + */ + /*try:*/ { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":103 + * 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 = 103; goto __pyx_L2;} + Py_DECREF(__pyx_v_warn_msg); + __pyx_v_warn_msg = __pyx_1; + __pyx_1 = 0; + } + goto __pyx_L3; + __pyx_L2:; + Py_XDECREF(__pyx_1); __pyx_1 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":104 + * try: + * warn_msg = format % message + * except: # <<<<<<<<<<<<<< + * warn_msg = format + * sys.stdout.write('GEOS_NOTICE: %s\n' % warn_msg) + */ + /*except:*/ { + __Pyx_AddTraceback("_geos.notice_h"); + __pyx_1 = __Pyx_GetExcValue(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":105 + * warn_msg = format % message + * except: + * warn_msg = format # <<<<<<<<<<<<<< + * sys.stdout.write('GEOS_NOTICE: %s\n' % warn_msg) + * + */ + Py_INCREF(__pyx_v_format); + Py_DECREF(__pyx_v_warn_msg); + __pyx_v_warn_msg = __pyx_v_format; + goto __pyx_L3; + } + __pyx_L3:; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":106 + * 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_n_sys); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_stdout); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_write); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_2 = PyNumber_Remainder(__pyx_k7p, __pyx_v_warn_msg); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); + __pyx_2 = 0; + __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_WriteUnraisable("_geos.notice_h"); + __pyx_L0:; + Py_DECREF(__pyx_v_format); + Py_DECREF(__pyx_v_message); + Py_DECREF(__pyx_v_warn_msg); +} + +static PyObject *__pyx_n_stderr; + +static PyObject *__pyx_k8p; + +static char (__pyx_k8[]) = "GEOS_ERROR: %s\n"; + +static void __pyx_f_5_geos_error_h(char (*__pyx_v_fmt),char (*__pyx_v_msg)) { + PyObject *__pyx_v_format; + PyObject *__pyx_v_message; + PyObject *__pyx_v_warn_msg; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + __pyx_v_format = Py_None; Py_INCREF(Py_None); + __pyx_v_message = Py_None; Py_INCREF(Py_None); + __pyx_v_warn_msg = Py_None; Py_INCREF(Py_None); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":109 + * + * 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 = 109; goto __pyx_L1;} + Py_DECREF(__pyx_v_format); + __pyx_v_format = __pyx_1; + __pyx_1 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":110 + * 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 = 110; goto __pyx_L1;} + Py_DECREF(__pyx_v_message); + __pyx_v_message = __pyx_1; + __pyx_1 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":111 + * format = PyString_FromString(fmt) + * message = PyString_FromString(msg) + * try: # <<<<<<<<<<<<<< + * warn_msg = format % message + * except: + */ + /*try:*/ { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":112 + * 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 = 112; goto __pyx_L2;} + Py_DECREF(__pyx_v_warn_msg); + __pyx_v_warn_msg = __pyx_1; + __pyx_1 = 0; + } + goto __pyx_L3; + __pyx_L2:; + Py_XDECREF(__pyx_1); __pyx_1 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":113 + * try: + * warn_msg = format % message + * except: # <<<<<<<<<<<<<< + * warn_msg = format + * sys.stderr.write('GEOS_ERROR: %s\n' % warn_msg) + */ + /*except:*/ { + __Pyx_AddTraceback("_geos.error_h"); + __pyx_1 = __Pyx_GetExcValue(); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":114 + * warn_msg = format % message + * except: + * warn_msg = format # <<<<<<<<<<<<<< + * sys.stderr.write('GEOS_ERROR: %s\n' % warn_msg) + * + */ + Py_INCREF(__pyx_v_format); + Py_DECREF(__pyx_v_warn_msg); + __pyx_v_warn_msg = __pyx_v_format; + goto __pyx_L3; + } + __pyx_L3:; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":115 + * except: + * warn_msg = format + * sys.stderr.write('GEOS_ERROR: %s\n' % warn_msg) # <<<<<<<<<<<<<< + * + * # intialize GEOS (parameters are notice and error function callbacks). + */ + __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_sys); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;} + __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_stderr); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_write); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + __pyx_2 = PyNumber_Remainder(__pyx_k8p, __pyx_v_warn_msg); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); + __pyx_2 = 0; + __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;} + Py_DECREF(__pyx_1); __pyx_1 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_2); __pyx_2 = 0; + + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_WriteUnraisable("_geos.error_h"); + __pyx_L0:; + Py_DECREF(__pyx_v_format); + Py_DECREF(__pyx_v_message); + Py_DECREF(__pyx_v_warn_msg); +} + +static PyObject *__pyx_f_py_5_geos_12BaseGeometry_is_valid(PyObject *__pyx_v_self, PyObject *unused); /*proto*/ +static PyObject *__pyx_f_py_5_geos_12BaseGeometry_is_valid(PyObject *__pyx_v_self, PyObject *unused) { + char __pyx_v_valid; + PyObject *__pyx_r; + char __pyx_1; + Py_INCREF(__pyx_v_self); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":127 + * def is_valid(self): + * cdef char valid + * valid = GEOSisValid(self._geom) # <<<<<<<<<<<<<< + * if valid: + * return True + */ + __pyx_v_valid = GEOSisValid(((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_self)->_geom); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":128 + * cdef char valid + * valid = GEOSisValid(self._geom) + * if valid: # <<<<<<<<<<<<<< + * return True + * else: + */ + __pyx_1 = __pyx_v_valid; + if (__pyx_1) { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":129 + * valid = GEOSisValid(self._geom) + * if valid: + * return True # <<<<<<<<<<<<<< + * else: + * return False + */ + Py_INCREF(Py_True); + __pyx_r = Py_True; + goto __pyx_L0; + goto __pyx_L2; + } + /*else*/ { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":131 + * return True + * else: + * return False # <<<<<<<<<<<<<< + * + * def geom_type(self): + */ + Py_INCREF(Py_False); + __pyx_r = Py_False; + goto __pyx_L0; + } + __pyx_L2:; + + __pyx_r = Py_None; Py_INCREF(Py_None); + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_py_5_geos_12BaseGeometry_geom_type(PyObject *__pyx_v_self, PyObject *unused); /*proto*/ +static PyObject *__pyx_f_py_5_geos_12BaseGeometry_geom_type(PyObject *__pyx_v_self, PyObject *unused) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":134 + * + * def geom_type(self): + * return PyString_FromString(GEOSGeomType(self._geom)) # <<<<<<<<<<<<<< + * + * def within(self, BaseGeometry geom): + */ + __pyx_1 = PyString_FromString(GEOSGeomType(((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_self)->_geom)); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_geos.BaseGeometry.geom_type"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_f_py_5_geos_12BaseGeometry_within(PyObject *__pyx_v_self, PyObject *__pyx_v_geom); /*proto*/ +static PyObject *__pyx_f_py_5_geos_12BaseGeometry_within(PyObject *__pyx_v_self, PyObject *__pyx_v_geom) { + GEOSGeom (*__pyx_v_g1); + GEOSGeom (*__pyx_v_g2); + char __pyx_v_answer; + PyObject *__pyx_r; + char __pyx_1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_geom); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_5_geos_BaseGeometry, 1, "geom"))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; goto __pyx_L1;} + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":139 + * cdef GEOSGeom *g1, *g2 + * cdef char answer + * g1 = self._geom # <<<<<<<<<<<<<< + * g2 = geom._geom + * answer = GEOSWithin(g1, g2) + */ + __pyx_v_g1 = ((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_self)->_geom; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":140 + * cdef char answer + * g1 = self._geom + * g2 = geom._geom # <<<<<<<<<<<<<< + * answer = GEOSWithin(g1, g2) + * if answer: + */ + __pyx_v_g2 = ((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_geom)->_geom; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":141 + * g1 = self._geom + * g2 = geom._geom + * answer = GEOSWithin(g1, g2) # <<<<<<<<<<<<<< + * if answer: + * return True + */ + __pyx_v_answer = GEOSWithin(__pyx_v_g1,__pyx_v_g2); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":142 + * g2 = geom._geom + * answer = GEOSWithin(g1, g2) + * if answer: # <<<<<<<<<<<<<< + * return True + * else: + */ + __pyx_1 = __pyx_v_answer; + if (__pyx_1) { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":143 + * answer = GEOSWithin(g1, g2) + * if answer: + * return True # <<<<<<<<<<<<<< + * else: + * return False + */ + Py_INCREF(Py_True); + __pyx_r = Py_True; + goto __pyx_L0; + goto __pyx_L2; + } + /*else*/ { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":145 + * return True + * else: + * return False # <<<<<<<<<<<<<< + * + * def intersects(self, BaseGeometry geom): + */ + Py_INCREF(Py_False); + __pyx_r = Py_False; + goto __pyx_L0; + } + __pyx_L2:; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + __Pyx_AddTraceback("_geos.BaseGeometry.within"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_geom); + return __pyx_r; +} + +static PyObject *__pyx_f_py_5_geos_12BaseGeometry_intersects(PyObject *__pyx_v_self, PyObject *__pyx_v_geom); /*proto*/ +static PyObject *__pyx_f_py_5_geos_12BaseGeometry_intersects(PyObject *__pyx_v_self, PyObject *__pyx_v_geom) { + GEOSGeom (*__pyx_v_g1); + GEOSGeom (*__pyx_v_g2); + char __pyx_v_answer; + PyObject *__pyx_r; + char __pyx_1; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_geom); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_5_geos_BaseGeometry, 1, "geom"))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; goto __pyx_L1;} + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":150 + * cdef GEOSGeom *g1, *g2 + * cdef char answer + * g1 = self._geom # <<<<<<<<<<<<<< + * g2 = geom._geom + * answer = GEOSIntersects(g1, g2) + */ + __pyx_v_g1 = ((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_self)->_geom; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":151 + * cdef char answer + * g1 = self._geom + * g2 = geom._geom # <<<<<<<<<<<<<< + * answer = GEOSIntersects(g1, g2) + * if answer: + */ + __pyx_v_g2 = ((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_geom)->_geom; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":152 + * g1 = self._geom + * g2 = geom._geom + * answer = GEOSIntersects(g1, g2) # <<<<<<<<<<<<<< + * if answer: + * return True + */ + __pyx_v_answer = GEOSIntersects(__pyx_v_g1,__pyx_v_g2); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":153 + * g2 = geom._geom + * answer = GEOSIntersects(g1, g2) + * if answer: # <<<<<<<<<<<<<< + * return True + * else: + */ + __pyx_1 = __pyx_v_answer; + if (__pyx_1) { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":154 + * answer = GEOSIntersects(g1, g2) + * if answer: + * return True # <<<<<<<<<<<<<< + * else: + * return False + */ + Py_INCREF(Py_True); + __pyx_r = Py_True; + goto __pyx_L0; + goto __pyx_L2; + } + /*else*/ { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":156 + * return True + * else: + * return False # <<<<<<<<<<<<<< + * + * def intersection(self, BaseGeometry geom): + */ + Py_INCREF(Py_False); + __pyx_r = Py_False; + goto __pyx_L0; + } + __pyx_L2:; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + __Pyx_AddTraceback("_geos.BaseGeometry.intersects"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_geom); + return __pyx_r; +} + +static PyObject *__pyx_n_append; +static PyObject *__pyx_n_NotImplementedError; + +static PyObject *__pyx_k9p; + +static PyObject *__pyx_builtin_NotImplementedError; + +static char (__pyx_k9[]) = "intersections of type '%s' not yet implemented"; + +static PyObject *__pyx_f_py_5_geos_12BaseGeometry_intersection(PyObject *__pyx_v_self, PyObject *__pyx_v_geom); /*proto*/ +static PyObject *__pyx_f_py_5_geos_12BaseGeometry_intersection(PyObject *__pyx_v_self, PyObject *__pyx_v_geom) { + GEOSGeom (*__pyx_v_g1); + GEOSGeom (*__pyx_v_g2); + GEOSGeom (*__pyx_v_g3); + GEOSGeom (*__pyx_v_gout); + int __pyx_v_numgeoms; + int __pyx_v_i; + int __pyx_v_typeid; + PyObject *__pyx_v_p; + PyObject *__pyx_v_pout; + PyObject *__pyx_r; + int __pyx_1; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + Py_INCREF(__pyx_v_self); + Py_INCREF(__pyx_v_geom); + __pyx_v_p = Py_None; Py_INCREF(Py_None); + __pyx_v_pout = Py_None; Py_INCREF(Py_None); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_geom), __pyx_ptype_5_geos_BaseGeometry, 1, "geom"))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; goto __pyx_L1;} + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":162 + * cdef char answer + * cdef int numgeoms, i, typeid + * g1 = self._geom # <<<<<<<<<<<<<< + * g2 = geom._geom + * g3 = GEOSIntersection(g1, g2) + */ + __pyx_v_g1 = ((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_self)->_geom; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":163 + * cdef int numgeoms, i, typeid + * g1 = self._geom + * g2 = geom._geom # <<<<<<<<<<<<<< + * g3 = GEOSIntersection(g1, g2) + * typeid = GEOSGeomTypeId(g3) + */ + __pyx_v_g2 = ((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_geom)->_geom; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":164 + * g1 = self._geom + * g2 = geom._geom + * g3 = GEOSIntersection(g1, g2) # <<<<<<<<<<<<<< + * typeid = GEOSGeomTypeId(g3) + * if typeid == GEOS_POLYGON: + */ + __pyx_v_g3 = GEOSIntersection(__pyx_v_g1,__pyx_v_g2); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":165 + * g2 = geom._geom + * g3 = GEOSIntersection(g1, g2) + * typeid = GEOSGeomTypeId(g3) # <<<<<<<<<<<<<< + * if typeid == GEOS_POLYGON: + * p = Polygon() # create an empty Polygon instance + */ + __pyx_v_typeid = GEOSGeomTypeId(__pyx_v_g3); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":166 + * g3 = GEOSIntersection(g1, g2) + * typeid = GEOSGeomTypeId(g3) + * if typeid == GEOS_POLYGON: # <<<<<<<<<<<<<< + * p = Polygon() # create an empty Polygon instance + * p = _add_geom(p,g3) # add geometry to it. + */ + __pyx_1 = (__pyx_v_typeid == GEOS_POLYGON); + if (__pyx_1) { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":167 + * typeid = GEOSGeomTypeId(g3) + * if typeid == GEOS_POLYGON: + * p = Polygon() # create an empty Polygon instance # <<<<<<<<<<<<<< + * p = _add_geom(p,g3) # add geometry to it. + * # above should be faster than this .. + */ + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_geos_Polygon), 0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; goto __pyx_L1;} + Py_DECREF(__pyx_v_p); + __pyx_v_p = __pyx_2; + __pyx_2 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":168 + * if typeid == GEOS_POLYGON: + * p = Polygon() # create an empty Polygon instance + * p = _add_geom(p,g3) # add geometry to it. # <<<<<<<<<<<<<< + * # above should be faster than this .. + * #b = _get_coords(g3) + */ + if (!__Pyx_TypeTest(__pyx_v_p, __pyx_ptype_5_geos_BaseGeometry)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; goto __pyx_L1;} + __pyx_2 = __pyx_f_5_geos__add_geom(((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_p),__pyx_v_g3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; goto __pyx_L1;} + Py_DECREF(__pyx_v_p); + __pyx_v_p = __pyx_2; + __pyx_2 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":172 + * #b = _get_coords(g3) + * #p = Polygon(b) + * pout = [p] # return a list with a single element # <<<<<<<<<<<<<< + * elif typeid == GEOS_LINESTRING: + * p = LineString() # create an empty LineString instance + */ + __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; goto __pyx_L1;} + Py_INCREF(__pyx_v_p); + PyList_SET_ITEM(__pyx_2, 0, __pyx_v_p); + Py_DECREF(__pyx_v_pout); + __pyx_v_pout = __pyx_2; + __pyx_2 = 0; + goto __pyx_L2; + } + __pyx_1 = (__pyx_v_typeid == GEOS_LINESTRING); + if (__pyx_1) { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":174 + * pout = [p] # return a list with a single element + * elif typeid == GEOS_LINESTRING: + * p = LineString() # create an empty LineString instance # <<<<<<<<<<<<<< + * p = _add_geom(p,g3) # add geometry to it. + * return [p] + */ + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_geos_LineString), 0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;} + Py_DECREF(__pyx_v_p); + __pyx_v_p = __pyx_2; + __pyx_2 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":175 + * elif typeid == GEOS_LINESTRING: + * p = LineString() # create an empty LineString instance + * p = _add_geom(p,g3) # add geometry to it. # <<<<<<<<<<<<<< + * return [p] + * elif typeid == GEOS_MULTIPOLYGON: + */ + if (!__Pyx_TypeTest(__pyx_v_p, __pyx_ptype_5_geos_BaseGeometry)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;} + __pyx_2 = __pyx_f_5_geos__add_geom(((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_p),__pyx_v_g3); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; goto __pyx_L1;} + Py_DECREF(__pyx_v_p); + __pyx_v_p = __pyx_2; + __pyx_2 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":176 + * p = LineString() # create an empty LineString instance + * p = _add_geom(p,g3) # add geometry to it. + * return [p] # <<<<<<<<<<<<<< + * elif typeid == GEOS_MULTIPOLYGON: + * numgeoms = GEOSGetNumGeometries(g3) + */ + __pyx_2 = PyList_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; goto __pyx_L1;} + Py_INCREF(__pyx_v_p); + PyList_SET_ITEM(__pyx_2, 0, __pyx_v_p); + __pyx_r = __pyx_2; + __pyx_2 = 0; + goto __pyx_L0; + goto __pyx_L2; + } + __pyx_1 = (__pyx_v_typeid == GEOS_MULTIPOLYGON); + if (__pyx_1) { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":178 + * return [p] + * elif typeid == GEOS_MULTIPOLYGON: + * numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<< + * pout = [] + * for i from 0 <= i < numgeoms: + */ + __pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":179 + * elif typeid == GEOS_MULTIPOLYGON: + * numgeoms = GEOSGetNumGeometries(g3) + * pout = [] # <<<<<<<<<<<<<< + * for i from 0 <= i < numgeoms: + * gout = GEOSGetGeometryN(g3, i) + */ + __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; goto __pyx_L1;} + Py_DECREF(__pyx_v_pout); + __pyx_v_pout = __pyx_2; + __pyx_2 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":180 + * numgeoms = GEOSGetNumGeometries(g3) + * pout = [] + * for i from 0 <= i < numgeoms: # <<<<<<<<<<<<<< + * gout = GEOSGetGeometryN(g3, i) + * p = Polygon() # create an empty Polygon instance + */ + for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_numgeoms; __pyx_v_i++) { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":181 + * pout = [] + * for i from 0 <= i < numgeoms: + * gout = GEOSGetGeometryN(g3, i) # <<<<<<<<<<<<<< + * p = Polygon() # create an empty Polygon instance + * p = _add_geom(p,gout) # add geometry to it. + */ + __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3,__pyx_v_i); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":182 + * for i from 0 <= i < numgeoms: + * gout = GEOSGetGeometryN(g3, i) + * p = Polygon() # create an empty Polygon instance # <<<<<<<<<<<<<< + * p = _add_geom(p,gout) # add geometry to it. + * pout.append(p) + */ + __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_geos_Polygon), 0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; goto __pyx_L1;} + Py_DECREF(__pyx_v_p); + __pyx_v_p = __pyx_2; + __pyx_2 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":183 + * gout = GEOSGetGeometryN(g3, i) + * p = Polygon() # create an empty Polygon instance + * p = _add_geom(p,gout) # add geometry to it. # <<<<<<<<<<<<<< + * pout.append(p) + * elif typeid == GEOS_MULTILINESTRING: + */ + if (!__Pyx_TypeTest(__pyx_v_p, __pyx_ptype_5_geos_BaseGeometry)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; goto __pyx_L1;} + __pyx_2 = __pyx_f_5_geos__add_geom(((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_p),__pyx_v_gout); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; goto __pyx_L1;} + Py_DECREF(__pyx_v_p); + __pyx_v_p = __pyx_2; + __pyx_2 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":184 + * p = Polygon() # create an empty Polygon instance + * p = _add_geom(p,gout) # add geometry to it. + * pout.append(p) # <<<<<<<<<<<<<< + * elif typeid == GEOS_MULTILINESTRING: + * numgeoms = GEOSGetNumGeometries(g3) + */ + __pyx_2 = PyObject_GetAttr(__pyx_v_pout, __pyx_n_append); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; goto __pyx_L1;} + Py_INCREF(__pyx_v_p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + } + goto __pyx_L2; + } + __pyx_1 = (__pyx_v_typeid == GEOS_MULTILINESTRING); + if (__pyx_1) { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":186 + * pout.append(p) + * elif typeid == GEOS_MULTILINESTRING: + * numgeoms = GEOSGetNumGeometries(g3) # <<<<<<<<<<<<<< + * pout = [] + * for i from 0 <= i < numgeoms: + */ + __pyx_v_numgeoms = GEOSGetNumGeometries(__pyx_v_g3); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":187 + * elif typeid == GEOS_MULTILINESTRING: + * numgeoms = GEOSGetNumGeometries(g3) + * pout = [] # <<<<<<<<<<<<<< + * for i from 0 <= i < numgeoms: + * gout = GEOSGetGeometryN(g3, i) + */ + __pyx_2 = PyList_New(0); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; goto __pyx_L1;} + Py_DECREF(__pyx_v_pout); + __pyx_v_pout = __pyx_2; + __pyx_2 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":188 + * numgeoms = GEOSGetNumGeometries(g3) + * pout = [] + * for i from 0 <= i < numgeoms: # <<<<<<<<<<<<<< + * gout = GEOSGetGeometryN(g3, i) + * p = LineString() # create an LineString instance + */ + for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_numgeoms; __pyx_v_i++) { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":189 + * pout = [] + * for i from 0 <= i < numgeoms: + * gout = GEOSGetGeometryN(g3, i) # <<<<<<<<<<<<<< + * p = LineString() # create an LineString instance + * p = _add_geom(p,gout) # add geometry to it. + */ + __pyx_v_gout = GEOSGetGeometryN(__pyx_v_g3,__pyx_v_i); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":190 + * for i from 0 <= i < numgeoms: + * gout = GEOSGetGeometryN(g3, i) + * p = LineString() # create an LineString instance # <<<<<<<<<<<<<< + * p = _add_geom(p,gout) # add geometry to it. + * pout.append(p) + */ + __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_geos_LineString), 0); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; goto __pyx_L1;} + Py_DECREF(__pyx_v_p); + __pyx_v_p = __pyx_3; + __pyx_3 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":191 + * gout = GEOSGetGeometryN(g3, i) + * p = LineString() # create an LineString instance + * p = _add_geom(p,gout) # add geometry to it. # <<<<<<<<<<<<<< + * pout.append(p) + * else: + */ + if (!__Pyx_TypeTest(__pyx_v_p, __pyx_ptype_5_geos_BaseGeometry)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;} + __pyx_4 = __pyx_f_5_geos__add_geom(((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_p),__pyx_v_gout); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; goto __pyx_L1;} + Py_DECREF(__pyx_v_p); + __pyx_v_p = __pyx_4; + __pyx_4 = 0; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":192 + * p = LineString() # create an LineString instance + * p = _add_geom(p,gout) # add geometry to it. + * pout.append(p) # <<<<<<<<<<<<<< + * else: + * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type)) + */ + __pyx_2 = PyObject_GetAttr(__pyx_v_pout, __pyx_n_append); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; goto __pyx_L1;} + Py_INCREF(__pyx_v_p); + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_p); + __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; goto __pyx_L1;} + Py_DECREF(__pyx_2); __pyx_2 = 0; + Py_DECREF(__pyx_3); __pyx_3 = 0; + Py_DECREF(__pyx_4); __pyx_4 = 0; + } + goto __pyx_L2; + } + /*else*/ { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":194 + * pout.append(p) + * else: + * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type)) # <<<<<<<<<<<<<< + * return pout + * + */ + __pyx_2 = PyNumber_Remainder(__pyx_k9p, ((PyObject*)&PyType_Type)); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); + __pyx_2 = 0; + __pyx_4 = PyObject_CallObject(__pyx_builtin_NotImplementedError, __pyx_3); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + Py_DECREF(__pyx_3); __pyx_3 = 0; + __Pyx_Raise(__pyx_4, 0, 0); + Py_DECREF(__pyx_4); __pyx_4 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; goto __pyx_L1;} + } + __pyx_L2:; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":195 + * else: + * raise NotImplementedError("intersections of type '%s' not yet implemented" % (type)) + * return pout # <<<<<<<<<<<<<< + * + * def get_coords(self): + */ + Py_INCREF(__pyx_v_pout); + __pyx_r = __pyx_v_pout; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + Py_XDECREF(__pyx_4); + __Pyx_AddTraceback("_geos.BaseGeometry.intersection"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_p); + Py_DECREF(__pyx_v_pout); + Py_DECREF(__pyx_v_self); + Py_DECREF(__pyx_v_geom); + return __pyx_r; +} + +static PyObject *__pyx_f_py_5_geos_12BaseGeometry_get_coords(PyObject *__pyx_v_self, PyObject *unused); /*proto*/ +static PyObject *__pyx_f_py_5_geos_12BaseGeometry_get_coords(PyObject *__pyx_v_self, PyObject *unused) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + Py_INCREF(__pyx_v_self); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":198 + * + * def get_coords(self): + * return _get_coords(self._geom) # <<<<<<<<<<<<<< + * + * def __dealloc__(self): + */ + __pyx_1 = __pyx_f_5_geos__get_coords(((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_self)->_geom); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; goto __pyx_L1;} + __pyx_r = __pyx_1; + __pyx_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + __Pyx_AddTraceback("_geos.BaseGeometry.get_coords"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static void __pyx_f_py_5_geos_12BaseGeometry___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static char __pyx_doc_5_geos_12BaseGeometry___dealloc__[] = "destroy GEOS geometry"; +static void __pyx_f_py_5_geos_12BaseGeometry___dealloc__(PyObject *__pyx_v_self) { + Py_INCREF(__pyx_v_self); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":202 + * def __dealloc__(self): + * """destroy GEOS geometry""" + * GEOSGeom_destroy(self._geom) # <<<<<<<<<<<<<< + * + * def __reduce__(self): + */ + GEOSGeom_destroy(((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_self)->_geom); + + Py_DECREF(__pyx_v_self); +} + +static PyObject *__pyx_n___class__; + +static PyObject *__pyx_f_py_5_geos_12BaseGeometry___reduce__(PyObject *__pyx_v_self, PyObject *unused); /*proto*/ +static char __pyx_doc_5_geos_12BaseGeometry___reduce__[] = "special method that allows geos instance to be pickled"; +static PyObject *__pyx_f_py_5_geos_12BaseGeometry___reduce__(PyObject *__pyx_v_self, PyObject *unused) { + PyObject *__pyx_r; + PyObject *__pyx_1 = 0; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + Py_INCREF(__pyx_v_self); + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":206 + * def __reduce__(self): + * """special method that allows geos instance to be pickled""" + * return (self.__class__,(self.boundary,)) # <<<<<<<<<<<<<< + * + * cdef class Polygon(BaseGeometry): + */ + __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; goto __pyx_L1;} + __pyx_2 = PyTuple_New(1); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; goto __pyx_L1;} + Py_INCREF(((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_self)->boundary); + PyTuple_SET_ITEM(__pyx_2, 0, ((struct __pyx_obj_5_geos_BaseGeometry *)__pyx_v_self)->boundary); + __pyx_3 = PyTuple_New(2); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; goto __pyx_L1;} + PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); + PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); + __pyx_1 = 0; + __pyx_2 = 0; + __pyx_r = __pyx_3; + __pyx_3 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; Py_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1:; + Py_XDECREF(__pyx_1); + Py_XDECREF(__pyx_2); + Py_XDECREF(__pyx_3); + __Pyx_AddTraceback("_geos.BaseGeometry.__reduce__"); + __pyx_r = 0; + __pyx_L0:; + Py_DECREF(__pyx_v_self); + return __pyx_r; +} + +static PyObject *__pyx_num_neg_1; +static PyObject *__pyx_num_0; +static PyObject *__pyx_num_1; + +static PyObject *__pyx_n_copy; +static PyObject *__pyx_n_shape; + +static int __pyx_f_py_5_geos_7Polygon___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_f_py_5_geos_7Polygon___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_b = 0; + unsigned int __pyx_v_M; + unsigned int __pyx_v_m; + unsigned int __pyx_v_i; + double __pyx_v_dx; + double __pyx_v_dy; + double (*__pyx_v_bbuffer); + GEOSCoordSeq (*__pyx_v_cs); + GEOSGeom (*__pyx_v_lr); + int __pyx_r; + int __pyx_1; + PyObject *__pyx_2 = 0; + PyObject *__pyx_3 = 0; + PyObject *__pyx_4 = 0; + unsigned int __pyx_5; + PyObject *__pyx_6 = 0; + static char *__pyx_argnames[] = {"b",0}; + __pyx_v_b = __pyx_k4; + if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_b))) return -1; + Py_INCREF((PyObject *)__pyx_v_self); + Py_INCREF(__pyx_v_b); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_5_geos_ndarray, 1, "b"))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; goto __pyx_L1;} + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":218 + * + * # just return an empty class + * if b is None: # <<<<<<<<<<<<<< + * return + * + */ + __pyx_1 = (((PyObject *)__pyx_v_b) == Py_None); + if (__pyx_1) { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":219 + * # just return an empty class + * if b is None: + * return # <<<<<<<<<<<<<< + * + * # make sure data is contiguous. + */ + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L2; + } + __pyx_L2:; + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":223 + * # make sure data is contiguous. + * # if not, make a local copy. + * if not PyArray_ISCONTIGUOUS(b): # <<<<<<<<<<<<<< + * b = b.copy() + * + */ + __pyx_1 = (!PyArray_ISCONTIGUOUS(__pyx_v_b)); + if (__pyx_1) { + + /* "/Users/jsw/python/matplotlib/toolkits/basemap-testing/src/_geos.pyx":224 + * # if not, make a local copy. + * if not PyArray_ISCONTIGUOUS(b): + * b = b.copy() # <<<<<<<<<<<<<< ... [truncated message content] |