1 /* Generated by Cython 0.29.21 */
2 
3 /* BEGIN: Cython Metadata
4 {
5     "distutils": {
6         "depends": [
7             "/home/sean/.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h",
8             "/home/sean/.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/core/include/numpy/arrayscalars.h",
9             "/home/sean/.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h",
10             "/home/sean/.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h",
11             "/home/sean/.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/core/include/numpy/ufuncobject.h",
12             "/home/sean/local/include/cpl_conv.h",
13             "/home/sean/local/include/cpl_error.h",
14             "/home/sean/local/include/cpl_string.h",
15             "/home/sean/local/include/cpl_vsi.h",
16             "/home/sean/local/include/gdal.h",
17             "/home/sean/local/include/gdal_alg.h",
18             "/home/sean/local/include/gdalwarper.h",
19             "/home/sean/local/include/ogr_api.h",
20             "/home/sean/local/include/ogr_core.h",
21             "/home/sean/local/include/ogr_srs_api.h"
22         ],
23         "extra_compile_args": [
24             "-Wno-unused-parameter",
25             "-Wno-unused-function"
26         ],
27         "include_dirs": [
28             "/home/sean/.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/core/include",
29             "/home/sean/local/include"
30         ],
31         "libraries": [
32             "gdal"
33         ],
34         "library_dirs": [
35             "/home/sean/local/lib"
36         ],
37         "name": "rasterio._features",
38         "sources": [
39             "rasterio/_features.pyx"
40         ]
41     },
42     "module_name": "rasterio._features"
43 }
44 END: Cython Metadata */
45 
46 #define PY_SSIZE_T_CLEAN
47 #include "Python.h"
48 #ifndef Py_PYTHON_H
49     #error Python headers needed to compile C extensions, please install development version of Python.
50 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
51     #error Cython requires Python 2.6+ or Python 3.3+.
52 #else
53 #define CYTHON_ABI "0_29_21"
54 #define CYTHON_HEX_VERSION 0x001D15F0
55 #define CYTHON_FUTURE_DIVISION 1
56 #include <stddef.h>
57 #ifndef offsetof
58   #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
59 #endif
60 #if !defined(WIN32) && !defined(MS_WINDOWS)
61   #ifndef __stdcall
62     #define __stdcall
63   #endif
64   #ifndef __cdecl
65     #define __cdecl
66   #endif
67   #ifndef __fastcall
68     #define __fastcall
69   #endif
70 #endif
71 #ifndef DL_IMPORT
72   #define DL_IMPORT(t) t
73 #endif
74 #ifndef DL_EXPORT
75   #define DL_EXPORT(t) t
76 #endif
77 #define __PYX_COMMA ,
78 #ifndef HAVE_LONG_LONG
79   #if PY_VERSION_HEX >= 0x02070000
80     #define HAVE_LONG_LONG
81   #endif
82 #endif
83 #ifndef PY_LONG_LONG
84   #define PY_LONG_LONG LONG_LONG
85 #endif
86 #ifndef Py_HUGE_VAL
87   #define Py_HUGE_VAL HUGE_VAL
88 #endif
89 #ifdef PYPY_VERSION
90   #define CYTHON_COMPILING_IN_PYPY 1
91   #define CYTHON_COMPILING_IN_PYSTON 0
92   #define CYTHON_COMPILING_IN_CPYTHON 0
93   #undef CYTHON_USE_TYPE_SLOTS
94   #define CYTHON_USE_TYPE_SLOTS 0
95   #undef CYTHON_USE_PYTYPE_LOOKUP
96   #define CYTHON_USE_PYTYPE_LOOKUP 0
97   #if PY_VERSION_HEX < 0x03050000
98     #undef CYTHON_USE_ASYNC_SLOTS
99     #define CYTHON_USE_ASYNC_SLOTS 0
100   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
101     #define CYTHON_USE_ASYNC_SLOTS 1
102   #endif
103   #undef CYTHON_USE_PYLIST_INTERNALS
104   #define CYTHON_USE_PYLIST_INTERNALS 0
105   #undef CYTHON_USE_UNICODE_INTERNALS
106   #define CYTHON_USE_UNICODE_INTERNALS 0
107   #undef CYTHON_USE_UNICODE_WRITER
108   #define CYTHON_USE_UNICODE_WRITER 0
109   #undef CYTHON_USE_PYLONG_INTERNALS
110   #define CYTHON_USE_PYLONG_INTERNALS 0
111   #undef CYTHON_AVOID_BORROWED_REFS
112   #define CYTHON_AVOID_BORROWED_REFS 1
113   #undef CYTHON_ASSUME_SAFE_MACROS
114   #define CYTHON_ASSUME_SAFE_MACROS 0
115   #undef CYTHON_UNPACK_METHODS
116   #define CYTHON_UNPACK_METHODS 0
117   #undef CYTHON_FAST_THREAD_STATE
118   #define CYTHON_FAST_THREAD_STATE 0
119   #undef CYTHON_FAST_PYCALL
120   #define CYTHON_FAST_PYCALL 0
121   #undef CYTHON_PEP489_MULTI_PHASE_INIT
122   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
123   #undef CYTHON_USE_TP_FINALIZE
124   #define CYTHON_USE_TP_FINALIZE 0
125   #undef CYTHON_USE_DICT_VERSIONS
126   #define CYTHON_USE_DICT_VERSIONS 0
127   #undef CYTHON_USE_EXC_INFO_STACK
128   #define CYTHON_USE_EXC_INFO_STACK 0
129 #elif defined(PYSTON_VERSION)
130   #define CYTHON_COMPILING_IN_PYPY 0
131   #define CYTHON_COMPILING_IN_PYSTON 1
132   #define CYTHON_COMPILING_IN_CPYTHON 0
133   #ifndef CYTHON_USE_TYPE_SLOTS
134     #define CYTHON_USE_TYPE_SLOTS 1
135   #endif
136   #undef CYTHON_USE_PYTYPE_LOOKUP
137   #define CYTHON_USE_PYTYPE_LOOKUP 0
138   #undef CYTHON_USE_ASYNC_SLOTS
139   #define CYTHON_USE_ASYNC_SLOTS 0
140   #undef CYTHON_USE_PYLIST_INTERNALS
141   #define CYTHON_USE_PYLIST_INTERNALS 0
142   #ifndef CYTHON_USE_UNICODE_INTERNALS
143     #define CYTHON_USE_UNICODE_INTERNALS 1
144   #endif
145   #undef CYTHON_USE_UNICODE_WRITER
146   #define CYTHON_USE_UNICODE_WRITER 0
147   #undef CYTHON_USE_PYLONG_INTERNALS
148   #define CYTHON_USE_PYLONG_INTERNALS 0
149   #ifndef CYTHON_AVOID_BORROWED_REFS
150     #define CYTHON_AVOID_BORROWED_REFS 0
151   #endif
152   #ifndef CYTHON_ASSUME_SAFE_MACROS
153     #define CYTHON_ASSUME_SAFE_MACROS 1
154   #endif
155   #ifndef CYTHON_UNPACK_METHODS
156     #define CYTHON_UNPACK_METHODS 1
157   #endif
158   #undef CYTHON_FAST_THREAD_STATE
159   #define CYTHON_FAST_THREAD_STATE 0
160   #undef CYTHON_FAST_PYCALL
161   #define CYTHON_FAST_PYCALL 0
162   #undef CYTHON_PEP489_MULTI_PHASE_INIT
163   #define CYTHON_PEP489_MULTI_PHASE_INIT 0
164   #undef CYTHON_USE_TP_FINALIZE
165   #define CYTHON_USE_TP_FINALIZE 0
166   #undef CYTHON_USE_DICT_VERSIONS
167   #define CYTHON_USE_DICT_VERSIONS 0
168   #undef CYTHON_USE_EXC_INFO_STACK
169   #define CYTHON_USE_EXC_INFO_STACK 0
170 #else
171   #define CYTHON_COMPILING_IN_PYPY 0
172   #define CYTHON_COMPILING_IN_PYSTON 0
173   #define CYTHON_COMPILING_IN_CPYTHON 1
174   #ifndef CYTHON_USE_TYPE_SLOTS
175     #define CYTHON_USE_TYPE_SLOTS 1
176   #endif
177   #if PY_VERSION_HEX < 0x02070000
178     #undef CYTHON_USE_PYTYPE_LOOKUP
179     #define CYTHON_USE_PYTYPE_LOOKUP 0
180   #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
181     #define CYTHON_USE_PYTYPE_LOOKUP 1
182   #endif
183   #if PY_MAJOR_VERSION < 3
184     #undef CYTHON_USE_ASYNC_SLOTS
185     #define CYTHON_USE_ASYNC_SLOTS 0
186   #elif !defined(CYTHON_USE_ASYNC_SLOTS)
187     #define CYTHON_USE_ASYNC_SLOTS 1
188   #endif
189   #if PY_VERSION_HEX < 0x02070000
190     #undef CYTHON_USE_PYLONG_INTERNALS
191     #define CYTHON_USE_PYLONG_INTERNALS 0
192   #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
193     #define CYTHON_USE_PYLONG_INTERNALS 1
194   #endif
195   #ifndef CYTHON_USE_PYLIST_INTERNALS
196     #define CYTHON_USE_PYLIST_INTERNALS 1
197   #endif
198   #ifndef CYTHON_USE_UNICODE_INTERNALS
199     #define CYTHON_USE_UNICODE_INTERNALS 1
200   #endif
201   #if PY_VERSION_HEX < 0x030300F0
202     #undef CYTHON_USE_UNICODE_WRITER
203     #define CYTHON_USE_UNICODE_WRITER 0
204   #elif !defined(CYTHON_USE_UNICODE_WRITER)
205     #define CYTHON_USE_UNICODE_WRITER 1
206   #endif
207   #ifndef CYTHON_AVOID_BORROWED_REFS
208     #define CYTHON_AVOID_BORROWED_REFS 0
209   #endif
210   #ifndef CYTHON_ASSUME_SAFE_MACROS
211     #define CYTHON_ASSUME_SAFE_MACROS 1
212   #endif
213   #ifndef CYTHON_UNPACK_METHODS
214     #define CYTHON_UNPACK_METHODS 1
215   #endif
216   #ifndef CYTHON_FAST_THREAD_STATE
217     #define CYTHON_FAST_THREAD_STATE 1
218   #endif
219   #ifndef CYTHON_FAST_PYCALL
220     #define CYTHON_FAST_PYCALL 1
221   #endif
222   #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
223     #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
224   #endif
225   #ifndef CYTHON_USE_TP_FINALIZE
226     #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
227   #endif
228   #ifndef CYTHON_USE_DICT_VERSIONS
229     #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
230   #endif
231   #ifndef CYTHON_USE_EXC_INFO_STACK
232     #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
233   #endif
234 #endif
235 #if !defined(CYTHON_FAST_PYCCALL)
236 #define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
237 #endif
238 #if CYTHON_USE_PYLONG_INTERNALS
239   #include "longintrepr.h"
240   #undef SHIFT
241   #undef BASE
242   #undef MASK
243   #ifdef SIZEOF_VOID_P
244     enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
245   #endif
246 #endif
247 #ifndef __has_attribute
248   #define __has_attribute(x) 0
249 #endif
250 #ifndef __has_cpp_attribute
251   #define __has_cpp_attribute(x) 0
252 #endif
253 #ifndef CYTHON_RESTRICT
254   #if defined(__GNUC__)
255     #define CYTHON_RESTRICT __restrict__
256   #elif defined(_MSC_VER) && _MSC_VER >= 1400
257     #define CYTHON_RESTRICT __restrict
258   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
259     #define CYTHON_RESTRICT restrict
260   #else
261     #define CYTHON_RESTRICT
262   #endif
263 #endif
264 #ifndef CYTHON_UNUSED
265 # if defined(__GNUC__)
266 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
267 #     define CYTHON_UNUSED __attribute__ ((__unused__))
268 #   else
269 #     define CYTHON_UNUSED
270 #   endif
271 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
272 #   define CYTHON_UNUSED __attribute__ ((__unused__))
273 # else
274 #   define CYTHON_UNUSED
275 # endif
276 #endif
277 #ifndef CYTHON_MAYBE_UNUSED_VAR
278 #  if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)279      template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
280 #  else
281 #    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
282 #  endif
283 #endif
284 #ifndef CYTHON_NCP_UNUSED
285 # if CYTHON_COMPILING_IN_CPYTHON
286 #  define CYTHON_NCP_UNUSED
287 # else
288 #  define CYTHON_NCP_UNUSED CYTHON_UNUSED
289 # endif
290 #endif
291 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
292 #ifdef _MSC_VER
293     #ifndef _MSC_STDINT_H_
294         #if _MSC_VER < 1300
295            typedef unsigned char     uint8_t;
296            typedef unsigned int      uint32_t;
297         #else
298            typedef unsigned __int8   uint8_t;
299            typedef unsigned __int32  uint32_t;
300         #endif
301     #endif
302 #else
303    #include <stdint.h>
304 #endif
305 #ifndef CYTHON_FALLTHROUGH
306   #if defined(__cplusplus) && __cplusplus >= 201103L
307     #if __has_cpp_attribute(fallthrough)
308       #define CYTHON_FALLTHROUGH [[fallthrough]]
309     #elif __has_cpp_attribute(clang::fallthrough)
310       #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
311     #elif __has_cpp_attribute(gnu::fallthrough)
312       #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
313     #endif
314   #endif
315   #ifndef CYTHON_FALLTHROUGH
316     #if __has_attribute(fallthrough)
317       #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
318     #else
319       #define CYTHON_FALLTHROUGH
320     #endif
321   #endif
322   #if defined(__clang__ ) && defined(__apple_build_version__)
323     #if __apple_build_version__ < 7000000
324       #undef  CYTHON_FALLTHROUGH
325       #define CYTHON_FALLTHROUGH
326     #endif
327   #endif
328 #endif
329 
330 #ifndef CYTHON_INLINE
331   #if defined(__clang__)
332     #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
333   #elif defined(__GNUC__)
334     #define CYTHON_INLINE __inline__
335   #elif defined(_MSC_VER)
336     #define CYTHON_INLINE __inline
337   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
338     #define CYTHON_INLINE inline
339   #else
340     #define CYTHON_INLINE
341   #endif
342 #endif
343 
344 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
345   #define Py_OptimizeFlag 0
346 #endif
347 #define __PYX_BUILD_PY_SSIZE_T "n"
348 #define CYTHON_FORMAT_SSIZE_T "z"
349 #if PY_MAJOR_VERSION < 3
350   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
351   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
352           PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
353   #define __Pyx_DefaultClassType PyClass_Type
354 #else
355   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
356 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
357   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
358           PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
359 #else
360   #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
361           PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
362 #endif
363   #define __Pyx_DefaultClassType PyType_Type
364 #endif
365 #ifndef Py_TPFLAGS_CHECKTYPES
366   #define Py_TPFLAGS_CHECKTYPES 0
367 #endif
368 #ifndef Py_TPFLAGS_HAVE_INDEX
369   #define Py_TPFLAGS_HAVE_INDEX 0
370 #endif
371 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
372   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
373 #endif
374 #ifndef Py_TPFLAGS_HAVE_FINALIZE
375   #define Py_TPFLAGS_HAVE_FINALIZE 0
376 #endif
377 #ifndef METH_STACKLESS
378   #define METH_STACKLESS 0
379 #endif
380 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
381   #ifndef METH_FASTCALL
382      #define METH_FASTCALL 0x80
383   #endif
384   typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
385   typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
386                                                           Py_ssize_t nargs, PyObject *kwnames);
387 #else
388   #define __Pyx_PyCFunctionFast _PyCFunctionFast
389   #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
390 #endif
391 #if CYTHON_FAST_PYCCALL
392 #define __Pyx_PyFastCFunction_Check(func)\
393     ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
394 #else
395 #define __Pyx_PyFastCFunction_Check(func) 0
396 #endif
397 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
398   #define PyObject_Malloc(s)   PyMem_Malloc(s)
399   #define PyObject_Free(p)     PyMem_Free(p)
400   #define PyObject_Realloc(p)  PyMem_Realloc(p)
401 #endif
402 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
403   #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
404   #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
405   #define PyMem_RawFree(p)             PyMem_Free(p)
406 #endif
407 #if CYTHON_COMPILING_IN_PYSTON
408   #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
409   #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
410 #else
411   #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
412   #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
413 #endif
414 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
415   #define __Pyx_PyThreadState_Current PyThreadState_GET()
416 #elif PY_VERSION_HEX >= 0x03060000
417   #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
418 #elif PY_VERSION_HEX >= 0x03000000
419   #define __Pyx_PyThreadState_Current PyThreadState_GET()
420 #else
421   #define __Pyx_PyThreadState_Current _PyThreadState_Current
422 #endif
423 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
424 #include "pythread.h"
425 #define Py_tss_NEEDS_INIT 0
426 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)427 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
428   *key = PyThread_create_key();
429   return 0;
430 }
PyThread_tss_alloc(void)431 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
432   Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
433   *key = Py_tss_NEEDS_INIT;
434   return key;
435 }
PyThread_tss_free(Py_tss_t * key)436 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
437   PyObject_Free(key);
438 }
PyThread_tss_is_created(Py_tss_t * key)439 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
440   return *key != Py_tss_NEEDS_INIT;
441 }
PyThread_tss_delete(Py_tss_t * key)442 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
443   PyThread_delete_key(*key);
444   *key = Py_tss_NEEDS_INIT;
445 }
PyThread_tss_set(Py_tss_t * key,void * value)446 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
447   return PyThread_set_key_value(*key, value);
448 }
PyThread_tss_get(Py_tss_t * key)449 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
450   return PyThread_get_key_value(*key);
451 }
452 #endif
453 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
454 #define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
455 #else
456 #define __Pyx_PyDict_NewPresized(n)  PyDict_New()
457 #endif
458 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
459   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
460   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
461 #else
462   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
463   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
464 #endif
465 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
466 #define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
467 #else
468 #define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
469 #endif
470 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
471   #define CYTHON_PEP393_ENABLED 1
472   #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
473                                               0 : _PyUnicode_Ready((PyObject *)(op)))
474   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
475   #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
476   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
477   #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
478   #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
479   #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
480   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
481   #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
482   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
483   #else
484   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
485   #endif
486 #else
487   #define CYTHON_PEP393_ENABLED 0
488   #define PyUnicode_1BYTE_KIND  1
489   #define PyUnicode_2BYTE_KIND  2
490   #define PyUnicode_4BYTE_KIND  4
491   #define __Pyx_PyUnicode_READY(op)       (0)
492   #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
493   #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
494   #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
495   #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
496   #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
497   #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
498   #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
499   #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
500 #endif
501 #if CYTHON_COMPILING_IN_PYPY
502   #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
503   #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
504 #else
505   #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
506   #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
507       PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
508 #endif
509 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
510   #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
511 #endif
512 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
513   #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
514 #endif
515 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
516   #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
517 #endif
518 #define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
519 #define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
520 #if PY_MAJOR_VERSION >= 3
521   #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
522 #else
523   #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
524 #endif
525 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
526   #define PyObject_ASCII(o)            PyObject_Repr(o)
527 #endif
528 #if PY_MAJOR_VERSION >= 3
529   #define PyBaseString_Type            PyUnicode_Type
530   #define PyStringObject               PyUnicodeObject
531   #define PyString_Type                PyUnicode_Type
532   #define PyString_Check               PyUnicode_Check
533   #define PyString_CheckExact          PyUnicode_CheckExact
534 #ifndef PyObject_Unicode
535   #define PyObject_Unicode             PyObject_Str
536 #endif
537 #endif
538 #if PY_MAJOR_VERSION >= 3
539   #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
540   #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
541 #else
542   #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
543   #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
544 #endif
545 #ifndef PySet_CheckExact
546   #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
547 #endif
548 #if PY_VERSION_HEX >= 0x030900A4
549   #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
550   #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
551 #else
552   #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
553   #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
554 #endif
555 #if CYTHON_ASSUME_SAFE_MACROS
556   #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
557 #else
558   #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
559 #endif
560 #if PY_MAJOR_VERSION >= 3
561   #define PyIntObject                  PyLongObject
562   #define PyInt_Type                   PyLong_Type
563   #define PyInt_Check(op)              PyLong_Check(op)
564   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
565   #define PyInt_FromString             PyLong_FromString
566   #define PyInt_FromUnicode            PyLong_FromUnicode
567   #define PyInt_FromLong               PyLong_FromLong
568   #define PyInt_FromSize_t             PyLong_FromSize_t
569   #define PyInt_FromSsize_t            PyLong_FromSsize_t
570   #define PyInt_AsLong                 PyLong_AsLong
571   #define PyInt_AS_LONG                PyLong_AS_LONG
572   #define PyInt_AsSsize_t              PyLong_AsSsize_t
573   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
574   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
575   #define PyNumber_Int                 PyNumber_Long
576 #endif
577 #if PY_MAJOR_VERSION >= 3
578   #define PyBoolObject                 PyLongObject
579 #endif
580 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
581   #ifndef PyUnicode_InternFromString
582     #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
583   #endif
584 #endif
585 #if PY_VERSION_HEX < 0x030200A4
586   typedef long Py_hash_t;
587   #define __Pyx_PyInt_FromHash_t PyInt_FromLong
588   #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
589 #else
590   #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
591   #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
592 #endif
593 #if PY_MAJOR_VERSION >= 3
594   #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
595 #else
596   #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
597 #endif
598 #if CYTHON_USE_ASYNC_SLOTS
599   #if PY_VERSION_HEX >= 0x030500B1
600     #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
601     #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
602   #else
603     #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
604   #endif
605 #else
606   #define __Pyx_PyType_AsAsync(obj) NULL
607 #endif
608 #ifndef __Pyx_PyAsyncMethodsStruct
609     typedef struct {
610         unaryfunc am_await;
611         unaryfunc am_aiter;
612         unaryfunc am_anext;
613     } __Pyx_PyAsyncMethodsStruct;
614 #endif
615 
616 #if defined(WIN32) || defined(MS_WINDOWS)
617   #define _USE_MATH_DEFINES
618 #endif
619 #include <math.h>
620 #ifdef NAN
621 #define __PYX_NAN() ((float) NAN)
622 #else
__PYX_NAN()623 static CYTHON_INLINE float __PYX_NAN() {
624   float value;
625   memset(&value, 0xFF, sizeof(value));
626   return value;
627 }
628 #endif
629 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
630 #define __Pyx_truncl trunc
631 #else
632 #define __Pyx_truncl truncl
633 #endif
634 
635 #define __PYX_MARK_ERR_POS(f_index, lineno) \
636     { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
637 #define __PYX_ERR(f_index, lineno, Ln_error) \
638     { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
639 
640 #ifndef __PYX_EXTERN_C
641   #ifdef __cplusplus
642     #define __PYX_EXTERN_C extern "C"
643   #else
644     #define __PYX_EXTERN_C extern
645   #endif
646 #endif
647 
648 #define __PYX_HAVE__rasterio___features
649 #define __PYX_HAVE_API__rasterio___features
650 /* Early includes */
651 #include <string.h>
652 #include <stdio.h>
653 #include "cpl_conv.h"
654 #include "cpl_error.h"
655 #include "cpl_string.h"
656 #include "sys/stat.h"
657 #include "cpl_vsi.h"
658 #include "ogr_srs_api.h"
659 #include "gdal.h"
660 #include "ogr_api.h"
661 #include "gdalwarper.h"
662 #include "gdal_alg.h"
663 #include "ogr_core.h"
664 #include "numpy/arrayobject.h"
665 #include "numpy/ndarrayobject.h"
666 #include "numpy/ndarraytypes.h"
667 #include "numpy/arrayscalars.h"
668 #include "numpy/ufuncobject.h"
669 
670     /* NumPy API declarations from "numpy/__init__.pxd" */
671 
672 #ifdef _OPENMP
673 #include <omp.h>
674 #endif /* _OPENMP */
675 
676 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
677 #define CYTHON_WITHOUT_ASSERTIONS
678 #endif
679 
680 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
681                 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
682 
683 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
684 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
685 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
686 #define __PYX_DEFAULT_STRING_ENCODING ""
687 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
688 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
689 #define __Pyx_uchar_cast(c) ((unsigned char)c)
690 #define __Pyx_long_cast(x) ((long)x)
691 #define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
692     (sizeof(type) < sizeof(Py_ssize_t))  ||\
693     (sizeof(type) > sizeof(Py_ssize_t) &&\
694           likely(v < (type)PY_SSIZE_T_MAX ||\
695                  v == (type)PY_SSIZE_T_MAX)  &&\
696           (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
697                                 v == (type)PY_SSIZE_T_MIN)))  ||\
698     (sizeof(type) == sizeof(Py_ssize_t) &&\
699           (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
700                                v == (type)PY_SSIZE_T_MAX)))  )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)701 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
702     return (size_t) i < (size_t) limit;
703 }
704 #if defined (__cplusplus) && __cplusplus >= 201103L
705     #include <cstdlib>
706     #define __Pyx_sst_abs(value) std::abs(value)
707 #elif SIZEOF_INT >= SIZEOF_SIZE_T
708     #define __Pyx_sst_abs(value) abs(value)
709 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
710     #define __Pyx_sst_abs(value) labs(value)
711 #elif defined (_MSC_VER)
712     #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
713 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
714     #define __Pyx_sst_abs(value) llabs(value)
715 #elif defined (__GNUC__)
716     #define __Pyx_sst_abs(value) __builtin_llabs(value)
717 #else
718     #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
719 #endif
720 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
721 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
722 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
723 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
724 #define __Pyx_PyBytes_FromString        PyBytes_FromString
725 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
726 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
727 #if PY_MAJOR_VERSION < 3
728     #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
729     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
730 #else
731     #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
732     #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
733 #endif
734 #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
735 #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
736 #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
737 #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
738 #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
739 #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
740 #define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
741 #define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
742 #define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
743 #define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
744 #define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
745 #define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
746 #define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
747 #define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
748 #define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
749 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)750 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
751     const Py_UNICODE *u_end = u;
752     while (*u_end++) ;
753     return (size_t)(u_end - u - 1);
754 }
755 #define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
756 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
757 #define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
758 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
759 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
760 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
761 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
762 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
763 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
764 #define __Pyx_PySequence_Tuple(obj)\
765     (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
766 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
767 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
768 #if CYTHON_ASSUME_SAFE_MACROS
769 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
770 #else
771 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
772 #endif
773 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
774 #if PY_MAJOR_VERSION >= 3
775 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
776 #else
777 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
778 #endif
779 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
780 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
781 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)782 static int __Pyx_init_sys_getdefaultencoding_params(void) {
783     PyObject* sys;
784     PyObject* default_encoding = NULL;
785     PyObject* ascii_chars_u = NULL;
786     PyObject* ascii_chars_b = NULL;
787     const char* default_encoding_c;
788     sys = PyImport_ImportModule("sys");
789     if (!sys) goto bad;
790     default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
791     Py_DECREF(sys);
792     if (!default_encoding) goto bad;
793     default_encoding_c = PyBytes_AsString(default_encoding);
794     if (!default_encoding_c) goto bad;
795     if (strcmp(default_encoding_c, "ascii") == 0) {
796         __Pyx_sys_getdefaultencoding_not_ascii = 0;
797     } else {
798         char ascii_chars[128];
799         int c;
800         for (c = 0; c < 128; c++) {
801             ascii_chars[c] = c;
802         }
803         __Pyx_sys_getdefaultencoding_not_ascii = 1;
804         ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
805         if (!ascii_chars_u) goto bad;
806         ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
807         if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
808             PyErr_Format(
809                 PyExc_ValueError,
810                 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
811                 default_encoding_c);
812             goto bad;
813         }
814         Py_DECREF(ascii_chars_u);
815         Py_DECREF(ascii_chars_b);
816     }
817     Py_DECREF(default_encoding);
818     return 0;
819 bad:
820     Py_XDECREF(default_encoding);
821     Py_XDECREF(ascii_chars_u);
822     Py_XDECREF(ascii_chars_b);
823     return -1;
824 }
825 #endif
826 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
827 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
828 #else
829 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
830 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
831 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)832 static int __Pyx_init_sys_getdefaultencoding_params(void) {
833     PyObject* sys;
834     PyObject* default_encoding = NULL;
835     char* default_encoding_c;
836     sys = PyImport_ImportModule("sys");
837     if (!sys) goto bad;
838     default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
839     Py_DECREF(sys);
840     if (!default_encoding) goto bad;
841     default_encoding_c = PyBytes_AsString(default_encoding);
842     if (!default_encoding_c) goto bad;
843     __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
844     if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
845     strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
846     Py_DECREF(default_encoding);
847     return 0;
848 bad:
849     Py_XDECREF(default_encoding);
850     return -1;
851 }
852 #endif
853 #endif
854 
855 
856 /* Test for GCC > 2.95 */
857 #if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
858   #define likely(x)   __builtin_expect(!!(x), 1)
859   #define unlikely(x) __builtin_expect(!!(x), 0)
860 #else /* !__GNUC__ or GCC < 2.95 */
861   #define likely(x)   (x)
862   #define unlikely(x) (x)
863 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)864 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
865 
866 static PyObject *__pyx_m = NULL;
867 static PyObject *__pyx_d;
868 static PyObject *__pyx_b;
869 static PyObject *__pyx_cython_runtime = NULL;
870 static PyObject *__pyx_empty_tuple;
871 static PyObject *__pyx_empty_bytes;
872 static PyObject *__pyx_empty_unicode;
873 static int __pyx_lineno;
874 static int __pyx_clineno = 0;
875 static const char * __pyx_cfilenm= __FILE__;
876 static const char *__pyx_filename;
877 
878 /* Header.proto */
879 #if !defined(CYTHON_CCOMPLEX)
880   #if defined(__cplusplus)
881     #define CYTHON_CCOMPLEX 1
882   #elif defined(_Complex_I)
883     #define CYTHON_CCOMPLEX 1
884   #else
885     #define CYTHON_CCOMPLEX 0
886   #endif
887 #endif
888 #if CYTHON_CCOMPLEX
889   #ifdef __cplusplus
890     #include <complex>
891   #else
892     #include <complex.h>
893   #endif
894 #endif
895 #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
896   #undef _Complex_I
897   #define _Complex_I 1.0fj
898 #endif
899 
900 
901 static const char *__pyx_f[] = {
902   "rasterio/_features.pyx",
903   "stringsource",
904   "__init__.pxd",
905   "type.pxd",
906   "rasterio/_base.pxd",
907   "rasterio/_io.pxd",
908 };
909 
910 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":690
911  * # in Cython to enable them only on the right systems.
912  *
913  * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
914  * ctypedef npy_int16      int16_t
915  * ctypedef npy_int32      int32_t
916  */
917 typedef npy_int8 __pyx_t_5numpy_int8_t;
918 
919 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":691
920  *
921  * ctypedef npy_int8       int8_t
922  * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
923  * ctypedef npy_int32      int32_t
924  * ctypedef npy_int64      int64_t
925  */
926 typedef npy_int16 __pyx_t_5numpy_int16_t;
927 
928 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":692
929  * ctypedef npy_int8       int8_t
930  * ctypedef npy_int16      int16_t
931  * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
932  * ctypedef npy_int64      int64_t
933  * #ctypedef npy_int96      int96_t
934  */
935 typedef npy_int32 __pyx_t_5numpy_int32_t;
936 
937 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":693
938  * ctypedef npy_int16      int16_t
939  * ctypedef npy_int32      int32_t
940  * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
941  * #ctypedef npy_int96      int96_t
942  * #ctypedef npy_int128     int128_t
943  */
944 typedef npy_int64 __pyx_t_5numpy_int64_t;
945 
946 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":697
947  * #ctypedef npy_int128     int128_t
948  *
949  * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
950  * ctypedef npy_uint16     uint16_t
951  * ctypedef npy_uint32     uint32_t
952  */
953 typedef npy_uint8 __pyx_t_5numpy_uint8_t;
954 
955 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":698
956  *
957  * ctypedef npy_uint8      uint8_t
958  * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
959  * ctypedef npy_uint32     uint32_t
960  * ctypedef npy_uint64     uint64_t
961  */
962 typedef npy_uint16 __pyx_t_5numpy_uint16_t;
963 
964 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":699
965  * ctypedef npy_uint8      uint8_t
966  * ctypedef npy_uint16     uint16_t
967  * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
968  * ctypedef npy_uint64     uint64_t
969  * #ctypedef npy_uint96     uint96_t
970  */
971 typedef npy_uint32 __pyx_t_5numpy_uint32_t;
972 
973 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":700
974  * ctypedef npy_uint16     uint16_t
975  * ctypedef npy_uint32     uint32_t
976  * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
977  * #ctypedef npy_uint96     uint96_t
978  * #ctypedef npy_uint128    uint128_t
979  */
980 typedef npy_uint64 __pyx_t_5numpy_uint64_t;
981 
982 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":704
983  * #ctypedef npy_uint128    uint128_t
984  *
985  * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
986  * ctypedef npy_float64    float64_t
987  * #ctypedef npy_float80    float80_t
988  */
989 typedef npy_float32 __pyx_t_5numpy_float32_t;
990 
991 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":705
992  *
993  * ctypedef npy_float32    float32_t
994  * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
995  * #ctypedef npy_float80    float80_t
996  * #ctypedef npy_float128   float128_t
997  */
998 typedef npy_float64 __pyx_t_5numpy_float64_t;
999 
1000 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":714
1001  * # The int types are mapped a bit surprising --
1002  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1003  * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
1004  * ctypedef npy_longlong   long_t
1005  * ctypedef npy_longlong   longlong_t
1006  */
1007 typedef npy_long __pyx_t_5numpy_int_t;
1008 
1009 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":715
1010  * # numpy.int corresponds to 'l' and numpy.long to 'q'
1011  * ctypedef npy_long       int_t
1012  * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
1013  * ctypedef npy_longlong   longlong_t
1014  *
1015  */
1016 typedef npy_longlong __pyx_t_5numpy_long_t;
1017 
1018 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":716
1019  * ctypedef npy_long       int_t
1020  * ctypedef npy_longlong   long_t
1021  * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
1022  *
1023  * ctypedef npy_ulong      uint_t
1024  */
1025 typedef npy_longlong __pyx_t_5numpy_longlong_t;
1026 
1027 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":718
1028  * ctypedef npy_longlong   longlong_t
1029  *
1030  * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
1031  * ctypedef npy_ulonglong  ulong_t
1032  * ctypedef npy_ulonglong  ulonglong_t
1033  */
1034 typedef npy_ulong __pyx_t_5numpy_uint_t;
1035 
1036 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":719
1037  *
1038  * ctypedef npy_ulong      uint_t
1039  * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
1040  * ctypedef npy_ulonglong  ulonglong_t
1041  *
1042  */
1043 typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
1044 
1045 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":720
1046  * ctypedef npy_ulong      uint_t
1047  * ctypedef npy_ulonglong  ulong_t
1048  * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
1049  *
1050  * ctypedef npy_intp       intp_t
1051  */
1052 typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
1053 
1054 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":722
1055  * ctypedef npy_ulonglong  ulonglong_t
1056  *
1057  * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
1058  * ctypedef npy_uintp      uintp_t
1059  *
1060  */
1061 typedef npy_intp __pyx_t_5numpy_intp_t;
1062 
1063 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":723
1064  *
1065  * ctypedef npy_intp       intp_t
1066  * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
1067  *
1068  * ctypedef npy_double     float_t
1069  */
1070 typedef npy_uintp __pyx_t_5numpy_uintp_t;
1071 
1072 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":725
1073  * ctypedef npy_uintp      uintp_t
1074  *
1075  * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
1076  * ctypedef npy_double     double_t
1077  * ctypedef npy_longdouble longdouble_t
1078  */
1079 typedef npy_double __pyx_t_5numpy_float_t;
1080 
1081 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":726
1082  *
1083  * ctypedef npy_double     float_t
1084  * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
1085  * ctypedef npy_longdouble longdouble_t
1086  *
1087  */
1088 typedef npy_double __pyx_t_5numpy_double_t;
1089 
1090 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":727
1091  * ctypedef npy_double     float_t
1092  * ctypedef npy_double     double_t
1093  * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
1094  *
1095  * ctypedef npy_cfloat      cfloat_t
1096  */
1097 typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
1098 
1099 /* "rasterio/_io.pxd":42
1100  *
1101  *
1102  * ctypedef np.uint8_t DTYPE_UBYTE_t             # <<<<<<<<<<<<<<
1103  * ctypedef np.uint16_t DTYPE_UINT16_t
1104  * ctypedef np.int16_t DTYPE_INT16_t
1105  */
1106 typedef __pyx_t_5numpy_uint8_t __pyx_t_8rasterio_3_io_DTYPE_UBYTE_t;
1107 
1108 /* "rasterio/_io.pxd":43
1109  *
1110  * ctypedef np.uint8_t DTYPE_UBYTE_t
1111  * ctypedef np.uint16_t DTYPE_UINT16_t             # <<<<<<<<<<<<<<
1112  * ctypedef np.int16_t DTYPE_INT16_t
1113  * ctypedef np.uint32_t DTYPE_UINT32_t
1114  */
1115 typedef __pyx_t_5numpy_uint16_t __pyx_t_8rasterio_3_io_DTYPE_UINT16_t;
1116 
1117 /* "rasterio/_io.pxd":44
1118  * ctypedef np.uint8_t DTYPE_UBYTE_t
1119  * ctypedef np.uint16_t DTYPE_UINT16_t
1120  * ctypedef np.int16_t DTYPE_INT16_t             # <<<<<<<<<<<<<<
1121  * ctypedef np.uint32_t DTYPE_UINT32_t
1122  * ctypedef np.int32_t DTYPE_INT32_t
1123  */
1124 typedef __pyx_t_5numpy_int16_t __pyx_t_8rasterio_3_io_DTYPE_INT16_t;
1125 
1126 /* "rasterio/_io.pxd":45
1127  * ctypedef np.uint16_t DTYPE_UINT16_t
1128  * ctypedef np.int16_t DTYPE_INT16_t
1129  * ctypedef np.uint32_t DTYPE_UINT32_t             # <<<<<<<<<<<<<<
1130  * ctypedef np.int32_t DTYPE_INT32_t
1131  * ctypedef np.float32_t DTYPE_FLOAT32_t
1132  */
1133 typedef __pyx_t_5numpy_uint32_t __pyx_t_8rasterio_3_io_DTYPE_UINT32_t;
1134 
1135 /* "rasterio/_io.pxd":46
1136  * ctypedef np.int16_t DTYPE_INT16_t
1137  * ctypedef np.uint32_t DTYPE_UINT32_t
1138  * ctypedef np.int32_t DTYPE_INT32_t             # <<<<<<<<<<<<<<
1139  * ctypedef np.float32_t DTYPE_FLOAT32_t
1140  * ctypedef np.float64_t DTYPE_FLOAT64_t
1141  */
1142 typedef __pyx_t_5numpy_int32_t __pyx_t_8rasterio_3_io_DTYPE_INT32_t;
1143 
1144 /* "rasterio/_io.pxd":47
1145  * ctypedef np.uint32_t DTYPE_UINT32_t
1146  * ctypedef np.int32_t DTYPE_INT32_t
1147  * ctypedef np.float32_t DTYPE_FLOAT32_t             # <<<<<<<<<<<<<<
1148  * ctypedef np.float64_t DTYPE_FLOAT64_t
1149  *
1150  */
1151 typedef __pyx_t_5numpy_float32_t __pyx_t_8rasterio_3_io_DTYPE_FLOAT32_t;
1152 
1153 /* "rasterio/_io.pxd":48
1154  * ctypedef np.int32_t DTYPE_INT32_t
1155  * ctypedef np.float32_t DTYPE_FLOAT32_t
1156  * ctypedef np.float64_t DTYPE_FLOAT64_t             # <<<<<<<<<<<<<<
1157  *
1158  *
1159  */
1160 typedef __pyx_t_5numpy_float64_t __pyx_t_8rasterio_3_io_DTYPE_FLOAT64_t;
1161 /* Declarations.proto */
1162 #if CYTHON_CCOMPLEX
1163   #ifdef __cplusplus
1164     typedef ::std::complex< float > __pyx_t_float_complex;
1165   #else
1166     typedef float _Complex __pyx_t_float_complex;
1167   #endif
1168 #else
1169     typedef struct { float real, imag; } __pyx_t_float_complex;
1170 #endif
1171 static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
1172 
1173 /* Declarations.proto */
1174 #if CYTHON_CCOMPLEX
1175   #ifdef __cplusplus
1176     typedef ::std::complex< double > __pyx_t_double_complex;
1177   #else
1178     typedef double _Complex __pyx_t_double_complex;
1179   #endif
1180 #else
1181     typedef struct { double real, imag; } __pyx_t_double_complex;
1182 #endif
1183 static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
1184 
1185 
1186 /*--- Type declarations ---*/
1187 struct __pyx_obj_8rasterio_5_base_DatasetBase;
1188 struct __pyx_obj_8rasterio_3_io_DatasetReaderBase;
1189 struct __pyx_obj_8rasterio_3_io_DatasetWriterBase;
1190 struct __pyx_obj_8rasterio_3_io_BufferedDatasetWriterBase;
1191 struct __pyx_obj_8rasterio_3_io_InMemoryRaster;
1192 struct __pyx_obj_8rasterio_3_io_MemoryFileBase;
1193 struct __pyx_obj_8rasterio_9_features_GeomBuilder;
1194 struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder;
1195 struct __pyx_obj_8rasterio_9_features_ShapeIterator;
1196 struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes;
1197 struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve;
1198 struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr;
1199 struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode;
1200 struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr;
1201 
1202 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":729
1203  * ctypedef npy_longdouble longdouble_t
1204  *
1205  * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
1206  * ctypedef npy_cdouble     cdouble_t
1207  * ctypedef npy_clongdouble clongdouble_t
1208  */
1209 typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
1210 
1211 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":730
1212  *
1213  * ctypedef npy_cfloat      cfloat_t
1214  * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
1215  * ctypedef npy_clongdouble clongdouble_t
1216  *
1217  */
1218 typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
1219 
1220 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":731
1221  * ctypedef npy_cfloat      cfloat_t
1222  * ctypedef npy_cdouble     cdouble_t
1223  * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
1224  *
1225  * ctypedef npy_cdouble     complex_t
1226  */
1227 typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
1228 
1229 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":733
1230  * ctypedef npy_clongdouble clongdouble_t
1231  *
1232  * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
1233  *
1234  * cdef inline object PyArray_MultiIterNew1(a):
1235  */
1236 typedef npy_cdouble __pyx_t_5numpy_complex_t;
1237 struct __pyx_opt_args_8rasterio_3_io_io_auto;
1238 
1239 /* "rasterio/_io.pxd":53
1240  * cdef bint in_dtype_range(value, dtype)
1241  *
1242  * cdef int io_auto(image, GDALRasterBandH band, bint write, int resampling=*) except -1             # <<<<<<<<<<<<<<
1243  */
1244 struct __pyx_opt_args_8rasterio_3_io_io_auto {
1245   int __pyx_n;
1246   int resampling;
1247 };
1248 
1249 /* "rasterio/_base.pxd":6
1250  *
1251  *
1252  * cdef class DatasetBase:             # <<<<<<<<<<<<<<
1253  *
1254  *     cdef GDALDatasetH _hds
1255  */
1256 struct __pyx_obj_8rasterio_5_base_DatasetBase {
1257   PyObject_HEAD
1258   struct __pyx_vtabstruct_8rasterio_5_base_DatasetBase *__pyx_vtab;
1259   GDALDatasetH _hds;
1260   PyObject *name;
1261   PyObject *mode;
1262   PyObject *options;
1263   PyObject *width;
1264   PyObject *height;
1265   PyObject *shape;
1266   PyObject *driver;
1267   PyObject *_count;
1268   PyObject *_dtypes;
1269   PyObject *_closed;
1270   PyObject *_crs;
1271   PyObject *_crs_wkt;
1272   PyObject *_transform;
1273   PyObject *_block_shapes;
1274   PyObject *_nodatavals;
1275   PyObject *_units;
1276   PyObject *_descriptions;
1277   PyObject *_scales;
1278   PyObject *_offsets;
1279   PyObject *_read;
1280   PyObject *_gcps;
1281   PyObject *_rpcs;
1282   PyObject *_env;
1283 };
1284 
1285 
1286 /* "rasterio/_io.pxd":10
1287  *
1288  *
1289  * cdef class DatasetReaderBase(DatasetBase):             # <<<<<<<<<<<<<<
1290  *     pass
1291  *
1292  */
1293 struct __pyx_obj_8rasterio_3_io_DatasetReaderBase {
1294   struct __pyx_obj_8rasterio_5_base_DatasetBase __pyx_base;
1295 };
1296 
1297 
1298 /* "rasterio/_io.pxd":14
1299  *
1300  *
1301  * cdef class DatasetWriterBase(DatasetReaderBase):             # <<<<<<<<<<<<<<
1302  *     cdef readonly object _init_dtype
1303  *     cdef readonly object _init_nodata
1304  */
1305 struct __pyx_obj_8rasterio_3_io_DatasetWriterBase {
1306   struct __pyx_obj_8rasterio_3_io_DatasetReaderBase __pyx_base;
1307   PyObject *_init_dtype;
1308   PyObject *_init_nodata;
1309   PyObject *_init_gcps;
1310   PyObject *_init_rpcs;
1311   PyObject *_options;
1312 };
1313 
1314 
1315 /* "rasterio/_io.pxd":22
1316  *
1317  *
1318  * cdef class BufferedDatasetWriterBase(DatasetWriterBase):             # <<<<<<<<<<<<<<
1319  *     pass
1320  *
1321  */
1322 struct __pyx_obj_8rasterio_3_io_BufferedDatasetWriterBase {
1323   struct __pyx_obj_8rasterio_3_io_DatasetWriterBase __pyx_base;
1324 };
1325 
1326 
1327 /* "rasterio/_io.pxd":26
1328  *
1329  *
1330  * cdef class InMemoryRaster:             # <<<<<<<<<<<<<<
1331  *     cdef GDALDatasetH _hds
1332  *     cdef double gdal_transform[6]
1333  */
1334 struct __pyx_obj_8rasterio_3_io_InMemoryRaster {
1335   PyObject_HEAD
1336   struct __pyx_vtabstruct_8rasterio_3_io_InMemoryRaster *__pyx_vtab;
1337   GDALDatasetH _hds;
1338   double gdal_transform[6];
1339   int *band_ids;
1340   PyArrayObject *_image;
1341   PyObject *crs;
1342   PyObject *transform;
1343 };
1344 
1345 
1346 /* "rasterio/_io.pxd":38
1347  *
1348  *
1349  * cdef class MemoryFileBase:             # <<<<<<<<<<<<<<
1350  *     cdef VSILFILE * _vsif
1351  *
1352  */
1353 struct __pyx_obj_8rasterio_3_io_MemoryFileBase {
1354   PyObject_HEAD
1355   VSILFILE *_vsif;
1356 };
1357 
1358 
1359 /* "rasterio/_features.pxd":6
1360  *
1361  *
1362  * cdef class GeomBuilder:             # <<<<<<<<<<<<<<
1363  *
1364  *     cdef OGRGeometryH geom
1365  */
1366 struct __pyx_obj_8rasterio_9_features_GeomBuilder {
1367   PyObject_HEAD
1368   struct __pyx_vtabstruct_8rasterio_9_features_GeomBuilder *__pyx_vtab;
1369   OGRGeometryH geom;
1370   PyObject *code;
1371   PyObject *geomtypename;
1372   PyObject *ndims;
1373 };
1374 
1375 
1376 /* "rasterio/_features.pxd":24
1377  *
1378  *
1379  * cdef class OGRGeomBuilder:             # <<<<<<<<<<<<<<
1380  *
1381  *     cdef OGRGeometryH _createOgrGeometry(self, int geom_type) except NULL
1382  */
1383 struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder {
1384   PyObject_HEAD
1385   struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *__pyx_vtab;
1386 };
1387 
1388 
1389 /* "rasterio/_features.pxd":39
1390  *
1391  *
1392  * cdef class ShapeIterator:             # <<<<<<<<<<<<<<
1393  *
1394  *     cdef OGRLayerH layer
1395  */
1396 struct __pyx_obj_8rasterio_9_features_ShapeIterator {
1397   PyObject_HEAD
1398   OGRLayerH layer;
1399   int fieldtype;
1400 };
1401 
1402 
1403 /* "rasterio/_features.pyx":22
1404  *
1405  *
1406  * def _shapes(image, mask, connectivity, transform):             # <<<<<<<<<<<<<<
1407  *     """
1408  *     Return a generator of (polygon, value) for each each set of adjacent pixels
1409  */
1410 struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes {
1411   PyObject_HEAD
1412   GDALRasterBandH __pyx_v_band;
1413   int __pyx_v_cols;
1414   PyObject *__pyx_v_connectivity;
1415   GDALDriverH __pyx_v_driver;
1416   OGRFieldDefnH __pyx_v_fielddefn;
1417   int __pyx_v_fieldtp;
1418   OGRDataSourceH __pyx_v_fs;
1419   PyObject *__pyx_v_image;
1420   PyObject *__pyx_v_is_float;
1421   OGRLayerH __pyx_v_layer;
1422   PyObject *__pyx_v_mask;
1423   struct __pyx_obj_8rasterio_3_io_InMemoryRaster *__pyx_v_mask_ds;
1424   GDALRasterBandH __pyx_v_maskband;
1425   struct __pyx_obj_8rasterio_3_io_InMemoryRaster *__pyx_v_mem_ds;
1426   PyObject *__pyx_v_mrdr;
1427   char **__pyx_v_options;
1428   PyObject *__pyx_v_rdr;
1429   int __pyx_v_retval;
1430   int __pyx_v_rows;
1431   PyObject *__pyx_v_s;
1432   struct __pyx_obj_8rasterio_9_features_ShapeIterator *__pyx_v_shape_iter;
1433   PyObject *__pyx_v_transform;
1434   PyObject *__pyx_v_v;
1435   PyObject *__pyx_v_valid_dtypes;
1436   PyObject *__pyx_t_0;
1437   Py_ssize_t __pyx_t_1;
1438   PyObject *(*__pyx_t_2)(PyObject *);
1439 };
1440 
1441 
1442 /* "rasterio/_features.pyx":154
1443  *
1444  *
1445  * def _sieve(image, size, out, mask, connectivity):             # <<<<<<<<<<<<<<
1446  *     """
1447  *     Replaces small polygons in `image` with the value of their largest
1448  */
1449 struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve {
1450   PyObject_HEAD
1451   PyObject *__pyx_v_valid_dtypes;
1452 };
1453 
1454 
1455 /* "rasterio/_features.pyx":189
1456  *
1457  *     if _getnpdtype(image.dtype).name not in valid_dtypes:
1458  *         valid_types_str = ', '.join(('rasterio.{0}'.format(t) for t             # <<<<<<<<<<<<<<
1459  *                                      in valid_dtypes))
1460  *         raise ValueError(
1461  */
1462 struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr {
1463   PyObject_HEAD
1464   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve *__pyx_outer_scope;
1465   PyObject *__pyx_v_t;
1466 };
1467 
1468 
1469 /* "rasterio/_features.pyx":371
1470  *
1471  *
1472  * def _explode(coords):             # <<<<<<<<<<<<<<
1473  *     """Explode a GeoJSON geometry's coordinates object and yield
1474  *     coordinate tuples. As long as the input is conforming, the type of
1475  */
1476 struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode {
1477   PyObject_HEAD
1478   PyObject *__pyx_v_coords;
1479   PyObject *__pyx_v_e;
1480   PyObject *__pyx_v_f;
1481   PyObject *__pyx_t_0;
1482   Py_ssize_t __pyx_t_1;
1483   PyObject *(*__pyx_t_2)(PyObject *);
1484   PyObject *__pyx_t_3;
1485   Py_ssize_t __pyx_t_4;
1486   PyObject *(*__pyx_t_5)(PyObject *);
1487 };
1488 
1489 
1490 /* "rasterio/_features.pyx":473
1491  * # Mapping of GeoJSON type names to OGR integer geometry types
1492  * GEOJSON2OGR_GEOMETRY_TYPES = dict(
1493  *     (v, k) for k, v in GEOMETRY_TYPES.iteritems()             # <<<<<<<<<<<<<<
1494  * )
1495  *
1496  */
1497 struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr {
1498   PyObject_HEAD
1499   PyObject *__pyx_v_k;
1500   PyObject *__pyx_v_v;
1501 };
1502 
1503 
1504 
1505 /* "rasterio/_base.pxd":6
1506  *
1507  *
1508  * cdef class DatasetBase:             # <<<<<<<<<<<<<<
1509  *
1510  *     cdef GDALDatasetH _hds
1511  */
1512 
1513 struct __pyx_vtabstruct_8rasterio_5_base_DatasetBase {
1514   GDALDatasetH (*handle)(struct __pyx_obj_8rasterio_5_base_DatasetBase *);
1515   GDALRasterBandH (*band)(struct __pyx_obj_8rasterio_5_base_DatasetBase *, int);
1516 };
1517 static struct __pyx_vtabstruct_8rasterio_5_base_DatasetBase *__pyx_vtabptr_8rasterio_5_base_DatasetBase;
1518 
1519 
1520 /* "rasterio/_io.pxd":10
1521  *
1522  *
1523  * cdef class DatasetReaderBase(DatasetBase):             # <<<<<<<<<<<<<<
1524  *     pass
1525  *
1526  */
1527 
1528 struct __pyx_vtabstruct_8rasterio_3_io_DatasetReaderBase {
1529   struct __pyx_vtabstruct_8rasterio_5_base_DatasetBase __pyx_base;
1530 };
1531 static struct __pyx_vtabstruct_8rasterio_3_io_DatasetReaderBase *__pyx_vtabptr_8rasterio_3_io_DatasetReaderBase;
1532 
1533 
1534 /* "rasterio/_io.pxd":14
1535  *
1536  *
1537  * cdef class DatasetWriterBase(DatasetReaderBase):             # <<<<<<<<<<<<<<
1538  *     cdef readonly object _init_dtype
1539  *     cdef readonly object _init_nodata
1540  */
1541 
1542 struct __pyx_vtabstruct_8rasterio_3_io_DatasetWriterBase {
1543   struct __pyx_vtabstruct_8rasterio_3_io_DatasetReaderBase __pyx_base;
1544 };
1545 static struct __pyx_vtabstruct_8rasterio_3_io_DatasetWriterBase *__pyx_vtabptr_8rasterio_3_io_DatasetWriterBase;
1546 
1547 
1548 /* "rasterio/_io.pxd":22
1549  *
1550  *
1551  * cdef class BufferedDatasetWriterBase(DatasetWriterBase):             # <<<<<<<<<<<<<<
1552  *     pass
1553  *
1554  */
1555 
1556 struct __pyx_vtabstruct_8rasterio_3_io_BufferedDatasetWriterBase {
1557   struct __pyx_vtabstruct_8rasterio_3_io_DatasetWriterBase __pyx_base;
1558 };
1559 static struct __pyx_vtabstruct_8rasterio_3_io_BufferedDatasetWriterBase *__pyx_vtabptr_8rasterio_3_io_BufferedDatasetWriterBase;
1560 
1561 
1562 /* "rasterio/_io.pxd":26
1563  *
1564  *
1565  * cdef class InMemoryRaster:             # <<<<<<<<<<<<<<
1566  *     cdef GDALDatasetH _hds
1567  *     cdef double gdal_transform[6]
1568  */
1569 
1570 struct __pyx_vtabstruct_8rasterio_3_io_InMemoryRaster {
1571   GDALDatasetH (*handle)(struct __pyx_obj_8rasterio_3_io_InMemoryRaster *);
1572   GDALRasterBandH (*band)(struct __pyx_obj_8rasterio_3_io_InMemoryRaster *, int);
1573 };
1574 static struct __pyx_vtabstruct_8rasterio_3_io_InMemoryRaster *__pyx_vtabptr_8rasterio_3_io_InMemoryRaster;
1575 
1576 
1577 /* "rasterio/_features.pyx":487
1578  *
1579  *
1580  * cdef class GeomBuilder:             # <<<<<<<<<<<<<<
1581  *     """Builds a GeoJSON (Fiona-style) geometry from an OGR geometry."""
1582  *
1583  */
1584 
1585 struct __pyx_vtabstruct_8rasterio_9_features_GeomBuilder {
1586   PyObject *(*_buildCoords)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, OGRGeometryH);
1587   PyObject *(*_buildPoint)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch);
1588   PyObject *(*_buildLineString)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch);
1589   PyObject *(*_buildLinearRing)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch);
1590   PyObject *(*_buildParts)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, OGRGeometryH);
1591   PyObject *(*_buildPolygon)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch);
1592   PyObject *(*_buildMultiPoint)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch);
1593   PyObject *(*_buildMultiLineString)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch);
1594   PyObject *(*_buildMultiPolygon)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch);
1595   PyObject *(*build)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, OGRGeometryH);
1596 };
1597 static struct __pyx_vtabstruct_8rasterio_9_features_GeomBuilder *__pyx_vtabptr_8rasterio_9_features_GeomBuilder;
1598 
1599 
1600 /* "rasterio/_features.pyx":559
1601  *
1602  *
1603  * cdef class OGRGeomBuilder:             # <<<<<<<<<<<<<<
1604  *     """
1605  *     Builds an OGR geometry from GeoJSON geometry.
1606  */
1607 
1608 struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder {
1609   OGRGeometryH (*_createOgrGeometry)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, int);
1610   PyObject *(*_addPointToGeometry)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, OGRGeometryH, PyObject *);
1611   OGRGeometryH (*_buildPoint)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *);
1612   OGRGeometryH (*_buildLineString)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *);
1613   OGRGeometryH (*_buildLinearRing)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *);
1614   OGRGeometryH (*_buildPolygon)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *);
1615   OGRGeometryH (*_buildMultiPoint)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *);
1616   OGRGeometryH (*_buildMultiLineString)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *);
1617   OGRGeometryH (*_buildMultiPolygon)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *);
1618   OGRGeometryH (*_buildGeomCollection)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *);
1619   OGRGeometryH (*build)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *);
1620 };
1621 static struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *__pyx_vtabptr_8rasterio_9_features_OGRGeomBuilder;
1622 
1623 /* --- Runtime support code (head) --- */
1624 /* Refnanny.proto */
1625 #ifndef CYTHON_REFNANNY
1626   #define CYTHON_REFNANNY 0
1627 #endif
1628 #if CYTHON_REFNANNY
1629   typedef struct {
1630     void (*INCREF)(void*, PyObject*, int);
1631     void (*DECREF)(void*, PyObject*, int);
1632     void (*GOTREF)(void*, PyObject*, int);
1633     void (*GIVEREF)(void*, PyObject*, int);
1634     void* (*SetupContext)(const char*, int, const char*);
1635     void (*FinishContext)(void**);
1636   } __Pyx_RefNannyAPIStruct;
1637   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
1638   static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
1639   #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
1640 #ifdef WITH_THREAD
1641   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1642           if (acquire_gil) {\
1643               PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
1644               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1645               PyGILState_Release(__pyx_gilstate_save);\
1646           } else {\
1647               __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
1648           }
1649 #else
1650   #define __Pyx_RefNannySetupContext(name, acquire_gil)\
1651           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
1652 #endif
1653   #define __Pyx_RefNannyFinishContext()\
1654           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
1655   #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1656   #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1657   #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1658   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
1659   #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
1660   #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
1661   #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
1662   #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
1663 #else
1664   #define __Pyx_RefNannyDeclarations
1665   #define __Pyx_RefNannySetupContext(name, acquire_gil)
1666   #define __Pyx_RefNannyFinishContext()
1667   #define __Pyx_INCREF(r) Py_INCREF(r)
1668   #define __Pyx_DECREF(r) Py_DECREF(r)
1669   #define __Pyx_GOTREF(r)
1670   #define __Pyx_GIVEREF(r)
1671   #define __Pyx_XINCREF(r) Py_XINCREF(r)
1672   #define __Pyx_XDECREF(r) Py_XDECREF(r)
1673   #define __Pyx_XGOTREF(r)
1674   #define __Pyx_XGIVEREF(r)
1675 #endif
1676 #define __Pyx_XDECREF_SET(r, v) do {\
1677         PyObject *tmp = (PyObject *) r;\
1678         r = v; __Pyx_XDECREF(tmp);\
1679     } while (0)
1680 #define __Pyx_DECREF_SET(r, v) do {\
1681         PyObject *tmp = (PyObject *) r;\
1682         r = v; __Pyx_DECREF(tmp);\
1683     } while (0)
1684 #define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
1685 #define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
1686 
1687 /* PyObjectGetAttrStr.proto */
1688 #if CYTHON_USE_TYPE_SLOTS
1689 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
1690 #else
1691 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
1692 #endif
1693 
1694 /* GetBuiltinName.proto */
1695 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
1696 
1697 /* IterFinish.proto */
1698 static CYTHON_INLINE int __Pyx_IterFinish(void);
1699 
1700 /* PyFunctionFastCall.proto */
1701 #if CYTHON_FAST_PYCALL
1702 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
1703     __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
1704 #if 1 || PY_VERSION_HEX < 0x030600B1
1705 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1706 #else
1707 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
1708 #endif
1709 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
1710     (sizeof(char [1 - 2*!(cond)]) - 1)
1711 #ifndef Py_MEMBER_SIZE
1712 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
1713 #endif
1714   static size_t __pyx_pyframe_localsplus_offset = 0;
1715   #include "frameobject.h"
1716   #define __Pxy_PyFrame_Initialize_Offsets()\
1717     ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
1718      (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
1719   #define __Pyx_PyFrame_GetLocalsplus(frame)\
1720     (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1721 #endif
1722 
1723 /* PyObjectCall.proto */
1724 #if CYTHON_COMPILING_IN_CPYTHON
1725 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1726 #else
1727 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1728 #endif
1729 
1730 /* PyObjectCallMethO.proto */
1731 #if CYTHON_COMPILING_IN_CPYTHON
1732 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1733 #endif
1734 
1735 /* PyObjectCallNoArg.proto */
1736 #if CYTHON_COMPILING_IN_CPYTHON
1737 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1738 #else
1739 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1740 #endif
1741 
1742 /* PyCFunctionFastCall.proto */
1743 #if CYTHON_FAST_PYCCALL
1744 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1745 #else
1746 #define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
1747 #endif
1748 
1749 /* PyObjectCallOneArg.proto */
1750 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1751 
1752 /* PyObjectGetMethod.proto */
1753 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
1754 
1755 /* PyObjectCallMethod0.proto */
1756 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
1757 
1758 /* RaiseNeedMoreValuesToUnpack.proto */
1759 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1760 
1761 /* RaiseTooManyValuesToUnpack.proto */
1762 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1763 
1764 /* UnpackItemEndCheck.proto */
1765 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
1766 
1767 /* RaiseNoneIterError.proto */
1768 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
1769 
1770 /* UnpackTupleError.proto */
1771 static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);
1772 
1773 /* UnpackTuple2.proto */
1774 #define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\
1775     (likely(is_tuple || PyTuple_Check(tuple)) ?\
1776         (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\
1777             __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\
1778             (__Pyx_UnpackTupleError(tuple, 2), -1)) :\
1779         __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple))
1780 static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
1781     PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
1782 static int __Pyx_unpack_tuple2_generic(
1783     PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);
1784 
1785 /* dict_iter.proto */
1786 static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
1787                                                    Py_ssize_t* p_orig_length, int* p_is_dict);
1788 static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
1789                                               PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);
1790 
1791 /* PyDictVersioning.proto */
1792 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
1793 #define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
1794 #define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
1795 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
1796     (version_var) = __PYX_GET_DICT_VERSION(dict);\
1797     (cache_var) = (value);
1798 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
1799     static PY_UINT64_T __pyx_dict_version = 0;\
1800     static PyObject *__pyx_dict_cached_value = NULL;\
1801     if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
1802         (VAR) = __pyx_dict_cached_value;\
1803     } else {\
1804         (VAR) = __pyx_dict_cached_value = (LOOKUP);\
1805         __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
1806     }\
1807 }
1808 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
1809 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
1810 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1811 #else
1812 #define __PYX_GET_DICT_VERSION(dict)  (0)
1813 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1814 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
1815 #endif
1816 
1817 /* GetModuleGlobalName.proto */
1818 #if CYTHON_USE_DICT_VERSIONS
1819 #define __Pyx_GetModuleGlobalName(var, name)  {\
1820     static PY_UINT64_T __pyx_dict_version = 0;\
1821     static PyObject *__pyx_dict_cached_value = NULL;\
1822     (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1823         (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1824         __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1825 }
1826 #define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
1827     PY_UINT64_T __pyx_dict_version;\
1828     PyObject *__pyx_dict_cached_value;\
1829     (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1830 }
1831 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1832 #else
1833 #define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1834 #define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
1835 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1836 #endif
1837 
1838 /* RaiseArgTupleInvalid.proto */
1839 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
1840     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
1841 
1842 /* RaiseDoubleKeywords.proto */
1843 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
1844 
1845 /* ParseKeywords.proto */
1846 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
1847     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
1848     const char* function_name);
1849 
1850 /* PyObjectCall2Args.proto */
1851 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1852 
1853 /* PySequenceContains.proto */
__Pyx_PySequence_ContainsTF(PyObject * item,PyObject * seq,int eq)1854 static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
1855     int result = PySequence_Contains(seq, item);
1856     return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
1857 }
1858 
1859 /* PyThreadStateGet.proto */
1860 #if CYTHON_FAST_THREAD_STATE
1861 #define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
1862 #define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
1863 #define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
1864 #else
1865 #define __Pyx_PyThreadState_declare
1866 #define __Pyx_PyThreadState_assign
1867 #define __Pyx_PyErr_Occurred()  PyErr_Occurred()
1868 #endif
1869 
1870 /* PyErrFetchRestore.proto */
1871 #if CYTHON_FAST_THREAD_STATE
1872 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1873 #define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1874 #define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1875 #define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1876 #define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1877 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1878 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1879 #if CYTHON_COMPILING_IN_CPYTHON
1880 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1881 #else
1882 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1883 #endif
1884 #else
1885 #define __Pyx_PyErr_Clear() PyErr_Clear()
1886 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1887 #define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
1888 #define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
1889 #define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
1890 #define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
1891 #define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
1892 #define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
1893 #endif
1894 
1895 /* RaiseException.proto */
1896 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1897 
1898 /* PyIntCompare.proto */
1899 static CYTHON_INLINE PyObject* __Pyx_PyInt_NeObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
1900 
1901 /* ExtTypeTest.proto */
1902 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
1903 
1904 /* IncludeStringH.proto */
1905 #include <string.h>
1906 
1907 /* BytesEquals.proto */
1908 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
1909 
1910 /* UnicodeEquals.proto */
1911 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
1912 
1913 /* PyIntCompare.proto */
1914 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
1915 
1916 /* GetException.proto */
1917 #if CYTHON_FAST_THREAD_STATE
1918 #define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
1919 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1920 #else
1921 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1922 #endif
1923 
1924 /* SwapException.proto */
1925 #if CYTHON_FAST_THREAD_STATE
1926 #define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
1927 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1928 #else
1929 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
1930 #endif
1931 
1932 /* GetTopmostException.proto */
1933 #if CYTHON_USE_EXC_INFO_STACK
1934 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1935 #endif
1936 
1937 /* SaveResetException.proto */
1938 #if CYTHON_FAST_THREAD_STATE
1939 #define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1940 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1941 #define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1942 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1943 #else
1944 #define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
1945 #define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
1946 #endif
1947 
1948 /* None.proto */
1949 static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);
1950 
1951 /* ListCompAppend.proto */
1952 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_ListComp_Append(PyObject * list,PyObject * x)1953 static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
1954     PyListObject* L = (PyListObject*) list;
1955     Py_ssize_t len = Py_SIZE(list);
1956     if (likely(L->allocated > len)) {
1957         Py_INCREF(x);
1958         PyList_SET_ITEM(list, len, x);
1959         __Pyx_SET_SIZE(list, len + 1);
1960         return 0;
1961     }
1962     return PyList_Append(list, x);
1963 }
1964 #else
1965 #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
1966 #endif
1967 
1968 /* GetItemInt.proto */
1969 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1970     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1971     __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1972     (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1973                __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1974 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1975     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1976     __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1977     (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1978 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1979                                                               int wraparound, int boundscheck);
1980 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1981     (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1982     __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1983     (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1984 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1985                                                               int wraparound, int boundscheck);
1986 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1987 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1988                                                      int is_list, int wraparound, int boundscheck);
1989 
1990 /* PyObjectLookupSpecial.proto */
1991 #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_LookupSpecial(PyObject * obj,PyObject * attr_name)1992 static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
1993     PyObject *res;
1994     PyTypeObject *tp = Py_TYPE(obj);
1995 #if PY_MAJOR_VERSION < 3
1996     if (unlikely(PyInstance_Check(obj)))
1997         return __Pyx_PyObject_GetAttrStr(obj, attr_name);
1998 #endif
1999     res = _PyType_Lookup(tp, attr_name);
2000     if (likely(res)) {
2001         descrgetfunc f = Py_TYPE(res)->tp_descr_get;
2002         if (!f) {
2003             Py_INCREF(res);
2004         } else {
2005             res = f(res, obj, (PyObject *)tp);
2006         }
2007     } else {
2008         PyErr_SetObject(PyExc_AttributeError, attr_name);
2009     }
2010     return res;
2011 }
2012 #else
2013 #define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
2014 #endif
2015 
2016 /* DictGetItem.proto */
2017 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
2018 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
2019 #define __Pyx_PyObject_Dict_GetItem(obj, name)\
2020     (likely(PyDict_CheckExact(obj)) ?\
2021      __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
2022 #else
2023 #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
2024 #define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
2025 #endif
2026 
2027 /* ListAppend.proto */
2028 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_PyList_Append(PyObject * list,PyObject * x)2029 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
2030     PyListObject* L = (PyListObject*) list;
2031     Py_ssize_t len = Py_SIZE(list);
2032     if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
2033         Py_INCREF(x);
2034         PyList_SET_ITEM(list, len, x);
2035         __Pyx_SET_SIZE(list, len + 1);
2036         return 0;
2037     }
2038     return PyList_Append(list, x);
2039 }
2040 #else
2041 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
2042 #endif
2043 
2044 /* ObjectGetItem.proto */
2045 #if CYTHON_USE_TYPE_SLOTS
2046 static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
2047 #else
2048 #define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
2049 #endif
2050 
2051 /* GetAttr.proto */
2052 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
2053 
2054 /* SliceObject.proto */
2055 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
2056         PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
2057         PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
2058         int has_cstart, int has_cstop, int wraparound);
2059 
2060 /* PyErrExceptionMatches.proto */
2061 #if CYTHON_FAST_THREAD_STATE
2062 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
2063 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
2064 #else
2065 #define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
2066 #endif
2067 
2068 /* GetAttr3.proto */
2069 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
2070 
2071 /* pyfrozenset_new.proto */
2072 static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it);
2073 
2074 /* PySetContains.proto */
2075 static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq);
2076 
2077 /* Import.proto */
2078 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
2079 
2080 /* ImportFrom.proto */
2081 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
2082 
2083 /* HasAttr.proto */
2084 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
2085 
2086 /* PyObject_GenericGetAttrNoDict.proto */
2087 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
2088 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
2089 #else
2090 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
2091 #endif
2092 
2093 /* PyObject_GenericGetAttr.proto */
2094 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
2095 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
2096 #else
2097 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
2098 #endif
2099 
2100 /* SetVTable.proto */
2101 static int __Pyx_SetVtable(PyObject *dict, void *vtable);
2102 
2103 /* PyObjectGetAttrStrNoError.proto */
2104 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
2105 
2106 /* SetupReduce.proto */
2107 static int __Pyx_setup_reduce(PyObject* type_obj);
2108 
2109 /* TypeImport.proto */
2110 #ifndef __PYX_HAVE_RT_ImportType_proto
2111 #define __PYX_HAVE_RT_ImportType_proto
2112 enum __Pyx_ImportType_CheckSize {
2113    __Pyx_ImportType_CheckSize_Error = 0,
2114    __Pyx_ImportType_CheckSize_Warn = 1,
2115    __Pyx_ImportType_CheckSize_Ignore = 2
2116 };
2117 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
2118 #endif
2119 
2120 /* GetVTable.proto */
2121 static void* __Pyx_GetVtable(PyObject *dict);
2122 
2123 /* CLineInTraceback.proto */
2124 #ifdef CYTHON_CLINE_IN_TRACEBACK
2125 #define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
2126 #else
2127 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
2128 #endif
2129 
2130 /* CodeObjectCache.proto */
2131 typedef struct {
2132     PyCodeObject* code_object;
2133     int code_line;
2134 } __Pyx_CodeObjectCacheEntry;
2135 struct __Pyx_CodeObjectCache {
2136     int count;
2137     int max_count;
2138     __Pyx_CodeObjectCacheEntry* entries;
2139 };
2140 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
2141 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
2142 static PyCodeObject *__pyx_find_code_object(int code_line);
2143 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
2144 
2145 /* AddTraceback.proto */
2146 static void __Pyx_AddTraceback(const char *funcname, int c_line,
2147                                int py_line, const char *filename);
2148 
2149 /* CIntToPy.proto */
2150 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
2151 
2152 /* CIntToPy.proto */
2153 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
2154 
2155 /* CIntToPy.proto */
2156 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);
2157 
2158 /* RealImag.proto */
2159 #if CYTHON_CCOMPLEX
2160   #ifdef __cplusplus
2161     #define __Pyx_CREAL(z) ((z).real())
2162     #define __Pyx_CIMAG(z) ((z).imag())
2163   #else
2164     #define __Pyx_CREAL(z) (__real__(z))
2165     #define __Pyx_CIMAG(z) (__imag__(z))
2166   #endif
2167 #else
2168     #define __Pyx_CREAL(z) ((z).real)
2169     #define __Pyx_CIMAG(z) ((z).imag)
2170 #endif
2171 #if defined(__cplusplus) && CYTHON_CCOMPLEX\
2172         && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
2173     #define __Pyx_SET_CREAL(z,x) ((z).real(x))
2174     #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
2175 #else
2176     #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
2177     #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
2178 #endif
2179 
2180 /* Arithmetic.proto */
2181 #if CYTHON_CCOMPLEX
2182     #define __Pyx_c_eq_float(a, b)   ((a)==(b))
2183     #define __Pyx_c_sum_float(a, b)  ((a)+(b))
2184     #define __Pyx_c_diff_float(a, b) ((a)-(b))
2185     #define __Pyx_c_prod_float(a, b) ((a)*(b))
2186     #define __Pyx_c_quot_float(a, b) ((a)/(b))
2187     #define __Pyx_c_neg_float(a)     (-(a))
2188   #ifdef __cplusplus
2189     #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
2190     #define __Pyx_c_conj_float(z)    (::std::conj(z))
2191     #if 1
2192         #define __Pyx_c_abs_float(z)     (::std::abs(z))
2193         #define __Pyx_c_pow_float(a, b)  (::std::pow(a, b))
2194     #endif
2195   #else
2196     #define __Pyx_c_is_zero_float(z) ((z)==0)
2197     #define __Pyx_c_conj_float(z)    (conjf(z))
2198     #if 1
2199         #define __Pyx_c_abs_float(z)     (cabsf(z))
2200         #define __Pyx_c_pow_float(a, b)  (cpowf(a, b))
2201     #endif
2202  #endif
2203 #else
2204     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
2205     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
2206     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
2207     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
2208     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
2209     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
2210     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
2211     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
2212     #if 1
2213         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
2214         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
2215     #endif
2216 #endif
2217 
2218 /* Arithmetic.proto */
2219 #if CYTHON_CCOMPLEX
2220     #define __Pyx_c_eq_double(a, b)   ((a)==(b))
2221     #define __Pyx_c_sum_double(a, b)  ((a)+(b))
2222     #define __Pyx_c_diff_double(a, b) ((a)-(b))
2223     #define __Pyx_c_prod_double(a, b) ((a)*(b))
2224     #define __Pyx_c_quot_double(a, b) ((a)/(b))
2225     #define __Pyx_c_neg_double(a)     (-(a))
2226   #ifdef __cplusplus
2227     #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
2228     #define __Pyx_c_conj_double(z)    (::std::conj(z))
2229     #if 1
2230         #define __Pyx_c_abs_double(z)     (::std::abs(z))
2231         #define __Pyx_c_pow_double(a, b)  (::std::pow(a, b))
2232     #endif
2233   #else
2234     #define __Pyx_c_is_zero_double(z) ((z)==0)
2235     #define __Pyx_c_conj_double(z)    (conj(z))
2236     #if 1
2237         #define __Pyx_c_abs_double(z)     (cabs(z))
2238         #define __Pyx_c_pow_double(a, b)  (cpow(a, b))
2239     #endif
2240  #endif
2241 #else
2242     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
2243     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
2244     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
2245     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
2246     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
2247     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
2248     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
2249     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
2250     #if 1
2251         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
2252         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
2253     #endif
2254 #endif
2255 
2256 /* CIntFromPy.proto */
2257 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
2258 
2259 /* CIntFromPy.proto */
2260 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
2261 
2262 /* CIntFromPy.proto */
2263 static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);
2264 
2265 /* FastTypeChecks.proto */
2266 #if CYTHON_COMPILING_IN_CPYTHON
2267 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
2268 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
2269 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
2270 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
2271 #else
2272 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
2273 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
2274 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
2275 #endif
2276 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
2277 
2278 /* FetchCommonType.proto */
2279 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
2280 
2281 /* PyObjectCallMethod1.proto */
2282 static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
2283 
2284 /* CoroutineBase.proto */
2285 typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
2286 #if CYTHON_USE_EXC_INFO_STACK
2287 #define __Pyx_ExcInfoStruct  _PyErr_StackItem
2288 #else
2289 typedef struct {
2290     PyObject *exc_type;
2291     PyObject *exc_value;
2292     PyObject *exc_traceback;
2293 } __Pyx_ExcInfoStruct;
2294 #endif
2295 typedef struct {
2296     PyObject_HEAD
2297     __pyx_coroutine_body_t body;
2298     PyObject *closure;
2299     __Pyx_ExcInfoStruct gi_exc_state;
2300     PyObject *gi_weakreflist;
2301     PyObject *classobj;
2302     PyObject *yieldfrom;
2303     PyObject *gi_name;
2304     PyObject *gi_qualname;
2305     PyObject *gi_modulename;
2306     PyObject *gi_code;
2307     int resume_label;
2308     char is_running;
2309 } __pyx_CoroutineObject;
2310 static __pyx_CoroutineObject *__Pyx__Coroutine_New(
2311     PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
2312     PyObject *name, PyObject *qualname, PyObject *module_name);
2313 static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
2314             __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
2315             PyObject *name, PyObject *qualname, PyObject *module_name);
2316 static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
2317 static int __Pyx_Coroutine_clear(PyObject *self);
2318 static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
2319 static PyObject *__Pyx_Coroutine_Close(PyObject *self);
2320 static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
2321 #if CYTHON_USE_EXC_INFO_STACK
2322 #define __Pyx_Coroutine_SwapException(self)
2323 #define __Pyx_Coroutine_ResetAndClearException(self)  __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
2324 #else
2325 #define __Pyx_Coroutine_SwapException(self) {\
2326     __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
2327     __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
2328     }
2329 #define __Pyx_Coroutine_ResetAndClearException(self) {\
2330     __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
2331     (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
2332     }
2333 #endif
2334 #if CYTHON_FAST_THREAD_STATE
2335 #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
2336     __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
2337 #else
2338 #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
2339     __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
2340 #endif
2341 static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
2342 static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);
2343 
2344 /* PatchModuleWithCoroutine.proto */
2345 static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);
2346 
2347 /* PatchGeneratorABC.proto */
2348 static int __Pyx_patch_abc(void);
2349 
2350 /* Generator.proto */
2351 #define __Pyx_Generator_USED
2352 static PyTypeObject *__pyx_GeneratorType = 0;
2353 #define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
2354 #define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
2355     __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
2356 static PyObject *__Pyx_Generator_Next(PyObject *self);
2357 static int __pyx_Generator_init(void);
2358 
2359 /* CheckBinaryVersion.proto */
2360 static int __Pyx_check_binary_version(void);
2361 
2362 /* FunctionImport.proto */
2363 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);
2364 
2365 /* InitStrings.proto */
2366 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
2367 
2368 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildCoords(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, OGRGeometryH __pyx_v_geom); /* proto*/
2369 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildPoint(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
2370 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildLineString(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
2371 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildLinearRing(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
2372 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildParts(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, OGRGeometryH __pyx_v_geom); /* proto*/
2373 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildPolygon(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
2374 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiPoint(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
2375 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiLineString(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
2376 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiPolygon(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/
2377 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder_build(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, OGRGeometryH __pyx_v_geom); /* proto*/
2378 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__createOgrGeometry(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, int __pyx_v_geom_type); /* proto*/
2379 static PyObject *__pyx_f_8rasterio_9_features_14OGRGeomBuilder__addPointToGeometry(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, OGRGeometryH __pyx_v_geom, PyObject *__pyx_v_coordinate); /* proto*/
2380 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildPoint(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates); /* proto*/
2381 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildLineString(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates); /* proto*/
2382 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildLinearRing(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates); /* proto*/
2383 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildPolygon(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates); /* proto*/
2384 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildMultiPoint(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates); /* proto*/
2385 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildMultiLineString(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates); /* proto*/
2386 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildMultiPolygon(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates); /* proto*/
2387 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildGeomCollection(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_geoms); /* proto*/
2388 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder_build(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_geometry); /* proto*/
2389 
2390 /* Module declarations from 'libc.string' */
2391 
2392 /* Module declarations from 'libc.stdio' */
2393 
2394 /* Module declarations from 'rasterio._err' */
2395 static int (*__pyx_f_8rasterio_4_err_exc_wrap_int)(int); /*proto*/
2396 static void *(*__pyx_f_8rasterio_4_err_exc_wrap_pointer)(void *); /*proto*/
2397 
2398 /* Module declarations from 'cpython.buffer' */
2399 
2400 /* Module declarations from '__builtin__' */
2401 
2402 /* Module declarations from 'cpython.type' */
2403 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
2404 
2405 /* Module declarations from 'cpython' */
2406 
2407 /* Module declarations from 'cpython.object' */
2408 
2409 /* Module declarations from 'cpython.ref' */
2410 
2411 /* Module declarations from 'cpython.mem' */
2412 
2413 /* Module declarations from 'numpy' */
2414 
2415 /* Module declarations from 'numpy' */
2416 static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
2417 static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
2418 static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
2419 static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
2420 static PyTypeObject *__pyx_ptype_5numpy_generic = 0;
2421 static PyTypeObject *__pyx_ptype_5numpy_number = 0;
2422 static PyTypeObject *__pyx_ptype_5numpy_integer = 0;
2423 static PyTypeObject *__pyx_ptype_5numpy_signedinteger = 0;
2424 static PyTypeObject *__pyx_ptype_5numpy_unsignedinteger = 0;
2425 static PyTypeObject *__pyx_ptype_5numpy_inexact = 0;
2426 static PyTypeObject *__pyx_ptype_5numpy_floating = 0;
2427 static PyTypeObject *__pyx_ptype_5numpy_complexfloating = 0;
2428 static PyTypeObject *__pyx_ptype_5numpy_flexible = 0;
2429 static PyTypeObject *__pyx_ptype_5numpy_character = 0;
2430 static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
2431 
2432 /* Module declarations from 'rasterio._base' */
2433 static PyTypeObject *__pyx_ptype_8rasterio_5_base_DatasetBase = 0;
2434 
2435 /* Module declarations from 'rasterio._io' */
2436 static PyTypeObject *__pyx_ptype_8rasterio_3_io_DatasetReaderBase = 0;
2437 static PyTypeObject *__pyx_ptype_8rasterio_3_io_DatasetWriterBase = 0;
2438 static PyTypeObject *__pyx_ptype_8rasterio_3_io_BufferedDatasetWriterBase = 0;
2439 static PyTypeObject *__pyx_ptype_8rasterio_3_io_InMemoryRaster = 0;
2440 static PyTypeObject *__pyx_ptype_8rasterio_3_io_MemoryFileBase = 0;
2441 static int (*__pyx_f_8rasterio_3_io_io_auto)(PyObject *, GDALRasterBandH, int, struct __pyx_opt_args_8rasterio_3_io_io_auto *__pyx_optional_args); /*proto*/
2442 
2443 /* Module declarations from 'rasterio._features' */
2444 static PyTypeObject *__pyx_ptype_8rasterio_9_features_GeomBuilder = 0;
2445 static PyTypeObject *__pyx_ptype_8rasterio_9_features_OGRGeomBuilder = 0;
2446 static PyTypeObject *__pyx_ptype_8rasterio_9_features_ShapeIterator = 0;
2447 static PyTypeObject *__pyx_ptype_8rasterio_9_features___pyx_scope_struct___shapes = 0;
2448 static PyTypeObject *__pyx_ptype_8rasterio_9_features___pyx_scope_struct_1__sieve = 0;
2449 static PyTypeObject *__pyx_ptype_8rasterio_9_features___pyx_scope_struct_2_genexpr = 0;
2450 static PyTypeObject *__pyx_ptype_8rasterio_9_features___pyx_scope_struct_3__explode = 0;
2451 static PyTypeObject *__pyx_ptype_8rasterio_9_features___pyx_scope_struct_4_genexpr = 0;
2452 static PyObject *__pyx_f_8rasterio_9_features__deleteOgrGeom(OGRGeometryH); /*proto*/
2453 static PyObject *__pyx_f_8rasterio_9_features__deleteOgrFeature(OGRFeatureH); /*proto*/
2454 static PyObject *__pyx_f_8rasterio_9_features___pyx_unpickle_OGRGeomBuilder__set_state(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *); /*proto*/
2455 #define __Pyx_MODULE_NAME "rasterio._features"
2456 extern int __pyx_module_is_main_rasterio___features;
2457 int __pyx_module_is_main_rasterio___features = 0;
2458 
2459 /* Implementation of 'rasterio._features' */
2460 static PyObject *__pyx_builtin_ValueError;
2461 static PyObject *__pyx_builtin_enumerate;
2462 static PyObject *__pyx_builtin_range;
2463 static PyObject *__pyx_builtin_min;
2464 static PyObject *__pyx_builtin_max;
2465 static PyObject *__pyx_builtin_zip;
2466 static PyObject *__pyx_builtin_TypeError;
2467 static PyObject *__pyx_builtin_StopIteration;
2468 static PyObject *__pyx_builtin_ImportError;
2469 static const char __pyx_k_e[] = "e";
2470 static const char __pyx_k_f[] = "f";
2471 static const char __pyx_k_i[] = "i";
2472 static const char __pyx_k_s[] = "s";
2473 static const char __pyx_k_v[] = "v";
2474 static const char __pyx_k__3[] = ", ";
2475 static const char __pyx_k_ds[] = "ds";
2476 static const char __pyx_k_fs[] = "fs";
2477 static const char __pyx_k_np[] = "np";
2478 static const char __pyx_k_get[] = "get";
2479 static const char __pyx_k_log[] = "log";
2480 static const char __pyx_k_max[] = "max";
2481 static const char __pyx_k_mem[] = "mem";
2482 static const char __pyx_k_min[] = "min";
2483 static const char __pyx_k_new[] = "__new__";
2484 static const char __pyx_k_out[] = "out";
2485 static const char __pyx_k_rdr[] = "rdr";
2486 static const char __pyx_k_udr[] = "udr";
2487 static const char __pyx_k_xyz[] = "xyz";
2488 static const char __pyx_k_zip[] = "zip";
2489 static const char __pyx_k_None[] = "None";
2490 static const char __pyx_k_args[] = "args";
2491 static const char __pyx_k_band[] = "band";
2492 static const char __pyx_k_bidx[] = "bidx";
2493 static const char __pyx_k_bool[] = "bool";
2494 static const char __pyx_k_cols[] = "cols";
2495 static const char __pyx_k_dict[] = "__dict__";
2496 static const char __pyx_k_exit[] = "__exit__";
2497 static const char __pyx_k_kind[] = "kind";
2498 static const char __pyx_k_main[] = "__main__";
2499 static const char __pyx_k_mask[] = "mask";
2500 static const char __pyx_k_mrdr[] = "mrdr";
2501 static const char __pyx_k_name[] = "name";
2502 static const char __pyx_k_read[] = "read";
2503 static const char __pyx_k_rows[] = "rows";
2504 static const char __pyx_k_send[] = "send";
2505 static const char __pyx_k_size[] = "size";
2506 static const char __pyx_k_test[] = "__test__";
2507 static const char __pyx_k_type[] = "type";
2508 static const char __pyx_k_xmax[] = "xmax";
2509 static const char __pyx_k_xmin[] = "xmin";
2510 static const char __pyx_k_ymax[] = "ymax";
2511 static const char __pyx_k_ymin[] = "ymin";
2512 static const char __pyx_k_Point[] = "Point";
2513 static const char __pyx_k_build[] = "_build";
2514 static const char __pyx_k_close[] = "close";
2515 static const char __pyx_k_debug[] = "debug";
2516 static const char __pyx_k_dtype[] = "dtype";
2517 static const char __pyx_k_enter[] = "__enter__";
2518 static const char __pyx_k_error[] = "error";
2519 static const char __pyx_k_geoms[] = "geoms";
2520 static const char __pyx_k_image[] = "image";
2521 static const char __pyx_k_int16[] = "int16";
2522 static const char __pyx_k_int32[] = "int32";
2523 static const char __pyx_k_layer[] = "layer";
2524 static const char __pyx_k_numpy[] = "numpy";
2525 static const char __pyx_k_point[] = "point";
2526 static const char __pyx_k_range[] = "range";
2527 static const char __pyx_k_shape[] = "shape";
2528 static const char __pyx_k_sieve[] = "_sieve";
2529 static const char __pyx_k_throw[] = "throw";
2530 static const char __pyx_k_uint8[] = "uint8";
2531 static const char __pyx_k_utf_8[] = "utf-8";
2532 static const char __pyx_k_value[] = "value";
2533 static const char __pyx_k_xmaxs[] = "xmaxs";
2534 static const char __pyx_k_xmins[] = "xmins";
2535 static const char __pyx_k_ymaxs[] = "ymaxs";
2536 static const char __pyx_k_ymins[] = "ymins";
2537 static const char __pyx_k_astype[] = "astype";
2538 static const char __pyx_k_bounds[] = "_bounds";
2539 static const char __pyx_k_coords[] = "coords";
2540 static const char __pyx_k_driver[] = "driver";
2541 static const char __pyx_k_dtypes[] = "dtypes";
2542 static const char __pyx_k_encode[] = "encode";
2543 static const char __pyx_k_format[] = "format";
2544 static const char __pyx_k_import[] = "__import__";
2545 static const char __pyx_k_mem_ds[] = "mem_ds";
2546 static const char __pyx_k_name_2[] = "__name__";
2547 static const char __pyx_k_pickle[] = "pickle";
2548 static const char __pyx_k_reduce[] = "__reduce__";
2549 static const char __pyx_k_retval[] = "retval";
2550 static const char __pyx_k_shapes[] = "_shapes";
2551 static const char __pyx_k_uint16[] = "uint16";
2552 static const char __pyx_k_update[] = "update";
2553 static const char __pyx_k_xyz_px[] = "xyz_px";
2554 static const char __pyx_k_Polygon[] = "Polygon";
2555 static const char __pyx_k_Unknown[] = "Unknown";
2556 static const char __pyx_k_explode[] = "_explode";
2557 static const char __pyx_k_feature[] = "feature";
2558 static const char __pyx_k_fieldtp[] = "fieldtp";
2559 static const char __pyx_k_float32[] = "float32";
2560 static const char __pyx_k_genexpr[] = "genexpr";
2561 static const char __pyx_k_in_band[] = "in_band";
2562 static const char __pyx_k_logging[] = "logging";
2563 static const char __pyx_k_mask_ds[] = "mask_ds";
2564 static const char __pyx_k_options[] = "options";
2565 static const char __pyx_k_3D_Point[] = "3D Point";
2566 static const char __pyx_k_MergeAlg[] = "MergeAlg";
2567 static const char __pyx_k_features[] = "features";
2568 static const char __pyx_k_geometry[] = "geometry";
2569 static const char __pyx_k_getstate[] = "__getstate__";
2570 static const char __pyx_k_is_float[] = "is_float";
2571 static const char __pyx_k_maskband[] = "maskband";
2572 static const char __pyx_k_north_up[] = "north_up";
2573 static const char __pyx_k_out_band[] = "out_band";
2574 static const char __pyx_k_pyx_type[] = "__pyx_type";
2575 static const char __pyx_k_rasterio[] = "rasterio";
2576 static const char __pyx_k_setstate[] = "__setstate__";
2577 static const char __pyx_k_shapes_2[] = "shapes";
2578 static const char __pyx_k_Null_geom[] = "Null geom";
2579 static const char __pyx_k_TypeError[] = "TypeError";
2580 static const char __pyx_k_enumerate[] = "enumerate";
2581 static const char __pyx_k_fielddefn[] = "fielddefn";
2582 static const char __pyx_k_getLogger[] = "getLogger";
2583 static const char __pyx_k_in_mem_ds[] = "in_mem_ds";
2584 static const char __pyx_k_iteritems[] = "iteritems";
2585 static const char __pyx_k_mask_band[] = "mask_band";
2586 static const char __pyx_k_merge_alg[] = "merge_alg";
2587 static const char __pyx_k_num_geoms[] = "num_geoms";
2588 static const char __pyx_k_pyx_state[] = "__pyx_state";
2589 static const char __pyx_k_rasterize[] = "_rasterize";
2590 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
2591 static const char __pyx_k_transform[] = "transform";
2592 static const char __pyx_k_3D_Polygon[] = "3D Polygon";
2593 static const char __pyx_k_LineString[] = "LineString";
2594 static const char __pyx_k_LinearRing[] = "LinearRing";
2595 static const char __pyx_k_MultiPoint[] = "MultiPoint";
2596 static const char __pyx_k_NULL_layer[] = "NULL layer";
2597 static const char __pyx_k_ValueError[] = "ValueError";
2598 static const char __pyx_k_all_shapes[] = "all_shapes";
2599 static const char __pyx_k_buildPoint[] = "_buildPoint";
2600 static const char __pyx_k_geometries[] = "geometries";
2601 static const char __pyx_k_getnpdtype[] = "_getnpdtype";
2602 static const char __pyx_k_is_ndarray[] = "is_ndarray";
2603 static const char __pyx_k_out_mem_ds[] = "out_mem_ds";
2604 static const char __pyx_k_pyx_result[] = "__pyx_result";
2605 static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
2606 static const char __pyx_k_rasterio_0[] = "rasterio.{0}";
2607 static const char __pyx_k_shape_iter[] = "shape_iter";
2608 static const char __pyx_k_GeomBuilder[] = "GeomBuilder";
2609 static const char __pyx_k_ImportError[] = "ImportError";
2610 static const char __pyx_k_NULL_driver[] = "NULL driver";
2611 static const char __pyx_k_PickleError[] = "PickleError";
2612 static const char __pyx_k_all_touched[] = "all_touched";
2613 static const char __pyx_k_coordinates[] = "coordinates";
2614 static const char __pyx_k_mask_mem_ds[] = "mask_mem_ds";
2615 static const char __pyx_k_mask_reader[] = "mask_reader";
2616 static const char __pyx_k_out_array_r[] = "out array: %r";
2617 static const char __pyx_k_MultiPolygon[] = "MultiPolygon";
2618 static const char __pyx_k_buildPolygon[] = "_buildPolygon";
2619 static const char __pyx_k_connectivity[] = "connectivity";
2620 static const char __pyx_k_pixel_values[] = "pixel_values";
2621 static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
2622 static const char __pyx_k_stringsource[] = "stringsource";
2623 static const char __pyx_k_valid_dtypes[] = "valid_dtypes";
2624 static const char __pyx_k_3D_LineString[] = "3D LineString";
2625 static const char __pyx_k_3D_MultiPoint[] = "3D MultiPoint";
2626 static const char __pyx_k_ShapeIterator[] = "ShapeIterator";
2627 static const char __pyx_k_StopIteration[] = "StopIteration";
2628 static const char __pyx_k_geo_interface[] = "__geo_interface__";
2629 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
2630 static const char __pyx_k_GEOMETRY_TYPES[] = "GEOMETRY_TYPES";
2631 static const char __pyx_k_OGRGeomBuilder[] = "OGRGeomBuilder";
2632 static const char __pyx_k_rasterio_enums[] = "rasterio.enums";
2633 static const char __pyx_k_3D_MultiPolygon[] = "3D MultiPolygon";
2634 static const char __pyx_k_MultiLineString[] = "MultiLineString";
2635 static const char __pyx_k_buildLineString[] = "_buildLineString";
2636 static const char __pyx_k_buildLinearRing[] = "_buildLinearRing";
2637 static const char __pyx_k_buildMultiPoint[] = "_buildMultiPoint";
2638 static const char __pyx_k_merge_algorithm[] = "merge_algorithm";
2639 static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
2640 static const char __pyx_k_rasterio_dtypes[] = "rasterio.dtypes";
2641 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
2642 static const char __pyx_k_valid_types_str[] = "valid_types_str";
2643 static const char __pyx_k_Invalid_out_image[] = "Invalid out image";
2644 static const char __pyx_k_buildMultiPolygon[] = "_buildMultiPolygon";
2645 static const char __pyx_k_3D_MultiLineString[] = "3D MultiLineString";
2646 static const char __pyx_k_Feature_extraction[] = "Feature extraction";
2647 static const char __pyx_k_GeometryCollection[] = "GeometryCollection";
2648 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
2649 static const char __pyx_k_rasterio__features[] = "rasterio._features";
2650 static const char __pyx_k_Invalid_source_image[] = "Invalid source image";
2651 static const char __pyx_k_NULL_feature_dataset[] = "NULL feature dataset";
2652 static const char __pyx_k_buildMultiLineString[] = "_buildMultiLineString";
2653 static const char __pyx_k_sieve_locals_genexpr[] = "_sieve.<locals>.genexpr";
2654 static const char __pyx_k_3D_GeometryCollection[] = "3D GeometryCollection";
2655 static const char __pyx_k_NULL_field_definition[] = "NULL field definition";
2656 static const char __pyx_k_rasterio__features_pyx[] = "rasterio/_features.pyx";
2657 static const char __pyx_k_GEOJSON2OGR_GEOMETRY_TYPES[] = "GEOJSON2OGR_GEOMETRY_TYPES";
2658 static const char __pyx_k_Unsupported_geometry_type_s[] = "Unsupported geometry type %s";
2659 static const char __pyx_k_connectivity_must_be_4_or_8[] = "connectivity must be 4 or 8";
2660 static const char __pyx_k_pyx_unpickle_OGRGeomBuilder[] = "__pyx_unpickle_OGRGeomBuilder";
2661 static const char __pyx_k_size_must_be_greater_than_0[] = "size must be greater than 0";
2662 static const char __pyx_k_image_dtype_must_be_one_of_0[] = "image dtype must be one of: {0}";
2663 static const char __pyx_k_geometry_must_be_a_GeoJSON_like[] = "geometry must be a GeoJSON-like geometry, GeometryCollection, or FeatureCollection";
2664 static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
2665 static const char __pyx_k_Connectivity_Option_must_be_4_or[] = "Connectivity Option must be 4 or 8";
2666 static const char __pyx_k_Could_not_create_OGR_Geometry_of[] = "Could not create OGR Geometry of type: %i";
2667 static const char __pyx_k_Geometry_r_at_index_d_with_value[] = "Geometry %r at index %d with value %d skipped";
2668 static const char __pyx_k_Incompatible_checksums_s_vs_0xd4[] = "Incompatible checksums (%s vs 0xd41d8cd = ())";
2669 static const char __pyx_k_Input_is_not_a_valid_geometry_ob[] = "Input is not a valid geometry object";
2670 static const char __pyx_k_Mask_must_be_dtype_rasterio_bool[] = "Mask must be dtype rasterio.bool_ or rasterio.uint8";
2671 static const char __pyx_k_Mask_must_have_same_shape_as_ima[] = "Mask must have same shape as image";
2672 static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
2673 static const char __pyx_k_out_raster_must_match_dtype_of_i[] = "out raster must match dtype of image";
2674 static const char __pyx_k_out_raster_shape_must_be_same_as[] = "out raster shape must be same as image shape";
2675 static const char __pyx_k_self_geom_cannot_be_converted_to[] = "self.geom cannot be converted to a Python object for pickling";
2676 static const char __pyx_k_self_layer_cannot_be_converted_t[] = "self.layer cannot be converted to a Python object for pickling";
2677 static const char __pyx_k_size_must_be_an_integer_number_o[] = "size must be an integer number of pixels";
2678 static const char __pyx_k_size_must_be_smaller_than_size_o[] = "size must be smaller than size of image";
2679 static PyObject *__pyx_kp_u_3D_GeometryCollection;
2680 static PyObject *__pyx_kp_u_3D_LineString;
2681 static PyObject *__pyx_kp_u_3D_MultiLineString;
2682 static PyObject *__pyx_kp_u_3D_MultiPoint;
2683 static PyObject *__pyx_kp_u_3D_MultiPolygon;
2684 static PyObject *__pyx_kp_u_3D_Point;
2685 static PyObject *__pyx_kp_u_3D_Polygon;
2686 static PyObject *__pyx_kp_u_Connectivity_Option_must_be_4_or;
2687 static PyObject *__pyx_kp_u_Could_not_create_OGR_Geometry_of;
2688 static PyObject *__pyx_n_s_GEOJSON2OGR_GEOMETRY_TYPES;
2689 static PyObject *__pyx_n_s_GEOMETRY_TYPES;
2690 static PyObject *__pyx_n_s_GeomBuilder;
2691 static PyObject *__pyx_n_u_GeometryCollection;
2692 static PyObject *__pyx_kp_u_Geometry_r_at_index_d_with_value;
2693 static PyObject *__pyx_n_s_ImportError;
2694 static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xd4;
2695 static PyObject *__pyx_kp_u_Input_is_not_a_valid_geometry_ob;
2696 static PyObject *__pyx_kp_u_Invalid_out_image;
2697 static PyObject *__pyx_kp_u_Invalid_source_image;
2698 static PyObject *__pyx_n_u_LineString;
2699 static PyObject *__pyx_n_u_LinearRing;
2700 static PyObject *__pyx_kp_u_Mask_must_be_dtype_rasterio_bool;
2701 static PyObject *__pyx_kp_u_Mask_must_have_same_shape_as_ima;
2702 static PyObject *__pyx_n_s_MergeAlg;
2703 static PyObject *__pyx_n_u_MultiLineString;
2704 static PyObject *__pyx_n_u_MultiPoint;
2705 static PyObject *__pyx_n_u_MultiPolygon;
2706 static PyObject *__pyx_kp_u_NULL_driver;
2707 static PyObject *__pyx_kp_u_NULL_feature_dataset;
2708 static PyObject *__pyx_kp_u_NULL_field_definition;
2709 static PyObject *__pyx_kp_u_NULL_layer;
2710 static PyObject *__pyx_n_u_None;
2711 static PyObject *__pyx_kp_u_Null_geom;
2712 static PyObject *__pyx_n_s_OGRGeomBuilder;
2713 static PyObject *__pyx_n_s_PickleError;
2714 static PyObject *__pyx_n_u_Point;
2715 static PyObject *__pyx_n_u_Polygon;
2716 static PyObject *__pyx_n_s_ShapeIterator;
2717 static PyObject *__pyx_n_s_StopIteration;
2718 static PyObject *__pyx_n_s_TypeError;
2719 static PyObject *__pyx_n_u_Unknown;
2720 static PyObject *__pyx_kp_u_Unsupported_geometry_type_s;
2721 static PyObject *__pyx_n_s_ValueError;
2722 static PyObject *__pyx_kp_u__3;
2723 static PyObject *__pyx_n_s_all_shapes;
2724 static PyObject *__pyx_n_s_all_touched;
2725 static PyObject *__pyx_n_s_args;
2726 static PyObject *__pyx_n_s_astype;
2727 static PyObject *__pyx_n_s_band;
2728 static PyObject *__pyx_n_s_bidx;
2729 static PyObject *__pyx_n_u_bool;
2730 static PyObject *__pyx_n_s_bounds;
2731 static PyObject *__pyx_n_u_build;
2732 static PyObject *__pyx_n_s_buildLineString;
2733 static PyObject *__pyx_n_s_buildLinearRing;
2734 static PyObject *__pyx_n_s_buildMultiLineString;
2735 static PyObject *__pyx_n_s_buildMultiPoint;
2736 static PyObject *__pyx_n_s_buildMultiPolygon;
2737 static PyObject *__pyx_n_s_buildPoint;
2738 static PyObject *__pyx_n_s_buildPolygon;
2739 static PyObject *__pyx_n_s_cline_in_traceback;
2740 static PyObject *__pyx_n_s_close;
2741 static PyObject *__pyx_n_s_cols;
2742 static PyObject *__pyx_n_s_connectivity;
2743 static PyObject *__pyx_kp_u_connectivity_must_be_4_or_8;
2744 static PyObject *__pyx_n_u_coordinates;
2745 static PyObject *__pyx_n_s_coords;
2746 static PyObject *__pyx_n_s_debug;
2747 static PyObject *__pyx_n_s_dict;
2748 static PyObject *__pyx_n_s_driver;
2749 static PyObject *__pyx_n_s_ds;
2750 static PyObject *__pyx_n_s_dtype;
2751 static PyObject *__pyx_n_s_dtypes;
2752 static PyObject *__pyx_n_s_e;
2753 static PyObject *__pyx_n_s_encode;
2754 static PyObject *__pyx_n_s_enter;
2755 static PyObject *__pyx_n_s_enumerate;
2756 static PyObject *__pyx_n_s_error;
2757 static PyObject *__pyx_n_s_exit;
2758 static PyObject *__pyx_n_s_explode;
2759 static PyObject *__pyx_n_s_f;
2760 static PyObject *__pyx_n_u_f;
2761 static PyObject *__pyx_n_s_feature;
2762 static PyObject *__pyx_n_u_features;
2763 static PyObject *__pyx_n_s_fielddefn;
2764 static PyObject *__pyx_n_s_fieldtp;
2765 static PyObject *__pyx_n_u_float32;
2766 static PyObject *__pyx_n_s_format;
2767 static PyObject *__pyx_n_s_fs;
2768 static PyObject *__pyx_n_s_genexpr;
2769 static PyObject *__pyx_n_u_geo_interface;
2770 static PyObject *__pyx_n_u_geometries;
2771 static PyObject *__pyx_n_s_geometry;
2772 static PyObject *__pyx_n_u_geometry;
2773 static PyObject *__pyx_kp_u_geometry_must_be_a_GeoJSON_like;
2774 static PyObject *__pyx_n_s_geoms;
2775 static PyObject *__pyx_n_s_get;
2776 static PyObject *__pyx_n_s_getLogger;
2777 static PyObject *__pyx_n_s_getnpdtype;
2778 static PyObject *__pyx_n_s_getstate;
2779 static PyObject *__pyx_n_s_i;
2780 static PyObject *__pyx_n_s_image;
2781 static PyObject *__pyx_kp_u_image_dtype_must_be_one_of_0;
2782 static PyObject *__pyx_n_s_import;
2783 static PyObject *__pyx_n_s_in_band;
2784 static PyObject *__pyx_n_s_in_mem_ds;
2785 static PyObject *__pyx_n_u_int16;
2786 static PyObject *__pyx_n_u_int32;
2787 static PyObject *__pyx_n_s_is_float;
2788 static PyObject *__pyx_n_s_is_ndarray;
2789 static PyObject *__pyx_n_s_iteritems;
2790 static PyObject *__pyx_n_s_kind;
2791 static PyObject *__pyx_n_s_layer;
2792 static PyObject *__pyx_n_s_log;
2793 static PyObject *__pyx_n_s_logging;
2794 static PyObject *__pyx_n_s_main;
2795 static PyObject *__pyx_n_s_mask;
2796 static PyObject *__pyx_n_s_mask_band;
2797 static PyObject *__pyx_n_s_mask_ds;
2798 static PyObject *__pyx_n_s_mask_mem_ds;
2799 static PyObject *__pyx_n_s_mask_reader;
2800 static PyObject *__pyx_n_s_maskband;
2801 static PyObject *__pyx_n_s_max;
2802 static PyObject *__pyx_n_s_mem;
2803 static PyObject *__pyx_n_s_mem_ds;
2804 static PyObject *__pyx_n_s_merge_alg;
2805 static PyObject *__pyx_n_s_merge_algorithm;
2806 static PyObject *__pyx_n_s_min;
2807 static PyObject *__pyx_n_s_mrdr;
2808 static PyObject *__pyx_n_s_name;
2809 static PyObject *__pyx_n_s_name_2;
2810 static PyObject *__pyx_n_s_new;
2811 static PyObject *__pyx_n_s_north_up;
2812 static PyObject *__pyx_n_s_np;
2813 static PyObject *__pyx_n_s_num_geoms;
2814 static PyObject *__pyx_n_s_numpy;
2815 static PyObject *__pyx_kp_u_numpy_core_multiarray_failed_to;
2816 static PyObject *__pyx_kp_u_numpy_core_umath_failed_to_impor;
2817 static PyObject *__pyx_n_s_options;
2818 static PyObject *__pyx_n_s_out;
2819 static PyObject *__pyx_kp_u_out_array_r;
2820 static PyObject *__pyx_n_s_out_band;
2821 static PyObject *__pyx_n_s_out_mem_ds;
2822 static PyObject *__pyx_kp_u_out_raster_must_match_dtype_of_i;
2823 static PyObject *__pyx_kp_u_out_raster_shape_must_be_same_as;
2824 static PyObject *__pyx_n_s_pickle;
2825 static PyObject *__pyx_n_s_pixel_values;
2826 static PyObject *__pyx_n_s_point;
2827 static PyObject *__pyx_n_s_pyx_PickleError;
2828 static PyObject *__pyx_n_s_pyx_checksum;
2829 static PyObject *__pyx_n_s_pyx_result;
2830 static PyObject *__pyx_n_s_pyx_state;
2831 static PyObject *__pyx_n_s_pyx_type;
2832 static PyObject *__pyx_n_s_pyx_unpickle_OGRGeomBuilder;
2833 static PyObject *__pyx_n_s_pyx_vtable;
2834 static PyObject *__pyx_n_s_range;
2835 static PyObject *__pyx_n_s_rasterio;
2836 static PyObject *__pyx_kp_u_rasterio_0;
2837 static PyObject *__pyx_n_s_rasterio__features;
2838 static PyObject *__pyx_kp_s_rasterio__features_pyx;
2839 static PyObject *__pyx_n_s_rasterio_dtypes;
2840 static PyObject *__pyx_n_s_rasterio_enums;
2841 static PyObject *__pyx_n_s_rasterize;
2842 static PyObject *__pyx_n_s_rdr;
2843 static PyObject *__pyx_n_s_read;
2844 static PyObject *__pyx_n_s_reduce;
2845 static PyObject *__pyx_n_s_reduce_cython;
2846 static PyObject *__pyx_n_s_reduce_ex;
2847 static PyObject *__pyx_n_s_retval;
2848 static PyObject *__pyx_n_s_rows;
2849 static PyObject *__pyx_n_s_s;
2850 static PyObject *__pyx_kp_s_self_geom_cannot_be_converted_to;
2851 static PyObject *__pyx_kp_s_self_layer_cannot_be_converted_t;
2852 static PyObject *__pyx_n_s_send;
2853 static PyObject *__pyx_n_s_setstate;
2854 static PyObject *__pyx_n_s_setstate_cython;
2855 static PyObject *__pyx_n_s_shape;
2856 static PyObject *__pyx_n_s_shape_iter;
2857 static PyObject *__pyx_n_s_shapes;
2858 static PyObject *__pyx_n_s_shapes_2;
2859 static PyObject *__pyx_n_s_sieve;
2860 static PyObject *__pyx_n_s_sieve_locals_genexpr;
2861 static PyObject *__pyx_n_s_size;
2862 static PyObject *__pyx_kp_u_size_must_be_an_integer_number_o;
2863 static PyObject *__pyx_kp_u_size_must_be_greater_than_0;
2864 static PyObject *__pyx_kp_u_size_must_be_smaller_than_size_o;
2865 static PyObject *__pyx_kp_s_stringsource;
2866 static PyObject *__pyx_n_s_test;
2867 static PyObject *__pyx_n_s_throw;
2868 static PyObject *__pyx_n_s_transform;
2869 static PyObject *__pyx_n_u_type;
2870 static PyObject *__pyx_n_s_udr;
2871 static PyObject *__pyx_n_u_uint16;
2872 static PyObject *__pyx_n_u_uint8;
2873 static PyObject *__pyx_n_s_update;
2874 static PyObject *__pyx_kp_u_utf_8;
2875 static PyObject *__pyx_n_s_v;
2876 static PyObject *__pyx_n_s_valid_dtypes;
2877 static PyObject *__pyx_n_s_valid_types_str;
2878 static PyObject *__pyx_n_s_value;
2879 static PyObject *__pyx_n_s_xmax;
2880 static PyObject *__pyx_n_s_xmaxs;
2881 static PyObject *__pyx_n_s_xmin;
2882 static PyObject *__pyx_n_s_xmins;
2883 static PyObject *__pyx_n_s_xyz;
2884 static PyObject *__pyx_n_s_xyz_px;
2885 static PyObject *__pyx_n_s_ymax;
2886 static PyObject *__pyx_n_s_ymaxs;
2887 static PyObject *__pyx_n_s_ymin;
2888 static PyObject *__pyx_n_s_ymins;
2889 static PyObject *__pyx_n_s_zip;
2890 static PyObject *__pyx_pf_8rasterio_9_features_12genexpr(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
2891 static PyObject *__pyx_pf_8rasterio_9_features__shapes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_image, PyObject *__pyx_v_mask, PyObject *__pyx_v_connectivity, PyObject *__pyx_v_transform); /* proto */
2892 static PyObject *__pyx_pf_8rasterio_9_features_6_sieve_genexpr(PyObject *__pyx_self); /* proto */
2893 static PyObject *__pyx_pf_8rasterio_9_features_3_sieve(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_image, PyObject *__pyx_v_size, PyObject *__pyx_v_out, PyObject *__pyx_v_mask, PyObject *__pyx_v_connectivity); /* proto */
2894 static PyObject *__pyx_pf_8rasterio_9_features_5_rasterize(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_shapes, PyObject *__pyx_v_image, PyObject *__pyx_v_transform, PyObject *__pyx_v_all_touched, PyObject *__pyx_v_merge_alg); /* proto */
2895 static PyObject *__pyx_pf_8rasterio_9_features_7_explode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_coords); /* proto */
2896 static PyObject *__pyx_pf_8rasterio_9_features_10_bounds(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_geometry, PyObject *__pyx_v_north_up, PyObject *__pyx_v_transform); /* proto */
2897 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder__buildPoint(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self); /* proto */
2898 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_2_buildLineString(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self); /* proto */
2899 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_4_buildLinearRing(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self); /* proto */
2900 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_6_buildPolygon(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self); /* proto */
2901 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_8_buildMultiPoint(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self); /* proto */
2902 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_10_buildMultiLineString(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self); /* proto */
2903 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_12_buildMultiPolygon(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self); /* proto */
2904 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self); /* proto */
2905 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
2906 static PyObject *__pyx_pf_8rasterio_9_features_14OGRGeomBuilder___reduce_cython__(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self); /* proto */
2907 static PyObject *__pyx_pf_8rasterio_9_features_14OGRGeomBuilder_2__setstate_cython__(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
2908 static PyObject *__pyx_pf_8rasterio_9_features_13ShapeIterator___iter__(struct __pyx_obj_8rasterio_9_features_ShapeIterator *__pyx_v_self); /* proto */
2909 static PyObject *__pyx_pf_8rasterio_9_features_13ShapeIterator_2__next__(struct __pyx_obj_8rasterio_9_features_ShapeIterator *__pyx_v_self); /* proto */
2910 static PyObject *__pyx_pf_8rasterio_9_features_13ShapeIterator_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_ShapeIterator *__pyx_v_self); /* proto */
2911 static PyObject *__pyx_pf_8rasterio_9_features_13ShapeIterator_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_ShapeIterator *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
2912 static PyObject *__pyx_pf_8rasterio_9_features_15__pyx_unpickle_OGRGeomBuilder(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
2913 static PyObject *__pyx_tp_new_8rasterio_9_features_GeomBuilder(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2914 static PyObject *__pyx_tp_new_8rasterio_9_features_OGRGeomBuilder(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2915 static PyObject *__pyx_tp_new_8rasterio_9_features_ShapeIterator(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2916 static PyObject *__pyx_tp_new_8rasterio_9_features___pyx_scope_struct___shapes(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2917 static PyObject *__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_1__sieve(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2918 static PyObject *__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_2_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2919 static PyObject *__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_3__explode(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2920 static PyObject *__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_4_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
2921 static PyObject *__pyx_int_0;
2922 static PyObject *__pyx_int_1;
2923 static PyObject *__pyx_int_2;
2924 static PyObject *__pyx_int_3;
2925 static PyObject *__pyx_int_4;
2926 static PyObject *__pyx_int_5;
2927 static PyObject *__pyx_int_6;
2928 static PyObject *__pyx_int_7;
2929 static PyObject *__pyx_int_8;
2930 static PyObject *__pyx_int_100;
2931 static PyObject *__pyx_int_101;
2932 static PyObject *__pyx_int_222419149;
2933 static PyObject *__pyx_int_2147483648;
2934 static PyObject *__pyx_int_2147483649;
2935 static PyObject *__pyx_int_2147483650;
2936 static PyObject *__pyx_int_2147483651;
2937 static PyObject *__pyx_int_2147483652;
2938 static PyObject *__pyx_int_2147483653;
2939 static PyObject *__pyx_int_2147483654;
2940 static PyObject *__pyx_int_2147483655;
2941 static PyObject *__pyx_codeobj_;
2942 static PyObject *__pyx_tuple__2;
2943 static PyObject *__pyx_tuple__4;
2944 static PyObject *__pyx_tuple__5;
2945 static PyObject *__pyx_tuple__6;
2946 static PyObject *__pyx_tuple__7;
2947 static PyObject *__pyx_tuple__8;
2948 static PyObject *__pyx_tuple__9;
2949 static PyObject *__pyx_slice__26;
2950 static PyObject *__pyx_tuple__10;
2951 static PyObject *__pyx_tuple__11;
2952 static PyObject *__pyx_tuple__12;
2953 static PyObject *__pyx_tuple__13;
2954 static PyObject *__pyx_tuple__14;
2955 static PyObject *__pyx_tuple__15;
2956 static PyObject *__pyx_tuple__16;
2957 static PyObject *__pyx_tuple__17;
2958 static PyObject *__pyx_tuple__18;
2959 static PyObject *__pyx_tuple__19;
2960 static PyObject *__pyx_tuple__20;
2961 static PyObject *__pyx_tuple__22;
2962 static PyObject *__pyx_tuple__23;
2963 static PyObject *__pyx_tuple__24;
2964 static PyObject *__pyx_tuple__25;
2965 static PyObject *__pyx_tuple__27;
2966 static PyObject *__pyx_tuple__28;
2967 static PyObject *__pyx_tuple__29;
2968 static PyObject *__pyx_tuple__30;
2969 static PyObject *__pyx_tuple__31;
2970 static PyObject *__pyx_tuple__32;
2971 static PyObject *__pyx_tuple__33;
2972 static PyObject *__pyx_tuple__35;
2973 static PyObject *__pyx_tuple__37;
2974 static PyObject *__pyx_tuple__38;
2975 static PyObject *__pyx_tuple__40;
2976 static PyObject *__pyx_codeobj__21;
2977 static PyObject *__pyx_codeobj__34;
2978 static PyObject *__pyx_codeobj__36;
2979 static PyObject *__pyx_codeobj__39;
2980 static PyObject *__pyx_codeobj__41;
2981 /* Late includes */
2982 static PyObject *__pyx_gb_8rasterio_9_features_14generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
2983 
2984 /* "rasterio/_features.pyx":473
2985  * # Mapping of GeoJSON type names to OGR integer geometry types
2986  * GEOJSON2OGR_GEOMETRY_TYPES = dict(
2987  *     (v, k) for k, v in GEOMETRY_TYPES.iteritems()             # <<<<<<<<<<<<<<
2988  * )
2989  *
2990  */
2991 
__pyx_pf_8rasterio_9_features_12genexpr(CYTHON_UNUSED PyObject * __pyx_self)2992 static PyObject *__pyx_pf_8rasterio_9_features_12genexpr(CYTHON_UNUSED PyObject *__pyx_self) {
2993   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr *__pyx_cur_scope;
2994   PyObject *__pyx_r = NULL;
2995   __Pyx_RefNannyDeclarations
2996   int __pyx_lineno = 0;
2997   const char *__pyx_filename = NULL;
2998   int __pyx_clineno = 0;
2999   __Pyx_RefNannySetupContext("genexpr", 0);
3000   __pyx_cur_scope = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr *)__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_4_genexpr(__pyx_ptype_8rasterio_9_features___pyx_scope_struct_4_genexpr, __pyx_empty_tuple, NULL);
3001   if (unlikely(!__pyx_cur_scope)) {
3002     __pyx_cur_scope = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr *)Py_None);
3003     __Pyx_INCREF(Py_None);
3004     __PYX_ERR(0, 473, __pyx_L1_error)
3005   } else {
3006     __Pyx_GOTREF(__pyx_cur_scope);
3007   }
3008   {
3009     __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_8rasterio_9_features_14generator3, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_genexpr, __pyx_n_s_rasterio__features); if (unlikely(!gen)) __PYX_ERR(0, 473, __pyx_L1_error)
3010     __Pyx_DECREF(__pyx_cur_scope);
3011     __Pyx_RefNannyFinishContext();
3012     return (PyObject *) gen;
3013   }
3014 
3015   /* function exit code */
3016   __pyx_L1_error:;
3017   __Pyx_AddTraceback("rasterio._features.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
3018   __pyx_r = NULL;
3019   __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
3020   __Pyx_XGIVEREF(__pyx_r);
3021   __Pyx_RefNannyFinishContext();
3022   return __pyx_r;
3023 }
3024 
__pyx_gb_8rasterio_9_features_14generator3(__pyx_CoroutineObject * __pyx_generator,CYTHON_UNUSED PyThreadState * __pyx_tstate,PyObject * __pyx_sent_value)3025 static PyObject *__pyx_gb_8rasterio_9_features_14generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
3026 {
3027   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr *__pyx_cur_scope = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr *)__pyx_generator->closure);
3028   PyObject *__pyx_r = NULL;
3029   PyObject *__pyx_t_1 = NULL;
3030   Py_ssize_t __pyx_t_2;
3031   Py_ssize_t __pyx_t_3;
3032   int __pyx_t_4;
3033   PyObject *__pyx_t_5 = NULL;
3034   PyObject *__pyx_t_6 = NULL;
3035   int __pyx_t_7;
3036   int __pyx_lineno = 0;
3037   const char *__pyx_filename = NULL;
3038   int __pyx_clineno = 0;
3039   __Pyx_RefNannyDeclarations
3040   __Pyx_RefNannySetupContext("genexpr", 0);
3041   switch (__pyx_generator->resume_label) {
3042     case 0: goto __pyx_L3_first_run;
3043     default: /* CPython raises the right error here */
3044     __Pyx_RefNannyFinishContext();
3045     return NULL;
3046   }
3047   __pyx_L3_first_run:;
3048   if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 473, __pyx_L1_error)
3049   __pyx_r = PyDict_New(); if (unlikely(!__pyx_r)) __PYX_ERR(0, 473, __pyx_L1_error)
3050   __Pyx_GOTREF(__pyx_r);
3051   __pyx_t_2 = 0;
3052   __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_GEOMETRY_TYPES); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 473, __pyx_L1_error)
3053   __Pyx_GOTREF(__pyx_t_5);
3054   if (unlikely(__pyx_t_5 == Py_None)) {
3055     PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "iteritems");
3056     __PYX_ERR(0, 473, __pyx_L1_error)
3057   }
3058   __pyx_t_6 = __Pyx_dict_iterator(__pyx_t_5, 0, __pyx_n_s_iteritems, (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 473, __pyx_L1_error)
3059   __Pyx_GOTREF(__pyx_t_6);
3060   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3061   __Pyx_XDECREF(__pyx_t_1);
3062   __pyx_t_1 = __pyx_t_6;
3063   __pyx_t_6 = 0;
3064   while (1) {
3065     __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_6, &__pyx_t_5, NULL, __pyx_t_4);
3066     if (unlikely(__pyx_t_7 == 0)) break;
3067     if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 473, __pyx_L1_error)
3068     __Pyx_GOTREF(__pyx_t_6);
3069     __Pyx_GOTREF(__pyx_t_5);
3070     __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_k);
3071     __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_k, __pyx_t_6);
3072     __Pyx_GIVEREF(__pyx_t_6);
3073     __pyx_t_6 = 0;
3074     __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
3075     __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_5);
3076     __Pyx_GIVEREF(__pyx_t_5);
3077     __pyx_t_5 = 0;
3078     if (unlikely(PyDict_SetItem(__pyx_r, (PyObject*)__pyx_cur_scope->__pyx_v_v, (PyObject*)__pyx_cur_scope->__pyx_v_k))) __PYX_ERR(0, 473, __pyx_L1_error)
3079   }
3080   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3081   CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
3082 
3083   /* function exit code */
3084   goto __pyx_L0;
3085   __pyx_L1_error:;
3086   __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
3087   __Pyx_XDECREF(__pyx_t_1);
3088   __Pyx_XDECREF(__pyx_t_5);
3089   __Pyx_XDECREF(__pyx_t_6);
3090   __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
3091   __pyx_L0:;
3092   __Pyx_XGIVEREF(__pyx_r);
3093   #if !CYTHON_USE_EXC_INFO_STACK
3094   __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
3095   #endif
3096   __pyx_generator->resume_label = -1;
3097   __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
3098   __Pyx_RefNannyFinishContext();
3099   return __pyx_r;
3100 }
3101 static PyObject *__pyx_gb_8rasterio_9_features_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
3102 
3103 /* "rasterio/_features.pyx":22
3104  *
3105  *
3106  * def _shapes(image, mask, connectivity, transform):             # <<<<<<<<<<<<<<
3107  *     """
3108  *     Return a generator of (polygon, value) for each each set of adjacent pixels
3109  */
3110 
3111 /* Python wrapper */
3112 static PyObject *__pyx_pw_8rasterio_9_features_1_shapes(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3113 static char __pyx_doc_8rasterio_9_features__shapes[] = "\n    Return a generator of (polygon, value) for each each set of adjacent pixels\n    of the same value.\n\n    Parameters\n    ----------\n    image : array or dataset object opened in 'r' mode or Band or tuple(dataset, bidx)\n        Data type must be one of rasterio.int16, rasterio.int32,\n        rasterio.uint8, rasterio.uint16, or rasterio.float32.\n    mask : numpy ndarray or rasterio Band object\n        Values of False or 0 will be excluded from feature generation\n        Must evaluate to bool (rasterio.bool_ or rasterio.uint8)\n    connectivity : int\n        Use 4 or 8 pixel connectivity for grouping pixels into features\n    transform : Affine\n        If not provided, feature coordinates will be generated based on pixel\n        coordinates\n\n    Returns\n    -------\n    Generator of (polygon, value)\n        Yields a pair of (polygon, value) for each feature found in the image.\n        Polygons are GeoJSON-like dicts and the values are the associated value\n        from the image, in the data type of the image.\n        Note: due to floating point precision issues, values returned from a\n        floating point image may not exactly match the original values.\n\n    ";
3114 static PyMethodDef __pyx_mdef_8rasterio_9_features_1_shapes = {"_shapes", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8rasterio_9_features_1_shapes, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8rasterio_9_features__shapes};
__pyx_pw_8rasterio_9_features_1_shapes(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)3115 static PyObject *__pyx_pw_8rasterio_9_features_1_shapes(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3116   PyObject *__pyx_v_image = 0;
3117   PyObject *__pyx_v_mask = 0;
3118   PyObject *__pyx_v_connectivity = 0;
3119   PyObject *__pyx_v_transform = 0;
3120   int __pyx_lineno = 0;
3121   const char *__pyx_filename = NULL;
3122   int __pyx_clineno = 0;
3123   PyObject *__pyx_r = 0;
3124   __Pyx_RefNannyDeclarations
3125   __Pyx_RefNannySetupContext("_shapes (wrapper)", 0);
3126   {
3127     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_image,&__pyx_n_s_mask,&__pyx_n_s_connectivity,&__pyx_n_s_transform,0};
3128     PyObject* values[4] = {0,0,0,0};
3129     if (unlikely(__pyx_kwds)) {
3130       Py_ssize_t kw_args;
3131       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3132       switch (pos_args) {
3133         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3134         CYTHON_FALLTHROUGH;
3135         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3136         CYTHON_FALLTHROUGH;
3137         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3138         CYTHON_FALLTHROUGH;
3139         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3140         CYTHON_FALLTHROUGH;
3141         case  0: break;
3142         default: goto __pyx_L5_argtuple_error;
3143       }
3144       kw_args = PyDict_Size(__pyx_kwds);
3145       switch (pos_args) {
3146         case  0:
3147         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_image)) != 0)) kw_args--;
3148         else goto __pyx_L5_argtuple_error;
3149         CYTHON_FALLTHROUGH;
3150         case  1:
3151         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--;
3152         else {
3153           __Pyx_RaiseArgtupleInvalid("_shapes", 1, 4, 4, 1); __PYX_ERR(0, 22, __pyx_L3_error)
3154         }
3155         CYTHON_FALLTHROUGH;
3156         case  2:
3157         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_connectivity)) != 0)) kw_args--;
3158         else {
3159           __Pyx_RaiseArgtupleInvalid("_shapes", 1, 4, 4, 2); __PYX_ERR(0, 22, __pyx_L3_error)
3160         }
3161         CYTHON_FALLTHROUGH;
3162         case  3:
3163         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_transform)) != 0)) kw_args--;
3164         else {
3165           __Pyx_RaiseArgtupleInvalid("_shapes", 1, 4, 4, 3); __PYX_ERR(0, 22, __pyx_L3_error)
3166         }
3167       }
3168       if (unlikely(kw_args > 0)) {
3169         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_shapes") < 0)) __PYX_ERR(0, 22, __pyx_L3_error)
3170       }
3171     } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
3172       goto __pyx_L5_argtuple_error;
3173     } else {
3174       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3175       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3176       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3177       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3178     }
3179     __pyx_v_image = values[0];
3180     __pyx_v_mask = values[1];
3181     __pyx_v_connectivity = values[2];
3182     __pyx_v_transform = values[3];
3183   }
3184   goto __pyx_L4_argument_unpacking_done;
3185   __pyx_L5_argtuple_error:;
3186   __Pyx_RaiseArgtupleInvalid("_shapes", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 22, __pyx_L3_error)
3187   __pyx_L3_error:;
3188   __Pyx_AddTraceback("rasterio._features._shapes", __pyx_clineno, __pyx_lineno, __pyx_filename);
3189   __Pyx_RefNannyFinishContext();
3190   return NULL;
3191   __pyx_L4_argument_unpacking_done:;
3192   __pyx_r = __pyx_pf_8rasterio_9_features__shapes(__pyx_self, __pyx_v_image, __pyx_v_mask, __pyx_v_connectivity, __pyx_v_transform);
3193 
3194   /* function exit code */
3195   __Pyx_RefNannyFinishContext();
3196   return __pyx_r;
3197 }
3198 
__pyx_pf_8rasterio_9_features__shapes(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_image,PyObject * __pyx_v_mask,PyObject * __pyx_v_connectivity,PyObject * __pyx_v_transform)3199 static PyObject *__pyx_pf_8rasterio_9_features__shapes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_image, PyObject *__pyx_v_mask, PyObject *__pyx_v_connectivity, PyObject *__pyx_v_transform) {
3200   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes *__pyx_cur_scope;
3201   PyObject *__pyx_r = NULL;
3202   __Pyx_RefNannyDeclarations
3203   int __pyx_lineno = 0;
3204   const char *__pyx_filename = NULL;
3205   int __pyx_clineno = 0;
3206   __Pyx_RefNannySetupContext("_shapes", 0);
3207   __pyx_cur_scope = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes *)__pyx_tp_new_8rasterio_9_features___pyx_scope_struct___shapes(__pyx_ptype_8rasterio_9_features___pyx_scope_struct___shapes, __pyx_empty_tuple, NULL);
3208   if (unlikely(!__pyx_cur_scope)) {
3209     __pyx_cur_scope = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes *)Py_None);
3210     __Pyx_INCREF(Py_None);
3211     __PYX_ERR(0, 22, __pyx_L1_error)
3212   } else {
3213     __Pyx_GOTREF(__pyx_cur_scope);
3214   }
3215   __pyx_cur_scope->__pyx_v_image = __pyx_v_image;
3216   __Pyx_INCREF(__pyx_cur_scope->__pyx_v_image);
3217   __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_image);
3218   __pyx_cur_scope->__pyx_v_mask = __pyx_v_mask;
3219   __Pyx_INCREF(__pyx_cur_scope->__pyx_v_mask);
3220   __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_mask);
3221   __pyx_cur_scope->__pyx_v_connectivity = __pyx_v_connectivity;
3222   __Pyx_INCREF(__pyx_cur_scope->__pyx_v_connectivity);
3223   __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_connectivity);
3224   __pyx_cur_scope->__pyx_v_transform = __pyx_v_transform;
3225   __Pyx_INCREF(__pyx_cur_scope->__pyx_v_transform);
3226   __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_transform);
3227   {
3228     __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_8rasterio_9_features_2generator, __pyx_codeobj_, (PyObject *) __pyx_cur_scope, __pyx_n_s_shapes, __pyx_n_s_shapes, __pyx_n_s_rasterio__features); if (unlikely(!gen)) __PYX_ERR(0, 22, __pyx_L1_error)
3229     __Pyx_DECREF(__pyx_cur_scope);
3230     __Pyx_RefNannyFinishContext();
3231     return (PyObject *) gen;
3232   }
3233 
3234   /* function exit code */
3235   __pyx_L1_error:;
3236   __Pyx_AddTraceback("rasterio._features._shapes", __pyx_clineno, __pyx_lineno, __pyx_filename);
3237   __pyx_r = NULL;
3238   __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
3239   __Pyx_XGIVEREF(__pyx_r);
3240   __Pyx_RefNannyFinishContext();
3241   return __pyx_r;
3242 }
3243 
__pyx_gb_8rasterio_9_features_2generator(__pyx_CoroutineObject * __pyx_generator,CYTHON_UNUSED PyThreadState * __pyx_tstate,PyObject * __pyx_sent_value)3244 static PyObject *__pyx_gb_8rasterio_9_features_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
3245 {
3246   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes *__pyx_cur_scope = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes *)__pyx_generator->closure);
3247   PyObject *__pyx_r = NULL;
3248   PyObject *__pyx_t_1 = NULL;
3249   PyObject *__pyx_t_2 = NULL;
3250   PyObject *__pyx_t_3 = NULL;
3251   PyObject *__pyx_t_4 = NULL;
3252   int __pyx_t_5;
3253   int __pyx_t_6;
3254   int __pyx_t_7;
3255   GDALRasterBandH __pyx_t_8;
3256   GDALRasterBandH __pyx_t_9;
3257   int __pyx_t_10;
3258   char const *__pyx_t_11;
3259   PyObject *__pyx_t_12 = NULL;
3260   PyObject *__pyx_t_13 = NULL;
3261   PyObject *__pyx_t_14 = NULL;
3262   PyObject *__pyx_t_15 = NULL;
3263   PyObject *__pyx_t_16 = NULL;
3264   PyObject *__pyx_t_17 = NULL;
3265   Py_ssize_t __pyx_t_18;
3266   PyObject *(*__pyx_t_19)(PyObject *);
3267   PyObject *__pyx_t_20 = NULL;
3268   PyObject *(*__pyx_t_21)(PyObject *);
3269   char const *__pyx_t_22;
3270   int __pyx_lineno = 0;
3271   const char *__pyx_filename = NULL;
3272   int __pyx_clineno = 0;
3273   __Pyx_RefNannyDeclarations
3274   __Pyx_RefNannySetupContext("_shapes", 0);
3275   switch (__pyx_generator->resume_label) {
3276     case 0: goto __pyx_L3_first_run;
3277     case 1: goto __pyx_L39_resume_from_yield;
3278     default: /* CPython raises the right error here */
3279     __Pyx_RefNannyFinishContext();
3280     return NULL;
3281   }
3282   __pyx_L3_first_run:;
3283   if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 22, __pyx_L1_error)
3284 
3285   /* "rasterio/_features.pyx":54
3286  *     cdef int rows
3287  *     cdef int cols
3288  *     cdef GDALRasterBandH band = NULL             # <<<<<<<<<<<<<<
3289  *     cdef GDALRasterBandH maskband = NULL
3290  *     cdef GDALDriverH driver = NULL
3291  */
3292   __pyx_cur_scope->__pyx_v_band = NULL;
3293 
3294   /* "rasterio/_features.pyx":55
3295  *     cdef int cols
3296  *     cdef GDALRasterBandH band = NULL
3297  *     cdef GDALRasterBandH maskband = NULL             # <<<<<<<<<<<<<<
3298  *     cdef GDALDriverH driver = NULL
3299  *     cdef OGRDataSourceH fs = NULL
3300  */
3301   __pyx_cur_scope->__pyx_v_maskband = NULL;
3302 
3303   /* "rasterio/_features.pyx":56
3304  *     cdef GDALRasterBandH band = NULL
3305  *     cdef GDALRasterBandH maskband = NULL
3306  *     cdef GDALDriverH driver = NULL             # <<<<<<<<<<<<<<
3307  *     cdef OGRDataSourceH fs = NULL
3308  *     cdef OGRLayerH layer = NULL
3309  */
3310   __pyx_cur_scope->__pyx_v_driver = NULL;
3311 
3312   /* "rasterio/_features.pyx":57
3313  *     cdef GDALRasterBandH maskband = NULL
3314  *     cdef GDALDriverH driver = NULL
3315  *     cdef OGRDataSourceH fs = NULL             # <<<<<<<<<<<<<<
3316  *     cdef OGRLayerH layer = NULL
3317  *     cdef OGRFieldDefnH fielddefn = NULL
3318  */
3319   __pyx_cur_scope->__pyx_v_fs = NULL;
3320 
3321   /* "rasterio/_features.pyx":58
3322  *     cdef GDALDriverH driver = NULL
3323  *     cdef OGRDataSourceH fs = NULL
3324  *     cdef OGRLayerH layer = NULL             # <<<<<<<<<<<<<<
3325  *     cdef OGRFieldDefnH fielddefn = NULL
3326  *     cdef char **options = NULL
3327  */
3328   __pyx_cur_scope->__pyx_v_layer = NULL;
3329 
3330   /* "rasterio/_features.pyx":59
3331  *     cdef OGRDataSourceH fs = NULL
3332  *     cdef OGRLayerH layer = NULL
3333  *     cdef OGRFieldDefnH fielddefn = NULL             # <<<<<<<<<<<<<<
3334  *     cdef char **options = NULL
3335  *     cdef InMemoryRaster mem_ds = None
3336  */
3337   __pyx_cur_scope->__pyx_v_fielddefn = NULL;
3338 
3339   /* "rasterio/_features.pyx":60
3340  *     cdef OGRLayerH layer = NULL
3341  *     cdef OGRFieldDefnH fielddefn = NULL
3342  *     cdef char **options = NULL             # <<<<<<<<<<<<<<
3343  *     cdef InMemoryRaster mem_ds = None
3344  *     cdef InMemoryRaster mask_ds = None
3345  */
3346   __pyx_cur_scope->__pyx_v_options = NULL;
3347 
3348   /* "rasterio/_features.pyx":61
3349  *     cdef OGRFieldDefnH fielddefn = NULL
3350  *     cdef char **options = NULL
3351  *     cdef InMemoryRaster mem_ds = None             # <<<<<<<<<<<<<<
3352  *     cdef InMemoryRaster mask_ds = None
3353  *     cdef ShapeIterator shape_iter = None
3354  */
3355   __Pyx_INCREF(Py_None);
3356   __Pyx_GIVEREF(Py_None);
3357   __pyx_cur_scope->__pyx_v_mem_ds = ((struct __pyx_obj_8rasterio_3_io_InMemoryRaster *)Py_None);
3358 
3359   /* "rasterio/_features.pyx":62
3360  *     cdef char **options = NULL
3361  *     cdef InMemoryRaster mem_ds = None
3362  *     cdef InMemoryRaster mask_ds = None             # <<<<<<<<<<<<<<
3363  *     cdef ShapeIterator shape_iter = None
3364  *     cdef int fieldtp
3365  */
3366   __Pyx_INCREF(Py_None);
3367   __Pyx_GIVEREF(Py_None);
3368   __pyx_cur_scope->__pyx_v_mask_ds = ((struct __pyx_obj_8rasterio_3_io_InMemoryRaster *)Py_None);
3369 
3370   /* "rasterio/_features.pyx":63
3371  *     cdef InMemoryRaster mem_ds = None
3372  *     cdef InMemoryRaster mask_ds = None
3373  *     cdef ShapeIterator shape_iter = None             # <<<<<<<<<<<<<<
3374  *     cdef int fieldtp
3375  *
3376  */
3377   __Pyx_INCREF(Py_None);
3378   __Pyx_GIVEREF(Py_None);
3379   __pyx_cur_scope->__pyx_v_shape_iter = ((struct __pyx_obj_8rasterio_9_features_ShapeIterator *)Py_None);
3380 
3381   /* "rasterio/_features.pyx":66
3382  *     cdef int fieldtp
3383  *
3384  *     is_float = _getnpdtype(image.dtype).kind == "f"             # <<<<<<<<<<<<<<
3385  *     fieldtp = 2 if is_float else 0
3386  *
3387  */
3388   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_getnpdtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
3389   __Pyx_GOTREF(__pyx_t_2);
3390   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_image, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 66, __pyx_L1_error)
3391   __Pyx_GOTREF(__pyx_t_3);
3392   __pyx_t_4 = NULL;
3393   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
3394     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
3395     if (likely(__pyx_t_4)) {
3396       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3397       __Pyx_INCREF(__pyx_t_4);
3398       __Pyx_INCREF(function);
3399       __Pyx_DECREF_SET(__pyx_t_2, function);
3400     }
3401   }
3402   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
3403   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3404   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3405   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
3406   __Pyx_GOTREF(__pyx_t_1);
3407   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3408   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_kind); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
3409   __Pyx_GOTREF(__pyx_t_2);
3410   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3411   __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_n_u_f, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
3412   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3413   __Pyx_GIVEREF(__pyx_t_1);
3414   __pyx_cur_scope->__pyx_v_is_float = __pyx_t_1;
3415   __pyx_t_1 = 0;
3416 
3417   /* "rasterio/_features.pyx":67
3418  *
3419  *     is_float = _getnpdtype(image.dtype).kind == "f"
3420  *     fieldtp = 2 if is_float else 0             # <<<<<<<<<<<<<<
3421  *
3422  *     valid_dtypes = ('int16', 'int32', 'uint8', 'uint16', 'float32')
3423  */
3424   __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_float); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 67, __pyx_L1_error)
3425   if (__pyx_t_6) {
3426     __pyx_t_5 = 2;
3427   } else {
3428     __pyx_t_5 = 0;
3429   }
3430   __pyx_cur_scope->__pyx_v_fieldtp = __pyx_t_5;
3431 
3432   /* "rasterio/_features.pyx":69
3433  *     fieldtp = 2 if is_float else 0
3434  *
3435  *     valid_dtypes = ('int16', 'int32', 'uint8', 'uint16', 'float32')             # <<<<<<<<<<<<<<
3436  *
3437  *     if _getnpdtype(image.dtype).name not in valid_dtypes:
3438  */
3439   __Pyx_INCREF(__pyx_tuple__2);
3440   __Pyx_GIVEREF(__pyx_tuple__2);
3441   __pyx_cur_scope->__pyx_v_valid_dtypes = __pyx_tuple__2;
3442 
3443   /* "rasterio/_features.pyx":71
3444  *     valid_dtypes = ('int16', 'int32', 'uint8', 'uint16', 'float32')
3445  *
3446  *     if _getnpdtype(image.dtype).name not in valid_dtypes:             # <<<<<<<<<<<<<<
3447  *         raise ValueError("image dtype must be one of: {0}".format(
3448  *             ', '.join(valid_dtypes)))
3449  */
3450   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_getnpdtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
3451   __Pyx_GOTREF(__pyx_t_2);
3452   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_image, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
3453   __Pyx_GOTREF(__pyx_t_3);
3454   __pyx_t_4 = NULL;
3455   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
3456     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
3457     if (likely(__pyx_t_4)) {
3458       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3459       __Pyx_INCREF(__pyx_t_4);
3460       __Pyx_INCREF(function);
3461       __Pyx_DECREF_SET(__pyx_t_2, function);
3462     }
3463   }
3464   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
3465   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3466   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3467   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
3468   __Pyx_GOTREF(__pyx_t_1);
3469   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3470   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
3471   __Pyx_GOTREF(__pyx_t_2);
3472   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3473   __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_t_2, __pyx_cur_scope->__pyx_v_valid_dtypes, Py_NE)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 71, __pyx_L1_error)
3474   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3475   __pyx_t_7 = (__pyx_t_6 != 0);
3476   if (unlikely(__pyx_t_7)) {
3477 
3478     /* "rasterio/_features.pyx":72
3479  *
3480  *     if _getnpdtype(image.dtype).name not in valid_dtypes:
3481  *         raise ValueError("image dtype must be one of: {0}".format(             # <<<<<<<<<<<<<<
3482  *             ', '.join(valid_dtypes)))
3483  *
3484  */
3485     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_image_dtype_must_be_one_of_0, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
3486     __Pyx_GOTREF(__pyx_t_1);
3487 
3488     /* "rasterio/_features.pyx":73
3489  *     if _getnpdtype(image.dtype).name not in valid_dtypes:
3490  *         raise ValueError("image dtype must be one of: {0}".format(
3491  *             ', '.join(valid_dtypes)))             # <<<<<<<<<<<<<<
3492  *
3493  *     if connectivity not in (4, 8):
3494  */
3495     __pyx_t_3 = PyUnicode_Join(__pyx_kp_u__3, __pyx_cur_scope->__pyx_v_valid_dtypes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 73, __pyx_L1_error)
3496     __Pyx_GOTREF(__pyx_t_3);
3497     __pyx_t_4 = NULL;
3498     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
3499       __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
3500       if (likely(__pyx_t_4)) {
3501         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3502         __Pyx_INCREF(__pyx_t_4);
3503         __Pyx_INCREF(function);
3504         __Pyx_DECREF_SET(__pyx_t_1, function);
3505       }
3506     }
3507     __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
3508     __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3509     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3510     if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
3511     __Pyx_GOTREF(__pyx_t_2);
3512     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3513 
3514     /* "rasterio/_features.pyx":72
3515  *
3516  *     if _getnpdtype(image.dtype).name not in valid_dtypes:
3517  *         raise ValueError("image dtype must be one of: {0}".format(             # <<<<<<<<<<<<<<
3518  *             ', '.join(valid_dtypes)))
3519  *
3520  */
3521     __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
3522     __Pyx_GOTREF(__pyx_t_1);
3523     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3524     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
3525     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3526     __PYX_ERR(0, 72, __pyx_L1_error)
3527 
3528     /* "rasterio/_features.pyx":71
3529  *     valid_dtypes = ('int16', 'int32', 'uint8', 'uint16', 'float32')
3530  *
3531  *     if _getnpdtype(image.dtype).name not in valid_dtypes:             # <<<<<<<<<<<<<<
3532  *         raise ValueError("image dtype must be one of: {0}".format(
3533  *             ', '.join(valid_dtypes)))
3534  */
3535   }
3536 
3537   /* "rasterio/_features.pyx":75
3538  *             ', '.join(valid_dtypes)))
3539  *
3540  *     if connectivity not in (4, 8):             # <<<<<<<<<<<<<<
3541  *         raise ValueError("Connectivity Option must be 4 or 8")
3542  *
3543  */
3544   __Pyx_INCREF(__pyx_cur_scope->__pyx_v_connectivity);
3545   __pyx_t_1 = __pyx_cur_scope->__pyx_v_connectivity;
3546   __pyx_t_2 = __Pyx_PyInt_NeObjC(__pyx_t_1, __pyx_int_4, 4, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error)
3547   __Pyx_GOTREF(__pyx_t_2);
3548   __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 75, __pyx_L1_error)
3549   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3550   if (__pyx_t_6) {
3551   } else {
3552     __pyx_t_7 = __pyx_t_6;
3553     goto __pyx_L6_bool_binop_done;
3554   }
3555   __pyx_t_2 = __Pyx_PyInt_NeObjC(__pyx_t_1, __pyx_int_8, 8, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error)
3556   __Pyx_GOTREF(__pyx_t_2);
3557   __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 75, __pyx_L1_error)
3558   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3559   __pyx_t_7 = __pyx_t_6;
3560   __pyx_L6_bool_binop_done:;
3561   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3562   __pyx_t_6 = (__pyx_t_7 != 0);
3563   if (unlikely(__pyx_t_6)) {
3564 
3565     /* "rasterio/_features.pyx":76
3566  *
3567  *     if connectivity not in (4, 8):
3568  *         raise ValueError("Connectivity Option must be 4 or 8")             # <<<<<<<<<<<<<<
3569  *
3570  *     try:
3571  */
3572     __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
3573     __Pyx_GOTREF(__pyx_t_1);
3574     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
3575     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3576     __PYX_ERR(0, 76, __pyx_L1_error)
3577 
3578     /* "rasterio/_features.pyx":75
3579  *             ', '.join(valid_dtypes)))
3580  *
3581  *     if connectivity not in (4, 8):             # <<<<<<<<<<<<<<
3582  *         raise ValueError("Connectivity Option must be 4 or 8")
3583  *
3584  */
3585   }
3586 
3587   /* "rasterio/_features.pyx":78
3588  *         raise ValueError("Connectivity Option must be 4 or 8")
3589  *
3590  *     try:             # <<<<<<<<<<<<<<
3591  *
3592  *         if dtypes.is_ndarray(image):
3593  */
3594   /*try:*/ {
3595 
3596     /* "rasterio/_features.pyx":80
3597  *     try:
3598  *
3599  *         if dtypes.is_ndarray(image):             # <<<<<<<<<<<<<<
3600  *             mem_ds = InMemoryRaster(image=image, transform=transform)
3601  *             band = mem_ds.band(1)
3602  */
3603     __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_dtypes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L9_error)
3604     __Pyx_GOTREF(__pyx_t_2);
3605     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 80, __pyx_L9_error)
3606     __Pyx_GOTREF(__pyx_t_3);
3607     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3608     __pyx_t_2 = NULL;
3609     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
3610       __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
3611       if (likely(__pyx_t_2)) {
3612         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3613         __Pyx_INCREF(__pyx_t_2);
3614         __Pyx_INCREF(function);
3615         __Pyx_DECREF_SET(__pyx_t_3, function);
3616       }
3617     }
3618     __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_cur_scope->__pyx_v_image) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_image);
3619     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3620     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L9_error)
3621     __Pyx_GOTREF(__pyx_t_1);
3622     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3623     __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 80, __pyx_L9_error)
3624     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3625     if (__pyx_t_6) {
3626 
3627       /* "rasterio/_features.pyx":81
3628  *
3629  *         if dtypes.is_ndarray(image):
3630  *             mem_ds = InMemoryRaster(image=image, transform=transform)             # <<<<<<<<<<<<<<
3631  *             band = mem_ds.band(1)
3632  *         elif isinstance(image, tuple):
3633  */
3634       __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L9_error)
3635       __Pyx_GOTREF(__pyx_t_1);
3636       if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_image, __pyx_cur_scope->__pyx_v_image) < 0) __PYX_ERR(0, 81, __pyx_L9_error)
3637       if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_transform, __pyx_cur_scope->__pyx_v_transform) < 0) __PYX_ERR(0, 81, __pyx_L9_error)
3638       __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8rasterio_3_io_InMemoryRaster), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 81, __pyx_L9_error)
3639       __Pyx_GOTREF(__pyx_t_3);
3640       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3641       __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_mem_ds));
3642       __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_mem_ds, ((struct __pyx_obj_8rasterio_3_io_InMemoryRaster *)__pyx_t_3));
3643       __Pyx_GIVEREF(__pyx_t_3);
3644       __pyx_t_3 = 0;
3645 
3646       /* "rasterio/_features.pyx":82
3647  *         if dtypes.is_ndarray(image):
3648  *             mem_ds = InMemoryRaster(image=image, transform=transform)
3649  *             band = mem_ds.band(1)             # <<<<<<<<<<<<<<
3650  *         elif isinstance(image, tuple):
3651  *             rdr = image.ds
3652  */
3653       __pyx_t_8 = ((struct __pyx_vtabstruct_8rasterio_3_io_InMemoryRaster *)__pyx_cur_scope->__pyx_v_mem_ds->__pyx_vtab)->band(__pyx_cur_scope->__pyx_v_mem_ds, 1); if (unlikely(__pyx_t_8 == ((GDALRasterBandH)NULL))) __PYX_ERR(0, 82, __pyx_L9_error)
3654       __pyx_cur_scope->__pyx_v_band = __pyx_t_8;
3655 
3656       /* "rasterio/_features.pyx":80
3657  *     try:
3658  *
3659  *         if dtypes.is_ndarray(image):             # <<<<<<<<<<<<<<
3660  *             mem_ds = InMemoryRaster(image=image, transform=transform)
3661  *             band = mem_ds.band(1)
3662  */
3663       goto __pyx_L11;
3664     }
3665 
3666     /* "rasterio/_features.pyx":83
3667  *             mem_ds = InMemoryRaster(image=image, transform=transform)
3668  *             band = mem_ds.band(1)
3669  *         elif isinstance(image, tuple):             # <<<<<<<<<<<<<<
3670  *             rdr = image.ds
3671  *             band = (<DatasetReaderBase?>rdr).band(image.bidx)
3672  */
3673     __pyx_t_6 = PyTuple_Check(__pyx_cur_scope->__pyx_v_image);
3674     __pyx_t_7 = (__pyx_t_6 != 0);
3675     if (likely(__pyx_t_7)) {
3676 
3677       /* "rasterio/_features.pyx":84
3678  *             band = mem_ds.band(1)
3679  *         elif isinstance(image, tuple):
3680  *             rdr = image.ds             # <<<<<<<<<<<<<<
3681  *             band = (<DatasetReaderBase?>rdr).band(image.bidx)
3682  *         else:
3683  */
3684       __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_image, __pyx_n_s_ds); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L9_error)
3685       __Pyx_GOTREF(__pyx_t_3);
3686       __Pyx_GIVEREF(__pyx_t_3);
3687       __pyx_cur_scope->__pyx_v_rdr = __pyx_t_3;
3688       __pyx_t_3 = 0;
3689 
3690       /* "rasterio/_features.pyx":85
3691  *         elif isinstance(image, tuple):
3692  *             rdr = image.ds
3693  *             band = (<DatasetReaderBase?>rdr).band(image.bidx)             # <<<<<<<<<<<<<<
3694  *         else:
3695  *             raise ValueError("Invalid source image")
3696  */
3697       if (!(likely(__Pyx_TypeTest(__pyx_cur_scope->__pyx_v_rdr, __pyx_ptype_8rasterio_3_io_DatasetReaderBase)))) __PYX_ERR(0, 85, __pyx_L9_error)
3698       __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_image, __pyx_n_s_bidx); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L9_error)
3699       __Pyx_GOTREF(__pyx_t_3);
3700       __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L9_error)
3701       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3702       __pyx_t_9 = ((struct __pyx_vtabstruct_8rasterio_3_io_DatasetReaderBase *)((struct __pyx_obj_8rasterio_3_io_DatasetReaderBase *)__pyx_cur_scope->__pyx_v_rdr)->__pyx_base.__pyx_vtab)->__pyx_base.band(((struct __pyx_obj_8rasterio_5_base_DatasetBase *)((struct __pyx_obj_8rasterio_3_io_DatasetReaderBase *)__pyx_cur_scope->__pyx_v_rdr)), __pyx_t_5); if (unlikely(__pyx_t_9 == ((GDALRasterBandH)NULL))) __PYX_ERR(0, 85, __pyx_L9_error)
3703       __pyx_cur_scope->__pyx_v_band = __pyx_t_9;
3704 
3705       /* "rasterio/_features.pyx":83
3706  *             mem_ds = InMemoryRaster(image=image, transform=transform)
3707  *             band = mem_ds.band(1)
3708  *         elif isinstance(image, tuple):             # <<<<<<<<<<<<<<
3709  *             rdr = image.ds
3710  *             band = (<DatasetReaderBase?>rdr).band(image.bidx)
3711  */
3712       goto __pyx_L11;
3713     }
3714 
3715     /* "rasterio/_features.pyx":87
3716  *             band = (<DatasetReaderBase?>rdr).band(image.bidx)
3717  *         else:
3718  *             raise ValueError("Invalid source image")             # <<<<<<<<<<<<<<
3719  *
3720  *         if mask is not None:
3721  */
3722     /*else*/ {
3723       __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L9_error)
3724       __Pyx_GOTREF(__pyx_t_3);
3725       __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3726       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3727       __PYX_ERR(0, 87, __pyx_L9_error)
3728     }
3729     __pyx_L11:;
3730 
3731     /* "rasterio/_features.pyx":89
3732  *             raise ValueError("Invalid source image")
3733  *
3734  *         if mask is not None:             # <<<<<<<<<<<<<<
3735  *             if mask.shape != image.shape:
3736  *                 raise ValueError("Mask must have same shape as image")
3737  */
3738     __pyx_t_7 = (__pyx_cur_scope->__pyx_v_mask != Py_None);
3739     __pyx_t_6 = (__pyx_t_7 != 0);
3740     if (__pyx_t_6) {
3741 
3742       /* "rasterio/_features.pyx":90
3743  *
3744  *         if mask is not None:
3745  *             if mask.shape != image.shape:             # <<<<<<<<<<<<<<
3746  *                 raise ValueError("Mask must have same shape as image")
3747  *
3748  */
3749       __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mask, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L9_error)
3750       __Pyx_GOTREF(__pyx_t_3);
3751       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_image, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L9_error)
3752       __Pyx_GOTREF(__pyx_t_1);
3753       __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L9_error)
3754       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3755       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3756       __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 90, __pyx_L9_error)
3757       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3758       if (unlikely(__pyx_t_6)) {
3759 
3760         /* "rasterio/_features.pyx":91
3761  *         if mask is not None:
3762  *             if mask.shape != image.shape:
3763  *                 raise ValueError("Mask must have same shape as image")             # <<<<<<<<<<<<<<
3764  *
3765  *             if _getnpdtype(mask.dtype).name not in ('bool', 'uint8'):
3766  */
3767         __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L9_error)
3768         __Pyx_GOTREF(__pyx_t_2);
3769         __Pyx_Raise(__pyx_t_2, 0, 0, 0);
3770         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3771         __PYX_ERR(0, 91, __pyx_L9_error)
3772 
3773         /* "rasterio/_features.pyx":90
3774  *
3775  *         if mask is not None:
3776  *             if mask.shape != image.shape:             # <<<<<<<<<<<<<<
3777  *                 raise ValueError("Mask must have same shape as image")
3778  *
3779  */
3780       }
3781 
3782       /* "rasterio/_features.pyx":93
3783  *                 raise ValueError("Mask must have same shape as image")
3784  *
3785  *             if _getnpdtype(mask.dtype).name not in ('bool', 'uint8'):             # <<<<<<<<<<<<<<
3786  *                 raise ValueError("Mask must be dtype rasterio.bool_ or "
3787  *                                  "rasterio.uint8")
3788  */
3789       __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_getnpdtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L9_error)
3790       __Pyx_GOTREF(__pyx_t_1);
3791       __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mask, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L9_error)
3792       __Pyx_GOTREF(__pyx_t_3);
3793       __pyx_t_4 = NULL;
3794       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
3795         __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
3796         if (likely(__pyx_t_4)) {
3797           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3798           __Pyx_INCREF(__pyx_t_4);
3799           __Pyx_INCREF(function);
3800           __Pyx_DECREF_SET(__pyx_t_1, function);
3801         }
3802       }
3803       __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
3804       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3805       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3806       if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L9_error)
3807       __Pyx_GOTREF(__pyx_t_2);
3808       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3809       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L9_error)
3810       __Pyx_GOTREF(__pyx_t_1);
3811       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3812       __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_bool, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 93, __pyx_L9_error)
3813       if (__pyx_t_7) {
3814       } else {
3815         __pyx_t_6 = __pyx_t_7;
3816         goto __pyx_L15_bool_binop_done;
3817       }
3818       __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_uint8, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 93, __pyx_L9_error)
3819       __pyx_t_6 = __pyx_t_7;
3820       __pyx_L15_bool_binop_done:;
3821       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3822       __pyx_t_7 = (__pyx_t_6 != 0);
3823       if (unlikely(__pyx_t_7)) {
3824 
3825         /* "rasterio/_features.pyx":94
3826  *
3827  *             if _getnpdtype(mask.dtype).name not in ('bool', 'uint8'):
3828  *                 raise ValueError("Mask must be dtype rasterio.bool_ or "             # <<<<<<<<<<<<<<
3829  *                                  "rasterio.uint8")
3830  *
3831  */
3832         __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L9_error)
3833         __Pyx_GOTREF(__pyx_t_1);
3834         __Pyx_Raise(__pyx_t_1, 0, 0, 0);
3835         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3836         __PYX_ERR(0, 94, __pyx_L9_error)
3837 
3838         /* "rasterio/_features.pyx":93
3839  *                 raise ValueError("Mask must have same shape as image")
3840  *
3841  *             if _getnpdtype(mask.dtype).name not in ('bool', 'uint8'):             # <<<<<<<<<<<<<<
3842  *                 raise ValueError("Mask must be dtype rasterio.bool_ or "
3843  *                                  "rasterio.uint8")
3844  */
3845       }
3846 
3847       /* "rasterio/_features.pyx":97
3848  *                                  "rasterio.uint8")
3849  *
3850  *             if dtypes.is_ndarray(mask):             # <<<<<<<<<<<<<<
3851  *                 # A boolean mask must be converted to uint8 for GDAL
3852  *                 mask_ds = InMemoryRaster(image=mask.astype('uint8'),
3853  */
3854       __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_dtypes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L9_error)
3855       __Pyx_GOTREF(__pyx_t_2);
3856       __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 97, __pyx_L9_error)
3857       __Pyx_GOTREF(__pyx_t_3);
3858       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3859       __pyx_t_2 = NULL;
3860       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
3861         __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
3862         if (likely(__pyx_t_2)) {
3863           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3864           __Pyx_INCREF(__pyx_t_2);
3865           __Pyx_INCREF(function);
3866           __Pyx_DECREF_SET(__pyx_t_3, function);
3867         }
3868       }
3869       __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_cur_scope->__pyx_v_mask) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_cur_scope->__pyx_v_mask);
3870       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3871       if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L9_error)
3872       __Pyx_GOTREF(__pyx_t_1);
3873       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3874       __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 97, __pyx_L9_error)
3875       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3876       if (__pyx_t_7) {
3877 
3878         /* "rasterio/_features.pyx":99
3879  *             if dtypes.is_ndarray(mask):
3880  *                 # A boolean mask must be converted to uint8 for GDAL
3881  *                 mask_ds = InMemoryRaster(image=mask.astype('uint8'),             # <<<<<<<<<<<<<<
3882  *                                          transform=transform)
3883  *                 maskband = mask_ds.band(1)
3884  */
3885         __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L9_error)
3886         __Pyx_GOTREF(__pyx_t_1);
3887         __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mask, __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L9_error)
3888         __Pyx_GOTREF(__pyx_t_2);
3889         __pyx_t_4 = NULL;
3890         if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
3891           __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
3892           if (likely(__pyx_t_4)) {
3893             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3894             __Pyx_INCREF(__pyx_t_4);
3895             __Pyx_INCREF(function);
3896             __Pyx_DECREF_SET(__pyx_t_2, function);
3897           }
3898         }
3899         __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_n_u_uint8) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_n_u_uint8);
3900         __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3901         if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 99, __pyx_L9_error)
3902         __Pyx_GOTREF(__pyx_t_3);
3903         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3904         if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_image, __pyx_t_3) < 0) __PYX_ERR(0, 99, __pyx_L9_error)
3905         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3906 
3907         /* "rasterio/_features.pyx":100
3908  *                 # A boolean mask must be converted to uint8 for GDAL
3909  *                 mask_ds = InMemoryRaster(image=mask.astype('uint8'),
3910  *                                          transform=transform)             # <<<<<<<<<<<<<<
3911  *                 maskband = mask_ds.band(1)
3912  *             elif isinstance(mask, tuple):
3913  */
3914         if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_transform, __pyx_cur_scope->__pyx_v_transform) < 0) __PYX_ERR(0, 99, __pyx_L9_error)
3915 
3916         /* "rasterio/_features.pyx":99
3917  *             if dtypes.is_ndarray(mask):
3918  *                 # A boolean mask must be converted to uint8 for GDAL
3919  *                 mask_ds = InMemoryRaster(image=mask.astype('uint8'),             # <<<<<<<<<<<<<<
3920  *                                          transform=transform)
3921  *                 maskband = mask_ds.band(1)
3922  */
3923         __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8rasterio_3_io_InMemoryRaster), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 99, __pyx_L9_error)
3924         __Pyx_GOTREF(__pyx_t_3);
3925         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3926         __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_mask_ds));
3927         __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_mask_ds, ((struct __pyx_obj_8rasterio_3_io_InMemoryRaster *)__pyx_t_3));
3928         __Pyx_GIVEREF(__pyx_t_3);
3929         __pyx_t_3 = 0;
3930 
3931         /* "rasterio/_features.pyx":101
3932  *                 mask_ds = InMemoryRaster(image=mask.astype('uint8'),
3933  *                                          transform=transform)
3934  *                 maskband = mask_ds.band(1)             # <<<<<<<<<<<<<<
3935  *             elif isinstance(mask, tuple):
3936  *                 mrdr = mask.ds
3937  */
3938         __pyx_t_8 = ((struct __pyx_vtabstruct_8rasterio_3_io_InMemoryRaster *)__pyx_cur_scope->__pyx_v_mask_ds->__pyx_vtab)->band(__pyx_cur_scope->__pyx_v_mask_ds, 1); if (unlikely(__pyx_t_8 == ((GDALRasterBandH)NULL))) __PYX_ERR(0, 101, __pyx_L9_error)
3939         __pyx_cur_scope->__pyx_v_maskband = __pyx_t_8;
3940 
3941         /* "rasterio/_features.pyx":97
3942  *                                  "rasterio.uint8")
3943  *
3944  *             if dtypes.is_ndarray(mask):             # <<<<<<<<<<<<<<
3945  *                 # A boolean mask must be converted to uint8 for GDAL
3946  *                 mask_ds = InMemoryRaster(image=mask.astype('uint8'),
3947  */
3948         goto __pyx_L17;
3949       }
3950 
3951       /* "rasterio/_features.pyx":102
3952  *                                          transform=transform)
3953  *                 maskband = mask_ds.band(1)
3954  *             elif isinstance(mask, tuple):             # <<<<<<<<<<<<<<
3955  *                 mrdr = mask.ds
3956  *                 maskband = (<DatasetReaderBase?>mrdr).band(mask.bidx)
3957  */
3958       __pyx_t_7 = PyTuple_Check(__pyx_cur_scope->__pyx_v_mask);
3959       __pyx_t_6 = (__pyx_t_7 != 0);
3960       if (__pyx_t_6) {
3961 
3962         /* "rasterio/_features.pyx":103
3963  *                 maskband = mask_ds.band(1)
3964  *             elif isinstance(mask, tuple):
3965  *                 mrdr = mask.ds             # <<<<<<<<<<<<<<
3966  *                 maskband = (<DatasetReaderBase?>mrdr).band(mask.bidx)
3967  *
3968  */
3969         __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mask, __pyx_n_s_ds); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 103, __pyx_L9_error)
3970         __Pyx_GOTREF(__pyx_t_3);
3971         __Pyx_GIVEREF(__pyx_t_3);
3972         __pyx_cur_scope->__pyx_v_mrdr = __pyx_t_3;
3973         __pyx_t_3 = 0;
3974 
3975         /* "rasterio/_features.pyx":104
3976  *             elif isinstance(mask, tuple):
3977  *                 mrdr = mask.ds
3978  *                 maskband = (<DatasetReaderBase?>mrdr).band(mask.bidx)             # <<<<<<<<<<<<<<
3979  *
3980  *         # Create an in-memory feature store.
3981  */
3982         if (!(likely(__Pyx_TypeTest(__pyx_cur_scope->__pyx_v_mrdr, __pyx_ptype_8rasterio_3_io_DatasetReaderBase)))) __PYX_ERR(0, 104, __pyx_L9_error)
3983         __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mask, __pyx_n_s_bidx); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 104, __pyx_L9_error)
3984         __Pyx_GOTREF(__pyx_t_3);
3985         __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 104, __pyx_L9_error)
3986         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3987         __pyx_t_9 = ((struct __pyx_vtabstruct_8rasterio_3_io_DatasetReaderBase *)((struct __pyx_obj_8rasterio_3_io_DatasetReaderBase *)__pyx_cur_scope->__pyx_v_mrdr)->__pyx_base.__pyx_vtab)->__pyx_base.band(((struct __pyx_obj_8rasterio_5_base_DatasetBase *)((struct __pyx_obj_8rasterio_3_io_DatasetReaderBase *)__pyx_cur_scope->__pyx_v_mrdr)), __pyx_t_5); if (unlikely(__pyx_t_9 == ((GDALRasterBandH)NULL))) __PYX_ERR(0, 104, __pyx_L9_error)
3988         __pyx_cur_scope->__pyx_v_maskband = __pyx_t_9;
3989 
3990         /* "rasterio/_features.pyx":102
3991  *                                          transform=transform)
3992  *                 maskband = mask_ds.band(1)
3993  *             elif isinstance(mask, tuple):             # <<<<<<<<<<<<<<
3994  *                 mrdr = mask.ds
3995  *                 maskband = (<DatasetReaderBase?>mrdr).band(mask.bidx)
3996  */
3997       }
3998       __pyx_L17:;
3999 
4000       /* "rasterio/_features.pyx":89
4001  *             raise ValueError("Invalid source image")
4002  *
4003  *         if mask is not None:             # <<<<<<<<<<<<<<
4004  *             if mask.shape != image.shape:
4005  *                 raise ValueError("Mask must have same shape as image")
4006  */
4007     }
4008 
4009     /* "rasterio/_features.pyx":107
4010  *
4011  *         # Create an in-memory feature store.
4012  *         driver = OGRGetDriverByName("Memory")             # <<<<<<<<<<<<<<
4013  *         if driver == NULL:
4014  *             raise ValueError("NULL driver")
4015  */
4016     __pyx_cur_scope->__pyx_v_driver = OGRGetDriverByName(((char const *)"Memory"));
4017 
4018     /* "rasterio/_features.pyx":108
4019  *         # Create an in-memory feature store.
4020  *         driver = OGRGetDriverByName("Memory")
4021  *         if driver == NULL:             # <<<<<<<<<<<<<<
4022  *             raise ValueError("NULL driver")
4023  *         fs = OGR_Dr_CreateDataSource(driver, "temp", NULL)
4024  */
4025     __pyx_t_6 = ((__pyx_cur_scope->__pyx_v_driver == NULL) != 0);
4026     if (unlikely(__pyx_t_6)) {
4027 
4028       /* "rasterio/_features.pyx":109
4029  *         driver = OGRGetDriverByName("Memory")
4030  *         if driver == NULL:
4031  *             raise ValueError("NULL driver")             # <<<<<<<<<<<<<<
4032  *         fs = OGR_Dr_CreateDataSource(driver, "temp", NULL)
4033  *         if fs == NULL:
4034  */
4035       __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 109, __pyx_L9_error)
4036       __Pyx_GOTREF(__pyx_t_3);
4037       __Pyx_Raise(__pyx_t_3, 0, 0, 0);
4038       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4039       __PYX_ERR(0, 109, __pyx_L9_error)
4040 
4041       /* "rasterio/_features.pyx":108
4042  *         # Create an in-memory feature store.
4043  *         driver = OGRGetDriverByName("Memory")
4044  *         if driver == NULL:             # <<<<<<<<<<<<<<
4045  *             raise ValueError("NULL driver")
4046  *         fs = OGR_Dr_CreateDataSource(driver, "temp", NULL)
4047  */
4048     }
4049 
4050     /* "rasterio/_features.pyx":110
4051  *         if driver == NULL:
4052  *             raise ValueError("NULL driver")
4053  *         fs = OGR_Dr_CreateDataSource(driver, "temp", NULL)             # <<<<<<<<<<<<<<
4054  *         if fs == NULL:
4055  *             raise ValueError("NULL feature dataset")
4056  */
4057     __pyx_cur_scope->__pyx_v_fs = OGR_Dr_CreateDataSource(__pyx_cur_scope->__pyx_v_driver, ((char const *)"temp"), NULL);
4058 
4059     /* "rasterio/_features.pyx":111
4060  *             raise ValueError("NULL driver")
4061  *         fs = OGR_Dr_CreateDataSource(driver, "temp", NULL)
4062  *         if fs == NULL:             # <<<<<<<<<<<<<<
4063  *             raise ValueError("NULL feature dataset")
4064  *
4065  */
4066     __pyx_t_6 = ((__pyx_cur_scope->__pyx_v_fs == NULL) != 0);
4067     if (unlikely(__pyx_t_6)) {
4068 
4069       /* "rasterio/_features.pyx":112
4070  *         fs = OGR_Dr_CreateDataSource(driver, "temp", NULL)
4071  *         if fs == NULL:
4072  *             raise ValueError("NULL feature dataset")             # <<<<<<<<<<<<<<
4073  *
4074  *         # And a layer.
4075  */
4076       __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 112, __pyx_L9_error)
4077       __Pyx_GOTREF(__pyx_t_3);
4078       __Pyx_Raise(__pyx_t_3, 0, 0, 0);
4079       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4080       __PYX_ERR(0, 112, __pyx_L9_error)
4081 
4082       /* "rasterio/_features.pyx":111
4083  *             raise ValueError("NULL driver")
4084  *         fs = OGR_Dr_CreateDataSource(driver, "temp", NULL)
4085  *         if fs == NULL:             # <<<<<<<<<<<<<<
4086  *             raise ValueError("NULL feature dataset")
4087  *
4088  */
4089     }
4090 
4091     /* "rasterio/_features.pyx":115
4092  *
4093  *         # And a layer.
4094  *         layer = OGR_DS_CreateLayer(fs, "polygons", NULL, 3, NULL)             # <<<<<<<<<<<<<<
4095  *         if layer == NULL:
4096  *             raise ValueError("NULL layer")
4097  */
4098     __pyx_cur_scope->__pyx_v_layer = OGR_DS_CreateLayer(__pyx_cur_scope->__pyx_v_fs, ((char const *)"polygons"), NULL, 3, NULL);
4099 
4100     /* "rasterio/_features.pyx":116
4101  *         # And a layer.
4102  *         layer = OGR_DS_CreateLayer(fs, "polygons", NULL, 3, NULL)
4103  *         if layer == NULL:             # <<<<<<<<<<<<<<
4104  *             raise ValueError("NULL layer")
4105  *
4106  */
4107     __pyx_t_6 = ((__pyx_cur_scope->__pyx_v_layer == NULL) != 0);
4108     if (unlikely(__pyx_t_6)) {
4109 
4110       /* "rasterio/_features.pyx":117
4111  *         layer = OGR_DS_CreateLayer(fs, "polygons", NULL, 3, NULL)
4112  *         if layer == NULL:
4113  *             raise ValueError("NULL layer")             # <<<<<<<<<<<<<<
4114  *
4115  *         fielddefn = OGR_Fld_Create("image_value", fieldtp)
4116  */
4117       __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 117, __pyx_L9_error)
4118       __Pyx_GOTREF(__pyx_t_3);
4119       __Pyx_Raise(__pyx_t_3, 0, 0, 0);
4120       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4121       __PYX_ERR(0, 117, __pyx_L9_error)
4122 
4123       /* "rasterio/_features.pyx":116
4124  *         # And a layer.
4125  *         layer = OGR_DS_CreateLayer(fs, "polygons", NULL, 3, NULL)
4126  *         if layer == NULL:             # <<<<<<<<<<<<<<
4127  *             raise ValueError("NULL layer")
4128  *
4129  */
4130     }
4131 
4132     /* "rasterio/_features.pyx":119
4133  *             raise ValueError("NULL layer")
4134  *
4135  *         fielddefn = OGR_Fld_Create("image_value", fieldtp)             # <<<<<<<<<<<<<<
4136  *         if fielddefn == NULL:
4137  *             raise ValueError("NULL field definition")
4138  */
4139     __pyx_cur_scope->__pyx_v_fielddefn = OGR_Fld_Create(((char const *)"image_value"), __pyx_cur_scope->__pyx_v_fieldtp);
4140 
4141     /* "rasterio/_features.pyx":120
4142  *
4143  *         fielddefn = OGR_Fld_Create("image_value", fieldtp)
4144  *         if fielddefn == NULL:             # <<<<<<<<<<<<<<
4145  *             raise ValueError("NULL field definition")
4146  *         OGR_L_CreateField(layer, fielddefn, 1)
4147  */
4148     __pyx_t_6 = ((__pyx_cur_scope->__pyx_v_fielddefn == NULL) != 0);
4149     if (unlikely(__pyx_t_6)) {
4150 
4151       /* "rasterio/_features.pyx":121
4152  *         fielddefn = OGR_Fld_Create("image_value", fieldtp)
4153  *         if fielddefn == NULL:
4154  *             raise ValueError("NULL field definition")             # <<<<<<<<<<<<<<
4155  *         OGR_L_CreateField(layer, fielddefn, 1)
4156  *         OGR_Fld_Destroy(fielddefn)
4157  */
4158       __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 121, __pyx_L9_error)
4159       __Pyx_GOTREF(__pyx_t_3);
4160       __Pyx_Raise(__pyx_t_3, 0, 0, 0);
4161       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4162       __PYX_ERR(0, 121, __pyx_L9_error)
4163 
4164       /* "rasterio/_features.pyx":120
4165  *
4166  *         fielddefn = OGR_Fld_Create("image_value", fieldtp)
4167  *         if fielddefn == NULL:             # <<<<<<<<<<<<<<
4168  *             raise ValueError("NULL field definition")
4169  *         OGR_L_CreateField(layer, fielddefn, 1)
4170  */
4171     }
4172 
4173     /* "rasterio/_features.pyx":122
4174  *         if fielddefn == NULL:
4175  *             raise ValueError("NULL field definition")
4176  *         OGR_L_CreateField(layer, fielddefn, 1)             # <<<<<<<<<<<<<<
4177  *         OGR_Fld_Destroy(fielddefn)
4178  *
4179  */
4180     (void)(OGR_L_CreateField(__pyx_cur_scope->__pyx_v_layer, __pyx_cur_scope->__pyx_v_fielddefn, 1));
4181 
4182     /* "rasterio/_features.pyx":123
4183  *             raise ValueError("NULL field definition")
4184  *         OGR_L_CreateField(layer, fielddefn, 1)
4185  *         OGR_Fld_Destroy(fielddefn)             # <<<<<<<<<<<<<<
4186  *
4187  *         if connectivity == 8:
4188  */
4189     OGR_Fld_Destroy(__pyx_cur_scope->__pyx_v_fielddefn);
4190 
4191     /* "rasterio/_features.pyx":125
4192  *         OGR_Fld_Destroy(fielddefn)
4193  *
4194  *         if connectivity == 8:             # <<<<<<<<<<<<<<
4195  *             options = CSLSetNameValue(options, "8CONNECTED", "8")
4196  *
4197  */
4198     __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_cur_scope->__pyx_v_connectivity, __pyx_int_8, 8, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 125, __pyx_L9_error)
4199     __Pyx_GOTREF(__pyx_t_3);
4200     __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 125, __pyx_L9_error)
4201     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4202     if (__pyx_t_6) {
4203 
4204       /* "rasterio/_features.pyx":126
4205  *
4206  *         if connectivity == 8:
4207  *             options = CSLSetNameValue(options, "8CONNECTED", "8")             # <<<<<<<<<<<<<<
4208  *
4209  *         if is_float:
4210  */
4211       __pyx_cur_scope->__pyx_v_options = CSLSetNameValue(__pyx_cur_scope->__pyx_v_options, ((char *)"8CONNECTED"), ((char *)"8"));
4212 
4213       /* "rasterio/_features.pyx":125
4214  *         OGR_Fld_Destroy(fielddefn)
4215  *
4216  *         if connectivity == 8:             # <<<<<<<<<<<<<<
4217  *             options = CSLSetNameValue(options, "8CONNECTED", "8")
4218  *
4219  */
4220     }
4221 
4222     /* "rasterio/_features.pyx":128
4223  *             options = CSLSetNameValue(options, "8CONNECTED", "8")
4224  *
4225  *         if is_float:             # <<<<<<<<<<<<<<
4226  *             GDALFPolygonize(band, maskband, layer, 0, options, NULL, NULL)
4227  *         else:
4228  */
4229     __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_float); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 128, __pyx_L9_error)
4230     if (__pyx_t_6) {
4231 
4232       /* "rasterio/_features.pyx":129
4233  *
4234  *         if is_float:
4235  *             GDALFPolygonize(band, maskband, layer, 0, options, NULL, NULL)             # <<<<<<<<<<<<<<
4236  *         else:
4237  *             GDALPolygonize(band, maskband, layer, 0, options, NULL, NULL)
4238  */
4239       (void)(GDALFPolygonize(__pyx_cur_scope->__pyx_v_band, __pyx_cur_scope->__pyx_v_maskband, __pyx_cur_scope->__pyx_v_layer, 0, __pyx_cur_scope->__pyx_v_options, NULL, NULL));
4240 
4241       /* "rasterio/_features.pyx":128
4242  *             options = CSLSetNameValue(options, "8CONNECTED", "8")
4243  *
4244  *         if is_float:             # <<<<<<<<<<<<<<
4245  *             GDALFPolygonize(band, maskband, layer, 0, options, NULL, NULL)
4246  *         else:
4247  */
4248       goto __pyx_L23;
4249     }
4250 
4251     /* "rasterio/_features.pyx":131
4252  *             GDALFPolygonize(band, maskband, layer, 0, options, NULL, NULL)
4253  *         else:
4254  *             GDALPolygonize(band, maskband, layer, 0, options, NULL, NULL)             # <<<<<<<<<<<<<<
4255  *
4256  *     finally:
4257  */
4258     /*else*/ {
4259       (void)(GDALPolygonize(__pyx_cur_scope->__pyx_v_band, __pyx_cur_scope->__pyx_v_maskband, __pyx_cur_scope->__pyx_v_layer, 0, __pyx_cur_scope->__pyx_v_options, NULL, NULL));
4260     }
4261     __pyx_L23:;
4262   }
4263 
4264   /* "rasterio/_features.pyx":134
4265  *
4266  *     finally:
4267  *         if mem_ds is not None:             # <<<<<<<<<<<<<<
4268  *             mem_ds.close()
4269  *         if mask_ds is not None:
4270  */
4271   /*finally:*/ {
4272     /*normal exit:*/{
4273       __pyx_t_6 = (((PyObject *)__pyx_cur_scope->__pyx_v_mem_ds) != Py_None);
4274       __pyx_t_7 = (__pyx_t_6 != 0);
4275       if (__pyx_t_7) {
4276 
4277         /* "rasterio/_features.pyx":135
4278  *     finally:
4279  *         if mem_ds is not None:
4280  *             mem_ds.close()             # <<<<<<<<<<<<<<
4281  *         if mask_ds is not None:
4282  *             mask_ds.close()
4283  */
4284         __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_mem_ds), __pyx_n_s_close); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error)
4285         __Pyx_GOTREF(__pyx_t_1);
4286         __pyx_t_2 = NULL;
4287         if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
4288           __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
4289           if (likely(__pyx_t_2)) {
4290             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
4291             __Pyx_INCREF(__pyx_t_2);
4292             __Pyx_INCREF(function);
4293             __Pyx_DECREF_SET(__pyx_t_1, function);
4294           }
4295         }
4296         __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
4297         __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4298         if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
4299         __Pyx_GOTREF(__pyx_t_3);
4300         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4301         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4302 
4303         /* "rasterio/_features.pyx":134
4304  *
4305  *     finally:
4306  *         if mem_ds is not None:             # <<<<<<<<<<<<<<
4307  *             mem_ds.close()
4308  *         if mask_ds is not None:
4309  */
4310       }
4311 
4312       /* "rasterio/_features.pyx":136
4313  *         if mem_ds is not None:
4314  *             mem_ds.close()
4315  *         if mask_ds is not None:             # <<<<<<<<<<<<<<
4316  *             mask_ds.close()
4317  *         if options:
4318  */
4319       __pyx_t_7 = (((PyObject *)__pyx_cur_scope->__pyx_v_mask_ds) != Py_None);
4320       __pyx_t_6 = (__pyx_t_7 != 0);
4321       if (__pyx_t_6) {
4322 
4323         /* "rasterio/_features.pyx":137
4324  *             mem_ds.close()
4325  *         if mask_ds is not None:
4326  *             mask_ds.close()             # <<<<<<<<<<<<<<
4327  *         if options:
4328  *             CSLDestroy(options)
4329  */
4330         __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_mask_ds), __pyx_n_s_close); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error)
4331         __Pyx_GOTREF(__pyx_t_1);
4332         __pyx_t_2 = NULL;
4333         if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
4334           __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
4335           if (likely(__pyx_t_2)) {
4336             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
4337             __Pyx_INCREF(__pyx_t_2);
4338             __Pyx_INCREF(function);
4339             __Pyx_DECREF_SET(__pyx_t_1, function);
4340           }
4341         }
4342         __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
4343         __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4344         if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L1_error)
4345         __Pyx_GOTREF(__pyx_t_3);
4346         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4347         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4348 
4349         /* "rasterio/_features.pyx":136
4350  *         if mem_ds is not None:
4351  *             mem_ds.close()
4352  *         if mask_ds is not None:             # <<<<<<<<<<<<<<
4353  *             mask_ds.close()
4354  *         if options:
4355  */
4356       }
4357 
4358       /* "rasterio/_features.pyx":138
4359  *         if mask_ds is not None:
4360  *             mask_ds.close()
4361  *         if options:             # <<<<<<<<<<<<<<
4362  *             CSLDestroy(options)
4363  *
4364  */
4365       __pyx_t_6 = (__pyx_cur_scope->__pyx_v_options != 0);
4366       if (__pyx_t_6) {
4367 
4368         /* "rasterio/_features.pyx":139
4369  *             mask_ds.close()
4370  *         if options:
4371  *             CSLDestroy(options)             # <<<<<<<<<<<<<<
4372  *
4373  *     try:
4374  */
4375         CSLDestroy(__pyx_cur_scope->__pyx_v_options);
4376 
4377         /* "rasterio/_features.pyx":138
4378  *         if mask_ds is not None:
4379  *             mask_ds.close()
4380  *         if options:             # <<<<<<<<<<<<<<
4381  *             CSLDestroy(options)
4382  *
4383  */
4384       }
4385       goto __pyx_L10;
4386     }
4387     __pyx_L9_error:;
4388     /*exception exit:*/{
4389       __Pyx_PyThreadState_assign
4390       __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
4391       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
4392       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4393       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
4394       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
4395       if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
4396       if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
4397       __Pyx_XGOTREF(__pyx_t_12);
4398       __Pyx_XGOTREF(__pyx_t_13);
4399       __Pyx_XGOTREF(__pyx_t_14);
4400       __Pyx_XGOTREF(__pyx_t_15);
4401       __Pyx_XGOTREF(__pyx_t_16);
4402       __Pyx_XGOTREF(__pyx_t_17);
4403       __pyx_t_5 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
4404       {
4405 
4406         /* "rasterio/_features.pyx":134
4407  *
4408  *     finally:
4409  *         if mem_ds is not None:             # <<<<<<<<<<<<<<
4410  *             mem_ds.close()
4411  *         if mask_ds is not None:
4412  */
4413         __pyx_t_6 = (((PyObject *)__pyx_cur_scope->__pyx_v_mem_ds) != Py_None);
4414         __pyx_t_7 = (__pyx_t_6 != 0);
4415         if (__pyx_t_7) {
4416 
4417           /* "rasterio/_features.pyx":135
4418  *     finally:
4419  *         if mem_ds is not None:
4420  *             mem_ds.close()             # <<<<<<<<<<<<<<
4421  *         if mask_ds is not None:
4422  *             mask_ds.close()
4423  */
4424           __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_mem_ds), __pyx_n_s_close); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L28_error)
4425           __Pyx_GOTREF(__pyx_t_1);
4426           __pyx_t_2 = NULL;
4427           if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
4428             __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
4429             if (likely(__pyx_t_2)) {
4430               PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
4431               __Pyx_INCREF(__pyx_t_2);
4432               __Pyx_INCREF(function);
4433               __Pyx_DECREF_SET(__pyx_t_1, function);
4434             }
4435           }
4436           __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
4437           __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4438           if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L28_error)
4439           __Pyx_GOTREF(__pyx_t_3);
4440           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4441           __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4442 
4443           /* "rasterio/_features.pyx":134
4444  *
4445  *     finally:
4446  *         if mem_ds is not None:             # <<<<<<<<<<<<<<
4447  *             mem_ds.close()
4448  *         if mask_ds is not None:
4449  */
4450         }
4451 
4452         /* "rasterio/_features.pyx":136
4453  *         if mem_ds is not None:
4454  *             mem_ds.close()
4455  *         if mask_ds is not None:             # <<<<<<<<<<<<<<
4456  *             mask_ds.close()
4457  *         if options:
4458  */
4459         __pyx_t_7 = (((PyObject *)__pyx_cur_scope->__pyx_v_mask_ds) != Py_None);
4460         __pyx_t_6 = (__pyx_t_7 != 0);
4461         if (__pyx_t_6) {
4462 
4463           /* "rasterio/_features.pyx":137
4464  *             mem_ds.close()
4465  *         if mask_ds is not None:
4466  *             mask_ds.close()             # <<<<<<<<<<<<<<
4467  *         if options:
4468  *             CSLDestroy(options)
4469  */
4470           __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_mask_ds), __pyx_n_s_close); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L28_error)
4471           __Pyx_GOTREF(__pyx_t_1);
4472           __pyx_t_2 = NULL;
4473           if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
4474             __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
4475             if (likely(__pyx_t_2)) {
4476               PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
4477               __Pyx_INCREF(__pyx_t_2);
4478               __Pyx_INCREF(function);
4479               __Pyx_DECREF_SET(__pyx_t_1, function);
4480             }
4481           }
4482           __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
4483           __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4484           if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L28_error)
4485           __Pyx_GOTREF(__pyx_t_3);
4486           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4487           __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4488 
4489           /* "rasterio/_features.pyx":136
4490  *         if mem_ds is not None:
4491  *             mem_ds.close()
4492  *         if mask_ds is not None:             # <<<<<<<<<<<<<<
4493  *             mask_ds.close()
4494  *         if options:
4495  */
4496         }
4497 
4498         /* "rasterio/_features.pyx":138
4499  *         if mask_ds is not None:
4500  *             mask_ds.close()
4501  *         if options:             # <<<<<<<<<<<<<<
4502  *             CSLDestroy(options)
4503  *
4504  */
4505         __pyx_t_6 = (__pyx_cur_scope->__pyx_v_options != 0);
4506         if (__pyx_t_6) {
4507 
4508           /* "rasterio/_features.pyx":139
4509  *             mask_ds.close()
4510  *         if options:
4511  *             CSLDestroy(options)             # <<<<<<<<<<<<<<
4512  *
4513  *     try:
4514  */
4515           CSLDestroy(__pyx_cur_scope->__pyx_v_options);
4516 
4517           /* "rasterio/_features.pyx":138
4518  *         if mask_ds is not None:
4519  *             mask_ds.close()
4520  *         if options:             # <<<<<<<<<<<<<<
4521  *             CSLDestroy(options)
4522  *
4523  */
4524         }
4525       }
4526       if (PY_MAJOR_VERSION >= 3) {
4527         __Pyx_XGIVEREF(__pyx_t_15);
4528         __Pyx_XGIVEREF(__pyx_t_16);
4529         __Pyx_XGIVEREF(__pyx_t_17);
4530         __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
4531       }
4532       __Pyx_XGIVEREF(__pyx_t_12);
4533       __Pyx_XGIVEREF(__pyx_t_13);
4534       __Pyx_XGIVEREF(__pyx_t_14);
4535       __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
4536       __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
4537       __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
4538       goto __pyx_L1_error;
4539       __pyx_L28_error:;
4540       if (PY_MAJOR_VERSION >= 3) {
4541         __Pyx_XGIVEREF(__pyx_t_15);
4542         __Pyx_XGIVEREF(__pyx_t_16);
4543         __Pyx_XGIVEREF(__pyx_t_17);
4544         __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
4545       }
4546       __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
4547       __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
4548       __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
4549       __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
4550       goto __pyx_L1_error;
4551     }
4552     __pyx_L10:;
4553   }
4554 
4555   /* "rasterio/_features.pyx":141
4556  *             CSLDestroy(options)
4557  *
4558  *     try:             # <<<<<<<<<<<<<<
4559  *         # Yield Fiona-style features
4560  *         shape_iter = ShapeIterator()
4561  */
4562   /*try:*/ {
4563 
4564     /* "rasterio/_features.pyx":143
4565  *     try:
4566  *         # Yield Fiona-style features
4567  *         shape_iter = ShapeIterator()             # <<<<<<<<<<<<<<
4568  *         shape_iter.layer = layer
4569  *         shape_iter.fieldtype = fieldtp
4570  */
4571     __pyx_t_3 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_8rasterio_9_features_ShapeIterator)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 143, __pyx_L33_error)
4572     __Pyx_GOTREF(__pyx_t_3);
4573     __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_shape_iter));
4574     __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_shape_iter, ((struct __pyx_obj_8rasterio_9_features_ShapeIterator *)__pyx_t_3));
4575     __Pyx_GIVEREF(__pyx_t_3);
4576     __pyx_t_3 = 0;
4577 
4578     /* "rasterio/_features.pyx":144
4579  *         # Yield Fiona-style features
4580  *         shape_iter = ShapeIterator()
4581  *         shape_iter.layer = layer             # <<<<<<<<<<<<<<
4582  *         shape_iter.fieldtype = fieldtp
4583  *         for s, v in shape_iter:
4584  */
4585     __pyx_cur_scope->__pyx_v_shape_iter->layer = __pyx_cur_scope->__pyx_v_layer;
4586 
4587     /* "rasterio/_features.pyx":145
4588  *         shape_iter = ShapeIterator()
4589  *         shape_iter.layer = layer
4590  *         shape_iter.fieldtype = fieldtp             # <<<<<<<<<<<<<<
4591  *         for s, v in shape_iter:
4592  *             yield s, v
4593  */
4594     __pyx_cur_scope->__pyx_v_shape_iter->fieldtype = __pyx_cur_scope->__pyx_v_fieldtp;
4595 
4596     /* "rasterio/_features.pyx":146
4597  *         shape_iter.layer = layer
4598  *         shape_iter.fieldtype = fieldtp
4599  *         for s, v in shape_iter:             # <<<<<<<<<<<<<<
4600  *             yield s, v
4601  *
4602  */
4603     if (likely(PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_shape_iter))) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_v_shape_iter))) {
4604       __pyx_t_3 = ((PyObject *)__pyx_cur_scope->__pyx_v_shape_iter); __Pyx_INCREF(__pyx_t_3); __pyx_t_18 = 0;
4605       __pyx_t_19 = NULL;
4606     } else {
4607       __pyx_t_18 = -1; __pyx_t_3 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_v_shape_iter)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L33_error)
4608       __Pyx_GOTREF(__pyx_t_3);
4609       __pyx_t_19 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 146, __pyx_L33_error)
4610     }
4611     for (;;) {
4612       if (likely(!__pyx_t_19)) {
4613         if (likely(PyList_CheckExact(__pyx_t_3))) {
4614           if (__pyx_t_18 >= PyList_GET_SIZE(__pyx_t_3)) break;
4615           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4616           __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_18); __Pyx_INCREF(__pyx_t_1); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 146, __pyx_L33_error)
4617           #else
4618           __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L33_error)
4619           __Pyx_GOTREF(__pyx_t_1);
4620           #endif
4621         } else {
4622           if (__pyx_t_18 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
4623           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4624           __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_18); __Pyx_INCREF(__pyx_t_1); __pyx_t_18++; if (unlikely(0 < 0)) __PYX_ERR(0, 146, __pyx_L33_error)
4625           #else
4626           __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L33_error)
4627           __Pyx_GOTREF(__pyx_t_1);
4628           #endif
4629         }
4630       } else {
4631         __pyx_t_1 = __pyx_t_19(__pyx_t_3);
4632         if (unlikely(!__pyx_t_1)) {
4633           PyObject* exc_type = PyErr_Occurred();
4634           if (exc_type) {
4635             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
4636             else __PYX_ERR(0, 146, __pyx_L33_error)
4637           }
4638           break;
4639         }
4640         __Pyx_GOTREF(__pyx_t_1);
4641       }
4642       if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
4643         PyObject* sequence = __pyx_t_1;
4644         Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
4645         if (unlikely(size != 2)) {
4646           if (size > 2) __Pyx_RaiseTooManyValuesError(2);
4647           else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
4648           __PYX_ERR(0, 146, __pyx_L33_error)
4649         }
4650         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4651         if (likely(PyTuple_CheckExact(sequence))) {
4652           __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
4653           __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
4654         } else {
4655           __pyx_t_2 = PyList_GET_ITEM(sequence, 0);
4656           __pyx_t_4 = PyList_GET_ITEM(sequence, 1);
4657         }
4658         __Pyx_INCREF(__pyx_t_2);
4659         __Pyx_INCREF(__pyx_t_4);
4660         #else
4661         __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L33_error)
4662         __Pyx_GOTREF(__pyx_t_2);
4663         __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L33_error)
4664         __Pyx_GOTREF(__pyx_t_4);
4665         #endif
4666         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4667       } else {
4668         Py_ssize_t index = -1;
4669         __pyx_t_20 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 146, __pyx_L33_error)
4670         __Pyx_GOTREF(__pyx_t_20);
4671         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4672         __pyx_t_21 = Py_TYPE(__pyx_t_20)->tp_iternext;
4673         index = 0; __pyx_t_2 = __pyx_t_21(__pyx_t_20); if (unlikely(!__pyx_t_2)) goto __pyx_L37_unpacking_failed;
4674         __Pyx_GOTREF(__pyx_t_2);
4675         index = 1; __pyx_t_4 = __pyx_t_21(__pyx_t_20); if (unlikely(!__pyx_t_4)) goto __pyx_L37_unpacking_failed;
4676         __Pyx_GOTREF(__pyx_t_4);
4677         if (__Pyx_IternextUnpackEndCheck(__pyx_t_21(__pyx_t_20), 2) < 0) __PYX_ERR(0, 146, __pyx_L33_error)
4678         __pyx_t_21 = NULL;
4679         __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
4680         goto __pyx_L38_unpacking_done;
4681         __pyx_L37_unpacking_failed:;
4682         __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
4683         __pyx_t_21 = NULL;
4684         if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
4685         __PYX_ERR(0, 146, __pyx_L33_error)
4686         __pyx_L38_unpacking_done:;
4687       }
4688       __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_s);
4689       __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_s, __pyx_t_2);
4690       __Pyx_GIVEREF(__pyx_t_2);
4691       __pyx_t_2 = 0;
4692       __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
4693       __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_4);
4694       __Pyx_GIVEREF(__pyx_t_4);
4695       __pyx_t_4 = 0;
4696 
4697       /* "rasterio/_features.pyx":147
4698  *         shape_iter.fieldtype = fieldtp
4699  *         for s, v in shape_iter:
4700  *             yield s, v             # <<<<<<<<<<<<<<
4701  *
4702  *     finally:
4703  */
4704       __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L33_error)
4705       __Pyx_GOTREF(__pyx_t_1);
4706       __Pyx_INCREF(__pyx_cur_scope->__pyx_v_s);
4707       __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_s);
4708       PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_s);
4709       __Pyx_INCREF(__pyx_cur_scope->__pyx_v_v);
4710       __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_v);
4711       PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_cur_scope->__pyx_v_v);
4712       __pyx_r = __pyx_t_1;
4713       __pyx_t_1 = 0;
4714       __Pyx_XGIVEREF(__pyx_t_3);
4715       __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
4716       __pyx_cur_scope->__pyx_t_1 = __pyx_t_18;
4717       __pyx_cur_scope->__pyx_t_2 = __pyx_t_19;
4718       __Pyx_XGIVEREF(__pyx_r);
4719       __Pyx_RefNannyFinishContext();
4720       __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
4721       /* return from generator, yielding value */
4722       __pyx_generator->resume_label = 1;
4723       return __pyx_r;
4724       __pyx_L39_resume_from_yield:;
4725       __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
4726       __pyx_cur_scope->__pyx_t_0 = 0;
4727       __Pyx_XGOTREF(__pyx_t_3);
4728       __pyx_t_18 = __pyx_cur_scope->__pyx_t_1;
4729       __pyx_t_19 = __pyx_cur_scope->__pyx_t_2;
4730       if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 147, __pyx_L33_error)
4731 
4732       /* "rasterio/_features.pyx":146
4733  *         shape_iter.layer = layer
4734  *         shape_iter.fieldtype = fieldtp
4735  *         for s, v in shape_iter:             # <<<<<<<<<<<<<<
4736  *             yield s, v
4737  *
4738  */
4739     }
4740     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4741   }
4742 
4743   /* "rasterio/_features.pyx":150
4744  *
4745  *     finally:
4746  *         if fs != NULL:             # <<<<<<<<<<<<<<
4747  *             OGR_DS_Destroy(fs)
4748  *
4749  */
4750   /*finally:*/ {
4751     /*normal exit:*/{
4752       __pyx_t_6 = ((__pyx_cur_scope->__pyx_v_fs != NULL) != 0);
4753       if (__pyx_t_6) {
4754 
4755         /* "rasterio/_features.pyx":151
4756  *     finally:
4757  *         if fs != NULL:
4758  *             OGR_DS_Destroy(fs)             # <<<<<<<<<<<<<<
4759  *
4760  *
4761  */
4762         OGR_DS_Destroy(__pyx_cur_scope->__pyx_v_fs);
4763 
4764         /* "rasterio/_features.pyx":150
4765  *
4766  *     finally:
4767  *         if fs != NULL:             # <<<<<<<<<<<<<<
4768  *             OGR_DS_Destroy(fs)
4769  *
4770  */
4771       }
4772       goto __pyx_L34;
4773     }
4774     __pyx_L33_error:;
4775     /*exception exit:*/{
4776       __Pyx_PyThreadState_assign
4777       __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0;
4778       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
4779       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4780       __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
4781       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
4782       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
4783       if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
4784       if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_16, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_16, &__pyx_t_15);
4785       __Pyx_XGOTREF(__pyx_t_17);
4786       __Pyx_XGOTREF(__pyx_t_16);
4787       __Pyx_XGOTREF(__pyx_t_15);
4788       __Pyx_XGOTREF(__pyx_t_14);
4789       __Pyx_XGOTREF(__pyx_t_13);
4790       __Pyx_XGOTREF(__pyx_t_12);
4791       __pyx_t_10 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_22 = __pyx_filename;
4792       {
4793         __pyx_t_6 = ((__pyx_cur_scope->__pyx_v_fs != NULL) != 0);
4794         if (__pyx_t_6) {
4795 
4796           /* "rasterio/_features.pyx":151
4797  *     finally:
4798  *         if fs != NULL:
4799  *             OGR_DS_Destroy(fs)             # <<<<<<<<<<<<<<
4800  *
4801  *
4802  */
4803           OGR_DS_Destroy(__pyx_cur_scope->__pyx_v_fs);
4804 
4805           /* "rasterio/_features.pyx":150
4806  *
4807  *     finally:
4808  *         if fs != NULL:             # <<<<<<<<<<<<<<
4809  *             OGR_DS_Destroy(fs)
4810  *
4811  */
4812         }
4813       }
4814       if (PY_MAJOR_VERSION >= 3) {
4815         __Pyx_XGIVEREF(__pyx_t_14);
4816         __Pyx_XGIVEREF(__pyx_t_13);
4817         __Pyx_XGIVEREF(__pyx_t_12);
4818         __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
4819       }
4820       __Pyx_XGIVEREF(__pyx_t_17);
4821       __Pyx_XGIVEREF(__pyx_t_16);
4822       __Pyx_XGIVEREF(__pyx_t_15);
4823       __Pyx_ErrRestore(__pyx_t_17, __pyx_t_16, __pyx_t_15);
4824       __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0;
4825       __pyx_lineno = __pyx_t_10; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_22;
4826       goto __pyx_L1_error;
4827     }
4828     __pyx_L34:;
4829   }
4830   CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
4831 
4832   /* "rasterio/_features.pyx":22
4833  *
4834  *
4835  * def _shapes(image, mask, connectivity, transform):             # <<<<<<<<<<<<<<
4836  *     """
4837  *     Return a generator of (polygon, value) for each each set of adjacent pixels
4838  */
4839 
4840   /* function exit code */
4841   PyErr_SetNone(PyExc_StopIteration);
4842   goto __pyx_L0;
4843   __pyx_L1_error:;
4844   __Pyx_XDECREF(__pyx_t_1);
4845   __Pyx_XDECREF(__pyx_t_2);
4846   __Pyx_XDECREF(__pyx_t_3);
4847   __Pyx_XDECREF(__pyx_t_4);
4848   __Pyx_XDECREF(__pyx_t_20);
4849   __Pyx_AddTraceback("_shapes", __pyx_clineno, __pyx_lineno, __pyx_filename);
4850   __pyx_L0:;
4851   __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
4852   #if !CYTHON_USE_EXC_INFO_STACK
4853   __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
4854   #endif
4855   __pyx_generator->resume_label = -1;
4856   __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
4857   __Pyx_RefNannyFinishContext();
4858   return __pyx_r;
4859 }
4860 
4861 /* "rasterio/_features.pyx":154
4862  *
4863  *
4864  * def _sieve(image, size, out, mask, connectivity):             # <<<<<<<<<<<<<<
4865  *     """
4866  *     Replaces small polygons in `image` with the value of their largest
4867  */
4868 
4869 /* Python wrapper */
4870 static PyObject *__pyx_pw_8rasterio_9_features_4_sieve(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4871 static char __pyx_doc_8rasterio_9_features_3_sieve[] = "\n    Replaces small polygons in `image` with the value of their largest\n    neighbor.  Polygons are found for each set of neighboring pixels of the\n    same value.\n\n    Parameters\n    ----------\n    image : array or dataset object opened in 'r' mode or Band or tuple(dataset, bidx)\n        Must be of type rasterio.int16, rasterio.int32, rasterio.uint8,\n        rasterio.uint16, or rasterio.float32.\n    size : int\n        minimum polygon size (number of pixels) to retain.\n    out : numpy ndarray\n        Array of same shape and data type as `image` in which to store results.\n    mask : numpy ndarray or rasterio Band object\n        Values of False or 0 will be excluded from feature generation.\n        Must evaluate to bool (rasterio.bool_ or rasterio.uint8)\n    connectivity : int\n        Use 4 or 8 pixel connectivity for grouping pixels into features.\n\n    ";
4872 static PyMethodDef __pyx_mdef_8rasterio_9_features_4_sieve = {"_sieve", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8rasterio_9_features_4_sieve, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8rasterio_9_features_3_sieve};
__pyx_pw_8rasterio_9_features_4_sieve(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)4873 static PyObject *__pyx_pw_8rasterio_9_features_4_sieve(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4874   PyObject *__pyx_v_image = 0;
4875   PyObject *__pyx_v_size = 0;
4876   PyObject *__pyx_v_out = 0;
4877   PyObject *__pyx_v_mask = 0;
4878   PyObject *__pyx_v_connectivity = 0;
4879   int __pyx_lineno = 0;
4880   const char *__pyx_filename = NULL;
4881   int __pyx_clineno = 0;
4882   PyObject *__pyx_r = 0;
4883   __Pyx_RefNannyDeclarations
4884   __Pyx_RefNannySetupContext("_sieve (wrapper)", 0);
4885   {
4886     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_image,&__pyx_n_s_size,&__pyx_n_s_out,&__pyx_n_s_mask,&__pyx_n_s_connectivity,0};
4887     PyObject* values[5] = {0,0,0,0,0};
4888     if (unlikely(__pyx_kwds)) {
4889       Py_ssize_t kw_args;
4890       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4891       switch (pos_args) {
4892         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
4893         CYTHON_FALLTHROUGH;
4894         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4895         CYTHON_FALLTHROUGH;
4896         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4897         CYTHON_FALLTHROUGH;
4898         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4899         CYTHON_FALLTHROUGH;
4900         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4901         CYTHON_FALLTHROUGH;
4902         case  0: break;
4903         default: goto __pyx_L5_argtuple_error;
4904       }
4905       kw_args = PyDict_Size(__pyx_kwds);
4906       switch (pos_args) {
4907         case  0:
4908         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_image)) != 0)) kw_args--;
4909         else goto __pyx_L5_argtuple_error;
4910         CYTHON_FALLTHROUGH;
4911         case  1:
4912         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_size)) != 0)) kw_args--;
4913         else {
4914           __Pyx_RaiseArgtupleInvalid("_sieve", 1, 5, 5, 1); __PYX_ERR(0, 154, __pyx_L3_error)
4915         }
4916         CYTHON_FALLTHROUGH;
4917         case  2:
4918         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out)) != 0)) kw_args--;
4919         else {
4920           __Pyx_RaiseArgtupleInvalid("_sieve", 1, 5, 5, 2); __PYX_ERR(0, 154, __pyx_L3_error)
4921         }
4922         CYTHON_FALLTHROUGH;
4923         case  3:
4924         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--;
4925         else {
4926           __Pyx_RaiseArgtupleInvalid("_sieve", 1, 5, 5, 3); __PYX_ERR(0, 154, __pyx_L3_error)
4927         }
4928         CYTHON_FALLTHROUGH;
4929         case  4:
4930         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_connectivity)) != 0)) kw_args--;
4931         else {
4932           __Pyx_RaiseArgtupleInvalid("_sieve", 1, 5, 5, 4); __PYX_ERR(0, 154, __pyx_L3_error)
4933         }
4934       }
4935       if (unlikely(kw_args > 0)) {
4936         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_sieve") < 0)) __PYX_ERR(0, 154, __pyx_L3_error)
4937       }
4938     } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
4939       goto __pyx_L5_argtuple_error;
4940     } else {
4941       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4942       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4943       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4944       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4945       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
4946     }
4947     __pyx_v_image = values[0];
4948     __pyx_v_size = values[1];
4949     __pyx_v_out = values[2];
4950     __pyx_v_mask = values[3];
4951     __pyx_v_connectivity = values[4];
4952   }
4953   goto __pyx_L4_argument_unpacking_done;
4954   __pyx_L5_argtuple_error:;
4955   __Pyx_RaiseArgtupleInvalid("_sieve", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 154, __pyx_L3_error)
4956   __pyx_L3_error:;
4957   __Pyx_AddTraceback("rasterio._features._sieve", __pyx_clineno, __pyx_lineno, __pyx_filename);
4958   __Pyx_RefNannyFinishContext();
4959   return NULL;
4960   __pyx_L4_argument_unpacking_done:;
4961   __pyx_r = __pyx_pf_8rasterio_9_features_3_sieve(__pyx_self, __pyx_v_image, __pyx_v_size, __pyx_v_out, __pyx_v_mask, __pyx_v_connectivity);
4962 
4963   /* function exit code */
4964   __Pyx_RefNannyFinishContext();
4965   return __pyx_r;
4966 }
4967 static PyObject *__pyx_gb_8rasterio_9_features_6_sieve_2generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
4968 
4969 /* "rasterio/_features.pyx":189
4970  *
4971  *     if _getnpdtype(image.dtype).name not in valid_dtypes:
4972  *         valid_types_str = ', '.join(('rasterio.{0}'.format(t) for t             # <<<<<<<<<<<<<<
4973  *                                      in valid_dtypes))
4974  *         raise ValueError(
4975  */
4976 
__pyx_pf_8rasterio_9_features_6_sieve_genexpr(PyObject * __pyx_self)4977 static PyObject *__pyx_pf_8rasterio_9_features_6_sieve_genexpr(PyObject *__pyx_self) {
4978   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr *__pyx_cur_scope;
4979   PyObject *__pyx_r = NULL;
4980   __Pyx_RefNannyDeclarations
4981   int __pyx_lineno = 0;
4982   const char *__pyx_filename = NULL;
4983   int __pyx_clineno = 0;
4984   __Pyx_RefNannySetupContext("genexpr", 0);
4985   __pyx_cur_scope = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr *)__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_2_genexpr(__pyx_ptype_8rasterio_9_features___pyx_scope_struct_2_genexpr, __pyx_empty_tuple, NULL);
4986   if (unlikely(!__pyx_cur_scope)) {
4987     __pyx_cur_scope = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr *)Py_None);
4988     __Pyx_INCREF(Py_None);
4989     __PYX_ERR(0, 189, __pyx_L1_error)
4990   } else {
4991     __Pyx_GOTREF(__pyx_cur_scope);
4992   }
4993   __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve *) __pyx_self;
4994   __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
4995   __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
4996   {
4997     __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_8rasterio_9_features_6_sieve_2generator2, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_sieve_locals_genexpr, __pyx_n_s_rasterio__features); if (unlikely(!gen)) __PYX_ERR(0, 189, __pyx_L1_error)
4998     __Pyx_DECREF(__pyx_cur_scope);
4999     __Pyx_RefNannyFinishContext();
5000     return (PyObject *) gen;
5001   }
5002 
5003   /* function exit code */
5004   __pyx_L1_error:;
5005   __Pyx_AddTraceback("rasterio._features._sieve.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
5006   __pyx_r = NULL;
5007   __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
5008   __Pyx_XGIVEREF(__pyx_r);
5009   __Pyx_RefNannyFinishContext();
5010   return __pyx_r;
5011 }
5012 
__pyx_gb_8rasterio_9_features_6_sieve_2generator2(__pyx_CoroutineObject * __pyx_generator,CYTHON_UNUSED PyThreadState * __pyx_tstate,PyObject * __pyx_sent_value)5013 static PyObject *__pyx_gb_8rasterio_9_features_6_sieve_2generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
5014 {
5015   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr *__pyx_cur_scope = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr *)__pyx_generator->closure);
5016   PyObject *__pyx_r = NULL;
5017   PyObject *__pyx_t_1 = NULL;
5018   Py_ssize_t __pyx_t_2;
5019   PyObject *__pyx_t_3 = NULL;
5020   PyObject *__pyx_t_4 = NULL;
5021   PyObject *__pyx_t_5 = NULL;
5022   int __pyx_lineno = 0;
5023   const char *__pyx_filename = NULL;
5024   int __pyx_clineno = 0;
5025   __Pyx_RefNannyDeclarations
5026   __Pyx_RefNannySetupContext("genexpr", 0);
5027   switch (__pyx_generator->resume_label) {
5028     case 0: goto __pyx_L3_first_run;
5029     default: /* CPython raises the right error here */
5030     __Pyx_RefNannyFinishContext();
5031     return NULL;
5032   }
5033   __pyx_L3_first_run:;
5034   if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 189, __pyx_L1_error)
5035   __pyx_r = PyList_New(0); if (unlikely(!__pyx_r)) __PYX_ERR(0, 189, __pyx_L1_error)
5036   __Pyx_GOTREF(__pyx_r);
5037 
5038   /* "rasterio/_features.pyx":190
5039  *     if _getnpdtype(image.dtype).name not in valid_dtypes:
5040  *         valid_types_str = ', '.join(('rasterio.{0}'.format(t) for t
5041  *                                      in valid_dtypes))             # <<<<<<<<<<<<<<
5042  *         raise ValueError(
5043  *             "image dtype must be one of: {0}".format(valid_types_str))
5044  */
5045   if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_valid_dtypes)) { __Pyx_RaiseClosureNameError("valid_dtypes"); __PYX_ERR(0, 190, __pyx_L1_error) }
5046   if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_valid_dtypes == Py_None)) {
5047     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
5048     __PYX_ERR(0, 190, __pyx_L1_error)
5049   }
5050   __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_valid_dtypes; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
5051   for (;;) {
5052     if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
5053     #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5054     __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 190, __pyx_L1_error)
5055     #else
5056     __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error)
5057     __Pyx_GOTREF(__pyx_t_3);
5058     #endif
5059     __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_t);
5060     __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_t, __pyx_t_3);
5061     __Pyx_GIVEREF(__pyx_t_3);
5062     __pyx_t_3 = 0;
5063 
5064     /* "rasterio/_features.pyx":189
5065  *
5066  *     if _getnpdtype(image.dtype).name not in valid_dtypes:
5067  *         valid_types_str = ', '.join(('rasterio.{0}'.format(t) for t             # <<<<<<<<<<<<<<
5068  *                                      in valid_dtypes))
5069  *         raise ValueError(
5070  */
5071     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_rasterio_0, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 189, __pyx_L1_error)
5072     __Pyx_GOTREF(__pyx_t_4);
5073     __pyx_t_5 = NULL;
5074     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
5075       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
5076       if (likely(__pyx_t_5)) {
5077         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
5078         __Pyx_INCREF(__pyx_t_5);
5079         __Pyx_INCREF(function);
5080         __Pyx_DECREF_SET(__pyx_t_4, function);
5081       }
5082     }
5083     __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_cur_scope->__pyx_v_t) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_cur_scope->__pyx_v_t);
5084     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5085     if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 189, __pyx_L1_error)
5086     __Pyx_GOTREF(__pyx_t_3);
5087     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5088     if (unlikely(__Pyx_ListComp_Append(__pyx_r, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 189, __pyx_L1_error)
5089     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5090   }
5091   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5092   CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
5093 
5094   /* function exit code */
5095   goto __pyx_L0;
5096   __pyx_L1_error:;
5097   __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
5098   __Pyx_XDECREF(__pyx_t_1);
5099   __Pyx_XDECREF(__pyx_t_3);
5100   __Pyx_XDECREF(__pyx_t_4);
5101   __Pyx_XDECREF(__pyx_t_5);
5102   __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
5103   __pyx_L0:;
5104   __Pyx_XGIVEREF(__pyx_r);
5105   #if !CYTHON_USE_EXC_INFO_STACK
5106   __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
5107   #endif
5108   __pyx_generator->resume_label = -1;
5109   __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
5110   __Pyx_RefNannyFinishContext();
5111   return __pyx_r;
5112 }
5113 
5114 /* "rasterio/_features.pyx":154
5115  *
5116  *
5117  * def _sieve(image, size, out, mask, connectivity):             # <<<<<<<<<<<<<<
5118  *     """
5119  *     Replaces small polygons in `image` with the value of their largest
5120  */
5121 
__pyx_pf_8rasterio_9_features_3_sieve(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_image,PyObject * __pyx_v_size,PyObject * __pyx_v_out,PyObject * __pyx_v_mask,PyObject * __pyx_v_connectivity)5122 static PyObject *__pyx_pf_8rasterio_9_features_3_sieve(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_image, PyObject *__pyx_v_size, PyObject *__pyx_v_out, PyObject *__pyx_v_mask, PyObject *__pyx_v_connectivity) {
5123   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve *__pyx_cur_scope;
5124   struct __pyx_obj_8rasterio_3_io_InMemoryRaster *__pyx_v_in_mem_ds = 0;
5125   struct __pyx_obj_8rasterio_3_io_InMemoryRaster *__pyx_v_out_mem_ds = 0;
5126   struct __pyx_obj_8rasterio_3_io_InMemoryRaster *__pyx_v_mask_mem_ds = 0;
5127   GDALRasterBandH __pyx_v_in_band;
5128   GDALRasterBandH __pyx_v_out_band;
5129   GDALRasterBandH __pyx_v_mask_band;
5130   PyObject *__pyx_v_valid_types_str = NULL;
5131   PyObject *__pyx_v_rdr = NULL;
5132   PyObject *__pyx_v_udr = NULL;
5133   PyObject *__pyx_v_mask_reader = NULL;
5134   PyObject *__pyx_r = NULL;
5135   __Pyx_RefNannyDeclarations
5136   PyObject *__pyx_t_1 = NULL;
5137   PyObject *__pyx_t_2 = NULL;
5138   PyObject *__pyx_t_3 = NULL;
5139   PyObject *__pyx_t_4 = NULL;
5140   int __pyx_t_5;
5141   int __pyx_t_6;
5142   PyObject *__pyx_t_7 = NULL;
5143   PyObject *__pyx_t_8 = NULL;
5144   PyObject *__pyx_t_9 = NULL;
5145   PyObject *__pyx_t_10 = NULL;
5146   GDALRasterBandH __pyx_t_11;
5147   int __pyx_t_12;
5148   GDALRasterBandH __pyx_t_13;
5149   int __pyx_t_14;
5150   char const *__pyx_t_15;
5151   PyObject *__pyx_t_16 = NULL;
5152   PyObject *__pyx_t_17 = NULL;
5153   PyObject *__pyx_t_18 = NULL;
5154   int __pyx_lineno = 0;
5155   const char *__pyx_filename = NULL;
5156   int __pyx_clineno = 0;
5157   __Pyx_RefNannySetupContext("_sieve", 0);
5158   __pyx_cur_scope = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve *)__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_1__sieve(__pyx_ptype_8rasterio_9_features___pyx_scope_struct_1__sieve, __pyx_empty_tuple, NULL);
5159   if (unlikely(!__pyx_cur_scope)) {
5160     __pyx_cur_scope = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve *)Py_None);
5161     __Pyx_INCREF(Py_None);
5162     __PYX_ERR(0, 154, __pyx_L1_error)
5163   } else {
5164     __Pyx_GOTREF(__pyx_cur_scope);
5165   }
5166 
5167   /* "rasterio/_features.pyx":179
5168  *     cdef int rows
5169  *     cdef int cols
5170  *     cdef InMemoryRaster in_mem_ds = None             # <<<<<<<<<<<<<<
5171  *     cdef InMemoryRaster out_mem_ds = None
5172  *     cdef InMemoryRaster mask_mem_ds = None
5173  */
5174   __Pyx_INCREF(Py_None);
5175   __pyx_v_in_mem_ds = ((struct __pyx_obj_8rasterio_3_io_InMemoryRaster *)Py_None);
5176 
5177   /* "rasterio/_features.pyx":180
5178  *     cdef int cols
5179  *     cdef InMemoryRaster in_mem_ds = None
5180  *     cdef InMemoryRaster out_mem_ds = None             # <<<<<<<<<<<<<<
5181  *     cdef InMemoryRaster mask_mem_ds = None
5182  *     cdef GDALRasterBandH in_band = NULL
5183  */
5184   __Pyx_INCREF(Py_None);
5185   __pyx_v_out_mem_ds = ((struct __pyx_obj_8rasterio_3_io_InMemoryRaster *)Py_None);
5186 
5187   /* "rasterio/_features.pyx":181
5188  *     cdef InMemoryRaster in_mem_ds = None
5189  *     cdef InMemoryRaster out_mem_ds = None
5190  *     cdef InMemoryRaster mask_mem_ds = None             # <<<<<<<<<<<<<<
5191  *     cdef GDALRasterBandH in_band = NULL
5192  *     cdef GDALRasterBandH out_band = NULL
5193  */
5194   __Pyx_INCREF(Py_None);
5195   __pyx_v_mask_mem_ds = ((struct __pyx_obj_8rasterio_3_io_InMemoryRaster *)Py_None);
5196 
5197   /* "rasterio/_features.pyx":182
5198  *     cdef InMemoryRaster out_mem_ds = None
5199  *     cdef InMemoryRaster mask_mem_ds = None
5200  *     cdef GDALRasterBandH in_band = NULL             # <<<<<<<<<<<<<<
5201  *     cdef GDALRasterBandH out_band = NULL
5202  *     cdef GDALRasterBandH mask_band = NULL
5203  */
5204   __pyx_v_in_band = NULL;
5205 
5206   /* "rasterio/_features.pyx":183
5207  *     cdef InMemoryRaster mask_mem_ds = None
5208  *     cdef GDALRasterBandH in_band = NULL
5209  *     cdef GDALRasterBandH out_band = NULL             # <<<<<<<<<<<<<<
5210  *     cdef GDALRasterBandH mask_band = NULL
5211  *
5212  */
5213   __pyx_v_out_band = NULL;
5214 
5215   /* "rasterio/_features.pyx":184
5216  *     cdef GDALRasterBandH in_band = NULL
5217  *     cdef GDALRasterBandH out_band = NULL
5218  *     cdef GDALRasterBandH mask_band = NULL             # <<<<<<<<<<<<<<
5219  *
5220  *     valid_dtypes = ('int16', 'int32', 'uint8', 'uint16')
5221  */
5222   __pyx_v_mask_band = NULL;
5223 
5224   /* "rasterio/_features.pyx":186
5225  *     cdef GDALRasterBandH mask_band = NULL
5226  *
5227  *     valid_dtypes = ('int16', 'int32', 'uint8', 'uint16')             # <<<<<<<<<<<<<<
5228  *
5229  *     if _getnpdtype(image.dtype).name not in valid_dtypes:
5230  */
5231   __Pyx_INCREF(__pyx_tuple__12);
5232   __Pyx_GIVEREF(__pyx_tuple__12);
5233   __pyx_cur_scope->__pyx_v_valid_dtypes = __pyx_tuple__12;
5234 
5235   /* "rasterio/_features.pyx":188
5236  *     valid_dtypes = ('int16', 'int32', 'uint8', 'uint16')
5237  *
5238  *     if _getnpdtype(image.dtype).name not in valid_dtypes:             # <<<<<<<<<<<<<<
5239  *         valid_types_str = ', '.join(('rasterio.{0}'.format(t) for t
5240  *                                      in valid_dtypes))
5241  */
5242   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_getnpdtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
5243   __Pyx_GOTREF(__pyx_t_2);
5244   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 188, __pyx_L1_error)
5245   __Pyx_GOTREF(__pyx_t_3);
5246   __pyx_t_4 = NULL;
5247   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
5248     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
5249     if (likely(__pyx_t_4)) {
5250       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5251       __Pyx_INCREF(__pyx_t_4);
5252       __Pyx_INCREF(function);
5253       __Pyx_DECREF_SET(__pyx_t_2, function);
5254     }
5255   }
5256   __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
5257   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5258   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5259   if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error)
5260   __Pyx_GOTREF(__pyx_t_1);
5261   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5262   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L1_error)
5263   __Pyx_GOTREF(__pyx_t_2);
5264   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5265   __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_t_2, __pyx_cur_scope->__pyx_v_valid_dtypes, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 188, __pyx_L1_error)
5266   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5267   __pyx_t_6 = (__pyx_t_5 != 0);
5268   if (unlikely(__pyx_t_6)) {
5269 
5270     /* "rasterio/_features.pyx":189
5271  *
5272  *     if _getnpdtype(image.dtype).name not in valid_dtypes:
5273  *         valid_types_str = ', '.join(('rasterio.{0}'.format(t) for t             # <<<<<<<<<<<<<<
5274  *                                      in valid_dtypes))
5275  *         raise ValueError(
5276  */
5277     __pyx_t_2 = __pyx_pf_8rasterio_9_features_6_sieve_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error)
5278     __Pyx_GOTREF(__pyx_t_2);
5279     __pyx_t_1 = __Pyx_Generator_Next(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error)
5280     __Pyx_GOTREF(__pyx_t_1);
5281     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5282     __pyx_t_2 = PyUnicode_Join(__pyx_kp_u__3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error)
5283     __Pyx_GOTREF(__pyx_t_2);
5284     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5285     __pyx_v_valid_types_str = ((PyObject*)__pyx_t_2);
5286     __pyx_t_2 = 0;
5287 
5288     /* "rasterio/_features.pyx":192
5289  *                                      in valid_dtypes))
5290  *         raise ValueError(
5291  *             "image dtype must be one of: {0}".format(valid_types_str))             # <<<<<<<<<<<<<<
5292  *
5293  *     if size <= 0:
5294  */
5295     __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_image_dtype_must_be_one_of_0, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error)
5296     __Pyx_GOTREF(__pyx_t_1);
5297     __pyx_t_3 = NULL;
5298     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
5299       __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
5300       if (likely(__pyx_t_3)) {
5301         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
5302         __Pyx_INCREF(__pyx_t_3);
5303         __Pyx_INCREF(function);
5304         __Pyx_DECREF_SET(__pyx_t_1, function);
5305       }
5306     }
5307     __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_valid_types_str) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_valid_types_str);
5308     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5309     if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error)
5310     __Pyx_GOTREF(__pyx_t_2);
5311     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5312 
5313     /* "rasterio/_features.pyx":191
5314  *         valid_types_str = ', '.join(('rasterio.{0}'.format(t) for t
5315  *                                      in valid_dtypes))
5316  *         raise ValueError(             # <<<<<<<<<<<<<<
5317  *             "image dtype must be one of: {0}".format(valid_types_str))
5318  *
5319  */
5320     __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error)
5321     __Pyx_GOTREF(__pyx_t_1);
5322     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5323     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
5324     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5325     __PYX_ERR(0, 191, __pyx_L1_error)
5326 
5327     /* "rasterio/_features.pyx":188
5328  *     valid_dtypes = ('int16', 'int32', 'uint8', 'uint16')
5329  *
5330  *     if _getnpdtype(image.dtype).name not in valid_dtypes:             # <<<<<<<<<<<<<<
5331  *         valid_types_str = ', '.join(('rasterio.{0}'.format(t) for t
5332  *                                      in valid_dtypes))
5333  */
5334   }
5335 
5336   /* "rasterio/_features.pyx":194
5337  *             "image dtype must be one of: {0}".format(valid_types_str))
5338  *
5339  *     if size <= 0:             # <<<<<<<<<<<<<<
5340  *         raise ValueError('size must be greater than 0')
5341  *     elif type(size) == float:
5342  */
5343   __pyx_t_1 = PyObject_RichCompare(__pyx_v_size, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error)
5344   __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 194, __pyx_L1_error)
5345   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5346   if (unlikely(__pyx_t_6)) {
5347 
5348     /* "rasterio/_features.pyx":195
5349  *
5350  *     if size <= 0:
5351  *         raise ValueError('size must be greater than 0')             # <<<<<<<<<<<<<<
5352  *     elif type(size) == float:
5353  *         raise ValueError('size must be an integer number of pixels')
5354  */
5355     __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error)
5356     __Pyx_GOTREF(__pyx_t_1);
5357     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
5358     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5359     __PYX_ERR(0, 195, __pyx_L1_error)
5360 
5361     /* "rasterio/_features.pyx":194
5362  *             "image dtype must be one of: {0}".format(valid_types_str))
5363  *
5364  *     if size <= 0:             # <<<<<<<<<<<<<<
5365  *         raise ValueError('size must be greater than 0')
5366  *     elif type(size) == float:
5367  */
5368   }
5369 
5370   /* "rasterio/_features.pyx":196
5371  *     if size <= 0:
5372  *         raise ValueError('size must be greater than 0')
5373  *     elif type(size) == float:             # <<<<<<<<<<<<<<
5374  *         raise ValueError('size must be an integer number of pixels')
5375  *     elif size > (image.shape[0] * image.shape[1]):
5376  */
5377   __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_size)), ((PyObject *)(&PyFloat_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error)
5378   __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 196, __pyx_L1_error)
5379   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5380   if (unlikely(__pyx_t_6)) {
5381 
5382     /* "rasterio/_features.pyx":197
5383  *         raise ValueError('size must be greater than 0')
5384  *     elif type(size) == float:
5385  *         raise ValueError('size must be an integer number of pixels')             # <<<<<<<<<<<<<<
5386  *     elif size > (image.shape[0] * image.shape[1]):
5387  *         raise ValueError('size must be smaller than size of image')
5388  */
5389     __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error)
5390     __Pyx_GOTREF(__pyx_t_1);
5391     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
5392     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5393     __PYX_ERR(0, 197, __pyx_L1_error)
5394 
5395     /* "rasterio/_features.pyx":196
5396  *     if size <= 0:
5397  *         raise ValueError('size must be greater than 0')
5398  *     elif type(size) == float:             # <<<<<<<<<<<<<<
5399  *         raise ValueError('size must be an integer number of pixels')
5400  *     elif size > (image.shape[0] * image.shape[1]):
5401  */
5402   }
5403 
5404   /* "rasterio/_features.pyx":198
5405  *     elif type(size) == float:
5406  *         raise ValueError('size must be an integer number of pixels')
5407  *     elif size > (image.shape[0] * image.shape[1]):             # <<<<<<<<<<<<<<
5408  *         raise ValueError('size must be smaller than size of image')
5409  *
5410  */
5411   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
5412   __Pyx_GOTREF(__pyx_t_1);
5413   __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error)
5414   __Pyx_GOTREF(__pyx_t_2);
5415   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5416   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
5417   __Pyx_GOTREF(__pyx_t_1);
5418   __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
5419   __Pyx_GOTREF(__pyx_t_3);
5420   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5421   __pyx_t_1 = PyNumber_Multiply(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
5422   __Pyx_GOTREF(__pyx_t_1);
5423   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5424   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5425   __pyx_t_3 = PyObject_RichCompare(__pyx_v_size, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
5426   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5427   __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 198, __pyx_L1_error)
5428   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5429   if (unlikely(__pyx_t_6)) {
5430 
5431     /* "rasterio/_features.pyx":199
5432  *         raise ValueError('size must be an integer number of pixels')
5433  *     elif size > (image.shape[0] * image.shape[1]):
5434  *         raise ValueError('size must be smaller than size of image')             # <<<<<<<<<<<<<<
5435  *
5436  *     if connectivity not in (4, 8):
5437  */
5438     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error)
5439     __Pyx_GOTREF(__pyx_t_3);
5440     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
5441     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5442     __PYX_ERR(0, 199, __pyx_L1_error)
5443 
5444     /* "rasterio/_features.pyx":198
5445  *     elif type(size) == float:
5446  *         raise ValueError('size must be an integer number of pixels')
5447  *     elif size > (image.shape[0] * image.shape[1]):             # <<<<<<<<<<<<<<
5448  *         raise ValueError('size must be smaller than size of image')
5449  *
5450  */
5451   }
5452 
5453   /* "rasterio/_features.pyx":201
5454  *         raise ValueError('size must be smaller than size of image')
5455  *
5456  *     if connectivity not in (4, 8):             # <<<<<<<<<<<<<<
5457  *         raise ValueError('connectivity must be 4 or 8')
5458  *
5459  */
5460   __Pyx_INCREF(__pyx_v_connectivity);
5461   __pyx_t_3 = __pyx_v_connectivity;
5462   __pyx_t_1 = __Pyx_PyInt_NeObjC(__pyx_t_3, __pyx_int_4, 4, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 201, __pyx_L1_error)
5463   __Pyx_GOTREF(__pyx_t_1);
5464   __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 201, __pyx_L1_error)
5465   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5466   if (__pyx_t_5) {
5467   } else {
5468     __pyx_t_6 = __pyx_t_5;
5469     goto __pyx_L6_bool_binop_done;
5470   }
5471   __pyx_t_1 = __Pyx_PyInt_NeObjC(__pyx_t_3, __pyx_int_8, 8, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 201, __pyx_L1_error)
5472   __Pyx_GOTREF(__pyx_t_1);
5473   __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 201, __pyx_L1_error)
5474   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5475   __pyx_t_6 = __pyx_t_5;
5476   __pyx_L6_bool_binop_done:;
5477   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5478   __pyx_t_5 = (__pyx_t_6 != 0);
5479   if (unlikely(__pyx_t_5)) {
5480 
5481     /* "rasterio/_features.pyx":202
5482  *
5483  *     if connectivity not in (4, 8):
5484  *         raise ValueError('connectivity must be 4 or 8')             # <<<<<<<<<<<<<<
5485  *
5486  *     if out.shape != image.shape:
5487  */
5488     __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 202, __pyx_L1_error)
5489     __Pyx_GOTREF(__pyx_t_3);
5490     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
5491     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5492     __PYX_ERR(0, 202, __pyx_L1_error)
5493 
5494     /* "rasterio/_features.pyx":201
5495  *         raise ValueError('size must be smaller than size of image')
5496  *
5497  *     if connectivity not in (4, 8):             # <<<<<<<<<<<<<<
5498  *         raise ValueError('connectivity must be 4 or 8')
5499  *
5500  */
5501   }
5502 
5503   /* "rasterio/_features.pyx":204
5504  *         raise ValueError('connectivity must be 4 or 8')
5505  *
5506  *     if out.shape != image.shape:             # <<<<<<<<<<<<<<
5507  *         raise ValueError('out raster shape must be same as image shape')
5508  *
5509  */
5510   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
5511   __Pyx_GOTREF(__pyx_t_3);
5512   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
5513   __Pyx_GOTREF(__pyx_t_1);
5514   __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error)
5515   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5516   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5517   __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 204, __pyx_L1_error)
5518   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5519   if (unlikely(__pyx_t_5)) {
5520 
5521     /* "rasterio/_features.pyx":205
5522  *
5523  *     if out.shape != image.shape:
5524  *         raise ValueError('out raster shape must be same as image shape')             # <<<<<<<<<<<<<<
5525  *
5526  *     if _getnpdtype(image.dtype).name != _getnpdtype(out.dtype).name:
5527  */
5528     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 205, __pyx_L1_error)
5529     __Pyx_GOTREF(__pyx_t_2);
5530     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
5531     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5532     __PYX_ERR(0, 205, __pyx_L1_error)
5533 
5534     /* "rasterio/_features.pyx":204
5535  *         raise ValueError('connectivity must be 4 or 8')
5536  *
5537  *     if out.shape != image.shape:             # <<<<<<<<<<<<<<
5538  *         raise ValueError('out raster shape must be same as image shape')
5539  *
5540  */
5541   }
5542 
5543   /* "rasterio/_features.pyx":207
5544  *         raise ValueError('out raster shape must be same as image shape')
5545  *
5546  *     if _getnpdtype(image.dtype).name != _getnpdtype(out.dtype).name:             # <<<<<<<<<<<<<<
5547  *         raise ValueError('out raster must match dtype of image')
5548  *
5549  */
5550   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_getnpdtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error)
5551   __Pyx_GOTREF(__pyx_t_1);
5552   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 207, __pyx_L1_error)
5553   __Pyx_GOTREF(__pyx_t_3);
5554   __pyx_t_4 = NULL;
5555   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
5556     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
5557     if (likely(__pyx_t_4)) {
5558       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
5559       __Pyx_INCREF(__pyx_t_4);
5560       __Pyx_INCREF(function);
5561       __Pyx_DECREF_SET(__pyx_t_1, function);
5562     }
5563   }
5564   __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
5565   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5566   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5567   if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error)
5568   __Pyx_GOTREF(__pyx_t_2);
5569   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5570   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error)
5571   __Pyx_GOTREF(__pyx_t_1);
5572   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5573   __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_getnpdtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 207, __pyx_L1_error)
5574   __Pyx_GOTREF(__pyx_t_3);
5575   __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 207, __pyx_L1_error)
5576   __Pyx_GOTREF(__pyx_t_4);
5577   __pyx_t_7 = NULL;
5578   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
5579     __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
5580     if (likely(__pyx_t_7)) {
5581       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
5582       __Pyx_INCREF(__pyx_t_7);
5583       __Pyx_INCREF(function);
5584       __Pyx_DECREF_SET(__pyx_t_3, function);
5585     }
5586   }
5587   __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
5588   __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
5589   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5590   if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error)
5591   __Pyx_GOTREF(__pyx_t_2);
5592   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5593   __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 207, __pyx_L1_error)
5594   __Pyx_GOTREF(__pyx_t_3);
5595   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5596   __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error)
5597   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5598   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5599   __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 207, __pyx_L1_error)
5600   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5601   if (unlikely(__pyx_t_5)) {
5602 
5603     /* "rasterio/_features.pyx":208
5604  *
5605  *     if _getnpdtype(image.dtype).name != _getnpdtype(out.dtype).name:
5606  *         raise ValueError('out raster must match dtype of image')             # <<<<<<<<<<<<<<
5607  *
5608  *     try:
5609  */
5610     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 208, __pyx_L1_error)
5611     __Pyx_GOTREF(__pyx_t_2);
5612     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
5613     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5614     __PYX_ERR(0, 208, __pyx_L1_error)
5615 
5616     /* "rasterio/_features.pyx":207
5617  *         raise ValueError('out raster shape must be same as image shape')
5618  *
5619  *     if _getnpdtype(image.dtype).name != _getnpdtype(out.dtype).name:             # <<<<<<<<<<<<<<
5620  *         raise ValueError('out raster must match dtype of image')
5621  *
5622  */
5623   }
5624 
5625   /* "rasterio/_features.pyx":210
5626  *         raise ValueError('out raster must match dtype of image')
5627  *
5628  *     try:             # <<<<<<<<<<<<<<
5629  *
5630  *         if dtypes.is_ndarray(image):
5631  */
5632   /*try:*/ {
5633     {
5634       __Pyx_PyThreadState_declare
5635       __Pyx_PyThreadState_assign
5636       __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
5637       __Pyx_XGOTREF(__pyx_t_8);
5638       __Pyx_XGOTREF(__pyx_t_9);
5639       __Pyx_XGOTREF(__pyx_t_10);
5640       /*try:*/ {
5641 
5642         /* "rasterio/_features.pyx":212
5643  *     try:
5644  *
5645  *         if dtypes.is_ndarray(image):             # <<<<<<<<<<<<<<
5646  *             in_mem_ds = InMemoryRaster(image=image)
5647  *             in_band = in_mem_ds.band(1)
5648  */
5649         __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_dtypes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 212, __pyx_L13_error)
5650         __Pyx_GOTREF(__pyx_t_3);
5651         __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_is_ndarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L13_error)
5652         __Pyx_GOTREF(__pyx_t_1);
5653         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5654         __pyx_t_3 = NULL;
5655         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
5656           __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
5657           if (likely(__pyx_t_3)) {
5658             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
5659             __Pyx_INCREF(__pyx_t_3);
5660             __Pyx_INCREF(function);
5661             __Pyx_DECREF_SET(__pyx_t_1, function);
5662           }
5663         }
5664         __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_image) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_image);
5665         __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5666         if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L13_error)
5667         __Pyx_GOTREF(__pyx_t_2);
5668         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5669         __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 212, __pyx_L13_error)
5670         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5671         if (__pyx_t_5) {
5672 
5673           /* "rasterio/_features.pyx":213
5674  *
5675  *         if dtypes.is_ndarray(image):
5676  *             in_mem_ds = InMemoryRaster(image=image)             # <<<<<<<<<<<<<<
5677  *             in_band = in_mem_ds.band(1)
5678  *         elif isinstance(image, tuple):
5679  */
5680           __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L13_error)
5681           __Pyx_GOTREF(__pyx_t_2);
5682           if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_image, __pyx_v_image) < 0) __PYX_ERR(0, 213, __pyx_L13_error)
5683           __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8rasterio_3_io_InMemoryRaster), __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L13_error)
5684           __Pyx_GOTREF(__pyx_t_1);
5685           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5686           __Pyx_DECREF_SET(__pyx_v_in_mem_ds, ((struct __pyx_obj_8rasterio_3_io_InMemoryRaster *)__pyx_t_1));
5687           __pyx_t_1 = 0;
5688 
5689           /* "rasterio/_features.pyx":214
5690  *         if dtypes.is_ndarray(image):
5691  *             in_mem_ds = InMemoryRaster(image=image)
5692  *             in_band = in_mem_ds.band(1)             # <<<<<<<<<<<<<<
5693  *         elif isinstance(image, tuple):
5694  *             rdr = image.ds
5695  */
5696           __pyx_t_11 = ((struct __pyx_vtabstruct_8rasterio_3_io_InMemoryRaster *)__pyx_v_in_mem_ds->__pyx_vtab)->band(__pyx_v_in_mem_ds, 1); if (unlikely(__pyx_t_11 == ((GDALRasterBandH)NULL))) __PYX_ERR(0, 214, __pyx_L13_error)
5697           __pyx_v_in_band = __pyx_t_11;
5698 
5699           /* "rasterio/_features.pyx":212
5700  *     try:
5701  *
5702  *         if dtypes.is_ndarray(image):             # <<<<<<<<<<<<<<
5703  *             in_mem_ds = InMemoryRaster(image=image)
5704  *             in_band = in_mem_ds.band(1)
5705  */
5706           goto __pyx_L19;
5707         }
5708 
5709         /* "rasterio/_features.pyx":215
5710  *             in_mem_ds = InMemoryRaster(image=image)
5711  *             in_band = in_mem_ds.band(1)
5712  *         elif isinstance(image, tuple):             # <<<<<<<<<<<<<<
5713  *             rdr = image.ds
5714  *             in_band = (<DatasetReaderBase?>rdr).band(image.bidx)
5715  */
5716         __pyx_t_5 = PyTuple_Check(__pyx_v_image);
5717         __pyx_t_6 = (__pyx_t_5 != 0);
5718         if (likely(__pyx_t_6)) {
5719 
5720           /* "rasterio/_features.pyx":216
5721  *             in_band = in_mem_ds.band(1)
5722  *         elif isinstance(image, tuple):
5723  *             rdr = image.ds             # <<<<<<<<<<<<<<
5724  *             in_band = (<DatasetReaderBase?>rdr).band(image.bidx)
5725  *         else:
5726  */
5727           __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_ds); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L13_error)
5728           __Pyx_GOTREF(__pyx_t_1);
5729           __pyx_v_rdr = __pyx_t_1;
5730           __pyx_t_1 = 0;
5731 
5732           /* "rasterio/_features.pyx":217
5733  *         elif isinstance(image, tuple):
5734  *             rdr = image.ds
5735  *             in_band = (<DatasetReaderBase?>rdr).band(image.bidx)             # <<<<<<<<<<<<<<
5736  *         else:
5737  *             raise ValueError("Invalid source image")
5738  */
5739           if (!(likely(__Pyx_TypeTest(__pyx_v_rdr, __pyx_ptype_8rasterio_3_io_DatasetReaderBase)))) __PYX_ERR(0, 217, __pyx_L13_error)
5740           __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_bidx); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L13_error)
5741           __Pyx_GOTREF(__pyx_t_1);
5742           __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 217, __pyx_L13_error)
5743           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5744           __pyx_t_13 = ((struct __pyx_vtabstruct_8rasterio_3_io_DatasetReaderBase *)((struct __pyx_obj_8rasterio_3_io_DatasetReaderBase *)__pyx_v_rdr)->__pyx_base.__pyx_vtab)->__pyx_base.band(((struct __pyx_obj_8rasterio_5_base_DatasetBase *)((struct __pyx_obj_8rasterio_3_io_DatasetReaderBase *)__pyx_v_rdr)), __pyx_t_12); if (unlikely(__pyx_t_13 == ((GDALRasterBandH)NULL))) __PYX_ERR(0, 217, __pyx_L13_error)
5745           __pyx_v_in_band = __pyx_t_13;
5746 
5747           /* "rasterio/_features.pyx":215
5748  *             in_mem_ds = InMemoryRaster(image=image)
5749  *             in_band = in_mem_ds.band(1)
5750  *         elif isinstance(image, tuple):             # <<<<<<<<<<<<<<
5751  *             rdr = image.ds
5752  *             in_band = (<DatasetReaderBase?>rdr).band(image.bidx)
5753  */
5754           goto __pyx_L19;
5755         }
5756 
5757         /* "rasterio/_features.pyx":219
5758  *             in_band = (<DatasetReaderBase?>rdr).band(image.bidx)
5759  *         else:
5760  *             raise ValueError("Invalid source image")             # <<<<<<<<<<<<<<
5761  *
5762  *         if dtypes.is_ndarray(out):
5763  */
5764         /*else*/ {
5765           __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 219, __pyx_L13_error)
5766           __Pyx_GOTREF(__pyx_t_1);
5767           __Pyx_Raise(__pyx_t_1, 0, 0, 0);
5768           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5769           __PYX_ERR(0, 219, __pyx_L13_error)
5770         }
5771         __pyx_L19:;
5772 
5773         /* "rasterio/_features.pyx":221
5774  *             raise ValueError("Invalid source image")
5775  *
5776  *         if dtypes.is_ndarray(out):             # <<<<<<<<<<<<<<
5777  *             log.debug("out array: %r", out)
5778  *             out_mem_ds = InMemoryRaster(image=out)
5779  */
5780         __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_dtypes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L13_error)
5781         __Pyx_GOTREF(__pyx_t_2);
5782         __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 221, __pyx_L13_error)
5783         __Pyx_GOTREF(__pyx_t_3);
5784         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5785         __pyx_t_2 = NULL;
5786         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
5787           __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
5788           if (likely(__pyx_t_2)) {
5789             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
5790             __Pyx_INCREF(__pyx_t_2);
5791             __Pyx_INCREF(function);
5792             __Pyx_DECREF_SET(__pyx_t_3, function);
5793           }
5794         }
5795         __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_out) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_out);
5796         __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
5797         if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L13_error)
5798         __Pyx_GOTREF(__pyx_t_1);
5799         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5800         __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 221, __pyx_L13_error)
5801         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5802         if (__pyx_t_6) {
5803 
5804           /* "rasterio/_features.pyx":222
5805  *
5806  *         if dtypes.is_ndarray(out):
5807  *             log.debug("out array: %r", out)             # <<<<<<<<<<<<<<
5808  *             out_mem_ds = InMemoryRaster(image=out)
5809  *             out_band = out_mem_ds.band(1)
5810  */
5811           __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 222, __pyx_L13_error)
5812           __Pyx_GOTREF(__pyx_t_3);
5813           __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L13_error)
5814           __Pyx_GOTREF(__pyx_t_2);
5815           __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5816           __pyx_t_3 = NULL;
5817           __pyx_t_12 = 0;
5818           if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
5819             __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
5820             if (likely(__pyx_t_3)) {
5821               PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5822               __Pyx_INCREF(__pyx_t_3);
5823               __Pyx_INCREF(function);
5824               __Pyx_DECREF_SET(__pyx_t_2, function);
5825               __pyx_t_12 = 1;
5826             }
5827           }
5828           #if CYTHON_FAST_PYCALL
5829           if (PyFunction_Check(__pyx_t_2)) {
5830             PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u_out_array_r, __pyx_v_out};
5831             __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L13_error)
5832             __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5833             __Pyx_GOTREF(__pyx_t_1);
5834           } else
5835           #endif
5836           #if CYTHON_FAST_PYCCALL
5837           if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
5838             PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u_out_array_r, __pyx_v_out};
5839             __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L13_error)
5840             __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5841             __Pyx_GOTREF(__pyx_t_1);
5842           } else
5843           #endif
5844           {
5845             __pyx_t_4 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 222, __pyx_L13_error)
5846             __Pyx_GOTREF(__pyx_t_4);
5847             if (__pyx_t_3) {
5848               __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
5849             }
5850             __Pyx_INCREF(__pyx_kp_u_out_array_r);
5851             __Pyx_GIVEREF(__pyx_kp_u_out_array_r);
5852             PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_12, __pyx_kp_u_out_array_r);
5853             __Pyx_INCREF(__pyx_v_out);
5854             __Pyx_GIVEREF(__pyx_v_out);
5855             PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_12, __pyx_v_out);
5856             __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L13_error)
5857             __Pyx_GOTREF(__pyx_t_1);
5858             __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5859           }
5860           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5861           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5862 
5863           /* "rasterio/_features.pyx":223
5864  *         if dtypes.is_ndarray(out):
5865  *             log.debug("out array: %r", out)
5866  *             out_mem_ds = InMemoryRaster(image=out)             # <<<<<<<<<<<<<<
5867  *             out_band = out_mem_ds.band(1)
5868  *         elif isinstance(out, tuple):
5869  */
5870           __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 223, __pyx_L13_error)
5871           __Pyx_GOTREF(__pyx_t_1);
5872           if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_image, __pyx_v_out) < 0) __PYX_ERR(0, 223, __pyx_L13_error)
5873           __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8rasterio_3_io_InMemoryRaster), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L13_error)
5874           __Pyx_GOTREF(__pyx_t_2);
5875           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5876           __Pyx_DECREF_SET(__pyx_v_out_mem_ds, ((struct __pyx_obj_8rasterio_3_io_InMemoryRaster *)__pyx_t_2));
5877           __pyx_t_2 = 0;
5878 
5879           /* "rasterio/_features.pyx":224
5880  *             log.debug("out array: %r", out)
5881  *             out_mem_ds = InMemoryRaster(image=out)
5882  *             out_band = out_mem_ds.band(1)             # <<<<<<<<<<<<<<
5883  *         elif isinstance(out, tuple):
5884  *             udr = out.ds
5885  */
5886           __pyx_t_11 = ((struct __pyx_vtabstruct_8rasterio_3_io_InMemoryRaster *)__pyx_v_out_mem_ds->__pyx_vtab)->band(__pyx_v_out_mem_ds, 1); if (unlikely(__pyx_t_11 == ((GDALRasterBandH)NULL))) __PYX_ERR(0, 224, __pyx_L13_error)
5887           __pyx_v_out_band = __pyx_t_11;
5888 
5889           /* "rasterio/_features.pyx":221
5890  *             raise ValueError("Invalid source image")
5891  *
5892  *         if dtypes.is_ndarray(out):             # <<<<<<<<<<<<<<
5893  *             log.debug("out array: %r", out)
5894  *             out_mem_ds = InMemoryRaster(image=out)
5895  */
5896           goto __pyx_L20;
5897         }
5898 
5899         /* "rasterio/_features.pyx":225
5900  *             out_mem_ds = InMemoryRaster(image=out)
5901  *             out_band = out_mem_ds.band(1)
5902  *         elif isinstance(out, tuple):             # <<<<<<<<<<<<<<
5903  *             udr = out.ds
5904  *             out_band = (<DatasetReaderBase?>udr).band(out.bidx)
5905  */
5906         __pyx_t_6 = PyTuple_Check(__pyx_v_out);
5907         __pyx_t_5 = (__pyx_t_6 != 0);
5908         if (likely(__pyx_t_5)) {
5909 
5910           /* "rasterio/_features.pyx":226
5911  *             out_band = out_mem_ds.band(1)
5912  *         elif isinstance(out, tuple):
5913  *             udr = out.ds             # <<<<<<<<<<<<<<
5914  *             out_band = (<DatasetReaderBase?>udr).band(out.bidx)
5915  *         else:
5916  */
5917           __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_ds); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L13_error)
5918           __Pyx_GOTREF(__pyx_t_2);
5919           __pyx_v_udr = __pyx_t_2;
5920           __pyx_t_2 = 0;
5921 
5922           /* "rasterio/_features.pyx":227
5923  *         elif isinstance(out, tuple):
5924  *             udr = out.ds
5925  *             out_band = (<DatasetReaderBase?>udr).band(out.bidx)             # <<<<<<<<<<<<<<
5926  *         else:
5927  *             raise ValueError("Invalid out image")
5928  */
5929           if (!(likely(__Pyx_TypeTest(__pyx_v_udr, __pyx_ptype_8rasterio_3_io_DatasetReaderBase)))) __PYX_ERR(0, 227, __pyx_L13_error)
5930           __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_bidx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 227, __pyx_L13_error)
5931           __Pyx_GOTREF(__pyx_t_2);
5932           __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 227, __pyx_L13_error)
5933           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5934           __pyx_t_13 = ((struct __pyx_vtabstruct_8rasterio_3_io_DatasetReaderBase *)((struct __pyx_obj_8rasterio_3_io_DatasetReaderBase *)__pyx_v_udr)->__pyx_base.__pyx_vtab)->__pyx_base.band(((struct __pyx_obj_8rasterio_5_base_DatasetBase *)((struct __pyx_obj_8rasterio_3_io_DatasetReaderBase *)__pyx_v_udr)), __pyx_t_12); if (unlikely(__pyx_t_13 == ((GDALRasterBandH)NULL))) __PYX_ERR(0, 227, __pyx_L13_error)
5935           __pyx_v_out_band = __pyx_t_13;
5936 
5937           /* "rasterio/_features.pyx":225
5938  *             out_mem_ds = InMemoryRaster(image=out)
5939  *             out_band = out_mem_ds.band(1)
5940  *         elif isinstance(out, tuple):             # <<<<<<<<<<<<<<
5941  *             udr = out.ds
5942  *             out_band = (<DatasetReaderBase?>udr).band(out.bidx)
5943  */
5944           goto __pyx_L20;
5945         }
5946 
5947         /* "rasterio/_features.pyx":229
5948  *             out_band = (<DatasetReaderBase?>udr).band(out.bidx)
5949  *         else:
5950  *             raise ValueError("Invalid out image")             # <<<<<<<<<<<<<<
5951  *
5952  *         if mask is not None:
5953  */
5954         /*else*/ {
5955           __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L13_error)
5956           __Pyx_GOTREF(__pyx_t_2);
5957           __Pyx_Raise(__pyx_t_2, 0, 0, 0);
5958           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5959           __PYX_ERR(0, 229, __pyx_L13_error)
5960         }
5961         __pyx_L20:;
5962 
5963         /* "rasterio/_features.pyx":231
5964  *             raise ValueError("Invalid out image")
5965  *
5966  *         if mask is not None:             # <<<<<<<<<<<<<<
5967  *             if mask.shape != image.shape:
5968  *                 raise ValueError("Mask must have same shape as image")
5969  */
5970         __pyx_t_5 = (__pyx_v_mask != Py_None);
5971         __pyx_t_6 = (__pyx_t_5 != 0);
5972         if (__pyx_t_6) {
5973 
5974           /* "rasterio/_features.pyx":232
5975  *
5976  *         if mask is not None:
5977  *             if mask.shape != image.shape:             # <<<<<<<<<<<<<<
5978  *                 raise ValueError("Mask must have same shape as image")
5979  *
5980  */
5981           __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_mask, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 232, __pyx_L13_error)
5982           __Pyx_GOTREF(__pyx_t_2);
5983           __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 232, __pyx_L13_error)
5984           __Pyx_GOTREF(__pyx_t_1);
5985           __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 232, __pyx_L13_error)
5986           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5987           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5988           __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 232, __pyx_L13_error)
5989           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5990           if (unlikely(__pyx_t_6)) {
5991 
5992             /* "rasterio/_features.pyx":233
5993  *         if mask is not None:
5994  *             if mask.shape != image.shape:
5995  *                 raise ValueError("Mask must have same shape as image")             # <<<<<<<<<<<<<<
5996  *
5997  *             if _getnpdtype(mask.dtype) not in ('bool', 'uint8'):
5998  */
5999             __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 233, __pyx_L13_error)
6000             __Pyx_GOTREF(__pyx_t_4);
6001             __Pyx_Raise(__pyx_t_4, 0, 0, 0);
6002             __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6003             __PYX_ERR(0, 233, __pyx_L13_error)
6004 
6005             /* "rasterio/_features.pyx":232
6006  *
6007  *         if mask is not None:
6008  *             if mask.shape != image.shape:             # <<<<<<<<<<<<<<
6009  *                 raise ValueError("Mask must have same shape as image")
6010  *
6011  */
6012           }
6013 
6014           /* "rasterio/_features.pyx":235
6015  *                 raise ValueError("Mask must have same shape as image")
6016  *
6017  *             if _getnpdtype(mask.dtype) not in ('bool', 'uint8'):             # <<<<<<<<<<<<<<
6018  *                 raise ValueError("Mask must be dtype rasterio.bool_ or "
6019  *                                  "rasterio.uint8")
6020  */
6021           __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_getnpdtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L13_error)
6022           __Pyx_GOTREF(__pyx_t_1);
6023           __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_mask, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 235, __pyx_L13_error)
6024           __Pyx_GOTREF(__pyx_t_2);
6025           __pyx_t_3 = NULL;
6026           if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
6027             __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
6028             if (likely(__pyx_t_3)) {
6029               PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
6030               __Pyx_INCREF(__pyx_t_3);
6031               __Pyx_INCREF(function);
6032               __Pyx_DECREF_SET(__pyx_t_1, function);
6033             }
6034           }
6035           __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2);
6036           __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
6037           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6038           if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 235, __pyx_L13_error)
6039           __Pyx_GOTREF(__pyx_t_4);
6040           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6041           __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_n_u_bool, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 235, __pyx_L13_error)
6042           if (__pyx_t_5) {
6043           } else {
6044             __pyx_t_6 = __pyx_t_5;
6045             goto __pyx_L24_bool_binop_done;
6046           }
6047           __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_n_u_uint8, Py_NE)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 235, __pyx_L13_error)
6048           __pyx_t_6 = __pyx_t_5;
6049           __pyx_L24_bool_binop_done:;
6050           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6051           __pyx_t_5 = (__pyx_t_6 != 0);
6052           if (unlikely(__pyx_t_5)) {
6053 
6054             /* "rasterio/_features.pyx":236
6055  *
6056  *             if _getnpdtype(mask.dtype) not in ('bool', 'uint8'):
6057  *                 raise ValueError("Mask must be dtype rasterio.bool_ or "             # <<<<<<<<<<<<<<
6058  *                                  "rasterio.uint8")
6059  *
6060  */
6061             __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 236, __pyx_L13_error)
6062             __Pyx_GOTREF(__pyx_t_4);
6063             __Pyx_Raise(__pyx_t_4, 0, 0, 0);
6064             __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6065             __PYX_ERR(0, 236, __pyx_L13_error)
6066 
6067             /* "rasterio/_features.pyx":235
6068  *                 raise ValueError("Mask must have same shape as image")
6069  *
6070  *             if _getnpdtype(mask.dtype) not in ('bool', 'uint8'):             # <<<<<<<<<<<<<<
6071  *                 raise ValueError("Mask must be dtype rasterio.bool_ or "
6072  *                                  "rasterio.uint8")
6073  */
6074           }
6075 
6076           /* "rasterio/_features.pyx":239
6077  *                                  "rasterio.uint8")
6078  *
6079  *             if dtypes.is_ndarray(mask):             # <<<<<<<<<<<<<<
6080  *                 # A boolean mask must be converted to uint8 for GDAL
6081  *                 mask_mem_ds = InMemoryRaster(image=mask.astype('uint8'))
6082  */
6083           __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_dtypes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 239, __pyx_L13_error)
6084           __Pyx_GOTREF(__pyx_t_1);
6085           __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_is_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 239, __pyx_L13_error)
6086           __Pyx_GOTREF(__pyx_t_2);
6087           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6088           __pyx_t_1 = NULL;
6089           if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
6090             __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
6091             if (likely(__pyx_t_1)) {
6092               PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
6093               __Pyx_INCREF(__pyx_t_1);
6094               __Pyx_INCREF(function);
6095               __Pyx_DECREF_SET(__pyx_t_2, function);
6096             }
6097           }
6098           __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_v_mask) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_mask);
6099           __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
6100           if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 239, __pyx_L13_error)
6101           __Pyx_GOTREF(__pyx_t_4);
6102           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6103           __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 239, __pyx_L13_error)
6104           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6105           if (__pyx_t_5) {
6106 
6107             /* "rasterio/_features.pyx":241
6108  *             if dtypes.is_ndarray(mask):
6109  *                 # A boolean mask must be converted to uint8 for GDAL
6110  *                 mask_mem_ds = InMemoryRaster(image=mask.astype('uint8'))             # <<<<<<<<<<<<<<
6111  *                 mask_band = mask_mem_ds.band(1)
6112  *
6113  */
6114             __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 241, __pyx_L13_error)
6115             __Pyx_GOTREF(__pyx_t_4);
6116             __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_mask, __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 241, __pyx_L13_error)
6117             __Pyx_GOTREF(__pyx_t_1);
6118             __pyx_t_3 = NULL;
6119             if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
6120               __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
6121               if (likely(__pyx_t_3)) {
6122                 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
6123                 __Pyx_INCREF(__pyx_t_3);
6124                 __Pyx_INCREF(function);
6125                 __Pyx_DECREF_SET(__pyx_t_1, function);
6126               }
6127             }
6128             __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_n_u_uint8) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_n_u_uint8);
6129             __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
6130             if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 241, __pyx_L13_error)
6131             __Pyx_GOTREF(__pyx_t_2);
6132             __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6133             if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_image, __pyx_t_2) < 0) __PYX_ERR(0, 241, __pyx_L13_error)
6134             __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6135             __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8rasterio_3_io_InMemoryRaster), __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 241, __pyx_L13_error)
6136             __Pyx_GOTREF(__pyx_t_2);
6137             __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6138             __Pyx_DECREF_SET(__pyx_v_mask_mem_ds, ((struct __pyx_obj_8rasterio_3_io_InMemoryRaster *)__pyx_t_2));
6139             __pyx_t_2 = 0;
6140 
6141             /* "rasterio/_features.pyx":242
6142  *                 # A boolean mask must be converted to uint8 for GDAL
6143  *                 mask_mem_ds = InMemoryRaster(image=mask.astype('uint8'))
6144  *                 mask_band = mask_mem_ds.band(1)             # <<<<<<<<<<<<<<
6145  *
6146  *             elif isinstance(mask, tuple):
6147  */
6148             __pyx_t_11 = ((struct __pyx_vtabstruct_8rasterio_3_io_InMemoryRaster *)__pyx_v_mask_mem_ds->__pyx_vtab)->band(__pyx_v_mask_mem_ds, 1); if (unlikely(__pyx_t_11 == ((GDALRasterBandH)NULL))) __PYX_ERR(0, 242, __pyx_L13_error)
6149             __pyx_v_mask_band = __pyx_t_11;
6150 
6151             /* "rasterio/_features.pyx":239
6152  *                                  "rasterio.uint8")
6153  *
6154  *             if dtypes.is_ndarray(mask):             # <<<<<<<<<<<<<<
6155  *                 # A boolean mask must be converted to uint8 for GDAL
6156  *                 mask_mem_ds = InMemoryRaster(image=mask.astype('uint8'))
6157  */
6158             goto __pyx_L26;
6159           }
6160 
6161           /* "rasterio/_features.pyx":244
6162  *                 mask_band = mask_mem_ds.band(1)
6163  *
6164  *             elif isinstance(mask, tuple):             # <<<<<<<<<<<<<<
6165  *                 mask_reader = mask.ds
6166  *                 mask_band = (<DatasetReaderBase?>mask_reader).band(mask.bidx)
6167  */
6168           __pyx_t_5 = PyTuple_Check(__pyx_v_mask);
6169           __pyx_t_6 = (__pyx_t_5 != 0);
6170           if (__pyx_t_6) {
6171 
6172             /* "rasterio/_features.pyx":245
6173  *
6174  *             elif isinstance(mask, tuple):
6175  *                 mask_reader = mask.ds             # <<<<<<<<<<<<<<
6176  *                 mask_band = (<DatasetReaderBase?>mask_reader).band(mask.bidx)
6177  *
6178  */
6179             __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_mask, __pyx_n_s_ds); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 245, __pyx_L13_error)
6180             __Pyx_GOTREF(__pyx_t_2);
6181             __pyx_v_mask_reader = __pyx_t_2;
6182             __pyx_t_2 = 0;
6183 
6184             /* "rasterio/_features.pyx":246
6185  *             elif isinstance(mask, tuple):
6186  *                 mask_reader = mask.ds
6187  *                 mask_band = (<DatasetReaderBase?>mask_reader).band(mask.bidx)             # <<<<<<<<<<<<<<
6188  *
6189  *         GDALSieveFilter(in_band, mask_band, out_band, size, connectivity,
6190  */
6191             if (!(likely(__Pyx_TypeTest(__pyx_v_mask_reader, __pyx_ptype_8rasterio_3_io_DatasetReaderBase)))) __PYX_ERR(0, 246, __pyx_L13_error)
6192             __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_mask, __pyx_n_s_bidx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 246, __pyx_L13_error)
6193             __Pyx_GOTREF(__pyx_t_2);
6194             __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 246, __pyx_L13_error)
6195             __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6196             __pyx_t_13 = ((struct __pyx_vtabstruct_8rasterio_3_io_DatasetReaderBase *)((struct __pyx_obj_8rasterio_3_io_DatasetReaderBase *)__pyx_v_mask_reader)->__pyx_base.__pyx_vtab)->__pyx_base.band(((struct __pyx_obj_8rasterio_5_base_DatasetBase *)((struct __pyx_obj_8rasterio_3_io_DatasetReaderBase *)__pyx_v_mask_reader)), __pyx_t_12); if (unlikely(__pyx_t_13 == ((GDALRasterBandH)NULL))) __PYX_ERR(0, 246, __pyx_L13_error)
6197             __pyx_v_mask_band = __pyx_t_13;
6198 
6199             /* "rasterio/_features.pyx":244
6200  *                 mask_band = mask_mem_ds.band(1)
6201  *
6202  *             elif isinstance(mask, tuple):             # <<<<<<<<<<<<<<
6203  *                 mask_reader = mask.ds
6204  *                 mask_band = (<DatasetReaderBase?>mask_reader).band(mask.bidx)
6205  */
6206           }
6207           __pyx_L26:;
6208 
6209           /* "rasterio/_features.pyx":231
6210  *             raise ValueError("Invalid out image")
6211  *
6212  *         if mask is not None:             # <<<<<<<<<<<<<<
6213  *             if mask.shape != image.shape:
6214  *                 raise ValueError("Mask must have same shape as image")
6215  */
6216         }
6217 
6218         /* "rasterio/_features.pyx":248
6219  *                 mask_band = (<DatasetReaderBase?>mask_reader).band(mask.bidx)
6220  *
6221  *         GDALSieveFilter(in_band, mask_band, out_band, size, connectivity,             # <<<<<<<<<<<<<<
6222  *                               NULL, NULL, NULL)
6223  *
6224  */
6225         __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_v_size); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 248, __pyx_L13_error)
6226         __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_v_connectivity); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 248, __pyx_L13_error)
6227 
6228         /* "rasterio/_features.pyx":249
6229  *
6230  *         GDALSieveFilter(in_band, mask_band, out_band, size, connectivity,
6231  *                               NULL, NULL, NULL)             # <<<<<<<<<<<<<<
6232  *
6233  *     else:
6234  */
6235         (void)(GDALSieveFilter(__pyx_v_in_band, __pyx_v_mask_band, __pyx_v_out_band, __pyx_t_12, __pyx_t_14, NULL, NULL, NULL));
6236 
6237         /* "rasterio/_features.pyx":210
6238  *         raise ValueError('out raster must match dtype of image')
6239  *
6240  *     try:             # <<<<<<<<<<<<<<
6241  *
6242  *         if dtypes.is_ndarray(image):
6243  */
6244       }
6245 
6246       /* "rasterio/_features.pyx":253
6247  *     else:
6248  *         # Read from out_band into out
6249  *         io_auto(out, out_band, False)             # <<<<<<<<<<<<<<
6250  *
6251  *     finally:
6252  */
6253       /*else:*/ {
6254         __pyx_t_14 = __pyx_f_8rasterio_3_io_io_auto(__pyx_v_out, __pyx_v_out_band, 0, NULL); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 253, __pyx_L15_except_error)
6255       }
6256       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
6257       __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
6258       __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
6259       goto __pyx_L18_try_end;
6260       __pyx_L13_error:;
6261       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
6262       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
6263       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
6264       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
6265       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
6266       goto __pyx_L15_except_error;
6267       __pyx_L15_except_error:;
6268 
6269       /* "rasterio/_features.pyx":210
6270  *         raise ValueError('out raster must match dtype of image')
6271  *
6272  *     try:             # <<<<<<<<<<<<<<
6273  *
6274  *         if dtypes.is_ndarray(image):
6275  */
6276       __Pyx_XGIVEREF(__pyx_t_8);
6277       __Pyx_XGIVEREF(__pyx_t_9);
6278       __Pyx_XGIVEREF(__pyx_t_10);
6279       __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
6280       goto __pyx_L11_error;
6281       __pyx_L18_try_end:;
6282     }
6283   }
6284 
6285   /* "rasterio/_features.pyx":256
6286  *
6287  *     finally:
6288  *         if in_mem_ds is not None:             # <<<<<<<<<<<<<<
6289  *             in_mem_ds.close()
6290  *         if out_mem_ds is not None:
6291  */
6292   /*finally:*/ {
6293     /*normal exit:*/{
6294       __pyx_t_6 = (((PyObject *)__pyx_v_in_mem_ds) != Py_None);
6295       __pyx_t_5 = (__pyx_t_6 != 0);
6296       if (__pyx_t_5) {
6297 
6298         /* "rasterio/_features.pyx":257
6299  *     finally:
6300  *         if in_mem_ds is not None:
6301  *             in_mem_ds.close()             # <<<<<<<<<<<<<<
6302  *         if out_mem_ds is not None:
6303  *             out_mem_ds.close()
6304  */
6305         __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_in_mem_ds), __pyx_n_s_close); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 257, __pyx_L1_error)
6306         __Pyx_GOTREF(__pyx_t_4);
6307         __pyx_t_1 = NULL;
6308         if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
6309           __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
6310           if (likely(__pyx_t_1)) {
6311             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6312             __Pyx_INCREF(__pyx_t_1);
6313             __Pyx_INCREF(function);
6314             __Pyx_DECREF_SET(__pyx_t_4, function);
6315           }
6316         }
6317         __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
6318         __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
6319         if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error)
6320         __Pyx_GOTREF(__pyx_t_2);
6321         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6322         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6323 
6324         /* "rasterio/_features.pyx":256
6325  *
6326  *     finally:
6327  *         if in_mem_ds is not None:             # <<<<<<<<<<<<<<
6328  *             in_mem_ds.close()
6329  *         if out_mem_ds is not None:
6330  */
6331       }
6332 
6333       /* "rasterio/_features.pyx":258
6334  *         if in_mem_ds is not None:
6335  *             in_mem_ds.close()
6336  *         if out_mem_ds is not None:             # <<<<<<<<<<<<<<
6337  *             out_mem_ds.close()
6338  *         if mask_mem_ds is not None:
6339  */
6340       __pyx_t_5 = (((PyObject *)__pyx_v_out_mem_ds) != Py_None);
6341       __pyx_t_6 = (__pyx_t_5 != 0);
6342       if (__pyx_t_6) {
6343 
6344         /* "rasterio/_features.pyx":259
6345  *             in_mem_ds.close()
6346  *         if out_mem_ds is not None:
6347  *             out_mem_ds.close()             # <<<<<<<<<<<<<<
6348  *         if mask_mem_ds is not None:
6349  *             mask_mem_ds.close()
6350  */
6351         __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out_mem_ds), __pyx_n_s_close); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 259, __pyx_L1_error)
6352         __Pyx_GOTREF(__pyx_t_4);
6353         __pyx_t_1 = NULL;
6354         if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
6355           __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
6356           if (likely(__pyx_t_1)) {
6357             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6358             __Pyx_INCREF(__pyx_t_1);
6359             __Pyx_INCREF(function);
6360             __Pyx_DECREF_SET(__pyx_t_4, function);
6361           }
6362         }
6363         __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
6364         __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
6365         if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error)
6366         __Pyx_GOTREF(__pyx_t_2);
6367         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6368         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6369 
6370         /* "rasterio/_features.pyx":258
6371  *         if in_mem_ds is not None:
6372  *             in_mem_ds.close()
6373  *         if out_mem_ds is not None:             # <<<<<<<<<<<<<<
6374  *             out_mem_ds.close()
6375  *         if mask_mem_ds is not None:
6376  */
6377       }
6378 
6379       /* "rasterio/_features.pyx":260
6380  *         if out_mem_ds is not None:
6381  *             out_mem_ds.close()
6382  *         if mask_mem_ds is not None:             # <<<<<<<<<<<<<<
6383  *             mask_mem_ds.close()
6384  *
6385  */
6386       __pyx_t_6 = (((PyObject *)__pyx_v_mask_mem_ds) != Py_None);
6387       __pyx_t_5 = (__pyx_t_6 != 0);
6388       if (__pyx_t_5) {
6389 
6390         /* "rasterio/_features.pyx":261
6391  *             out_mem_ds.close()
6392  *         if mask_mem_ds is not None:
6393  *             mask_mem_ds.close()             # <<<<<<<<<<<<<<
6394  *
6395  *
6396  */
6397         __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mask_mem_ds), __pyx_n_s_close); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 261, __pyx_L1_error)
6398         __Pyx_GOTREF(__pyx_t_4);
6399         __pyx_t_1 = NULL;
6400         if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
6401           __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
6402           if (likely(__pyx_t_1)) {
6403             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6404             __Pyx_INCREF(__pyx_t_1);
6405             __Pyx_INCREF(function);
6406             __Pyx_DECREF_SET(__pyx_t_4, function);
6407           }
6408         }
6409         __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
6410         __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
6411         if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L1_error)
6412         __Pyx_GOTREF(__pyx_t_2);
6413         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6414         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6415 
6416         /* "rasterio/_features.pyx":260
6417  *         if out_mem_ds is not None:
6418  *             out_mem_ds.close()
6419  *         if mask_mem_ds is not None:             # <<<<<<<<<<<<<<
6420  *             mask_mem_ds.close()
6421  *
6422  */
6423       }
6424       goto __pyx_L12;
6425     }
6426     __pyx_L11_error:;
6427     /*exception exit:*/{
6428       __Pyx_PyThreadState_declare
6429       __Pyx_PyThreadState_assign
6430       __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0;
6431       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
6432       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
6433       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
6434       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
6435       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
6436       if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
6437       if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
6438       __Pyx_XGOTREF(__pyx_t_10);
6439       __Pyx_XGOTREF(__pyx_t_9);
6440       __Pyx_XGOTREF(__pyx_t_8);
6441       __Pyx_XGOTREF(__pyx_t_16);
6442       __Pyx_XGOTREF(__pyx_t_17);
6443       __Pyx_XGOTREF(__pyx_t_18);
6444       __pyx_t_14 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
6445       {
6446 
6447         /* "rasterio/_features.pyx":256
6448  *
6449  *     finally:
6450  *         if in_mem_ds is not None:             # <<<<<<<<<<<<<<
6451  *             in_mem_ds.close()
6452  *         if out_mem_ds is not None:
6453  */
6454         __pyx_t_5 = (((PyObject *)__pyx_v_in_mem_ds) != Py_None);
6455         __pyx_t_6 = (__pyx_t_5 != 0);
6456         if (__pyx_t_6) {
6457 
6458           /* "rasterio/_features.pyx":257
6459  *     finally:
6460  *         if in_mem_ds is not None:
6461  *             in_mem_ds.close()             # <<<<<<<<<<<<<<
6462  *         if out_mem_ds is not None:
6463  *             out_mem_ds.close()
6464  */
6465           __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_in_mem_ds), __pyx_n_s_close); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 257, __pyx_L31_error)
6466           __Pyx_GOTREF(__pyx_t_4);
6467           __pyx_t_1 = NULL;
6468           if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
6469             __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
6470             if (likely(__pyx_t_1)) {
6471               PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6472               __Pyx_INCREF(__pyx_t_1);
6473               __Pyx_INCREF(function);
6474               __Pyx_DECREF_SET(__pyx_t_4, function);
6475             }
6476           }
6477           __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
6478           __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
6479           if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L31_error)
6480           __Pyx_GOTREF(__pyx_t_2);
6481           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6482           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6483 
6484           /* "rasterio/_features.pyx":256
6485  *
6486  *     finally:
6487  *         if in_mem_ds is not None:             # <<<<<<<<<<<<<<
6488  *             in_mem_ds.close()
6489  *         if out_mem_ds is not None:
6490  */
6491         }
6492 
6493         /* "rasterio/_features.pyx":258
6494  *         if in_mem_ds is not None:
6495  *             in_mem_ds.close()
6496  *         if out_mem_ds is not None:             # <<<<<<<<<<<<<<
6497  *             out_mem_ds.close()
6498  *         if mask_mem_ds is not None:
6499  */
6500         __pyx_t_6 = (((PyObject *)__pyx_v_out_mem_ds) != Py_None);
6501         __pyx_t_5 = (__pyx_t_6 != 0);
6502         if (__pyx_t_5) {
6503 
6504           /* "rasterio/_features.pyx":259
6505  *             in_mem_ds.close()
6506  *         if out_mem_ds is not None:
6507  *             out_mem_ds.close()             # <<<<<<<<<<<<<<
6508  *         if mask_mem_ds is not None:
6509  *             mask_mem_ds.close()
6510  */
6511           __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_out_mem_ds), __pyx_n_s_close); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 259, __pyx_L31_error)
6512           __Pyx_GOTREF(__pyx_t_4);
6513           __pyx_t_1 = NULL;
6514           if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
6515             __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
6516             if (likely(__pyx_t_1)) {
6517               PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6518               __Pyx_INCREF(__pyx_t_1);
6519               __Pyx_INCREF(function);
6520               __Pyx_DECREF_SET(__pyx_t_4, function);
6521             }
6522           }
6523           __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
6524           __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
6525           if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L31_error)
6526           __Pyx_GOTREF(__pyx_t_2);
6527           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6528           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6529 
6530           /* "rasterio/_features.pyx":258
6531  *         if in_mem_ds is not None:
6532  *             in_mem_ds.close()
6533  *         if out_mem_ds is not None:             # <<<<<<<<<<<<<<
6534  *             out_mem_ds.close()
6535  *         if mask_mem_ds is not None:
6536  */
6537         }
6538 
6539         /* "rasterio/_features.pyx":260
6540  *         if out_mem_ds is not None:
6541  *             out_mem_ds.close()
6542  *         if mask_mem_ds is not None:             # <<<<<<<<<<<<<<
6543  *             mask_mem_ds.close()
6544  *
6545  */
6546         __pyx_t_5 = (((PyObject *)__pyx_v_mask_mem_ds) != Py_None);
6547         __pyx_t_6 = (__pyx_t_5 != 0);
6548         if (__pyx_t_6) {
6549 
6550           /* "rasterio/_features.pyx":261
6551  *             out_mem_ds.close()
6552  *         if mask_mem_ds is not None:
6553  *             mask_mem_ds.close()             # <<<<<<<<<<<<<<
6554  *
6555  *
6556  */
6557           __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mask_mem_ds), __pyx_n_s_close); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 261, __pyx_L31_error)
6558           __Pyx_GOTREF(__pyx_t_4);
6559           __pyx_t_1 = NULL;
6560           if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
6561             __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
6562             if (likely(__pyx_t_1)) {
6563               PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6564               __Pyx_INCREF(__pyx_t_1);
6565               __Pyx_INCREF(function);
6566               __Pyx_DECREF_SET(__pyx_t_4, function);
6567             }
6568           }
6569           __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
6570           __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
6571           if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 261, __pyx_L31_error)
6572           __Pyx_GOTREF(__pyx_t_2);
6573           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6574           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6575 
6576           /* "rasterio/_features.pyx":260
6577  *         if out_mem_ds is not None:
6578  *             out_mem_ds.close()
6579  *         if mask_mem_ds is not None:             # <<<<<<<<<<<<<<
6580  *             mask_mem_ds.close()
6581  *
6582  */
6583         }
6584       }
6585       if (PY_MAJOR_VERSION >= 3) {
6586         __Pyx_XGIVEREF(__pyx_t_16);
6587         __Pyx_XGIVEREF(__pyx_t_17);
6588         __Pyx_XGIVEREF(__pyx_t_18);
6589         __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
6590       }
6591       __Pyx_XGIVEREF(__pyx_t_10);
6592       __Pyx_XGIVEREF(__pyx_t_9);
6593       __Pyx_XGIVEREF(__pyx_t_8);
6594       __Pyx_ErrRestore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
6595       __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0;
6596       __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_15;
6597       goto __pyx_L1_error;
6598       __pyx_L31_error:;
6599       if (PY_MAJOR_VERSION >= 3) {
6600         __Pyx_XGIVEREF(__pyx_t_16);
6601         __Pyx_XGIVEREF(__pyx_t_17);
6602         __Pyx_XGIVEREF(__pyx_t_18);
6603         __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
6604       }
6605       __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
6606       __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
6607       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
6608       __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0;
6609       goto __pyx_L1_error;
6610     }
6611     __pyx_L12:;
6612   }
6613 
6614   /* "rasterio/_features.pyx":154
6615  *
6616  *
6617  * def _sieve(image, size, out, mask, connectivity):             # <<<<<<<<<<<<<<
6618  *     """
6619  *     Replaces small polygons in `image` with the value of their largest
6620  */
6621 
6622   /* function exit code */
6623   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6624   goto __pyx_L0;
6625   __pyx_L1_error:;
6626   __Pyx_XDECREF(__pyx_t_1);
6627   __Pyx_XDECREF(__pyx_t_2);
6628   __Pyx_XDECREF(__pyx_t_3);
6629   __Pyx_XDECREF(__pyx_t_4);
6630   __Pyx_XDECREF(__pyx_t_7);
6631   __Pyx_AddTraceback("rasterio._features._sieve", __pyx_clineno, __pyx_lineno, __pyx_filename);
6632   __pyx_r = NULL;
6633   __pyx_L0:;
6634   __Pyx_XDECREF((PyObject *)__pyx_v_in_mem_ds);
6635   __Pyx_XDECREF((PyObject *)__pyx_v_out_mem_ds);
6636   __Pyx_XDECREF((PyObject *)__pyx_v_mask_mem_ds);
6637   __Pyx_XDECREF(__pyx_v_valid_types_str);
6638   __Pyx_XDECREF(__pyx_v_rdr);
6639   __Pyx_XDECREF(__pyx_v_udr);
6640   __Pyx_XDECREF(__pyx_v_mask_reader);
6641   __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
6642   __Pyx_XGIVEREF(__pyx_r);
6643   __Pyx_RefNannyFinishContext();
6644   return __pyx_r;
6645 }
6646 
6647 /* "rasterio/_features.pyx":264
6648  *
6649  *
6650  * def _rasterize(shapes, image, transform, all_touched, merge_alg):             # <<<<<<<<<<<<<<
6651  *     """
6652  *     Burns input geometries into `image`.
6653  */
6654 
6655 /* Python wrapper */
6656 static PyObject *__pyx_pw_8rasterio_9_features_6_rasterize(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6657 static char __pyx_doc_8rasterio_9_features_5_rasterize[] = "\n    Burns input geometries into `image`.\n\n    The `image` array is modified in place.\n\n    Parameters\n    ----------\n    shapes : iterable of (geometry, value) pairs\n        `geometry` is a GeoJSON-like object.\n    image : numpy ndarray\n        Array in which to store results.\n    transform : Affine transformation object, optional\n        Transformation from pixel coordinates of `image` to the\n        coordinate system of the input `shapes`. See the `transform`\n        property of dataset objects.\n    all_touched : boolean, optional\n        If True, all pixels touched by geometries will be burned in. If\n        false, only pixels whose center is within the polygon or that\n        are selected by Bresenham's line algorithm will be burned in.\n    merge_alg : MergeAlg, required\n        Merge algorithm to use.  One of:\n            MergeAlg.replace (default):\n                the new value will overwrite the existing value.\n            MergeAlg.add:\n                the new value will be added to the existing raster.\n\n    Returns\n    -------\n    None\n\n    Notes\n    -----\n    This function uses significant memory resources.\n    GDALRasterizeGeometries does the bulk of the work and requires a\n    working buffer. The size of this buffer is the smaller of the\n    `image` data or GDAL's maximum cache size.  That latter value is 5%\n    of a computer's physical RAM unless otherwise specified using the\n    GDAL_CACHEMAX configuration option. Additionally, this function uses\n    a temporary in-memory dataset containing a copy of the input `image`\n    data and an array of OGRGeometryH structs. The size of that array is\n    approximately equal to the size of all objects in `shapes`. Note\n    that the `shapes` iterator is also materialized to a list within\n    this function.\n\n    If the working buffer is smaller than the `image` data, the array of\n    shapes will be iterated multiple times. Performance is thus a linear\n    function of the"" buffer size. For maximum speed, ensure that\n    GDAL_CACHEMAX is larger than the size of the input `image`.\n\n    The minimum memory requirement of this function is approximately\n    equal to 2x the `image` data size plus 2x the smaller of the the\n    `image` data and GDAL max cache size, plus 2x the size of the\n    objects in `shapes`.\n\n    ";
6658 static PyMethodDef __pyx_mdef_8rasterio_9_features_6_rasterize = {"_rasterize", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8rasterio_9_features_6_rasterize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8rasterio_9_features_5_rasterize};
__pyx_pw_8rasterio_9_features_6_rasterize(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)6659 static PyObject *__pyx_pw_8rasterio_9_features_6_rasterize(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6660   PyObject *__pyx_v_shapes = 0;
6661   PyObject *__pyx_v_image = 0;
6662   PyObject *__pyx_v_transform = 0;
6663   PyObject *__pyx_v_all_touched = 0;
6664   PyObject *__pyx_v_merge_alg = 0;
6665   int __pyx_lineno = 0;
6666   const char *__pyx_filename = NULL;
6667   int __pyx_clineno = 0;
6668   PyObject *__pyx_r = 0;
6669   __Pyx_RefNannyDeclarations
6670   __Pyx_RefNannySetupContext("_rasterize (wrapper)", 0);
6671   {
6672     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shapes_2,&__pyx_n_s_image,&__pyx_n_s_transform,&__pyx_n_s_all_touched,&__pyx_n_s_merge_alg,0};
6673     PyObject* values[5] = {0,0,0,0,0};
6674     if (unlikely(__pyx_kwds)) {
6675       Py_ssize_t kw_args;
6676       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6677       switch (pos_args) {
6678         case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
6679         CYTHON_FALLTHROUGH;
6680         case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6681         CYTHON_FALLTHROUGH;
6682         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6683         CYTHON_FALLTHROUGH;
6684         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6685         CYTHON_FALLTHROUGH;
6686         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6687         CYTHON_FALLTHROUGH;
6688         case  0: break;
6689         default: goto __pyx_L5_argtuple_error;
6690       }
6691       kw_args = PyDict_Size(__pyx_kwds);
6692       switch (pos_args) {
6693         case  0:
6694         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shapes_2)) != 0)) kw_args--;
6695         else goto __pyx_L5_argtuple_error;
6696         CYTHON_FALLTHROUGH;
6697         case  1:
6698         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_image)) != 0)) kw_args--;
6699         else {
6700           __Pyx_RaiseArgtupleInvalid("_rasterize", 1, 5, 5, 1); __PYX_ERR(0, 264, __pyx_L3_error)
6701         }
6702         CYTHON_FALLTHROUGH;
6703         case  2:
6704         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_transform)) != 0)) kw_args--;
6705         else {
6706           __Pyx_RaiseArgtupleInvalid("_rasterize", 1, 5, 5, 2); __PYX_ERR(0, 264, __pyx_L3_error)
6707         }
6708         CYTHON_FALLTHROUGH;
6709         case  3:
6710         if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_all_touched)) != 0)) kw_args--;
6711         else {
6712           __Pyx_RaiseArgtupleInvalid("_rasterize", 1, 5, 5, 3); __PYX_ERR(0, 264, __pyx_L3_error)
6713         }
6714         CYTHON_FALLTHROUGH;
6715         case  4:
6716         if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_merge_alg)) != 0)) kw_args--;
6717         else {
6718           __Pyx_RaiseArgtupleInvalid("_rasterize", 1, 5, 5, 4); __PYX_ERR(0, 264, __pyx_L3_error)
6719         }
6720       }
6721       if (unlikely(kw_args > 0)) {
6722         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_rasterize") < 0)) __PYX_ERR(0, 264, __pyx_L3_error)
6723       }
6724     } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
6725       goto __pyx_L5_argtuple_error;
6726     } else {
6727       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6728       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6729       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6730       values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
6731       values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
6732     }
6733     __pyx_v_shapes = values[0];
6734     __pyx_v_image = values[1];
6735     __pyx_v_transform = values[2];
6736     __pyx_v_all_touched = values[3];
6737     __pyx_v_merge_alg = values[4];
6738   }
6739   goto __pyx_L4_argument_unpacking_done;
6740   __pyx_L5_argtuple_error:;
6741   __Pyx_RaiseArgtupleInvalid("_rasterize", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 264, __pyx_L3_error)
6742   __pyx_L3_error:;
6743   __Pyx_AddTraceback("rasterio._features._rasterize", __pyx_clineno, __pyx_lineno, __pyx_filename);
6744   __Pyx_RefNannyFinishContext();
6745   return NULL;
6746   __pyx_L4_argument_unpacking_done:;
6747   __pyx_r = __pyx_pf_8rasterio_9_features_5_rasterize(__pyx_self, __pyx_v_shapes, __pyx_v_image, __pyx_v_transform, __pyx_v_all_touched, __pyx_v_merge_alg);
6748 
6749   /* function exit code */
6750   __Pyx_RefNannyFinishContext();
6751   return __pyx_r;
6752 }
6753 
__pyx_pf_8rasterio_9_features_5_rasterize(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_shapes,PyObject * __pyx_v_image,PyObject * __pyx_v_transform,PyObject * __pyx_v_all_touched,PyObject * __pyx_v_merge_alg)6754 static PyObject *__pyx_pf_8rasterio_9_features_5_rasterize(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_shapes, PyObject *__pyx_v_image, PyObject *__pyx_v_transform, PyObject *__pyx_v_all_touched, PyObject *__pyx_v_merge_alg) {
6755   size_t __pyx_v_i;
6756   size_t __pyx_v_num_geoms;
6757   OGRGeometryH *__pyx_v_geoms;
6758   char **__pyx_v_options;
6759   double *__pyx_v_pixel_values;
6760   struct __pyx_obj_8rasterio_3_io_InMemoryRaster *__pyx_v_mem = 0;
6761   PyObject *__pyx_v_merge_algorithm = NULL;
6762   PyObject *__pyx_v_all_shapes = NULL;
6763   PyObject *__pyx_v_geometry = NULL;
6764   PyObject *__pyx_v_value = NULL;
6765   PyObject *__pyx_r = NULL;
6766   __Pyx_RefNannyDeclarations
6767   int __pyx_t_1;
6768   PyObject *__pyx_t_2 = NULL;
6769   PyObject *__pyx_t_3 = NULL;
6770   PyObject *__pyx_t_4 = NULL;
6771   char *__pyx_t_5;
6772   Py_ssize_t __pyx_t_6;
6773   size_t __pyx_t_7;
6774   PyObject *__pyx_t_8 = NULL;
6775   PyObject *__pyx_t_9 = NULL;
6776   PyObject *(*__pyx_t_10)(PyObject *);
6777   PyObject *__pyx_t_11 = NULL;
6778   PyObject *__pyx_t_12 = NULL;
6779   PyObject *__pyx_t_13 = NULL;
6780   OGRGeometryH __pyx_t_14;
6781   double __pyx_t_15;
6782   PyObject *__pyx_t_16 = NULL;
6783   PyObject *__pyx_t_17 = NULL;
6784   PyObject *__pyx_t_18 = NULL;
6785   int __pyx_t_19;
6786   PyObject *__pyx_t_20 = NULL;
6787   PyObject *__pyx_t_21 = NULL;
6788   GDALDatasetH __pyx_t_22;
6789   PyObject *__pyx_t_23 = NULL;
6790   int __pyx_t_24;
6791   size_t __pyx_t_25;
6792   size_t __pyx_t_26;
6793   int __pyx_t_27;
6794   char const *__pyx_t_28;
6795   PyObject *__pyx_t_29 = NULL;
6796   int __pyx_lineno = 0;
6797   const char *__pyx_filename = NULL;
6798   int __pyx_clineno = 0;
6799   __Pyx_RefNannySetupContext("_rasterize", 0);
6800   __Pyx_INCREF(__pyx_v_image);
6801 
6802   /* "rasterio/_features.pyx":322
6803  *     cdef int retval
6804  *     cdef size_t i
6805  *     cdef size_t num_geoms = 0             # <<<<<<<<<<<<<<
6806  *     cdef OGRGeometryH *geoms = NULL
6807  *     cdef char **options = NULL
6808  */
6809   __pyx_v_num_geoms = 0;
6810 
6811   /* "rasterio/_features.pyx":323
6812  *     cdef size_t i
6813  *     cdef size_t num_geoms = 0
6814  *     cdef OGRGeometryH *geoms = NULL             # <<<<<<<<<<<<<<
6815  *     cdef char **options = NULL
6816  *     cdef double *pixel_values = NULL
6817  */
6818   __pyx_v_geoms = NULL;
6819 
6820   /* "rasterio/_features.pyx":324
6821  *     cdef size_t num_geoms = 0
6822  *     cdef OGRGeometryH *geoms = NULL
6823  *     cdef char **options = NULL             # <<<<<<<<<<<<<<
6824  *     cdef double *pixel_values = NULL
6825  *     cdef InMemoryRaster mem = None
6826  */
6827   __pyx_v_options = NULL;
6828 
6829   /* "rasterio/_features.pyx":325
6830  *     cdef OGRGeometryH *geoms = NULL
6831  *     cdef char **options = NULL
6832  *     cdef double *pixel_values = NULL             # <<<<<<<<<<<<<<
6833  *     cdef InMemoryRaster mem = None
6834  *
6835  */
6836   __pyx_v_pixel_values = NULL;
6837 
6838   /* "rasterio/_features.pyx":326
6839  *     cdef char **options = NULL
6840  *     cdef double *pixel_values = NULL
6841  *     cdef InMemoryRaster mem = None             # <<<<<<<<<<<<<<
6842  *
6843  *     try:
6844  */
6845   __Pyx_INCREF(Py_None);
6846   __pyx_v_mem = ((struct __pyx_obj_8rasterio_3_io_InMemoryRaster *)Py_None);
6847 
6848   /* "rasterio/_features.pyx":328
6849  *     cdef InMemoryRaster mem = None
6850  *
6851  *     try:             # <<<<<<<<<<<<<<
6852  *         if all_touched:
6853  *             options = CSLSetNameValue(options, "ALL_TOUCHED", "TRUE")
6854  */
6855   /*try:*/ {
6856 
6857     /* "rasterio/_features.pyx":329
6858  *
6859  *     try:
6860  *         if all_touched:             # <<<<<<<<<<<<<<
6861  *             options = CSLSetNameValue(options, "ALL_TOUCHED", "TRUE")
6862  *         merge_algorithm = merge_alg.value.encode('utf-8')
6863  */
6864     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_all_touched); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 329, __pyx_L4_error)
6865     if (__pyx_t_1) {
6866 
6867       /* "rasterio/_features.pyx":330
6868  *     try:
6869  *         if all_touched:
6870  *             options = CSLSetNameValue(options, "ALL_TOUCHED", "TRUE")             # <<<<<<<<<<<<<<
6871  *         merge_algorithm = merge_alg.value.encode('utf-8')
6872  *         options = CSLSetNameValue(options, "MERGE_ALG", merge_algorithm)
6873  */
6874       __pyx_v_options = CSLSetNameValue(__pyx_v_options, ((char *)"ALL_TOUCHED"), ((char *)"TRUE"));
6875 
6876       /* "rasterio/_features.pyx":329
6877  *
6878  *     try:
6879  *         if all_touched:             # <<<<<<<<<<<<<<
6880  *             options = CSLSetNameValue(options, "ALL_TOUCHED", "TRUE")
6881  *         merge_algorithm = merge_alg.value.encode('utf-8')
6882  */
6883     }
6884 
6885     /* "rasterio/_features.pyx":331
6886  *         if all_touched:
6887  *             options = CSLSetNameValue(options, "ALL_TOUCHED", "TRUE")
6888  *         merge_algorithm = merge_alg.value.encode('utf-8')             # <<<<<<<<<<<<<<
6889  *         options = CSLSetNameValue(options, "MERGE_ALG", merge_algorithm)
6890  *
6891  */
6892     __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_merge_alg, __pyx_n_s_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 331, __pyx_L4_error)
6893     __Pyx_GOTREF(__pyx_t_3);
6894     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 331, __pyx_L4_error)
6895     __Pyx_GOTREF(__pyx_t_4);
6896     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6897     __pyx_t_3 = NULL;
6898     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
6899       __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
6900       if (likely(__pyx_t_3)) {
6901         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6902         __Pyx_INCREF(__pyx_t_3);
6903         __Pyx_INCREF(function);
6904         __Pyx_DECREF_SET(__pyx_t_4, function);
6905       }
6906     }
6907     __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_kp_u_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_utf_8);
6908     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
6909     if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L4_error)
6910     __Pyx_GOTREF(__pyx_t_2);
6911     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6912     __pyx_v_merge_algorithm = __pyx_t_2;
6913     __pyx_t_2 = 0;
6914 
6915     /* "rasterio/_features.pyx":332
6916  *             options = CSLSetNameValue(options, "ALL_TOUCHED", "TRUE")
6917  *         merge_algorithm = merge_alg.value.encode('utf-8')
6918  *         options = CSLSetNameValue(options, "MERGE_ALG", merge_algorithm)             # <<<<<<<<<<<<<<
6919  *
6920  *         # GDAL needs an array of geometries.
6921  */
6922     __pyx_t_5 = __Pyx_PyObject_AsWritableString(__pyx_v_merge_algorithm); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 332, __pyx_L4_error)
6923     __pyx_v_options = CSLSetNameValue(__pyx_v_options, ((char *)"MERGE_ALG"), __pyx_t_5);
6924 
6925     /* "rasterio/_features.pyx":337
6926  *         # For now, we'll build a Python list on the way to building that
6927  *         # C array. TODO: make this more efficient.
6928  *         all_shapes = list(shapes)             # <<<<<<<<<<<<<<
6929  *         num_geoms = len(all_shapes)
6930  *
6931  */
6932     __pyx_t_2 = PySequence_List(__pyx_v_shapes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L4_error)
6933     __Pyx_GOTREF(__pyx_t_2);
6934     __pyx_v_all_shapes = ((PyObject*)__pyx_t_2);
6935     __pyx_t_2 = 0;
6936 
6937     /* "rasterio/_features.pyx":338
6938  *         # C array. TODO: make this more efficient.
6939  *         all_shapes = list(shapes)
6940  *         num_geoms = len(all_shapes)             # <<<<<<<<<<<<<<
6941  *
6942  *         geoms = <OGRGeometryH *>CPLMalloc(
6943  */
6944     __pyx_t_6 = PyList_GET_SIZE(__pyx_v_all_shapes); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 338, __pyx_L4_error)
6945     __pyx_v_num_geoms = __pyx_t_6;
6946 
6947     /* "rasterio/_features.pyx":340
6948  *         num_geoms = len(all_shapes)
6949  *
6950  *         geoms = <OGRGeometryH *>CPLMalloc(             # <<<<<<<<<<<<<<
6951  *             num_geoms * sizeof(OGRGeometryH))
6952  *         pixel_values = <double *>CPLMalloc(num_geoms * sizeof(double))
6953  */
6954     __pyx_v_geoms = ((OGRGeometryH *)CPLMalloc((__pyx_v_num_geoms * (sizeof(OGRGeometryH)))));
6955 
6956     /* "rasterio/_features.pyx":342
6957  *         geoms = <OGRGeometryH *>CPLMalloc(
6958  *             num_geoms * sizeof(OGRGeometryH))
6959  *         pixel_values = <double *>CPLMalloc(num_geoms * sizeof(double))             # <<<<<<<<<<<<<<
6960  *
6961  *         for i, (geometry, value) in enumerate(all_shapes):
6962  */
6963     __pyx_v_pixel_values = ((double *)CPLMalloc((__pyx_v_num_geoms * (sizeof(double)))));
6964 
6965     /* "rasterio/_features.pyx":344
6966  *         pixel_values = <double *>CPLMalloc(num_geoms * sizeof(double))
6967  *
6968  *         for i, (geometry, value) in enumerate(all_shapes):             # <<<<<<<<<<<<<<
6969  *             try:
6970  *                 geoms[i] = OGRGeomBuilder().build(geometry)
6971  */
6972     __pyx_t_7 = 0;
6973     __pyx_t_2 = __pyx_v_all_shapes; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
6974     for (;;) {
6975       if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
6976       #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6977       __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 344, __pyx_L4_error)
6978       #else
6979       __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 344, __pyx_L4_error)
6980       __Pyx_GOTREF(__pyx_t_4);
6981       #endif
6982       if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
6983         PyObject* sequence = __pyx_t_4;
6984         Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
6985         if (unlikely(size != 2)) {
6986           if (size > 2) __Pyx_RaiseTooManyValuesError(2);
6987           else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
6988           __PYX_ERR(0, 344, __pyx_L4_error)
6989         }
6990         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6991         if (likely(PyTuple_CheckExact(sequence))) {
6992           __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
6993           __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1);
6994         } else {
6995           __pyx_t_3 = PyList_GET_ITEM(sequence, 0);
6996           __pyx_t_8 = PyList_GET_ITEM(sequence, 1);
6997         }
6998         __Pyx_INCREF(__pyx_t_3);
6999         __Pyx_INCREF(__pyx_t_8);
7000         #else
7001         __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 344, __pyx_L4_error)
7002         __Pyx_GOTREF(__pyx_t_3);
7003         __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 344, __pyx_L4_error)
7004         __Pyx_GOTREF(__pyx_t_8);
7005         #endif
7006         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7007       } else {
7008         Py_ssize_t index = -1;
7009         __pyx_t_9 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 344, __pyx_L4_error)
7010         __Pyx_GOTREF(__pyx_t_9);
7011         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7012         __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
7013         index = 0; __pyx_t_3 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_3)) goto __pyx_L9_unpacking_failed;
7014         __Pyx_GOTREF(__pyx_t_3);
7015         index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L9_unpacking_failed;
7016         __Pyx_GOTREF(__pyx_t_8);
7017         if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 344, __pyx_L4_error)
7018         __pyx_t_10 = NULL;
7019         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
7020         goto __pyx_L10_unpacking_done;
7021         __pyx_L9_unpacking_failed:;
7022         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
7023         __pyx_t_10 = NULL;
7024         if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
7025         __PYX_ERR(0, 344, __pyx_L4_error)
7026         __pyx_L10_unpacking_done:;
7027       }
7028       __Pyx_XDECREF_SET(__pyx_v_geometry, __pyx_t_3);
7029       __pyx_t_3 = 0;
7030       __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_8);
7031       __pyx_t_8 = 0;
7032       __pyx_v_i = __pyx_t_7;
7033       __pyx_t_7 = (__pyx_t_7 + 1);
7034 
7035       /* "rasterio/_features.pyx":345
7036  *
7037  *         for i, (geometry, value) in enumerate(all_shapes):
7038  *             try:             # <<<<<<<<<<<<<<
7039  *                 geoms[i] = OGRGeomBuilder().build(geometry)
7040  *                 pixel_values[i] = <double>value
7041  */
7042       {
7043         __Pyx_PyThreadState_declare
7044         __Pyx_PyThreadState_assign
7045         __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
7046         __Pyx_XGOTREF(__pyx_t_11);
7047         __Pyx_XGOTREF(__pyx_t_12);
7048         __Pyx_XGOTREF(__pyx_t_13);
7049         /*try:*/ {
7050 
7051           /* "rasterio/_features.pyx":346
7052  *         for i, (geometry, value) in enumerate(all_shapes):
7053  *             try:
7054  *                 geoms[i] = OGRGeomBuilder().build(geometry)             # <<<<<<<<<<<<<<
7055  *                 pixel_values[i] = <double>value
7056  *             except:
7057  */
7058           __pyx_t_4 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_8rasterio_9_features_OGRGeomBuilder)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 346, __pyx_L11_error)
7059           __Pyx_GOTREF(__pyx_t_4);
7060           __pyx_t_14 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)((struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *)__pyx_t_4)->__pyx_vtab)->build(((struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *)__pyx_t_4), __pyx_v_geometry); if (unlikely(__pyx_t_14 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 346, __pyx_L11_error)
7061           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7062           (__pyx_v_geoms[__pyx_v_i]) = __pyx_t_14;
7063 
7064           /* "rasterio/_features.pyx":347
7065  *             try:
7066  *                 geoms[i] = OGRGeomBuilder().build(geometry)
7067  *                 pixel_values[i] = <double>value             # <<<<<<<<<<<<<<
7068  *             except:
7069  *                 log.error("Geometry %r at index %d with value %d skipped",
7070  */
7071           __pyx_t_15 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_15 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 347, __pyx_L11_error)
7072           (__pyx_v_pixel_values[__pyx_v_i]) = ((double)__pyx_t_15);
7073 
7074           /* "rasterio/_features.pyx":345
7075  *
7076  *         for i, (geometry, value) in enumerate(all_shapes):
7077  *             try:             # <<<<<<<<<<<<<<
7078  *                 geoms[i] = OGRGeomBuilder().build(geometry)
7079  *                 pixel_values[i] = <double>value
7080  */
7081         }
7082         __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
7083         __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
7084         __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
7085         goto __pyx_L18_try_end;
7086         __pyx_L11_error:;
7087         __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7088         __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7089         __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
7090         __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
7091 
7092         /* "rasterio/_features.pyx":348
7093  *                 geoms[i] = OGRGeomBuilder().build(geometry)
7094  *                 pixel_values[i] = <double>value
7095  *             except:             # <<<<<<<<<<<<<<
7096  *                 log.error("Geometry %r at index %d with value %d skipped",
7097  *                     geometry, i, value)
7098  */
7099         /*except:*/ {
7100           __Pyx_AddTraceback("rasterio._features._rasterize", __pyx_clineno, __pyx_lineno, __pyx_filename);
7101           if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_8, &__pyx_t_3) < 0) __PYX_ERR(0, 348, __pyx_L13_except_error)
7102           __Pyx_GOTREF(__pyx_t_4);
7103           __Pyx_GOTREF(__pyx_t_8);
7104           __Pyx_GOTREF(__pyx_t_3);
7105 
7106           /* "rasterio/_features.pyx":349
7107  *                 pixel_values[i] = <double>value
7108  *             except:
7109  *                 log.error("Geometry %r at index %d with value %d skipped",             # <<<<<<<<<<<<<<
7110  *                     geometry, i, value)
7111  *
7112  */
7113           __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_log); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 349, __pyx_L13_except_error)
7114           __Pyx_GOTREF(__pyx_t_16);
7115           __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_error); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 349, __pyx_L13_except_error)
7116           __Pyx_GOTREF(__pyx_t_17);
7117           __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
7118 
7119           /* "rasterio/_features.pyx":350
7120  *             except:
7121  *                 log.error("Geometry %r at index %d with value %d skipped",
7122  *                     geometry, i, value)             # <<<<<<<<<<<<<<
7123  *
7124  *         # TODO: is a vsimem file more memory efficient?
7125  */
7126           __pyx_t_16 = __Pyx_PyInt_FromSize_t(__pyx_v_i); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 350, __pyx_L13_except_error)
7127           __Pyx_GOTREF(__pyx_t_16);
7128           __pyx_t_18 = NULL;
7129           __pyx_t_19 = 0;
7130           if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_17))) {
7131             __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_17);
7132             if (likely(__pyx_t_18)) {
7133               PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
7134               __Pyx_INCREF(__pyx_t_18);
7135               __Pyx_INCREF(function);
7136               __Pyx_DECREF_SET(__pyx_t_17, function);
7137               __pyx_t_19 = 1;
7138             }
7139           }
7140           #if CYTHON_FAST_PYCALL
7141           if (PyFunction_Check(__pyx_t_17)) {
7142             PyObject *__pyx_temp[5] = {__pyx_t_18, __pyx_kp_u_Geometry_r_at_index_d_with_value, __pyx_v_geometry, __pyx_t_16, __pyx_v_value};
7143             __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_17, __pyx_temp+1-__pyx_t_19, 4+__pyx_t_19); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 349, __pyx_L13_except_error)
7144             __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
7145             __Pyx_GOTREF(__pyx_t_9);
7146             __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
7147           } else
7148           #endif
7149           #if CYTHON_FAST_PYCCALL
7150           if (__Pyx_PyFastCFunction_Check(__pyx_t_17)) {
7151             PyObject *__pyx_temp[5] = {__pyx_t_18, __pyx_kp_u_Geometry_r_at_index_d_with_value, __pyx_v_geometry, __pyx_t_16, __pyx_v_value};
7152             __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_17, __pyx_temp+1-__pyx_t_19, 4+__pyx_t_19); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 349, __pyx_L13_except_error)
7153             __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
7154             __Pyx_GOTREF(__pyx_t_9);
7155             __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
7156           } else
7157           #endif
7158           {
7159             __pyx_t_20 = PyTuple_New(4+__pyx_t_19); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 349, __pyx_L13_except_error)
7160             __Pyx_GOTREF(__pyx_t_20);
7161             if (__pyx_t_18) {
7162               __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_18); __pyx_t_18 = NULL;
7163             }
7164             __Pyx_INCREF(__pyx_kp_u_Geometry_r_at_index_d_with_value);
7165             __Pyx_GIVEREF(__pyx_kp_u_Geometry_r_at_index_d_with_value);
7166             PyTuple_SET_ITEM(__pyx_t_20, 0+__pyx_t_19, __pyx_kp_u_Geometry_r_at_index_d_with_value);
7167             __Pyx_INCREF(__pyx_v_geometry);
7168             __Pyx_GIVEREF(__pyx_v_geometry);
7169             PyTuple_SET_ITEM(__pyx_t_20, 1+__pyx_t_19, __pyx_v_geometry);
7170             __Pyx_GIVEREF(__pyx_t_16);
7171             PyTuple_SET_ITEM(__pyx_t_20, 2+__pyx_t_19, __pyx_t_16);
7172             __Pyx_INCREF(__pyx_v_value);
7173             __Pyx_GIVEREF(__pyx_v_value);
7174             PyTuple_SET_ITEM(__pyx_t_20, 3+__pyx_t_19, __pyx_v_value);
7175             __pyx_t_16 = 0;
7176             __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_20, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 349, __pyx_L13_except_error)
7177             __Pyx_GOTREF(__pyx_t_9);
7178             __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
7179           }
7180           __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
7181           __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
7182           __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7183           __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
7184           __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7185           goto __pyx_L12_exception_handled;
7186         }
7187         __pyx_L13_except_error:;
7188 
7189         /* "rasterio/_features.pyx":345
7190  *
7191  *         for i, (geometry, value) in enumerate(all_shapes):
7192  *             try:             # <<<<<<<<<<<<<<
7193  *                 geoms[i] = OGRGeomBuilder().build(geometry)
7194  *                 pixel_values[i] = <double>value
7195  */
7196         __Pyx_XGIVEREF(__pyx_t_11);
7197         __Pyx_XGIVEREF(__pyx_t_12);
7198         __Pyx_XGIVEREF(__pyx_t_13);
7199         __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
7200         goto __pyx_L4_error;
7201         __pyx_L12_exception_handled:;
7202         __Pyx_XGIVEREF(__pyx_t_11);
7203         __Pyx_XGIVEREF(__pyx_t_12);
7204         __Pyx_XGIVEREF(__pyx_t_13);
7205         __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
7206         __pyx_L18_try_end:;
7207       }
7208 
7209       /* "rasterio/_features.pyx":344
7210  *         pixel_values = <double *>CPLMalloc(num_geoms * sizeof(double))
7211  *
7212  *         for i, (geometry, value) in enumerate(all_shapes):             # <<<<<<<<<<<<<<
7213  *             try:
7214  *                 geoms[i] = OGRGeomBuilder().build(geometry)
7215  */
7216     }
7217     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7218 
7219     /* "rasterio/_features.pyx":353
7220  *
7221  *         # TODO: is a vsimem file more memory efficient?
7222  *         with InMemoryRaster(image=image, transform=transform) as mem:             # <<<<<<<<<<<<<<
7223  *             exc_wrap_int(
7224  *                 GDALRasterizeGeometries(
7225  */
7226     /*with:*/ {
7227       __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 353, __pyx_L4_error)
7228       __Pyx_GOTREF(__pyx_t_2);
7229       if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_image, __pyx_v_image) < 0) __PYX_ERR(0, 353, __pyx_L4_error)
7230       if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_transform, __pyx_v_transform) < 0) __PYX_ERR(0, 353, __pyx_L4_error)
7231       __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_8rasterio_3_io_InMemoryRaster), __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 353, __pyx_L4_error)
7232       __Pyx_GOTREF(__pyx_t_3);
7233       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7234       __pyx_t_13 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_exit); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 353, __pyx_L4_error)
7235       __Pyx_GOTREF(__pyx_t_13);
7236       __pyx_t_8 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_enter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 353, __pyx_L21_error)
7237       __Pyx_GOTREF(__pyx_t_8);
7238       __pyx_t_4 = NULL;
7239       if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
7240         __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
7241         if (likely(__pyx_t_4)) {
7242           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
7243           __Pyx_INCREF(__pyx_t_4);
7244           __Pyx_INCREF(function);
7245           __Pyx_DECREF_SET(__pyx_t_8, function);
7246         }
7247       }
7248       __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
7249       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7250       if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 353, __pyx_L21_error)
7251       __Pyx_GOTREF(__pyx_t_2);
7252       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7253       __pyx_t_8 = __pyx_t_2;
7254       __pyx_t_2 = 0;
7255       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7256       /*try:*/ {
7257         {
7258           __Pyx_PyThreadState_declare
7259           __Pyx_PyThreadState_assign
7260           __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_11, &__pyx_t_21);
7261           __Pyx_XGOTREF(__pyx_t_12);
7262           __Pyx_XGOTREF(__pyx_t_11);
7263           __Pyx_XGOTREF(__pyx_t_21);
7264           /*try:*/ {
7265             if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_8rasterio_3_io_InMemoryRaster))))) __PYX_ERR(0, 353, __pyx_L25_error)
7266             __Pyx_DECREF_SET(__pyx_v_mem, ((struct __pyx_obj_8rasterio_3_io_InMemoryRaster *)__pyx_t_8));
7267             __pyx_t_8 = 0;
7268 
7269             /* "rasterio/_features.pyx":356
7270  *             exc_wrap_int(
7271  *                 GDALRasterizeGeometries(
7272  *                     mem.handle(), 1, mem.band_ids, num_geoms, geoms, NULL,             # <<<<<<<<<<<<<<
7273  *                     NULL, pixel_values, options, NULL, NULL))
7274  *
7275  */
7276             __pyx_t_22 = ((struct __pyx_vtabstruct_8rasterio_3_io_InMemoryRaster *)__pyx_v_mem->__pyx_vtab)->handle(__pyx_v_mem); if (unlikely(__pyx_t_22 == ((GDALDatasetH)NULL))) __PYX_ERR(0, 356, __pyx_L25_error)
7277 
7278             /* "rasterio/_features.pyx":354
7279  *         # TODO: is a vsimem file more memory efficient?
7280  *         with InMemoryRaster(image=image, transform=transform) as mem:
7281  *             exc_wrap_int(             # <<<<<<<<<<<<<<
7282  *                 GDALRasterizeGeometries(
7283  *                     mem.handle(), 1, mem.band_ids, num_geoms, geoms, NULL,
7284  */
7285             __pyx_t_19 = __pyx_f_8rasterio_4_err_exc_wrap_int(GDALRasterizeGeometries(__pyx_t_22, 1, __pyx_v_mem->band_ids, __pyx_v_num_geoms, __pyx_v_geoms, NULL, NULL, __pyx_v_pixel_values, __pyx_v_options, NULL, NULL)); if (unlikely(__pyx_t_19 == ((int)-1))) __PYX_ERR(0, 354, __pyx_L25_error)
7286 
7287             /* "rasterio/_features.pyx":360
7288  *
7289  *             # Read in-memory data back into image
7290  *             image = mem.read()             # <<<<<<<<<<<<<<
7291  *
7292  *     finally:
7293  */
7294             __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_mem), __pyx_n_s_read); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 360, __pyx_L25_error)
7295             __Pyx_GOTREF(__pyx_t_3);
7296             __pyx_t_2 = NULL;
7297             if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
7298               __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
7299               if (likely(__pyx_t_2)) {
7300                 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
7301                 __Pyx_INCREF(__pyx_t_2);
7302                 __Pyx_INCREF(function);
7303                 __Pyx_DECREF_SET(__pyx_t_3, function);
7304               }
7305             }
7306             __pyx_t_8 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
7307             __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7308             if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 360, __pyx_L25_error)
7309             __Pyx_GOTREF(__pyx_t_8);
7310             __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7311             __Pyx_DECREF_SET(__pyx_v_image, __pyx_t_8);
7312             __pyx_t_8 = 0;
7313 
7314             /* "rasterio/_features.pyx":353
7315  *
7316  *         # TODO: is a vsimem file more memory efficient?
7317  *         with InMemoryRaster(image=image, transform=transform) as mem:             # <<<<<<<<<<<<<<
7318  *             exc_wrap_int(
7319  *                 GDALRasterizeGeometries(
7320  */
7321           }
7322           __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
7323           __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
7324           __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
7325           goto __pyx_L30_try_end;
7326           __pyx_L25_error:;
7327           __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
7328           __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
7329           __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
7330           __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7331           __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
7332           __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7333           __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7334           __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
7335           __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
7336           /*except:*/ {
7337             __Pyx_AddTraceback("rasterio._features._rasterize", __pyx_clineno, __pyx_lineno, __pyx_filename);
7338             if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 353, __pyx_L27_except_error)
7339             __Pyx_GOTREF(__pyx_t_8);
7340             __Pyx_GOTREF(__pyx_t_3);
7341             __Pyx_GOTREF(__pyx_t_2);
7342             __pyx_t_4 = PyTuple_Pack(3, __pyx_t_8, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 353, __pyx_L27_except_error)
7343             __Pyx_GOTREF(__pyx_t_4);
7344             __pyx_t_23 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_4, NULL);
7345             __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
7346             __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7347             if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 353, __pyx_L27_except_error)
7348             __Pyx_GOTREF(__pyx_t_23);
7349             __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_23);
7350             __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
7351             if (__pyx_t_1 < 0) __PYX_ERR(0, 353, __pyx_L27_except_error)
7352             __pyx_t_24 = ((!(__pyx_t_1 != 0)) != 0);
7353             if (__pyx_t_24) {
7354               __Pyx_GIVEREF(__pyx_t_8);
7355               __Pyx_GIVEREF(__pyx_t_3);
7356               __Pyx_XGIVEREF(__pyx_t_2);
7357               __Pyx_ErrRestoreWithState(__pyx_t_8, __pyx_t_3, __pyx_t_2);
7358               __pyx_t_8 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0;
7359               __PYX_ERR(0, 353, __pyx_L27_except_error)
7360             }
7361             __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
7362             __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7363             __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7364             goto __pyx_L26_exception_handled;
7365           }
7366           __pyx_L27_except_error:;
7367           __Pyx_XGIVEREF(__pyx_t_12);
7368           __Pyx_XGIVEREF(__pyx_t_11);
7369           __Pyx_XGIVEREF(__pyx_t_21);
7370           __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_21);
7371           goto __pyx_L4_error;
7372           __pyx_L26_exception_handled:;
7373           __Pyx_XGIVEREF(__pyx_t_12);
7374           __Pyx_XGIVEREF(__pyx_t_11);
7375           __Pyx_XGIVEREF(__pyx_t_21);
7376           __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_21);
7377           __pyx_L30_try_end:;
7378         }
7379       }
7380       /*finally:*/ {
7381         /*normal exit:*/{
7382           if (__pyx_t_13) {
7383             __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_tuple__20, NULL);
7384             __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
7385             if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 353, __pyx_L4_error)
7386             __Pyx_GOTREF(__pyx_t_21);
7387             __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
7388           }
7389           goto __pyx_L24;
7390         }
7391         __pyx_L24:;
7392       }
7393       goto __pyx_L34;
7394       __pyx_L21_error:;
7395       __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
7396       goto __pyx_L4_error;
7397       __pyx_L34:;
7398     }
7399   }
7400 
7401   /* "rasterio/_features.pyx":363
7402  *
7403  *     finally:
7404  *         for i in range(num_geoms):             # <<<<<<<<<<<<<<
7405  *             _deleteOgrGeom(geoms[i])
7406  *         CPLFree(geoms)
7407  */
7408   /*finally:*/ {
7409     /*normal exit:*/{
7410       __pyx_t_7 = __pyx_v_num_geoms;
7411       __pyx_t_25 = __pyx_t_7;
7412       for (__pyx_t_26 = 0; __pyx_t_26 < __pyx_t_25; __pyx_t_26+=1) {
7413         __pyx_v_i = __pyx_t_26;
7414 
7415         /* "rasterio/_features.pyx":364
7416  *     finally:
7417  *         for i in range(num_geoms):
7418  *             _deleteOgrGeom(geoms[i])             # <<<<<<<<<<<<<<
7419  *         CPLFree(geoms)
7420  *         CPLFree(pixel_values)
7421  */
7422         __pyx_t_2 = __pyx_f_8rasterio_9_features__deleteOgrGeom((__pyx_v_geoms[__pyx_v_i])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 364, __pyx_L1_error)
7423         __Pyx_GOTREF(__pyx_t_2);
7424         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7425       }
7426 
7427       /* "rasterio/_features.pyx":365
7428  *         for i in range(num_geoms):
7429  *             _deleteOgrGeom(geoms[i])
7430  *         CPLFree(geoms)             # <<<<<<<<<<<<<<
7431  *         CPLFree(pixel_values)
7432  *         if options:
7433  */
7434       CPLFree(__pyx_v_geoms);
7435 
7436       /* "rasterio/_features.pyx":366
7437  *             _deleteOgrGeom(geoms[i])
7438  *         CPLFree(geoms)
7439  *         CPLFree(pixel_values)             # <<<<<<<<<<<<<<
7440  *         if options:
7441  *             CSLDestroy(options)
7442  */
7443       CPLFree(__pyx_v_pixel_values);
7444 
7445       /* "rasterio/_features.pyx":367
7446  *         CPLFree(geoms)
7447  *         CPLFree(pixel_values)
7448  *         if options:             # <<<<<<<<<<<<<<
7449  *             CSLDestroy(options)
7450  *
7451  */
7452       __pyx_t_24 = (__pyx_v_options != 0);
7453       if (__pyx_t_24) {
7454 
7455         /* "rasterio/_features.pyx":368
7456  *         CPLFree(pixel_values)
7457  *         if options:
7458  *             CSLDestroy(options)             # <<<<<<<<<<<<<<
7459  *
7460  *
7461  */
7462         CSLDestroy(__pyx_v_options);
7463 
7464         /* "rasterio/_features.pyx":367
7465  *         CPLFree(geoms)
7466  *         CPLFree(pixel_values)
7467  *         if options:             # <<<<<<<<<<<<<<
7468  *             CSLDestroy(options)
7469  *
7470  */
7471       }
7472       goto __pyx_L5;
7473     }
7474     __pyx_L4_error:;
7475     /*exception exit:*/{
7476       __Pyx_PyThreadState_declare
7477       __Pyx_PyThreadState_assign
7478       __pyx_t_13 = 0; __pyx_t_21 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_23 = 0; __pyx_t_29 = 0;
7479       __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
7480       __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
7481       __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
7482       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7483       __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
7484       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7485       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7486       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
7487       __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
7488       if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_23, &__pyx_t_29);
7489       if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_21, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_21, &__pyx_t_11);
7490       __Pyx_XGOTREF(__pyx_t_13);
7491       __Pyx_XGOTREF(__pyx_t_21);
7492       __Pyx_XGOTREF(__pyx_t_11);
7493       __Pyx_XGOTREF(__pyx_t_12);
7494       __Pyx_XGOTREF(__pyx_t_23);
7495       __Pyx_XGOTREF(__pyx_t_29);
7496       __pyx_t_19 = __pyx_lineno; __pyx_t_27 = __pyx_clineno; __pyx_t_28 = __pyx_filename;
7497       {
7498 
7499         /* "rasterio/_features.pyx":363
7500  *
7501  *     finally:
7502  *         for i in range(num_geoms):             # <<<<<<<<<<<<<<
7503  *             _deleteOgrGeom(geoms[i])
7504  *         CPLFree(geoms)
7505  */
7506         __pyx_t_7 = __pyx_v_num_geoms;
7507         __pyx_t_25 = __pyx_t_7;
7508         for (__pyx_t_26 = 0; __pyx_t_26 < __pyx_t_25; __pyx_t_26+=1) {
7509           __pyx_v_i = __pyx_t_26;
7510 
7511           /* "rasterio/_features.pyx":364
7512  *     finally:
7513  *         for i in range(num_geoms):
7514  *             _deleteOgrGeom(geoms[i])             # <<<<<<<<<<<<<<
7515  *         CPLFree(geoms)
7516  *         CPLFree(pixel_values)
7517  */
7518           __pyx_t_2 = __pyx_f_8rasterio_9_features__deleteOgrGeom((__pyx_v_geoms[__pyx_v_i])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 364, __pyx_L39_error)
7519           __Pyx_GOTREF(__pyx_t_2);
7520           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7521         }
7522 
7523         /* "rasterio/_features.pyx":365
7524  *         for i in range(num_geoms):
7525  *             _deleteOgrGeom(geoms[i])
7526  *         CPLFree(geoms)             # <<<<<<<<<<<<<<
7527  *         CPLFree(pixel_values)
7528  *         if options:
7529  */
7530         CPLFree(__pyx_v_geoms);
7531 
7532         /* "rasterio/_features.pyx":366
7533  *             _deleteOgrGeom(geoms[i])
7534  *         CPLFree(geoms)
7535  *         CPLFree(pixel_values)             # <<<<<<<<<<<<<<
7536  *         if options:
7537  *             CSLDestroy(options)
7538  */
7539         CPLFree(__pyx_v_pixel_values);
7540 
7541         /* "rasterio/_features.pyx":367
7542  *         CPLFree(geoms)
7543  *         CPLFree(pixel_values)
7544  *         if options:             # <<<<<<<<<<<<<<
7545  *             CSLDestroy(options)
7546  *
7547  */
7548         __pyx_t_24 = (__pyx_v_options != 0);
7549         if (__pyx_t_24) {
7550 
7551           /* "rasterio/_features.pyx":368
7552  *         CPLFree(pixel_values)
7553  *         if options:
7554  *             CSLDestroy(options)             # <<<<<<<<<<<<<<
7555  *
7556  *
7557  */
7558           CSLDestroy(__pyx_v_options);
7559 
7560           /* "rasterio/_features.pyx":367
7561  *         CPLFree(geoms)
7562  *         CPLFree(pixel_values)
7563  *         if options:             # <<<<<<<<<<<<<<
7564  *             CSLDestroy(options)
7565  *
7566  */
7567         }
7568       }
7569       if (PY_MAJOR_VERSION >= 3) {
7570         __Pyx_XGIVEREF(__pyx_t_12);
7571         __Pyx_XGIVEREF(__pyx_t_23);
7572         __Pyx_XGIVEREF(__pyx_t_29);
7573         __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_23, __pyx_t_29);
7574       }
7575       __Pyx_XGIVEREF(__pyx_t_13);
7576       __Pyx_XGIVEREF(__pyx_t_21);
7577       __Pyx_XGIVEREF(__pyx_t_11);
7578       __Pyx_ErrRestore(__pyx_t_13, __pyx_t_21, __pyx_t_11);
7579       __pyx_t_13 = 0; __pyx_t_21 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_23 = 0; __pyx_t_29 = 0;
7580       __pyx_lineno = __pyx_t_19; __pyx_clineno = __pyx_t_27; __pyx_filename = __pyx_t_28;
7581       goto __pyx_L1_error;
7582       __pyx_L39_error:;
7583       if (PY_MAJOR_VERSION >= 3) {
7584         __Pyx_XGIVEREF(__pyx_t_12);
7585         __Pyx_XGIVEREF(__pyx_t_23);
7586         __Pyx_XGIVEREF(__pyx_t_29);
7587         __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_23, __pyx_t_29);
7588       }
7589       __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
7590       __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
7591       __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
7592       __pyx_t_12 = 0; __pyx_t_23 = 0; __pyx_t_29 = 0;
7593       goto __pyx_L1_error;
7594     }
7595     __pyx_L5:;
7596   }
7597 
7598   /* "rasterio/_features.pyx":264
7599  *
7600  *
7601  * def _rasterize(shapes, image, transform, all_touched, merge_alg):             # <<<<<<<<<<<<<<
7602  *     """
7603  *     Burns input geometries into `image`.
7604  */
7605 
7606   /* function exit code */
7607   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7608   goto __pyx_L0;
7609   __pyx_L1_error:;
7610   __Pyx_XDECREF(__pyx_t_2);
7611   __Pyx_XDECREF(__pyx_t_3);
7612   __Pyx_XDECREF(__pyx_t_4);
7613   __Pyx_XDECREF(__pyx_t_8);
7614   __Pyx_XDECREF(__pyx_t_9);
7615   __Pyx_XDECREF(__pyx_t_16);
7616   __Pyx_XDECREF(__pyx_t_17);
7617   __Pyx_XDECREF(__pyx_t_18);
7618   __Pyx_XDECREF(__pyx_t_20);
7619   __Pyx_AddTraceback("rasterio._features._rasterize", __pyx_clineno, __pyx_lineno, __pyx_filename);
7620   __pyx_r = NULL;
7621   __pyx_L0:;
7622   __Pyx_XDECREF((PyObject *)__pyx_v_mem);
7623   __Pyx_XDECREF(__pyx_v_merge_algorithm);
7624   __Pyx_XDECREF(__pyx_v_all_shapes);
7625   __Pyx_XDECREF(__pyx_v_geometry);
7626   __Pyx_XDECREF(__pyx_v_value);
7627   __Pyx_XDECREF(__pyx_v_image);
7628   __Pyx_XGIVEREF(__pyx_r);
7629   __Pyx_RefNannyFinishContext();
7630   return __pyx_r;
7631 }
7632 static PyObject *__pyx_gb_8rasterio_9_features_9generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
7633 
7634 /* "rasterio/_features.pyx":371
7635  *
7636  *
7637  * def _explode(coords):             # <<<<<<<<<<<<<<
7638  *     """Explode a GeoJSON geometry's coordinates object and yield
7639  *     coordinate tuples. As long as the input is conforming, the type of
7640  */
7641 
7642 /* Python wrapper */
7643 static PyObject *__pyx_pw_8rasterio_9_features_8_explode(PyObject *__pyx_self, PyObject *__pyx_v_coords); /*proto*/
7644 static char __pyx_doc_8rasterio_9_features_7_explode[] = "Explode a GeoJSON geometry's coordinates object and yield\n    coordinate tuples. As long as the input is conforming, the type of\n    the geometry doesn't matter.  From Fiona 1.4.8";
7645 static PyMethodDef __pyx_mdef_8rasterio_9_features_8_explode = {"_explode", (PyCFunction)__pyx_pw_8rasterio_9_features_8_explode, METH_O, __pyx_doc_8rasterio_9_features_7_explode};
__pyx_pw_8rasterio_9_features_8_explode(PyObject * __pyx_self,PyObject * __pyx_v_coords)7646 static PyObject *__pyx_pw_8rasterio_9_features_8_explode(PyObject *__pyx_self, PyObject *__pyx_v_coords) {
7647   PyObject *__pyx_r = 0;
7648   __Pyx_RefNannyDeclarations
7649   __Pyx_RefNannySetupContext("_explode (wrapper)", 0);
7650   __pyx_r = __pyx_pf_8rasterio_9_features_7_explode(__pyx_self, ((PyObject *)__pyx_v_coords));
7651 
7652   /* function exit code */
7653   __Pyx_RefNannyFinishContext();
7654   return __pyx_r;
7655 }
7656 
__pyx_pf_8rasterio_9_features_7_explode(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_coords)7657 static PyObject *__pyx_pf_8rasterio_9_features_7_explode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_coords) {
7658   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode *__pyx_cur_scope;
7659   PyObject *__pyx_r = NULL;
7660   __Pyx_RefNannyDeclarations
7661   int __pyx_lineno = 0;
7662   const char *__pyx_filename = NULL;
7663   int __pyx_clineno = 0;
7664   __Pyx_RefNannySetupContext("_explode", 0);
7665   __pyx_cur_scope = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode *)__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_3__explode(__pyx_ptype_8rasterio_9_features___pyx_scope_struct_3__explode, __pyx_empty_tuple, NULL);
7666   if (unlikely(!__pyx_cur_scope)) {
7667     __pyx_cur_scope = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode *)Py_None);
7668     __Pyx_INCREF(Py_None);
7669     __PYX_ERR(0, 371, __pyx_L1_error)
7670   } else {
7671     __Pyx_GOTREF(__pyx_cur_scope);
7672   }
7673   __pyx_cur_scope->__pyx_v_coords = __pyx_v_coords;
7674   __Pyx_INCREF(__pyx_cur_scope->__pyx_v_coords);
7675   __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_coords);
7676   {
7677     __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_8rasterio_9_features_9generator1, __pyx_codeobj__21, (PyObject *) __pyx_cur_scope, __pyx_n_s_explode, __pyx_n_s_explode, __pyx_n_s_rasterio__features); if (unlikely(!gen)) __PYX_ERR(0, 371, __pyx_L1_error)
7678     __Pyx_DECREF(__pyx_cur_scope);
7679     __Pyx_RefNannyFinishContext();
7680     return (PyObject *) gen;
7681   }
7682 
7683   /* function exit code */
7684   __pyx_L1_error:;
7685   __Pyx_AddTraceback("rasterio._features._explode", __pyx_clineno, __pyx_lineno, __pyx_filename);
7686   __pyx_r = NULL;
7687   __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
7688   __Pyx_XGIVEREF(__pyx_r);
7689   __Pyx_RefNannyFinishContext();
7690   return __pyx_r;
7691 }
7692 
__pyx_gb_8rasterio_9_features_9generator1(__pyx_CoroutineObject * __pyx_generator,CYTHON_UNUSED PyThreadState * __pyx_tstate,PyObject * __pyx_sent_value)7693 static PyObject *__pyx_gb_8rasterio_9_features_9generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
7694 {
7695   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode *__pyx_cur_scope = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode *)__pyx_generator->closure);
7696   PyObject *__pyx_r = NULL;
7697   PyObject *__pyx_t_1 = NULL;
7698   Py_ssize_t __pyx_t_2;
7699   PyObject *(*__pyx_t_3)(PyObject *);
7700   PyObject *__pyx_t_4 = NULL;
7701   int __pyx_t_5;
7702   int __pyx_t_6;
7703   int __pyx_t_7;
7704   PyObject *__pyx_t_8 = NULL;
7705   PyObject *__pyx_t_9 = NULL;
7706   Py_ssize_t __pyx_t_10;
7707   PyObject *(*__pyx_t_11)(PyObject *);
7708   int __pyx_lineno = 0;
7709   const char *__pyx_filename = NULL;
7710   int __pyx_clineno = 0;
7711   __Pyx_RefNannyDeclarations
7712   __Pyx_RefNannySetupContext("_explode", 0);
7713   switch (__pyx_generator->resume_label) {
7714     case 0: goto __pyx_L3_first_run;
7715     case 1: goto __pyx_L9_resume_from_yield;
7716     case 2: goto __pyx_L12_resume_from_yield;
7717     default: /* CPython raises the right error here */
7718     __Pyx_RefNannyFinishContext();
7719     return NULL;
7720   }
7721   __pyx_L3_first_run:;
7722   if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 371, __pyx_L1_error)
7723 
7724   /* "rasterio/_features.pyx":375
7725  *     coordinate tuples. As long as the input is conforming, the type of
7726  *     the geometry doesn't matter.  From Fiona 1.4.8"""
7727  *     for e in coords:             # <<<<<<<<<<<<<<
7728  *         if isinstance(e, (float, int)):
7729  *             yield coords
7730  */
7731   if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_coords)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_coords)) {
7732     __pyx_t_1 = __pyx_cur_scope->__pyx_v_coords; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
7733     __pyx_t_3 = NULL;
7734   } else {
7735     __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_coords); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 375, __pyx_L1_error)
7736     __Pyx_GOTREF(__pyx_t_1);
7737     __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 375, __pyx_L1_error)
7738   }
7739   for (;;) {
7740     if (likely(!__pyx_t_3)) {
7741       if (likely(PyList_CheckExact(__pyx_t_1))) {
7742         if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
7743         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
7744         __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 375, __pyx_L1_error)
7745         #else
7746         __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 375, __pyx_L1_error)
7747         __Pyx_GOTREF(__pyx_t_4);
7748         #endif
7749       } else {
7750         if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
7751         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
7752         __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 375, __pyx_L1_error)
7753         #else
7754         __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 375, __pyx_L1_error)
7755         __Pyx_GOTREF(__pyx_t_4);
7756         #endif
7757       }
7758     } else {
7759       __pyx_t_4 = __pyx_t_3(__pyx_t_1);
7760       if (unlikely(!__pyx_t_4)) {
7761         PyObject* exc_type = PyErr_Occurred();
7762         if (exc_type) {
7763           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
7764           else __PYX_ERR(0, 375, __pyx_L1_error)
7765         }
7766         break;
7767       }
7768       __Pyx_GOTREF(__pyx_t_4);
7769     }
7770     __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
7771     __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_4);
7772     __Pyx_GIVEREF(__pyx_t_4);
7773     __pyx_t_4 = 0;
7774 
7775     /* "rasterio/_features.pyx":376
7776  *     the geometry doesn't matter.  From Fiona 1.4.8"""
7777  *     for e in coords:
7778  *         if isinstance(e, (float, int)):             # <<<<<<<<<<<<<<
7779  *             yield coords
7780  *             break
7781  */
7782     __pyx_t_6 = PyFloat_Check(__pyx_cur_scope->__pyx_v_e);
7783     __pyx_t_7 = (__pyx_t_6 != 0);
7784     if (!__pyx_t_7) {
7785     } else {
7786       __pyx_t_5 = __pyx_t_7;
7787       goto __pyx_L7_bool_binop_done;
7788     }
7789     __pyx_t_7 = PyInt_Check(__pyx_cur_scope->__pyx_v_e);
7790     __pyx_t_6 = (__pyx_t_7 != 0);
7791     __pyx_t_5 = __pyx_t_6;
7792     __pyx_L7_bool_binop_done:;
7793     __pyx_t_6 = (__pyx_t_5 != 0);
7794     if (__pyx_t_6) {
7795 
7796       /* "rasterio/_features.pyx":377
7797  *     for e in coords:
7798  *         if isinstance(e, (float, int)):
7799  *             yield coords             # <<<<<<<<<<<<<<
7800  *             break
7801  *         else:
7802  */
7803       __Pyx_INCREF(__pyx_cur_scope->__pyx_v_coords);
7804       __pyx_r = __pyx_cur_scope->__pyx_v_coords;
7805       __Pyx_XGIVEREF(__pyx_t_1);
7806       __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
7807       __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
7808       __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
7809       __Pyx_XGIVEREF(__pyx_r);
7810       __Pyx_RefNannyFinishContext();
7811       __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
7812       /* return from generator, yielding value */
7813       __pyx_generator->resume_label = 1;
7814       return __pyx_r;
7815       __pyx_L9_resume_from_yield:;
7816       __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
7817       __pyx_cur_scope->__pyx_t_0 = 0;
7818       __Pyx_XGOTREF(__pyx_t_1);
7819       __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
7820       __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
7821       if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 377, __pyx_L1_error)
7822 
7823       /* "rasterio/_features.pyx":378
7824  *         if isinstance(e, (float, int)):
7825  *             yield coords
7826  *             break             # <<<<<<<<<<<<<<
7827  *         else:
7828  *             for f in _explode(e):
7829  */
7830       goto __pyx_L5_break;
7831 
7832       /* "rasterio/_features.pyx":376
7833  *     the geometry doesn't matter.  From Fiona 1.4.8"""
7834  *     for e in coords:
7835  *         if isinstance(e, (float, int)):             # <<<<<<<<<<<<<<
7836  *             yield coords
7837  *             break
7838  */
7839     }
7840 
7841     /* "rasterio/_features.pyx":380
7842  *             break
7843  *         else:
7844  *             for f in _explode(e):             # <<<<<<<<<<<<<<
7845  *                 yield f
7846  *
7847  */
7848     /*else*/ {
7849       __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_explode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 380, __pyx_L1_error)
7850       __Pyx_GOTREF(__pyx_t_8);
7851       __pyx_t_9 = NULL;
7852       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
7853         __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
7854         if (likely(__pyx_t_9)) {
7855           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
7856           __Pyx_INCREF(__pyx_t_9);
7857           __Pyx_INCREF(function);
7858           __Pyx_DECREF_SET(__pyx_t_8, function);
7859         }
7860       }
7861       __pyx_t_4 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_cur_scope->__pyx_v_e) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_cur_scope->__pyx_v_e);
7862       __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
7863       if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 380, __pyx_L1_error)
7864       __Pyx_GOTREF(__pyx_t_4);
7865       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7866       if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
7867         __pyx_t_8 = __pyx_t_4; __Pyx_INCREF(__pyx_t_8); __pyx_t_10 = 0;
7868         __pyx_t_11 = NULL;
7869       } else {
7870         __pyx_t_10 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 380, __pyx_L1_error)
7871         __Pyx_GOTREF(__pyx_t_8);
7872         __pyx_t_11 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 380, __pyx_L1_error)
7873       }
7874       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7875       for (;;) {
7876         if (likely(!__pyx_t_11)) {
7877           if (likely(PyList_CheckExact(__pyx_t_8))) {
7878             if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_8)) break;
7879             #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
7880             __pyx_t_4 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 380, __pyx_L1_error)
7881             #else
7882             __pyx_t_4 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 380, __pyx_L1_error)
7883             __Pyx_GOTREF(__pyx_t_4);
7884             #endif
7885           } else {
7886             if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
7887             #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
7888             __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(0, 380, __pyx_L1_error)
7889             #else
7890             __pyx_t_4 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 380, __pyx_L1_error)
7891             __Pyx_GOTREF(__pyx_t_4);
7892             #endif
7893           }
7894         } else {
7895           __pyx_t_4 = __pyx_t_11(__pyx_t_8);
7896           if (unlikely(!__pyx_t_4)) {
7897             PyObject* exc_type = PyErr_Occurred();
7898             if (exc_type) {
7899               if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
7900               else __PYX_ERR(0, 380, __pyx_L1_error)
7901             }
7902             break;
7903           }
7904           __Pyx_GOTREF(__pyx_t_4);
7905         }
7906         __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_f);
7907         __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_f, __pyx_t_4);
7908         __Pyx_GIVEREF(__pyx_t_4);
7909         __pyx_t_4 = 0;
7910 
7911         /* "rasterio/_features.pyx":381
7912  *         else:
7913  *             for f in _explode(e):
7914  *                 yield f             # <<<<<<<<<<<<<<
7915  *
7916  *
7917  */
7918         __Pyx_INCREF(__pyx_cur_scope->__pyx_v_f);
7919         __pyx_r = __pyx_cur_scope->__pyx_v_f;
7920         __Pyx_XGIVEREF(__pyx_t_1);
7921         __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
7922         __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
7923         __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
7924         __Pyx_XGIVEREF(__pyx_t_8);
7925         __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
7926         __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
7927         __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
7928         __Pyx_XGIVEREF(__pyx_r);
7929         __Pyx_RefNannyFinishContext();
7930         __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
7931         /* return from generator, yielding value */
7932         __pyx_generator->resume_label = 2;
7933         return __pyx_r;
7934         __pyx_L12_resume_from_yield:;
7935         __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
7936         __pyx_cur_scope->__pyx_t_0 = 0;
7937         __Pyx_XGOTREF(__pyx_t_1);
7938         __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
7939         __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
7940         __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
7941         __pyx_cur_scope->__pyx_t_3 = 0;
7942         __Pyx_XGOTREF(__pyx_t_8);
7943         __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
7944         __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
7945         if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 381, __pyx_L1_error)
7946 
7947         /* "rasterio/_features.pyx":380
7948  *             break
7949  *         else:
7950  *             for f in _explode(e):             # <<<<<<<<<<<<<<
7951  *                 yield f
7952  *
7953  */
7954       }
7955       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7956     }
7957 
7958     /* "rasterio/_features.pyx":375
7959  *     coordinate tuples. As long as the input is conforming, the type of
7960  *     the geometry doesn't matter.  From Fiona 1.4.8"""
7961  *     for e in coords:             # <<<<<<<<<<<<<<
7962  *         if isinstance(e, (float, int)):
7963  *             yield coords
7964  */
7965   }
7966   __pyx_L5_break:;
7967   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7968   CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
7969 
7970   /* "rasterio/_features.pyx":371
7971  *
7972  *
7973  * def _explode(coords):             # <<<<<<<<<<<<<<
7974  *     """Explode a GeoJSON geometry's coordinates object and yield
7975  *     coordinate tuples. As long as the input is conforming, the type of
7976  */
7977 
7978   /* function exit code */
7979   PyErr_SetNone(PyExc_StopIteration);
7980   goto __pyx_L0;
7981   __pyx_L1_error:;
7982   __Pyx_XDECREF(__pyx_t_1);
7983   __Pyx_XDECREF(__pyx_t_4);
7984   __Pyx_XDECREF(__pyx_t_8);
7985   __Pyx_XDECREF(__pyx_t_9);
7986   __Pyx_AddTraceback("_explode", __pyx_clineno, __pyx_lineno, __pyx_filename);
7987   __pyx_L0:;
7988   __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
7989   #if !CYTHON_USE_EXC_INFO_STACK
7990   __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
7991   #endif
7992   __pyx_generator->resume_label = -1;
7993   __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
7994   __Pyx_RefNannyFinishContext();
7995   return __pyx_r;
7996 }
7997 
7998 /* "rasterio/_features.pyx":384
7999  *
8000  *
8001  * def _bounds(geometry, north_up=True, transform=None):             # <<<<<<<<<<<<<<
8002  *     """Bounding box of a GeoJSON geometry, GeometryCollection, or FeatureCollection.
8003  *
8004  */
8005 
8006 /* Python wrapper */
8007 static PyObject *__pyx_pw_8rasterio_9_features_11_bounds(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
8008 static char __pyx_doc_8rasterio_9_features_10_bounds[] = "Bounding box of a GeoJSON geometry, GeometryCollection, or FeatureCollection.\n\n    left, bottom, right, top\n    *not* xmin, ymin, xmax, ymax\n\n    If not north_up, y will be switched to guarantee the above.\n\n    From Fiona 1.4.8 with updates here to handle feature collections.\n    TODO: add to Fiona.\n    ";
8009 static PyMethodDef __pyx_mdef_8rasterio_9_features_11_bounds = {"_bounds", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8rasterio_9_features_11_bounds, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8rasterio_9_features_10_bounds};
__pyx_pw_8rasterio_9_features_11_bounds(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)8010 static PyObject *__pyx_pw_8rasterio_9_features_11_bounds(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
8011   PyObject *__pyx_v_geometry = 0;
8012   PyObject *__pyx_v_north_up = 0;
8013   PyObject *__pyx_v_transform = 0;
8014   int __pyx_lineno = 0;
8015   const char *__pyx_filename = NULL;
8016   int __pyx_clineno = 0;
8017   PyObject *__pyx_r = 0;
8018   __Pyx_RefNannyDeclarations
8019   __Pyx_RefNannySetupContext("_bounds (wrapper)", 0);
8020   {
8021     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_geometry,&__pyx_n_s_north_up,&__pyx_n_s_transform,0};
8022     PyObject* values[3] = {0,0,0};
8023     values[1] = ((PyObject *)Py_True);
8024     values[2] = ((PyObject *)Py_None);
8025     if (unlikely(__pyx_kwds)) {
8026       Py_ssize_t kw_args;
8027       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
8028       switch (pos_args) {
8029         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8030         CYTHON_FALLTHROUGH;
8031         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8032         CYTHON_FALLTHROUGH;
8033         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8034         CYTHON_FALLTHROUGH;
8035         case  0: break;
8036         default: goto __pyx_L5_argtuple_error;
8037       }
8038       kw_args = PyDict_Size(__pyx_kwds);
8039       switch (pos_args) {
8040         case  0:
8041         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_geometry)) != 0)) kw_args--;
8042         else goto __pyx_L5_argtuple_error;
8043         CYTHON_FALLTHROUGH;
8044         case  1:
8045         if (kw_args > 0) {
8046           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_north_up);
8047           if (value) { values[1] = value; kw_args--; }
8048         }
8049         CYTHON_FALLTHROUGH;
8050         case  2:
8051         if (kw_args > 0) {
8052           PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_transform);
8053           if (value) { values[2] = value; kw_args--; }
8054         }
8055       }
8056       if (unlikely(kw_args > 0)) {
8057         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_bounds") < 0)) __PYX_ERR(0, 384, __pyx_L3_error)
8058       }
8059     } else {
8060       switch (PyTuple_GET_SIZE(__pyx_args)) {
8061         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8062         CYTHON_FALLTHROUGH;
8063         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8064         CYTHON_FALLTHROUGH;
8065         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8066         break;
8067         default: goto __pyx_L5_argtuple_error;
8068       }
8069     }
8070     __pyx_v_geometry = values[0];
8071     __pyx_v_north_up = values[1];
8072     __pyx_v_transform = values[2];
8073   }
8074   goto __pyx_L4_argument_unpacking_done;
8075   __pyx_L5_argtuple_error:;
8076   __Pyx_RaiseArgtupleInvalid("_bounds", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 384, __pyx_L3_error)
8077   __pyx_L3_error:;
8078   __Pyx_AddTraceback("rasterio._features._bounds", __pyx_clineno, __pyx_lineno, __pyx_filename);
8079   __Pyx_RefNannyFinishContext();
8080   return NULL;
8081   __pyx_L4_argument_unpacking_done:;
8082   __pyx_r = __pyx_pf_8rasterio_9_features_10_bounds(__pyx_self, __pyx_v_geometry, __pyx_v_north_up, __pyx_v_transform);
8083 
8084   /* function exit code */
8085   __Pyx_RefNannyFinishContext();
8086   return __pyx_r;
8087 }
8088 
__pyx_pf_8rasterio_9_features_10_bounds(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_geometry,PyObject * __pyx_v_north_up,PyObject * __pyx_v_transform)8089 static PyObject *__pyx_pf_8rasterio_9_features_10_bounds(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_geometry, PyObject *__pyx_v_north_up, PyObject *__pyx_v_transform) {
8090   PyObject *__pyx_v_xmins = NULL;
8091   PyObject *__pyx_v_ymins = NULL;
8092   PyObject *__pyx_v_xmaxs = NULL;
8093   PyObject *__pyx_v_ymaxs = NULL;
8094   PyObject *__pyx_v_feature = NULL;
8095   PyObject *__pyx_v_xmin = NULL;
8096   PyObject *__pyx_v_ymin = NULL;
8097   PyObject *__pyx_v_xmax = NULL;
8098   PyObject *__pyx_v_ymax = NULL;
8099   PyObject *__pyx_v_xyz = NULL;
8100   PyObject *__pyx_v_xyz_px = NULL;
8101   PyObject *__pyx_8genexpr1__pyx_v_point = NULL;
8102   PyObject *__pyx_r = NULL;
8103   __Pyx_RefNannyDeclarations
8104   int __pyx_t_1;
8105   int __pyx_t_2;
8106   PyObject *__pyx_t_3 = NULL;
8107   PyObject *__pyx_t_4 = NULL;
8108   Py_ssize_t __pyx_t_5;
8109   PyObject *(*__pyx_t_6)(PyObject *);
8110   PyObject *__pyx_t_7 = NULL;
8111   PyObject *__pyx_t_8 = NULL;
8112   PyObject *__pyx_t_9 = NULL;
8113   PyObject *__pyx_t_10 = NULL;
8114   PyObject *__pyx_t_11 = NULL;
8115   PyObject *(*__pyx_t_12)(PyObject *);
8116   int __pyx_t_13;
8117   int __pyx_lineno = 0;
8118   const char *__pyx_filename = NULL;
8119   int __pyx_clineno = 0;
8120   __Pyx_RefNannySetupContext("_bounds", 0);
8121   __Pyx_INCREF(__pyx_v_geometry);
8122 
8123   /* "rasterio/_features.pyx":396
8124  *     """
8125  *
8126  *     if 'features' in geometry:             # <<<<<<<<<<<<<<
8127  *         # Input is a FeatureCollection
8128  *         xmins = []
8129  */
8130   __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_features, __pyx_v_geometry, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 396, __pyx_L1_error)
8131   __pyx_t_2 = (__pyx_t_1 != 0);
8132   if (__pyx_t_2) {
8133 
8134     /* "rasterio/_features.pyx":398
8135  *     if 'features' in geometry:
8136  *         # Input is a FeatureCollection
8137  *         xmins = []             # <<<<<<<<<<<<<<
8138  *         ymins = []
8139  *         xmaxs = []
8140  */
8141     __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 398, __pyx_L1_error)
8142     __Pyx_GOTREF(__pyx_t_3);
8143     __pyx_v_xmins = ((PyObject*)__pyx_t_3);
8144     __pyx_t_3 = 0;
8145 
8146     /* "rasterio/_features.pyx":399
8147  *         # Input is a FeatureCollection
8148  *         xmins = []
8149  *         ymins = []             # <<<<<<<<<<<<<<
8150  *         xmaxs = []
8151  *         ymaxs = []
8152  */
8153     __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 399, __pyx_L1_error)
8154     __Pyx_GOTREF(__pyx_t_3);
8155     __pyx_v_ymins = ((PyObject*)__pyx_t_3);
8156     __pyx_t_3 = 0;
8157 
8158     /* "rasterio/_features.pyx":400
8159  *         xmins = []
8160  *         ymins = []
8161  *         xmaxs = []             # <<<<<<<<<<<<<<
8162  *         ymaxs = []
8163  *         for feature in geometry['features']:
8164  */
8165     __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 400, __pyx_L1_error)
8166     __Pyx_GOTREF(__pyx_t_3);
8167     __pyx_v_xmaxs = ((PyObject*)__pyx_t_3);
8168     __pyx_t_3 = 0;
8169 
8170     /* "rasterio/_features.pyx":401
8171  *         ymins = []
8172  *         xmaxs = []
8173  *         ymaxs = []             # <<<<<<<<<<<<<<
8174  *         for feature in geometry['features']:
8175  *             xmin, ymin, xmax, ymax = _bounds(feature['geometry'])
8176  */
8177     __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 401, __pyx_L1_error)
8178     __Pyx_GOTREF(__pyx_t_3);
8179     __pyx_v_ymaxs = ((PyObject*)__pyx_t_3);
8180     __pyx_t_3 = 0;
8181 
8182     /* "rasterio/_features.pyx":402
8183  *         xmaxs = []
8184  *         ymaxs = []
8185  *         for feature in geometry['features']:             # <<<<<<<<<<<<<<
8186  *             xmin, ymin, xmax, ymax = _bounds(feature['geometry'])
8187  *             xmins.append(xmin)
8188  */
8189     __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_geometry, __pyx_n_u_features); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 402, __pyx_L1_error)
8190     __Pyx_GOTREF(__pyx_t_3);
8191     if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
8192       __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
8193       __pyx_t_6 = NULL;
8194     } else {
8195       __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 402, __pyx_L1_error)
8196       __Pyx_GOTREF(__pyx_t_4);
8197       __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 402, __pyx_L1_error)
8198     }
8199     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8200     for (;;) {
8201       if (likely(!__pyx_t_6)) {
8202         if (likely(PyList_CheckExact(__pyx_t_4))) {
8203           if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
8204           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8205           __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 402, __pyx_L1_error)
8206           #else
8207           __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 402, __pyx_L1_error)
8208           __Pyx_GOTREF(__pyx_t_3);
8209           #endif
8210         } else {
8211           if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
8212           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8213           __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 402, __pyx_L1_error)
8214           #else
8215           __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 402, __pyx_L1_error)
8216           __Pyx_GOTREF(__pyx_t_3);
8217           #endif
8218         }
8219       } else {
8220         __pyx_t_3 = __pyx_t_6(__pyx_t_4);
8221         if (unlikely(!__pyx_t_3)) {
8222           PyObject* exc_type = PyErr_Occurred();
8223           if (exc_type) {
8224             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
8225             else __PYX_ERR(0, 402, __pyx_L1_error)
8226           }
8227           break;
8228         }
8229         __Pyx_GOTREF(__pyx_t_3);
8230       }
8231       __Pyx_XDECREF_SET(__pyx_v_feature, __pyx_t_3);
8232       __pyx_t_3 = 0;
8233 
8234       /* "rasterio/_features.pyx":403
8235  *         ymaxs = []
8236  *         for feature in geometry['features']:
8237  *             xmin, ymin, xmax, ymax = _bounds(feature['geometry'])             # <<<<<<<<<<<<<<
8238  *             xmins.append(xmin)
8239  *             ymins.append(ymin)
8240  */
8241       __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_bounds); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 403, __pyx_L1_error)
8242       __Pyx_GOTREF(__pyx_t_7);
8243       __pyx_t_8 = __Pyx_PyObject_Dict_GetItem(__pyx_v_feature, __pyx_n_u_geometry); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 403, __pyx_L1_error)
8244       __Pyx_GOTREF(__pyx_t_8);
8245       __pyx_t_9 = NULL;
8246       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
8247         __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
8248         if (likely(__pyx_t_9)) {
8249           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
8250           __Pyx_INCREF(__pyx_t_9);
8251           __Pyx_INCREF(function);
8252           __Pyx_DECREF_SET(__pyx_t_7, function);
8253         }
8254       }
8255       __pyx_t_3 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_9, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8);
8256       __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
8257       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
8258       if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error)
8259       __Pyx_GOTREF(__pyx_t_3);
8260       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8261       if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
8262         PyObject* sequence = __pyx_t_3;
8263         Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
8264         if (unlikely(size != 4)) {
8265           if (size > 4) __Pyx_RaiseTooManyValuesError(4);
8266           else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
8267           __PYX_ERR(0, 403, __pyx_L1_error)
8268         }
8269         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8270         if (likely(PyTuple_CheckExact(sequence))) {
8271           __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0);
8272           __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1);
8273           __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2);
8274           __pyx_t_10 = PyTuple_GET_ITEM(sequence, 3);
8275         } else {
8276           __pyx_t_7 = PyList_GET_ITEM(sequence, 0);
8277           __pyx_t_8 = PyList_GET_ITEM(sequence, 1);
8278           __pyx_t_9 = PyList_GET_ITEM(sequence, 2);
8279           __pyx_t_10 = PyList_GET_ITEM(sequence, 3);
8280         }
8281         __Pyx_INCREF(__pyx_t_7);
8282         __Pyx_INCREF(__pyx_t_8);
8283         __Pyx_INCREF(__pyx_t_9);
8284         __Pyx_INCREF(__pyx_t_10);
8285         #else
8286         {
8287           Py_ssize_t i;
8288           PyObject** temps[4] = {&__pyx_t_7,&__pyx_t_8,&__pyx_t_9,&__pyx_t_10};
8289           for (i=0; i < 4; i++) {
8290             PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 403, __pyx_L1_error)
8291             __Pyx_GOTREF(item);
8292             *(temps[i]) = item;
8293           }
8294         }
8295         #endif
8296         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8297       } else {
8298         Py_ssize_t index = -1;
8299         PyObject** temps[4] = {&__pyx_t_7,&__pyx_t_8,&__pyx_t_9,&__pyx_t_10};
8300         __pyx_t_11 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 403, __pyx_L1_error)
8301         __Pyx_GOTREF(__pyx_t_11);
8302         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8303         __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
8304         for (index=0; index < 4; index++) {
8305           PyObject* item = __pyx_t_12(__pyx_t_11); if (unlikely(!item)) goto __pyx_L6_unpacking_failed;
8306           __Pyx_GOTREF(item);
8307           *(temps[index]) = item;
8308         }
8309         if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 4) < 0) __PYX_ERR(0, 403, __pyx_L1_error)
8310         __pyx_t_12 = NULL;
8311         __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
8312         goto __pyx_L7_unpacking_done;
8313         __pyx_L6_unpacking_failed:;
8314         __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
8315         __pyx_t_12 = NULL;
8316         if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
8317         __PYX_ERR(0, 403, __pyx_L1_error)
8318         __pyx_L7_unpacking_done:;
8319       }
8320       __Pyx_XDECREF_SET(__pyx_v_xmin, __pyx_t_7);
8321       __pyx_t_7 = 0;
8322       __Pyx_XDECREF_SET(__pyx_v_ymin, __pyx_t_8);
8323       __pyx_t_8 = 0;
8324       __Pyx_XDECREF_SET(__pyx_v_xmax, __pyx_t_9);
8325       __pyx_t_9 = 0;
8326       __Pyx_XDECREF_SET(__pyx_v_ymax, __pyx_t_10);
8327       __pyx_t_10 = 0;
8328 
8329       /* "rasterio/_features.pyx":404
8330  *         for feature in geometry['features']:
8331  *             xmin, ymin, xmax, ymax = _bounds(feature['geometry'])
8332  *             xmins.append(xmin)             # <<<<<<<<<<<<<<
8333  *             ymins.append(ymin)
8334  *             xmaxs.append(xmax)
8335  */
8336       __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_xmins, __pyx_v_xmin); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 404, __pyx_L1_error)
8337 
8338       /* "rasterio/_features.pyx":405
8339  *             xmin, ymin, xmax, ymax = _bounds(feature['geometry'])
8340  *             xmins.append(xmin)
8341  *             ymins.append(ymin)             # <<<<<<<<<<<<<<
8342  *             xmaxs.append(xmax)
8343  *             ymaxs.append(ymax)
8344  */
8345       __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ymins, __pyx_v_ymin); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 405, __pyx_L1_error)
8346 
8347       /* "rasterio/_features.pyx":406
8348  *             xmins.append(xmin)
8349  *             ymins.append(ymin)
8350  *             xmaxs.append(xmax)             # <<<<<<<<<<<<<<
8351  *             ymaxs.append(ymax)
8352  *         if north_up:
8353  */
8354       __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_xmaxs, __pyx_v_xmax); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 406, __pyx_L1_error)
8355 
8356       /* "rasterio/_features.pyx":407
8357  *             ymins.append(ymin)
8358  *             xmaxs.append(xmax)
8359  *             ymaxs.append(ymax)             # <<<<<<<<<<<<<<
8360  *         if north_up:
8361  *             return min(xmins), min(ymins), max(xmaxs), max(ymaxs)
8362  */
8363       __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ymaxs, __pyx_v_ymax); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 407, __pyx_L1_error)
8364 
8365       /* "rasterio/_features.pyx":402
8366  *         xmaxs = []
8367  *         ymaxs = []
8368  *         for feature in geometry['features']:             # <<<<<<<<<<<<<<
8369  *             xmin, ymin, xmax, ymax = _bounds(feature['geometry'])
8370  *             xmins.append(xmin)
8371  */
8372     }
8373     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8374 
8375     /* "rasterio/_features.pyx":408
8376  *             xmaxs.append(xmax)
8377  *             ymaxs.append(ymax)
8378  *         if north_up:             # <<<<<<<<<<<<<<
8379  *             return min(xmins), min(ymins), max(xmaxs), max(ymaxs)
8380  *         else:
8381  */
8382     __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_north_up); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 408, __pyx_L1_error)
8383     if (__pyx_t_2) {
8384 
8385       /* "rasterio/_features.pyx":409
8386  *             ymaxs.append(ymax)
8387  *         if north_up:
8388  *             return min(xmins), min(ymins), max(xmaxs), max(ymaxs)             # <<<<<<<<<<<<<<
8389  *         else:
8390  *             return min(xmins), max(ymaxs), max(xmaxs), min(ymins)
8391  */
8392       __Pyx_XDECREF(__pyx_r);
8393       __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_v_xmins); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 409, __pyx_L1_error)
8394       __Pyx_GOTREF(__pyx_t_4);
8395       __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_v_ymins); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L1_error)
8396       __Pyx_GOTREF(__pyx_t_3);
8397       __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_v_xmaxs); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 409, __pyx_L1_error)
8398       __Pyx_GOTREF(__pyx_t_10);
8399       __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_v_ymaxs); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 409, __pyx_L1_error)
8400       __Pyx_GOTREF(__pyx_t_9);
8401       __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 409, __pyx_L1_error)
8402       __Pyx_GOTREF(__pyx_t_8);
8403       __Pyx_GIVEREF(__pyx_t_4);
8404       PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
8405       __Pyx_GIVEREF(__pyx_t_3);
8406       PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_3);
8407       __Pyx_GIVEREF(__pyx_t_10);
8408       PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_10);
8409       __Pyx_GIVEREF(__pyx_t_9);
8410       PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_9);
8411       __pyx_t_4 = 0;
8412       __pyx_t_3 = 0;
8413       __pyx_t_10 = 0;
8414       __pyx_t_9 = 0;
8415       __pyx_r = __pyx_t_8;
8416       __pyx_t_8 = 0;
8417       goto __pyx_L0;
8418 
8419       /* "rasterio/_features.pyx":408
8420  *             xmaxs.append(xmax)
8421  *             ymaxs.append(ymax)
8422  *         if north_up:             # <<<<<<<<<<<<<<
8423  *             return min(xmins), min(ymins), max(xmaxs), max(ymaxs)
8424  *         else:
8425  */
8426     }
8427 
8428     /* "rasterio/_features.pyx":411
8429  *             return min(xmins), min(ymins), max(xmaxs), max(ymaxs)
8430  *         else:
8431  *             return min(xmins), max(ymaxs), max(xmaxs), min(ymins)             # <<<<<<<<<<<<<<
8432  *
8433  *     elif 'geometries' in geometry:
8434  */
8435     /*else*/ {
8436       __Pyx_XDECREF(__pyx_r);
8437       __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_v_xmins); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 411, __pyx_L1_error)
8438       __Pyx_GOTREF(__pyx_t_8);
8439       __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_v_ymaxs); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 411, __pyx_L1_error)
8440       __Pyx_GOTREF(__pyx_t_9);
8441       __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_v_xmaxs); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 411, __pyx_L1_error)
8442       __Pyx_GOTREF(__pyx_t_10);
8443       __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_v_ymins); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 411, __pyx_L1_error)
8444       __Pyx_GOTREF(__pyx_t_3);
8445       __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 411, __pyx_L1_error)
8446       __Pyx_GOTREF(__pyx_t_4);
8447       __Pyx_GIVEREF(__pyx_t_8);
8448       PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8);
8449       __Pyx_GIVEREF(__pyx_t_9);
8450       PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_9);
8451       __Pyx_GIVEREF(__pyx_t_10);
8452       PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_10);
8453       __Pyx_GIVEREF(__pyx_t_3);
8454       PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_3);
8455       __pyx_t_8 = 0;
8456       __pyx_t_9 = 0;
8457       __pyx_t_10 = 0;
8458       __pyx_t_3 = 0;
8459       __pyx_r = __pyx_t_4;
8460       __pyx_t_4 = 0;
8461       goto __pyx_L0;
8462     }
8463 
8464     /* "rasterio/_features.pyx":396
8465  *     """
8466  *
8467  *     if 'features' in geometry:             # <<<<<<<<<<<<<<
8468  *         # Input is a FeatureCollection
8469  *         xmins = []
8470  */
8471   }
8472 
8473   /* "rasterio/_features.pyx":413
8474  *             return min(xmins), max(ymaxs), max(xmaxs), min(ymins)
8475  *
8476  *     elif 'geometries' in geometry:             # <<<<<<<<<<<<<<
8477  *         # Input is a geometry collection
8478  *         xmins = []
8479  */
8480   __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_geometries, __pyx_v_geometry, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 413, __pyx_L1_error)
8481   __pyx_t_1 = (__pyx_t_2 != 0);
8482   if (__pyx_t_1) {
8483 
8484     /* "rasterio/_features.pyx":415
8485  *     elif 'geometries' in geometry:
8486  *         # Input is a geometry collection
8487  *         xmins = []             # <<<<<<<<<<<<<<
8488  *         ymins = []
8489  *         xmaxs = []
8490  */
8491     __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 415, __pyx_L1_error)
8492     __Pyx_GOTREF(__pyx_t_4);
8493     __pyx_v_xmins = ((PyObject*)__pyx_t_4);
8494     __pyx_t_4 = 0;
8495 
8496     /* "rasterio/_features.pyx":416
8497  *         # Input is a geometry collection
8498  *         xmins = []
8499  *         ymins = []             # <<<<<<<<<<<<<<
8500  *         xmaxs = []
8501  *         ymaxs = []
8502  */
8503     __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 416, __pyx_L1_error)
8504     __Pyx_GOTREF(__pyx_t_4);
8505     __pyx_v_ymins = ((PyObject*)__pyx_t_4);
8506     __pyx_t_4 = 0;
8507 
8508     /* "rasterio/_features.pyx":417
8509  *         xmins = []
8510  *         ymins = []
8511  *         xmaxs = []             # <<<<<<<<<<<<<<
8512  *         ymaxs = []
8513  *         for geometry in geometry['geometries']:
8514  */
8515     __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 417, __pyx_L1_error)
8516     __Pyx_GOTREF(__pyx_t_4);
8517     __pyx_v_xmaxs = ((PyObject*)__pyx_t_4);
8518     __pyx_t_4 = 0;
8519 
8520     /* "rasterio/_features.pyx":418
8521  *         ymins = []
8522  *         xmaxs = []
8523  *         ymaxs = []             # <<<<<<<<<<<<<<
8524  *         for geometry in geometry['geometries']:
8525  *             xmin, ymin, xmax, ymax = _bounds(geometry)
8526  */
8527     __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 418, __pyx_L1_error)
8528     __Pyx_GOTREF(__pyx_t_4);
8529     __pyx_v_ymaxs = ((PyObject*)__pyx_t_4);
8530     __pyx_t_4 = 0;
8531 
8532     /* "rasterio/_features.pyx":419
8533  *         xmaxs = []
8534  *         ymaxs = []
8535  *         for geometry in geometry['geometries']:             # <<<<<<<<<<<<<<
8536  *             xmin, ymin, xmax, ymax = _bounds(geometry)
8537  *             xmins.append(xmin)
8538  */
8539     __pyx_t_4 = __Pyx_PyObject_Dict_GetItem(__pyx_v_geometry, __pyx_n_u_geometries); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 419, __pyx_L1_error)
8540     __Pyx_GOTREF(__pyx_t_4);
8541     if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
8542       __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
8543       __pyx_t_6 = NULL;
8544     } else {
8545       __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 419, __pyx_L1_error)
8546       __Pyx_GOTREF(__pyx_t_3);
8547       __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 419, __pyx_L1_error)
8548     }
8549     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8550     for (;;) {
8551       if (likely(!__pyx_t_6)) {
8552         if (likely(PyList_CheckExact(__pyx_t_3))) {
8553           if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
8554           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8555           __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 419, __pyx_L1_error)
8556           #else
8557           __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 419, __pyx_L1_error)
8558           __Pyx_GOTREF(__pyx_t_4);
8559           #endif
8560         } else {
8561           if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
8562           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8563           __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 419, __pyx_L1_error)
8564           #else
8565           __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 419, __pyx_L1_error)
8566           __Pyx_GOTREF(__pyx_t_4);
8567           #endif
8568         }
8569       } else {
8570         __pyx_t_4 = __pyx_t_6(__pyx_t_3);
8571         if (unlikely(!__pyx_t_4)) {
8572           PyObject* exc_type = PyErr_Occurred();
8573           if (exc_type) {
8574             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
8575             else __PYX_ERR(0, 419, __pyx_L1_error)
8576           }
8577           break;
8578         }
8579         __Pyx_GOTREF(__pyx_t_4);
8580       }
8581       __Pyx_DECREF_SET(__pyx_v_geometry, __pyx_t_4);
8582       __pyx_t_4 = 0;
8583 
8584       /* "rasterio/_features.pyx":420
8585  *         ymaxs = []
8586  *         for geometry in geometry['geometries']:
8587  *             xmin, ymin, xmax, ymax = _bounds(geometry)             # <<<<<<<<<<<<<<
8588  *             xmins.append(xmin)
8589  *             ymins.append(ymin)
8590  */
8591       __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_bounds); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 420, __pyx_L1_error)
8592       __Pyx_GOTREF(__pyx_t_10);
8593       __pyx_t_9 = NULL;
8594       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
8595         __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
8596         if (likely(__pyx_t_9)) {
8597           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
8598           __Pyx_INCREF(__pyx_t_9);
8599           __Pyx_INCREF(function);
8600           __Pyx_DECREF_SET(__pyx_t_10, function);
8601         }
8602       }
8603       __pyx_t_4 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_9, __pyx_v_geometry) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_v_geometry);
8604       __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
8605       if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 420, __pyx_L1_error)
8606       __Pyx_GOTREF(__pyx_t_4);
8607       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
8608       if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
8609         PyObject* sequence = __pyx_t_4;
8610         Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
8611         if (unlikely(size != 4)) {
8612           if (size > 4) __Pyx_RaiseTooManyValuesError(4);
8613           else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
8614           __PYX_ERR(0, 420, __pyx_L1_error)
8615         }
8616         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8617         if (likely(PyTuple_CheckExact(sequence))) {
8618           __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0);
8619           __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1);
8620           __pyx_t_8 = PyTuple_GET_ITEM(sequence, 2);
8621           __pyx_t_7 = PyTuple_GET_ITEM(sequence, 3);
8622         } else {
8623           __pyx_t_10 = PyList_GET_ITEM(sequence, 0);
8624           __pyx_t_9 = PyList_GET_ITEM(sequence, 1);
8625           __pyx_t_8 = PyList_GET_ITEM(sequence, 2);
8626           __pyx_t_7 = PyList_GET_ITEM(sequence, 3);
8627         }
8628         __Pyx_INCREF(__pyx_t_10);
8629         __Pyx_INCREF(__pyx_t_9);
8630         __Pyx_INCREF(__pyx_t_8);
8631         __Pyx_INCREF(__pyx_t_7);
8632         #else
8633         {
8634           Py_ssize_t i;
8635           PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_9,&__pyx_t_8,&__pyx_t_7};
8636           for (i=0; i < 4; i++) {
8637             PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 420, __pyx_L1_error)
8638             __Pyx_GOTREF(item);
8639             *(temps[i]) = item;
8640           }
8641         }
8642         #endif
8643         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8644       } else {
8645         Py_ssize_t index = -1;
8646         PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_9,&__pyx_t_8,&__pyx_t_7};
8647         __pyx_t_11 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 420, __pyx_L1_error)
8648         __Pyx_GOTREF(__pyx_t_11);
8649         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8650         __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
8651         for (index=0; index < 4; index++) {
8652           PyObject* item = __pyx_t_12(__pyx_t_11); if (unlikely(!item)) goto __pyx_L11_unpacking_failed;
8653           __Pyx_GOTREF(item);
8654           *(temps[index]) = item;
8655         }
8656         if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 4) < 0) __PYX_ERR(0, 420, __pyx_L1_error)
8657         __pyx_t_12 = NULL;
8658         __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
8659         goto __pyx_L12_unpacking_done;
8660         __pyx_L11_unpacking_failed:;
8661         __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
8662         __pyx_t_12 = NULL;
8663         if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
8664         __PYX_ERR(0, 420, __pyx_L1_error)
8665         __pyx_L12_unpacking_done:;
8666       }
8667       __Pyx_XDECREF_SET(__pyx_v_xmin, __pyx_t_10);
8668       __pyx_t_10 = 0;
8669       __Pyx_XDECREF_SET(__pyx_v_ymin, __pyx_t_9);
8670       __pyx_t_9 = 0;
8671       __Pyx_XDECREF_SET(__pyx_v_xmax, __pyx_t_8);
8672       __pyx_t_8 = 0;
8673       __Pyx_XDECREF_SET(__pyx_v_ymax, __pyx_t_7);
8674       __pyx_t_7 = 0;
8675 
8676       /* "rasterio/_features.pyx":421
8677  *         for geometry in geometry['geometries']:
8678  *             xmin, ymin, xmax, ymax = _bounds(geometry)
8679  *             xmins.append(xmin)             # <<<<<<<<<<<<<<
8680  *             ymins.append(ymin)
8681  *             xmaxs.append(xmax)
8682  */
8683       __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_xmins, __pyx_v_xmin); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 421, __pyx_L1_error)
8684 
8685       /* "rasterio/_features.pyx":422
8686  *             xmin, ymin, xmax, ymax = _bounds(geometry)
8687  *             xmins.append(xmin)
8688  *             ymins.append(ymin)             # <<<<<<<<<<<<<<
8689  *             xmaxs.append(xmax)
8690  *             ymaxs.append(ymax)
8691  */
8692       __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ymins, __pyx_v_ymin); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 422, __pyx_L1_error)
8693 
8694       /* "rasterio/_features.pyx":423
8695  *             xmins.append(xmin)
8696  *             ymins.append(ymin)
8697  *             xmaxs.append(xmax)             # <<<<<<<<<<<<<<
8698  *             ymaxs.append(ymax)
8699  *         if north_up:
8700  */
8701       __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_xmaxs, __pyx_v_xmax); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 423, __pyx_L1_error)
8702 
8703       /* "rasterio/_features.pyx":424
8704  *             ymins.append(ymin)
8705  *             xmaxs.append(xmax)
8706  *             ymaxs.append(ymax)             # <<<<<<<<<<<<<<
8707  *         if north_up:
8708  *             return min(xmins), min(ymins), max(xmaxs), max(ymaxs)
8709  */
8710       __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_ymaxs, __pyx_v_ymax); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 424, __pyx_L1_error)
8711 
8712       /* "rasterio/_features.pyx":419
8713  *         xmaxs = []
8714  *         ymaxs = []
8715  *         for geometry in geometry['geometries']:             # <<<<<<<<<<<<<<
8716  *             xmin, ymin, xmax, ymax = _bounds(geometry)
8717  *             xmins.append(xmin)
8718  */
8719     }
8720     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8721 
8722     /* "rasterio/_features.pyx":425
8723  *             xmaxs.append(xmax)
8724  *             ymaxs.append(ymax)
8725  *         if north_up:             # <<<<<<<<<<<<<<
8726  *             return min(xmins), min(ymins), max(xmaxs), max(ymaxs)
8727  *         else:
8728  */
8729     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_north_up); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 425, __pyx_L1_error)
8730     if (__pyx_t_1) {
8731 
8732       /* "rasterio/_features.pyx":426
8733  *             ymaxs.append(ymax)
8734  *         if north_up:
8735  *             return min(xmins), min(ymins), max(xmaxs), max(ymaxs)             # <<<<<<<<<<<<<<
8736  *         else:
8737  *             return min(xmins), max(ymaxs), max(xmaxs), min(ymins)
8738  */
8739       __Pyx_XDECREF(__pyx_r);
8740       __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_v_xmins); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error)
8741       __Pyx_GOTREF(__pyx_t_3);
8742       __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_v_ymins); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 426, __pyx_L1_error)
8743       __Pyx_GOTREF(__pyx_t_4);
8744       __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_v_xmaxs); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 426, __pyx_L1_error)
8745       __Pyx_GOTREF(__pyx_t_7);
8746       __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_v_ymaxs); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 426, __pyx_L1_error)
8747       __Pyx_GOTREF(__pyx_t_8);
8748       __pyx_t_9 = PyTuple_New(4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 426, __pyx_L1_error)
8749       __Pyx_GOTREF(__pyx_t_9);
8750       __Pyx_GIVEREF(__pyx_t_3);
8751       PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3);
8752       __Pyx_GIVEREF(__pyx_t_4);
8753       PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_4);
8754       __Pyx_GIVEREF(__pyx_t_7);
8755       PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_7);
8756       __Pyx_GIVEREF(__pyx_t_8);
8757       PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_8);
8758       __pyx_t_3 = 0;
8759       __pyx_t_4 = 0;
8760       __pyx_t_7 = 0;
8761       __pyx_t_8 = 0;
8762       __pyx_r = __pyx_t_9;
8763       __pyx_t_9 = 0;
8764       goto __pyx_L0;
8765 
8766       /* "rasterio/_features.pyx":425
8767  *             xmaxs.append(xmax)
8768  *             ymaxs.append(ymax)
8769  *         if north_up:             # <<<<<<<<<<<<<<
8770  *             return min(xmins), min(ymins), max(xmaxs), max(ymaxs)
8771  *         else:
8772  */
8773     }
8774 
8775     /* "rasterio/_features.pyx":428
8776  *             return min(xmins), min(ymins), max(xmaxs), max(ymaxs)
8777  *         else:
8778  *             return min(xmins), max(ymaxs), max(xmaxs), min(ymins)             # <<<<<<<<<<<<<<
8779  *
8780  *     elif 'coordinates' in geometry:
8781  */
8782     /*else*/ {
8783       __Pyx_XDECREF(__pyx_r);
8784       __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_v_xmins); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 428, __pyx_L1_error)
8785       __Pyx_GOTREF(__pyx_t_9);
8786       __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_v_ymaxs); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 428, __pyx_L1_error)
8787       __Pyx_GOTREF(__pyx_t_8);
8788       __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_v_xmaxs); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 428, __pyx_L1_error)
8789       __Pyx_GOTREF(__pyx_t_7);
8790       __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_v_ymins); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 428, __pyx_L1_error)
8791       __Pyx_GOTREF(__pyx_t_4);
8792       __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 428, __pyx_L1_error)
8793       __Pyx_GOTREF(__pyx_t_3);
8794       __Pyx_GIVEREF(__pyx_t_9);
8795       PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9);
8796       __Pyx_GIVEREF(__pyx_t_8);
8797       PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_8);
8798       __Pyx_GIVEREF(__pyx_t_7);
8799       PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_7);
8800       __Pyx_GIVEREF(__pyx_t_4);
8801       PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_4);
8802       __pyx_t_9 = 0;
8803       __pyx_t_8 = 0;
8804       __pyx_t_7 = 0;
8805       __pyx_t_4 = 0;
8806       __pyx_r = __pyx_t_3;
8807       __pyx_t_3 = 0;
8808       goto __pyx_L0;
8809     }
8810 
8811     /* "rasterio/_features.pyx":413
8812  *             return min(xmins), max(ymaxs), max(xmaxs), min(ymins)
8813  *
8814  *     elif 'geometries' in geometry:             # <<<<<<<<<<<<<<
8815  *         # Input is a geometry collection
8816  *         xmins = []
8817  */
8818   }
8819 
8820   /* "rasterio/_features.pyx":430
8821  *             return min(xmins), max(ymaxs), max(xmaxs), min(ymins)
8822  *
8823  *     elif 'coordinates' in geometry:             # <<<<<<<<<<<<<<
8824  *         # Input is a singular geometry object
8825  *         if transform is not None:
8826  */
8827   __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_coordinates, __pyx_v_geometry, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 430, __pyx_L1_error)
8828   __pyx_t_2 = (__pyx_t_1 != 0);
8829   if (__pyx_t_2) {
8830 
8831     /* "rasterio/_features.pyx":432
8832  *     elif 'coordinates' in geometry:
8833  *         # Input is a singular geometry object
8834  *         if transform is not None:             # <<<<<<<<<<<<<<
8835  *             xyz = list(_explode(geometry['coordinates']))
8836  *             xyz_px = [transform * point for point in xyz]
8837  */
8838     __pyx_t_2 = (__pyx_v_transform != Py_None);
8839     __pyx_t_1 = (__pyx_t_2 != 0);
8840     if (__pyx_t_1) {
8841 
8842       /* "rasterio/_features.pyx":433
8843  *         # Input is a singular geometry object
8844  *         if transform is not None:
8845  *             xyz = list(_explode(geometry['coordinates']))             # <<<<<<<<<<<<<<
8846  *             xyz_px = [transform * point for point in xyz]
8847  *             xyz = tuple(zip(*xyz_px))
8848  */
8849       __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_explode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 433, __pyx_L1_error)
8850       __Pyx_GOTREF(__pyx_t_4);
8851       __pyx_t_7 = __Pyx_PyObject_Dict_GetItem(__pyx_v_geometry, __pyx_n_u_coordinates); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 433, __pyx_L1_error)
8852       __Pyx_GOTREF(__pyx_t_7);
8853       __pyx_t_8 = NULL;
8854       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
8855         __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
8856         if (likely(__pyx_t_8)) {
8857           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
8858           __Pyx_INCREF(__pyx_t_8);
8859           __Pyx_INCREF(function);
8860           __Pyx_DECREF_SET(__pyx_t_4, function);
8861         }
8862       }
8863       __pyx_t_3 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7);
8864       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
8865       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8866       if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 433, __pyx_L1_error)
8867       __Pyx_GOTREF(__pyx_t_3);
8868       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8869       __pyx_t_4 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 433, __pyx_L1_error)
8870       __Pyx_GOTREF(__pyx_t_4);
8871       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8872       __pyx_v_xyz = __pyx_t_4;
8873       __pyx_t_4 = 0;
8874 
8875       /* "rasterio/_features.pyx":434
8876  *         if transform is not None:
8877  *             xyz = list(_explode(geometry['coordinates']))
8878  *             xyz_px = [transform * point for point in xyz]             # <<<<<<<<<<<<<<
8879  *             xyz = tuple(zip(*xyz_px))
8880  *             return min(xyz[0]), max(xyz[1]), max(xyz[0]), min(xyz[1])
8881  */
8882       { /* enter inner scope */
8883         __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 434, __pyx_L17_error)
8884         __Pyx_GOTREF(__pyx_t_4);
8885         if (likely(PyList_CheckExact(__pyx_v_xyz)) || PyTuple_CheckExact(__pyx_v_xyz)) {
8886           __pyx_t_3 = __pyx_v_xyz; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
8887           __pyx_t_6 = NULL;
8888         } else {
8889           __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_xyz); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 434, __pyx_L17_error)
8890           __Pyx_GOTREF(__pyx_t_3);
8891           __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 434, __pyx_L17_error)
8892         }
8893         for (;;) {
8894           if (likely(!__pyx_t_6)) {
8895             if (likely(PyList_CheckExact(__pyx_t_3))) {
8896               if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
8897               #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8898               __pyx_t_7 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 434, __pyx_L17_error)
8899               #else
8900               __pyx_t_7 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 434, __pyx_L17_error)
8901               __Pyx_GOTREF(__pyx_t_7);
8902               #endif
8903             } else {
8904               if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
8905               #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8906               __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 434, __pyx_L17_error)
8907               #else
8908               __pyx_t_7 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 434, __pyx_L17_error)
8909               __Pyx_GOTREF(__pyx_t_7);
8910               #endif
8911             }
8912           } else {
8913             __pyx_t_7 = __pyx_t_6(__pyx_t_3);
8914             if (unlikely(!__pyx_t_7)) {
8915               PyObject* exc_type = PyErr_Occurred();
8916               if (exc_type) {
8917                 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
8918                 else __PYX_ERR(0, 434, __pyx_L17_error)
8919               }
8920               break;
8921             }
8922             __Pyx_GOTREF(__pyx_t_7);
8923           }
8924           __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_point, __pyx_t_7);
8925           __pyx_t_7 = 0;
8926           __pyx_t_7 = PyNumber_Multiply(__pyx_v_transform, __pyx_8genexpr1__pyx_v_point); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 434, __pyx_L17_error)
8927           __Pyx_GOTREF(__pyx_t_7);
8928           if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 434, __pyx_L17_error)
8929           __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8930         }
8931         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8932         __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_point); __pyx_8genexpr1__pyx_v_point = 0;
8933         goto __pyx_L20_exit_scope;
8934         __pyx_L17_error:;
8935         __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_point); __pyx_8genexpr1__pyx_v_point = 0;
8936         goto __pyx_L1_error;
8937         __pyx_L20_exit_scope:;
8938       } /* exit inner scope */
8939       __pyx_v_xyz_px = ((PyObject*)__pyx_t_4);
8940       __pyx_t_4 = 0;
8941 
8942       /* "rasterio/_features.pyx":435
8943  *             xyz = list(_explode(geometry['coordinates']))
8944  *             xyz_px = [transform * point for point in xyz]
8945  *             xyz = tuple(zip(*xyz_px))             # <<<<<<<<<<<<<<
8946  *             return min(xyz[0]), max(xyz[1]), max(xyz[0]), min(xyz[1])
8947  *         else:
8948  */
8949       __pyx_t_4 = PySequence_Tuple(__pyx_v_xyz_px); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 435, __pyx_L1_error)
8950       __Pyx_GOTREF(__pyx_t_4);
8951       __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 435, __pyx_L1_error)
8952       __Pyx_GOTREF(__pyx_t_3);
8953       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8954       __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 435, __pyx_L1_error)
8955       __Pyx_GOTREF(__pyx_t_4);
8956       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8957       __Pyx_DECREF_SET(__pyx_v_xyz, __pyx_t_4);
8958       __pyx_t_4 = 0;
8959 
8960       /* "rasterio/_features.pyx":436
8961  *             xyz_px = [transform * point for point in xyz]
8962  *             xyz = tuple(zip(*xyz_px))
8963  *             return min(xyz[0]), max(xyz[1]), max(xyz[0]), min(xyz[1])             # <<<<<<<<<<<<<<
8964  *         else:
8965  *             xyz = tuple(zip(*list(_explode(geometry['coordinates']))))
8966  */
8967       __Pyx_XDECREF(__pyx_r);
8968       __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_xyz, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 436, __pyx_L1_error)
8969       __Pyx_GOTREF(__pyx_t_4);
8970       __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 436, __pyx_L1_error)
8971       __Pyx_GOTREF(__pyx_t_3);
8972       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8973       __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_xyz, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 436, __pyx_L1_error)
8974       __Pyx_GOTREF(__pyx_t_4);
8975       __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 436, __pyx_L1_error)
8976       __Pyx_GOTREF(__pyx_t_7);
8977       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8978       __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_xyz, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 436, __pyx_L1_error)
8979       __Pyx_GOTREF(__pyx_t_4);
8980       __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 436, __pyx_L1_error)
8981       __Pyx_GOTREF(__pyx_t_8);
8982       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8983       __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_xyz, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 436, __pyx_L1_error)
8984       __Pyx_GOTREF(__pyx_t_4);
8985       __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 436, __pyx_L1_error)
8986       __Pyx_GOTREF(__pyx_t_9);
8987       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
8988       __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 436, __pyx_L1_error)
8989       __Pyx_GOTREF(__pyx_t_4);
8990       __Pyx_GIVEREF(__pyx_t_3);
8991       PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
8992       __Pyx_GIVEREF(__pyx_t_7);
8993       PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_7);
8994       __Pyx_GIVEREF(__pyx_t_8);
8995       PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_8);
8996       __Pyx_GIVEREF(__pyx_t_9);
8997       PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_9);
8998       __pyx_t_3 = 0;
8999       __pyx_t_7 = 0;
9000       __pyx_t_8 = 0;
9001       __pyx_t_9 = 0;
9002       __pyx_r = __pyx_t_4;
9003       __pyx_t_4 = 0;
9004       goto __pyx_L0;
9005 
9006       /* "rasterio/_features.pyx":432
9007  *     elif 'coordinates' in geometry:
9008  *         # Input is a singular geometry object
9009  *         if transform is not None:             # <<<<<<<<<<<<<<
9010  *             xyz = list(_explode(geometry['coordinates']))
9011  *             xyz_px = [transform * point for point in xyz]
9012  */
9013     }
9014 
9015     /* "rasterio/_features.pyx":438
9016  *             return min(xyz[0]), max(xyz[1]), max(xyz[0]), min(xyz[1])
9017  *         else:
9018  *             xyz = tuple(zip(*list(_explode(geometry['coordinates']))))             # <<<<<<<<<<<<<<
9019  *             if north_up:
9020  *                 return min(xyz[0]), min(xyz[1]), max(xyz[0]), max(xyz[1])
9021  */
9022     /*else*/ {
9023       __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_explode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 438, __pyx_L1_error)
9024       __Pyx_GOTREF(__pyx_t_9);
9025       __pyx_t_8 = __Pyx_PyObject_Dict_GetItem(__pyx_v_geometry, __pyx_n_u_coordinates); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 438, __pyx_L1_error)
9026       __Pyx_GOTREF(__pyx_t_8);
9027       __pyx_t_7 = NULL;
9028       if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
9029         __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
9030         if (likely(__pyx_t_7)) {
9031           PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
9032           __Pyx_INCREF(__pyx_t_7);
9033           __Pyx_INCREF(function);
9034           __Pyx_DECREF_SET(__pyx_t_9, function);
9035         }
9036       }
9037       __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_7, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8);
9038       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
9039       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
9040       if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 438, __pyx_L1_error)
9041       __Pyx_GOTREF(__pyx_t_4);
9042       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
9043       __pyx_t_9 = PySequence_List(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 438, __pyx_L1_error)
9044       __Pyx_GOTREF(__pyx_t_9);
9045       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9046       __pyx_t_4 = PySequence_Tuple(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 438, __pyx_L1_error)
9047       __Pyx_GOTREF(__pyx_t_4);
9048       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
9049       __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_4, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 438, __pyx_L1_error)
9050       __Pyx_GOTREF(__pyx_t_9);
9051       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9052       __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 438, __pyx_L1_error)
9053       __Pyx_GOTREF(__pyx_t_4);
9054       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
9055       __pyx_v_xyz = __pyx_t_4;
9056       __pyx_t_4 = 0;
9057 
9058       /* "rasterio/_features.pyx":439
9059  *         else:
9060  *             xyz = tuple(zip(*list(_explode(geometry['coordinates']))))
9061  *             if north_up:             # <<<<<<<<<<<<<<
9062  *                 return min(xyz[0]), min(xyz[1]), max(xyz[0]), max(xyz[1])
9063  *             else:
9064  */
9065       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_north_up); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 439, __pyx_L1_error)
9066       if (__pyx_t_1) {
9067 
9068         /* "rasterio/_features.pyx":440
9069  *             xyz = tuple(zip(*list(_explode(geometry['coordinates']))))
9070  *             if north_up:
9071  *                 return min(xyz[0]), min(xyz[1]), max(xyz[0]), max(xyz[1])             # <<<<<<<<<<<<<<
9072  *             else:
9073  *                 return min(xyz[0]), max(xyz[1]), max(xyz[0]), min(xyz[1])
9074  */
9075         __Pyx_XDECREF(__pyx_r);
9076         __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_xyz, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 440, __pyx_L1_error)
9077         __Pyx_GOTREF(__pyx_t_4);
9078         __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 440, __pyx_L1_error)
9079         __Pyx_GOTREF(__pyx_t_9);
9080         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9081         __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_xyz, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 440, __pyx_L1_error)
9082         __Pyx_GOTREF(__pyx_t_4);
9083         __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 440, __pyx_L1_error)
9084         __Pyx_GOTREF(__pyx_t_8);
9085         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9086         __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_xyz, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 440, __pyx_L1_error)
9087         __Pyx_GOTREF(__pyx_t_4);
9088         __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 440, __pyx_L1_error)
9089         __Pyx_GOTREF(__pyx_t_7);
9090         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9091         __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_xyz, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 440, __pyx_L1_error)
9092         __Pyx_GOTREF(__pyx_t_4);
9093         __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 440, __pyx_L1_error)
9094         __Pyx_GOTREF(__pyx_t_3);
9095         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9096         __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 440, __pyx_L1_error)
9097         __Pyx_GOTREF(__pyx_t_4);
9098         __Pyx_GIVEREF(__pyx_t_9);
9099         PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_9);
9100         __Pyx_GIVEREF(__pyx_t_8);
9101         PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_8);
9102         __Pyx_GIVEREF(__pyx_t_7);
9103         PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_7);
9104         __Pyx_GIVEREF(__pyx_t_3);
9105         PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_3);
9106         __pyx_t_9 = 0;
9107         __pyx_t_8 = 0;
9108         __pyx_t_7 = 0;
9109         __pyx_t_3 = 0;
9110         __pyx_r = __pyx_t_4;
9111         __pyx_t_4 = 0;
9112         goto __pyx_L0;
9113 
9114         /* "rasterio/_features.pyx":439
9115  *         else:
9116  *             xyz = tuple(zip(*list(_explode(geometry['coordinates']))))
9117  *             if north_up:             # <<<<<<<<<<<<<<
9118  *                 return min(xyz[0]), min(xyz[1]), max(xyz[0]), max(xyz[1])
9119  *             else:
9120  */
9121       }
9122 
9123       /* "rasterio/_features.pyx":442
9124  *                 return min(xyz[0]), min(xyz[1]), max(xyz[0]), max(xyz[1])
9125  *             else:
9126  *                 return min(xyz[0]), max(xyz[1]), max(xyz[0]), min(xyz[1])             # <<<<<<<<<<<<<<
9127  *
9128  *     # all valid inputs returned above, so whatever falls through is an error
9129  */
9130       /*else*/ {
9131         __Pyx_XDECREF(__pyx_r);
9132         __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_xyz, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 442, __pyx_L1_error)
9133         __Pyx_GOTREF(__pyx_t_4);
9134         __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 442, __pyx_L1_error)
9135         __Pyx_GOTREF(__pyx_t_3);
9136         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9137         __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_xyz, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 442, __pyx_L1_error)
9138         __Pyx_GOTREF(__pyx_t_4);
9139         __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 442, __pyx_L1_error)
9140         __Pyx_GOTREF(__pyx_t_7);
9141         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9142         __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_xyz, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 442, __pyx_L1_error)
9143         __Pyx_GOTREF(__pyx_t_4);
9144         __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 442, __pyx_L1_error)
9145         __Pyx_GOTREF(__pyx_t_8);
9146         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9147         __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_xyz, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 442, __pyx_L1_error)
9148         __Pyx_GOTREF(__pyx_t_4);
9149         __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 442, __pyx_L1_error)
9150         __Pyx_GOTREF(__pyx_t_9);
9151         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9152         __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 442, __pyx_L1_error)
9153         __Pyx_GOTREF(__pyx_t_4);
9154         __Pyx_GIVEREF(__pyx_t_3);
9155         PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
9156         __Pyx_GIVEREF(__pyx_t_7);
9157         PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_7);
9158         __Pyx_GIVEREF(__pyx_t_8);
9159         PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_8);
9160         __Pyx_GIVEREF(__pyx_t_9);
9161         PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_9);
9162         __pyx_t_3 = 0;
9163         __pyx_t_7 = 0;
9164         __pyx_t_8 = 0;
9165         __pyx_t_9 = 0;
9166         __pyx_r = __pyx_t_4;
9167         __pyx_t_4 = 0;
9168         goto __pyx_L0;
9169       }
9170     }
9171 
9172     /* "rasterio/_features.pyx":430
9173  *             return min(xmins), max(ymaxs), max(xmaxs), min(ymins)
9174  *
9175  *     elif 'coordinates' in geometry:             # <<<<<<<<<<<<<<
9176  *         # Input is a singular geometry object
9177  *         if transform is not None:
9178  */
9179   }
9180 
9181   /* "rasterio/_features.pyx":445
9182  *
9183  *     # all valid inputs returned above, so whatever falls through is an error
9184  *     raise ValueError(             # <<<<<<<<<<<<<<
9185  *             "geometry must be a GeoJSON-like geometry, GeometryCollection, "
9186  *             "or FeatureCollection"
9187  */
9188   __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 445, __pyx_L1_error)
9189   __Pyx_GOTREF(__pyx_t_4);
9190   __Pyx_Raise(__pyx_t_4, 0, 0, 0);
9191   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
9192   __PYX_ERR(0, 445, __pyx_L1_error)
9193 
9194   /* "rasterio/_features.pyx":384
9195  *
9196  *
9197  * def _bounds(geometry, north_up=True, transform=None):             # <<<<<<<<<<<<<<
9198  *     """Bounding box of a GeoJSON geometry, GeometryCollection, or FeatureCollection.
9199  *
9200  */
9201 
9202   /* function exit code */
9203   __pyx_L1_error:;
9204   __Pyx_XDECREF(__pyx_t_3);
9205   __Pyx_XDECREF(__pyx_t_4);
9206   __Pyx_XDECREF(__pyx_t_7);
9207   __Pyx_XDECREF(__pyx_t_8);
9208   __Pyx_XDECREF(__pyx_t_9);
9209   __Pyx_XDECREF(__pyx_t_10);
9210   __Pyx_XDECREF(__pyx_t_11);
9211   __Pyx_AddTraceback("rasterio._features._bounds", __pyx_clineno, __pyx_lineno, __pyx_filename);
9212   __pyx_r = NULL;
9213   __pyx_L0:;
9214   __Pyx_XDECREF(__pyx_v_xmins);
9215   __Pyx_XDECREF(__pyx_v_ymins);
9216   __Pyx_XDECREF(__pyx_v_xmaxs);
9217   __Pyx_XDECREF(__pyx_v_ymaxs);
9218   __Pyx_XDECREF(__pyx_v_feature);
9219   __Pyx_XDECREF(__pyx_v_xmin);
9220   __Pyx_XDECREF(__pyx_v_ymin);
9221   __Pyx_XDECREF(__pyx_v_xmax);
9222   __Pyx_XDECREF(__pyx_v_ymax);
9223   __Pyx_XDECREF(__pyx_v_xyz);
9224   __Pyx_XDECREF(__pyx_v_xyz_px);
9225   __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_point);
9226   __Pyx_XDECREF(__pyx_v_geometry);
9227   __Pyx_XGIVEREF(__pyx_r);
9228   __Pyx_RefNannyFinishContext();
9229   return __pyx_r;
9230 }
9231 
9232 /* "rasterio/_features.pyx":480
9233  *
9234  *
9235  * cdef _deleteOgrGeom(OGRGeometryH geom):             # <<<<<<<<<<<<<<
9236  *     """Delete an OGR geometry"""
9237  *     if geom != NULL:
9238  */
9239 
__pyx_f_8rasterio_9_features__deleteOgrGeom(OGRGeometryH __pyx_v_geom)9240 static PyObject *__pyx_f_8rasterio_9_features__deleteOgrGeom(OGRGeometryH __pyx_v_geom) {
9241   PyObject *__pyx_r = NULL;
9242   __Pyx_RefNannyDeclarations
9243   int __pyx_t_1;
9244   __Pyx_RefNannySetupContext("_deleteOgrGeom", 0);
9245 
9246   /* "rasterio/_features.pyx":482
9247  * cdef _deleteOgrGeom(OGRGeometryH geom):
9248  *     """Delete an OGR geometry"""
9249  *     if geom != NULL:             # <<<<<<<<<<<<<<
9250  *         OGR_G_DestroyGeometry(geom)
9251  *     geom = NULL
9252  */
9253   __pyx_t_1 = ((__pyx_v_geom != NULL) != 0);
9254   if (__pyx_t_1) {
9255 
9256     /* "rasterio/_features.pyx":483
9257  *     """Delete an OGR geometry"""
9258  *     if geom != NULL:
9259  *         OGR_G_DestroyGeometry(geom)             # <<<<<<<<<<<<<<
9260  *     geom = NULL
9261  *
9262  */
9263     OGR_G_DestroyGeometry(__pyx_v_geom);
9264 
9265     /* "rasterio/_features.pyx":482
9266  * cdef _deleteOgrGeom(OGRGeometryH geom):
9267  *     """Delete an OGR geometry"""
9268  *     if geom != NULL:             # <<<<<<<<<<<<<<
9269  *         OGR_G_DestroyGeometry(geom)
9270  *     geom = NULL
9271  */
9272   }
9273 
9274   /* "rasterio/_features.pyx":484
9275  *     if geom != NULL:
9276  *         OGR_G_DestroyGeometry(geom)
9277  *     geom = NULL             # <<<<<<<<<<<<<<
9278  *
9279  *
9280  */
9281   __pyx_v_geom = NULL;
9282 
9283   /* "rasterio/_features.pyx":480
9284  *
9285  *
9286  * cdef _deleteOgrGeom(OGRGeometryH geom):             # <<<<<<<<<<<<<<
9287  *     """Delete an OGR geometry"""
9288  *     if geom != NULL:
9289  */
9290 
9291   /* function exit code */
9292   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
9293   __Pyx_XGIVEREF(__pyx_r);
9294   __Pyx_RefNannyFinishContext();
9295   return __pyx_r;
9296 }
9297 
9298 /* "rasterio/_features.pyx":490
9299  *     """Builds a GeoJSON (Fiona-style) geometry from an OGR geometry."""
9300  *
9301  *     cdef _buildCoords(self, OGRGeometryH geom):             # <<<<<<<<<<<<<<
9302  *         # Build a coordinate sequence
9303  *         cdef int i
9304  */
9305 
__pyx_f_8rasterio_9_features_11GeomBuilder__buildCoords(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self,OGRGeometryH __pyx_v_geom)9306 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildCoords(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, OGRGeometryH __pyx_v_geom) {
9307   int __pyx_v_i;
9308   int __pyx_v_npoints;
9309   PyObject *__pyx_v_coords = NULL;
9310   PyObject *__pyx_v_values = NULL;
9311   PyObject *__pyx_r = NULL;
9312   __Pyx_RefNannyDeclarations
9313   int __pyx_t_1;
9314   PyObject *__pyx_t_2 = NULL;
9315   int __pyx_t_3;
9316   int __pyx_t_4;
9317   int __pyx_t_5;
9318   PyObject *__pyx_t_6 = NULL;
9319   PyObject *__pyx_t_7 = NULL;
9320   int __pyx_t_8;
9321   int __pyx_lineno = 0;
9322   const char *__pyx_filename = NULL;
9323   int __pyx_clineno = 0;
9324   __Pyx_RefNannySetupContext("_buildCoords", 0);
9325 
9326   /* "rasterio/_features.pyx":493
9327  *         # Build a coordinate sequence
9328  *         cdef int i
9329  *         if geom == NULL:             # <<<<<<<<<<<<<<
9330  *             raise ValueError("Null geom")
9331  *         npoints = OGR_G_GetPointCount(geom)
9332  */
9333   __pyx_t_1 = ((__pyx_v_geom == NULL) != 0);
9334   if (unlikely(__pyx_t_1)) {
9335 
9336     /* "rasterio/_features.pyx":494
9337  *         cdef int i
9338  *         if geom == NULL:
9339  *             raise ValueError("Null geom")             # <<<<<<<<<<<<<<
9340  *         npoints = OGR_G_GetPointCount(geom)
9341  *         coords = []
9342  */
9343     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 494, __pyx_L1_error)
9344     __Pyx_GOTREF(__pyx_t_2);
9345     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
9346     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9347     __PYX_ERR(0, 494, __pyx_L1_error)
9348 
9349     /* "rasterio/_features.pyx":493
9350  *         # Build a coordinate sequence
9351  *         cdef int i
9352  *         if geom == NULL:             # <<<<<<<<<<<<<<
9353  *             raise ValueError("Null geom")
9354  *         npoints = OGR_G_GetPointCount(geom)
9355  */
9356   }
9357 
9358   /* "rasterio/_features.pyx":495
9359  *         if geom == NULL:
9360  *             raise ValueError("Null geom")
9361  *         npoints = OGR_G_GetPointCount(geom)             # <<<<<<<<<<<<<<
9362  *         coords = []
9363  *         for i in range(npoints):
9364  */
9365   __pyx_v_npoints = OGR_G_GetPointCount(__pyx_v_geom);
9366 
9367   /* "rasterio/_features.pyx":496
9368  *             raise ValueError("Null geom")
9369  *         npoints = OGR_G_GetPointCount(geom)
9370  *         coords = []             # <<<<<<<<<<<<<<
9371  *         for i in range(npoints):
9372  *             values = [OGR_G_GetX(geom, i), OGR_G_GetY(geom, i)]
9373  */
9374   __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 496, __pyx_L1_error)
9375   __Pyx_GOTREF(__pyx_t_2);
9376   __pyx_v_coords = ((PyObject*)__pyx_t_2);
9377   __pyx_t_2 = 0;
9378 
9379   /* "rasterio/_features.pyx":497
9380  *         npoints = OGR_G_GetPointCount(geom)
9381  *         coords = []
9382  *         for i in range(npoints):             # <<<<<<<<<<<<<<
9383  *             values = [OGR_G_GetX(geom, i), OGR_G_GetY(geom, i)]
9384  *             if self.ndims > 2:
9385  */
9386   __pyx_t_3 = __pyx_v_npoints;
9387   __pyx_t_4 = __pyx_t_3;
9388   for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
9389     __pyx_v_i = __pyx_t_5;
9390 
9391     /* "rasterio/_features.pyx":498
9392  *         coords = []
9393  *         for i in range(npoints):
9394  *             values = [OGR_G_GetX(geom, i), OGR_G_GetY(geom, i)]             # <<<<<<<<<<<<<<
9395  *             if self.ndims > 2:
9396  *                 values.append(OGR_G_GetZ(geom, i))
9397  */
9398     __pyx_t_2 = PyFloat_FromDouble(OGR_G_GetX(__pyx_v_geom, __pyx_v_i)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 498, __pyx_L1_error)
9399     __Pyx_GOTREF(__pyx_t_2);
9400     __pyx_t_6 = PyFloat_FromDouble(OGR_G_GetY(__pyx_v_geom, __pyx_v_i)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 498, __pyx_L1_error)
9401     __Pyx_GOTREF(__pyx_t_6);
9402     __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 498, __pyx_L1_error)
9403     __Pyx_GOTREF(__pyx_t_7);
9404     __Pyx_GIVEREF(__pyx_t_2);
9405     PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
9406     __Pyx_GIVEREF(__pyx_t_6);
9407     PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
9408     __pyx_t_2 = 0;
9409     __pyx_t_6 = 0;
9410     __Pyx_XDECREF_SET(__pyx_v_values, ((PyObject*)__pyx_t_7));
9411     __pyx_t_7 = 0;
9412 
9413     /* "rasterio/_features.pyx":499
9414  *         for i in range(npoints):
9415  *             values = [OGR_G_GetX(geom, i), OGR_G_GetY(geom, i)]
9416  *             if self.ndims > 2:             # <<<<<<<<<<<<<<
9417  *                 values.append(OGR_G_GetZ(geom, i))
9418  *             coords.append(tuple(values))
9419  */
9420     __pyx_t_7 = PyObject_RichCompare(__pyx_v_self->ndims, __pyx_int_2, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 499, __pyx_L1_error)
9421     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 499, __pyx_L1_error)
9422     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9423     if (__pyx_t_1) {
9424 
9425       /* "rasterio/_features.pyx":500
9426  *             values = [OGR_G_GetX(geom, i), OGR_G_GetY(geom, i)]
9427  *             if self.ndims > 2:
9428  *                 values.append(OGR_G_GetZ(geom, i))             # <<<<<<<<<<<<<<
9429  *             coords.append(tuple(values))
9430  *         return coords
9431  */
9432       __pyx_t_7 = PyFloat_FromDouble(OGR_G_GetZ(__pyx_v_geom, __pyx_v_i)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 500, __pyx_L1_error)
9433       __Pyx_GOTREF(__pyx_t_7);
9434       __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_values, __pyx_t_7); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 500, __pyx_L1_error)
9435       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9436 
9437       /* "rasterio/_features.pyx":499
9438  *         for i in range(npoints):
9439  *             values = [OGR_G_GetX(geom, i), OGR_G_GetY(geom, i)]
9440  *             if self.ndims > 2:             # <<<<<<<<<<<<<<
9441  *                 values.append(OGR_G_GetZ(geom, i))
9442  *             coords.append(tuple(values))
9443  */
9444     }
9445 
9446     /* "rasterio/_features.pyx":501
9447  *             if self.ndims > 2:
9448  *                 values.append(OGR_G_GetZ(geom, i))
9449  *             coords.append(tuple(values))             # <<<<<<<<<<<<<<
9450  *         return coords
9451  *
9452  */
9453     __pyx_t_7 = PyList_AsTuple(__pyx_v_values); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 501, __pyx_L1_error)
9454     __Pyx_GOTREF(__pyx_t_7);
9455     __pyx_t_8 = __Pyx_PyList_Append(__pyx_v_coords, __pyx_t_7); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 501, __pyx_L1_error)
9456     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9457   }
9458 
9459   /* "rasterio/_features.pyx":502
9460  *                 values.append(OGR_G_GetZ(geom, i))
9461  *             coords.append(tuple(values))
9462  *         return coords             # <<<<<<<<<<<<<<
9463  *
9464  *     cpdef _buildPoint(self):
9465  */
9466   __Pyx_XDECREF(__pyx_r);
9467   __Pyx_INCREF(__pyx_v_coords);
9468   __pyx_r = __pyx_v_coords;
9469   goto __pyx_L0;
9470 
9471   /* "rasterio/_features.pyx":490
9472  *     """Builds a GeoJSON (Fiona-style) geometry from an OGR geometry."""
9473  *
9474  *     cdef _buildCoords(self, OGRGeometryH geom):             # <<<<<<<<<<<<<<
9475  *         # Build a coordinate sequence
9476  *         cdef int i
9477  */
9478 
9479   /* function exit code */
9480   __pyx_L1_error:;
9481   __Pyx_XDECREF(__pyx_t_2);
9482   __Pyx_XDECREF(__pyx_t_6);
9483   __Pyx_XDECREF(__pyx_t_7);
9484   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildCoords", __pyx_clineno, __pyx_lineno, __pyx_filename);
9485   __pyx_r = 0;
9486   __pyx_L0:;
9487   __Pyx_XDECREF(__pyx_v_coords);
9488   __Pyx_XDECREF(__pyx_v_values);
9489   __Pyx_XGIVEREF(__pyx_r);
9490   __Pyx_RefNannyFinishContext();
9491   return __pyx_r;
9492 }
9493 
9494 /* "rasterio/_features.pyx":504
9495  *         return coords
9496  *
9497  *     cpdef _buildPoint(self):             # <<<<<<<<<<<<<<
9498  *         return {
9499  *             'type': 'Point',
9500  */
9501 
9502 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_1_buildPoint(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_f_8rasterio_9_features_11GeomBuilder__buildPoint(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self,int __pyx_skip_dispatch)9503 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildPoint(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
9504   PyObject *__pyx_r = NULL;
9505   __Pyx_RefNannyDeclarations
9506   PyObject *__pyx_t_1 = NULL;
9507   PyObject *__pyx_t_2 = NULL;
9508   PyObject *__pyx_t_3 = NULL;
9509   PyObject *__pyx_t_4 = NULL;
9510   int __pyx_lineno = 0;
9511   const char *__pyx_filename = NULL;
9512   int __pyx_clineno = 0;
9513   __Pyx_RefNannySetupContext("_buildPoint", 0);
9514   /* Check if called by wrapper */
9515   if (unlikely(__pyx_skip_dispatch)) ;
9516   /* Check if overridden in Python */
9517   else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
9518     #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
9519     static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
9520     if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
9521       PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
9522       #endif
9523       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_buildPoint); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 504, __pyx_L1_error)
9524       __Pyx_GOTREF(__pyx_t_1);
9525       if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_8rasterio_9_features_11GeomBuilder_1_buildPoint)) {
9526         __Pyx_XDECREF(__pyx_r);
9527         __Pyx_INCREF(__pyx_t_1);
9528         __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
9529         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
9530           __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
9531           if (likely(__pyx_t_4)) {
9532             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
9533             __Pyx_INCREF(__pyx_t_4);
9534             __Pyx_INCREF(function);
9535             __Pyx_DECREF_SET(__pyx_t_3, function);
9536           }
9537         }
9538         __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
9539         __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
9540         if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 504, __pyx_L1_error)
9541         __Pyx_GOTREF(__pyx_t_2);
9542         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9543         __pyx_r = __pyx_t_2;
9544         __pyx_t_2 = 0;
9545         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9546         goto __pyx_L0;
9547       }
9548       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
9549       __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
9550       __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
9551       if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
9552         __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
9553       }
9554       #endif
9555       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9556       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
9557     }
9558     #endif
9559   }
9560 
9561   /* "rasterio/_features.pyx":505
9562  *
9563  *     cpdef _buildPoint(self):
9564  *         return {             # <<<<<<<<<<<<<<
9565  *             'type': 'Point',
9566  *             'coordinates': self._buildCoords(self.geom)[0]}
9567  */
9568   __Pyx_XDECREF(__pyx_r);
9569 
9570   /* "rasterio/_features.pyx":506
9571  *     cpdef _buildPoint(self):
9572  *         return {
9573  *             'type': 'Point',             # <<<<<<<<<<<<<<
9574  *             'coordinates': self._buildCoords(self.geom)[0]}
9575  *
9576  */
9577   __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 506, __pyx_L1_error)
9578   __Pyx_GOTREF(__pyx_t_1);
9579   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_type, __pyx_n_u_Point) < 0) __PYX_ERR(0, 506, __pyx_L1_error)
9580 
9581   /* "rasterio/_features.pyx":507
9582  *         return {
9583  *             'type': 'Point',
9584  *             'coordinates': self._buildCoords(self.geom)[0]}             # <<<<<<<<<<<<<<
9585  *
9586  *     cpdef _buildLineString(self):
9587  */
9588   __pyx_t_2 = ((struct __pyx_vtabstruct_8rasterio_9_features_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildCoords(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 507, __pyx_L1_error)
9589   __Pyx_GOTREF(__pyx_t_2);
9590   __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 507, __pyx_L1_error)
9591   __Pyx_GOTREF(__pyx_t_3);
9592   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9593   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_coordinates, __pyx_t_3) < 0) __PYX_ERR(0, 506, __pyx_L1_error)
9594   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9595   __pyx_r = __pyx_t_1;
9596   __pyx_t_1 = 0;
9597   goto __pyx_L0;
9598 
9599   /* "rasterio/_features.pyx":504
9600  *         return coords
9601  *
9602  *     cpdef _buildPoint(self):             # <<<<<<<<<<<<<<
9603  *         return {
9604  *             'type': 'Point',
9605  */
9606 
9607   /* function exit code */
9608   __pyx_L1_error:;
9609   __Pyx_XDECREF(__pyx_t_1);
9610   __Pyx_XDECREF(__pyx_t_2);
9611   __Pyx_XDECREF(__pyx_t_3);
9612   __Pyx_XDECREF(__pyx_t_4);
9613   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
9614   __pyx_r = 0;
9615   __pyx_L0:;
9616   __Pyx_XGIVEREF(__pyx_r);
9617   __Pyx_RefNannyFinishContext();
9618   return __pyx_r;
9619 }
9620 
9621 /* Python wrapper */
9622 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_1_buildPoint(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_8rasterio_9_features_11GeomBuilder_1_buildPoint(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)9623 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_1_buildPoint(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
9624   PyObject *__pyx_r = 0;
9625   __Pyx_RefNannyDeclarations
9626   __Pyx_RefNannySetupContext("_buildPoint (wrapper)", 0);
9627   __pyx_r = __pyx_pf_8rasterio_9_features_11GeomBuilder__buildPoint(((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)__pyx_v_self));
9628 
9629   /* function exit code */
9630   __Pyx_RefNannyFinishContext();
9631   return __pyx_r;
9632 }
9633 
__pyx_pf_8rasterio_9_features_11GeomBuilder__buildPoint(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self)9634 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder__buildPoint(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self) {
9635   PyObject *__pyx_r = NULL;
9636   __Pyx_RefNannyDeclarations
9637   PyObject *__pyx_t_1 = NULL;
9638   int __pyx_lineno = 0;
9639   const char *__pyx_filename = NULL;
9640   int __pyx_clineno = 0;
9641   __Pyx_RefNannySetupContext("_buildPoint", 0);
9642   __Pyx_XDECREF(__pyx_r);
9643   __pyx_t_1 = __pyx_f_8rasterio_9_features_11GeomBuilder__buildPoint(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 504, __pyx_L1_error)
9644   __Pyx_GOTREF(__pyx_t_1);
9645   __pyx_r = __pyx_t_1;
9646   __pyx_t_1 = 0;
9647   goto __pyx_L0;
9648 
9649   /* function exit code */
9650   __pyx_L1_error:;
9651   __Pyx_XDECREF(__pyx_t_1);
9652   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
9653   __pyx_r = NULL;
9654   __pyx_L0:;
9655   __Pyx_XGIVEREF(__pyx_r);
9656   __Pyx_RefNannyFinishContext();
9657   return __pyx_r;
9658 }
9659 
9660 /* "rasterio/_features.pyx":509
9661  *             'coordinates': self._buildCoords(self.geom)[0]}
9662  *
9663  *     cpdef _buildLineString(self):             # <<<<<<<<<<<<<<
9664  *         return {
9665  *             'type': 'LineString',
9666  */
9667 
9668 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_3_buildLineString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_f_8rasterio_9_features_11GeomBuilder__buildLineString(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self,int __pyx_skip_dispatch)9669 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildLineString(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
9670   PyObject *__pyx_r = NULL;
9671   __Pyx_RefNannyDeclarations
9672   PyObject *__pyx_t_1 = NULL;
9673   PyObject *__pyx_t_2 = NULL;
9674   PyObject *__pyx_t_3 = NULL;
9675   PyObject *__pyx_t_4 = NULL;
9676   int __pyx_lineno = 0;
9677   const char *__pyx_filename = NULL;
9678   int __pyx_clineno = 0;
9679   __Pyx_RefNannySetupContext("_buildLineString", 0);
9680   /* Check if called by wrapper */
9681   if (unlikely(__pyx_skip_dispatch)) ;
9682   /* Check if overridden in Python */
9683   else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
9684     #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
9685     static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
9686     if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
9687       PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
9688       #endif
9689       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_buildLineString); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 509, __pyx_L1_error)
9690       __Pyx_GOTREF(__pyx_t_1);
9691       if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_8rasterio_9_features_11GeomBuilder_3_buildLineString)) {
9692         __Pyx_XDECREF(__pyx_r);
9693         __Pyx_INCREF(__pyx_t_1);
9694         __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
9695         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
9696           __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
9697           if (likely(__pyx_t_4)) {
9698             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
9699             __Pyx_INCREF(__pyx_t_4);
9700             __Pyx_INCREF(function);
9701             __Pyx_DECREF_SET(__pyx_t_3, function);
9702           }
9703         }
9704         __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
9705         __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
9706         if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 509, __pyx_L1_error)
9707         __Pyx_GOTREF(__pyx_t_2);
9708         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9709         __pyx_r = __pyx_t_2;
9710         __pyx_t_2 = 0;
9711         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9712         goto __pyx_L0;
9713       }
9714       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
9715       __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
9716       __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
9717       if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
9718         __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
9719       }
9720       #endif
9721       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9722       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
9723     }
9724     #endif
9725   }
9726 
9727   /* "rasterio/_features.pyx":510
9728  *
9729  *     cpdef _buildLineString(self):
9730  *         return {             # <<<<<<<<<<<<<<
9731  *             'type': 'LineString',
9732  *             'coordinates': self._buildCoords(self.geom)}
9733  */
9734   __Pyx_XDECREF(__pyx_r);
9735 
9736   /* "rasterio/_features.pyx":511
9737  *     cpdef _buildLineString(self):
9738  *         return {
9739  *             'type': 'LineString',             # <<<<<<<<<<<<<<
9740  *             'coordinates': self._buildCoords(self.geom)}
9741  *
9742  */
9743   __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 511, __pyx_L1_error)
9744   __Pyx_GOTREF(__pyx_t_1);
9745   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_type, __pyx_n_u_LineString) < 0) __PYX_ERR(0, 511, __pyx_L1_error)
9746 
9747   /* "rasterio/_features.pyx":512
9748  *         return {
9749  *             'type': 'LineString',
9750  *             'coordinates': self._buildCoords(self.geom)}             # <<<<<<<<<<<<<<
9751  *
9752  *     cpdef _buildLinearRing(self):
9753  */
9754   __pyx_t_2 = ((struct __pyx_vtabstruct_8rasterio_9_features_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildCoords(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 512, __pyx_L1_error)
9755   __Pyx_GOTREF(__pyx_t_2);
9756   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_coordinates, __pyx_t_2) < 0) __PYX_ERR(0, 511, __pyx_L1_error)
9757   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9758   __pyx_r = __pyx_t_1;
9759   __pyx_t_1 = 0;
9760   goto __pyx_L0;
9761 
9762   /* "rasterio/_features.pyx":509
9763  *             'coordinates': self._buildCoords(self.geom)[0]}
9764  *
9765  *     cpdef _buildLineString(self):             # <<<<<<<<<<<<<<
9766  *         return {
9767  *             'type': 'LineString',
9768  */
9769 
9770   /* function exit code */
9771   __pyx_L1_error:;
9772   __Pyx_XDECREF(__pyx_t_1);
9773   __Pyx_XDECREF(__pyx_t_2);
9774   __Pyx_XDECREF(__pyx_t_3);
9775   __Pyx_XDECREF(__pyx_t_4);
9776   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
9777   __pyx_r = 0;
9778   __pyx_L0:;
9779   __Pyx_XGIVEREF(__pyx_r);
9780   __Pyx_RefNannyFinishContext();
9781   return __pyx_r;
9782 }
9783 
9784 /* Python wrapper */
9785 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_3_buildLineString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_8rasterio_9_features_11GeomBuilder_3_buildLineString(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)9786 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_3_buildLineString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
9787   PyObject *__pyx_r = 0;
9788   __Pyx_RefNannyDeclarations
9789   __Pyx_RefNannySetupContext("_buildLineString (wrapper)", 0);
9790   __pyx_r = __pyx_pf_8rasterio_9_features_11GeomBuilder_2_buildLineString(((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)__pyx_v_self));
9791 
9792   /* function exit code */
9793   __Pyx_RefNannyFinishContext();
9794   return __pyx_r;
9795 }
9796 
__pyx_pf_8rasterio_9_features_11GeomBuilder_2_buildLineString(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self)9797 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_2_buildLineString(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self) {
9798   PyObject *__pyx_r = NULL;
9799   __Pyx_RefNannyDeclarations
9800   PyObject *__pyx_t_1 = NULL;
9801   int __pyx_lineno = 0;
9802   const char *__pyx_filename = NULL;
9803   int __pyx_clineno = 0;
9804   __Pyx_RefNannySetupContext("_buildLineString", 0);
9805   __Pyx_XDECREF(__pyx_r);
9806   __pyx_t_1 = __pyx_f_8rasterio_9_features_11GeomBuilder__buildLineString(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 509, __pyx_L1_error)
9807   __Pyx_GOTREF(__pyx_t_1);
9808   __pyx_r = __pyx_t_1;
9809   __pyx_t_1 = 0;
9810   goto __pyx_L0;
9811 
9812   /* function exit code */
9813   __pyx_L1_error:;
9814   __Pyx_XDECREF(__pyx_t_1);
9815   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
9816   __pyx_r = NULL;
9817   __pyx_L0:;
9818   __Pyx_XGIVEREF(__pyx_r);
9819   __Pyx_RefNannyFinishContext();
9820   return __pyx_r;
9821 }
9822 
9823 /* "rasterio/_features.pyx":514
9824  *             'coordinates': self._buildCoords(self.geom)}
9825  *
9826  *     cpdef _buildLinearRing(self):             # <<<<<<<<<<<<<<
9827  *         return {
9828  *             'type': 'LinearRing',
9829  */
9830 
9831 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_5_buildLinearRing(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_f_8rasterio_9_features_11GeomBuilder__buildLinearRing(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self,int __pyx_skip_dispatch)9832 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildLinearRing(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
9833   PyObject *__pyx_r = NULL;
9834   __Pyx_RefNannyDeclarations
9835   PyObject *__pyx_t_1 = NULL;
9836   PyObject *__pyx_t_2 = NULL;
9837   PyObject *__pyx_t_3 = NULL;
9838   PyObject *__pyx_t_4 = NULL;
9839   int __pyx_lineno = 0;
9840   const char *__pyx_filename = NULL;
9841   int __pyx_clineno = 0;
9842   __Pyx_RefNannySetupContext("_buildLinearRing", 0);
9843   /* Check if called by wrapper */
9844   if (unlikely(__pyx_skip_dispatch)) ;
9845   /* Check if overridden in Python */
9846   else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
9847     #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
9848     static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
9849     if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
9850       PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
9851       #endif
9852       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_buildLinearRing); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 514, __pyx_L1_error)
9853       __Pyx_GOTREF(__pyx_t_1);
9854       if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_8rasterio_9_features_11GeomBuilder_5_buildLinearRing)) {
9855         __Pyx_XDECREF(__pyx_r);
9856         __Pyx_INCREF(__pyx_t_1);
9857         __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
9858         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
9859           __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
9860           if (likely(__pyx_t_4)) {
9861             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
9862             __Pyx_INCREF(__pyx_t_4);
9863             __Pyx_INCREF(function);
9864             __Pyx_DECREF_SET(__pyx_t_3, function);
9865           }
9866         }
9867         __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
9868         __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
9869         if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 514, __pyx_L1_error)
9870         __Pyx_GOTREF(__pyx_t_2);
9871         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
9872         __pyx_r = __pyx_t_2;
9873         __pyx_t_2 = 0;
9874         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9875         goto __pyx_L0;
9876       }
9877       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
9878       __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
9879       __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
9880       if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
9881         __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
9882       }
9883       #endif
9884       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9885       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
9886     }
9887     #endif
9888   }
9889 
9890   /* "rasterio/_features.pyx":515
9891  *
9892  *     cpdef _buildLinearRing(self):
9893  *         return {             # <<<<<<<<<<<<<<
9894  *             'type': 'LinearRing',
9895  *             'coordinates': self._buildCoords(self.geom)}
9896  */
9897   __Pyx_XDECREF(__pyx_r);
9898 
9899   /* "rasterio/_features.pyx":516
9900  *     cpdef _buildLinearRing(self):
9901  *         return {
9902  *             'type': 'LinearRing',             # <<<<<<<<<<<<<<
9903  *             'coordinates': self._buildCoords(self.geom)}
9904  *
9905  */
9906   __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 516, __pyx_L1_error)
9907   __Pyx_GOTREF(__pyx_t_1);
9908   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_type, __pyx_n_u_LinearRing) < 0) __PYX_ERR(0, 516, __pyx_L1_error)
9909 
9910   /* "rasterio/_features.pyx":517
9911  *         return {
9912  *             'type': 'LinearRing',
9913  *             'coordinates': self._buildCoords(self.geom)}             # <<<<<<<<<<<<<<
9914  *
9915  *     cdef _buildParts(self, OGRGeometryH geom):
9916  */
9917   __pyx_t_2 = ((struct __pyx_vtabstruct_8rasterio_9_features_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildCoords(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 517, __pyx_L1_error)
9918   __Pyx_GOTREF(__pyx_t_2);
9919   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_coordinates, __pyx_t_2) < 0) __PYX_ERR(0, 516, __pyx_L1_error)
9920   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9921   __pyx_r = __pyx_t_1;
9922   __pyx_t_1 = 0;
9923   goto __pyx_L0;
9924 
9925   /* "rasterio/_features.pyx":514
9926  *             'coordinates': self._buildCoords(self.geom)}
9927  *
9928  *     cpdef _buildLinearRing(self):             # <<<<<<<<<<<<<<
9929  *         return {
9930  *             'type': 'LinearRing',
9931  */
9932 
9933   /* function exit code */
9934   __pyx_L1_error:;
9935   __Pyx_XDECREF(__pyx_t_1);
9936   __Pyx_XDECREF(__pyx_t_2);
9937   __Pyx_XDECREF(__pyx_t_3);
9938   __Pyx_XDECREF(__pyx_t_4);
9939   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildLinearRing", __pyx_clineno, __pyx_lineno, __pyx_filename);
9940   __pyx_r = 0;
9941   __pyx_L0:;
9942   __Pyx_XGIVEREF(__pyx_r);
9943   __Pyx_RefNannyFinishContext();
9944   return __pyx_r;
9945 }
9946 
9947 /* Python wrapper */
9948 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_5_buildLinearRing(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_8rasterio_9_features_11GeomBuilder_5_buildLinearRing(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)9949 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_5_buildLinearRing(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
9950   PyObject *__pyx_r = 0;
9951   __Pyx_RefNannyDeclarations
9952   __Pyx_RefNannySetupContext("_buildLinearRing (wrapper)", 0);
9953   __pyx_r = __pyx_pf_8rasterio_9_features_11GeomBuilder_4_buildLinearRing(((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)__pyx_v_self));
9954 
9955   /* function exit code */
9956   __Pyx_RefNannyFinishContext();
9957   return __pyx_r;
9958 }
9959 
__pyx_pf_8rasterio_9_features_11GeomBuilder_4_buildLinearRing(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self)9960 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_4_buildLinearRing(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self) {
9961   PyObject *__pyx_r = NULL;
9962   __Pyx_RefNannyDeclarations
9963   PyObject *__pyx_t_1 = NULL;
9964   int __pyx_lineno = 0;
9965   const char *__pyx_filename = NULL;
9966   int __pyx_clineno = 0;
9967   __Pyx_RefNannySetupContext("_buildLinearRing", 0);
9968   __Pyx_XDECREF(__pyx_r);
9969   __pyx_t_1 = __pyx_f_8rasterio_9_features_11GeomBuilder__buildLinearRing(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 514, __pyx_L1_error)
9970   __Pyx_GOTREF(__pyx_t_1);
9971   __pyx_r = __pyx_t_1;
9972   __pyx_t_1 = 0;
9973   goto __pyx_L0;
9974 
9975   /* function exit code */
9976   __pyx_L1_error:;
9977   __Pyx_XDECREF(__pyx_t_1);
9978   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildLinearRing", __pyx_clineno, __pyx_lineno, __pyx_filename);
9979   __pyx_r = NULL;
9980   __pyx_L0:;
9981   __Pyx_XGIVEREF(__pyx_r);
9982   __Pyx_RefNannyFinishContext();
9983   return __pyx_r;
9984 }
9985 
9986 /* "rasterio/_features.pyx":519
9987  *             'coordinates': self._buildCoords(self.geom)}
9988  *
9989  *     cdef _buildParts(self, OGRGeometryH geom):             # <<<<<<<<<<<<<<
9990  *         cdef int j
9991  *         cdef OGRGeometryH part
9992  */
9993 
__pyx_f_8rasterio_9_features_11GeomBuilder__buildParts(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self,OGRGeometryH __pyx_v_geom)9994 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildParts(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, OGRGeometryH __pyx_v_geom) {
9995   int __pyx_v_j;
9996   OGRGeometryH __pyx_v_part;
9997   PyObject *__pyx_v_parts = NULL;
9998   PyObject *__pyx_r = NULL;
9999   __Pyx_RefNannyDeclarations
10000   int __pyx_t_1;
10001   PyObject *__pyx_t_2 = NULL;
10002   int __pyx_t_3;
10003   int __pyx_t_4;
10004   int __pyx_t_5;
10005   PyObject *__pyx_t_6 = NULL;
10006   int __pyx_t_7;
10007   int __pyx_lineno = 0;
10008   const char *__pyx_filename = NULL;
10009   int __pyx_clineno = 0;
10010   __Pyx_RefNannySetupContext("_buildParts", 0);
10011 
10012   /* "rasterio/_features.pyx":522
10013  *         cdef int j
10014  *         cdef OGRGeometryH part
10015  *         if geom == NULL:             # <<<<<<<<<<<<<<
10016  *             raise ValueError("Null geom")
10017  *         parts = []
10018  */
10019   __pyx_t_1 = ((__pyx_v_geom == NULL) != 0);
10020   if (unlikely(__pyx_t_1)) {
10021 
10022     /* "rasterio/_features.pyx":523
10023  *         cdef OGRGeometryH part
10024  *         if geom == NULL:
10025  *             raise ValueError("Null geom")             # <<<<<<<<<<<<<<
10026  *         parts = []
10027  *         for j in range(OGR_G_GetGeometryCount(geom)):
10028  */
10029     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 523, __pyx_L1_error)
10030     __Pyx_GOTREF(__pyx_t_2);
10031     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
10032     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10033     __PYX_ERR(0, 523, __pyx_L1_error)
10034 
10035     /* "rasterio/_features.pyx":522
10036  *         cdef int j
10037  *         cdef OGRGeometryH part
10038  *         if geom == NULL:             # <<<<<<<<<<<<<<
10039  *             raise ValueError("Null geom")
10040  *         parts = []
10041  */
10042   }
10043 
10044   /* "rasterio/_features.pyx":524
10045  *         if geom == NULL:
10046  *             raise ValueError("Null geom")
10047  *         parts = []             # <<<<<<<<<<<<<<
10048  *         for j in range(OGR_G_GetGeometryCount(geom)):
10049  *             part = OGR_G_GetGeometryRef(geom, j)
10050  */
10051   __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 524, __pyx_L1_error)
10052   __Pyx_GOTREF(__pyx_t_2);
10053   __pyx_v_parts = ((PyObject*)__pyx_t_2);
10054   __pyx_t_2 = 0;
10055 
10056   /* "rasterio/_features.pyx":525
10057  *             raise ValueError("Null geom")
10058  *         parts = []
10059  *         for j in range(OGR_G_GetGeometryCount(geom)):             # <<<<<<<<<<<<<<
10060  *             part = OGR_G_GetGeometryRef(geom, j)
10061  *             parts.append(GeomBuilder().build(part))
10062  */
10063   __pyx_t_3 = OGR_G_GetGeometryCount(__pyx_v_geom);
10064   __pyx_t_4 = __pyx_t_3;
10065   for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
10066     __pyx_v_j = __pyx_t_5;
10067 
10068     /* "rasterio/_features.pyx":526
10069  *         parts = []
10070  *         for j in range(OGR_G_GetGeometryCount(geom)):
10071  *             part = OGR_G_GetGeometryRef(geom, j)             # <<<<<<<<<<<<<<
10072  *             parts.append(GeomBuilder().build(part))
10073  *         return parts
10074  */
10075     __pyx_v_part = OGR_G_GetGeometryRef(__pyx_v_geom, __pyx_v_j);
10076 
10077     /* "rasterio/_features.pyx":527
10078  *         for j in range(OGR_G_GetGeometryCount(geom)):
10079  *             part = OGR_G_GetGeometryRef(geom, j)
10080  *             parts.append(GeomBuilder().build(part))             # <<<<<<<<<<<<<<
10081  *         return parts
10082  *
10083  */
10084     __pyx_t_2 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_8rasterio_9_features_GeomBuilder)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 527, __pyx_L1_error)
10085     __Pyx_GOTREF(__pyx_t_2);
10086     __pyx_t_6 = ((struct __pyx_vtabstruct_8rasterio_9_features_GeomBuilder *)((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)__pyx_t_2)->__pyx_vtab)->build(((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)__pyx_t_2), __pyx_v_part); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 527, __pyx_L1_error)
10087     __Pyx_GOTREF(__pyx_t_6);
10088     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10089     __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_parts, __pyx_t_6); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 527, __pyx_L1_error)
10090     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10091   }
10092 
10093   /* "rasterio/_features.pyx":528
10094  *             part = OGR_G_GetGeometryRef(geom, j)
10095  *             parts.append(GeomBuilder().build(part))
10096  *         return parts             # <<<<<<<<<<<<<<
10097  *
10098  *     cpdef _buildPolygon(self):
10099  */
10100   __Pyx_XDECREF(__pyx_r);
10101   __Pyx_INCREF(__pyx_v_parts);
10102   __pyx_r = __pyx_v_parts;
10103   goto __pyx_L0;
10104 
10105   /* "rasterio/_features.pyx":519
10106  *             'coordinates': self._buildCoords(self.geom)}
10107  *
10108  *     cdef _buildParts(self, OGRGeometryH geom):             # <<<<<<<<<<<<<<
10109  *         cdef int j
10110  *         cdef OGRGeometryH part
10111  */
10112 
10113   /* function exit code */
10114   __pyx_L1_error:;
10115   __Pyx_XDECREF(__pyx_t_2);
10116   __Pyx_XDECREF(__pyx_t_6);
10117   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildParts", __pyx_clineno, __pyx_lineno, __pyx_filename);
10118   __pyx_r = 0;
10119   __pyx_L0:;
10120   __Pyx_XDECREF(__pyx_v_parts);
10121   __Pyx_XGIVEREF(__pyx_r);
10122   __Pyx_RefNannyFinishContext();
10123   return __pyx_r;
10124 }
10125 
10126 /* "rasterio/_features.pyx":530
10127  *         return parts
10128  *
10129  *     cpdef _buildPolygon(self):             # <<<<<<<<<<<<<<
10130  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
10131  *         return {'type': 'Polygon', 'coordinates': coordinates}
10132  */
10133 
10134 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_7_buildPolygon(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_f_8rasterio_9_features_11GeomBuilder__buildPolygon(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self,int __pyx_skip_dispatch)10135 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildPolygon(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
10136   PyObject *__pyx_v_coordinates = NULL;
10137   PyObject *__pyx_8genexpr3__pyx_v_p = NULL;
10138   PyObject *__pyx_r = NULL;
10139   __Pyx_RefNannyDeclarations
10140   PyObject *__pyx_t_1 = NULL;
10141   PyObject *__pyx_t_2 = NULL;
10142   PyObject *__pyx_t_3 = NULL;
10143   PyObject *__pyx_t_4 = NULL;
10144   Py_ssize_t __pyx_t_5;
10145   PyObject *(*__pyx_t_6)(PyObject *);
10146   int __pyx_lineno = 0;
10147   const char *__pyx_filename = NULL;
10148   int __pyx_clineno = 0;
10149   __Pyx_RefNannySetupContext("_buildPolygon", 0);
10150   /* Check if called by wrapper */
10151   if (unlikely(__pyx_skip_dispatch)) ;
10152   /* Check if overridden in Python */
10153   else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
10154     #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
10155     static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
10156     if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
10157       PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
10158       #endif
10159       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_buildPolygon); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 530, __pyx_L1_error)
10160       __Pyx_GOTREF(__pyx_t_1);
10161       if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_8rasterio_9_features_11GeomBuilder_7_buildPolygon)) {
10162         __Pyx_XDECREF(__pyx_r);
10163         __Pyx_INCREF(__pyx_t_1);
10164         __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
10165         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
10166           __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
10167           if (likely(__pyx_t_4)) {
10168             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
10169             __Pyx_INCREF(__pyx_t_4);
10170             __Pyx_INCREF(function);
10171             __Pyx_DECREF_SET(__pyx_t_3, function);
10172           }
10173         }
10174         __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
10175         __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
10176         if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 530, __pyx_L1_error)
10177         __Pyx_GOTREF(__pyx_t_2);
10178         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10179         __pyx_r = __pyx_t_2;
10180         __pyx_t_2 = 0;
10181         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10182         goto __pyx_L0;
10183       }
10184       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
10185       __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
10186       __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
10187       if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
10188         __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
10189       }
10190       #endif
10191       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10192       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
10193     }
10194     #endif
10195   }
10196 
10197   /* "rasterio/_features.pyx":531
10198  *
10199  *     cpdef _buildPolygon(self):
10200  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]             # <<<<<<<<<<<<<<
10201  *         return {'type': 'Polygon', 'coordinates': coordinates}
10202  *
10203  */
10204   { /* enter inner scope */
10205     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 531, __pyx_L5_error)
10206     __Pyx_GOTREF(__pyx_t_1);
10207     __pyx_t_2 = ((struct __pyx_vtabstruct_8rasterio_9_features_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildParts(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 531, __pyx_L5_error)
10208     __Pyx_GOTREF(__pyx_t_2);
10209     if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
10210       __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
10211       __pyx_t_6 = NULL;
10212     } else {
10213       __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 531, __pyx_L5_error)
10214       __Pyx_GOTREF(__pyx_t_3);
10215       __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 531, __pyx_L5_error)
10216     }
10217     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10218     for (;;) {
10219       if (likely(!__pyx_t_6)) {
10220         if (likely(PyList_CheckExact(__pyx_t_3))) {
10221           if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
10222           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10223           __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 531, __pyx_L5_error)
10224           #else
10225           __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 531, __pyx_L5_error)
10226           __Pyx_GOTREF(__pyx_t_2);
10227           #endif
10228         } else {
10229           if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
10230           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10231           __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 531, __pyx_L5_error)
10232           #else
10233           __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 531, __pyx_L5_error)
10234           __Pyx_GOTREF(__pyx_t_2);
10235           #endif
10236         }
10237       } else {
10238         __pyx_t_2 = __pyx_t_6(__pyx_t_3);
10239         if (unlikely(!__pyx_t_2)) {
10240           PyObject* exc_type = PyErr_Occurred();
10241           if (exc_type) {
10242             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
10243             else __PYX_ERR(0, 531, __pyx_L5_error)
10244           }
10245           break;
10246         }
10247         __Pyx_GOTREF(__pyx_t_2);
10248       }
10249       __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_p, __pyx_t_2);
10250       __pyx_t_2 = 0;
10251       __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_8genexpr3__pyx_v_p, __pyx_n_u_coordinates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 531, __pyx_L5_error)
10252       __Pyx_GOTREF(__pyx_t_2);
10253       if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 531, __pyx_L5_error)
10254       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10255     }
10256     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10257     __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p); __pyx_8genexpr3__pyx_v_p = 0;
10258     goto __pyx_L8_exit_scope;
10259     __pyx_L5_error:;
10260     __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p); __pyx_8genexpr3__pyx_v_p = 0;
10261     goto __pyx_L1_error;
10262     __pyx_L8_exit_scope:;
10263   } /* exit inner scope */
10264   __pyx_v_coordinates = ((PyObject*)__pyx_t_1);
10265   __pyx_t_1 = 0;
10266 
10267   /* "rasterio/_features.pyx":532
10268  *     cpdef _buildPolygon(self):
10269  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
10270  *         return {'type': 'Polygon', 'coordinates': coordinates}             # <<<<<<<<<<<<<<
10271  *
10272  *     cpdef _buildMultiPoint(self):
10273  */
10274   __Pyx_XDECREF(__pyx_r);
10275   __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 532, __pyx_L1_error)
10276   __Pyx_GOTREF(__pyx_t_1);
10277   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_type, __pyx_n_u_Polygon) < 0) __PYX_ERR(0, 532, __pyx_L1_error)
10278   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_coordinates, __pyx_v_coordinates) < 0) __PYX_ERR(0, 532, __pyx_L1_error)
10279   __pyx_r = __pyx_t_1;
10280   __pyx_t_1 = 0;
10281   goto __pyx_L0;
10282 
10283   /* "rasterio/_features.pyx":530
10284  *         return parts
10285  *
10286  *     cpdef _buildPolygon(self):             # <<<<<<<<<<<<<<
10287  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
10288  *         return {'type': 'Polygon', 'coordinates': coordinates}
10289  */
10290 
10291   /* function exit code */
10292   __pyx_L1_error:;
10293   __Pyx_XDECREF(__pyx_t_1);
10294   __Pyx_XDECREF(__pyx_t_2);
10295   __Pyx_XDECREF(__pyx_t_3);
10296   __Pyx_XDECREF(__pyx_t_4);
10297   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
10298   __pyx_r = 0;
10299   __pyx_L0:;
10300   __Pyx_XDECREF(__pyx_v_coordinates);
10301   __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p);
10302   __Pyx_XGIVEREF(__pyx_r);
10303   __Pyx_RefNannyFinishContext();
10304   return __pyx_r;
10305 }
10306 
10307 /* Python wrapper */
10308 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_7_buildPolygon(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_8rasterio_9_features_11GeomBuilder_7_buildPolygon(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)10309 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_7_buildPolygon(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10310   PyObject *__pyx_r = 0;
10311   __Pyx_RefNannyDeclarations
10312   __Pyx_RefNannySetupContext("_buildPolygon (wrapper)", 0);
10313   __pyx_r = __pyx_pf_8rasterio_9_features_11GeomBuilder_6_buildPolygon(((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)__pyx_v_self));
10314 
10315   /* function exit code */
10316   __Pyx_RefNannyFinishContext();
10317   return __pyx_r;
10318 }
10319 
__pyx_pf_8rasterio_9_features_11GeomBuilder_6_buildPolygon(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self)10320 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_6_buildPolygon(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self) {
10321   PyObject *__pyx_r = NULL;
10322   __Pyx_RefNannyDeclarations
10323   PyObject *__pyx_t_1 = NULL;
10324   int __pyx_lineno = 0;
10325   const char *__pyx_filename = NULL;
10326   int __pyx_clineno = 0;
10327   __Pyx_RefNannySetupContext("_buildPolygon", 0);
10328   __Pyx_XDECREF(__pyx_r);
10329   __pyx_t_1 = __pyx_f_8rasterio_9_features_11GeomBuilder__buildPolygon(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 530, __pyx_L1_error)
10330   __Pyx_GOTREF(__pyx_t_1);
10331   __pyx_r = __pyx_t_1;
10332   __pyx_t_1 = 0;
10333   goto __pyx_L0;
10334 
10335   /* function exit code */
10336   __pyx_L1_error:;
10337   __Pyx_XDECREF(__pyx_t_1);
10338   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
10339   __pyx_r = NULL;
10340   __pyx_L0:;
10341   __Pyx_XGIVEREF(__pyx_r);
10342   __Pyx_RefNannyFinishContext();
10343   return __pyx_r;
10344 }
10345 
10346 /* "rasterio/_features.pyx":534
10347  *         return {'type': 'Polygon', 'coordinates': coordinates}
10348  *
10349  *     cpdef _buildMultiPoint(self):             # <<<<<<<<<<<<<<
10350  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
10351  *         return {'type': 'MultiPoint', 'coordinates': coordinates}
10352  */
10353 
10354 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_9_buildMultiPoint(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiPoint(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self,int __pyx_skip_dispatch)10355 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiPoint(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
10356   PyObject *__pyx_v_coordinates = NULL;
10357   PyObject *__pyx_8genexpr4__pyx_v_p = NULL;
10358   PyObject *__pyx_r = NULL;
10359   __Pyx_RefNannyDeclarations
10360   PyObject *__pyx_t_1 = NULL;
10361   PyObject *__pyx_t_2 = NULL;
10362   PyObject *__pyx_t_3 = NULL;
10363   PyObject *__pyx_t_4 = NULL;
10364   Py_ssize_t __pyx_t_5;
10365   PyObject *(*__pyx_t_6)(PyObject *);
10366   int __pyx_lineno = 0;
10367   const char *__pyx_filename = NULL;
10368   int __pyx_clineno = 0;
10369   __Pyx_RefNannySetupContext("_buildMultiPoint", 0);
10370   /* Check if called by wrapper */
10371   if (unlikely(__pyx_skip_dispatch)) ;
10372   /* Check if overridden in Python */
10373   else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
10374     #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
10375     static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
10376     if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
10377       PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
10378       #endif
10379       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_buildMultiPoint); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
10380       __Pyx_GOTREF(__pyx_t_1);
10381       if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_8rasterio_9_features_11GeomBuilder_9_buildMultiPoint)) {
10382         __Pyx_XDECREF(__pyx_r);
10383         __Pyx_INCREF(__pyx_t_1);
10384         __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
10385         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
10386           __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
10387           if (likely(__pyx_t_4)) {
10388             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
10389             __Pyx_INCREF(__pyx_t_4);
10390             __Pyx_INCREF(function);
10391             __Pyx_DECREF_SET(__pyx_t_3, function);
10392           }
10393         }
10394         __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
10395         __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
10396         if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 534, __pyx_L1_error)
10397         __Pyx_GOTREF(__pyx_t_2);
10398         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10399         __pyx_r = __pyx_t_2;
10400         __pyx_t_2 = 0;
10401         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10402         goto __pyx_L0;
10403       }
10404       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
10405       __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
10406       __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
10407       if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
10408         __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
10409       }
10410       #endif
10411       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10412       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
10413     }
10414     #endif
10415   }
10416 
10417   /* "rasterio/_features.pyx":535
10418  *
10419  *     cpdef _buildMultiPoint(self):
10420  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]             # <<<<<<<<<<<<<<
10421  *         return {'type': 'MultiPoint', 'coordinates': coordinates}
10422  *
10423  */
10424   { /* enter inner scope */
10425     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 535, __pyx_L5_error)
10426     __Pyx_GOTREF(__pyx_t_1);
10427     __pyx_t_2 = ((struct __pyx_vtabstruct_8rasterio_9_features_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildParts(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L5_error)
10428     __Pyx_GOTREF(__pyx_t_2);
10429     if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
10430       __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
10431       __pyx_t_6 = NULL;
10432     } else {
10433       __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 535, __pyx_L5_error)
10434       __Pyx_GOTREF(__pyx_t_3);
10435       __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 535, __pyx_L5_error)
10436     }
10437     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10438     for (;;) {
10439       if (likely(!__pyx_t_6)) {
10440         if (likely(PyList_CheckExact(__pyx_t_3))) {
10441           if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
10442           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10443           __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 535, __pyx_L5_error)
10444           #else
10445           __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L5_error)
10446           __Pyx_GOTREF(__pyx_t_2);
10447           #endif
10448         } else {
10449           if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
10450           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10451           __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 535, __pyx_L5_error)
10452           #else
10453           __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L5_error)
10454           __Pyx_GOTREF(__pyx_t_2);
10455           #endif
10456         }
10457       } else {
10458         __pyx_t_2 = __pyx_t_6(__pyx_t_3);
10459         if (unlikely(!__pyx_t_2)) {
10460           PyObject* exc_type = PyErr_Occurred();
10461           if (exc_type) {
10462             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
10463             else __PYX_ERR(0, 535, __pyx_L5_error)
10464           }
10465           break;
10466         }
10467         __Pyx_GOTREF(__pyx_t_2);
10468       }
10469       __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_p, __pyx_t_2);
10470       __pyx_t_2 = 0;
10471       __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_8genexpr4__pyx_v_p, __pyx_n_u_coordinates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 535, __pyx_L5_error)
10472       __Pyx_GOTREF(__pyx_t_2);
10473       if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 535, __pyx_L5_error)
10474       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10475     }
10476     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10477     __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_p); __pyx_8genexpr4__pyx_v_p = 0;
10478     goto __pyx_L8_exit_scope;
10479     __pyx_L5_error:;
10480     __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_p); __pyx_8genexpr4__pyx_v_p = 0;
10481     goto __pyx_L1_error;
10482     __pyx_L8_exit_scope:;
10483   } /* exit inner scope */
10484   __pyx_v_coordinates = ((PyObject*)__pyx_t_1);
10485   __pyx_t_1 = 0;
10486 
10487   /* "rasterio/_features.pyx":536
10488  *     cpdef _buildMultiPoint(self):
10489  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
10490  *         return {'type': 'MultiPoint', 'coordinates': coordinates}             # <<<<<<<<<<<<<<
10491  *
10492  *     cpdef _buildMultiLineString(self):
10493  */
10494   __Pyx_XDECREF(__pyx_r);
10495   __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 536, __pyx_L1_error)
10496   __Pyx_GOTREF(__pyx_t_1);
10497   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_type, __pyx_n_u_MultiPoint) < 0) __PYX_ERR(0, 536, __pyx_L1_error)
10498   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_coordinates, __pyx_v_coordinates) < 0) __PYX_ERR(0, 536, __pyx_L1_error)
10499   __pyx_r = __pyx_t_1;
10500   __pyx_t_1 = 0;
10501   goto __pyx_L0;
10502 
10503   /* "rasterio/_features.pyx":534
10504  *         return {'type': 'Polygon', 'coordinates': coordinates}
10505  *
10506  *     cpdef _buildMultiPoint(self):             # <<<<<<<<<<<<<<
10507  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
10508  *         return {'type': 'MultiPoint', 'coordinates': coordinates}
10509  */
10510 
10511   /* function exit code */
10512   __pyx_L1_error:;
10513   __Pyx_XDECREF(__pyx_t_1);
10514   __Pyx_XDECREF(__pyx_t_2);
10515   __Pyx_XDECREF(__pyx_t_3);
10516   __Pyx_XDECREF(__pyx_t_4);
10517   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildMultiPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
10518   __pyx_r = 0;
10519   __pyx_L0:;
10520   __Pyx_XDECREF(__pyx_v_coordinates);
10521   __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_p);
10522   __Pyx_XGIVEREF(__pyx_r);
10523   __Pyx_RefNannyFinishContext();
10524   return __pyx_r;
10525 }
10526 
10527 /* Python wrapper */
10528 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_9_buildMultiPoint(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_8rasterio_9_features_11GeomBuilder_9_buildMultiPoint(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)10529 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_9_buildMultiPoint(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10530   PyObject *__pyx_r = 0;
10531   __Pyx_RefNannyDeclarations
10532   __Pyx_RefNannySetupContext("_buildMultiPoint (wrapper)", 0);
10533   __pyx_r = __pyx_pf_8rasterio_9_features_11GeomBuilder_8_buildMultiPoint(((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)__pyx_v_self));
10534 
10535   /* function exit code */
10536   __Pyx_RefNannyFinishContext();
10537   return __pyx_r;
10538 }
10539 
__pyx_pf_8rasterio_9_features_11GeomBuilder_8_buildMultiPoint(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self)10540 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_8_buildMultiPoint(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self) {
10541   PyObject *__pyx_r = NULL;
10542   __Pyx_RefNannyDeclarations
10543   PyObject *__pyx_t_1 = NULL;
10544   int __pyx_lineno = 0;
10545   const char *__pyx_filename = NULL;
10546   int __pyx_clineno = 0;
10547   __Pyx_RefNannySetupContext("_buildMultiPoint", 0);
10548   __Pyx_XDECREF(__pyx_r);
10549   __pyx_t_1 = __pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiPoint(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error)
10550   __Pyx_GOTREF(__pyx_t_1);
10551   __pyx_r = __pyx_t_1;
10552   __pyx_t_1 = 0;
10553   goto __pyx_L0;
10554 
10555   /* function exit code */
10556   __pyx_L1_error:;
10557   __Pyx_XDECREF(__pyx_t_1);
10558   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildMultiPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
10559   __pyx_r = NULL;
10560   __pyx_L0:;
10561   __Pyx_XGIVEREF(__pyx_r);
10562   __Pyx_RefNannyFinishContext();
10563   return __pyx_r;
10564 }
10565 
10566 /* "rasterio/_features.pyx":538
10567  *         return {'type': 'MultiPoint', 'coordinates': coordinates}
10568  *
10569  *     cpdef _buildMultiLineString(self):             # <<<<<<<<<<<<<<
10570  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
10571  *         return {'type': 'MultiLineString', 'coordinates': coordinates}
10572  */
10573 
10574 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_11_buildMultiLineString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiLineString(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self,int __pyx_skip_dispatch)10575 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiLineString(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
10576   PyObject *__pyx_v_coordinates = NULL;
10577   PyObject *__pyx_8genexpr5__pyx_v_p = NULL;
10578   PyObject *__pyx_r = NULL;
10579   __Pyx_RefNannyDeclarations
10580   PyObject *__pyx_t_1 = NULL;
10581   PyObject *__pyx_t_2 = NULL;
10582   PyObject *__pyx_t_3 = NULL;
10583   PyObject *__pyx_t_4 = NULL;
10584   Py_ssize_t __pyx_t_5;
10585   PyObject *(*__pyx_t_6)(PyObject *);
10586   int __pyx_lineno = 0;
10587   const char *__pyx_filename = NULL;
10588   int __pyx_clineno = 0;
10589   __Pyx_RefNannySetupContext("_buildMultiLineString", 0);
10590   /* Check if called by wrapper */
10591   if (unlikely(__pyx_skip_dispatch)) ;
10592   /* Check if overridden in Python */
10593   else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
10594     #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
10595     static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
10596     if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
10597       PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
10598       #endif
10599       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_buildMultiLineString); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __pyx_L1_error)
10600       __Pyx_GOTREF(__pyx_t_1);
10601       if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_8rasterio_9_features_11GeomBuilder_11_buildMultiLineString)) {
10602         __Pyx_XDECREF(__pyx_r);
10603         __Pyx_INCREF(__pyx_t_1);
10604         __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
10605         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
10606           __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
10607           if (likely(__pyx_t_4)) {
10608             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
10609             __Pyx_INCREF(__pyx_t_4);
10610             __Pyx_INCREF(function);
10611             __Pyx_DECREF_SET(__pyx_t_3, function);
10612           }
10613         }
10614         __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
10615         __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
10616         if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 538, __pyx_L1_error)
10617         __Pyx_GOTREF(__pyx_t_2);
10618         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10619         __pyx_r = __pyx_t_2;
10620         __pyx_t_2 = 0;
10621         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10622         goto __pyx_L0;
10623       }
10624       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
10625       __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
10626       __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
10627       if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
10628         __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
10629       }
10630       #endif
10631       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10632       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
10633     }
10634     #endif
10635   }
10636 
10637   /* "rasterio/_features.pyx":539
10638  *
10639  *     cpdef _buildMultiLineString(self):
10640  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]             # <<<<<<<<<<<<<<
10641  *         return {'type': 'MultiLineString', 'coordinates': coordinates}
10642  *
10643  */
10644   { /* enter inner scope */
10645     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 539, __pyx_L5_error)
10646     __Pyx_GOTREF(__pyx_t_1);
10647     __pyx_t_2 = ((struct __pyx_vtabstruct_8rasterio_9_features_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildParts(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 539, __pyx_L5_error)
10648     __Pyx_GOTREF(__pyx_t_2);
10649     if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
10650       __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
10651       __pyx_t_6 = NULL;
10652     } else {
10653       __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 539, __pyx_L5_error)
10654       __Pyx_GOTREF(__pyx_t_3);
10655       __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 539, __pyx_L5_error)
10656     }
10657     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10658     for (;;) {
10659       if (likely(!__pyx_t_6)) {
10660         if (likely(PyList_CheckExact(__pyx_t_3))) {
10661           if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
10662           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10663           __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 539, __pyx_L5_error)
10664           #else
10665           __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 539, __pyx_L5_error)
10666           __Pyx_GOTREF(__pyx_t_2);
10667           #endif
10668         } else {
10669           if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
10670           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10671           __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 539, __pyx_L5_error)
10672           #else
10673           __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 539, __pyx_L5_error)
10674           __Pyx_GOTREF(__pyx_t_2);
10675           #endif
10676         }
10677       } else {
10678         __pyx_t_2 = __pyx_t_6(__pyx_t_3);
10679         if (unlikely(!__pyx_t_2)) {
10680           PyObject* exc_type = PyErr_Occurred();
10681           if (exc_type) {
10682             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
10683             else __PYX_ERR(0, 539, __pyx_L5_error)
10684           }
10685           break;
10686         }
10687         __Pyx_GOTREF(__pyx_t_2);
10688       }
10689       __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_p, __pyx_t_2);
10690       __pyx_t_2 = 0;
10691       __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_8genexpr5__pyx_v_p, __pyx_n_u_coordinates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 539, __pyx_L5_error)
10692       __Pyx_GOTREF(__pyx_t_2);
10693       if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 539, __pyx_L5_error)
10694       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10695     }
10696     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10697     __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_p); __pyx_8genexpr5__pyx_v_p = 0;
10698     goto __pyx_L8_exit_scope;
10699     __pyx_L5_error:;
10700     __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_p); __pyx_8genexpr5__pyx_v_p = 0;
10701     goto __pyx_L1_error;
10702     __pyx_L8_exit_scope:;
10703   } /* exit inner scope */
10704   __pyx_v_coordinates = ((PyObject*)__pyx_t_1);
10705   __pyx_t_1 = 0;
10706 
10707   /* "rasterio/_features.pyx":540
10708  *     cpdef _buildMultiLineString(self):
10709  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
10710  *         return {'type': 'MultiLineString', 'coordinates': coordinates}             # <<<<<<<<<<<<<<
10711  *
10712  *     cpdef _buildMultiPolygon(self):
10713  */
10714   __Pyx_XDECREF(__pyx_r);
10715   __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 540, __pyx_L1_error)
10716   __Pyx_GOTREF(__pyx_t_1);
10717   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_type, __pyx_n_u_MultiLineString) < 0) __PYX_ERR(0, 540, __pyx_L1_error)
10718   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_coordinates, __pyx_v_coordinates) < 0) __PYX_ERR(0, 540, __pyx_L1_error)
10719   __pyx_r = __pyx_t_1;
10720   __pyx_t_1 = 0;
10721   goto __pyx_L0;
10722 
10723   /* "rasterio/_features.pyx":538
10724  *         return {'type': 'MultiPoint', 'coordinates': coordinates}
10725  *
10726  *     cpdef _buildMultiLineString(self):             # <<<<<<<<<<<<<<
10727  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
10728  *         return {'type': 'MultiLineString', 'coordinates': coordinates}
10729  */
10730 
10731   /* function exit code */
10732   __pyx_L1_error:;
10733   __Pyx_XDECREF(__pyx_t_1);
10734   __Pyx_XDECREF(__pyx_t_2);
10735   __Pyx_XDECREF(__pyx_t_3);
10736   __Pyx_XDECREF(__pyx_t_4);
10737   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildMultiLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
10738   __pyx_r = 0;
10739   __pyx_L0:;
10740   __Pyx_XDECREF(__pyx_v_coordinates);
10741   __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_p);
10742   __Pyx_XGIVEREF(__pyx_r);
10743   __Pyx_RefNannyFinishContext();
10744   return __pyx_r;
10745 }
10746 
10747 /* Python wrapper */
10748 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_11_buildMultiLineString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_8rasterio_9_features_11GeomBuilder_11_buildMultiLineString(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)10749 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_11_buildMultiLineString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10750   PyObject *__pyx_r = 0;
10751   __Pyx_RefNannyDeclarations
10752   __Pyx_RefNannySetupContext("_buildMultiLineString (wrapper)", 0);
10753   __pyx_r = __pyx_pf_8rasterio_9_features_11GeomBuilder_10_buildMultiLineString(((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)__pyx_v_self));
10754 
10755   /* function exit code */
10756   __Pyx_RefNannyFinishContext();
10757   return __pyx_r;
10758 }
10759 
__pyx_pf_8rasterio_9_features_11GeomBuilder_10_buildMultiLineString(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self)10760 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_10_buildMultiLineString(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self) {
10761   PyObject *__pyx_r = NULL;
10762   __Pyx_RefNannyDeclarations
10763   PyObject *__pyx_t_1 = NULL;
10764   int __pyx_lineno = 0;
10765   const char *__pyx_filename = NULL;
10766   int __pyx_clineno = 0;
10767   __Pyx_RefNannySetupContext("_buildMultiLineString", 0);
10768   __Pyx_XDECREF(__pyx_r);
10769   __pyx_t_1 = __pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiLineString(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 538, __pyx_L1_error)
10770   __Pyx_GOTREF(__pyx_t_1);
10771   __pyx_r = __pyx_t_1;
10772   __pyx_t_1 = 0;
10773   goto __pyx_L0;
10774 
10775   /* function exit code */
10776   __pyx_L1_error:;
10777   __Pyx_XDECREF(__pyx_t_1);
10778   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildMultiLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
10779   __pyx_r = NULL;
10780   __pyx_L0:;
10781   __Pyx_XGIVEREF(__pyx_r);
10782   __Pyx_RefNannyFinishContext();
10783   return __pyx_r;
10784 }
10785 
10786 /* "rasterio/_features.pyx":542
10787  *         return {'type': 'MultiLineString', 'coordinates': coordinates}
10788  *
10789  *     cpdef _buildMultiPolygon(self):             # <<<<<<<<<<<<<<
10790  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
10791  *         return {'type': 'MultiPolygon', 'coordinates': coordinates}
10792  */
10793 
10794 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_13_buildMultiPolygon(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiPolygon(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self,int __pyx_skip_dispatch)10795 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiPolygon(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
10796   PyObject *__pyx_v_coordinates = NULL;
10797   PyObject *__pyx_8genexpr6__pyx_v_p = NULL;
10798   PyObject *__pyx_r = NULL;
10799   __Pyx_RefNannyDeclarations
10800   PyObject *__pyx_t_1 = NULL;
10801   PyObject *__pyx_t_2 = NULL;
10802   PyObject *__pyx_t_3 = NULL;
10803   PyObject *__pyx_t_4 = NULL;
10804   Py_ssize_t __pyx_t_5;
10805   PyObject *(*__pyx_t_6)(PyObject *);
10806   int __pyx_lineno = 0;
10807   const char *__pyx_filename = NULL;
10808   int __pyx_clineno = 0;
10809   __Pyx_RefNannySetupContext("_buildMultiPolygon", 0);
10810   /* Check if called by wrapper */
10811   if (unlikely(__pyx_skip_dispatch)) ;
10812   /* Check if overridden in Python */
10813   else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || (Py_TYPE(((PyObject *)__pyx_v_self))->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) {
10814     #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
10815     static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
10816     if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
10817       PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
10818       #endif
10819       __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_buildMultiPolygon); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error)
10820       __Pyx_GOTREF(__pyx_t_1);
10821       if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_8rasterio_9_features_11GeomBuilder_13_buildMultiPolygon)) {
10822         __Pyx_XDECREF(__pyx_r);
10823         __Pyx_INCREF(__pyx_t_1);
10824         __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL;
10825         if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
10826           __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
10827           if (likely(__pyx_t_4)) {
10828             PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
10829             __Pyx_INCREF(__pyx_t_4);
10830             __Pyx_INCREF(function);
10831             __Pyx_DECREF_SET(__pyx_t_3, function);
10832           }
10833         }
10834         __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
10835         __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
10836         if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 542, __pyx_L1_error)
10837         __Pyx_GOTREF(__pyx_t_2);
10838         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10839         __pyx_r = __pyx_t_2;
10840         __pyx_t_2 = 0;
10841         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10842         goto __pyx_L0;
10843       }
10844       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
10845       __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
10846       __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self));
10847       if (unlikely(__pyx_type_dict_guard != __pyx_tp_dict_version)) {
10848         __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT;
10849       }
10850       #endif
10851       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10852       #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
10853     }
10854     #endif
10855   }
10856 
10857   /* "rasterio/_features.pyx":543
10858  *
10859  *     cpdef _buildMultiPolygon(self):
10860  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]             # <<<<<<<<<<<<<<
10861  *         return {'type': 'MultiPolygon', 'coordinates': coordinates}
10862  *
10863  */
10864   { /* enter inner scope */
10865     __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 543, __pyx_L5_error)
10866     __Pyx_GOTREF(__pyx_t_1);
10867     __pyx_t_2 = ((struct __pyx_vtabstruct_8rasterio_9_features_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildParts(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L5_error)
10868     __Pyx_GOTREF(__pyx_t_2);
10869     if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
10870       __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
10871       __pyx_t_6 = NULL;
10872     } else {
10873       __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 543, __pyx_L5_error)
10874       __Pyx_GOTREF(__pyx_t_3);
10875       __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 543, __pyx_L5_error)
10876     }
10877     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10878     for (;;) {
10879       if (likely(!__pyx_t_6)) {
10880         if (likely(PyList_CheckExact(__pyx_t_3))) {
10881           if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
10882           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10883           __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 543, __pyx_L5_error)
10884           #else
10885           __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L5_error)
10886           __Pyx_GOTREF(__pyx_t_2);
10887           #endif
10888         } else {
10889           if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
10890           #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10891           __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 543, __pyx_L5_error)
10892           #else
10893           __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L5_error)
10894           __Pyx_GOTREF(__pyx_t_2);
10895           #endif
10896         }
10897       } else {
10898         __pyx_t_2 = __pyx_t_6(__pyx_t_3);
10899         if (unlikely(!__pyx_t_2)) {
10900           PyObject* exc_type = PyErr_Occurred();
10901           if (exc_type) {
10902             if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
10903             else __PYX_ERR(0, 543, __pyx_L5_error)
10904           }
10905           break;
10906         }
10907         __Pyx_GOTREF(__pyx_t_2);
10908       }
10909       __Pyx_XDECREF_SET(__pyx_8genexpr6__pyx_v_p, __pyx_t_2);
10910       __pyx_t_2 = 0;
10911       __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_8genexpr6__pyx_v_p, __pyx_n_u_coordinates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L5_error)
10912       __Pyx_GOTREF(__pyx_t_2);
10913       if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 543, __pyx_L5_error)
10914       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10915     }
10916     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10917     __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_p); __pyx_8genexpr6__pyx_v_p = 0;
10918     goto __pyx_L8_exit_scope;
10919     __pyx_L5_error:;
10920     __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_p); __pyx_8genexpr6__pyx_v_p = 0;
10921     goto __pyx_L1_error;
10922     __pyx_L8_exit_scope:;
10923   } /* exit inner scope */
10924   __pyx_v_coordinates = ((PyObject*)__pyx_t_1);
10925   __pyx_t_1 = 0;
10926 
10927   /* "rasterio/_features.pyx":544
10928  *     cpdef _buildMultiPolygon(self):
10929  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
10930  *         return {'type': 'MultiPolygon', 'coordinates': coordinates}             # <<<<<<<<<<<<<<
10931  *
10932  *     cdef build(self, OGRGeometryH geom):
10933  */
10934   __Pyx_XDECREF(__pyx_r);
10935   __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 544, __pyx_L1_error)
10936   __Pyx_GOTREF(__pyx_t_1);
10937   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_type, __pyx_n_u_MultiPolygon) < 0) __PYX_ERR(0, 544, __pyx_L1_error)
10938   if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_coordinates, __pyx_v_coordinates) < 0) __PYX_ERR(0, 544, __pyx_L1_error)
10939   __pyx_r = __pyx_t_1;
10940   __pyx_t_1 = 0;
10941   goto __pyx_L0;
10942 
10943   /* "rasterio/_features.pyx":542
10944  *         return {'type': 'MultiLineString', 'coordinates': coordinates}
10945  *
10946  *     cpdef _buildMultiPolygon(self):             # <<<<<<<<<<<<<<
10947  *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
10948  *         return {'type': 'MultiPolygon', 'coordinates': coordinates}
10949  */
10950 
10951   /* function exit code */
10952   __pyx_L1_error:;
10953   __Pyx_XDECREF(__pyx_t_1);
10954   __Pyx_XDECREF(__pyx_t_2);
10955   __Pyx_XDECREF(__pyx_t_3);
10956   __Pyx_XDECREF(__pyx_t_4);
10957   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildMultiPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
10958   __pyx_r = 0;
10959   __pyx_L0:;
10960   __Pyx_XDECREF(__pyx_v_coordinates);
10961   __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_p);
10962   __Pyx_XGIVEREF(__pyx_r);
10963   __Pyx_RefNannyFinishContext();
10964   return __pyx_r;
10965 }
10966 
10967 /* Python wrapper */
10968 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_13_buildMultiPolygon(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_8rasterio_9_features_11GeomBuilder_13_buildMultiPolygon(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)10969 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_13_buildMultiPolygon(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10970   PyObject *__pyx_r = 0;
10971   __Pyx_RefNannyDeclarations
10972   __Pyx_RefNannySetupContext("_buildMultiPolygon (wrapper)", 0);
10973   __pyx_r = __pyx_pf_8rasterio_9_features_11GeomBuilder_12_buildMultiPolygon(((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)__pyx_v_self));
10974 
10975   /* function exit code */
10976   __Pyx_RefNannyFinishContext();
10977   return __pyx_r;
10978 }
10979 
__pyx_pf_8rasterio_9_features_11GeomBuilder_12_buildMultiPolygon(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self)10980 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_12_buildMultiPolygon(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self) {
10981   PyObject *__pyx_r = NULL;
10982   __Pyx_RefNannyDeclarations
10983   PyObject *__pyx_t_1 = NULL;
10984   int __pyx_lineno = 0;
10985   const char *__pyx_filename = NULL;
10986   int __pyx_clineno = 0;
10987   __Pyx_RefNannySetupContext("_buildMultiPolygon", 0);
10988   __Pyx_XDECREF(__pyx_r);
10989   __pyx_t_1 = __pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiPolygon(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L1_error)
10990   __Pyx_GOTREF(__pyx_t_1);
10991   __pyx_r = __pyx_t_1;
10992   __pyx_t_1 = 0;
10993   goto __pyx_L0;
10994 
10995   /* function exit code */
10996   __pyx_L1_error:;
10997   __Pyx_XDECREF(__pyx_t_1);
10998   __Pyx_AddTraceback("rasterio._features.GeomBuilder._buildMultiPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
10999   __pyx_r = NULL;
11000   __pyx_L0:;
11001   __Pyx_XGIVEREF(__pyx_r);
11002   __Pyx_RefNannyFinishContext();
11003   return __pyx_r;
11004 }
11005 
11006 /* "rasterio/_features.pyx":546
11007  *         return {'type': 'MultiPolygon', 'coordinates': coordinates}
11008  *
11009  *     cdef build(self, OGRGeometryH geom):             # <<<<<<<<<<<<<<
11010  *         """Builds a GeoJSON object from an OGR geometry object."""
11011  *         if geom == NULL:
11012  */
11013 
__pyx_f_8rasterio_9_features_11GeomBuilder_build(struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self,OGRGeometryH __pyx_v_geom)11014 static PyObject *__pyx_f_8rasterio_9_features_11GeomBuilder_build(struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, OGRGeometryH __pyx_v_geom) {
11015   unsigned int __pyx_v_etype;
11016   PyObject *__pyx_r = NULL;
11017   __Pyx_RefNannyDeclarations
11018   int __pyx_t_1;
11019   PyObject *__pyx_t_2 = NULL;
11020   PyObject *__pyx_t_3 = NULL;
11021   PyObject *__pyx_t_4 = NULL;
11022   int __pyx_lineno = 0;
11023   const char *__pyx_filename = NULL;
11024   int __pyx_clineno = 0;
11025   __Pyx_RefNannySetupContext("build", 0);
11026 
11027   /* "rasterio/_features.pyx":548
11028  *     cdef build(self, OGRGeometryH geom):
11029  *         """Builds a GeoJSON object from an OGR geometry object."""
11030  *         if geom == NULL:             # <<<<<<<<<<<<<<
11031  *             raise ValueError("Null geom")
11032  *         cdef unsigned int etype = OGR_G_GetGeometryType(geom)
11033  */
11034   __pyx_t_1 = ((__pyx_v_geom == NULL) != 0);
11035   if (unlikely(__pyx_t_1)) {
11036 
11037     /* "rasterio/_features.pyx":549
11038  *         """Builds a GeoJSON object from an OGR geometry object."""
11039  *         if geom == NULL:
11040  *             raise ValueError("Null geom")             # <<<<<<<<<<<<<<
11041  *         cdef unsigned int etype = OGR_G_GetGeometryType(geom)
11042  *         self.code = etype
11043  */
11044     __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 549, __pyx_L1_error)
11045     __Pyx_GOTREF(__pyx_t_2);
11046     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
11047     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11048     __PYX_ERR(0, 549, __pyx_L1_error)
11049 
11050     /* "rasterio/_features.pyx":548
11051  *     cdef build(self, OGRGeometryH geom):
11052  *         """Builds a GeoJSON object from an OGR geometry object."""
11053  *         if geom == NULL:             # <<<<<<<<<<<<<<
11054  *             raise ValueError("Null geom")
11055  *         cdef unsigned int etype = OGR_G_GetGeometryType(geom)
11056  */
11057   }
11058 
11059   /* "rasterio/_features.pyx":550
11060  *         if geom == NULL:
11061  *             raise ValueError("Null geom")
11062  *         cdef unsigned int etype = OGR_G_GetGeometryType(geom)             # <<<<<<<<<<<<<<
11063  *         self.code = etype
11064  *         self.geomtypename = GEOMETRY_TYPES[self.code & (~0x80000000)]
11065  */
11066   __pyx_v_etype = OGR_G_GetGeometryType(__pyx_v_geom);
11067 
11068   /* "rasterio/_features.pyx":551
11069  *             raise ValueError("Null geom")
11070  *         cdef unsigned int etype = OGR_G_GetGeometryType(geom)
11071  *         self.code = etype             # <<<<<<<<<<<<<<
11072  *         self.geomtypename = GEOMETRY_TYPES[self.code & (~0x80000000)]
11073  *         self.ndims = OGR_G_GetCoordinateDimension(geom)
11074  */
11075   __pyx_t_2 = __Pyx_PyInt_From_unsigned_int(__pyx_v_etype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 551, __pyx_L1_error)
11076   __Pyx_GOTREF(__pyx_t_2);
11077   __Pyx_GIVEREF(__pyx_t_2);
11078   __Pyx_GOTREF(__pyx_v_self->code);
11079   __Pyx_DECREF(__pyx_v_self->code);
11080   __pyx_v_self->code = __pyx_t_2;
11081   __pyx_t_2 = 0;
11082 
11083   /* "rasterio/_features.pyx":552
11084  *         cdef unsigned int etype = OGR_G_GetGeometryType(geom)
11085  *         self.code = etype
11086  *         self.geomtypename = GEOMETRY_TYPES[self.code & (~0x80000000)]             # <<<<<<<<<<<<<<
11087  *         self.ndims = OGR_G_GetCoordinateDimension(geom)
11088  *         self.geom = geom
11089  */
11090   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_GEOMETRY_TYPES); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 552, __pyx_L1_error)
11091   __Pyx_GOTREF(__pyx_t_2);
11092   __pyx_t_3 = PyNumber_Invert(__pyx_int_2147483648); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 552, __pyx_L1_error)
11093   __Pyx_GOTREF(__pyx_t_3);
11094   __pyx_t_4 = PyNumber_And(__pyx_v_self->code, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 552, __pyx_L1_error)
11095   __Pyx_GOTREF(__pyx_t_4);
11096   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11097   __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 552, __pyx_L1_error)
11098   __Pyx_GOTREF(__pyx_t_3);
11099   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11100   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
11101   __Pyx_GIVEREF(__pyx_t_3);
11102   __Pyx_GOTREF(__pyx_v_self->geomtypename);
11103   __Pyx_DECREF(__pyx_v_self->geomtypename);
11104   __pyx_v_self->geomtypename = __pyx_t_3;
11105   __pyx_t_3 = 0;
11106 
11107   /* "rasterio/_features.pyx":553
11108  *         self.code = etype
11109  *         self.geomtypename = GEOMETRY_TYPES[self.code & (~0x80000000)]
11110  *         self.ndims = OGR_G_GetCoordinateDimension(geom)             # <<<<<<<<<<<<<<
11111  *         self.geom = geom
11112  *
11113  */
11114   __pyx_t_3 = __Pyx_PyInt_From_int(OGR_G_GetCoordinateDimension(__pyx_v_geom)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 553, __pyx_L1_error)
11115   __Pyx_GOTREF(__pyx_t_3);
11116   __Pyx_GIVEREF(__pyx_t_3);
11117   __Pyx_GOTREF(__pyx_v_self->ndims);
11118   __Pyx_DECREF(__pyx_v_self->ndims);
11119   __pyx_v_self->ndims = __pyx_t_3;
11120   __pyx_t_3 = 0;
11121 
11122   /* "rasterio/_features.pyx":554
11123  *         self.geomtypename = GEOMETRY_TYPES[self.code & (~0x80000000)]
11124  *         self.ndims = OGR_G_GetCoordinateDimension(geom)
11125  *         self.geom = geom             # <<<<<<<<<<<<<<
11126  *
11127  *         return getattr(self, '_build' + self.geomtypename)()
11128  */
11129   __pyx_v_self->geom = __pyx_v_geom;
11130 
11131   /* "rasterio/_features.pyx":556
11132  *         self.geom = geom
11133  *
11134  *         return getattr(self, '_build' + self.geomtypename)()             # <<<<<<<<<<<<<<
11135  *
11136  *
11137  */
11138   __Pyx_XDECREF(__pyx_r);
11139   __pyx_t_4 = PyNumber_Add(__pyx_n_u_build, __pyx_v_self->geomtypename); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 556, __pyx_L1_error)
11140   __Pyx_GOTREF(__pyx_t_4);
11141   __pyx_t_2 = __Pyx_GetAttr(((PyObject *)__pyx_v_self), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 556, __pyx_L1_error)
11142   __Pyx_GOTREF(__pyx_t_2);
11143   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
11144   __pyx_t_4 = NULL;
11145   if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
11146     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
11147     if (likely(__pyx_t_4)) {
11148       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
11149       __Pyx_INCREF(__pyx_t_4);
11150       __Pyx_INCREF(function);
11151       __Pyx_DECREF_SET(__pyx_t_2, function);
11152     }
11153   }
11154   __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
11155   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
11156   if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 556, __pyx_L1_error)
11157   __Pyx_GOTREF(__pyx_t_3);
11158   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11159   __pyx_r = __pyx_t_3;
11160   __pyx_t_3 = 0;
11161   goto __pyx_L0;
11162 
11163   /* "rasterio/_features.pyx":546
11164  *         return {'type': 'MultiPolygon', 'coordinates': coordinates}
11165  *
11166  *     cdef build(self, OGRGeometryH geom):             # <<<<<<<<<<<<<<
11167  *         """Builds a GeoJSON object from an OGR geometry object."""
11168  *         if geom == NULL:
11169  */
11170 
11171   /* function exit code */
11172   __pyx_L1_error:;
11173   __Pyx_XDECREF(__pyx_t_2);
11174   __Pyx_XDECREF(__pyx_t_3);
11175   __Pyx_XDECREF(__pyx_t_4);
11176   __Pyx_AddTraceback("rasterio._features.GeomBuilder.build", __pyx_clineno, __pyx_lineno, __pyx_filename);
11177   __pyx_r = 0;
11178   __pyx_L0:;
11179   __Pyx_XGIVEREF(__pyx_r);
11180   __Pyx_RefNannyFinishContext();
11181   return __pyx_r;
11182 }
11183 
11184 /* "(tree fragment)":1
11185  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
11186  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")
11187  * def __setstate_cython__(self, __pyx_state):
11188  */
11189 
11190 /* Python wrapper */
11191 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_8rasterio_9_features_11GeomBuilder_15__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)11192 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
11193   PyObject *__pyx_r = 0;
11194   __Pyx_RefNannyDeclarations
11195   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
11196   __pyx_r = __pyx_pf_8rasterio_9_features_11GeomBuilder_14__reduce_cython__(((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)__pyx_v_self));
11197 
11198   /* function exit code */
11199   __Pyx_RefNannyFinishContext();
11200   return __pyx_r;
11201 }
11202 
__pyx_pf_8rasterio_9_features_11GeomBuilder_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self)11203 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_14__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self) {
11204   PyObject *__pyx_r = NULL;
11205   __Pyx_RefNannyDeclarations
11206   PyObject *__pyx_t_1 = NULL;
11207   int __pyx_lineno = 0;
11208   const char *__pyx_filename = NULL;
11209   int __pyx_clineno = 0;
11210   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
11211 
11212   /* "(tree fragment)":2
11213  * def __reduce_cython__(self):
11214  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
11215  * def __setstate_cython__(self, __pyx_state):
11216  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")
11217  */
11218   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
11219   __Pyx_GOTREF(__pyx_t_1);
11220   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
11221   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11222   __PYX_ERR(1, 2, __pyx_L1_error)
11223 
11224   /* "(tree fragment)":1
11225  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
11226  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")
11227  * def __setstate_cython__(self, __pyx_state):
11228  */
11229 
11230   /* function exit code */
11231   __pyx_L1_error:;
11232   __Pyx_XDECREF(__pyx_t_1);
11233   __Pyx_AddTraceback("rasterio._features.GeomBuilder.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11234   __pyx_r = NULL;
11235   __Pyx_XGIVEREF(__pyx_r);
11236   __Pyx_RefNannyFinishContext();
11237   return __pyx_r;
11238 }
11239 
11240 /* "(tree fragment)":3
11241  * def __reduce_cython__(self):
11242  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")
11243  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
11244  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")
11245  */
11246 
11247 /* Python wrapper */
11248 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw_8rasterio_9_features_11GeomBuilder_17__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)11249 static PyObject *__pyx_pw_8rasterio_9_features_11GeomBuilder_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
11250   PyObject *__pyx_r = 0;
11251   __Pyx_RefNannyDeclarations
11252   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
11253   __pyx_r = __pyx_pf_8rasterio_9_features_11GeomBuilder_16__setstate_cython__(((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
11254 
11255   /* function exit code */
11256   __Pyx_RefNannyFinishContext();
11257   return __pyx_r;
11258 }
11259 
__pyx_pf_8rasterio_9_features_11GeomBuilder_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_GeomBuilder * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)11260 static PyObject *__pyx_pf_8rasterio_9_features_11GeomBuilder_16__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_GeomBuilder *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
11261   PyObject *__pyx_r = NULL;
11262   __Pyx_RefNannyDeclarations
11263   PyObject *__pyx_t_1 = NULL;
11264   int __pyx_lineno = 0;
11265   const char *__pyx_filename = NULL;
11266   int __pyx_clineno = 0;
11267   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
11268 
11269   /* "(tree fragment)":4
11270  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")
11271  * def __setstate_cython__(self, __pyx_state):
11272  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
11273  */
11274   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
11275   __Pyx_GOTREF(__pyx_t_1);
11276   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
11277   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11278   __PYX_ERR(1, 4, __pyx_L1_error)
11279 
11280   /* "(tree fragment)":3
11281  * def __reduce_cython__(self):
11282  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")
11283  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
11284  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")
11285  */
11286 
11287   /* function exit code */
11288   __pyx_L1_error:;
11289   __Pyx_XDECREF(__pyx_t_1);
11290   __Pyx_AddTraceback("rasterio._features.GeomBuilder.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
11291   __pyx_r = NULL;
11292   __Pyx_XGIVEREF(__pyx_r);
11293   __Pyx_RefNannyFinishContext();
11294   return __pyx_r;
11295 }
11296 
11297 /* "rasterio/_features.pyx":565
11298  *     """
11299  *
11300  *     cdef OGRGeometryH _createOgrGeometry(self, int geom_type) except NULL:             # <<<<<<<<<<<<<<
11301  *         cdef OGRGeometryH geom = OGR_G_CreateGeometry(geom_type)
11302  *         if geom is NULL:
11303  */
11304 
__pyx_f_8rasterio_9_features_14OGRGeomBuilder__createOgrGeometry(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v_self,int __pyx_v_geom_type)11305 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__createOgrGeometry(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, int __pyx_v_geom_type) {
11306   OGRGeometryH __pyx_v_geom;
11307   OGRGeometryH __pyx_r;
11308   __Pyx_RefNannyDeclarations
11309   int __pyx_t_1;
11310   PyObject *__pyx_t_2 = NULL;
11311   PyObject *__pyx_t_3 = NULL;
11312   int __pyx_lineno = 0;
11313   const char *__pyx_filename = NULL;
11314   int __pyx_clineno = 0;
11315   __Pyx_RefNannySetupContext("_createOgrGeometry", 0);
11316 
11317   /* "rasterio/_features.pyx":566
11318  *
11319  *     cdef OGRGeometryH _createOgrGeometry(self, int geom_type) except NULL:
11320  *         cdef OGRGeometryH geom = OGR_G_CreateGeometry(geom_type)             # <<<<<<<<<<<<<<
11321  *         if geom is NULL:
11322  *             raise Exception(
11323  */
11324   __pyx_v_geom = OGR_G_CreateGeometry(__pyx_v_geom_type);
11325 
11326   /* "rasterio/_features.pyx":567
11327  *     cdef OGRGeometryH _createOgrGeometry(self, int geom_type) except NULL:
11328  *         cdef OGRGeometryH geom = OGR_G_CreateGeometry(geom_type)
11329  *         if geom is NULL:             # <<<<<<<<<<<<<<
11330  *             raise Exception(
11331  *                 "Could not create OGR Geometry of type: %i" % geom_type)
11332  */
11333   __pyx_t_1 = ((__pyx_v_geom == NULL) != 0);
11334   if (unlikely(__pyx_t_1)) {
11335 
11336     /* "rasterio/_features.pyx":569
11337  *         if geom is NULL:
11338  *             raise Exception(
11339  *                 "Could not create OGR Geometry of type: %i" % geom_type)             # <<<<<<<<<<<<<<
11340  *         return geom
11341  *
11342  */
11343     __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_geom_type); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 569, __pyx_L1_error)
11344     __Pyx_GOTREF(__pyx_t_2);
11345     __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_Could_not_create_OGR_Geometry_of, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 569, __pyx_L1_error)
11346     __Pyx_GOTREF(__pyx_t_3);
11347     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11348 
11349     /* "rasterio/_features.pyx":568
11350  *         cdef OGRGeometryH geom = OGR_G_CreateGeometry(geom_type)
11351  *         if geom is NULL:
11352  *             raise Exception(             # <<<<<<<<<<<<<<
11353  *                 "Could not create OGR Geometry of type: %i" % geom_type)
11354  *         return geom
11355  */
11356     __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 568, __pyx_L1_error)
11357     __Pyx_GOTREF(__pyx_t_2);
11358     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
11359     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
11360     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11361     __PYX_ERR(0, 568, __pyx_L1_error)
11362 
11363     /* "rasterio/_features.pyx":567
11364  *     cdef OGRGeometryH _createOgrGeometry(self, int geom_type) except NULL:
11365  *         cdef OGRGeometryH geom = OGR_G_CreateGeometry(geom_type)
11366  *         if geom is NULL:             # <<<<<<<<<<<<<<
11367  *             raise Exception(
11368  *                 "Could not create OGR Geometry of type: %i" % geom_type)
11369  */
11370   }
11371 
11372   /* "rasterio/_features.pyx":570
11373  *             raise Exception(
11374  *                 "Could not create OGR Geometry of type: %i" % geom_type)
11375  *         return geom             # <<<<<<<<<<<<<<
11376  *
11377  *     cdef _addPointToGeometry(self, OGRGeometryH geom, object coordinate):
11378  */
11379   __pyx_r = __pyx_v_geom;
11380   goto __pyx_L0;
11381 
11382   /* "rasterio/_features.pyx":565
11383  *     """
11384  *
11385  *     cdef OGRGeometryH _createOgrGeometry(self, int geom_type) except NULL:             # <<<<<<<<<<<<<<
11386  *         cdef OGRGeometryH geom = OGR_G_CreateGeometry(geom_type)
11387  *         if geom is NULL:
11388  */
11389 
11390   /* function exit code */
11391   __pyx_L1_error:;
11392   __Pyx_XDECREF(__pyx_t_2);
11393   __Pyx_XDECREF(__pyx_t_3);
11394   __Pyx_AddTraceback("rasterio._features.OGRGeomBuilder._createOgrGeometry", __pyx_clineno, __pyx_lineno, __pyx_filename);
11395   __pyx_r = NULL;
11396   __pyx_L0:;
11397   __Pyx_RefNannyFinishContext();
11398   return __pyx_r;
11399 }
11400 
11401 /* "rasterio/_features.pyx":572
11402  *         return geom
11403  *
11404  *     cdef _addPointToGeometry(self, OGRGeometryH geom, object coordinate):             # <<<<<<<<<<<<<<
11405  *         if len(coordinate) == 2:
11406  *             x, y = coordinate
11407  */
11408 
__pyx_f_8rasterio_9_features_14OGRGeomBuilder__addPointToGeometry(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v_self,OGRGeometryH __pyx_v_geom,PyObject * __pyx_v_coordinate)11409 static PyObject *__pyx_f_8rasterio_9_features_14OGRGeomBuilder__addPointToGeometry(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, OGRGeometryH __pyx_v_geom, PyObject *__pyx_v_coordinate) {
11410   PyObject *__pyx_v_x = NULL;
11411   PyObject *__pyx_v_y = NULL;
11412   PyObject *__pyx_v_z = NULL;
11413   PyObject *__pyx_r = NULL;
11414   __Pyx_RefNannyDeclarations
11415   Py_ssize_t __pyx_t_1;
11416   int __pyx_t_2;
11417   PyObject *__pyx_t_3 = NULL;
11418   PyObject *__pyx_t_4 = NULL;
11419   PyObject *__pyx_t_5 = NULL;
11420   PyObject *(*__pyx_t_6)(PyObject *);
11421   double __pyx_t_7;
11422   double __pyx_t_8;
11423   PyObject *__pyx_t_9 = NULL;
11424   PyObject *__pyx_t_10 = NULL;
11425   double __pyx_t_11;
11426   int __pyx_lineno = 0;
11427   const char *__pyx_filename = NULL;
11428   int __pyx_clineno = 0;
11429   __Pyx_RefNannySetupContext("_addPointToGeometry", 0);
11430 
11431   /* "rasterio/_features.pyx":573
11432  *
11433  *     cdef _addPointToGeometry(self, OGRGeometryH geom, object coordinate):
11434  *         if len(coordinate) == 2:             # <<<<<<<<<<<<<<
11435  *             x, y = coordinate
11436  *             OGR_G_AddPoint_2D(geom, x, y)
11437  */
11438   __pyx_t_1 = PyObject_Length(__pyx_v_coordinate); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 573, __pyx_L1_error)
11439   __pyx_t_2 = ((__pyx_t_1 == 2) != 0);
11440   if (__pyx_t_2) {
11441 
11442     /* "rasterio/_features.pyx":574
11443  *     cdef _addPointToGeometry(self, OGRGeometryH geom, object coordinate):
11444  *         if len(coordinate) == 2:
11445  *             x, y = coordinate             # <<<<<<<<<<<<<<
11446  *             OGR_G_AddPoint_2D(geom, x, y)
11447  *         else:
11448  */
11449     if ((likely(PyTuple_CheckExact(__pyx_v_coordinate))) || (PyList_CheckExact(__pyx_v_coordinate))) {
11450       PyObject* sequence = __pyx_v_coordinate;
11451       Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
11452       if (unlikely(size != 2)) {
11453         if (size > 2) __Pyx_RaiseTooManyValuesError(2);
11454         else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
11455         __PYX_ERR(0, 574, __pyx_L1_error)
11456       }
11457       #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11458       if (likely(PyTuple_CheckExact(sequence))) {
11459         __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
11460         __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
11461       } else {
11462         __pyx_t_3 = PyList_GET_ITEM(sequence, 0);
11463         __pyx_t_4 = PyList_GET_ITEM(sequence, 1);
11464       }
11465       __Pyx_INCREF(__pyx_t_3);
11466       __Pyx_INCREF(__pyx_t_4);
11467       #else
11468       __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 574, __pyx_L1_error)
11469       __Pyx_GOTREF(__pyx_t_3);
11470       __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 574, __pyx_L1_error)
11471       __Pyx_GOTREF(__pyx_t_4);
11472       #endif
11473     } else {
11474       Py_ssize_t index = -1;
11475       __pyx_t_5 = PyObject_GetIter(__pyx_v_coordinate); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 574, __pyx_L1_error)
11476       __Pyx_GOTREF(__pyx_t_5);
11477       __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
11478       index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
11479       __Pyx_GOTREF(__pyx_t_3);
11480       index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L4_unpacking_failed;
11481       __Pyx_GOTREF(__pyx_t_4);
11482       if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 574, __pyx_L1_error)
11483       __pyx_t_6 = NULL;
11484       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
11485       goto __pyx_L5_unpacking_done;
11486       __pyx_L4_unpacking_failed:;
11487       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
11488       __pyx_t_6 = NULL;
11489       if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
11490       __PYX_ERR(0, 574, __pyx_L1_error)
11491       __pyx_L5_unpacking_done:;
11492     }
11493     __pyx_v_x = __pyx_t_3;
11494     __pyx_t_3 = 0;
11495     __pyx_v_y = __pyx_t_4;
11496     __pyx_t_4 = 0;
11497 
11498     /* "rasterio/_features.pyx":575
11499  *         if len(coordinate) == 2:
11500  *             x, y = coordinate
11501  *             OGR_G_AddPoint_2D(geom, x, y)             # <<<<<<<<<<<<<<
11502  *         else:
11503  *             x, y, z = coordinate[:3]
11504  */
11505     __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_v_x); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 575, __pyx_L1_error)
11506     __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_v_y); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 575, __pyx_L1_error)
11507     OGR_G_AddPoint_2D(__pyx_v_geom, __pyx_t_7, __pyx_t_8);
11508 
11509     /* "rasterio/_features.pyx":573
11510  *
11511  *     cdef _addPointToGeometry(self, OGRGeometryH geom, object coordinate):
11512  *         if len(coordinate) == 2:             # <<<<<<<<<<<<<<
11513  *             x, y = coordinate
11514  *             OGR_G_AddPoint_2D(geom, x, y)
11515  */
11516     goto __pyx_L3;
11517   }
11518 
11519   /* "rasterio/_features.pyx":577
11520  *             OGR_G_AddPoint_2D(geom, x, y)
11521  *         else:
11522  *             x, y, z = coordinate[:3]             # <<<<<<<<<<<<<<
11523  *             OGR_G_AddPoint(geom, x, y, z)
11524  *
11525  */
11526   /*else*/ {
11527     __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_coordinate, 0, 3, NULL, NULL, &__pyx_slice__26, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 577, __pyx_L1_error)
11528     __Pyx_GOTREF(__pyx_t_4);
11529     if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
11530       PyObject* sequence = __pyx_t_4;
11531       Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
11532       if (unlikely(size != 3)) {
11533         if (size > 3) __Pyx_RaiseTooManyValuesError(3);
11534         else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
11535         __PYX_ERR(0, 577, __pyx_L1_error)
11536       }
11537       #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11538       if (likely(PyTuple_CheckExact(sequence))) {
11539         __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
11540         __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
11541         __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2);
11542       } else {
11543         __pyx_t_3 = PyList_GET_ITEM(sequence, 0);
11544         __pyx_t_5 = PyList_GET_ITEM(sequence, 1);
11545         __pyx_t_9 = PyList_GET_ITEM(sequence, 2);
11546       }
11547       __Pyx_INCREF(__pyx_t_3);
11548       __Pyx_INCREF(__pyx_t_5);
11549       __Pyx_INCREF(__pyx_t_9);
11550       #else
11551       __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 577, __pyx_L1_error)
11552       __Pyx_GOTREF(__pyx_t_3);
11553       __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 577, __pyx_L1_error)
11554       __Pyx_GOTREF(__pyx_t_5);
11555       __pyx_t_9 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 577, __pyx_L1_error)
11556       __Pyx_GOTREF(__pyx_t_9);
11557       #endif
11558       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
11559     } else {
11560       Py_ssize_t index = -1;
11561       __pyx_t_10 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 577, __pyx_L1_error)
11562       __Pyx_GOTREF(__pyx_t_10);
11563       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
11564       __pyx_t_6 = Py_TYPE(__pyx_t_10)->tp_iternext;
11565       index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_10); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
11566       __Pyx_GOTREF(__pyx_t_3);
11567       index = 1; __pyx_t_5 = __pyx_t_6(__pyx_t_10); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
11568       __Pyx_GOTREF(__pyx_t_5);
11569       index = 2; __pyx_t_9 = __pyx_t_6(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L6_unpacking_failed;
11570       __Pyx_GOTREF(__pyx_t_9);
11571       if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_10), 3) < 0) __PYX_ERR(0, 577, __pyx_L1_error)
11572       __pyx_t_6 = NULL;
11573       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
11574       goto __pyx_L7_unpacking_done;
11575       __pyx_L6_unpacking_failed:;
11576       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
11577       __pyx_t_6 = NULL;
11578       if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
11579       __PYX_ERR(0, 577, __pyx_L1_error)
11580       __pyx_L7_unpacking_done:;
11581     }
11582     __pyx_v_x = __pyx_t_3;
11583     __pyx_t_3 = 0;
11584     __pyx_v_y = __pyx_t_5;
11585     __pyx_t_5 = 0;
11586     __pyx_v_z = __pyx_t_9;
11587     __pyx_t_9 = 0;
11588 
11589     /* "rasterio/_features.pyx":578
11590  *         else:
11591  *             x, y, z = coordinate[:3]
11592  *             OGR_G_AddPoint(geom, x, y, z)             # <<<<<<<<<<<<<<
11593  *
11594  *     cdef OGRGeometryH _buildPoint(self, object coordinates) except NULL:
11595  */
11596     __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_v_x); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 578, __pyx_L1_error)
11597     __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_v_y); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 578, __pyx_L1_error)
11598     __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_v_z); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 578, __pyx_L1_error)
11599     OGR_G_AddPoint(__pyx_v_geom, __pyx_t_8, __pyx_t_7, __pyx_t_11);
11600   }
11601   __pyx_L3:;
11602 
11603   /* "rasterio/_features.pyx":572
11604  *         return geom
11605  *
11606  *     cdef _addPointToGeometry(self, OGRGeometryH geom, object coordinate):             # <<<<<<<<<<<<<<
11607  *         if len(coordinate) == 2:
11608  *             x, y = coordinate
11609  */
11610 
11611   /* function exit code */
11612   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
11613   goto __pyx_L0;
11614   __pyx_L1_error:;
11615   __Pyx_XDECREF(__pyx_t_3);
11616   __Pyx_XDECREF(__pyx_t_4);
11617   __Pyx_XDECREF(__pyx_t_5);
11618   __Pyx_XDECREF(__pyx_t_9);
11619   __Pyx_XDECREF(__pyx_t_10);
11620   __Pyx_AddTraceback("rasterio._features.OGRGeomBuilder._addPointToGeometry", __pyx_clineno, __pyx_lineno, __pyx_filename);
11621   __pyx_r = 0;
11622   __pyx_L0:;
11623   __Pyx_XDECREF(__pyx_v_x);
11624   __Pyx_XDECREF(__pyx_v_y);
11625   __Pyx_XDECREF(__pyx_v_z);
11626   __Pyx_XGIVEREF(__pyx_r);
11627   __Pyx_RefNannyFinishContext();
11628   return __pyx_r;
11629 }
11630 
11631 /* "rasterio/_features.pyx":580
11632  *             OGR_G_AddPoint(geom, x, y, z)
11633  *
11634  *     cdef OGRGeometryH _buildPoint(self, object coordinates) except NULL:             # <<<<<<<<<<<<<<
11635  *         cdef OGRGeometryH geom = self._createOgrGeometry(
11636  *             GEOJSON2OGR_GEOMETRY_TYPES['Point'])
11637  */
11638 
__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildPoint(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v_self,PyObject * __pyx_v_coordinates)11639 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildPoint(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates) {
11640   OGRGeometryH __pyx_v_geom;
11641   OGRGeometryH __pyx_r;
11642   __Pyx_RefNannyDeclarations
11643   PyObject *__pyx_t_1 = NULL;
11644   PyObject *__pyx_t_2 = NULL;
11645   int __pyx_t_3;
11646   OGRGeometryH __pyx_t_4;
11647   int __pyx_lineno = 0;
11648   const char *__pyx_filename = NULL;
11649   int __pyx_clineno = 0;
11650   __Pyx_RefNannySetupContext("_buildPoint", 0);
11651 
11652   /* "rasterio/_features.pyx":582
11653  *     cdef OGRGeometryH _buildPoint(self, object coordinates) except NULL:
11654  *         cdef OGRGeometryH geom = self._createOgrGeometry(
11655  *             GEOJSON2OGR_GEOMETRY_TYPES['Point'])             # <<<<<<<<<<<<<<
11656  *         self._addPointToGeometry(geom, coordinates)
11657  *         return geom
11658  */
11659   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_GEOJSON2OGR_GEOMETRY_TYPES); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 582, __pyx_L1_error)
11660   __Pyx_GOTREF(__pyx_t_1);
11661   __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_Point); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 582, __pyx_L1_error)
11662   __Pyx_GOTREF(__pyx_t_2);
11663   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11664   __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 582, __pyx_L1_error)
11665   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11666 
11667   /* "rasterio/_features.pyx":581
11668  *
11669  *     cdef OGRGeometryH _buildPoint(self, object coordinates) except NULL:
11670  *         cdef OGRGeometryH geom = self._createOgrGeometry(             # <<<<<<<<<<<<<<
11671  *             GEOJSON2OGR_GEOMETRY_TYPES['Point'])
11672  *         self._addPointToGeometry(geom, coordinates)
11673  */
11674   __pyx_t_4 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_createOgrGeometry(__pyx_v_self, __pyx_t_3); if (unlikely(__pyx_t_4 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 581, __pyx_L1_error)
11675   __pyx_v_geom = __pyx_t_4;
11676 
11677   /* "rasterio/_features.pyx":583
11678  *         cdef OGRGeometryH geom = self._createOgrGeometry(
11679  *             GEOJSON2OGR_GEOMETRY_TYPES['Point'])
11680  *         self._addPointToGeometry(geom, coordinates)             # <<<<<<<<<<<<<<
11681  *         return geom
11682  *
11683  */
11684   __pyx_t_2 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_addPointToGeometry(__pyx_v_self, __pyx_v_geom, __pyx_v_coordinates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 583, __pyx_L1_error)
11685   __Pyx_GOTREF(__pyx_t_2);
11686   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11687 
11688   /* "rasterio/_features.pyx":584
11689  *             GEOJSON2OGR_GEOMETRY_TYPES['Point'])
11690  *         self._addPointToGeometry(geom, coordinates)
11691  *         return geom             # <<<<<<<<<<<<<<
11692  *
11693  *     cdef OGRGeometryH _buildLineString(self, object coordinates) except NULL:
11694  */
11695   __pyx_r = __pyx_v_geom;
11696   goto __pyx_L0;
11697 
11698   /* "rasterio/_features.pyx":580
11699  *             OGR_G_AddPoint(geom, x, y, z)
11700  *
11701  *     cdef OGRGeometryH _buildPoint(self, object coordinates) except NULL:             # <<<<<<<<<<<<<<
11702  *         cdef OGRGeometryH geom = self._createOgrGeometry(
11703  *             GEOJSON2OGR_GEOMETRY_TYPES['Point'])
11704  */
11705 
11706   /* function exit code */
11707   __pyx_L1_error:;
11708   __Pyx_XDECREF(__pyx_t_1);
11709   __Pyx_XDECREF(__pyx_t_2);
11710   __Pyx_AddTraceback("rasterio._features.OGRGeomBuilder._buildPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
11711   __pyx_r = NULL;
11712   __pyx_L0:;
11713   __Pyx_RefNannyFinishContext();
11714   return __pyx_r;
11715 }
11716 
11717 /* "rasterio/_features.pyx":586
11718  *         return geom
11719  *
11720  *     cdef OGRGeometryH _buildLineString(self, object coordinates) except NULL:             # <<<<<<<<<<<<<<
11721  *         cdef OGRGeometryH geom = self._createOgrGeometry(
11722  *             GEOJSON2OGR_GEOMETRY_TYPES['LineString'])
11723  */
11724 
__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildLineString(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v_self,PyObject * __pyx_v_coordinates)11725 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildLineString(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates) {
11726   OGRGeometryH __pyx_v_geom;
11727   PyObject *__pyx_v_coordinate = NULL;
11728   OGRGeometryH __pyx_r;
11729   __Pyx_RefNannyDeclarations
11730   PyObject *__pyx_t_1 = NULL;
11731   PyObject *__pyx_t_2 = NULL;
11732   int __pyx_t_3;
11733   OGRGeometryH __pyx_t_4;
11734   Py_ssize_t __pyx_t_5;
11735   PyObject *(*__pyx_t_6)(PyObject *);
11736   int __pyx_lineno = 0;
11737   const char *__pyx_filename = NULL;
11738   int __pyx_clineno = 0;
11739   __Pyx_RefNannySetupContext("_buildLineString", 0);
11740 
11741   /* "rasterio/_features.pyx":588
11742  *     cdef OGRGeometryH _buildLineString(self, object coordinates) except NULL:
11743  *         cdef OGRGeometryH geom = self._createOgrGeometry(
11744  *             GEOJSON2OGR_GEOMETRY_TYPES['LineString'])             # <<<<<<<<<<<<<<
11745  *         for coordinate in coordinates:
11746  *             self._addPointToGeometry(geom, coordinate)
11747  */
11748   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_GEOJSON2OGR_GEOMETRY_TYPES); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 588, __pyx_L1_error)
11749   __Pyx_GOTREF(__pyx_t_1);
11750   __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_LineString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 588, __pyx_L1_error)
11751   __Pyx_GOTREF(__pyx_t_2);
11752   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11753   __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 588, __pyx_L1_error)
11754   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11755 
11756   /* "rasterio/_features.pyx":587
11757  *
11758  *     cdef OGRGeometryH _buildLineString(self, object coordinates) except NULL:
11759  *         cdef OGRGeometryH geom = self._createOgrGeometry(             # <<<<<<<<<<<<<<
11760  *             GEOJSON2OGR_GEOMETRY_TYPES['LineString'])
11761  *         for coordinate in coordinates:
11762  */
11763   __pyx_t_4 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_createOgrGeometry(__pyx_v_self, __pyx_t_3); if (unlikely(__pyx_t_4 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 587, __pyx_L1_error)
11764   __pyx_v_geom = __pyx_t_4;
11765 
11766   /* "rasterio/_features.pyx":589
11767  *         cdef OGRGeometryH geom = self._createOgrGeometry(
11768  *             GEOJSON2OGR_GEOMETRY_TYPES['LineString'])
11769  *         for coordinate in coordinates:             # <<<<<<<<<<<<<<
11770  *             self._addPointToGeometry(geom, coordinate)
11771  *         return geom
11772  */
11773   if (likely(PyList_CheckExact(__pyx_v_coordinates)) || PyTuple_CheckExact(__pyx_v_coordinates)) {
11774     __pyx_t_2 = __pyx_v_coordinates; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
11775     __pyx_t_6 = NULL;
11776   } else {
11777     __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_coordinates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 589, __pyx_L1_error)
11778     __Pyx_GOTREF(__pyx_t_2);
11779     __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 589, __pyx_L1_error)
11780   }
11781   for (;;) {
11782     if (likely(!__pyx_t_6)) {
11783       if (likely(PyList_CheckExact(__pyx_t_2))) {
11784         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
11785         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11786         __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 589, __pyx_L1_error)
11787         #else
11788         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 589, __pyx_L1_error)
11789         __Pyx_GOTREF(__pyx_t_1);
11790         #endif
11791       } else {
11792         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
11793         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11794         __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 589, __pyx_L1_error)
11795         #else
11796         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 589, __pyx_L1_error)
11797         __Pyx_GOTREF(__pyx_t_1);
11798         #endif
11799       }
11800     } else {
11801       __pyx_t_1 = __pyx_t_6(__pyx_t_2);
11802       if (unlikely(!__pyx_t_1)) {
11803         PyObject* exc_type = PyErr_Occurred();
11804         if (exc_type) {
11805           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
11806           else __PYX_ERR(0, 589, __pyx_L1_error)
11807         }
11808         break;
11809       }
11810       __Pyx_GOTREF(__pyx_t_1);
11811     }
11812     __Pyx_XDECREF_SET(__pyx_v_coordinate, __pyx_t_1);
11813     __pyx_t_1 = 0;
11814 
11815     /* "rasterio/_features.pyx":590
11816  *             GEOJSON2OGR_GEOMETRY_TYPES['LineString'])
11817  *         for coordinate in coordinates:
11818  *             self._addPointToGeometry(geom, coordinate)             # <<<<<<<<<<<<<<
11819  *         return geom
11820  *
11821  */
11822     __pyx_t_1 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_addPointToGeometry(__pyx_v_self, __pyx_v_geom, __pyx_v_coordinate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 590, __pyx_L1_error)
11823     __Pyx_GOTREF(__pyx_t_1);
11824     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11825 
11826     /* "rasterio/_features.pyx":589
11827  *         cdef OGRGeometryH geom = self._createOgrGeometry(
11828  *             GEOJSON2OGR_GEOMETRY_TYPES['LineString'])
11829  *         for coordinate in coordinates:             # <<<<<<<<<<<<<<
11830  *             self._addPointToGeometry(geom, coordinate)
11831  *         return geom
11832  */
11833   }
11834   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11835 
11836   /* "rasterio/_features.pyx":591
11837  *         for coordinate in coordinates:
11838  *             self._addPointToGeometry(geom, coordinate)
11839  *         return geom             # <<<<<<<<<<<<<<
11840  *
11841  *     cdef OGRGeometryH _buildLinearRing(self, object coordinates) except NULL:
11842  */
11843   __pyx_r = __pyx_v_geom;
11844   goto __pyx_L0;
11845 
11846   /* "rasterio/_features.pyx":586
11847  *         return geom
11848  *
11849  *     cdef OGRGeometryH _buildLineString(self, object coordinates) except NULL:             # <<<<<<<<<<<<<<
11850  *         cdef OGRGeometryH geom = self._createOgrGeometry(
11851  *             GEOJSON2OGR_GEOMETRY_TYPES['LineString'])
11852  */
11853 
11854   /* function exit code */
11855   __pyx_L1_error:;
11856   __Pyx_XDECREF(__pyx_t_1);
11857   __Pyx_XDECREF(__pyx_t_2);
11858   __Pyx_AddTraceback("rasterio._features.OGRGeomBuilder._buildLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
11859   __pyx_r = NULL;
11860   __pyx_L0:;
11861   __Pyx_XDECREF(__pyx_v_coordinate);
11862   __Pyx_RefNannyFinishContext();
11863   return __pyx_r;
11864 }
11865 
11866 /* "rasterio/_features.pyx":593
11867  *         return geom
11868  *
11869  *     cdef OGRGeometryH _buildLinearRing(self, object coordinates) except NULL:             # <<<<<<<<<<<<<<
11870  *         cdef OGRGeometryH geom = self._createOgrGeometry(
11871  *             GEOJSON2OGR_GEOMETRY_TYPES['LinearRing'])
11872  */
11873 
__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildLinearRing(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v_self,PyObject * __pyx_v_coordinates)11874 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildLinearRing(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates) {
11875   OGRGeometryH __pyx_v_geom;
11876   PyObject *__pyx_v_coordinate = NULL;
11877   OGRGeometryH __pyx_r;
11878   __Pyx_RefNannyDeclarations
11879   PyObject *__pyx_t_1 = NULL;
11880   PyObject *__pyx_t_2 = NULL;
11881   int __pyx_t_3;
11882   OGRGeometryH __pyx_t_4;
11883   Py_ssize_t __pyx_t_5;
11884   PyObject *(*__pyx_t_6)(PyObject *);
11885   int __pyx_lineno = 0;
11886   const char *__pyx_filename = NULL;
11887   int __pyx_clineno = 0;
11888   __Pyx_RefNannySetupContext("_buildLinearRing", 0);
11889 
11890   /* "rasterio/_features.pyx":595
11891  *     cdef OGRGeometryH _buildLinearRing(self, object coordinates) except NULL:
11892  *         cdef OGRGeometryH geom = self._createOgrGeometry(
11893  *             GEOJSON2OGR_GEOMETRY_TYPES['LinearRing'])             # <<<<<<<<<<<<<<
11894  *         for coordinate in coordinates:
11895  *             self._addPointToGeometry(geom, coordinate)
11896  */
11897   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_GEOJSON2OGR_GEOMETRY_TYPES); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 595, __pyx_L1_error)
11898   __Pyx_GOTREF(__pyx_t_1);
11899   __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_LinearRing); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 595, __pyx_L1_error)
11900   __Pyx_GOTREF(__pyx_t_2);
11901   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11902   __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 595, __pyx_L1_error)
11903   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11904 
11905   /* "rasterio/_features.pyx":594
11906  *
11907  *     cdef OGRGeometryH _buildLinearRing(self, object coordinates) except NULL:
11908  *         cdef OGRGeometryH geom = self._createOgrGeometry(             # <<<<<<<<<<<<<<
11909  *             GEOJSON2OGR_GEOMETRY_TYPES['LinearRing'])
11910  *         for coordinate in coordinates:
11911  */
11912   __pyx_t_4 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_createOgrGeometry(__pyx_v_self, __pyx_t_3); if (unlikely(__pyx_t_4 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 594, __pyx_L1_error)
11913   __pyx_v_geom = __pyx_t_4;
11914 
11915   /* "rasterio/_features.pyx":596
11916  *         cdef OGRGeometryH geom = self._createOgrGeometry(
11917  *             GEOJSON2OGR_GEOMETRY_TYPES['LinearRing'])
11918  *         for coordinate in coordinates:             # <<<<<<<<<<<<<<
11919  *             self._addPointToGeometry(geom, coordinate)
11920  *         OGR_G_CloseRings(geom)
11921  */
11922   if (likely(PyList_CheckExact(__pyx_v_coordinates)) || PyTuple_CheckExact(__pyx_v_coordinates)) {
11923     __pyx_t_2 = __pyx_v_coordinates; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
11924     __pyx_t_6 = NULL;
11925   } else {
11926     __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_coordinates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 596, __pyx_L1_error)
11927     __Pyx_GOTREF(__pyx_t_2);
11928     __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 596, __pyx_L1_error)
11929   }
11930   for (;;) {
11931     if (likely(!__pyx_t_6)) {
11932       if (likely(PyList_CheckExact(__pyx_t_2))) {
11933         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
11934         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11935         __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 596, __pyx_L1_error)
11936         #else
11937         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 596, __pyx_L1_error)
11938         __Pyx_GOTREF(__pyx_t_1);
11939         #endif
11940       } else {
11941         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
11942         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11943         __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 596, __pyx_L1_error)
11944         #else
11945         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 596, __pyx_L1_error)
11946         __Pyx_GOTREF(__pyx_t_1);
11947         #endif
11948       }
11949     } else {
11950       __pyx_t_1 = __pyx_t_6(__pyx_t_2);
11951       if (unlikely(!__pyx_t_1)) {
11952         PyObject* exc_type = PyErr_Occurred();
11953         if (exc_type) {
11954           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
11955           else __PYX_ERR(0, 596, __pyx_L1_error)
11956         }
11957         break;
11958       }
11959       __Pyx_GOTREF(__pyx_t_1);
11960     }
11961     __Pyx_XDECREF_SET(__pyx_v_coordinate, __pyx_t_1);
11962     __pyx_t_1 = 0;
11963 
11964     /* "rasterio/_features.pyx":597
11965  *             GEOJSON2OGR_GEOMETRY_TYPES['LinearRing'])
11966  *         for coordinate in coordinates:
11967  *             self._addPointToGeometry(geom, coordinate)             # <<<<<<<<<<<<<<
11968  *         OGR_G_CloseRings(geom)
11969  *         return geom
11970  */
11971     __pyx_t_1 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_addPointToGeometry(__pyx_v_self, __pyx_v_geom, __pyx_v_coordinate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 597, __pyx_L1_error)
11972     __Pyx_GOTREF(__pyx_t_1);
11973     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11974 
11975     /* "rasterio/_features.pyx":596
11976  *         cdef OGRGeometryH geom = self._createOgrGeometry(
11977  *             GEOJSON2OGR_GEOMETRY_TYPES['LinearRing'])
11978  *         for coordinate in coordinates:             # <<<<<<<<<<<<<<
11979  *             self._addPointToGeometry(geom, coordinate)
11980  *         OGR_G_CloseRings(geom)
11981  */
11982   }
11983   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11984 
11985   /* "rasterio/_features.pyx":598
11986  *         for coordinate in coordinates:
11987  *             self._addPointToGeometry(geom, coordinate)
11988  *         OGR_G_CloseRings(geom)             # <<<<<<<<<<<<<<
11989  *         return geom
11990  *
11991  */
11992   OGR_G_CloseRings(__pyx_v_geom);
11993 
11994   /* "rasterio/_features.pyx":599
11995  *             self._addPointToGeometry(geom, coordinate)
11996  *         OGR_G_CloseRings(geom)
11997  *         return geom             # <<<<<<<<<<<<<<
11998  *
11999  *     cdef OGRGeometryH _buildPolygon(self, object coordinates) except NULL:
12000  */
12001   __pyx_r = __pyx_v_geom;
12002   goto __pyx_L0;
12003 
12004   /* "rasterio/_features.pyx":593
12005  *         return geom
12006  *
12007  *     cdef OGRGeometryH _buildLinearRing(self, object coordinates) except NULL:             # <<<<<<<<<<<<<<
12008  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12009  *             GEOJSON2OGR_GEOMETRY_TYPES['LinearRing'])
12010  */
12011 
12012   /* function exit code */
12013   __pyx_L1_error:;
12014   __Pyx_XDECREF(__pyx_t_1);
12015   __Pyx_XDECREF(__pyx_t_2);
12016   __Pyx_AddTraceback("rasterio._features.OGRGeomBuilder._buildLinearRing", __pyx_clineno, __pyx_lineno, __pyx_filename);
12017   __pyx_r = NULL;
12018   __pyx_L0:;
12019   __Pyx_XDECREF(__pyx_v_coordinate);
12020   __Pyx_RefNannyFinishContext();
12021   return __pyx_r;
12022 }
12023 
12024 /* "rasterio/_features.pyx":601
12025  *         return geom
12026  *
12027  *     cdef OGRGeometryH _buildPolygon(self, object coordinates) except NULL:             # <<<<<<<<<<<<<<
12028  *         cdef OGRGeometryH ring = NULL
12029  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12030  */
12031 
__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildPolygon(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v_self,PyObject * __pyx_v_coordinates)12032 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildPolygon(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates) {
12033   OGRGeometryH __pyx_v_ring;
12034   OGRGeometryH __pyx_v_geom;
12035   PyObject *__pyx_v_r = NULL;
12036   OGRGeometryH __pyx_r;
12037   __Pyx_RefNannyDeclarations
12038   PyObject *__pyx_t_1 = NULL;
12039   PyObject *__pyx_t_2 = NULL;
12040   int __pyx_t_3;
12041   OGRGeometryH __pyx_t_4;
12042   Py_ssize_t __pyx_t_5;
12043   PyObject *(*__pyx_t_6)(PyObject *);
12044   int __pyx_lineno = 0;
12045   const char *__pyx_filename = NULL;
12046   int __pyx_clineno = 0;
12047   __Pyx_RefNannySetupContext("_buildPolygon", 0);
12048 
12049   /* "rasterio/_features.pyx":602
12050  *
12051  *     cdef OGRGeometryH _buildPolygon(self, object coordinates) except NULL:
12052  *         cdef OGRGeometryH ring = NULL             # <<<<<<<<<<<<<<
12053  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12054  *             GEOJSON2OGR_GEOMETRY_TYPES['Polygon'])
12055  */
12056   __pyx_v_ring = NULL;
12057 
12058   /* "rasterio/_features.pyx":604
12059  *         cdef OGRGeometryH ring = NULL
12060  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12061  *             GEOJSON2OGR_GEOMETRY_TYPES['Polygon'])             # <<<<<<<<<<<<<<
12062  *         for r in coordinates:
12063  *             ring = self._buildLinearRing(r)
12064  */
12065   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_GEOJSON2OGR_GEOMETRY_TYPES); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 604, __pyx_L1_error)
12066   __Pyx_GOTREF(__pyx_t_1);
12067   __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_Polygon); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 604, __pyx_L1_error)
12068   __Pyx_GOTREF(__pyx_t_2);
12069   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12070   __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 604, __pyx_L1_error)
12071   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12072 
12073   /* "rasterio/_features.pyx":603
12074  *     cdef OGRGeometryH _buildPolygon(self, object coordinates) except NULL:
12075  *         cdef OGRGeometryH ring = NULL
12076  *         cdef OGRGeometryH geom = self._createOgrGeometry(             # <<<<<<<<<<<<<<
12077  *             GEOJSON2OGR_GEOMETRY_TYPES['Polygon'])
12078  *         for r in coordinates:
12079  */
12080   __pyx_t_4 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_createOgrGeometry(__pyx_v_self, __pyx_t_3); if (unlikely(__pyx_t_4 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 603, __pyx_L1_error)
12081   __pyx_v_geom = __pyx_t_4;
12082 
12083   /* "rasterio/_features.pyx":605
12084  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12085  *             GEOJSON2OGR_GEOMETRY_TYPES['Polygon'])
12086  *         for r in coordinates:             # <<<<<<<<<<<<<<
12087  *             ring = self._buildLinearRing(r)
12088  *             OGR_G_AddGeometryDirectly(geom, ring)
12089  */
12090   if (likely(PyList_CheckExact(__pyx_v_coordinates)) || PyTuple_CheckExact(__pyx_v_coordinates)) {
12091     __pyx_t_2 = __pyx_v_coordinates; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
12092     __pyx_t_6 = NULL;
12093   } else {
12094     __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_coordinates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 605, __pyx_L1_error)
12095     __Pyx_GOTREF(__pyx_t_2);
12096     __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 605, __pyx_L1_error)
12097   }
12098   for (;;) {
12099     if (likely(!__pyx_t_6)) {
12100       if (likely(PyList_CheckExact(__pyx_t_2))) {
12101         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
12102         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12103         __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 605, __pyx_L1_error)
12104         #else
12105         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 605, __pyx_L1_error)
12106         __Pyx_GOTREF(__pyx_t_1);
12107         #endif
12108       } else {
12109         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
12110         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12111         __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 605, __pyx_L1_error)
12112         #else
12113         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 605, __pyx_L1_error)
12114         __Pyx_GOTREF(__pyx_t_1);
12115         #endif
12116       }
12117     } else {
12118       __pyx_t_1 = __pyx_t_6(__pyx_t_2);
12119       if (unlikely(!__pyx_t_1)) {
12120         PyObject* exc_type = PyErr_Occurred();
12121         if (exc_type) {
12122           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
12123           else __PYX_ERR(0, 605, __pyx_L1_error)
12124         }
12125         break;
12126       }
12127       __Pyx_GOTREF(__pyx_t_1);
12128     }
12129     __Pyx_XDECREF_SET(__pyx_v_r, __pyx_t_1);
12130     __pyx_t_1 = 0;
12131 
12132     /* "rasterio/_features.pyx":606
12133  *             GEOJSON2OGR_GEOMETRY_TYPES['Polygon'])
12134  *         for r in coordinates:
12135  *             ring = self._buildLinearRing(r)             # <<<<<<<<<<<<<<
12136  *             OGR_G_AddGeometryDirectly(geom, ring)
12137  *         return geom
12138  */
12139     __pyx_t_4 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildLinearRing(__pyx_v_self, __pyx_v_r); if (unlikely(__pyx_t_4 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 606, __pyx_L1_error)
12140     __pyx_v_ring = __pyx_t_4;
12141 
12142     /* "rasterio/_features.pyx":607
12143  *         for r in coordinates:
12144  *             ring = self._buildLinearRing(r)
12145  *             OGR_G_AddGeometryDirectly(geom, ring)             # <<<<<<<<<<<<<<
12146  *         return geom
12147  *
12148  */
12149     (void)(OGR_G_AddGeometryDirectly(__pyx_v_geom, __pyx_v_ring));
12150 
12151     /* "rasterio/_features.pyx":605
12152  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12153  *             GEOJSON2OGR_GEOMETRY_TYPES['Polygon'])
12154  *         for r in coordinates:             # <<<<<<<<<<<<<<
12155  *             ring = self._buildLinearRing(r)
12156  *             OGR_G_AddGeometryDirectly(geom, ring)
12157  */
12158   }
12159   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12160 
12161   /* "rasterio/_features.pyx":608
12162  *             ring = self._buildLinearRing(r)
12163  *             OGR_G_AddGeometryDirectly(geom, ring)
12164  *         return geom             # <<<<<<<<<<<<<<
12165  *
12166  *     cdef OGRGeometryH _buildMultiPoint(self, object coordinates) except NULL:
12167  */
12168   __pyx_r = __pyx_v_geom;
12169   goto __pyx_L0;
12170 
12171   /* "rasterio/_features.pyx":601
12172  *         return geom
12173  *
12174  *     cdef OGRGeometryH _buildPolygon(self, object coordinates) except NULL:             # <<<<<<<<<<<<<<
12175  *         cdef OGRGeometryH ring = NULL
12176  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12177  */
12178 
12179   /* function exit code */
12180   __pyx_L1_error:;
12181   __Pyx_XDECREF(__pyx_t_1);
12182   __Pyx_XDECREF(__pyx_t_2);
12183   __Pyx_AddTraceback("rasterio._features.OGRGeomBuilder._buildPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
12184   __pyx_r = NULL;
12185   __pyx_L0:;
12186   __Pyx_XDECREF(__pyx_v_r);
12187   __Pyx_RefNannyFinishContext();
12188   return __pyx_r;
12189 }
12190 
12191 /* "rasterio/_features.pyx":610
12192  *         return geom
12193  *
12194  *     cdef OGRGeometryH _buildMultiPoint(self, object coordinates) except NULL:             # <<<<<<<<<<<<<<
12195  *         cdef OGRGeometryH part = NULL
12196  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12197  */
12198 
__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildMultiPoint(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v_self,PyObject * __pyx_v_coordinates)12199 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildMultiPoint(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates) {
12200   OGRGeometryH __pyx_v_part;
12201   OGRGeometryH __pyx_v_geom;
12202   PyObject *__pyx_v_coordinate = NULL;
12203   OGRGeometryH __pyx_r;
12204   __Pyx_RefNannyDeclarations
12205   PyObject *__pyx_t_1 = NULL;
12206   PyObject *__pyx_t_2 = NULL;
12207   int __pyx_t_3;
12208   OGRGeometryH __pyx_t_4;
12209   Py_ssize_t __pyx_t_5;
12210   PyObject *(*__pyx_t_6)(PyObject *);
12211   int __pyx_lineno = 0;
12212   const char *__pyx_filename = NULL;
12213   int __pyx_clineno = 0;
12214   __Pyx_RefNannySetupContext("_buildMultiPoint", 0);
12215 
12216   /* "rasterio/_features.pyx":611
12217  *
12218  *     cdef OGRGeometryH _buildMultiPoint(self, object coordinates) except NULL:
12219  *         cdef OGRGeometryH part = NULL             # <<<<<<<<<<<<<<
12220  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12221  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiPoint'])
12222  */
12223   __pyx_v_part = NULL;
12224 
12225   /* "rasterio/_features.pyx":613
12226  *         cdef OGRGeometryH part = NULL
12227  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12228  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiPoint'])             # <<<<<<<<<<<<<<
12229  *         for coordinate in coordinates:
12230  *             part = self._buildPoint(coordinate)
12231  */
12232   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_GEOJSON2OGR_GEOMETRY_TYPES); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 613, __pyx_L1_error)
12233   __Pyx_GOTREF(__pyx_t_1);
12234   __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_MultiPoint); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 613, __pyx_L1_error)
12235   __Pyx_GOTREF(__pyx_t_2);
12236   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12237   __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 613, __pyx_L1_error)
12238   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12239 
12240   /* "rasterio/_features.pyx":612
12241  *     cdef OGRGeometryH _buildMultiPoint(self, object coordinates) except NULL:
12242  *         cdef OGRGeometryH part = NULL
12243  *         cdef OGRGeometryH geom = self._createOgrGeometry(             # <<<<<<<<<<<<<<
12244  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiPoint'])
12245  *         for coordinate in coordinates:
12246  */
12247   __pyx_t_4 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_createOgrGeometry(__pyx_v_self, __pyx_t_3); if (unlikely(__pyx_t_4 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 612, __pyx_L1_error)
12248   __pyx_v_geom = __pyx_t_4;
12249 
12250   /* "rasterio/_features.pyx":614
12251  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12252  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiPoint'])
12253  *         for coordinate in coordinates:             # <<<<<<<<<<<<<<
12254  *             part = self._buildPoint(coordinate)
12255  *             OGR_G_AddGeometryDirectly(geom, part)
12256  */
12257   if (likely(PyList_CheckExact(__pyx_v_coordinates)) || PyTuple_CheckExact(__pyx_v_coordinates)) {
12258     __pyx_t_2 = __pyx_v_coordinates; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
12259     __pyx_t_6 = NULL;
12260   } else {
12261     __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_coordinates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 614, __pyx_L1_error)
12262     __Pyx_GOTREF(__pyx_t_2);
12263     __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 614, __pyx_L1_error)
12264   }
12265   for (;;) {
12266     if (likely(!__pyx_t_6)) {
12267       if (likely(PyList_CheckExact(__pyx_t_2))) {
12268         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
12269         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12270         __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 614, __pyx_L1_error)
12271         #else
12272         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 614, __pyx_L1_error)
12273         __Pyx_GOTREF(__pyx_t_1);
12274         #endif
12275       } else {
12276         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
12277         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12278         __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 614, __pyx_L1_error)
12279         #else
12280         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 614, __pyx_L1_error)
12281         __Pyx_GOTREF(__pyx_t_1);
12282         #endif
12283       }
12284     } else {
12285       __pyx_t_1 = __pyx_t_6(__pyx_t_2);
12286       if (unlikely(!__pyx_t_1)) {
12287         PyObject* exc_type = PyErr_Occurred();
12288         if (exc_type) {
12289           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
12290           else __PYX_ERR(0, 614, __pyx_L1_error)
12291         }
12292         break;
12293       }
12294       __Pyx_GOTREF(__pyx_t_1);
12295     }
12296     __Pyx_XDECREF_SET(__pyx_v_coordinate, __pyx_t_1);
12297     __pyx_t_1 = 0;
12298 
12299     /* "rasterio/_features.pyx":615
12300  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiPoint'])
12301  *         for coordinate in coordinates:
12302  *             part = self._buildPoint(coordinate)             # <<<<<<<<<<<<<<
12303  *             OGR_G_AddGeometryDirectly(geom, part)
12304  *         return geom
12305  */
12306     __pyx_t_4 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildPoint(__pyx_v_self, __pyx_v_coordinate); if (unlikely(__pyx_t_4 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 615, __pyx_L1_error)
12307     __pyx_v_part = __pyx_t_4;
12308 
12309     /* "rasterio/_features.pyx":616
12310  *         for coordinate in coordinates:
12311  *             part = self._buildPoint(coordinate)
12312  *             OGR_G_AddGeometryDirectly(geom, part)             # <<<<<<<<<<<<<<
12313  *         return geom
12314  *
12315  */
12316     (void)(OGR_G_AddGeometryDirectly(__pyx_v_geom, __pyx_v_part));
12317 
12318     /* "rasterio/_features.pyx":614
12319  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12320  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiPoint'])
12321  *         for coordinate in coordinates:             # <<<<<<<<<<<<<<
12322  *             part = self._buildPoint(coordinate)
12323  *             OGR_G_AddGeometryDirectly(geom, part)
12324  */
12325   }
12326   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12327 
12328   /* "rasterio/_features.pyx":617
12329  *             part = self._buildPoint(coordinate)
12330  *             OGR_G_AddGeometryDirectly(geom, part)
12331  *         return geom             # <<<<<<<<<<<<<<
12332  *
12333  *     cdef OGRGeometryH _buildMultiLineString(
12334  */
12335   __pyx_r = __pyx_v_geom;
12336   goto __pyx_L0;
12337 
12338   /* "rasterio/_features.pyx":610
12339  *         return geom
12340  *
12341  *     cdef OGRGeometryH _buildMultiPoint(self, object coordinates) except NULL:             # <<<<<<<<<<<<<<
12342  *         cdef OGRGeometryH part = NULL
12343  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12344  */
12345 
12346   /* function exit code */
12347   __pyx_L1_error:;
12348   __Pyx_XDECREF(__pyx_t_1);
12349   __Pyx_XDECREF(__pyx_t_2);
12350   __Pyx_AddTraceback("rasterio._features.OGRGeomBuilder._buildMultiPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
12351   __pyx_r = NULL;
12352   __pyx_L0:;
12353   __Pyx_XDECREF(__pyx_v_coordinate);
12354   __Pyx_RefNannyFinishContext();
12355   return __pyx_r;
12356 }
12357 
12358 /* "rasterio/_features.pyx":619
12359  *         return geom
12360  *
12361  *     cdef OGRGeometryH _buildMultiLineString(             # <<<<<<<<<<<<<<
12362  *             self, object coordinates) except NULL:
12363  *         cdef OGRGeometryH part = NULL
12364  */
12365 
__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildMultiLineString(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v_self,PyObject * __pyx_v_coordinates)12366 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildMultiLineString(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates) {
12367   OGRGeometryH __pyx_v_part;
12368   OGRGeometryH __pyx_v_geom;
12369   PyObject *__pyx_v_line = NULL;
12370   OGRGeometryH __pyx_r;
12371   __Pyx_RefNannyDeclarations
12372   PyObject *__pyx_t_1 = NULL;
12373   PyObject *__pyx_t_2 = NULL;
12374   int __pyx_t_3;
12375   OGRGeometryH __pyx_t_4;
12376   Py_ssize_t __pyx_t_5;
12377   PyObject *(*__pyx_t_6)(PyObject *);
12378   int __pyx_lineno = 0;
12379   const char *__pyx_filename = NULL;
12380   int __pyx_clineno = 0;
12381   __Pyx_RefNannySetupContext("_buildMultiLineString", 0);
12382 
12383   /* "rasterio/_features.pyx":621
12384  *     cdef OGRGeometryH _buildMultiLineString(
12385  *             self, object coordinates) except NULL:
12386  *         cdef OGRGeometryH part = NULL             # <<<<<<<<<<<<<<
12387  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12388  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiLineString'])
12389  */
12390   __pyx_v_part = NULL;
12391 
12392   /* "rasterio/_features.pyx":623
12393  *         cdef OGRGeometryH part = NULL
12394  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12395  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiLineString'])             # <<<<<<<<<<<<<<
12396  *         for line in coordinates:
12397  *             part = self._buildLineString(line)
12398  */
12399   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_GEOJSON2OGR_GEOMETRY_TYPES); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 623, __pyx_L1_error)
12400   __Pyx_GOTREF(__pyx_t_1);
12401   __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_MultiLineString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 623, __pyx_L1_error)
12402   __Pyx_GOTREF(__pyx_t_2);
12403   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12404   __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 623, __pyx_L1_error)
12405   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12406 
12407   /* "rasterio/_features.pyx":622
12408  *             self, object coordinates) except NULL:
12409  *         cdef OGRGeometryH part = NULL
12410  *         cdef OGRGeometryH geom = self._createOgrGeometry(             # <<<<<<<<<<<<<<
12411  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiLineString'])
12412  *         for line in coordinates:
12413  */
12414   __pyx_t_4 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_createOgrGeometry(__pyx_v_self, __pyx_t_3); if (unlikely(__pyx_t_4 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 622, __pyx_L1_error)
12415   __pyx_v_geom = __pyx_t_4;
12416 
12417   /* "rasterio/_features.pyx":624
12418  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12419  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiLineString'])
12420  *         for line in coordinates:             # <<<<<<<<<<<<<<
12421  *             part = self._buildLineString(line)
12422  *             OGR_G_AddGeometryDirectly(geom, part)
12423  */
12424   if (likely(PyList_CheckExact(__pyx_v_coordinates)) || PyTuple_CheckExact(__pyx_v_coordinates)) {
12425     __pyx_t_2 = __pyx_v_coordinates; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
12426     __pyx_t_6 = NULL;
12427   } else {
12428     __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_coordinates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 624, __pyx_L1_error)
12429     __Pyx_GOTREF(__pyx_t_2);
12430     __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 624, __pyx_L1_error)
12431   }
12432   for (;;) {
12433     if (likely(!__pyx_t_6)) {
12434       if (likely(PyList_CheckExact(__pyx_t_2))) {
12435         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
12436         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12437         __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 624, __pyx_L1_error)
12438         #else
12439         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 624, __pyx_L1_error)
12440         __Pyx_GOTREF(__pyx_t_1);
12441         #endif
12442       } else {
12443         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
12444         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12445         __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 624, __pyx_L1_error)
12446         #else
12447         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 624, __pyx_L1_error)
12448         __Pyx_GOTREF(__pyx_t_1);
12449         #endif
12450       }
12451     } else {
12452       __pyx_t_1 = __pyx_t_6(__pyx_t_2);
12453       if (unlikely(!__pyx_t_1)) {
12454         PyObject* exc_type = PyErr_Occurred();
12455         if (exc_type) {
12456           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
12457           else __PYX_ERR(0, 624, __pyx_L1_error)
12458         }
12459         break;
12460       }
12461       __Pyx_GOTREF(__pyx_t_1);
12462     }
12463     __Pyx_XDECREF_SET(__pyx_v_line, __pyx_t_1);
12464     __pyx_t_1 = 0;
12465 
12466     /* "rasterio/_features.pyx":625
12467  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiLineString'])
12468  *         for line in coordinates:
12469  *             part = self._buildLineString(line)             # <<<<<<<<<<<<<<
12470  *             OGR_G_AddGeometryDirectly(geom, part)
12471  *         return geom
12472  */
12473     __pyx_t_4 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildLineString(__pyx_v_self, __pyx_v_line); if (unlikely(__pyx_t_4 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 625, __pyx_L1_error)
12474     __pyx_v_part = __pyx_t_4;
12475 
12476     /* "rasterio/_features.pyx":626
12477  *         for line in coordinates:
12478  *             part = self._buildLineString(line)
12479  *             OGR_G_AddGeometryDirectly(geom, part)             # <<<<<<<<<<<<<<
12480  *         return geom
12481  *
12482  */
12483     (void)(OGR_G_AddGeometryDirectly(__pyx_v_geom, __pyx_v_part));
12484 
12485     /* "rasterio/_features.pyx":624
12486  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12487  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiLineString'])
12488  *         for line in coordinates:             # <<<<<<<<<<<<<<
12489  *             part = self._buildLineString(line)
12490  *             OGR_G_AddGeometryDirectly(geom, part)
12491  */
12492   }
12493   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12494 
12495   /* "rasterio/_features.pyx":627
12496  *             part = self._buildLineString(line)
12497  *             OGR_G_AddGeometryDirectly(geom, part)
12498  *         return geom             # <<<<<<<<<<<<<<
12499  *
12500  *     cdef OGRGeometryH _buildMultiPolygon(self, object coordinates) except NULL:
12501  */
12502   __pyx_r = __pyx_v_geom;
12503   goto __pyx_L0;
12504 
12505   /* "rasterio/_features.pyx":619
12506  *         return geom
12507  *
12508  *     cdef OGRGeometryH _buildMultiLineString(             # <<<<<<<<<<<<<<
12509  *             self, object coordinates) except NULL:
12510  *         cdef OGRGeometryH part = NULL
12511  */
12512 
12513   /* function exit code */
12514   __pyx_L1_error:;
12515   __Pyx_XDECREF(__pyx_t_1);
12516   __Pyx_XDECREF(__pyx_t_2);
12517   __Pyx_AddTraceback("rasterio._features.OGRGeomBuilder._buildMultiLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
12518   __pyx_r = NULL;
12519   __pyx_L0:;
12520   __Pyx_XDECREF(__pyx_v_line);
12521   __Pyx_RefNannyFinishContext();
12522   return __pyx_r;
12523 }
12524 
12525 /* "rasterio/_features.pyx":629
12526  *         return geom
12527  *
12528  *     cdef OGRGeometryH _buildMultiPolygon(self, object coordinates) except NULL:             # <<<<<<<<<<<<<<
12529  *         cdef OGRGeometryH part = NULL
12530  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12531  */
12532 
__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildMultiPolygon(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v_self,PyObject * __pyx_v_coordinates)12533 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildMultiPolygon(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_coordinates) {
12534   OGRGeometryH __pyx_v_part;
12535   OGRGeometryH __pyx_v_geom;
12536   PyObject *__pyx_v_poly = NULL;
12537   OGRGeometryH __pyx_r;
12538   __Pyx_RefNannyDeclarations
12539   PyObject *__pyx_t_1 = NULL;
12540   PyObject *__pyx_t_2 = NULL;
12541   int __pyx_t_3;
12542   OGRGeometryH __pyx_t_4;
12543   Py_ssize_t __pyx_t_5;
12544   PyObject *(*__pyx_t_6)(PyObject *);
12545   int __pyx_lineno = 0;
12546   const char *__pyx_filename = NULL;
12547   int __pyx_clineno = 0;
12548   __Pyx_RefNannySetupContext("_buildMultiPolygon", 0);
12549 
12550   /* "rasterio/_features.pyx":630
12551  *
12552  *     cdef OGRGeometryH _buildMultiPolygon(self, object coordinates) except NULL:
12553  *         cdef OGRGeometryH part = NULL             # <<<<<<<<<<<<<<
12554  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12555  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiPolygon'])
12556  */
12557   __pyx_v_part = NULL;
12558 
12559   /* "rasterio/_features.pyx":632
12560  *         cdef OGRGeometryH part = NULL
12561  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12562  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiPolygon'])             # <<<<<<<<<<<<<<
12563  *         for poly in coordinates:
12564  *             part = self._buildPolygon(poly)
12565  */
12566   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_GEOJSON2OGR_GEOMETRY_TYPES); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 632, __pyx_L1_error)
12567   __Pyx_GOTREF(__pyx_t_1);
12568   __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_MultiPolygon); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 632, __pyx_L1_error)
12569   __Pyx_GOTREF(__pyx_t_2);
12570   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12571   __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 632, __pyx_L1_error)
12572   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12573 
12574   /* "rasterio/_features.pyx":631
12575  *     cdef OGRGeometryH _buildMultiPolygon(self, object coordinates) except NULL:
12576  *         cdef OGRGeometryH part = NULL
12577  *         cdef OGRGeometryH geom = self._createOgrGeometry(             # <<<<<<<<<<<<<<
12578  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiPolygon'])
12579  *         for poly in coordinates:
12580  */
12581   __pyx_t_4 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_createOgrGeometry(__pyx_v_self, __pyx_t_3); if (unlikely(__pyx_t_4 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 631, __pyx_L1_error)
12582   __pyx_v_geom = __pyx_t_4;
12583 
12584   /* "rasterio/_features.pyx":633
12585  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12586  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiPolygon'])
12587  *         for poly in coordinates:             # <<<<<<<<<<<<<<
12588  *             part = self._buildPolygon(poly)
12589  *             OGR_G_AddGeometryDirectly(geom, part)
12590  */
12591   if (likely(PyList_CheckExact(__pyx_v_coordinates)) || PyTuple_CheckExact(__pyx_v_coordinates)) {
12592     __pyx_t_2 = __pyx_v_coordinates; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
12593     __pyx_t_6 = NULL;
12594   } else {
12595     __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_coordinates); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L1_error)
12596     __Pyx_GOTREF(__pyx_t_2);
12597     __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 633, __pyx_L1_error)
12598   }
12599   for (;;) {
12600     if (likely(!__pyx_t_6)) {
12601       if (likely(PyList_CheckExact(__pyx_t_2))) {
12602         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
12603         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12604         __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 633, __pyx_L1_error)
12605         #else
12606         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L1_error)
12607         __Pyx_GOTREF(__pyx_t_1);
12608         #endif
12609       } else {
12610         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
12611         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12612         __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 633, __pyx_L1_error)
12613         #else
12614         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L1_error)
12615         __Pyx_GOTREF(__pyx_t_1);
12616         #endif
12617       }
12618     } else {
12619       __pyx_t_1 = __pyx_t_6(__pyx_t_2);
12620       if (unlikely(!__pyx_t_1)) {
12621         PyObject* exc_type = PyErr_Occurred();
12622         if (exc_type) {
12623           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
12624           else __PYX_ERR(0, 633, __pyx_L1_error)
12625         }
12626         break;
12627       }
12628       __Pyx_GOTREF(__pyx_t_1);
12629     }
12630     __Pyx_XDECREF_SET(__pyx_v_poly, __pyx_t_1);
12631     __pyx_t_1 = 0;
12632 
12633     /* "rasterio/_features.pyx":634
12634  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiPolygon'])
12635  *         for poly in coordinates:
12636  *             part = self._buildPolygon(poly)             # <<<<<<<<<<<<<<
12637  *             OGR_G_AddGeometryDirectly(geom, part)
12638  *         return geom
12639  */
12640     __pyx_t_4 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildPolygon(__pyx_v_self, __pyx_v_poly); if (unlikely(__pyx_t_4 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 634, __pyx_L1_error)
12641     __pyx_v_part = __pyx_t_4;
12642 
12643     /* "rasterio/_features.pyx":635
12644  *         for poly in coordinates:
12645  *             part = self._buildPolygon(poly)
12646  *             OGR_G_AddGeometryDirectly(geom, part)             # <<<<<<<<<<<<<<
12647  *         return geom
12648  *
12649  */
12650     (void)(OGR_G_AddGeometryDirectly(__pyx_v_geom, __pyx_v_part));
12651 
12652     /* "rasterio/_features.pyx":633
12653  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12654  *             GEOJSON2OGR_GEOMETRY_TYPES['MultiPolygon'])
12655  *         for poly in coordinates:             # <<<<<<<<<<<<<<
12656  *             part = self._buildPolygon(poly)
12657  *             OGR_G_AddGeometryDirectly(geom, part)
12658  */
12659   }
12660   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12661 
12662   /* "rasterio/_features.pyx":636
12663  *             part = self._buildPolygon(poly)
12664  *             OGR_G_AddGeometryDirectly(geom, part)
12665  *         return geom             # <<<<<<<<<<<<<<
12666  *
12667  *     cdef OGRGeometryH _buildGeomCollection(self, object geoms) except NULL:
12668  */
12669   __pyx_r = __pyx_v_geom;
12670   goto __pyx_L0;
12671 
12672   /* "rasterio/_features.pyx":629
12673  *         return geom
12674  *
12675  *     cdef OGRGeometryH _buildMultiPolygon(self, object coordinates) except NULL:             # <<<<<<<<<<<<<<
12676  *         cdef OGRGeometryH part = NULL
12677  *         cdef OGRGeometryH geom = self._createOgrGeometry(
12678  */
12679 
12680   /* function exit code */
12681   __pyx_L1_error:;
12682   __Pyx_XDECREF(__pyx_t_1);
12683   __Pyx_XDECREF(__pyx_t_2);
12684   __Pyx_AddTraceback("rasterio._features.OGRGeomBuilder._buildMultiPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
12685   __pyx_r = NULL;
12686   __pyx_L0:;
12687   __Pyx_XDECREF(__pyx_v_poly);
12688   __Pyx_RefNannyFinishContext();
12689   return __pyx_r;
12690 }
12691 
12692 /* "rasterio/_features.pyx":638
12693  *         return geom
12694  *
12695  *     cdef OGRGeometryH _buildGeomCollection(self, object geoms) except NULL:             # <<<<<<<<<<<<<<
12696  *         cdef OGRGeometryH part = NULL
12697  *         cdef OGRGeometryH ogr_geom = self._createOgrGeometry(
12698  */
12699 
__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildGeomCollection(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v_self,PyObject * __pyx_v_geoms)12700 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildGeomCollection(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_geoms) {
12701   OGRGeometryH __pyx_v_part;
12702   OGRGeometryH __pyx_v_ogr_geom;
12703   PyObject *__pyx_v_g = NULL;
12704   OGRGeometryH __pyx_r;
12705   __Pyx_RefNannyDeclarations
12706   PyObject *__pyx_t_1 = NULL;
12707   PyObject *__pyx_t_2 = NULL;
12708   int __pyx_t_3;
12709   OGRGeometryH __pyx_t_4;
12710   Py_ssize_t __pyx_t_5;
12711   PyObject *(*__pyx_t_6)(PyObject *);
12712   int __pyx_lineno = 0;
12713   const char *__pyx_filename = NULL;
12714   int __pyx_clineno = 0;
12715   __Pyx_RefNannySetupContext("_buildGeomCollection", 0);
12716 
12717   /* "rasterio/_features.pyx":639
12718  *
12719  *     cdef OGRGeometryH _buildGeomCollection(self, object geoms) except NULL:
12720  *         cdef OGRGeometryH part = NULL             # <<<<<<<<<<<<<<
12721  *         cdef OGRGeometryH ogr_geom = self._createOgrGeometry(
12722  *             GEOJSON2OGR_GEOMETRY_TYPES['GeometryCollection'])
12723  */
12724   __pyx_v_part = NULL;
12725 
12726   /* "rasterio/_features.pyx":641
12727  *         cdef OGRGeometryH part = NULL
12728  *         cdef OGRGeometryH ogr_geom = self._createOgrGeometry(
12729  *             GEOJSON2OGR_GEOMETRY_TYPES['GeometryCollection'])             # <<<<<<<<<<<<<<
12730  *         for g in geoms:
12731  *             part = OGRGeomBuilder().build(g)
12732  */
12733   __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_GEOJSON2OGR_GEOMETRY_TYPES); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 641, __pyx_L1_error)
12734   __Pyx_GOTREF(__pyx_t_1);
12735   __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_n_u_GeometryCollection); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 641, __pyx_L1_error)
12736   __Pyx_GOTREF(__pyx_t_2);
12737   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12738   __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 641, __pyx_L1_error)
12739   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12740 
12741   /* "rasterio/_features.pyx":640
12742  *     cdef OGRGeometryH _buildGeomCollection(self, object geoms) except NULL:
12743  *         cdef OGRGeometryH part = NULL
12744  *         cdef OGRGeometryH ogr_geom = self._createOgrGeometry(             # <<<<<<<<<<<<<<
12745  *             GEOJSON2OGR_GEOMETRY_TYPES['GeometryCollection'])
12746  *         for g in geoms:
12747  */
12748   __pyx_t_4 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_createOgrGeometry(__pyx_v_self, __pyx_t_3); if (unlikely(__pyx_t_4 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 640, __pyx_L1_error)
12749   __pyx_v_ogr_geom = __pyx_t_4;
12750 
12751   /* "rasterio/_features.pyx":642
12752  *         cdef OGRGeometryH ogr_geom = self._createOgrGeometry(
12753  *             GEOJSON2OGR_GEOMETRY_TYPES['GeometryCollection'])
12754  *         for g in geoms:             # <<<<<<<<<<<<<<
12755  *             part = OGRGeomBuilder().build(g)
12756  *             OGR_G_AddGeometryDirectly(ogr_geom, part)
12757  */
12758   if (likely(PyList_CheckExact(__pyx_v_geoms)) || PyTuple_CheckExact(__pyx_v_geoms)) {
12759     __pyx_t_2 = __pyx_v_geoms; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
12760     __pyx_t_6 = NULL;
12761   } else {
12762     __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_geoms); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 642, __pyx_L1_error)
12763     __Pyx_GOTREF(__pyx_t_2);
12764     __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 642, __pyx_L1_error)
12765   }
12766   for (;;) {
12767     if (likely(!__pyx_t_6)) {
12768       if (likely(PyList_CheckExact(__pyx_t_2))) {
12769         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
12770         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12771         __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 642, __pyx_L1_error)
12772         #else
12773         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error)
12774         __Pyx_GOTREF(__pyx_t_1);
12775         #endif
12776       } else {
12777         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
12778         #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
12779         __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 642, __pyx_L1_error)
12780         #else
12781         __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error)
12782         __Pyx_GOTREF(__pyx_t_1);
12783         #endif
12784       }
12785     } else {
12786       __pyx_t_1 = __pyx_t_6(__pyx_t_2);
12787       if (unlikely(!__pyx_t_1)) {
12788         PyObject* exc_type = PyErr_Occurred();
12789         if (exc_type) {
12790           if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
12791           else __PYX_ERR(0, 642, __pyx_L1_error)
12792         }
12793         break;
12794       }
12795       __Pyx_GOTREF(__pyx_t_1);
12796     }
12797     __Pyx_XDECREF_SET(__pyx_v_g, __pyx_t_1);
12798     __pyx_t_1 = 0;
12799 
12800     /* "rasterio/_features.pyx":643
12801  *             GEOJSON2OGR_GEOMETRY_TYPES['GeometryCollection'])
12802  *         for g in geoms:
12803  *             part = OGRGeomBuilder().build(g)             # <<<<<<<<<<<<<<
12804  *             OGR_G_AddGeometryDirectly(ogr_geom, part)
12805  *         return ogr_geom
12806  */
12807     __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_8rasterio_9_features_OGRGeomBuilder)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error)
12808     __Pyx_GOTREF(__pyx_t_1);
12809     __pyx_t_4 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)((struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *)__pyx_t_1)->__pyx_vtab)->build(((struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *)__pyx_t_1), __pyx_v_g); if (unlikely(__pyx_t_4 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 643, __pyx_L1_error)
12810     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12811     __pyx_v_part = __pyx_t_4;
12812 
12813     /* "rasterio/_features.pyx":644
12814  *         for g in geoms:
12815  *             part = OGRGeomBuilder().build(g)
12816  *             OGR_G_AddGeometryDirectly(ogr_geom, part)             # <<<<<<<<<<<<<<
12817  *         return ogr_geom
12818  *
12819  */
12820     (void)(OGR_G_AddGeometryDirectly(__pyx_v_ogr_geom, __pyx_v_part));
12821 
12822     /* "rasterio/_features.pyx":642
12823  *         cdef OGRGeometryH ogr_geom = self._createOgrGeometry(
12824  *             GEOJSON2OGR_GEOMETRY_TYPES['GeometryCollection'])
12825  *         for g in geoms:             # <<<<<<<<<<<<<<
12826  *             part = OGRGeomBuilder().build(g)
12827  *             OGR_G_AddGeometryDirectly(ogr_geom, part)
12828  */
12829   }
12830   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12831 
12832   /* "rasterio/_features.pyx":645
12833  *             part = OGRGeomBuilder().build(g)
12834  *             OGR_G_AddGeometryDirectly(ogr_geom, part)
12835  *         return ogr_geom             # <<<<<<<<<<<<<<
12836  *
12837  *     cdef OGRGeometryH build(self, object geometry) except NULL:
12838  */
12839   __pyx_r = __pyx_v_ogr_geom;
12840   goto __pyx_L0;
12841 
12842   /* "rasterio/_features.pyx":638
12843  *         return geom
12844  *
12845  *     cdef OGRGeometryH _buildGeomCollection(self, object geoms) except NULL:             # <<<<<<<<<<<<<<
12846  *         cdef OGRGeometryH part = NULL
12847  *         cdef OGRGeometryH ogr_geom = self._createOgrGeometry(
12848  */
12849 
12850   /* function exit code */
12851   __pyx_L1_error:;
12852   __Pyx_XDECREF(__pyx_t_1);
12853   __Pyx_XDECREF(__pyx_t_2);
12854   __Pyx_AddTraceback("rasterio._features.OGRGeomBuilder._buildGeomCollection", __pyx_clineno, __pyx_lineno, __pyx_filename);
12855   __pyx_r = NULL;
12856   __pyx_L0:;
12857   __Pyx_XDECREF(__pyx_v_g);
12858   __Pyx_RefNannyFinishContext();
12859   return __pyx_r;
12860 }
12861 
12862 /* "rasterio/_features.pyx":647
12863  *         return ogr_geom
12864  *
12865  *     cdef OGRGeometryH build(self, object geometry) except NULL:             # <<<<<<<<<<<<<<
12866  *         """Builds an OGR geometry from GeoJSON geometry.
12867  *         Assumes that geometry has been validated prior to calling this; this
12868  */
12869 
__pyx_f_8rasterio_9_features_14OGRGeomBuilder_build(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v_self,PyObject * __pyx_v_geometry)12870 static OGRGeometryH __pyx_f_8rasterio_9_features_14OGRGeomBuilder_build(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_geometry) {
12871   PyObject *__pyx_v_typename = 0;
12872   PyObject *__pyx_v_coordinates = 0;
12873   PyObject *__pyx_v_geometries = 0;
12874   PyObject *__pyx_v_valid_types = NULL;
12875   OGRGeometryH __pyx_r;
12876   __Pyx_RefNannyDeclarations
12877   PyObject *__pyx_t_1 = NULL;
12878   int __pyx_t_2;
12879   int __pyx_t_3;
12880   PyObject *__pyx_t_4 = NULL;
12881   PyObject *__pyx_t_5 = NULL;
12882   Py_ssize_t __pyx_t_6;
12883   OGRGeometryH __pyx_t_7;
12884   int __pyx_lineno = 0;
12885   const char *__pyx_filename = NULL;
12886   int __pyx_clineno = 0;
12887   __Pyx_RefNannySetupContext("build", 0);
12888   __Pyx_INCREF(__pyx_v_geometry);
12889 
12890   /* "rasterio/_features.pyx":652
12891  *         only does basic checks for validity.
12892  *         """
12893  *         geometry = getattr(geometry, "__geo_interface__", geometry)             # <<<<<<<<<<<<<<
12894  *         cdef object typename = geometry['type']
12895  *         cdef object coordinates
12896  */
12897   __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_geometry, __pyx_n_u_geo_interface, __pyx_v_geometry); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 652, __pyx_L1_error)
12898   __Pyx_GOTREF(__pyx_t_1);
12899   __Pyx_DECREF_SET(__pyx_v_geometry, __pyx_t_1);
12900   __pyx_t_1 = 0;
12901 
12902   /* "rasterio/_features.pyx":653
12903  *         """
12904  *         geometry = getattr(geometry, "__geo_interface__", geometry)
12905  *         cdef object typename = geometry['type']             # <<<<<<<<<<<<<<
12906  *         cdef object coordinates
12907  *         cdef object geometries
12908  */
12909   __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_geometry, __pyx_n_u_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 653, __pyx_L1_error)
12910   __Pyx_GOTREF(__pyx_t_1);
12911   __pyx_v_typename = __pyx_t_1;
12912   __pyx_t_1 = 0;
12913 
12914   /* "rasterio/_features.pyx":657
12915  *         cdef object geometries
12916  *
12917  *         valid_types = {'Point', 'MultiPoint', 'LineString', 'LinearRing',             # <<<<<<<<<<<<<<
12918  *                        'MultiLineString', 'Polygon', 'MultiPolygon'}
12919  *
12920  */
12921   __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 657, __pyx_L1_error)
12922   __Pyx_GOTREF(__pyx_t_1);
12923   if (PySet_Add(__pyx_t_1, __pyx_n_u_Point) < 0) __PYX_ERR(0, 657, __pyx_L1_error)
12924   if (PySet_Add(__pyx_t_1, __pyx_n_u_MultiPoint) < 0) __PYX_ERR(0, 657, __pyx_L1_error)
12925   if (PySet_Add(__pyx_t_1, __pyx_n_u_LineString) < 0) __PYX_ERR(0, 657, __pyx_L1_error)
12926   if (PySet_Add(__pyx_t_1, __pyx_n_u_LinearRing) < 0) __PYX_ERR(0, 657, __pyx_L1_error)
12927   if (PySet_Add(__pyx_t_1, __pyx_n_u_MultiLineString) < 0) __PYX_ERR(0, 657, __pyx_L1_error)
12928   if (PySet_Add(__pyx_t_1, __pyx_n_u_Polygon) < 0) __PYX_ERR(0, 657, __pyx_L1_error)
12929   if (PySet_Add(__pyx_t_1, __pyx_n_u_MultiPolygon) < 0) __PYX_ERR(0, 657, __pyx_L1_error)
12930   __pyx_v_valid_types = ((PyObject*)__pyx_t_1);
12931   __pyx_t_1 = 0;
12932 
12933   /* "rasterio/_features.pyx":660
12934  *                        'MultiLineString', 'Polygon', 'MultiPolygon'}
12935  *
12936  *         if typename in valid_types:             # <<<<<<<<<<<<<<
12937  *             coordinates = geometry.get('coordinates')
12938  *             if not (coordinates and len(coordinates) > 0):
12939  */
12940   __pyx_t_2 = (__Pyx_PySet_ContainsTF(__pyx_v_typename, __pyx_v_valid_types, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 660, __pyx_L1_error)
12941   __pyx_t_3 = (__pyx_t_2 != 0);
12942   if (__pyx_t_3) {
12943 
12944     /* "rasterio/_features.pyx":661
12945  *
12946  *         if typename in valid_types:
12947  *             coordinates = geometry.get('coordinates')             # <<<<<<<<<<<<<<
12948  *             if not (coordinates and len(coordinates) > 0):
12949  *                 raise ValueError("Input is not a valid geometry object")
12950  */
12951     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_geometry, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 661, __pyx_L1_error)
12952     __Pyx_GOTREF(__pyx_t_4);
12953     __pyx_t_5 = NULL;
12954     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
12955       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
12956       if (likely(__pyx_t_5)) {
12957         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
12958         __Pyx_INCREF(__pyx_t_5);
12959         __Pyx_INCREF(function);
12960         __Pyx_DECREF_SET(__pyx_t_4, function);
12961       }
12962     }
12963     __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_n_u_coordinates) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_n_u_coordinates);
12964     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
12965     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error)
12966     __Pyx_GOTREF(__pyx_t_1);
12967     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
12968     __pyx_v_coordinates = __pyx_t_1;
12969     __pyx_t_1 = 0;
12970 
12971     /* "rasterio/_features.pyx":662
12972  *         if typename in valid_types:
12973  *             coordinates = geometry.get('coordinates')
12974  *             if not (coordinates and len(coordinates) > 0):             # <<<<<<<<<<<<<<
12975  *                 raise ValueError("Input is not a valid geometry object")
12976  *
12977  */
12978     __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_coordinates); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 662, __pyx_L1_error)
12979     if (__pyx_t_2) {
12980     } else {
12981       __pyx_t_3 = __pyx_t_2;
12982       goto __pyx_L5_bool_binop_done;
12983     }
12984     __pyx_t_6 = PyObject_Length(__pyx_v_coordinates); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 662, __pyx_L1_error)
12985     __pyx_t_2 = ((__pyx_t_6 > 0) != 0);
12986     __pyx_t_3 = __pyx_t_2;
12987     __pyx_L5_bool_binop_done:;
12988     __pyx_t_2 = ((!__pyx_t_3) != 0);
12989     if (unlikely(__pyx_t_2)) {
12990 
12991       /* "rasterio/_features.pyx":663
12992  *             coordinates = geometry.get('coordinates')
12993  *             if not (coordinates and len(coordinates) > 0):
12994  *                 raise ValueError("Input is not a valid geometry object")             # <<<<<<<<<<<<<<
12995  *
12996  *             if typename == 'Point':
12997  */
12998       __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 663, __pyx_L1_error)
12999       __Pyx_GOTREF(__pyx_t_1);
13000       __Pyx_Raise(__pyx_t_1, 0, 0, 0);
13001       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13002       __PYX_ERR(0, 663, __pyx_L1_error)
13003 
13004       /* "rasterio/_features.pyx":662
13005  *         if typename in valid_types:
13006  *             coordinates = geometry.get('coordinates')
13007  *             if not (coordinates and len(coordinates) > 0):             # <<<<<<<<<<<<<<
13008  *                 raise ValueError("Input is not a valid geometry object")
13009  *
13010  */
13011     }
13012 
13013     /* "rasterio/_features.pyx":665
13014  *                 raise ValueError("Input is not a valid geometry object")
13015  *
13016  *             if typename == 'Point':             # <<<<<<<<<<<<<<
13017  *                 return self._buildPoint(coordinates)
13018  *             elif typename == 'LineString':
13019  */
13020     __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_typename, __pyx_n_u_Point, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 665, __pyx_L1_error)
13021     if (__pyx_t_2) {
13022 
13023       /* "rasterio/_features.pyx":666
13024  *
13025  *             if typename == 'Point':
13026  *                 return self._buildPoint(coordinates)             # <<<<<<<<<<<<<<
13027  *             elif typename == 'LineString':
13028  *                 return self._buildLineString(coordinates)
13029  */
13030       __pyx_t_7 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildPoint(__pyx_v_self, __pyx_v_coordinates); if (unlikely(__pyx_t_7 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 666, __pyx_L1_error)
13031       __pyx_r = __pyx_t_7;
13032       goto __pyx_L0;
13033 
13034       /* "rasterio/_features.pyx":665
13035  *                 raise ValueError("Input is not a valid geometry object")
13036  *
13037  *             if typename == 'Point':             # <<<<<<<<<<<<<<
13038  *                 return self._buildPoint(coordinates)
13039  *             elif typename == 'LineString':
13040  */
13041     }
13042 
13043     /* "rasterio/_features.pyx":667
13044  *             if typename == 'Point':
13045  *                 return self._buildPoint(coordinates)
13046  *             elif typename == 'LineString':             # <<<<<<<<<<<<<<
13047  *                 return self._buildLineString(coordinates)
13048  *             elif typename == 'LinearRing':
13049  */
13050     __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_typename, __pyx_n_u_LineString, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 667, __pyx_L1_error)
13051     if (__pyx_t_2) {
13052 
13053       /* "rasterio/_features.pyx":668
13054  *                 return self._buildPoint(coordinates)
13055  *             elif typename == 'LineString':
13056  *                 return self._buildLineString(coordinates)             # <<<<<<<<<<<<<<
13057  *             elif typename == 'LinearRing':
13058  *                 return self._buildLinearRing(coordinates)
13059  */
13060       __pyx_t_7 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildLineString(__pyx_v_self, __pyx_v_coordinates); if (unlikely(__pyx_t_7 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 668, __pyx_L1_error)
13061       __pyx_r = __pyx_t_7;
13062       goto __pyx_L0;
13063 
13064       /* "rasterio/_features.pyx":667
13065  *             if typename == 'Point':
13066  *                 return self._buildPoint(coordinates)
13067  *             elif typename == 'LineString':             # <<<<<<<<<<<<<<
13068  *                 return self._buildLineString(coordinates)
13069  *             elif typename == 'LinearRing':
13070  */
13071     }
13072 
13073     /* "rasterio/_features.pyx":669
13074  *             elif typename == 'LineString':
13075  *                 return self._buildLineString(coordinates)
13076  *             elif typename == 'LinearRing':             # <<<<<<<<<<<<<<
13077  *                 return self._buildLinearRing(coordinates)
13078  *             elif typename == 'Polygon':
13079  */
13080     __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_typename, __pyx_n_u_LinearRing, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 669, __pyx_L1_error)
13081     if (__pyx_t_2) {
13082 
13083       /* "rasterio/_features.pyx":670
13084  *                 return self._buildLineString(coordinates)
13085  *             elif typename == 'LinearRing':
13086  *                 return self._buildLinearRing(coordinates)             # <<<<<<<<<<<<<<
13087  *             elif typename == 'Polygon':
13088  *                 return self._buildPolygon(coordinates)
13089  */
13090       __pyx_t_7 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildLinearRing(__pyx_v_self, __pyx_v_coordinates); if (unlikely(__pyx_t_7 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 670, __pyx_L1_error)
13091       __pyx_r = __pyx_t_7;
13092       goto __pyx_L0;
13093 
13094       /* "rasterio/_features.pyx":669
13095  *             elif typename == 'LineString':
13096  *                 return self._buildLineString(coordinates)
13097  *             elif typename == 'LinearRing':             # <<<<<<<<<<<<<<
13098  *                 return self._buildLinearRing(coordinates)
13099  *             elif typename == 'Polygon':
13100  */
13101     }
13102 
13103     /* "rasterio/_features.pyx":671
13104  *             elif typename == 'LinearRing':
13105  *                 return self._buildLinearRing(coordinates)
13106  *             elif typename == 'Polygon':             # <<<<<<<<<<<<<<
13107  *                 return self._buildPolygon(coordinates)
13108  *             elif typename == 'MultiPoint':
13109  */
13110     __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_typename, __pyx_n_u_Polygon, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 671, __pyx_L1_error)
13111     if (__pyx_t_2) {
13112 
13113       /* "rasterio/_features.pyx":672
13114  *                 return self._buildLinearRing(coordinates)
13115  *             elif typename == 'Polygon':
13116  *                 return self._buildPolygon(coordinates)             # <<<<<<<<<<<<<<
13117  *             elif typename == 'MultiPoint':
13118  *                 return self._buildMultiPoint(coordinates)
13119  */
13120       __pyx_t_7 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildPolygon(__pyx_v_self, __pyx_v_coordinates); if (unlikely(__pyx_t_7 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 672, __pyx_L1_error)
13121       __pyx_r = __pyx_t_7;
13122       goto __pyx_L0;
13123 
13124       /* "rasterio/_features.pyx":671
13125  *             elif typename == 'LinearRing':
13126  *                 return self._buildLinearRing(coordinates)
13127  *             elif typename == 'Polygon':             # <<<<<<<<<<<<<<
13128  *                 return self._buildPolygon(coordinates)
13129  *             elif typename == 'MultiPoint':
13130  */
13131     }
13132 
13133     /* "rasterio/_features.pyx":673
13134  *             elif typename == 'Polygon':
13135  *                 return self._buildPolygon(coordinates)
13136  *             elif typename == 'MultiPoint':             # <<<<<<<<<<<<<<
13137  *                 return self._buildMultiPoint(coordinates)
13138  *             elif typename == 'MultiLineString':
13139  */
13140     __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_typename, __pyx_n_u_MultiPoint, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 673, __pyx_L1_error)
13141     if (__pyx_t_2) {
13142 
13143       /* "rasterio/_features.pyx":674
13144  *                 return self._buildPolygon(coordinates)
13145  *             elif typename == 'MultiPoint':
13146  *                 return self._buildMultiPoint(coordinates)             # <<<<<<<<<<<<<<
13147  *             elif typename == 'MultiLineString':
13148  *                 return self._buildMultiLineString(coordinates)
13149  */
13150       __pyx_t_7 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildMultiPoint(__pyx_v_self, __pyx_v_coordinates); if (unlikely(__pyx_t_7 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 674, __pyx_L1_error)
13151       __pyx_r = __pyx_t_7;
13152       goto __pyx_L0;
13153 
13154       /* "rasterio/_features.pyx":673
13155  *             elif typename == 'Polygon':
13156  *                 return self._buildPolygon(coordinates)
13157  *             elif typename == 'MultiPoint':             # <<<<<<<<<<<<<<
13158  *                 return self._buildMultiPoint(coordinates)
13159  *             elif typename == 'MultiLineString':
13160  */
13161     }
13162 
13163     /* "rasterio/_features.pyx":675
13164  *             elif typename == 'MultiPoint':
13165  *                 return self._buildMultiPoint(coordinates)
13166  *             elif typename == 'MultiLineString':             # <<<<<<<<<<<<<<
13167  *                 return self._buildMultiLineString(coordinates)
13168  *             elif typename == 'MultiPolygon':
13169  */
13170     __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_typename, __pyx_n_u_MultiLineString, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 675, __pyx_L1_error)
13171     if (__pyx_t_2) {
13172 
13173       /* "rasterio/_features.pyx":676
13174  *                 return self._buildMultiPoint(coordinates)
13175  *             elif typename == 'MultiLineString':
13176  *                 return self._buildMultiLineString(coordinates)             # <<<<<<<<<<<<<<
13177  *             elif typename == 'MultiPolygon':
13178  *                 return self._buildMultiPolygon(coordinates)
13179  */
13180       __pyx_t_7 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildMultiLineString(__pyx_v_self, __pyx_v_coordinates); if (unlikely(__pyx_t_7 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 676, __pyx_L1_error)
13181       __pyx_r = __pyx_t_7;
13182       goto __pyx_L0;
13183 
13184       /* "rasterio/_features.pyx":675
13185  *             elif typename == 'MultiPoint':
13186  *                 return self._buildMultiPoint(coordinates)
13187  *             elif typename == 'MultiLineString':             # <<<<<<<<<<<<<<
13188  *                 return self._buildMultiLineString(coordinates)
13189  *             elif typename == 'MultiPolygon':
13190  */
13191     }
13192 
13193     /* "rasterio/_features.pyx":677
13194  *             elif typename == 'MultiLineString':
13195  *                 return self._buildMultiLineString(coordinates)
13196  *             elif typename == 'MultiPolygon':             # <<<<<<<<<<<<<<
13197  *                 return self._buildMultiPolygon(coordinates)
13198  *
13199  */
13200     __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_typename, __pyx_n_u_MultiPolygon, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 677, __pyx_L1_error)
13201     if (__pyx_t_2) {
13202 
13203       /* "rasterio/_features.pyx":678
13204  *                 return self._buildMultiLineString(coordinates)
13205  *             elif typename == 'MultiPolygon':
13206  *                 return self._buildMultiPolygon(coordinates)             # <<<<<<<<<<<<<<
13207  *
13208  *         elif typename == 'GeometryCollection':
13209  */
13210       __pyx_t_7 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildMultiPolygon(__pyx_v_self, __pyx_v_coordinates); if (unlikely(__pyx_t_7 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 678, __pyx_L1_error)
13211       __pyx_r = __pyx_t_7;
13212       goto __pyx_L0;
13213 
13214       /* "rasterio/_features.pyx":677
13215  *             elif typename == 'MultiLineString':
13216  *                 return self._buildMultiLineString(coordinates)
13217  *             elif typename == 'MultiPolygon':             # <<<<<<<<<<<<<<
13218  *                 return self._buildMultiPolygon(coordinates)
13219  *
13220  */
13221     }
13222 
13223     /* "rasterio/_features.pyx":660
13224  *                        'MultiLineString', 'Polygon', 'MultiPolygon'}
13225  *
13226  *         if typename in valid_types:             # <<<<<<<<<<<<<<
13227  *             coordinates = geometry.get('coordinates')
13228  *             if not (coordinates and len(coordinates) > 0):
13229  */
13230     goto __pyx_L3;
13231   }
13232 
13233   /* "rasterio/_features.pyx":680
13234  *                 return self._buildMultiPolygon(coordinates)
13235  *
13236  *         elif typename == 'GeometryCollection':             # <<<<<<<<<<<<<<
13237  *             geometries = geometry.get('geometries')
13238  *             if not (geometries and len(geometries) > 0):
13239  */
13240   __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_typename, __pyx_n_u_GeometryCollection, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 680, __pyx_L1_error)
13241   if (likely(__pyx_t_2)) {
13242 
13243     /* "rasterio/_features.pyx":681
13244  *
13245  *         elif typename == 'GeometryCollection':
13246  *             geometries = geometry.get('geometries')             # <<<<<<<<<<<<<<
13247  *             if not (geometries and len(geometries) > 0):
13248  *                 raise ValueError("Input is not a valid geometry object")
13249  */
13250     __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_geometry, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 681, __pyx_L1_error)
13251     __Pyx_GOTREF(__pyx_t_4);
13252     __pyx_t_5 = NULL;
13253     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
13254       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
13255       if (likely(__pyx_t_5)) {
13256         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
13257         __Pyx_INCREF(__pyx_t_5);
13258         __Pyx_INCREF(function);
13259         __Pyx_DECREF_SET(__pyx_t_4, function);
13260       }
13261     }
13262     __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_n_u_geometries) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_n_u_geometries);
13263     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
13264     if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 681, __pyx_L1_error)
13265     __Pyx_GOTREF(__pyx_t_1);
13266     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13267     __pyx_v_geometries = __pyx_t_1;
13268     __pyx_t_1 = 0;
13269 
13270     /* "rasterio/_features.pyx":682
13271  *         elif typename == 'GeometryCollection':
13272  *             geometries = geometry.get('geometries')
13273  *             if not (geometries and len(geometries) > 0):             # <<<<<<<<<<<<<<
13274  *                 raise ValueError("Input is not a valid geometry object")
13275  *
13276  */
13277     __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_geometries); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 682, __pyx_L1_error)
13278     if (__pyx_t_3) {
13279     } else {
13280       __pyx_t_2 = __pyx_t_3;
13281       goto __pyx_L9_bool_binop_done;
13282     }
13283     __pyx_t_6 = PyObject_Length(__pyx_v_geometries); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 682, __pyx_L1_error)
13284     __pyx_t_3 = ((__pyx_t_6 > 0) != 0);
13285     __pyx_t_2 = __pyx_t_3;
13286     __pyx_L9_bool_binop_done:;
13287     __pyx_t_3 = ((!__pyx_t_2) != 0);
13288     if (unlikely(__pyx_t_3)) {
13289 
13290       /* "rasterio/_features.pyx":683
13291  *             geometries = geometry.get('geometries')
13292  *             if not (geometries and len(geometries) > 0):
13293  *                 raise ValueError("Input is not a valid geometry object")             # <<<<<<<<<<<<<<
13294  *
13295  *             return self._buildGeomCollection(geometries)
13296  */
13297       __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 683, __pyx_L1_error)
13298       __Pyx_GOTREF(__pyx_t_1);
13299       __Pyx_Raise(__pyx_t_1, 0, 0, 0);
13300       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13301       __PYX_ERR(0, 683, __pyx_L1_error)
13302 
13303       /* "rasterio/_features.pyx":682
13304  *         elif typename == 'GeometryCollection':
13305  *             geometries = geometry.get('geometries')
13306  *             if not (geometries and len(geometries) > 0):             # <<<<<<<<<<<<<<
13307  *                 raise ValueError("Input is not a valid geometry object")
13308  *
13309  */
13310     }
13311 
13312     /* "rasterio/_features.pyx":685
13313  *                 raise ValueError("Input is not a valid geometry object")
13314  *
13315  *             return self._buildGeomCollection(geometries)             # <<<<<<<<<<<<<<
13316  *
13317  *         else:
13318  */
13319     __pyx_t_7 = ((struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildGeomCollection(__pyx_v_self, __pyx_v_geometries); if (unlikely(__pyx_t_7 == ((OGRGeometryH)NULL))) __PYX_ERR(0, 685, __pyx_L1_error)
13320     __pyx_r = __pyx_t_7;
13321     goto __pyx_L0;
13322 
13323     /* "rasterio/_features.pyx":680
13324  *                 return self._buildMultiPolygon(coordinates)
13325  *
13326  *         elif typename == 'GeometryCollection':             # <<<<<<<<<<<<<<
13327  *             geometries = geometry.get('geometries')
13328  *             if not (geometries and len(geometries) > 0):
13329  */
13330   }
13331 
13332   /* "rasterio/_features.pyx":688
13333  *
13334  *         else:
13335  *             raise ValueError("Unsupported geometry type %s" % typename)             # <<<<<<<<<<<<<<
13336  *
13337  *
13338  */
13339   /*else*/ {
13340     __pyx_t_1 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Unsupported_geometry_type_s, __pyx_v_typename); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 688, __pyx_L1_error)
13341     __Pyx_GOTREF(__pyx_t_1);
13342     __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 688, __pyx_L1_error)
13343     __Pyx_GOTREF(__pyx_t_4);
13344     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13345     __Pyx_Raise(__pyx_t_4, 0, 0, 0);
13346     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
13347     __PYX_ERR(0, 688, __pyx_L1_error)
13348   }
13349   __pyx_L3:;
13350 
13351   /* "rasterio/_features.pyx":647
13352  *         return ogr_geom
13353  *
13354  *     cdef OGRGeometryH build(self, object geometry) except NULL:             # <<<<<<<<<<<<<<
13355  *         """Builds an OGR geometry from GeoJSON geometry.
13356  *         Assumes that geometry has been validated prior to calling this; this
13357  */
13358 
13359   /* function exit code */
13360   __pyx_r = 0;
13361   goto __pyx_L0;
13362   __pyx_L1_error:;
13363   __Pyx_XDECREF(__pyx_t_1);
13364   __Pyx_XDECREF(__pyx_t_4);
13365   __Pyx_XDECREF(__pyx_t_5);
13366   __Pyx_AddTraceback("rasterio._features.OGRGeomBuilder.build", __pyx_clineno, __pyx_lineno, __pyx_filename);
13367   __pyx_r = NULL;
13368   __pyx_L0:;
13369   __Pyx_XDECREF(__pyx_v_typename);
13370   __Pyx_XDECREF(__pyx_v_coordinates);
13371   __Pyx_XDECREF(__pyx_v_geometries);
13372   __Pyx_XDECREF(__pyx_v_valid_types);
13373   __Pyx_XDECREF(__pyx_v_geometry);
13374   __Pyx_RefNannyFinishContext();
13375   return __pyx_r;
13376 }
13377 
13378 /* "(tree fragment)":1
13379  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
13380  *     cdef tuple state
13381  *     cdef object _dict
13382  */
13383 
13384 /* Python wrapper */
13385 static PyObject *__pyx_pw_8rasterio_9_features_14OGRGeomBuilder_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_8rasterio_9_features_14OGRGeomBuilder_1__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)13386 static PyObject *__pyx_pw_8rasterio_9_features_14OGRGeomBuilder_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
13387   PyObject *__pyx_r = 0;
13388   __Pyx_RefNannyDeclarations
13389   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
13390   __pyx_r = __pyx_pf_8rasterio_9_features_14OGRGeomBuilder___reduce_cython__(((struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self));
13391 
13392   /* function exit code */
13393   __Pyx_RefNannyFinishContext();
13394   return __pyx_r;
13395 }
13396 
__pyx_pf_8rasterio_9_features_14OGRGeomBuilder___reduce_cython__(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v_self)13397 static PyObject *__pyx_pf_8rasterio_9_features_14OGRGeomBuilder___reduce_cython__(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self) {
13398   PyObject *__pyx_v_state = 0;
13399   PyObject *__pyx_v__dict = 0;
13400   int __pyx_v_use_setstate;
13401   PyObject *__pyx_r = NULL;
13402   __Pyx_RefNannyDeclarations
13403   PyObject *__pyx_t_1 = NULL;
13404   int __pyx_t_2;
13405   int __pyx_t_3;
13406   PyObject *__pyx_t_4 = NULL;
13407   PyObject *__pyx_t_5 = NULL;
13408   int __pyx_lineno = 0;
13409   const char *__pyx_filename = NULL;
13410   int __pyx_clineno = 0;
13411   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
13412 
13413   /* "(tree fragment)":5
13414  *     cdef object _dict
13415  *     cdef bint use_setstate
13416  *     state = ()             # <<<<<<<<<<<<<<
13417  *     _dict = getattr(self, '__dict__', None)
13418  *     if _dict is not None:
13419  */
13420   __Pyx_INCREF(__pyx_empty_tuple);
13421   __pyx_v_state = __pyx_empty_tuple;
13422 
13423   /* "(tree fragment)":6
13424  *     cdef bint use_setstate
13425  *     state = ()
13426  *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
13427  *     if _dict is not None:
13428  *         state += (_dict,)
13429  */
13430   __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
13431   __Pyx_GOTREF(__pyx_t_1);
13432   __pyx_v__dict = __pyx_t_1;
13433   __pyx_t_1 = 0;
13434 
13435   /* "(tree fragment)":7
13436  *     state = ()
13437  *     _dict = getattr(self, '__dict__', None)
13438  *     if _dict is not None:             # <<<<<<<<<<<<<<
13439  *         state += (_dict,)
13440  *         use_setstate = True
13441  */
13442   __pyx_t_2 = (__pyx_v__dict != Py_None);
13443   __pyx_t_3 = (__pyx_t_2 != 0);
13444   if (__pyx_t_3) {
13445 
13446     /* "(tree fragment)":8
13447  *     _dict = getattr(self, '__dict__', None)
13448  *     if _dict is not None:
13449  *         state += (_dict,)             # <<<<<<<<<<<<<<
13450  *         use_setstate = True
13451  *     else:
13452  */
13453     __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
13454     __Pyx_GOTREF(__pyx_t_1);
13455     __Pyx_INCREF(__pyx_v__dict);
13456     __Pyx_GIVEREF(__pyx_v__dict);
13457     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
13458     __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
13459     __Pyx_GOTREF(__pyx_t_4);
13460     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13461     __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
13462     __pyx_t_4 = 0;
13463 
13464     /* "(tree fragment)":9
13465  *     if _dict is not None:
13466  *         state += (_dict,)
13467  *         use_setstate = True             # <<<<<<<<<<<<<<
13468  *     else:
13469  *         use_setstate = False
13470  */
13471     __pyx_v_use_setstate = 1;
13472 
13473     /* "(tree fragment)":7
13474  *     state = ()
13475  *     _dict = getattr(self, '__dict__', None)
13476  *     if _dict is not None:             # <<<<<<<<<<<<<<
13477  *         state += (_dict,)
13478  *         use_setstate = True
13479  */
13480     goto __pyx_L3;
13481   }
13482 
13483   /* "(tree fragment)":11
13484  *         use_setstate = True
13485  *     else:
13486  *         use_setstate = False             # <<<<<<<<<<<<<<
13487  *     if use_setstate:
13488  *         return __pyx_unpickle_OGRGeomBuilder, (type(self), 0xd41d8cd, None), state
13489  */
13490   /*else*/ {
13491     __pyx_v_use_setstate = 0;
13492   }
13493   __pyx_L3:;
13494 
13495   /* "(tree fragment)":12
13496  *     else:
13497  *         use_setstate = False
13498  *     if use_setstate:             # <<<<<<<<<<<<<<
13499  *         return __pyx_unpickle_OGRGeomBuilder, (type(self), 0xd41d8cd, None), state
13500  *     else:
13501  */
13502   __pyx_t_3 = (__pyx_v_use_setstate != 0);
13503   if (__pyx_t_3) {
13504 
13505     /* "(tree fragment)":13
13506  *         use_setstate = False
13507  *     if use_setstate:
13508  *         return __pyx_unpickle_OGRGeomBuilder, (type(self), 0xd41d8cd, None), state             # <<<<<<<<<<<<<<
13509  *     else:
13510  *         return __pyx_unpickle_OGRGeomBuilder, (type(self), 0xd41d8cd, state)
13511  */
13512     __Pyx_XDECREF(__pyx_r);
13513     __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_OGRGeomBuilder); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
13514     __Pyx_GOTREF(__pyx_t_4);
13515     __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
13516     __Pyx_GOTREF(__pyx_t_1);
13517     __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
13518     __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
13519     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
13520     __Pyx_INCREF(__pyx_int_222419149);
13521     __Pyx_GIVEREF(__pyx_int_222419149);
13522     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_222419149);
13523     __Pyx_INCREF(Py_None);
13524     __Pyx_GIVEREF(Py_None);
13525     PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
13526     __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
13527     __Pyx_GOTREF(__pyx_t_5);
13528     __Pyx_GIVEREF(__pyx_t_4);
13529     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
13530     __Pyx_GIVEREF(__pyx_t_1);
13531     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
13532     __Pyx_INCREF(__pyx_v_state);
13533     __Pyx_GIVEREF(__pyx_v_state);
13534     PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
13535     __pyx_t_4 = 0;
13536     __pyx_t_1 = 0;
13537     __pyx_r = __pyx_t_5;
13538     __pyx_t_5 = 0;
13539     goto __pyx_L0;
13540 
13541     /* "(tree fragment)":12
13542  *     else:
13543  *         use_setstate = False
13544  *     if use_setstate:             # <<<<<<<<<<<<<<
13545  *         return __pyx_unpickle_OGRGeomBuilder, (type(self), 0xd41d8cd, None), state
13546  *     else:
13547  */
13548   }
13549 
13550   /* "(tree fragment)":15
13551  *         return __pyx_unpickle_OGRGeomBuilder, (type(self), 0xd41d8cd, None), state
13552  *     else:
13553  *         return __pyx_unpickle_OGRGeomBuilder, (type(self), 0xd41d8cd, state)             # <<<<<<<<<<<<<<
13554  * def __setstate_cython__(self, __pyx_state):
13555  *     __pyx_unpickle_OGRGeomBuilder__set_state(self, __pyx_state)
13556  */
13557   /*else*/ {
13558     __Pyx_XDECREF(__pyx_r);
13559     __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_OGRGeomBuilder); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
13560     __Pyx_GOTREF(__pyx_t_5);
13561     __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
13562     __Pyx_GOTREF(__pyx_t_1);
13563     __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
13564     __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
13565     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
13566     __Pyx_INCREF(__pyx_int_222419149);
13567     __Pyx_GIVEREF(__pyx_int_222419149);
13568     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_222419149);
13569     __Pyx_INCREF(__pyx_v_state);
13570     __Pyx_GIVEREF(__pyx_v_state);
13571     PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
13572     __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
13573     __Pyx_GOTREF(__pyx_t_4);
13574     __Pyx_GIVEREF(__pyx_t_5);
13575     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
13576     __Pyx_GIVEREF(__pyx_t_1);
13577     PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
13578     __pyx_t_5 = 0;
13579     __pyx_t_1 = 0;
13580     __pyx_r = __pyx_t_4;
13581     __pyx_t_4 = 0;
13582     goto __pyx_L0;
13583   }
13584 
13585   /* "(tree fragment)":1
13586  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
13587  *     cdef tuple state
13588  *     cdef object _dict
13589  */
13590 
13591   /* function exit code */
13592   __pyx_L1_error:;
13593   __Pyx_XDECREF(__pyx_t_1);
13594   __Pyx_XDECREF(__pyx_t_4);
13595   __Pyx_XDECREF(__pyx_t_5);
13596   __Pyx_AddTraceback("rasterio._features.OGRGeomBuilder.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13597   __pyx_r = NULL;
13598   __pyx_L0:;
13599   __Pyx_XDECREF(__pyx_v_state);
13600   __Pyx_XDECREF(__pyx_v__dict);
13601   __Pyx_XGIVEREF(__pyx_r);
13602   __Pyx_RefNannyFinishContext();
13603   return __pyx_r;
13604 }
13605 
13606 /* "(tree fragment)":16
13607  *     else:
13608  *         return __pyx_unpickle_OGRGeomBuilder, (type(self), 0xd41d8cd, state)
13609  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
13610  *     __pyx_unpickle_OGRGeomBuilder__set_state(self, __pyx_state)
13611  */
13612 
13613 /* Python wrapper */
13614 static PyObject *__pyx_pw_8rasterio_9_features_14OGRGeomBuilder_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw_8rasterio_9_features_14OGRGeomBuilder_3__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)13615 static PyObject *__pyx_pw_8rasterio_9_features_14OGRGeomBuilder_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
13616   PyObject *__pyx_r = 0;
13617   __Pyx_RefNannyDeclarations
13618   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
13619   __pyx_r = __pyx_pf_8rasterio_9_features_14OGRGeomBuilder_2__setstate_cython__(((struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
13620 
13621   /* function exit code */
13622   __Pyx_RefNannyFinishContext();
13623   return __pyx_r;
13624 }
13625 
__pyx_pf_8rasterio_9_features_14OGRGeomBuilder_2__setstate_cython__(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v_self,PyObject * __pyx_v___pyx_state)13626 static PyObject *__pyx_pf_8rasterio_9_features_14OGRGeomBuilder_2__setstate_cython__(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
13627   PyObject *__pyx_r = NULL;
13628   __Pyx_RefNannyDeclarations
13629   PyObject *__pyx_t_1 = NULL;
13630   int __pyx_lineno = 0;
13631   const char *__pyx_filename = NULL;
13632   int __pyx_clineno = 0;
13633   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
13634 
13635   /* "(tree fragment)":17
13636  *         return __pyx_unpickle_OGRGeomBuilder, (type(self), 0xd41d8cd, state)
13637  * def __setstate_cython__(self, __pyx_state):
13638  *     __pyx_unpickle_OGRGeomBuilder__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
13639  */
13640   if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
13641   __pyx_t_1 = __pyx_f_8rasterio_9_features___pyx_unpickle_OGRGeomBuilder__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
13642   __Pyx_GOTREF(__pyx_t_1);
13643   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13644 
13645   /* "(tree fragment)":16
13646  *     else:
13647  *         return __pyx_unpickle_OGRGeomBuilder, (type(self), 0xd41d8cd, state)
13648  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
13649  *     __pyx_unpickle_OGRGeomBuilder__set_state(self, __pyx_state)
13650  */
13651 
13652   /* function exit code */
13653   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
13654   goto __pyx_L0;
13655   __pyx_L1_error:;
13656   __Pyx_XDECREF(__pyx_t_1);
13657   __Pyx_AddTraceback("rasterio._features.OGRGeomBuilder.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
13658   __pyx_r = NULL;
13659   __pyx_L0:;
13660   __Pyx_XGIVEREF(__pyx_r);
13661   __Pyx_RefNannyFinishContext();
13662   return __pyx_r;
13663 }
13664 
13665 /* "rasterio/_features.pyx":693
13666  * # Feature extension classes and functions follow.
13667  *
13668  * cdef _deleteOgrFeature(OGRFeatureH feat):             # <<<<<<<<<<<<<<
13669  *     """Delete an OGR feature"""
13670  *     if feat != NULL:
13671  */
13672 
__pyx_f_8rasterio_9_features__deleteOgrFeature(OGRFeatureH __pyx_v_feat)13673 static PyObject *__pyx_f_8rasterio_9_features__deleteOgrFeature(OGRFeatureH __pyx_v_feat) {
13674   PyObject *__pyx_r = NULL;
13675   __Pyx_RefNannyDeclarations
13676   int __pyx_t_1;
13677   __Pyx_RefNannySetupContext("_deleteOgrFeature", 0);
13678 
13679   /* "rasterio/_features.pyx":695
13680  * cdef _deleteOgrFeature(OGRFeatureH feat):
13681  *     """Delete an OGR feature"""
13682  *     if feat != NULL:             # <<<<<<<<<<<<<<
13683  *         OGR_F_Destroy(feat)
13684  *     feat = NULL
13685  */
13686   __pyx_t_1 = ((__pyx_v_feat != NULL) != 0);
13687   if (__pyx_t_1) {
13688 
13689     /* "rasterio/_features.pyx":696
13690  *     """Delete an OGR feature"""
13691  *     if feat != NULL:
13692  *         OGR_F_Destroy(feat)             # <<<<<<<<<<<<<<
13693  *     feat = NULL
13694  *
13695  */
13696     OGR_F_Destroy(__pyx_v_feat);
13697 
13698     /* "rasterio/_features.pyx":695
13699  * cdef _deleteOgrFeature(OGRFeatureH feat):
13700  *     """Delete an OGR feature"""
13701  *     if feat != NULL:             # <<<<<<<<<<<<<<
13702  *         OGR_F_Destroy(feat)
13703  *     feat = NULL
13704  */
13705   }
13706 
13707   /* "rasterio/_features.pyx":697
13708  *     if feat != NULL:
13709  *         OGR_F_Destroy(feat)
13710  *     feat = NULL             # <<<<<<<<<<<<<<
13711  *
13712  *
13713  */
13714   __pyx_v_feat = NULL;
13715 
13716   /* "rasterio/_features.pyx":693
13717  * # Feature extension classes and functions follow.
13718  *
13719  * cdef _deleteOgrFeature(OGRFeatureH feat):             # <<<<<<<<<<<<<<
13720  *     """Delete an OGR feature"""
13721  *     if feat != NULL:
13722  */
13723 
13724   /* function exit code */
13725   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
13726   __Pyx_XGIVEREF(__pyx_r);
13727   __Pyx_RefNannyFinishContext();
13728   return __pyx_r;
13729 }
13730 
13731 /* "rasterio/_features.pyx":703
13732  *     """Provides an iterator over shapes in an OGR feature layer."""
13733  *
13734  *     def __iter__(self):             # <<<<<<<<<<<<<<
13735  *         OGR_L_ResetReading(self.layer)
13736  *         return self
13737  */
13738 
13739 /* Python wrapper */
13740 static PyObject *__pyx_pw_8rasterio_9_features_13ShapeIterator_1__iter__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_8rasterio_9_features_13ShapeIterator_1__iter__(PyObject * __pyx_v_self)13741 static PyObject *__pyx_pw_8rasterio_9_features_13ShapeIterator_1__iter__(PyObject *__pyx_v_self) {
13742   PyObject *__pyx_r = 0;
13743   __Pyx_RefNannyDeclarations
13744   __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
13745   __pyx_r = __pyx_pf_8rasterio_9_features_13ShapeIterator___iter__(((struct __pyx_obj_8rasterio_9_features_ShapeIterator *)__pyx_v_self));
13746 
13747   /* function exit code */
13748   __Pyx_RefNannyFinishContext();
13749   return __pyx_r;
13750 }
13751 
__pyx_pf_8rasterio_9_features_13ShapeIterator___iter__(struct __pyx_obj_8rasterio_9_features_ShapeIterator * __pyx_v_self)13752 static PyObject *__pyx_pf_8rasterio_9_features_13ShapeIterator___iter__(struct __pyx_obj_8rasterio_9_features_ShapeIterator *__pyx_v_self) {
13753   PyObject *__pyx_r = NULL;
13754   __Pyx_RefNannyDeclarations
13755   __Pyx_RefNannySetupContext("__iter__", 0);
13756 
13757   /* "rasterio/_features.pyx":704
13758  *
13759  *     def __iter__(self):
13760  *         OGR_L_ResetReading(self.layer)             # <<<<<<<<<<<<<<
13761  *         return self
13762  *
13763  */
13764   OGR_L_ResetReading(__pyx_v_self->layer);
13765 
13766   /* "rasterio/_features.pyx":705
13767  *     def __iter__(self):
13768  *         OGR_L_ResetReading(self.layer)
13769  *         return self             # <<<<<<<<<<<<<<
13770  *
13771  *     def __next__(self):
13772  */
13773   __Pyx_XDECREF(__pyx_r);
13774   __Pyx_INCREF(((PyObject *)__pyx_v_self));
13775   __pyx_r = ((PyObject *)__pyx_v_self);
13776   goto __pyx_L0;
13777 
13778   /* "rasterio/_features.pyx":703
13779  *     """Provides an iterator over shapes in an OGR feature layer."""
13780  *
13781  *     def __iter__(self):             # <<<<<<<<<<<<<<
13782  *         OGR_L_ResetReading(self.layer)
13783  *         return self
13784  */
13785 
13786   /* function exit code */
13787   __pyx_L0:;
13788   __Pyx_XGIVEREF(__pyx_r);
13789   __Pyx_RefNannyFinishContext();
13790   return __pyx_r;
13791 }
13792 
13793 /* "rasterio/_features.pyx":707
13794  *         return self
13795  *
13796  *     def __next__(self):             # <<<<<<<<<<<<<<
13797  *         cdef OGRFeatureH feat = NULL
13798  *         cdef OGRGeometryH geom = NULL
13799  */
13800 
13801 /* Python wrapper */
13802 static PyObject *__pyx_pw_8rasterio_9_features_13ShapeIterator_3__next__(PyObject *__pyx_v_self); /*proto*/
__pyx_pw_8rasterio_9_features_13ShapeIterator_3__next__(PyObject * __pyx_v_self)13803 static PyObject *__pyx_pw_8rasterio_9_features_13ShapeIterator_3__next__(PyObject *__pyx_v_self) {
13804   PyObject *__pyx_r = 0;
13805   __Pyx_RefNannyDeclarations
13806   __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
13807   __pyx_r = __pyx_pf_8rasterio_9_features_13ShapeIterator_2__next__(((struct __pyx_obj_8rasterio_9_features_ShapeIterator *)__pyx_v_self));
13808 
13809   /* function exit code */
13810   __Pyx_RefNannyFinishContext();
13811   return __pyx_r;
13812 }
13813 
__pyx_pf_8rasterio_9_features_13ShapeIterator_2__next__(struct __pyx_obj_8rasterio_9_features_ShapeIterator * __pyx_v_self)13814 static PyObject *__pyx_pf_8rasterio_9_features_13ShapeIterator_2__next__(struct __pyx_obj_8rasterio_9_features_ShapeIterator *__pyx_v_self) {
13815   OGRFeatureH __pyx_v_feat;
13816   OGRGeometryH __pyx_v_geom;
13817   double __pyx_v_image_value;
13818   PyObject *__pyx_v_shape = NULL;
13819   PyObject *__pyx_r = NULL;
13820   __Pyx_RefNannyDeclarations
13821   int __pyx_t_1;
13822   PyObject *__pyx_t_2 = NULL;
13823   PyObject *__pyx_t_3 = NULL;
13824   int __pyx_t_4;
13825   int __pyx_t_5;
13826   char const *__pyx_t_6;
13827   PyObject *__pyx_t_7 = NULL;
13828   PyObject *__pyx_t_8 = NULL;
13829   PyObject *__pyx_t_9 = NULL;
13830   PyObject *__pyx_t_10 = NULL;
13831   PyObject *__pyx_t_11 = NULL;
13832   PyObject *__pyx_t_12 = NULL;
13833   int __pyx_lineno = 0;
13834   const char *__pyx_filename = NULL;
13835   int __pyx_clineno = 0;
13836   __Pyx_RefNannySetupContext("__next__", 0);
13837 
13838   /* "rasterio/_features.pyx":708
13839  *
13840  *     def __next__(self):
13841  *         cdef OGRFeatureH feat = NULL             # <<<<<<<<<<<<<<
13842  *         cdef OGRGeometryH geom = NULL
13843  *
13844  */
13845   __pyx_v_feat = NULL;
13846 
13847   /* "rasterio/_features.pyx":709
13848  *     def __next__(self):
13849  *         cdef OGRFeatureH feat = NULL
13850  *         cdef OGRGeometryH geom = NULL             # <<<<<<<<<<<<<<
13851  *
13852  *         try:
13853  */
13854   __pyx_v_geom = NULL;
13855 
13856   /* "rasterio/_features.pyx":711
13857  *         cdef OGRGeometryH geom = NULL
13858  *
13859  *         try:             # <<<<<<<<<<<<<<
13860  *             feat = OGR_L_GetNextFeature(self.layer)
13861  *
13862  */
13863   /*try:*/ {
13864 
13865     /* "rasterio/_features.pyx":712
13866  *
13867  *         try:
13868  *             feat = OGR_L_GetNextFeature(self.layer)             # <<<<<<<<<<<<<<
13869  *
13870  *             if feat == NULL:
13871  */
13872     __pyx_v_feat = OGR_L_GetNextFeature(__pyx_v_self->layer);
13873 
13874     /* "rasterio/_features.pyx":714
13875  *             feat = OGR_L_GetNextFeature(self.layer)
13876  *
13877  *             if feat == NULL:             # <<<<<<<<<<<<<<
13878  *                 raise StopIteration
13879  *
13880  */
13881     __pyx_t_1 = ((__pyx_v_feat == NULL) != 0);
13882     if (unlikely(__pyx_t_1)) {
13883 
13884       /* "rasterio/_features.pyx":715
13885  *
13886  *             if feat == NULL:
13887  *                 raise StopIteration             # <<<<<<<<<<<<<<
13888  *
13889  *             if self.fieldtype == 0:
13890  */
13891       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
13892       __PYX_ERR(0, 715, __pyx_L4_error)
13893 
13894       /* "rasterio/_features.pyx":714
13895  *             feat = OGR_L_GetNextFeature(self.layer)
13896  *
13897  *             if feat == NULL:             # <<<<<<<<<<<<<<
13898  *                 raise StopIteration
13899  *
13900  */
13901     }
13902 
13903     /* "rasterio/_features.pyx":717
13904  *                 raise StopIteration
13905  *
13906  *             if self.fieldtype == 0:             # <<<<<<<<<<<<<<
13907  *                 image_value = OGR_F_GetFieldAsInteger(feat, 0)
13908  *             else:
13909  */
13910     __pyx_t_1 = ((__pyx_v_self->fieldtype == 0) != 0);
13911     if (__pyx_t_1) {
13912 
13913       /* "rasterio/_features.pyx":718
13914  *
13915  *             if self.fieldtype == 0:
13916  *                 image_value = OGR_F_GetFieldAsInteger(feat, 0)             # <<<<<<<<<<<<<<
13917  *             else:
13918  *                 image_value = OGR_F_GetFieldAsDouble(feat, 0)
13919  */
13920       __pyx_v_image_value = OGR_F_GetFieldAsInteger(__pyx_v_feat, 0);
13921 
13922       /* "rasterio/_features.pyx":717
13923  *                 raise StopIteration
13924  *
13925  *             if self.fieldtype == 0:             # <<<<<<<<<<<<<<
13926  *                 image_value = OGR_F_GetFieldAsInteger(feat, 0)
13927  *             else:
13928  */
13929       goto __pyx_L7;
13930     }
13931 
13932     /* "rasterio/_features.pyx":720
13933  *                 image_value = OGR_F_GetFieldAsInteger(feat, 0)
13934  *             else:
13935  *                 image_value = OGR_F_GetFieldAsDouble(feat, 0)             # <<<<<<<<<<<<<<
13936  *             geom = OGR_F_GetGeometryRef(feat)
13937  *             if geom != NULL:
13938  */
13939     /*else*/ {
13940       __pyx_v_image_value = OGR_F_GetFieldAsDouble(__pyx_v_feat, 0);
13941     }
13942     __pyx_L7:;
13943 
13944     /* "rasterio/_features.pyx":721
13945  *             else:
13946  *                 image_value = OGR_F_GetFieldAsDouble(feat, 0)
13947  *             geom = OGR_F_GetGeometryRef(feat)             # <<<<<<<<<<<<<<
13948  *             if geom != NULL:
13949  *                 shape = GeomBuilder().build(geom)
13950  */
13951     __pyx_v_geom = OGR_F_GetGeometryRef(__pyx_v_feat);
13952 
13953     /* "rasterio/_features.pyx":722
13954  *                 image_value = OGR_F_GetFieldAsDouble(feat, 0)
13955  *             geom = OGR_F_GetGeometryRef(feat)
13956  *             if geom != NULL:             # <<<<<<<<<<<<<<
13957  *                 shape = GeomBuilder().build(geom)
13958  *             else:
13959  */
13960     __pyx_t_1 = ((__pyx_v_geom != NULL) != 0);
13961     if (__pyx_t_1) {
13962 
13963       /* "rasterio/_features.pyx":723
13964  *             geom = OGR_F_GetGeometryRef(feat)
13965  *             if geom != NULL:
13966  *                 shape = GeomBuilder().build(geom)             # <<<<<<<<<<<<<<
13967  *             else:
13968  *                 shape = None
13969  */
13970       __pyx_t_2 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_8rasterio_9_features_GeomBuilder)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 723, __pyx_L4_error)
13971       __Pyx_GOTREF(__pyx_t_2);
13972       __pyx_t_3 = ((struct __pyx_vtabstruct_8rasterio_9_features_GeomBuilder *)((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)__pyx_t_2)->__pyx_vtab)->build(((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)__pyx_t_2), __pyx_v_geom); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 723, __pyx_L4_error)
13973       __Pyx_GOTREF(__pyx_t_3);
13974       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13975       __pyx_v_shape = __pyx_t_3;
13976       __pyx_t_3 = 0;
13977 
13978       /* "rasterio/_features.pyx":722
13979  *                 image_value = OGR_F_GetFieldAsDouble(feat, 0)
13980  *             geom = OGR_F_GetGeometryRef(feat)
13981  *             if geom != NULL:             # <<<<<<<<<<<<<<
13982  *                 shape = GeomBuilder().build(geom)
13983  *             else:
13984  */
13985       goto __pyx_L8;
13986     }
13987 
13988     /* "rasterio/_features.pyx":725
13989  *                 shape = GeomBuilder().build(geom)
13990  *             else:
13991  *                 shape = None             # <<<<<<<<<<<<<<
13992  *             return shape, image_value
13993  *
13994  */
13995     /*else*/ {
13996       __Pyx_INCREF(Py_None);
13997       __pyx_v_shape = Py_None;
13998     }
13999     __pyx_L8:;
14000 
14001     /* "rasterio/_features.pyx":726
14002  *             else:
14003  *                 shape = None
14004  *             return shape, image_value             # <<<<<<<<<<<<<<
14005  *
14006  *         finally:
14007  */
14008     __Pyx_XDECREF(__pyx_r);
14009     __pyx_t_3 = PyFloat_FromDouble(__pyx_v_image_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 726, __pyx_L4_error)
14010     __Pyx_GOTREF(__pyx_t_3);
14011     __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 726, __pyx_L4_error)
14012     __Pyx_GOTREF(__pyx_t_2);
14013     __Pyx_INCREF(__pyx_v_shape);
14014     __Pyx_GIVEREF(__pyx_v_shape);
14015     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
14016     __Pyx_GIVEREF(__pyx_t_3);
14017     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
14018     __pyx_t_3 = 0;
14019     __pyx_r = __pyx_t_2;
14020     __pyx_t_2 = 0;
14021     goto __pyx_L3_return;
14022   }
14023 
14024   /* "rasterio/_features.pyx":729
14025  *
14026  *         finally:
14027  *             _deleteOgrFeature(feat)             # <<<<<<<<<<<<<<
14028  */
14029   /*finally:*/ {
14030     __pyx_L4_error:;
14031     /*exception exit:*/{
14032       __Pyx_PyThreadState_declare
14033       __Pyx_PyThreadState_assign
14034       __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
14035       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
14036       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
14037       if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
14038       if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
14039       __Pyx_XGOTREF(__pyx_t_7);
14040       __Pyx_XGOTREF(__pyx_t_8);
14041       __Pyx_XGOTREF(__pyx_t_9);
14042       __Pyx_XGOTREF(__pyx_t_10);
14043       __Pyx_XGOTREF(__pyx_t_11);
14044       __Pyx_XGOTREF(__pyx_t_12);
14045       __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
14046       {
14047         __pyx_t_2 = __pyx_f_8rasterio_9_features__deleteOgrFeature(__pyx_v_feat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 729, __pyx_L10_error)
14048         __Pyx_GOTREF(__pyx_t_2);
14049         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14050       }
14051       if (PY_MAJOR_VERSION >= 3) {
14052         __Pyx_XGIVEREF(__pyx_t_10);
14053         __Pyx_XGIVEREF(__pyx_t_11);
14054         __Pyx_XGIVEREF(__pyx_t_12);
14055         __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
14056       }
14057       __Pyx_XGIVEREF(__pyx_t_7);
14058       __Pyx_XGIVEREF(__pyx_t_8);
14059       __Pyx_XGIVEREF(__pyx_t_9);
14060       __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
14061       __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
14062       __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
14063       goto __pyx_L1_error;
14064       __pyx_L10_error:;
14065       if (PY_MAJOR_VERSION >= 3) {
14066         __Pyx_XGIVEREF(__pyx_t_10);
14067         __Pyx_XGIVEREF(__pyx_t_11);
14068         __Pyx_XGIVEREF(__pyx_t_12);
14069         __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
14070       }
14071       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
14072       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
14073       __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
14074       __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
14075       goto __pyx_L1_error;
14076     }
14077     __pyx_L3_return: {
14078       __pyx_t_12 = __pyx_r;
14079       __pyx_r = 0;
14080       __pyx_t_2 = __pyx_f_8rasterio_9_features__deleteOgrFeature(__pyx_v_feat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 729, __pyx_L1_error)
14081       __Pyx_GOTREF(__pyx_t_2);
14082       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14083       __pyx_r = __pyx_t_12;
14084       __pyx_t_12 = 0;
14085       goto __pyx_L0;
14086     }
14087   }
14088 
14089   /* "rasterio/_features.pyx":707
14090  *         return self
14091  *
14092  *     def __next__(self):             # <<<<<<<<<<<<<<
14093  *         cdef OGRFeatureH feat = NULL
14094  *         cdef OGRGeometryH geom = NULL
14095  */
14096 
14097   /* function exit code */
14098   __pyx_L1_error:;
14099   __Pyx_XDECREF(__pyx_t_2);
14100   __Pyx_XDECREF(__pyx_t_3);
14101   __Pyx_AddTraceback("rasterio._features.ShapeIterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14102   __pyx_r = NULL;
14103   __pyx_L0:;
14104   __Pyx_XDECREF(__pyx_v_shape);
14105   __Pyx_XGIVEREF(__pyx_r);
14106   __Pyx_RefNannyFinishContext();
14107   return __pyx_r;
14108 }
14109 
14110 /* "(tree fragment)":1
14111  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
14112  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")
14113  * def __setstate_cython__(self, __pyx_state):
14114  */
14115 
14116 /* Python wrapper */
14117 static PyObject *__pyx_pw_8rasterio_9_features_13ShapeIterator_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
__pyx_pw_8rasterio_9_features_13ShapeIterator_5__reduce_cython__(PyObject * __pyx_v_self,CYTHON_UNUSED PyObject * unused)14118 static PyObject *__pyx_pw_8rasterio_9_features_13ShapeIterator_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
14119   PyObject *__pyx_r = 0;
14120   __Pyx_RefNannyDeclarations
14121   __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
14122   __pyx_r = __pyx_pf_8rasterio_9_features_13ShapeIterator_4__reduce_cython__(((struct __pyx_obj_8rasterio_9_features_ShapeIterator *)__pyx_v_self));
14123 
14124   /* function exit code */
14125   __Pyx_RefNannyFinishContext();
14126   return __pyx_r;
14127 }
14128 
__pyx_pf_8rasterio_9_features_13ShapeIterator_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_ShapeIterator * __pyx_v_self)14129 static PyObject *__pyx_pf_8rasterio_9_features_13ShapeIterator_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_ShapeIterator *__pyx_v_self) {
14130   PyObject *__pyx_r = NULL;
14131   __Pyx_RefNannyDeclarations
14132   PyObject *__pyx_t_1 = NULL;
14133   int __pyx_lineno = 0;
14134   const char *__pyx_filename = NULL;
14135   int __pyx_clineno = 0;
14136   __Pyx_RefNannySetupContext("__reduce_cython__", 0);
14137 
14138   /* "(tree fragment)":2
14139  * def __reduce_cython__(self):
14140  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
14141  * def __setstate_cython__(self, __pyx_state):
14142  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")
14143  */
14144   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
14145   __Pyx_GOTREF(__pyx_t_1);
14146   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
14147   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14148   __PYX_ERR(1, 2, __pyx_L1_error)
14149 
14150   /* "(tree fragment)":1
14151  * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
14152  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")
14153  * def __setstate_cython__(self, __pyx_state):
14154  */
14155 
14156   /* function exit code */
14157   __pyx_L1_error:;
14158   __Pyx_XDECREF(__pyx_t_1);
14159   __Pyx_AddTraceback("rasterio._features.ShapeIterator.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14160   __pyx_r = NULL;
14161   __Pyx_XGIVEREF(__pyx_r);
14162   __Pyx_RefNannyFinishContext();
14163   return __pyx_r;
14164 }
14165 
14166 /* "(tree fragment)":3
14167  * def __reduce_cython__(self):
14168  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")
14169  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
14170  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")
14171  */
14172 
14173 /* Python wrapper */
14174 static PyObject *__pyx_pw_8rasterio_9_features_13ShapeIterator_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
__pyx_pw_8rasterio_9_features_13ShapeIterator_7__setstate_cython__(PyObject * __pyx_v_self,PyObject * __pyx_v___pyx_state)14175 static PyObject *__pyx_pw_8rasterio_9_features_13ShapeIterator_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
14176   PyObject *__pyx_r = 0;
14177   __Pyx_RefNannyDeclarations
14178   __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
14179   __pyx_r = __pyx_pf_8rasterio_9_features_13ShapeIterator_6__setstate_cython__(((struct __pyx_obj_8rasterio_9_features_ShapeIterator *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
14180 
14181   /* function exit code */
14182   __Pyx_RefNannyFinishContext();
14183   return __pyx_r;
14184 }
14185 
__pyx_pf_8rasterio_9_features_13ShapeIterator_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_ShapeIterator * __pyx_v_self,CYTHON_UNUSED PyObject * __pyx_v___pyx_state)14186 static PyObject *__pyx_pf_8rasterio_9_features_13ShapeIterator_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_8rasterio_9_features_ShapeIterator *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
14187   PyObject *__pyx_r = NULL;
14188   __Pyx_RefNannyDeclarations
14189   PyObject *__pyx_t_1 = NULL;
14190   int __pyx_lineno = 0;
14191   const char *__pyx_filename = NULL;
14192   int __pyx_clineno = 0;
14193   __Pyx_RefNannySetupContext("__setstate_cython__", 0);
14194 
14195   /* "(tree fragment)":4
14196  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")
14197  * def __setstate_cython__(self, __pyx_state):
14198  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
14199  */
14200   __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
14201   __Pyx_GOTREF(__pyx_t_1);
14202   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
14203   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14204   __PYX_ERR(1, 4, __pyx_L1_error)
14205 
14206   /* "(tree fragment)":3
14207  * def __reduce_cython__(self):
14208  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")
14209  * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
14210  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")
14211  */
14212 
14213   /* function exit code */
14214   __pyx_L1_error:;
14215   __Pyx_XDECREF(__pyx_t_1);
14216   __Pyx_AddTraceback("rasterio._features.ShapeIterator.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
14217   __pyx_r = NULL;
14218   __Pyx_XGIVEREF(__pyx_r);
14219   __Pyx_RefNannyFinishContext();
14220   return __pyx_r;
14221 }
14222 
14223 /* "(tree fragment)":1
14224  * def __pyx_unpickle_OGRGeomBuilder(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
14225  *     cdef object __pyx_PickleError
14226  *     cdef object __pyx_result
14227  */
14228 
14229 /* Python wrapper */
14230 static PyObject *__pyx_pw_8rasterio_9_features_16__pyx_unpickle_OGRGeomBuilder(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
14231 static PyMethodDef __pyx_mdef_8rasterio_9_features_16__pyx_unpickle_OGRGeomBuilder = {"__pyx_unpickle_OGRGeomBuilder", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_8rasterio_9_features_16__pyx_unpickle_OGRGeomBuilder, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_8rasterio_9_features_16__pyx_unpickle_OGRGeomBuilder(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)14232 static PyObject *__pyx_pw_8rasterio_9_features_16__pyx_unpickle_OGRGeomBuilder(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
14233   PyObject *__pyx_v___pyx_type = 0;
14234   long __pyx_v___pyx_checksum;
14235   PyObject *__pyx_v___pyx_state = 0;
14236   int __pyx_lineno = 0;
14237   const char *__pyx_filename = NULL;
14238   int __pyx_clineno = 0;
14239   PyObject *__pyx_r = 0;
14240   __Pyx_RefNannyDeclarations
14241   __Pyx_RefNannySetupContext("__pyx_unpickle_OGRGeomBuilder (wrapper)", 0);
14242   {
14243     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
14244     PyObject* values[3] = {0,0,0};
14245     if (unlikely(__pyx_kwds)) {
14246       Py_ssize_t kw_args;
14247       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
14248       switch (pos_args) {
14249         case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
14250         CYTHON_FALLTHROUGH;
14251         case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
14252         CYTHON_FALLTHROUGH;
14253         case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
14254         CYTHON_FALLTHROUGH;
14255         case  0: break;
14256         default: goto __pyx_L5_argtuple_error;
14257       }
14258       kw_args = PyDict_Size(__pyx_kwds);
14259       switch (pos_args) {
14260         case  0:
14261         if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
14262         else goto __pyx_L5_argtuple_error;
14263         CYTHON_FALLTHROUGH;
14264         case  1:
14265         if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
14266         else {
14267           __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_OGRGeomBuilder", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
14268         }
14269         CYTHON_FALLTHROUGH;
14270         case  2:
14271         if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
14272         else {
14273           __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_OGRGeomBuilder", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
14274         }
14275       }
14276       if (unlikely(kw_args > 0)) {
14277         if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_OGRGeomBuilder") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
14278       }
14279     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
14280       goto __pyx_L5_argtuple_error;
14281     } else {
14282       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
14283       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
14284       values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
14285     }
14286     __pyx_v___pyx_type = values[0];
14287     __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
14288     __pyx_v___pyx_state = values[2];
14289   }
14290   goto __pyx_L4_argument_unpacking_done;
14291   __pyx_L5_argtuple_error:;
14292   __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_OGRGeomBuilder", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
14293   __pyx_L3_error:;
14294   __Pyx_AddTraceback("rasterio._features.__pyx_unpickle_OGRGeomBuilder", __pyx_clineno, __pyx_lineno, __pyx_filename);
14295   __Pyx_RefNannyFinishContext();
14296   return NULL;
14297   __pyx_L4_argument_unpacking_done:;
14298   __pyx_r = __pyx_pf_8rasterio_9_features_15__pyx_unpickle_OGRGeomBuilder(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
14299 
14300   /* function exit code */
14301   __Pyx_RefNannyFinishContext();
14302   return __pyx_r;
14303 }
14304 
__pyx_pf_8rasterio_9_features_15__pyx_unpickle_OGRGeomBuilder(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v___pyx_type,long __pyx_v___pyx_checksum,PyObject * __pyx_v___pyx_state)14305 static PyObject *__pyx_pf_8rasterio_9_features_15__pyx_unpickle_OGRGeomBuilder(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
14306   PyObject *__pyx_v___pyx_PickleError = 0;
14307   PyObject *__pyx_v___pyx_result = 0;
14308   PyObject *__pyx_r = NULL;
14309   __Pyx_RefNannyDeclarations
14310   int __pyx_t_1;
14311   PyObject *__pyx_t_2 = NULL;
14312   PyObject *__pyx_t_3 = NULL;
14313   PyObject *__pyx_t_4 = NULL;
14314   PyObject *__pyx_t_5 = NULL;
14315   int __pyx_t_6;
14316   int __pyx_lineno = 0;
14317   const char *__pyx_filename = NULL;
14318   int __pyx_clineno = 0;
14319   __Pyx_RefNannySetupContext("__pyx_unpickle_OGRGeomBuilder", 0);
14320 
14321   /* "(tree fragment)":4
14322  *     cdef object __pyx_PickleError
14323  *     cdef object __pyx_result
14324  *     if __pyx_checksum != 0xd41d8cd:             # <<<<<<<<<<<<<<
14325  *         from pickle import PickleError as __pyx_PickleError
14326  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
14327  */
14328   __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xd41d8cd) != 0);
14329   if (__pyx_t_1) {
14330 
14331     /* "(tree fragment)":5
14332  *     cdef object __pyx_result
14333  *     if __pyx_checksum != 0xd41d8cd:
14334  *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
14335  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
14336  *     __pyx_result = OGRGeomBuilder.__new__(__pyx_type)
14337  */
14338     __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
14339     __Pyx_GOTREF(__pyx_t_2);
14340     __Pyx_INCREF(__pyx_n_s_PickleError);
14341     __Pyx_GIVEREF(__pyx_n_s_PickleError);
14342     PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
14343     __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
14344     __Pyx_GOTREF(__pyx_t_3);
14345     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14346     __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
14347     __Pyx_GOTREF(__pyx_t_2);
14348     __Pyx_INCREF(__pyx_t_2);
14349     __pyx_v___pyx_PickleError = __pyx_t_2;
14350     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14351     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14352 
14353     /* "(tree fragment)":6
14354  *     if __pyx_checksum != 0xd41d8cd:
14355  *         from pickle import PickleError as __pyx_PickleError
14356  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)             # <<<<<<<<<<<<<<
14357  *     __pyx_result = OGRGeomBuilder.__new__(__pyx_type)
14358  *     if __pyx_state is not None:
14359  */
14360     __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
14361     __Pyx_GOTREF(__pyx_t_2);
14362     __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xd4, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
14363     __Pyx_GOTREF(__pyx_t_4);
14364     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14365     __Pyx_INCREF(__pyx_v___pyx_PickleError);
14366     __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
14367     if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
14368       __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
14369       if (likely(__pyx_t_5)) {
14370         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
14371         __Pyx_INCREF(__pyx_t_5);
14372         __Pyx_INCREF(function);
14373         __Pyx_DECREF_SET(__pyx_t_2, function);
14374       }
14375     }
14376     __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
14377     __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
14378     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14379     if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
14380     __Pyx_GOTREF(__pyx_t_3);
14381     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14382     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
14383     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14384     __PYX_ERR(1, 6, __pyx_L1_error)
14385 
14386     /* "(tree fragment)":4
14387  *     cdef object __pyx_PickleError
14388  *     cdef object __pyx_result
14389  *     if __pyx_checksum != 0xd41d8cd:             # <<<<<<<<<<<<<<
14390  *         from pickle import PickleError as __pyx_PickleError
14391  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
14392  */
14393   }
14394 
14395   /* "(tree fragment)":7
14396  *         from pickle import PickleError as __pyx_PickleError
14397  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
14398  *     __pyx_result = OGRGeomBuilder.__new__(__pyx_type)             # <<<<<<<<<<<<<<
14399  *     if __pyx_state is not None:
14400  *         __pyx_unpickle_OGRGeomBuilder__set_state(<OGRGeomBuilder> __pyx_result, __pyx_state)
14401  */
14402   __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_8rasterio_9_features_OGRGeomBuilder), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
14403   __Pyx_GOTREF(__pyx_t_2);
14404   __pyx_t_4 = NULL;
14405   if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
14406     __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
14407     if (likely(__pyx_t_4)) {
14408       PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
14409       __Pyx_INCREF(__pyx_t_4);
14410       __Pyx_INCREF(function);
14411       __Pyx_DECREF_SET(__pyx_t_2, function);
14412     }
14413   }
14414   __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
14415   __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
14416   if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
14417   __Pyx_GOTREF(__pyx_t_3);
14418   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14419   __pyx_v___pyx_result = __pyx_t_3;
14420   __pyx_t_3 = 0;
14421 
14422   /* "(tree fragment)":8
14423  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
14424  *     __pyx_result = OGRGeomBuilder.__new__(__pyx_type)
14425  *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
14426  *         __pyx_unpickle_OGRGeomBuilder__set_state(<OGRGeomBuilder> __pyx_result, __pyx_state)
14427  *     return __pyx_result
14428  */
14429   __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
14430   __pyx_t_6 = (__pyx_t_1 != 0);
14431   if (__pyx_t_6) {
14432 
14433     /* "(tree fragment)":9
14434  *     __pyx_result = OGRGeomBuilder.__new__(__pyx_type)
14435  *     if __pyx_state is not None:
14436  *         __pyx_unpickle_OGRGeomBuilder__set_state(<OGRGeomBuilder> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
14437  *     return __pyx_result
14438  * cdef __pyx_unpickle_OGRGeomBuilder__set_state(OGRGeomBuilder __pyx_result, tuple __pyx_state):
14439  */
14440     if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
14441     __pyx_t_3 = __pyx_f_8rasterio_9_features___pyx_unpickle_OGRGeomBuilder__set_state(((struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
14442     __Pyx_GOTREF(__pyx_t_3);
14443     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14444 
14445     /* "(tree fragment)":8
14446  *         raise __pyx_PickleError("Incompatible checksums (%s vs 0xd41d8cd = ())" % __pyx_checksum)
14447  *     __pyx_result = OGRGeomBuilder.__new__(__pyx_type)
14448  *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
14449  *         __pyx_unpickle_OGRGeomBuilder__set_state(<OGRGeomBuilder> __pyx_result, __pyx_state)
14450  *     return __pyx_result
14451  */
14452   }
14453 
14454   /* "(tree fragment)":10
14455  *     if __pyx_state is not None:
14456  *         __pyx_unpickle_OGRGeomBuilder__set_state(<OGRGeomBuilder> __pyx_result, __pyx_state)
14457  *     return __pyx_result             # <<<<<<<<<<<<<<
14458  * cdef __pyx_unpickle_OGRGeomBuilder__set_state(OGRGeomBuilder __pyx_result, tuple __pyx_state):
14459  *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
14460  */
14461   __Pyx_XDECREF(__pyx_r);
14462   __Pyx_INCREF(__pyx_v___pyx_result);
14463   __pyx_r = __pyx_v___pyx_result;
14464   goto __pyx_L0;
14465 
14466   /* "(tree fragment)":1
14467  * def __pyx_unpickle_OGRGeomBuilder(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
14468  *     cdef object __pyx_PickleError
14469  *     cdef object __pyx_result
14470  */
14471 
14472   /* function exit code */
14473   __pyx_L1_error:;
14474   __Pyx_XDECREF(__pyx_t_2);
14475   __Pyx_XDECREF(__pyx_t_3);
14476   __Pyx_XDECREF(__pyx_t_4);
14477   __Pyx_XDECREF(__pyx_t_5);
14478   __Pyx_AddTraceback("rasterio._features.__pyx_unpickle_OGRGeomBuilder", __pyx_clineno, __pyx_lineno, __pyx_filename);
14479   __pyx_r = NULL;
14480   __pyx_L0:;
14481   __Pyx_XDECREF(__pyx_v___pyx_PickleError);
14482   __Pyx_XDECREF(__pyx_v___pyx_result);
14483   __Pyx_XGIVEREF(__pyx_r);
14484   __Pyx_RefNannyFinishContext();
14485   return __pyx_r;
14486 }
14487 
14488 /* "(tree fragment)":11
14489  *         __pyx_unpickle_OGRGeomBuilder__set_state(<OGRGeomBuilder> __pyx_result, __pyx_state)
14490  *     return __pyx_result
14491  * cdef __pyx_unpickle_OGRGeomBuilder__set_state(OGRGeomBuilder __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
14492  *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
14493  *         __pyx_result.__dict__.update(__pyx_state[0])
14494  */
14495 
__pyx_f_8rasterio_9_features___pyx_unpickle_OGRGeomBuilder__set_state(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder * __pyx_v___pyx_result,PyObject * __pyx_v___pyx_state)14496 static PyObject *__pyx_f_8rasterio_9_features___pyx_unpickle_OGRGeomBuilder__set_state(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
14497   PyObject *__pyx_r = NULL;
14498   __Pyx_RefNannyDeclarations
14499   int __pyx_t_1;
14500   Py_ssize_t __pyx_t_2;
14501   int __pyx_t_3;
14502   int __pyx_t_4;
14503   PyObject *__pyx_t_5 = NULL;
14504   PyObject *__pyx_t_6 = NULL;
14505   PyObject *__pyx_t_7 = NULL;
14506   PyObject *__pyx_t_8 = NULL;
14507   int __pyx_lineno = 0;
14508   const char *__pyx_filename = NULL;
14509   int __pyx_clineno = 0;
14510   __Pyx_RefNannySetupContext("__pyx_unpickle_OGRGeomBuilder__set_state", 0);
14511 
14512   /* "(tree fragment)":12
14513  *     return __pyx_result
14514  * cdef __pyx_unpickle_OGRGeomBuilder__set_state(OGRGeomBuilder __pyx_result, tuple __pyx_state):
14515  *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
14516  *         __pyx_result.__dict__.update(__pyx_state[0])
14517  */
14518   if (unlikely(__pyx_v___pyx_state == Py_None)) {
14519     PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
14520     __PYX_ERR(1, 12, __pyx_L1_error)
14521   }
14522   __pyx_t_2 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(1, 12, __pyx_L1_error)
14523   __pyx_t_3 = ((__pyx_t_2 > 0) != 0);
14524   if (__pyx_t_3) {
14525   } else {
14526     __pyx_t_1 = __pyx_t_3;
14527     goto __pyx_L4_bool_binop_done;
14528   }
14529   __pyx_t_3 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 12, __pyx_L1_error)
14530   __pyx_t_4 = (__pyx_t_3 != 0);
14531   __pyx_t_1 = __pyx_t_4;
14532   __pyx_L4_bool_binop_done:;
14533   if (__pyx_t_1) {
14534 
14535     /* "(tree fragment)":13
14536  * cdef __pyx_unpickle_OGRGeomBuilder__set_state(OGRGeomBuilder __pyx_result, tuple __pyx_state):
14537  *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
14538  *         __pyx_result.__dict__.update(__pyx_state[0])             # <<<<<<<<<<<<<<
14539  */
14540     __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
14541     __Pyx_GOTREF(__pyx_t_6);
14542     __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 13, __pyx_L1_error)
14543     __Pyx_GOTREF(__pyx_t_7);
14544     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14545     if (unlikely(__pyx_v___pyx_state == Py_None)) {
14546       PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
14547       __PYX_ERR(1, 13, __pyx_L1_error)
14548     }
14549     __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 13, __pyx_L1_error)
14550     __Pyx_GOTREF(__pyx_t_6);
14551     __pyx_t_8 = NULL;
14552     if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
14553       __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
14554       if (likely(__pyx_t_8)) {
14555         PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
14556         __Pyx_INCREF(__pyx_t_8);
14557         __Pyx_INCREF(function);
14558         __Pyx_DECREF_SET(__pyx_t_7, function);
14559       }
14560     }
14561     __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
14562     __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
14563     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
14564     if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
14565     __Pyx_GOTREF(__pyx_t_5);
14566     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
14567     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
14568 
14569     /* "(tree fragment)":12
14570  *     return __pyx_result
14571  * cdef __pyx_unpickle_OGRGeomBuilder__set_state(OGRGeomBuilder __pyx_result, tuple __pyx_state):
14572  *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
14573  *         __pyx_result.__dict__.update(__pyx_state[0])
14574  */
14575   }
14576 
14577   /* "(tree fragment)":11
14578  *         __pyx_unpickle_OGRGeomBuilder__set_state(<OGRGeomBuilder> __pyx_result, __pyx_state)
14579  *     return __pyx_result
14580  * cdef __pyx_unpickle_OGRGeomBuilder__set_state(OGRGeomBuilder __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
14581  *     if len(__pyx_state) > 0 and hasattr(__pyx_result, '__dict__'):
14582  *         __pyx_result.__dict__.update(__pyx_state[0])
14583  */
14584 
14585   /* function exit code */
14586   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
14587   goto __pyx_L0;
14588   __pyx_L1_error:;
14589   __Pyx_XDECREF(__pyx_t_5);
14590   __Pyx_XDECREF(__pyx_t_6);
14591   __Pyx_XDECREF(__pyx_t_7);
14592   __Pyx_XDECREF(__pyx_t_8);
14593   __Pyx_AddTraceback("rasterio._features.__pyx_unpickle_OGRGeomBuilder__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
14594   __pyx_r = 0;
14595   __pyx_L0:;
14596   __Pyx_XGIVEREF(__pyx_r);
14597   __Pyx_RefNannyFinishContext();
14598   return __pyx_r;
14599 }
14600 
14601 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":735
14602  * ctypedef npy_cdouble     complex_t
14603  *
14604  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
14605  *     return PyArray_MultiIterNew(1, <void*>a)
14606  *
14607  */
14608 
__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject * __pyx_v_a)14609 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
14610   PyObject *__pyx_r = NULL;
14611   __Pyx_RefNannyDeclarations
14612   PyObject *__pyx_t_1 = NULL;
14613   int __pyx_lineno = 0;
14614   const char *__pyx_filename = NULL;
14615   int __pyx_clineno = 0;
14616   __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
14617 
14618   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":736
14619  *
14620  * cdef inline object PyArray_MultiIterNew1(a):
14621  *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
14622  *
14623  * cdef inline object PyArray_MultiIterNew2(a, b):
14624  */
14625   __Pyx_XDECREF(__pyx_r);
14626   __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 736, __pyx_L1_error)
14627   __Pyx_GOTREF(__pyx_t_1);
14628   __pyx_r = __pyx_t_1;
14629   __pyx_t_1 = 0;
14630   goto __pyx_L0;
14631 
14632   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":735
14633  * ctypedef npy_cdouble     complex_t
14634  *
14635  * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
14636  *     return PyArray_MultiIterNew(1, <void*>a)
14637  *
14638  */
14639 
14640   /* function exit code */
14641   __pyx_L1_error:;
14642   __Pyx_XDECREF(__pyx_t_1);
14643   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
14644   __pyx_r = 0;
14645   __pyx_L0:;
14646   __Pyx_XGIVEREF(__pyx_r);
14647   __Pyx_RefNannyFinishContext();
14648   return __pyx_r;
14649 }
14650 
14651 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":738
14652  *     return PyArray_MultiIterNew(1, <void*>a)
14653  *
14654  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
14655  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
14656  *
14657  */
14658 
__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject * __pyx_v_a,PyObject * __pyx_v_b)14659 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
14660   PyObject *__pyx_r = NULL;
14661   __Pyx_RefNannyDeclarations
14662   PyObject *__pyx_t_1 = NULL;
14663   int __pyx_lineno = 0;
14664   const char *__pyx_filename = NULL;
14665   int __pyx_clineno = 0;
14666   __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
14667 
14668   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":739
14669  *
14670  * cdef inline object PyArray_MultiIterNew2(a, b):
14671  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
14672  *
14673  * cdef inline object PyArray_MultiIterNew3(a, b, c):
14674  */
14675   __Pyx_XDECREF(__pyx_r);
14676   __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 739, __pyx_L1_error)
14677   __Pyx_GOTREF(__pyx_t_1);
14678   __pyx_r = __pyx_t_1;
14679   __pyx_t_1 = 0;
14680   goto __pyx_L0;
14681 
14682   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":738
14683  *     return PyArray_MultiIterNew(1, <void*>a)
14684  *
14685  * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
14686  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
14687  *
14688  */
14689 
14690   /* function exit code */
14691   __pyx_L1_error:;
14692   __Pyx_XDECREF(__pyx_t_1);
14693   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
14694   __pyx_r = 0;
14695   __pyx_L0:;
14696   __Pyx_XGIVEREF(__pyx_r);
14697   __Pyx_RefNannyFinishContext();
14698   return __pyx_r;
14699 }
14700 
14701 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":741
14702  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
14703  *
14704  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
14705  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
14706  *
14707  */
14708 
__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c)14709 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
14710   PyObject *__pyx_r = NULL;
14711   __Pyx_RefNannyDeclarations
14712   PyObject *__pyx_t_1 = NULL;
14713   int __pyx_lineno = 0;
14714   const char *__pyx_filename = NULL;
14715   int __pyx_clineno = 0;
14716   __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
14717 
14718   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":742
14719  *
14720  * cdef inline object PyArray_MultiIterNew3(a, b, c):
14721  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
14722  *
14723  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
14724  */
14725   __Pyx_XDECREF(__pyx_r);
14726   __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 742, __pyx_L1_error)
14727   __Pyx_GOTREF(__pyx_t_1);
14728   __pyx_r = __pyx_t_1;
14729   __pyx_t_1 = 0;
14730   goto __pyx_L0;
14731 
14732   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":741
14733  *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
14734  *
14735  * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
14736  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
14737  *
14738  */
14739 
14740   /* function exit code */
14741   __pyx_L1_error:;
14742   __Pyx_XDECREF(__pyx_t_1);
14743   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
14744   __pyx_r = 0;
14745   __pyx_L0:;
14746   __Pyx_XGIVEREF(__pyx_r);
14747   __Pyx_RefNannyFinishContext();
14748   return __pyx_r;
14749 }
14750 
14751 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":744
14752  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
14753  *
14754  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
14755  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
14756  *
14757  */
14758 
__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c,PyObject * __pyx_v_d)14759 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
14760   PyObject *__pyx_r = NULL;
14761   __Pyx_RefNannyDeclarations
14762   PyObject *__pyx_t_1 = NULL;
14763   int __pyx_lineno = 0;
14764   const char *__pyx_filename = NULL;
14765   int __pyx_clineno = 0;
14766   __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
14767 
14768   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":745
14769  *
14770  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
14771  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
14772  *
14773  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
14774  */
14775   __Pyx_XDECREF(__pyx_r);
14776   __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 745, __pyx_L1_error)
14777   __Pyx_GOTREF(__pyx_t_1);
14778   __pyx_r = __pyx_t_1;
14779   __pyx_t_1 = 0;
14780   goto __pyx_L0;
14781 
14782   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":744
14783  *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
14784  *
14785  * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
14786  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
14787  *
14788  */
14789 
14790   /* function exit code */
14791   __pyx_L1_error:;
14792   __Pyx_XDECREF(__pyx_t_1);
14793   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
14794   __pyx_r = 0;
14795   __pyx_L0:;
14796   __Pyx_XGIVEREF(__pyx_r);
14797   __Pyx_RefNannyFinishContext();
14798   return __pyx_r;
14799 }
14800 
14801 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":747
14802  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
14803  *
14804  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
14805  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
14806  *
14807  */
14808 
__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject * __pyx_v_a,PyObject * __pyx_v_b,PyObject * __pyx_v_c,PyObject * __pyx_v_d,PyObject * __pyx_v_e)14809 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
14810   PyObject *__pyx_r = NULL;
14811   __Pyx_RefNannyDeclarations
14812   PyObject *__pyx_t_1 = NULL;
14813   int __pyx_lineno = 0;
14814   const char *__pyx_filename = NULL;
14815   int __pyx_clineno = 0;
14816   __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
14817 
14818   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":748
14819  *
14820  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
14821  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
14822  *
14823  * cdef inline tuple PyDataType_SHAPE(dtype d):
14824  */
14825   __Pyx_XDECREF(__pyx_r);
14826   __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 748, __pyx_L1_error)
14827   __Pyx_GOTREF(__pyx_t_1);
14828   __pyx_r = __pyx_t_1;
14829   __pyx_t_1 = 0;
14830   goto __pyx_L0;
14831 
14832   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":747
14833  *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
14834  *
14835  * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
14836  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
14837  *
14838  */
14839 
14840   /* function exit code */
14841   __pyx_L1_error:;
14842   __Pyx_XDECREF(__pyx_t_1);
14843   __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
14844   __pyx_r = 0;
14845   __pyx_L0:;
14846   __Pyx_XGIVEREF(__pyx_r);
14847   __Pyx_RefNannyFinishContext();
14848   return __pyx_r;
14849 }
14850 
14851 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":750
14852  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
14853  *
14854  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
14855  *     if PyDataType_HASSUBARRAY(d):
14856  *         return <tuple>d.subarray.shape
14857  */
14858 
__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr * __pyx_v_d)14859 static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) {
14860   PyObject *__pyx_r = NULL;
14861   __Pyx_RefNannyDeclarations
14862   int __pyx_t_1;
14863   __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);
14864 
14865   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":751
14866  *
14867  * cdef inline tuple PyDataType_SHAPE(dtype d):
14868  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
14869  *         return <tuple>d.subarray.shape
14870  *     else:
14871  */
14872   __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0);
14873   if (__pyx_t_1) {
14874 
14875     /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":752
14876  * cdef inline tuple PyDataType_SHAPE(dtype d):
14877  *     if PyDataType_HASSUBARRAY(d):
14878  *         return <tuple>d.subarray.shape             # <<<<<<<<<<<<<<
14879  *     else:
14880  *         return ()
14881  */
14882     __Pyx_XDECREF(__pyx_r);
14883     __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
14884     __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
14885     goto __pyx_L0;
14886 
14887     /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":751
14888  *
14889  * cdef inline tuple PyDataType_SHAPE(dtype d):
14890  *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
14891  *         return <tuple>d.subarray.shape
14892  *     else:
14893  */
14894   }
14895 
14896   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":754
14897  *         return <tuple>d.subarray.shape
14898  *     else:
14899  *         return ()             # <<<<<<<<<<<<<<
14900  *
14901  *
14902  */
14903   /*else*/ {
14904     __Pyx_XDECREF(__pyx_r);
14905     __Pyx_INCREF(__pyx_empty_tuple);
14906     __pyx_r = __pyx_empty_tuple;
14907     goto __pyx_L0;
14908   }
14909 
14910   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":750
14911  *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
14912  *
14913  * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
14914  *     if PyDataType_HASSUBARRAY(d):
14915  *         return <tuple>d.subarray.shape
14916  */
14917 
14918   /* function exit code */
14919   __pyx_L0:;
14920   __Pyx_XGIVEREF(__pyx_r);
14921   __Pyx_RefNannyFinishContext();
14922   return __pyx_r;
14923 }
14924 
14925 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":931
14926  *     int _import_umath() except -1
14927  *
14928  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
14929  *     Py_INCREF(base) # important to do this before stealing the reference below!
14930  *     PyArray_SetBaseObject(arr, base)
14931  */
14932 
__pyx_f_5numpy_set_array_base(PyArrayObject * __pyx_v_arr,PyObject * __pyx_v_base)14933 static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
14934   __Pyx_RefNannyDeclarations
14935   __Pyx_RefNannySetupContext("set_array_base", 0);
14936 
14937   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":932
14938  *
14939  * cdef inline void set_array_base(ndarray arr, object base):
14940  *     Py_INCREF(base) # important to do this before stealing the reference below!             # <<<<<<<<<<<<<<
14941  *     PyArray_SetBaseObject(arr, base)
14942  *
14943  */
14944   Py_INCREF(__pyx_v_base);
14945 
14946   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":933
14947  * cdef inline void set_array_base(ndarray arr, object base):
14948  *     Py_INCREF(base) # important to do this before stealing the reference below!
14949  *     PyArray_SetBaseObject(arr, base)             # <<<<<<<<<<<<<<
14950  *
14951  * cdef inline object get_array_base(ndarray arr):
14952  */
14953   (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base));
14954 
14955   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":931
14956  *     int _import_umath() except -1
14957  *
14958  * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
14959  *     Py_INCREF(base) # important to do this before stealing the reference below!
14960  *     PyArray_SetBaseObject(arr, base)
14961  */
14962 
14963   /* function exit code */
14964   __Pyx_RefNannyFinishContext();
14965 }
14966 
14967 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":935
14968  *     PyArray_SetBaseObject(arr, base)
14969  *
14970  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
14971  *     base = PyArray_BASE(arr)
14972  *     if base is NULL:
14973  */
14974 
__pyx_f_5numpy_get_array_base(PyArrayObject * __pyx_v_arr)14975 static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
14976   PyObject *__pyx_v_base;
14977   PyObject *__pyx_r = NULL;
14978   __Pyx_RefNannyDeclarations
14979   int __pyx_t_1;
14980   __Pyx_RefNannySetupContext("get_array_base", 0);
14981 
14982   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":936
14983  *
14984  * cdef inline object get_array_base(ndarray arr):
14985  *     base = PyArray_BASE(arr)             # <<<<<<<<<<<<<<
14986  *     if base is NULL:
14987  *         return None
14988  */
14989   __pyx_v_base = PyArray_BASE(__pyx_v_arr);
14990 
14991   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":937
14992  * cdef inline object get_array_base(ndarray arr):
14993  *     base = PyArray_BASE(arr)
14994  *     if base is NULL:             # <<<<<<<<<<<<<<
14995  *         return None
14996  *     return <object>base
14997  */
14998   __pyx_t_1 = ((__pyx_v_base == NULL) != 0);
14999   if (__pyx_t_1) {
15000 
15001     /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":938
15002  *     base = PyArray_BASE(arr)
15003  *     if base is NULL:
15004  *         return None             # <<<<<<<<<<<<<<
15005  *     return <object>base
15006  *
15007  */
15008     __Pyx_XDECREF(__pyx_r);
15009     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
15010     goto __pyx_L0;
15011 
15012     /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":937
15013  * cdef inline object get_array_base(ndarray arr):
15014  *     base = PyArray_BASE(arr)
15015  *     if base is NULL:             # <<<<<<<<<<<<<<
15016  *         return None
15017  *     return <object>base
15018  */
15019   }
15020 
15021   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":939
15022  *     if base is NULL:
15023  *         return None
15024  *     return <object>base             # <<<<<<<<<<<<<<
15025  *
15026  * # Versions of the import_* functions which are more suitable for
15027  */
15028   __Pyx_XDECREF(__pyx_r);
15029   __Pyx_INCREF(((PyObject *)__pyx_v_base));
15030   __pyx_r = ((PyObject *)__pyx_v_base);
15031   goto __pyx_L0;
15032 
15033   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":935
15034  *     PyArray_SetBaseObject(arr, base)
15035  *
15036  * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
15037  *     base = PyArray_BASE(arr)
15038  *     if base is NULL:
15039  */
15040 
15041   /* function exit code */
15042   __pyx_L0:;
15043   __Pyx_XGIVEREF(__pyx_r);
15044   __Pyx_RefNannyFinishContext();
15045   return __pyx_r;
15046 }
15047 
15048 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":943
15049  * # Versions of the import_* functions which are more suitable for
15050  * # Cython code.
15051  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
15052  *     try:
15053  *         __pyx_import_array()
15054  */
15055 
__pyx_f_5numpy_import_array(void)15056 static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
15057   int __pyx_r;
15058   __Pyx_RefNannyDeclarations
15059   PyObject *__pyx_t_1 = NULL;
15060   PyObject *__pyx_t_2 = NULL;
15061   PyObject *__pyx_t_3 = NULL;
15062   int __pyx_t_4;
15063   PyObject *__pyx_t_5 = NULL;
15064   PyObject *__pyx_t_6 = NULL;
15065   PyObject *__pyx_t_7 = NULL;
15066   PyObject *__pyx_t_8 = NULL;
15067   int __pyx_lineno = 0;
15068   const char *__pyx_filename = NULL;
15069   int __pyx_clineno = 0;
15070   __Pyx_RefNannySetupContext("import_array", 0);
15071 
15072   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":944
15073  * # Cython code.
15074  * cdef inline int import_array() except -1:
15075  *     try:             # <<<<<<<<<<<<<<
15076  *         __pyx_import_array()
15077  *     except Exception:
15078  */
15079   {
15080     __Pyx_PyThreadState_declare
15081     __Pyx_PyThreadState_assign
15082     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
15083     __Pyx_XGOTREF(__pyx_t_1);
15084     __Pyx_XGOTREF(__pyx_t_2);
15085     __Pyx_XGOTREF(__pyx_t_3);
15086     /*try:*/ {
15087 
15088       /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":945
15089  * cdef inline int import_array() except -1:
15090  *     try:
15091  *         __pyx_import_array()             # <<<<<<<<<<<<<<
15092  *     except Exception:
15093  *         raise ImportError("numpy.core.multiarray failed to import")
15094  */
15095       __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 945, __pyx_L3_error)
15096 
15097       /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":944
15098  * # Cython code.
15099  * cdef inline int import_array() except -1:
15100  *     try:             # <<<<<<<<<<<<<<
15101  *         __pyx_import_array()
15102  *     except Exception:
15103  */
15104     }
15105     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
15106     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
15107     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
15108     goto __pyx_L8_try_end;
15109     __pyx_L3_error:;
15110 
15111     /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":946
15112  *     try:
15113  *         __pyx_import_array()
15114  *     except Exception:             # <<<<<<<<<<<<<<
15115  *         raise ImportError("numpy.core.multiarray failed to import")
15116  *
15117  */
15118     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
15119     if (__pyx_t_4) {
15120       __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
15121       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 946, __pyx_L5_except_error)
15122       __Pyx_GOTREF(__pyx_t_5);
15123       __Pyx_GOTREF(__pyx_t_6);
15124       __Pyx_GOTREF(__pyx_t_7);
15125 
15126       /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":947
15127  *         __pyx_import_array()
15128  *     except Exception:
15129  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
15130  *
15131  * cdef inline int import_umath() except -1:
15132  */
15133       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 947, __pyx_L5_except_error)
15134       __Pyx_GOTREF(__pyx_t_8);
15135       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
15136       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
15137       __PYX_ERR(2, 947, __pyx_L5_except_error)
15138     }
15139     goto __pyx_L5_except_error;
15140     __pyx_L5_except_error:;
15141 
15142     /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":944
15143  * # Cython code.
15144  * cdef inline int import_array() except -1:
15145  *     try:             # <<<<<<<<<<<<<<
15146  *         __pyx_import_array()
15147  *     except Exception:
15148  */
15149     __Pyx_XGIVEREF(__pyx_t_1);
15150     __Pyx_XGIVEREF(__pyx_t_2);
15151     __Pyx_XGIVEREF(__pyx_t_3);
15152     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
15153     goto __pyx_L1_error;
15154     __pyx_L8_try_end:;
15155   }
15156 
15157   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":943
15158  * # Versions of the import_* functions which are more suitable for
15159  * # Cython code.
15160  * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
15161  *     try:
15162  *         __pyx_import_array()
15163  */
15164 
15165   /* function exit code */
15166   __pyx_r = 0;
15167   goto __pyx_L0;
15168   __pyx_L1_error:;
15169   __Pyx_XDECREF(__pyx_t_5);
15170   __Pyx_XDECREF(__pyx_t_6);
15171   __Pyx_XDECREF(__pyx_t_7);
15172   __Pyx_XDECREF(__pyx_t_8);
15173   __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
15174   __pyx_r = -1;
15175   __pyx_L0:;
15176   __Pyx_RefNannyFinishContext();
15177   return __pyx_r;
15178 }
15179 
15180 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":949
15181  *         raise ImportError("numpy.core.multiarray failed to import")
15182  *
15183  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
15184  *     try:
15185  *         _import_umath()
15186  */
15187 
__pyx_f_5numpy_import_umath(void)15188 static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
15189   int __pyx_r;
15190   __Pyx_RefNannyDeclarations
15191   PyObject *__pyx_t_1 = NULL;
15192   PyObject *__pyx_t_2 = NULL;
15193   PyObject *__pyx_t_3 = NULL;
15194   int __pyx_t_4;
15195   PyObject *__pyx_t_5 = NULL;
15196   PyObject *__pyx_t_6 = NULL;
15197   PyObject *__pyx_t_7 = NULL;
15198   PyObject *__pyx_t_8 = NULL;
15199   int __pyx_lineno = 0;
15200   const char *__pyx_filename = NULL;
15201   int __pyx_clineno = 0;
15202   __Pyx_RefNannySetupContext("import_umath", 0);
15203 
15204   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":950
15205  *
15206  * cdef inline int import_umath() except -1:
15207  *     try:             # <<<<<<<<<<<<<<
15208  *         _import_umath()
15209  *     except Exception:
15210  */
15211   {
15212     __Pyx_PyThreadState_declare
15213     __Pyx_PyThreadState_assign
15214     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
15215     __Pyx_XGOTREF(__pyx_t_1);
15216     __Pyx_XGOTREF(__pyx_t_2);
15217     __Pyx_XGOTREF(__pyx_t_3);
15218     /*try:*/ {
15219 
15220       /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":951
15221  * cdef inline int import_umath() except -1:
15222  *     try:
15223  *         _import_umath()             # <<<<<<<<<<<<<<
15224  *     except Exception:
15225  *         raise ImportError("numpy.core.umath failed to import")
15226  */
15227       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 951, __pyx_L3_error)
15228 
15229       /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":950
15230  *
15231  * cdef inline int import_umath() except -1:
15232  *     try:             # <<<<<<<<<<<<<<
15233  *         _import_umath()
15234  *     except Exception:
15235  */
15236     }
15237     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
15238     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
15239     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
15240     goto __pyx_L8_try_end;
15241     __pyx_L3_error:;
15242 
15243     /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":952
15244  *     try:
15245  *         _import_umath()
15246  *     except Exception:             # <<<<<<<<<<<<<<
15247  *         raise ImportError("numpy.core.umath failed to import")
15248  *
15249  */
15250     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
15251     if (__pyx_t_4) {
15252       __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
15253       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 952, __pyx_L5_except_error)
15254       __Pyx_GOTREF(__pyx_t_5);
15255       __Pyx_GOTREF(__pyx_t_6);
15256       __Pyx_GOTREF(__pyx_t_7);
15257 
15258       /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":953
15259  *         _import_umath()
15260  *     except Exception:
15261  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
15262  *
15263  * cdef inline int import_ufunc() except -1:
15264  */
15265       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 953, __pyx_L5_except_error)
15266       __Pyx_GOTREF(__pyx_t_8);
15267       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
15268       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
15269       __PYX_ERR(2, 953, __pyx_L5_except_error)
15270     }
15271     goto __pyx_L5_except_error;
15272     __pyx_L5_except_error:;
15273 
15274     /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":950
15275  *
15276  * cdef inline int import_umath() except -1:
15277  *     try:             # <<<<<<<<<<<<<<
15278  *         _import_umath()
15279  *     except Exception:
15280  */
15281     __Pyx_XGIVEREF(__pyx_t_1);
15282     __Pyx_XGIVEREF(__pyx_t_2);
15283     __Pyx_XGIVEREF(__pyx_t_3);
15284     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
15285     goto __pyx_L1_error;
15286     __pyx_L8_try_end:;
15287   }
15288 
15289   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":949
15290  *         raise ImportError("numpy.core.multiarray failed to import")
15291  *
15292  * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
15293  *     try:
15294  *         _import_umath()
15295  */
15296 
15297   /* function exit code */
15298   __pyx_r = 0;
15299   goto __pyx_L0;
15300   __pyx_L1_error:;
15301   __Pyx_XDECREF(__pyx_t_5);
15302   __Pyx_XDECREF(__pyx_t_6);
15303   __Pyx_XDECREF(__pyx_t_7);
15304   __Pyx_XDECREF(__pyx_t_8);
15305   __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
15306   __pyx_r = -1;
15307   __pyx_L0:;
15308   __Pyx_RefNannyFinishContext();
15309   return __pyx_r;
15310 }
15311 
15312 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":955
15313  *         raise ImportError("numpy.core.umath failed to import")
15314  *
15315  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
15316  *     try:
15317  *         _import_umath()
15318  */
15319 
__pyx_f_5numpy_import_ufunc(void)15320 static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
15321   int __pyx_r;
15322   __Pyx_RefNannyDeclarations
15323   PyObject *__pyx_t_1 = NULL;
15324   PyObject *__pyx_t_2 = NULL;
15325   PyObject *__pyx_t_3 = NULL;
15326   int __pyx_t_4;
15327   PyObject *__pyx_t_5 = NULL;
15328   PyObject *__pyx_t_6 = NULL;
15329   PyObject *__pyx_t_7 = NULL;
15330   PyObject *__pyx_t_8 = NULL;
15331   int __pyx_lineno = 0;
15332   const char *__pyx_filename = NULL;
15333   int __pyx_clineno = 0;
15334   __Pyx_RefNannySetupContext("import_ufunc", 0);
15335 
15336   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":956
15337  *
15338  * cdef inline int import_ufunc() except -1:
15339  *     try:             # <<<<<<<<<<<<<<
15340  *         _import_umath()
15341  *     except Exception:
15342  */
15343   {
15344     __Pyx_PyThreadState_declare
15345     __Pyx_PyThreadState_assign
15346     __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
15347     __Pyx_XGOTREF(__pyx_t_1);
15348     __Pyx_XGOTREF(__pyx_t_2);
15349     __Pyx_XGOTREF(__pyx_t_3);
15350     /*try:*/ {
15351 
15352       /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":957
15353  * cdef inline int import_ufunc() except -1:
15354  *     try:
15355  *         _import_umath()             # <<<<<<<<<<<<<<
15356  *     except Exception:
15357  *         raise ImportError("numpy.core.umath failed to import")
15358  */
15359       __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 957, __pyx_L3_error)
15360 
15361       /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":956
15362  *
15363  * cdef inline int import_ufunc() except -1:
15364  *     try:             # <<<<<<<<<<<<<<
15365  *         _import_umath()
15366  *     except Exception:
15367  */
15368     }
15369     __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
15370     __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
15371     __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
15372     goto __pyx_L8_try_end;
15373     __pyx_L3_error:;
15374 
15375     /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":958
15376  *     try:
15377  *         _import_umath()
15378  *     except Exception:             # <<<<<<<<<<<<<<
15379  *         raise ImportError("numpy.core.umath failed to import")
15380  *
15381  */
15382     __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
15383     if (__pyx_t_4) {
15384       __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
15385       if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 958, __pyx_L5_except_error)
15386       __Pyx_GOTREF(__pyx_t_5);
15387       __Pyx_GOTREF(__pyx_t_6);
15388       __Pyx_GOTREF(__pyx_t_7);
15389 
15390       /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":959
15391  *         _import_umath()
15392  *     except Exception:
15393  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
15394  *
15395  * cdef extern from *:
15396  */
15397       __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 959, __pyx_L5_except_error)
15398       __Pyx_GOTREF(__pyx_t_8);
15399       __Pyx_Raise(__pyx_t_8, 0, 0, 0);
15400       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
15401       __PYX_ERR(2, 959, __pyx_L5_except_error)
15402     }
15403     goto __pyx_L5_except_error;
15404     __pyx_L5_except_error:;
15405 
15406     /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":956
15407  *
15408  * cdef inline int import_ufunc() except -1:
15409  *     try:             # <<<<<<<<<<<<<<
15410  *         _import_umath()
15411  *     except Exception:
15412  */
15413     __Pyx_XGIVEREF(__pyx_t_1);
15414     __Pyx_XGIVEREF(__pyx_t_2);
15415     __Pyx_XGIVEREF(__pyx_t_3);
15416     __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
15417     goto __pyx_L1_error;
15418     __pyx_L8_try_end:;
15419   }
15420 
15421   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":955
15422  *         raise ImportError("numpy.core.umath failed to import")
15423  *
15424  * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
15425  *     try:
15426  *         _import_umath()
15427  */
15428 
15429   /* function exit code */
15430   __pyx_r = 0;
15431   goto __pyx_L0;
15432   __pyx_L1_error:;
15433   __Pyx_XDECREF(__pyx_t_5);
15434   __Pyx_XDECREF(__pyx_t_6);
15435   __Pyx_XDECREF(__pyx_t_7);
15436   __Pyx_XDECREF(__pyx_t_8);
15437   __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
15438   __pyx_r = -1;
15439   __pyx_L0:;
15440   __Pyx_RefNannyFinishContext();
15441   return __pyx_r;
15442 }
15443 
15444 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":969
15445  *
15446  *
15447  * cdef inline bint is_timedelta64_object(object obj):             # <<<<<<<<<<<<<<
15448  *     """
15449  *     Cython equivalent of `isinstance(obj, np.timedelta64)`
15450  */
15451 
__pyx_f_5numpy_is_timedelta64_object(PyObject * __pyx_v_obj)15452 static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_obj) {
15453   int __pyx_r;
15454   __Pyx_RefNannyDeclarations
15455   __Pyx_RefNannySetupContext("is_timedelta64_object", 0);
15456 
15457   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":981
15458  *     bool
15459  *     """
15460  *     return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type)             # <<<<<<<<<<<<<<
15461  *
15462  *
15463  */
15464   __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyTimedeltaArrType_Type));
15465   goto __pyx_L0;
15466 
15467   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":969
15468  *
15469  *
15470  * cdef inline bint is_timedelta64_object(object obj):             # <<<<<<<<<<<<<<
15471  *     """
15472  *     Cython equivalent of `isinstance(obj, np.timedelta64)`
15473  */
15474 
15475   /* function exit code */
15476   __pyx_L0:;
15477   __Pyx_RefNannyFinishContext();
15478   return __pyx_r;
15479 }
15480 
15481 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":984
15482  *
15483  *
15484  * cdef inline bint is_datetime64_object(object obj):             # <<<<<<<<<<<<<<
15485  *     """
15486  *     Cython equivalent of `isinstance(obj, np.datetime64)`
15487  */
15488 
__pyx_f_5numpy_is_datetime64_object(PyObject * __pyx_v_obj)15489 static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_obj) {
15490   int __pyx_r;
15491   __Pyx_RefNannyDeclarations
15492   __Pyx_RefNannySetupContext("is_datetime64_object", 0);
15493 
15494   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":996
15495  *     bool
15496  *     """
15497  *     return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type)             # <<<<<<<<<<<<<<
15498  *
15499  *
15500  */
15501   __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyDatetimeArrType_Type));
15502   goto __pyx_L0;
15503 
15504   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":984
15505  *
15506  *
15507  * cdef inline bint is_datetime64_object(object obj):             # <<<<<<<<<<<<<<
15508  *     """
15509  *     Cython equivalent of `isinstance(obj, np.datetime64)`
15510  */
15511 
15512   /* function exit code */
15513   __pyx_L0:;
15514   __Pyx_RefNannyFinishContext();
15515   return __pyx_r;
15516 }
15517 
15518 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":999
15519  *
15520  *
15521  * cdef inline npy_datetime get_datetime64_value(object obj) nogil:             # <<<<<<<<<<<<<<
15522  *     """
15523  *     returns the int64 value underlying scalar numpy datetime64 object
15524  */
15525 
__pyx_f_5numpy_get_datetime64_value(PyObject * __pyx_v_obj)15526 static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject *__pyx_v_obj) {
15527   npy_datetime __pyx_r;
15528 
15529   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":1006
15530  *     also needed.  That can be found using `get_datetime64_unit`.
15531  *     """
15532  *     return (<PyDatetimeScalarObject*>obj).obval             # <<<<<<<<<<<<<<
15533  *
15534  *
15535  */
15536   __pyx_r = ((PyDatetimeScalarObject *)__pyx_v_obj)->obval;
15537   goto __pyx_L0;
15538 
15539   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":999
15540  *
15541  *
15542  * cdef inline npy_datetime get_datetime64_value(object obj) nogil:             # <<<<<<<<<<<<<<
15543  *     """
15544  *     returns the int64 value underlying scalar numpy datetime64 object
15545  */
15546 
15547   /* function exit code */
15548   __pyx_L0:;
15549   return __pyx_r;
15550 }
15551 
15552 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":1009
15553  *
15554  *
15555  * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil:             # <<<<<<<<<<<<<<
15556  *     """
15557  *     returns the int64 value underlying scalar numpy timedelta64 object
15558  */
15559 
__pyx_f_5numpy_get_timedelta64_value(PyObject * __pyx_v_obj)15560 static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject *__pyx_v_obj) {
15561   npy_timedelta __pyx_r;
15562 
15563   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":1013
15564  *     returns the int64 value underlying scalar numpy timedelta64 object
15565  *     """
15566  *     return (<PyTimedeltaScalarObject*>obj).obval             # <<<<<<<<<<<<<<
15567  *
15568  *
15569  */
15570   __pyx_r = ((PyTimedeltaScalarObject *)__pyx_v_obj)->obval;
15571   goto __pyx_L0;
15572 
15573   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":1009
15574  *
15575  *
15576  * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil:             # <<<<<<<<<<<<<<
15577  *     """
15578  *     returns the int64 value underlying scalar numpy timedelta64 object
15579  */
15580 
15581   /* function exit code */
15582   __pyx_L0:;
15583   return __pyx_r;
15584 }
15585 
15586 /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":1016
15587  *
15588  *
15589  * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:             # <<<<<<<<<<<<<<
15590  *     """
15591  *     returns the unit part of the dtype for a numpy datetime64 object.
15592  */
15593 
__pyx_f_5numpy_get_datetime64_unit(PyObject * __pyx_v_obj)15594 static CYTHON_INLINE NPY_DATETIMEUNIT __pyx_f_5numpy_get_datetime64_unit(PyObject *__pyx_v_obj) {
15595   NPY_DATETIMEUNIT __pyx_r;
15596 
15597   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":1020
15598  *     returns the unit part of the dtype for a numpy datetime64 object.
15599  *     """
15600  *     return <NPY_DATETIMEUNIT>(<PyDatetimeScalarObject*>obj).obmeta.base             # <<<<<<<<<<<<<<
15601  */
15602   __pyx_r = ((NPY_DATETIMEUNIT)((PyDatetimeScalarObject *)__pyx_v_obj)->obmeta.base);
15603   goto __pyx_L0;
15604 
15605   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":1016
15606  *
15607  *
15608  * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:             # <<<<<<<<<<<<<<
15609  *     """
15610  *     returns the unit part of the dtype for a numpy datetime64 object.
15611  */
15612 
15613   /* function exit code */
15614   __pyx_L0:;
15615   return __pyx_r;
15616 }
15617 static struct __pyx_vtabstruct_8rasterio_9_features_GeomBuilder __pyx_vtable_8rasterio_9_features_GeomBuilder;
15618 
__pyx_tp_new_8rasterio_9_features_GeomBuilder(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)15619 static PyObject *__pyx_tp_new_8rasterio_9_features_GeomBuilder(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
15620   struct __pyx_obj_8rasterio_9_features_GeomBuilder *p;
15621   PyObject *o;
15622   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
15623     o = (*t->tp_alloc)(t, 0);
15624   } else {
15625     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
15626   }
15627   if (unlikely(!o)) return 0;
15628   p = ((struct __pyx_obj_8rasterio_9_features_GeomBuilder *)o);
15629   p->__pyx_vtab = __pyx_vtabptr_8rasterio_9_features_GeomBuilder;
15630   p->code = Py_None; Py_INCREF(Py_None);
15631   p->geomtypename = Py_None; Py_INCREF(Py_None);
15632   p->ndims = Py_None; Py_INCREF(Py_None);
15633   return o;
15634 }
15635 
__pyx_tp_dealloc_8rasterio_9_features_GeomBuilder(PyObject * o)15636 static void __pyx_tp_dealloc_8rasterio_9_features_GeomBuilder(PyObject *o) {
15637   struct __pyx_obj_8rasterio_9_features_GeomBuilder *p = (struct __pyx_obj_8rasterio_9_features_GeomBuilder *)o;
15638   #if CYTHON_USE_TP_FINALIZE
15639   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
15640     if (PyObject_CallFinalizerFromDealloc(o)) return;
15641   }
15642   #endif
15643   PyObject_GC_UnTrack(o);
15644   Py_CLEAR(p->code);
15645   Py_CLEAR(p->geomtypename);
15646   Py_CLEAR(p->ndims);
15647   (*Py_TYPE(o)->tp_free)(o);
15648 }
15649 
__pyx_tp_traverse_8rasterio_9_features_GeomBuilder(PyObject * o,visitproc v,void * a)15650 static int __pyx_tp_traverse_8rasterio_9_features_GeomBuilder(PyObject *o, visitproc v, void *a) {
15651   int e;
15652   struct __pyx_obj_8rasterio_9_features_GeomBuilder *p = (struct __pyx_obj_8rasterio_9_features_GeomBuilder *)o;
15653   if (p->code) {
15654     e = (*v)(p->code, a); if (e) return e;
15655   }
15656   if (p->geomtypename) {
15657     e = (*v)(p->geomtypename, a); if (e) return e;
15658   }
15659   if (p->ndims) {
15660     e = (*v)(p->ndims, a); if (e) return e;
15661   }
15662   return 0;
15663 }
15664 
__pyx_tp_clear_8rasterio_9_features_GeomBuilder(PyObject * o)15665 static int __pyx_tp_clear_8rasterio_9_features_GeomBuilder(PyObject *o) {
15666   PyObject* tmp;
15667   struct __pyx_obj_8rasterio_9_features_GeomBuilder *p = (struct __pyx_obj_8rasterio_9_features_GeomBuilder *)o;
15668   tmp = ((PyObject*)p->code);
15669   p->code = Py_None; Py_INCREF(Py_None);
15670   Py_XDECREF(tmp);
15671   tmp = ((PyObject*)p->geomtypename);
15672   p->geomtypename = Py_None; Py_INCREF(Py_None);
15673   Py_XDECREF(tmp);
15674   tmp = ((PyObject*)p->ndims);
15675   p->ndims = Py_None; Py_INCREF(Py_None);
15676   Py_XDECREF(tmp);
15677   return 0;
15678 }
15679 
15680 static PyMethodDef __pyx_methods_8rasterio_9_features_GeomBuilder[] = {
15681   {"_buildPoint", (PyCFunction)__pyx_pw_8rasterio_9_features_11GeomBuilder_1_buildPoint, METH_NOARGS, 0},
15682   {"_buildLineString", (PyCFunction)__pyx_pw_8rasterio_9_features_11GeomBuilder_3_buildLineString, METH_NOARGS, 0},
15683   {"_buildLinearRing", (PyCFunction)__pyx_pw_8rasterio_9_features_11GeomBuilder_5_buildLinearRing, METH_NOARGS, 0},
15684   {"_buildPolygon", (PyCFunction)__pyx_pw_8rasterio_9_features_11GeomBuilder_7_buildPolygon, METH_NOARGS, 0},
15685   {"_buildMultiPoint", (PyCFunction)__pyx_pw_8rasterio_9_features_11GeomBuilder_9_buildMultiPoint, METH_NOARGS, 0},
15686   {"_buildMultiLineString", (PyCFunction)__pyx_pw_8rasterio_9_features_11GeomBuilder_11_buildMultiLineString, METH_NOARGS, 0},
15687   {"_buildMultiPolygon", (PyCFunction)__pyx_pw_8rasterio_9_features_11GeomBuilder_13_buildMultiPolygon, METH_NOARGS, 0},
15688   {"__reduce_cython__", (PyCFunction)__pyx_pw_8rasterio_9_features_11GeomBuilder_15__reduce_cython__, METH_NOARGS, 0},
15689   {"__setstate_cython__", (PyCFunction)__pyx_pw_8rasterio_9_features_11GeomBuilder_17__setstate_cython__, METH_O, 0},
15690   {0, 0, 0, 0}
15691 };
15692 
15693 static PyTypeObject __pyx_type_8rasterio_9_features_GeomBuilder = {
15694   PyVarObject_HEAD_INIT(0, 0)
15695   "rasterio._features.GeomBuilder", /*tp_name*/
15696   sizeof(struct __pyx_obj_8rasterio_9_features_GeomBuilder), /*tp_basicsize*/
15697   0, /*tp_itemsize*/
15698   __pyx_tp_dealloc_8rasterio_9_features_GeomBuilder, /*tp_dealloc*/
15699   #if PY_VERSION_HEX < 0x030800b4
15700   0, /*tp_print*/
15701   #endif
15702   #if PY_VERSION_HEX >= 0x030800b4
15703   0, /*tp_vectorcall_offset*/
15704   #endif
15705   0, /*tp_getattr*/
15706   0, /*tp_setattr*/
15707   #if PY_MAJOR_VERSION < 3
15708   0, /*tp_compare*/
15709   #endif
15710   #if PY_MAJOR_VERSION >= 3
15711   0, /*tp_as_async*/
15712   #endif
15713   0, /*tp_repr*/
15714   0, /*tp_as_number*/
15715   0, /*tp_as_sequence*/
15716   0, /*tp_as_mapping*/
15717   0, /*tp_hash*/
15718   0, /*tp_call*/
15719   0, /*tp_str*/
15720   0, /*tp_getattro*/
15721   0, /*tp_setattro*/
15722   0, /*tp_as_buffer*/
15723   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
15724   "Builds a GeoJSON (Fiona-style) geometry from an OGR geometry.", /*tp_doc*/
15725   __pyx_tp_traverse_8rasterio_9_features_GeomBuilder, /*tp_traverse*/
15726   __pyx_tp_clear_8rasterio_9_features_GeomBuilder, /*tp_clear*/
15727   0, /*tp_richcompare*/
15728   0, /*tp_weaklistoffset*/
15729   0, /*tp_iter*/
15730   0, /*tp_iternext*/
15731   __pyx_methods_8rasterio_9_features_GeomBuilder, /*tp_methods*/
15732   0, /*tp_members*/
15733   0, /*tp_getset*/
15734   0, /*tp_base*/
15735   0, /*tp_dict*/
15736   0, /*tp_descr_get*/
15737   0, /*tp_descr_set*/
15738   0, /*tp_dictoffset*/
15739   0, /*tp_init*/
15740   0, /*tp_alloc*/
15741   __pyx_tp_new_8rasterio_9_features_GeomBuilder, /*tp_new*/
15742   0, /*tp_free*/
15743   0, /*tp_is_gc*/
15744   0, /*tp_bases*/
15745   0, /*tp_mro*/
15746   0, /*tp_cache*/
15747   0, /*tp_subclasses*/
15748   0, /*tp_weaklist*/
15749   0, /*tp_del*/
15750   0, /*tp_version_tag*/
15751   #if PY_VERSION_HEX >= 0x030400a1
15752   0, /*tp_finalize*/
15753   #endif
15754   #if PY_VERSION_HEX >= 0x030800b1
15755   0, /*tp_vectorcall*/
15756   #endif
15757   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
15758   0, /*tp_print*/
15759   #endif
15760 };
15761 static struct __pyx_vtabstruct_8rasterio_9_features_OGRGeomBuilder __pyx_vtable_8rasterio_9_features_OGRGeomBuilder;
15762 
__pyx_tp_new_8rasterio_9_features_OGRGeomBuilder(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)15763 static PyObject *__pyx_tp_new_8rasterio_9_features_OGRGeomBuilder(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
15764   struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *p;
15765   PyObject *o;
15766   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
15767     o = (*t->tp_alloc)(t, 0);
15768   } else {
15769     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
15770   }
15771   if (unlikely(!o)) return 0;
15772   p = ((struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *)o);
15773   p->__pyx_vtab = __pyx_vtabptr_8rasterio_9_features_OGRGeomBuilder;
15774   return o;
15775 }
15776 
__pyx_tp_dealloc_8rasterio_9_features_OGRGeomBuilder(PyObject * o)15777 static void __pyx_tp_dealloc_8rasterio_9_features_OGRGeomBuilder(PyObject *o) {
15778   #if CYTHON_USE_TP_FINALIZE
15779   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
15780     if (PyObject_CallFinalizerFromDealloc(o)) return;
15781   }
15782   #endif
15783   (*Py_TYPE(o)->tp_free)(o);
15784 }
15785 
15786 static PyMethodDef __pyx_methods_8rasterio_9_features_OGRGeomBuilder[] = {
15787   {"__reduce_cython__", (PyCFunction)__pyx_pw_8rasterio_9_features_14OGRGeomBuilder_1__reduce_cython__, METH_NOARGS, 0},
15788   {"__setstate_cython__", (PyCFunction)__pyx_pw_8rasterio_9_features_14OGRGeomBuilder_3__setstate_cython__, METH_O, 0},
15789   {0, 0, 0, 0}
15790 };
15791 
15792 static PyTypeObject __pyx_type_8rasterio_9_features_OGRGeomBuilder = {
15793   PyVarObject_HEAD_INIT(0, 0)
15794   "rasterio._features.OGRGeomBuilder", /*tp_name*/
15795   sizeof(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder), /*tp_basicsize*/
15796   0, /*tp_itemsize*/
15797   __pyx_tp_dealloc_8rasterio_9_features_OGRGeomBuilder, /*tp_dealloc*/
15798   #if PY_VERSION_HEX < 0x030800b4
15799   0, /*tp_print*/
15800   #endif
15801   #if PY_VERSION_HEX >= 0x030800b4
15802   0, /*tp_vectorcall_offset*/
15803   #endif
15804   0, /*tp_getattr*/
15805   0, /*tp_setattr*/
15806   #if PY_MAJOR_VERSION < 3
15807   0, /*tp_compare*/
15808   #endif
15809   #if PY_MAJOR_VERSION >= 3
15810   0, /*tp_as_async*/
15811   #endif
15812   0, /*tp_repr*/
15813   0, /*tp_as_number*/
15814   0, /*tp_as_sequence*/
15815   0, /*tp_as_mapping*/
15816   0, /*tp_hash*/
15817   0, /*tp_call*/
15818   0, /*tp_str*/
15819   0, /*tp_getattro*/
15820   0, /*tp_setattro*/
15821   0, /*tp_as_buffer*/
15822   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
15823   "\n    Builds an OGR geometry from GeoJSON geometry.\n    From Fiona: https://github.com/Toblerity/Fiona/blob/master/src/fiona/ogrext.pyx\n    ", /*tp_doc*/
15824   0, /*tp_traverse*/
15825   0, /*tp_clear*/
15826   0, /*tp_richcompare*/
15827   0, /*tp_weaklistoffset*/
15828   0, /*tp_iter*/
15829   0, /*tp_iternext*/
15830   __pyx_methods_8rasterio_9_features_OGRGeomBuilder, /*tp_methods*/
15831   0, /*tp_members*/
15832   0, /*tp_getset*/
15833   0, /*tp_base*/
15834   0, /*tp_dict*/
15835   0, /*tp_descr_get*/
15836   0, /*tp_descr_set*/
15837   0, /*tp_dictoffset*/
15838   0, /*tp_init*/
15839   0, /*tp_alloc*/
15840   __pyx_tp_new_8rasterio_9_features_OGRGeomBuilder, /*tp_new*/
15841   0, /*tp_free*/
15842   0, /*tp_is_gc*/
15843   0, /*tp_bases*/
15844   0, /*tp_mro*/
15845   0, /*tp_cache*/
15846   0, /*tp_subclasses*/
15847   0, /*tp_weaklist*/
15848   0, /*tp_del*/
15849   0, /*tp_version_tag*/
15850   #if PY_VERSION_HEX >= 0x030400a1
15851   0, /*tp_finalize*/
15852   #endif
15853   #if PY_VERSION_HEX >= 0x030800b1
15854   0, /*tp_vectorcall*/
15855   #endif
15856   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
15857   0, /*tp_print*/
15858   #endif
15859 };
15860 
__pyx_tp_new_8rasterio_9_features_ShapeIterator(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)15861 static PyObject *__pyx_tp_new_8rasterio_9_features_ShapeIterator(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
15862   PyObject *o;
15863   if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
15864     o = (*t->tp_alloc)(t, 0);
15865   } else {
15866     o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
15867   }
15868   if (unlikely(!o)) return 0;
15869   return o;
15870 }
15871 
__pyx_tp_dealloc_8rasterio_9_features_ShapeIterator(PyObject * o)15872 static void __pyx_tp_dealloc_8rasterio_9_features_ShapeIterator(PyObject *o) {
15873   #if CYTHON_USE_TP_FINALIZE
15874   if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
15875     if (PyObject_CallFinalizerFromDealloc(o)) return;
15876   }
15877   #endif
15878   (*Py_TYPE(o)->tp_free)(o);
15879 }
15880 
__pyx_specialmethod___pyx_pw_8rasterio_9_features_13ShapeIterator_3__next__(PyObject * self,CYTHON_UNUSED PyObject * arg)15881 static PyObject *__pyx_specialmethod___pyx_pw_8rasterio_9_features_13ShapeIterator_3__next__(PyObject *self, CYTHON_UNUSED PyObject *arg) {return __pyx_pw_8rasterio_9_features_13ShapeIterator_3__next__(self);}
15882 
15883 static PyMethodDef __pyx_methods_8rasterio_9_features_ShapeIterator[] = {
15884   {"__next__", (PyCFunction)__pyx_specialmethod___pyx_pw_8rasterio_9_features_13ShapeIterator_3__next__, METH_NOARGS|METH_COEXIST, 0},
15885   {"__reduce_cython__", (PyCFunction)__pyx_pw_8rasterio_9_features_13ShapeIterator_5__reduce_cython__, METH_NOARGS, 0},
15886   {"__setstate_cython__", (PyCFunction)__pyx_pw_8rasterio_9_features_13ShapeIterator_7__setstate_cython__, METH_O, 0},
15887   {0, 0, 0, 0}
15888 };
15889 
15890 static PyTypeObject __pyx_type_8rasterio_9_features_ShapeIterator = {
15891   PyVarObject_HEAD_INIT(0, 0)
15892   "rasterio._features.ShapeIterator", /*tp_name*/
15893   sizeof(struct __pyx_obj_8rasterio_9_features_ShapeIterator), /*tp_basicsize*/
15894   0, /*tp_itemsize*/
15895   __pyx_tp_dealloc_8rasterio_9_features_ShapeIterator, /*tp_dealloc*/
15896   #if PY_VERSION_HEX < 0x030800b4
15897   0, /*tp_print*/
15898   #endif
15899   #if PY_VERSION_HEX >= 0x030800b4
15900   0, /*tp_vectorcall_offset*/
15901   #endif
15902   0, /*tp_getattr*/
15903   0, /*tp_setattr*/
15904   #if PY_MAJOR_VERSION < 3
15905   0, /*tp_compare*/
15906   #endif
15907   #if PY_MAJOR_VERSION >= 3
15908   0, /*tp_as_async*/
15909   #endif
15910   0, /*tp_repr*/
15911   0, /*tp_as_number*/
15912   0, /*tp_as_sequence*/
15913   0, /*tp_as_mapping*/
15914   0, /*tp_hash*/
15915   0, /*tp_call*/
15916   0, /*tp_str*/
15917   0, /*tp_getattro*/
15918   0, /*tp_setattro*/
15919   0, /*tp_as_buffer*/
15920   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
15921   "Provides an iterator over shapes in an OGR feature layer.", /*tp_doc*/
15922   0, /*tp_traverse*/
15923   0, /*tp_clear*/
15924   0, /*tp_richcompare*/
15925   0, /*tp_weaklistoffset*/
15926   __pyx_pw_8rasterio_9_features_13ShapeIterator_1__iter__, /*tp_iter*/
15927   __pyx_pw_8rasterio_9_features_13ShapeIterator_3__next__, /*tp_iternext*/
15928   __pyx_methods_8rasterio_9_features_ShapeIterator, /*tp_methods*/
15929   0, /*tp_members*/
15930   0, /*tp_getset*/
15931   0, /*tp_base*/
15932   0, /*tp_dict*/
15933   0, /*tp_descr_get*/
15934   0, /*tp_descr_set*/
15935   0, /*tp_dictoffset*/
15936   0, /*tp_init*/
15937   0, /*tp_alloc*/
15938   __pyx_tp_new_8rasterio_9_features_ShapeIterator, /*tp_new*/
15939   0, /*tp_free*/
15940   0, /*tp_is_gc*/
15941   0, /*tp_bases*/
15942   0, /*tp_mro*/
15943   0, /*tp_cache*/
15944   0, /*tp_subclasses*/
15945   0, /*tp_weaklist*/
15946   0, /*tp_del*/
15947   0, /*tp_version_tag*/
15948   #if PY_VERSION_HEX >= 0x030400a1
15949   0, /*tp_finalize*/
15950   #endif
15951   #if PY_VERSION_HEX >= 0x030800b1
15952   0, /*tp_vectorcall*/
15953   #endif
15954   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
15955   0, /*tp_print*/
15956   #endif
15957 };
15958 
15959 static struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes *__pyx_freelist_8rasterio_9_features___pyx_scope_struct___shapes[8];
15960 static int __pyx_freecount_8rasterio_9_features___pyx_scope_struct___shapes = 0;
15961 
__pyx_tp_new_8rasterio_9_features___pyx_scope_struct___shapes(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)15962 static PyObject *__pyx_tp_new_8rasterio_9_features___pyx_scope_struct___shapes(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
15963   PyObject *o;
15964   if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_8rasterio_9_features___pyx_scope_struct___shapes > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes)))) {
15965     o = (PyObject*)__pyx_freelist_8rasterio_9_features___pyx_scope_struct___shapes[--__pyx_freecount_8rasterio_9_features___pyx_scope_struct___shapes];
15966     memset(o, 0, sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes));
15967     (void) PyObject_INIT(o, t);
15968     PyObject_GC_Track(o);
15969   } else {
15970     o = (*t->tp_alloc)(t, 0);
15971     if (unlikely(!o)) return 0;
15972   }
15973   return o;
15974 }
15975 
__pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct___shapes(PyObject * o)15976 static void __pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct___shapes(PyObject *o) {
15977   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes *p = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes *)o;
15978   PyObject_GC_UnTrack(o);
15979   Py_CLEAR(p->__pyx_v_connectivity);
15980   Py_CLEAR(p->__pyx_v_image);
15981   Py_CLEAR(p->__pyx_v_is_float);
15982   Py_CLEAR(p->__pyx_v_mask);
15983   Py_CLEAR(p->__pyx_v_mask_ds);
15984   Py_CLEAR(p->__pyx_v_mem_ds);
15985   Py_CLEAR(p->__pyx_v_mrdr);
15986   Py_CLEAR(p->__pyx_v_rdr);
15987   Py_CLEAR(p->__pyx_v_s);
15988   Py_CLEAR(p->__pyx_v_shape_iter);
15989   Py_CLEAR(p->__pyx_v_transform);
15990   Py_CLEAR(p->__pyx_v_v);
15991   Py_CLEAR(p->__pyx_v_valid_dtypes);
15992   Py_CLEAR(p->__pyx_t_0);
15993   if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_8rasterio_9_features___pyx_scope_struct___shapes < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes)))) {
15994     __pyx_freelist_8rasterio_9_features___pyx_scope_struct___shapes[__pyx_freecount_8rasterio_9_features___pyx_scope_struct___shapes++] = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes *)o);
15995   } else {
15996     (*Py_TYPE(o)->tp_free)(o);
15997   }
15998 }
15999 
__pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct___shapes(PyObject * o,visitproc v,void * a)16000 static int __pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct___shapes(PyObject *o, visitproc v, void *a) {
16001   int e;
16002   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes *p = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes *)o;
16003   if (p->__pyx_v_connectivity) {
16004     e = (*v)(p->__pyx_v_connectivity, a); if (e) return e;
16005   }
16006   if (p->__pyx_v_image) {
16007     e = (*v)(p->__pyx_v_image, a); if (e) return e;
16008   }
16009   if (p->__pyx_v_is_float) {
16010     e = (*v)(p->__pyx_v_is_float, a); if (e) return e;
16011   }
16012   if (p->__pyx_v_mask) {
16013     e = (*v)(p->__pyx_v_mask, a); if (e) return e;
16014   }
16015   if (p->__pyx_v_mask_ds) {
16016     e = (*v)(((PyObject *)p->__pyx_v_mask_ds), a); if (e) return e;
16017   }
16018   if (p->__pyx_v_mem_ds) {
16019     e = (*v)(((PyObject *)p->__pyx_v_mem_ds), a); if (e) return e;
16020   }
16021   if (p->__pyx_v_mrdr) {
16022     e = (*v)(p->__pyx_v_mrdr, a); if (e) return e;
16023   }
16024   if (p->__pyx_v_rdr) {
16025     e = (*v)(p->__pyx_v_rdr, a); if (e) return e;
16026   }
16027   if (p->__pyx_v_s) {
16028     e = (*v)(p->__pyx_v_s, a); if (e) return e;
16029   }
16030   if (p->__pyx_v_shape_iter) {
16031     e = (*v)(((PyObject *)p->__pyx_v_shape_iter), a); if (e) return e;
16032   }
16033   if (p->__pyx_v_transform) {
16034     e = (*v)(p->__pyx_v_transform, a); if (e) return e;
16035   }
16036   if (p->__pyx_v_v) {
16037     e = (*v)(p->__pyx_v_v, a); if (e) return e;
16038   }
16039   if (p->__pyx_v_valid_dtypes) {
16040     e = (*v)(p->__pyx_v_valid_dtypes, a); if (e) return e;
16041   }
16042   if (p->__pyx_t_0) {
16043     e = (*v)(p->__pyx_t_0, a); if (e) return e;
16044   }
16045   return 0;
16046 }
16047 
16048 static PyTypeObject __pyx_type_8rasterio_9_features___pyx_scope_struct___shapes = {
16049   PyVarObject_HEAD_INIT(0, 0)
16050   "rasterio._features.__pyx_scope_struct___shapes", /*tp_name*/
16051   sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct___shapes), /*tp_basicsize*/
16052   0, /*tp_itemsize*/
16053   __pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct___shapes, /*tp_dealloc*/
16054   #if PY_VERSION_HEX < 0x030800b4
16055   0, /*tp_print*/
16056   #endif
16057   #if PY_VERSION_HEX >= 0x030800b4
16058   0, /*tp_vectorcall_offset*/
16059   #endif
16060   0, /*tp_getattr*/
16061   0, /*tp_setattr*/
16062   #if PY_MAJOR_VERSION < 3
16063   0, /*tp_compare*/
16064   #endif
16065   #if PY_MAJOR_VERSION >= 3
16066   0, /*tp_as_async*/
16067   #endif
16068   0, /*tp_repr*/
16069   0, /*tp_as_number*/
16070   0, /*tp_as_sequence*/
16071   0, /*tp_as_mapping*/
16072   0, /*tp_hash*/
16073   0, /*tp_call*/
16074   0, /*tp_str*/
16075   0, /*tp_getattro*/
16076   0, /*tp_setattro*/
16077   0, /*tp_as_buffer*/
16078   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
16079   0, /*tp_doc*/
16080   __pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct___shapes, /*tp_traverse*/
16081   0, /*tp_clear*/
16082   0, /*tp_richcompare*/
16083   0, /*tp_weaklistoffset*/
16084   0, /*tp_iter*/
16085   0, /*tp_iternext*/
16086   0, /*tp_methods*/
16087   0, /*tp_members*/
16088   0, /*tp_getset*/
16089   0, /*tp_base*/
16090   0, /*tp_dict*/
16091   0, /*tp_descr_get*/
16092   0, /*tp_descr_set*/
16093   0, /*tp_dictoffset*/
16094   0, /*tp_init*/
16095   0, /*tp_alloc*/
16096   __pyx_tp_new_8rasterio_9_features___pyx_scope_struct___shapes, /*tp_new*/
16097   0, /*tp_free*/
16098   0, /*tp_is_gc*/
16099   0, /*tp_bases*/
16100   0, /*tp_mro*/
16101   0, /*tp_cache*/
16102   0, /*tp_subclasses*/
16103   0, /*tp_weaklist*/
16104   0, /*tp_del*/
16105   0, /*tp_version_tag*/
16106   #if PY_VERSION_HEX >= 0x030400a1
16107   0, /*tp_finalize*/
16108   #endif
16109   #if PY_VERSION_HEX >= 0x030800b1
16110   0, /*tp_vectorcall*/
16111   #endif
16112   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
16113   0, /*tp_print*/
16114   #endif
16115 };
16116 
16117 static struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve *__pyx_freelist_8rasterio_9_features___pyx_scope_struct_1__sieve[8];
16118 static int __pyx_freecount_8rasterio_9_features___pyx_scope_struct_1__sieve = 0;
16119 
__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_1__sieve(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)16120 static PyObject *__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_1__sieve(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
16121   PyObject *o;
16122   if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_8rasterio_9_features___pyx_scope_struct_1__sieve > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve)))) {
16123     o = (PyObject*)__pyx_freelist_8rasterio_9_features___pyx_scope_struct_1__sieve[--__pyx_freecount_8rasterio_9_features___pyx_scope_struct_1__sieve];
16124     memset(o, 0, sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve));
16125     (void) PyObject_INIT(o, t);
16126     PyObject_GC_Track(o);
16127   } else {
16128     o = (*t->tp_alloc)(t, 0);
16129     if (unlikely(!o)) return 0;
16130   }
16131   return o;
16132 }
16133 
__pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct_1__sieve(PyObject * o)16134 static void __pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct_1__sieve(PyObject *o) {
16135   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve *p = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve *)o;
16136   PyObject_GC_UnTrack(o);
16137   Py_CLEAR(p->__pyx_v_valid_dtypes);
16138   if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_8rasterio_9_features___pyx_scope_struct_1__sieve < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve)))) {
16139     __pyx_freelist_8rasterio_9_features___pyx_scope_struct_1__sieve[__pyx_freecount_8rasterio_9_features___pyx_scope_struct_1__sieve++] = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve *)o);
16140   } else {
16141     (*Py_TYPE(o)->tp_free)(o);
16142   }
16143 }
16144 
__pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct_1__sieve(PyObject * o,visitproc v,void * a)16145 static int __pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct_1__sieve(PyObject *o, visitproc v, void *a) {
16146   int e;
16147   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve *p = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve *)o;
16148   if (p->__pyx_v_valid_dtypes) {
16149     e = (*v)(p->__pyx_v_valid_dtypes, a); if (e) return e;
16150   }
16151   return 0;
16152 }
16153 
__pyx_tp_clear_8rasterio_9_features___pyx_scope_struct_1__sieve(PyObject * o)16154 static int __pyx_tp_clear_8rasterio_9_features___pyx_scope_struct_1__sieve(PyObject *o) {
16155   PyObject* tmp;
16156   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve *p = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve *)o;
16157   tmp = ((PyObject*)p->__pyx_v_valid_dtypes);
16158   p->__pyx_v_valid_dtypes = ((PyObject*)Py_None); Py_INCREF(Py_None);
16159   Py_XDECREF(tmp);
16160   return 0;
16161 }
16162 
16163 static PyTypeObject __pyx_type_8rasterio_9_features___pyx_scope_struct_1__sieve = {
16164   PyVarObject_HEAD_INIT(0, 0)
16165   "rasterio._features.__pyx_scope_struct_1__sieve", /*tp_name*/
16166   sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_1__sieve), /*tp_basicsize*/
16167   0, /*tp_itemsize*/
16168   __pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct_1__sieve, /*tp_dealloc*/
16169   #if PY_VERSION_HEX < 0x030800b4
16170   0, /*tp_print*/
16171   #endif
16172   #if PY_VERSION_HEX >= 0x030800b4
16173   0, /*tp_vectorcall_offset*/
16174   #endif
16175   0, /*tp_getattr*/
16176   0, /*tp_setattr*/
16177   #if PY_MAJOR_VERSION < 3
16178   0, /*tp_compare*/
16179   #endif
16180   #if PY_MAJOR_VERSION >= 3
16181   0, /*tp_as_async*/
16182   #endif
16183   0, /*tp_repr*/
16184   0, /*tp_as_number*/
16185   0, /*tp_as_sequence*/
16186   0, /*tp_as_mapping*/
16187   0, /*tp_hash*/
16188   0, /*tp_call*/
16189   0, /*tp_str*/
16190   0, /*tp_getattro*/
16191   0, /*tp_setattro*/
16192   0, /*tp_as_buffer*/
16193   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
16194   0, /*tp_doc*/
16195   __pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct_1__sieve, /*tp_traverse*/
16196   __pyx_tp_clear_8rasterio_9_features___pyx_scope_struct_1__sieve, /*tp_clear*/
16197   0, /*tp_richcompare*/
16198   0, /*tp_weaklistoffset*/
16199   0, /*tp_iter*/
16200   0, /*tp_iternext*/
16201   0, /*tp_methods*/
16202   0, /*tp_members*/
16203   0, /*tp_getset*/
16204   0, /*tp_base*/
16205   0, /*tp_dict*/
16206   0, /*tp_descr_get*/
16207   0, /*tp_descr_set*/
16208   0, /*tp_dictoffset*/
16209   0, /*tp_init*/
16210   0, /*tp_alloc*/
16211   __pyx_tp_new_8rasterio_9_features___pyx_scope_struct_1__sieve, /*tp_new*/
16212   0, /*tp_free*/
16213   0, /*tp_is_gc*/
16214   0, /*tp_bases*/
16215   0, /*tp_mro*/
16216   0, /*tp_cache*/
16217   0, /*tp_subclasses*/
16218   0, /*tp_weaklist*/
16219   0, /*tp_del*/
16220   0, /*tp_version_tag*/
16221   #if PY_VERSION_HEX >= 0x030400a1
16222   0, /*tp_finalize*/
16223   #endif
16224   #if PY_VERSION_HEX >= 0x030800b1
16225   0, /*tp_vectorcall*/
16226   #endif
16227   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
16228   0, /*tp_print*/
16229   #endif
16230 };
16231 
16232 static struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr *__pyx_freelist_8rasterio_9_features___pyx_scope_struct_2_genexpr[8];
16233 static int __pyx_freecount_8rasterio_9_features___pyx_scope_struct_2_genexpr = 0;
16234 
__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_2_genexpr(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)16235 static PyObject *__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_2_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
16236   PyObject *o;
16237   if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_8rasterio_9_features___pyx_scope_struct_2_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr)))) {
16238     o = (PyObject*)__pyx_freelist_8rasterio_9_features___pyx_scope_struct_2_genexpr[--__pyx_freecount_8rasterio_9_features___pyx_scope_struct_2_genexpr];
16239     memset(o, 0, sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr));
16240     (void) PyObject_INIT(o, t);
16241     PyObject_GC_Track(o);
16242   } else {
16243     o = (*t->tp_alloc)(t, 0);
16244     if (unlikely(!o)) return 0;
16245   }
16246   return o;
16247 }
16248 
__pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct_2_genexpr(PyObject * o)16249 static void __pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct_2_genexpr(PyObject *o) {
16250   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr *p = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr *)o;
16251   PyObject_GC_UnTrack(o);
16252   Py_CLEAR(p->__pyx_outer_scope);
16253   Py_CLEAR(p->__pyx_v_t);
16254   if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_8rasterio_9_features___pyx_scope_struct_2_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr)))) {
16255     __pyx_freelist_8rasterio_9_features___pyx_scope_struct_2_genexpr[__pyx_freecount_8rasterio_9_features___pyx_scope_struct_2_genexpr++] = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr *)o);
16256   } else {
16257     (*Py_TYPE(o)->tp_free)(o);
16258   }
16259 }
16260 
__pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct_2_genexpr(PyObject * o,visitproc v,void * a)16261 static int __pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct_2_genexpr(PyObject *o, visitproc v, void *a) {
16262   int e;
16263   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr *p = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr *)o;
16264   if (p->__pyx_outer_scope) {
16265     e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
16266   }
16267   if (p->__pyx_v_t) {
16268     e = (*v)(p->__pyx_v_t, a); if (e) return e;
16269   }
16270   return 0;
16271 }
16272 
16273 static PyTypeObject __pyx_type_8rasterio_9_features___pyx_scope_struct_2_genexpr = {
16274   PyVarObject_HEAD_INIT(0, 0)
16275   "rasterio._features.__pyx_scope_struct_2_genexpr", /*tp_name*/
16276   sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_2_genexpr), /*tp_basicsize*/
16277   0, /*tp_itemsize*/
16278   __pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct_2_genexpr, /*tp_dealloc*/
16279   #if PY_VERSION_HEX < 0x030800b4
16280   0, /*tp_print*/
16281   #endif
16282   #if PY_VERSION_HEX >= 0x030800b4
16283   0, /*tp_vectorcall_offset*/
16284   #endif
16285   0, /*tp_getattr*/
16286   0, /*tp_setattr*/
16287   #if PY_MAJOR_VERSION < 3
16288   0, /*tp_compare*/
16289   #endif
16290   #if PY_MAJOR_VERSION >= 3
16291   0, /*tp_as_async*/
16292   #endif
16293   0, /*tp_repr*/
16294   0, /*tp_as_number*/
16295   0, /*tp_as_sequence*/
16296   0, /*tp_as_mapping*/
16297   0, /*tp_hash*/
16298   0, /*tp_call*/
16299   0, /*tp_str*/
16300   0, /*tp_getattro*/
16301   0, /*tp_setattro*/
16302   0, /*tp_as_buffer*/
16303   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
16304   0, /*tp_doc*/
16305   __pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct_2_genexpr, /*tp_traverse*/
16306   0, /*tp_clear*/
16307   0, /*tp_richcompare*/
16308   0, /*tp_weaklistoffset*/
16309   0, /*tp_iter*/
16310   0, /*tp_iternext*/
16311   0, /*tp_methods*/
16312   0, /*tp_members*/
16313   0, /*tp_getset*/
16314   0, /*tp_base*/
16315   0, /*tp_dict*/
16316   0, /*tp_descr_get*/
16317   0, /*tp_descr_set*/
16318   0, /*tp_dictoffset*/
16319   0, /*tp_init*/
16320   0, /*tp_alloc*/
16321   __pyx_tp_new_8rasterio_9_features___pyx_scope_struct_2_genexpr, /*tp_new*/
16322   0, /*tp_free*/
16323   0, /*tp_is_gc*/
16324   0, /*tp_bases*/
16325   0, /*tp_mro*/
16326   0, /*tp_cache*/
16327   0, /*tp_subclasses*/
16328   0, /*tp_weaklist*/
16329   0, /*tp_del*/
16330   0, /*tp_version_tag*/
16331   #if PY_VERSION_HEX >= 0x030400a1
16332   0, /*tp_finalize*/
16333   #endif
16334   #if PY_VERSION_HEX >= 0x030800b1
16335   0, /*tp_vectorcall*/
16336   #endif
16337   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
16338   0, /*tp_print*/
16339   #endif
16340 };
16341 
16342 static struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode *__pyx_freelist_8rasterio_9_features___pyx_scope_struct_3__explode[8];
16343 static int __pyx_freecount_8rasterio_9_features___pyx_scope_struct_3__explode = 0;
16344 
__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_3__explode(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)16345 static PyObject *__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_3__explode(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
16346   PyObject *o;
16347   if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_8rasterio_9_features___pyx_scope_struct_3__explode > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode)))) {
16348     o = (PyObject*)__pyx_freelist_8rasterio_9_features___pyx_scope_struct_3__explode[--__pyx_freecount_8rasterio_9_features___pyx_scope_struct_3__explode];
16349     memset(o, 0, sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode));
16350     (void) PyObject_INIT(o, t);
16351     PyObject_GC_Track(o);
16352   } else {
16353     o = (*t->tp_alloc)(t, 0);
16354     if (unlikely(!o)) return 0;
16355   }
16356   return o;
16357 }
16358 
__pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct_3__explode(PyObject * o)16359 static void __pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct_3__explode(PyObject *o) {
16360   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode *p = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode *)o;
16361   PyObject_GC_UnTrack(o);
16362   Py_CLEAR(p->__pyx_v_coords);
16363   Py_CLEAR(p->__pyx_v_e);
16364   Py_CLEAR(p->__pyx_v_f);
16365   Py_CLEAR(p->__pyx_t_0);
16366   Py_CLEAR(p->__pyx_t_3);
16367   if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_8rasterio_9_features___pyx_scope_struct_3__explode < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode)))) {
16368     __pyx_freelist_8rasterio_9_features___pyx_scope_struct_3__explode[__pyx_freecount_8rasterio_9_features___pyx_scope_struct_3__explode++] = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode *)o);
16369   } else {
16370     (*Py_TYPE(o)->tp_free)(o);
16371   }
16372 }
16373 
__pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct_3__explode(PyObject * o,visitproc v,void * a)16374 static int __pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct_3__explode(PyObject *o, visitproc v, void *a) {
16375   int e;
16376   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode *p = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode *)o;
16377   if (p->__pyx_v_coords) {
16378     e = (*v)(p->__pyx_v_coords, a); if (e) return e;
16379   }
16380   if (p->__pyx_v_e) {
16381     e = (*v)(p->__pyx_v_e, a); if (e) return e;
16382   }
16383   if (p->__pyx_v_f) {
16384     e = (*v)(p->__pyx_v_f, a); if (e) return e;
16385   }
16386   if (p->__pyx_t_0) {
16387     e = (*v)(p->__pyx_t_0, a); if (e) return e;
16388   }
16389   if (p->__pyx_t_3) {
16390     e = (*v)(p->__pyx_t_3, a); if (e) return e;
16391   }
16392   return 0;
16393 }
16394 
16395 static PyTypeObject __pyx_type_8rasterio_9_features___pyx_scope_struct_3__explode = {
16396   PyVarObject_HEAD_INIT(0, 0)
16397   "rasterio._features.__pyx_scope_struct_3__explode", /*tp_name*/
16398   sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_3__explode), /*tp_basicsize*/
16399   0, /*tp_itemsize*/
16400   __pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct_3__explode, /*tp_dealloc*/
16401   #if PY_VERSION_HEX < 0x030800b4
16402   0, /*tp_print*/
16403   #endif
16404   #if PY_VERSION_HEX >= 0x030800b4
16405   0, /*tp_vectorcall_offset*/
16406   #endif
16407   0, /*tp_getattr*/
16408   0, /*tp_setattr*/
16409   #if PY_MAJOR_VERSION < 3
16410   0, /*tp_compare*/
16411   #endif
16412   #if PY_MAJOR_VERSION >= 3
16413   0, /*tp_as_async*/
16414   #endif
16415   0, /*tp_repr*/
16416   0, /*tp_as_number*/
16417   0, /*tp_as_sequence*/
16418   0, /*tp_as_mapping*/
16419   0, /*tp_hash*/
16420   0, /*tp_call*/
16421   0, /*tp_str*/
16422   0, /*tp_getattro*/
16423   0, /*tp_setattro*/
16424   0, /*tp_as_buffer*/
16425   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
16426   0, /*tp_doc*/
16427   __pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct_3__explode, /*tp_traverse*/
16428   0, /*tp_clear*/
16429   0, /*tp_richcompare*/
16430   0, /*tp_weaklistoffset*/
16431   0, /*tp_iter*/
16432   0, /*tp_iternext*/
16433   0, /*tp_methods*/
16434   0, /*tp_members*/
16435   0, /*tp_getset*/
16436   0, /*tp_base*/
16437   0, /*tp_dict*/
16438   0, /*tp_descr_get*/
16439   0, /*tp_descr_set*/
16440   0, /*tp_dictoffset*/
16441   0, /*tp_init*/
16442   0, /*tp_alloc*/
16443   __pyx_tp_new_8rasterio_9_features___pyx_scope_struct_3__explode, /*tp_new*/
16444   0, /*tp_free*/
16445   0, /*tp_is_gc*/
16446   0, /*tp_bases*/
16447   0, /*tp_mro*/
16448   0, /*tp_cache*/
16449   0, /*tp_subclasses*/
16450   0, /*tp_weaklist*/
16451   0, /*tp_del*/
16452   0, /*tp_version_tag*/
16453   #if PY_VERSION_HEX >= 0x030400a1
16454   0, /*tp_finalize*/
16455   #endif
16456   #if PY_VERSION_HEX >= 0x030800b1
16457   0, /*tp_vectorcall*/
16458   #endif
16459   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
16460   0, /*tp_print*/
16461   #endif
16462 };
16463 
16464 static struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr *__pyx_freelist_8rasterio_9_features___pyx_scope_struct_4_genexpr[8];
16465 static int __pyx_freecount_8rasterio_9_features___pyx_scope_struct_4_genexpr = 0;
16466 
__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_4_genexpr(PyTypeObject * t,CYTHON_UNUSED PyObject * a,CYTHON_UNUSED PyObject * k)16467 static PyObject *__pyx_tp_new_8rasterio_9_features___pyx_scope_struct_4_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
16468   PyObject *o;
16469   if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_8rasterio_9_features___pyx_scope_struct_4_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr)))) {
16470     o = (PyObject*)__pyx_freelist_8rasterio_9_features___pyx_scope_struct_4_genexpr[--__pyx_freecount_8rasterio_9_features___pyx_scope_struct_4_genexpr];
16471     memset(o, 0, sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr));
16472     (void) PyObject_INIT(o, t);
16473     PyObject_GC_Track(o);
16474   } else {
16475     o = (*t->tp_alloc)(t, 0);
16476     if (unlikely(!o)) return 0;
16477   }
16478   return o;
16479 }
16480 
__pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct_4_genexpr(PyObject * o)16481 static void __pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct_4_genexpr(PyObject *o) {
16482   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr *p = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr *)o;
16483   PyObject_GC_UnTrack(o);
16484   Py_CLEAR(p->__pyx_v_k);
16485   Py_CLEAR(p->__pyx_v_v);
16486   if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_8rasterio_9_features___pyx_scope_struct_4_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr)))) {
16487     __pyx_freelist_8rasterio_9_features___pyx_scope_struct_4_genexpr[__pyx_freecount_8rasterio_9_features___pyx_scope_struct_4_genexpr++] = ((struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr *)o);
16488   } else {
16489     (*Py_TYPE(o)->tp_free)(o);
16490   }
16491 }
16492 
__pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct_4_genexpr(PyObject * o,visitproc v,void * a)16493 static int __pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct_4_genexpr(PyObject *o, visitproc v, void *a) {
16494   int e;
16495   struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr *p = (struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr *)o;
16496   if (p->__pyx_v_k) {
16497     e = (*v)(p->__pyx_v_k, a); if (e) return e;
16498   }
16499   if (p->__pyx_v_v) {
16500     e = (*v)(p->__pyx_v_v, a); if (e) return e;
16501   }
16502   return 0;
16503 }
16504 
16505 static PyTypeObject __pyx_type_8rasterio_9_features___pyx_scope_struct_4_genexpr = {
16506   PyVarObject_HEAD_INIT(0, 0)
16507   "rasterio._features.__pyx_scope_struct_4_genexpr", /*tp_name*/
16508   sizeof(struct __pyx_obj_8rasterio_9_features___pyx_scope_struct_4_genexpr), /*tp_basicsize*/
16509   0, /*tp_itemsize*/
16510   __pyx_tp_dealloc_8rasterio_9_features___pyx_scope_struct_4_genexpr, /*tp_dealloc*/
16511   #if PY_VERSION_HEX < 0x030800b4
16512   0, /*tp_print*/
16513   #endif
16514   #if PY_VERSION_HEX >= 0x030800b4
16515   0, /*tp_vectorcall_offset*/
16516   #endif
16517   0, /*tp_getattr*/
16518   0, /*tp_setattr*/
16519   #if PY_MAJOR_VERSION < 3
16520   0, /*tp_compare*/
16521   #endif
16522   #if PY_MAJOR_VERSION >= 3
16523   0, /*tp_as_async*/
16524   #endif
16525   0, /*tp_repr*/
16526   0, /*tp_as_number*/
16527   0, /*tp_as_sequence*/
16528   0, /*tp_as_mapping*/
16529   0, /*tp_hash*/
16530   0, /*tp_call*/
16531   0, /*tp_str*/
16532   0, /*tp_getattro*/
16533   0, /*tp_setattro*/
16534   0, /*tp_as_buffer*/
16535   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
16536   0, /*tp_doc*/
16537   __pyx_tp_traverse_8rasterio_9_features___pyx_scope_struct_4_genexpr, /*tp_traverse*/
16538   0, /*tp_clear*/
16539   0, /*tp_richcompare*/
16540   0, /*tp_weaklistoffset*/
16541   0, /*tp_iter*/
16542   0, /*tp_iternext*/
16543   0, /*tp_methods*/
16544   0, /*tp_members*/
16545   0, /*tp_getset*/
16546   0, /*tp_base*/
16547   0, /*tp_dict*/
16548   0, /*tp_descr_get*/
16549   0, /*tp_descr_set*/
16550   0, /*tp_dictoffset*/
16551   0, /*tp_init*/
16552   0, /*tp_alloc*/
16553   __pyx_tp_new_8rasterio_9_features___pyx_scope_struct_4_genexpr, /*tp_new*/
16554   0, /*tp_free*/
16555   0, /*tp_is_gc*/
16556   0, /*tp_bases*/
16557   0, /*tp_mro*/
16558   0, /*tp_cache*/
16559   0, /*tp_subclasses*/
16560   0, /*tp_weaklist*/
16561   0, /*tp_del*/
16562   0, /*tp_version_tag*/
16563   #if PY_VERSION_HEX >= 0x030400a1
16564   0, /*tp_finalize*/
16565   #endif
16566   #if PY_VERSION_HEX >= 0x030800b1
16567   0, /*tp_vectorcall*/
16568   #endif
16569   #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
16570   0, /*tp_print*/
16571   #endif
16572 };
16573 
16574 static PyMethodDef __pyx_methods[] = {
16575   {0, 0, 0, 0}
16576 };
16577 
16578 #if PY_MAJOR_VERSION >= 3
16579 #if CYTHON_PEP489_MULTI_PHASE_INIT
16580 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
16581 static int __pyx_pymod_exec__features(PyObject* module); /*proto*/
16582 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
16583   {Py_mod_create, (void*)__pyx_pymod_create},
16584   {Py_mod_exec, (void*)__pyx_pymod_exec__features},
16585   {0, NULL}
16586 };
16587 #endif
16588 
16589 static struct PyModuleDef __pyx_moduledef = {
16590     PyModuleDef_HEAD_INIT,
16591     "_features",
16592     __pyx_k_Feature_extraction, /* m_doc */
16593   #if CYTHON_PEP489_MULTI_PHASE_INIT
16594     0, /* m_size */
16595   #else
16596     -1, /* m_size */
16597   #endif
16598     __pyx_methods /* m_methods */,
16599   #if CYTHON_PEP489_MULTI_PHASE_INIT
16600     __pyx_moduledef_slots, /* m_slots */
16601   #else
16602     NULL, /* m_reload */
16603   #endif
16604     NULL, /* m_traverse */
16605     NULL, /* m_clear */
16606     NULL /* m_free */
16607 };
16608 #endif
16609 #ifndef CYTHON_SMALL_CODE
16610 #if defined(__clang__)
16611     #define CYTHON_SMALL_CODE
16612 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
16613     #define CYTHON_SMALL_CODE __attribute__((cold))
16614 #else
16615     #define CYTHON_SMALL_CODE
16616 #endif
16617 #endif
16618 
16619 static __Pyx_StringTabEntry __pyx_string_tab[] = {
16620   {&__pyx_kp_u_3D_GeometryCollection, __pyx_k_3D_GeometryCollection, sizeof(__pyx_k_3D_GeometryCollection), 0, 1, 0, 0},
16621   {&__pyx_kp_u_3D_LineString, __pyx_k_3D_LineString, sizeof(__pyx_k_3D_LineString), 0, 1, 0, 0},
16622   {&__pyx_kp_u_3D_MultiLineString, __pyx_k_3D_MultiLineString, sizeof(__pyx_k_3D_MultiLineString), 0, 1, 0, 0},
16623   {&__pyx_kp_u_3D_MultiPoint, __pyx_k_3D_MultiPoint, sizeof(__pyx_k_3D_MultiPoint), 0, 1, 0, 0},
16624   {&__pyx_kp_u_3D_MultiPolygon, __pyx_k_3D_MultiPolygon, sizeof(__pyx_k_3D_MultiPolygon), 0, 1, 0, 0},
16625   {&__pyx_kp_u_3D_Point, __pyx_k_3D_Point, sizeof(__pyx_k_3D_Point), 0, 1, 0, 0},
16626   {&__pyx_kp_u_3D_Polygon, __pyx_k_3D_Polygon, sizeof(__pyx_k_3D_Polygon), 0, 1, 0, 0},
16627   {&__pyx_kp_u_Connectivity_Option_must_be_4_or, __pyx_k_Connectivity_Option_must_be_4_or, sizeof(__pyx_k_Connectivity_Option_must_be_4_or), 0, 1, 0, 0},
16628   {&__pyx_kp_u_Could_not_create_OGR_Geometry_of, __pyx_k_Could_not_create_OGR_Geometry_of, sizeof(__pyx_k_Could_not_create_OGR_Geometry_of), 0, 1, 0, 0},
16629   {&__pyx_n_s_GEOJSON2OGR_GEOMETRY_TYPES, __pyx_k_GEOJSON2OGR_GEOMETRY_TYPES, sizeof(__pyx_k_GEOJSON2OGR_GEOMETRY_TYPES), 0, 0, 1, 1},
16630   {&__pyx_n_s_GEOMETRY_TYPES, __pyx_k_GEOMETRY_TYPES, sizeof(__pyx_k_GEOMETRY_TYPES), 0, 0, 1, 1},
16631   {&__pyx_n_s_GeomBuilder, __pyx_k_GeomBuilder, sizeof(__pyx_k_GeomBuilder), 0, 0, 1, 1},
16632   {&__pyx_n_u_GeometryCollection, __pyx_k_GeometryCollection, sizeof(__pyx_k_GeometryCollection), 0, 1, 0, 1},
16633   {&__pyx_kp_u_Geometry_r_at_index_d_with_value, __pyx_k_Geometry_r_at_index_d_with_value, sizeof(__pyx_k_Geometry_r_at_index_d_with_value), 0, 1, 0, 0},
16634   {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
16635   {&__pyx_kp_s_Incompatible_checksums_s_vs_0xd4, __pyx_k_Incompatible_checksums_s_vs_0xd4, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xd4), 0, 0, 1, 0},
16636   {&__pyx_kp_u_Input_is_not_a_valid_geometry_ob, __pyx_k_Input_is_not_a_valid_geometry_ob, sizeof(__pyx_k_Input_is_not_a_valid_geometry_ob), 0, 1, 0, 0},
16637   {&__pyx_kp_u_Invalid_out_image, __pyx_k_Invalid_out_image, sizeof(__pyx_k_Invalid_out_image), 0, 1, 0, 0},
16638   {&__pyx_kp_u_Invalid_source_image, __pyx_k_Invalid_source_image, sizeof(__pyx_k_Invalid_source_image), 0, 1, 0, 0},
16639   {&__pyx_n_u_LineString, __pyx_k_LineString, sizeof(__pyx_k_LineString), 0, 1, 0, 1},
16640   {&__pyx_n_u_LinearRing, __pyx_k_LinearRing, sizeof(__pyx_k_LinearRing), 0, 1, 0, 1},
16641   {&__pyx_kp_u_Mask_must_be_dtype_rasterio_bool, __pyx_k_Mask_must_be_dtype_rasterio_bool, sizeof(__pyx_k_Mask_must_be_dtype_rasterio_bool), 0, 1, 0, 0},
16642   {&__pyx_kp_u_Mask_must_have_same_shape_as_ima, __pyx_k_Mask_must_have_same_shape_as_ima, sizeof(__pyx_k_Mask_must_have_same_shape_as_ima), 0, 1, 0, 0},
16643   {&__pyx_n_s_MergeAlg, __pyx_k_MergeAlg, sizeof(__pyx_k_MergeAlg), 0, 0, 1, 1},
16644   {&__pyx_n_u_MultiLineString, __pyx_k_MultiLineString, sizeof(__pyx_k_MultiLineString), 0, 1, 0, 1},
16645   {&__pyx_n_u_MultiPoint, __pyx_k_MultiPoint, sizeof(__pyx_k_MultiPoint), 0, 1, 0, 1},
16646   {&__pyx_n_u_MultiPolygon, __pyx_k_MultiPolygon, sizeof(__pyx_k_MultiPolygon), 0, 1, 0, 1},
16647   {&__pyx_kp_u_NULL_driver, __pyx_k_NULL_driver, sizeof(__pyx_k_NULL_driver), 0, 1, 0, 0},
16648   {&__pyx_kp_u_NULL_feature_dataset, __pyx_k_NULL_feature_dataset, sizeof(__pyx_k_NULL_feature_dataset), 0, 1, 0, 0},
16649   {&__pyx_kp_u_NULL_field_definition, __pyx_k_NULL_field_definition, sizeof(__pyx_k_NULL_field_definition), 0, 1, 0, 0},
16650   {&__pyx_kp_u_NULL_layer, __pyx_k_NULL_layer, sizeof(__pyx_k_NULL_layer), 0, 1, 0, 0},
16651   {&__pyx_n_u_None, __pyx_k_None, sizeof(__pyx_k_None), 0, 1, 0, 1},
16652   {&__pyx_kp_u_Null_geom, __pyx_k_Null_geom, sizeof(__pyx_k_Null_geom), 0, 1, 0, 0},
16653   {&__pyx_n_s_OGRGeomBuilder, __pyx_k_OGRGeomBuilder, sizeof(__pyx_k_OGRGeomBuilder), 0, 0, 1, 1},
16654   {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
16655   {&__pyx_n_u_Point, __pyx_k_Point, sizeof(__pyx_k_Point), 0, 1, 0, 1},
16656   {&__pyx_n_u_Polygon, __pyx_k_Polygon, sizeof(__pyx_k_Polygon), 0, 1, 0, 1},
16657   {&__pyx_n_s_ShapeIterator, __pyx_k_ShapeIterator, sizeof(__pyx_k_ShapeIterator), 0, 0, 1, 1},
16658   {&__pyx_n_s_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 0, 0, 1, 1},
16659   {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
16660   {&__pyx_n_u_Unknown, __pyx_k_Unknown, sizeof(__pyx_k_Unknown), 0, 1, 0, 1},
16661   {&__pyx_kp_u_Unsupported_geometry_type_s, __pyx_k_Unsupported_geometry_type_s, sizeof(__pyx_k_Unsupported_geometry_type_s), 0, 1, 0, 0},
16662   {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
16663   {&__pyx_kp_u__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 1, 0, 0},
16664   {&__pyx_n_s_all_shapes, __pyx_k_all_shapes, sizeof(__pyx_k_all_shapes), 0, 0, 1, 1},
16665   {&__pyx_n_s_all_touched, __pyx_k_all_touched, sizeof(__pyx_k_all_touched), 0, 0, 1, 1},
16666   {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
16667   {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1},
16668   {&__pyx_n_s_band, __pyx_k_band, sizeof(__pyx_k_band), 0, 0, 1, 1},
16669   {&__pyx_n_s_bidx, __pyx_k_bidx, sizeof(__pyx_k_bidx), 0, 0, 1, 1},
16670   {&__pyx_n_u_bool, __pyx_k_bool, sizeof(__pyx_k_bool), 0, 1, 0, 1},
16671   {&__pyx_n_s_bounds, __pyx_k_bounds, sizeof(__pyx_k_bounds), 0, 0, 1, 1},
16672   {&__pyx_n_u_build, __pyx_k_build, sizeof(__pyx_k_build), 0, 1, 0, 1},
16673   {&__pyx_n_s_buildLineString, __pyx_k_buildLineString, sizeof(__pyx_k_buildLineString), 0, 0, 1, 1},
16674   {&__pyx_n_s_buildLinearRing, __pyx_k_buildLinearRing, sizeof(__pyx_k_buildLinearRing), 0, 0, 1, 1},
16675   {&__pyx_n_s_buildMultiLineString, __pyx_k_buildMultiLineString, sizeof(__pyx_k_buildMultiLineString), 0, 0, 1, 1},
16676   {&__pyx_n_s_buildMultiPoint, __pyx_k_buildMultiPoint, sizeof(__pyx_k_buildMultiPoint), 0, 0, 1, 1},
16677   {&__pyx_n_s_buildMultiPolygon, __pyx_k_buildMultiPolygon, sizeof(__pyx_k_buildMultiPolygon), 0, 0, 1, 1},
16678   {&__pyx_n_s_buildPoint, __pyx_k_buildPoint, sizeof(__pyx_k_buildPoint), 0, 0, 1, 1},
16679   {&__pyx_n_s_buildPolygon, __pyx_k_buildPolygon, sizeof(__pyx_k_buildPolygon), 0, 0, 1, 1},
16680   {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
16681   {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
16682   {&__pyx_n_s_cols, __pyx_k_cols, sizeof(__pyx_k_cols), 0, 0, 1, 1},
16683   {&__pyx_n_s_connectivity, __pyx_k_connectivity, sizeof(__pyx_k_connectivity), 0, 0, 1, 1},
16684   {&__pyx_kp_u_connectivity_must_be_4_or_8, __pyx_k_connectivity_must_be_4_or_8, sizeof(__pyx_k_connectivity_must_be_4_or_8), 0, 1, 0, 0},
16685   {&__pyx_n_u_coordinates, __pyx_k_coordinates, sizeof(__pyx_k_coordinates), 0, 1, 0, 1},
16686   {&__pyx_n_s_coords, __pyx_k_coords, sizeof(__pyx_k_coords), 0, 0, 1, 1},
16687   {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
16688   {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
16689   {&__pyx_n_s_driver, __pyx_k_driver, sizeof(__pyx_k_driver), 0, 0, 1, 1},
16690   {&__pyx_n_s_ds, __pyx_k_ds, sizeof(__pyx_k_ds), 0, 0, 1, 1},
16691   {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
16692   {&__pyx_n_s_dtypes, __pyx_k_dtypes, sizeof(__pyx_k_dtypes), 0, 0, 1, 1},
16693   {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
16694   {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
16695   {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
16696   {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
16697   {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
16698   {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
16699   {&__pyx_n_s_explode, __pyx_k_explode, sizeof(__pyx_k_explode), 0, 0, 1, 1},
16700   {&__pyx_n_s_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 0, 1, 1},
16701   {&__pyx_n_u_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 1, 0, 1},
16702   {&__pyx_n_s_feature, __pyx_k_feature, sizeof(__pyx_k_feature), 0, 0, 1, 1},
16703   {&__pyx_n_u_features, __pyx_k_features, sizeof(__pyx_k_features), 0, 1, 0, 1},
16704   {&__pyx_n_s_fielddefn, __pyx_k_fielddefn, sizeof(__pyx_k_fielddefn), 0, 0, 1, 1},
16705   {&__pyx_n_s_fieldtp, __pyx_k_fieldtp, sizeof(__pyx_k_fieldtp), 0, 0, 1, 1},
16706   {&__pyx_n_u_float32, __pyx_k_float32, sizeof(__pyx_k_float32), 0, 1, 0, 1},
16707   {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
16708   {&__pyx_n_s_fs, __pyx_k_fs, sizeof(__pyx_k_fs), 0, 0, 1, 1},
16709   {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
16710   {&__pyx_n_u_geo_interface, __pyx_k_geo_interface, sizeof(__pyx_k_geo_interface), 0, 1, 0, 1},
16711   {&__pyx_n_u_geometries, __pyx_k_geometries, sizeof(__pyx_k_geometries), 0, 1, 0, 1},
16712   {&__pyx_n_s_geometry, __pyx_k_geometry, sizeof(__pyx_k_geometry), 0, 0, 1, 1},
16713   {&__pyx_n_u_geometry, __pyx_k_geometry, sizeof(__pyx_k_geometry), 0, 1, 0, 1},
16714   {&__pyx_kp_u_geometry_must_be_a_GeoJSON_like, __pyx_k_geometry_must_be_a_GeoJSON_like, sizeof(__pyx_k_geometry_must_be_a_GeoJSON_like), 0, 1, 0, 0},
16715   {&__pyx_n_s_geoms, __pyx_k_geoms, sizeof(__pyx_k_geoms), 0, 0, 1, 1},
16716   {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
16717   {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1},
16718   {&__pyx_n_s_getnpdtype, __pyx_k_getnpdtype, sizeof(__pyx_k_getnpdtype), 0, 0, 1, 1},
16719   {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
16720   {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
16721   {&__pyx_n_s_image, __pyx_k_image, sizeof(__pyx_k_image), 0, 0, 1, 1},
16722   {&__pyx_kp_u_image_dtype_must_be_one_of_0, __pyx_k_image_dtype_must_be_one_of_0, sizeof(__pyx_k_image_dtype_must_be_one_of_0), 0, 1, 0, 0},
16723   {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
16724   {&__pyx_n_s_in_band, __pyx_k_in_band, sizeof(__pyx_k_in_band), 0, 0, 1, 1},
16725   {&__pyx_n_s_in_mem_ds, __pyx_k_in_mem_ds, sizeof(__pyx_k_in_mem_ds), 0, 0, 1, 1},
16726   {&__pyx_n_u_int16, __pyx_k_int16, sizeof(__pyx_k_int16), 0, 1, 0, 1},
16727   {&__pyx_n_u_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 1, 0, 1},
16728   {&__pyx_n_s_is_float, __pyx_k_is_float, sizeof(__pyx_k_is_float), 0, 0, 1, 1},
16729   {&__pyx_n_s_is_ndarray, __pyx_k_is_ndarray, sizeof(__pyx_k_is_ndarray), 0, 0, 1, 1},
16730   {&__pyx_n_s_iteritems, __pyx_k_iteritems, sizeof(__pyx_k_iteritems), 0, 0, 1, 1},
16731   {&__pyx_n_s_kind, __pyx_k_kind, sizeof(__pyx_k_kind), 0, 0, 1, 1},
16732   {&__pyx_n_s_layer, __pyx_k_layer, sizeof(__pyx_k_layer), 0, 0, 1, 1},
16733   {&__pyx_n_s_log, __pyx_k_log, sizeof(__pyx_k_log), 0, 0, 1, 1},
16734   {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1},
16735   {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
16736   {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1},
16737   {&__pyx_n_s_mask_band, __pyx_k_mask_band, sizeof(__pyx_k_mask_band), 0, 0, 1, 1},
16738   {&__pyx_n_s_mask_ds, __pyx_k_mask_ds, sizeof(__pyx_k_mask_ds), 0, 0, 1, 1},
16739   {&__pyx_n_s_mask_mem_ds, __pyx_k_mask_mem_ds, sizeof(__pyx_k_mask_mem_ds), 0, 0, 1, 1},
16740   {&__pyx_n_s_mask_reader, __pyx_k_mask_reader, sizeof(__pyx_k_mask_reader), 0, 0, 1, 1},
16741   {&__pyx_n_s_maskband, __pyx_k_maskband, sizeof(__pyx_k_maskband), 0, 0, 1, 1},
16742   {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1},
16743   {&__pyx_n_s_mem, __pyx_k_mem, sizeof(__pyx_k_mem), 0, 0, 1, 1},
16744   {&__pyx_n_s_mem_ds, __pyx_k_mem_ds, sizeof(__pyx_k_mem_ds), 0, 0, 1, 1},
16745   {&__pyx_n_s_merge_alg, __pyx_k_merge_alg, sizeof(__pyx_k_merge_alg), 0, 0, 1, 1},
16746   {&__pyx_n_s_merge_algorithm, __pyx_k_merge_algorithm, sizeof(__pyx_k_merge_algorithm), 0, 0, 1, 1},
16747   {&__pyx_n_s_min, __pyx_k_min, sizeof(__pyx_k_min), 0, 0, 1, 1},
16748   {&__pyx_n_s_mrdr, __pyx_k_mrdr, sizeof(__pyx_k_mrdr), 0, 0, 1, 1},
16749   {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
16750   {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
16751   {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
16752   {&__pyx_n_s_north_up, __pyx_k_north_up, sizeof(__pyx_k_north_up), 0, 0, 1, 1},
16753   {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
16754   {&__pyx_n_s_num_geoms, __pyx_k_num_geoms, sizeof(__pyx_k_num_geoms), 0, 0, 1, 1},
16755   {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
16756   {&__pyx_kp_u_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 1, 0, 0},
16757   {&__pyx_kp_u_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 1, 0, 0},
16758   {&__pyx_n_s_options, __pyx_k_options, sizeof(__pyx_k_options), 0, 0, 1, 1},
16759   {&__pyx_n_s_out, __pyx_k_out, sizeof(__pyx_k_out), 0, 0, 1, 1},
16760   {&__pyx_kp_u_out_array_r, __pyx_k_out_array_r, sizeof(__pyx_k_out_array_r), 0, 1, 0, 0},
16761   {&__pyx_n_s_out_band, __pyx_k_out_band, sizeof(__pyx_k_out_band), 0, 0, 1, 1},
16762   {&__pyx_n_s_out_mem_ds, __pyx_k_out_mem_ds, sizeof(__pyx_k_out_mem_ds), 0, 0, 1, 1},
16763   {&__pyx_kp_u_out_raster_must_match_dtype_of_i, __pyx_k_out_raster_must_match_dtype_of_i, sizeof(__pyx_k_out_raster_must_match_dtype_of_i), 0, 1, 0, 0},
16764   {&__pyx_kp_u_out_raster_shape_must_be_same_as, __pyx_k_out_raster_shape_must_be_same_as, sizeof(__pyx_k_out_raster_shape_must_be_same_as), 0, 1, 0, 0},
16765   {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
16766   {&__pyx_n_s_pixel_values, __pyx_k_pixel_values, sizeof(__pyx_k_pixel_values), 0, 0, 1, 1},
16767   {&__pyx_n_s_point, __pyx_k_point, sizeof(__pyx_k_point), 0, 0, 1, 1},
16768   {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
16769   {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
16770   {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
16771   {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
16772   {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
16773   {&__pyx_n_s_pyx_unpickle_OGRGeomBuilder, __pyx_k_pyx_unpickle_OGRGeomBuilder, sizeof(__pyx_k_pyx_unpickle_OGRGeomBuilder), 0, 0, 1, 1},
16774   {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
16775   {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
16776   {&__pyx_n_s_rasterio, __pyx_k_rasterio, sizeof(__pyx_k_rasterio), 0, 0, 1, 1},
16777   {&__pyx_kp_u_rasterio_0, __pyx_k_rasterio_0, sizeof(__pyx_k_rasterio_0), 0, 1, 0, 0},
16778   {&__pyx_n_s_rasterio__features, __pyx_k_rasterio__features, sizeof(__pyx_k_rasterio__features), 0, 0, 1, 1},
16779   {&__pyx_kp_s_rasterio__features_pyx, __pyx_k_rasterio__features_pyx, sizeof(__pyx_k_rasterio__features_pyx), 0, 0, 1, 0},
16780   {&__pyx_n_s_rasterio_dtypes, __pyx_k_rasterio_dtypes, sizeof(__pyx_k_rasterio_dtypes), 0, 0, 1, 1},
16781   {&__pyx_n_s_rasterio_enums, __pyx_k_rasterio_enums, sizeof(__pyx_k_rasterio_enums), 0, 0, 1, 1},
16782   {&__pyx_n_s_rasterize, __pyx_k_rasterize, sizeof(__pyx_k_rasterize), 0, 0, 1, 1},
16783   {&__pyx_n_s_rdr, __pyx_k_rdr, sizeof(__pyx_k_rdr), 0, 0, 1, 1},
16784   {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1},
16785   {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
16786   {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
16787   {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
16788   {&__pyx_n_s_retval, __pyx_k_retval, sizeof(__pyx_k_retval), 0, 0, 1, 1},
16789   {&__pyx_n_s_rows, __pyx_k_rows, sizeof(__pyx_k_rows), 0, 0, 1, 1},
16790   {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
16791   {&__pyx_kp_s_self_geom_cannot_be_converted_to, __pyx_k_self_geom_cannot_be_converted_to, sizeof(__pyx_k_self_geom_cannot_be_converted_to), 0, 0, 1, 0},
16792   {&__pyx_kp_s_self_layer_cannot_be_converted_t, __pyx_k_self_layer_cannot_be_converted_t, sizeof(__pyx_k_self_layer_cannot_be_converted_t), 0, 0, 1, 0},
16793   {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
16794   {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
16795   {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
16796   {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
16797   {&__pyx_n_s_shape_iter, __pyx_k_shape_iter, sizeof(__pyx_k_shape_iter), 0, 0, 1, 1},
16798   {&__pyx_n_s_shapes, __pyx_k_shapes, sizeof(__pyx_k_shapes), 0, 0, 1, 1},
16799   {&__pyx_n_s_shapes_2, __pyx_k_shapes_2, sizeof(__pyx_k_shapes_2), 0, 0, 1, 1},
16800   {&__pyx_n_s_sieve, __pyx_k_sieve, sizeof(__pyx_k_sieve), 0, 0, 1, 1},
16801   {&__pyx_n_s_sieve_locals_genexpr, __pyx_k_sieve_locals_genexpr, sizeof(__pyx_k_sieve_locals_genexpr), 0, 0, 1, 1},
16802   {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
16803   {&__pyx_kp_u_size_must_be_an_integer_number_o, __pyx_k_size_must_be_an_integer_number_o, sizeof(__pyx_k_size_must_be_an_integer_number_o), 0, 1, 0, 0},
16804   {&__pyx_kp_u_size_must_be_greater_than_0, __pyx_k_size_must_be_greater_than_0, sizeof(__pyx_k_size_must_be_greater_than_0), 0, 1, 0, 0},
16805   {&__pyx_kp_u_size_must_be_smaller_than_size_o, __pyx_k_size_must_be_smaller_than_size_o, sizeof(__pyx_k_size_must_be_smaller_than_size_o), 0, 1, 0, 0},
16806   {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
16807   {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
16808   {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
16809   {&__pyx_n_s_transform, __pyx_k_transform, sizeof(__pyx_k_transform), 0, 0, 1, 1},
16810   {&__pyx_n_u_type, __pyx_k_type, sizeof(__pyx_k_type), 0, 1, 0, 1},
16811   {&__pyx_n_s_udr, __pyx_k_udr, sizeof(__pyx_k_udr), 0, 0, 1, 1},
16812   {&__pyx_n_u_uint16, __pyx_k_uint16, sizeof(__pyx_k_uint16), 0, 1, 0, 1},
16813   {&__pyx_n_u_uint8, __pyx_k_uint8, sizeof(__pyx_k_uint8), 0, 1, 0, 1},
16814   {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
16815   {&__pyx_kp_u_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 1, 0, 0},
16816   {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
16817   {&__pyx_n_s_valid_dtypes, __pyx_k_valid_dtypes, sizeof(__pyx_k_valid_dtypes), 0, 0, 1, 1},
16818   {&__pyx_n_s_valid_types_str, __pyx_k_valid_types_str, sizeof(__pyx_k_valid_types_str), 0, 0, 1, 1},
16819   {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
16820   {&__pyx_n_s_xmax, __pyx_k_xmax, sizeof(__pyx_k_xmax), 0, 0, 1, 1},
16821   {&__pyx_n_s_xmaxs, __pyx_k_xmaxs, sizeof(__pyx_k_xmaxs), 0, 0, 1, 1},
16822   {&__pyx_n_s_xmin, __pyx_k_xmin, sizeof(__pyx_k_xmin), 0, 0, 1, 1},
16823   {&__pyx_n_s_xmins, __pyx_k_xmins, sizeof(__pyx_k_xmins), 0, 0, 1, 1},
16824   {&__pyx_n_s_xyz, __pyx_k_xyz, sizeof(__pyx_k_xyz), 0, 0, 1, 1},
16825   {&__pyx_n_s_xyz_px, __pyx_k_xyz_px, sizeof(__pyx_k_xyz_px), 0, 0, 1, 1},
16826   {&__pyx_n_s_ymax, __pyx_k_ymax, sizeof(__pyx_k_ymax), 0, 0, 1, 1},
16827   {&__pyx_n_s_ymaxs, __pyx_k_ymaxs, sizeof(__pyx_k_ymaxs), 0, 0, 1, 1},
16828   {&__pyx_n_s_ymin, __pyx_k_ymin, sizeof(__pyx_k_ymin), 0, 0, 1, 1},
16829   {&__pyx_n_s_ymins, __pyx_k_ymins, sizeof(__pyx_k_ymins), 0, 0, 1, 1},
16830   {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1},
16831   {0, 0, 0, 0, 0, 0, 0}
16832 };
__Pyx_InitCachedBuiltins(void)16833 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
16834   __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 72, __pyx_L1_error)
16835   __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 344, __pyx_L1_error)
16836   __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 363, __pyx_L1_error)
16837   __pyx_builtin_min = __Pyx_GetBuiltinName(__pyx_n_s_min); if (!__pyx_builtin_min) __PYX_ERR(0, 409, __pyx_L1_error)
16838   __pyx_builtin_max = __Pyx_GetBuiltinName(__pyx_n_s_max); if (!__pyx_builtin_max) __PYX_ERR(0, 409, __pyx_L1_error)
16839   __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 435, __pyx_L1_error)
16840   __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
16841   __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(0, 715, __pyx_L1_error)
16842   __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(2, 947, __pyx_L1_error)
16843   return 0;
16844   __pyx_L1_error:;
16845   return -1;
16846 }
16847 
__Pyx_InitCachedConstants(void)16848 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
16849   __Pyx_RefNannyDeclarations
16850   __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
16851 
16852   /* "rasterio/_features.pyx":69
16853  *     fieldtp = 2 if is_float else 0
16854  *
16855  *     valid_dtypes = ('int16', 'int32', 'uint8', 'uint16', 'float32')             # <<<<<<<<<<<<<<
16856  *
16857  *     if _getnpdtype(image.dtype).name not in valid_dtypes:
16858  */
16859   __pyx_tuple__2 = PyTuple_Pack(5, __pyx_n_u_int16, __pyx_n_u_int32, __pyx_n_u_uint8, __pyx_n_u_uint16, __pyx_n_u_float32); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 69, __pyx_L1_error)
16860   __Pyx_GOTREF(__pyx_tuple__2);
16861   __Pyx_GIVEREF(__pyx_tuple__2);
16862 
16863   /* "rasterio/_features.pyx":76
16864  *
16865  *     if connectivity not in (4, 8):
16866  *         raise ValueError("Connectivity Option must be 4 or 8")             # <<<<<<<<<<<<<<
16867  *
16868  *     try:
16869  */
16870   __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Connectivity_Option_must_be_4_or); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 76, __pyx_L1_error)
16871   __Pyx_GOTREF(__pyx_tuple__4);
16872   __Pyx_GIVEREF(__pyx_tuple__4);
16873 
16874   /* "rasterio/_features.pyx":87
16875  *             band = (<DatasetReaderBase?>rdr).band(image.bidx)
16876  *         else:
16877  *             raise ValueError("Invalid source image")             # <<<<<<<<<<<<<<
16878  *
16879  *         if mask is not None:
16880  */
16881   __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Invalid_source_image); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 87, __pyx_L1_error)
16882   __Pyx_GOTREF(__pyx_tuple__5);
16883   __Pyx_GIVEREF(__pyx_tuple__5);
16884 
16885   /* "rasterio/_features.pyx":91
16886  *         if mask is not None:
16887  *             if mask.shape != image.shape:
16888  *                 raise ValueError("Mask must have same shape as image")             # <<<<<<<<<<<<<<
16889  *
16890  *             if _getnpdtype(mask.dtype).name not in ('bool', 'uint8'):
16891  */
16892   __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Mask_must_have_same_shape_as_ima); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 91, __pyx_L1_error)
16893   __Pyx_GOTREF(__pyx_tuple__6);
16894   __Pyx_GIVEREF(__pyx_tuple__6);
16895 
16896   /* "rasterio/_features.pyx":94
16897  *
16898  *             if _getnpdtype(mask.dtype).name not in ('bool', 'uint8'):
16899  *                 raise ValueError("Mask must be dtype rasterio.bool_ or "             # <<<<<<<<<<<<<<
16900  *                                  "rasterio.uint8")
16901  *
16902  */
16903   __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Mask_must_be_dtype_rasterio_bool); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 94, __pyx_L1_error)
16904   __Pyx_GOTREF(__pyx_tuple__7);
16905   __Pyx_GIVEREF(__pyx_tuple__7);
16906 
16907   /* "rasterio/_features.pyx":109
16908  *         driver = OGRGetDriverByName("Memory")
16909  *         if driver == NULL:
16910  *             raise ValueError("NULL driver")             # <<<<<<<<<<<<<<
16911  *         fs = OGR_Dr_CreateDataSource(driver, "temp", NULL)
16912  *         if fs == NULL:
16913  */
16914   __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_NULL_driver); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 109, __pyx_L1_error)
16915   __Pyx_GOTREF(__pyx_tuple__8);
16916   __Pyx_GIVEREF(__pyx_tuple__8);
16917 
16918   /* "rasterio/_features.pyx":112
16919  *         fs = OGR_Dr_CreateDataSource(driver, "temp", NULL)
16920  *         if fs == NULL:
16921  *             raise ValueError("NULL feature dataset")             # <<<<<<<<<<<<<<
16922  *
16923  *         # And a layer.
16924  */
16925   __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_NULL_feature_dataset); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 112, __pyx_L1_error)
16926   __Pyx_GOTREF(__pyx_tuple__9);
16927   __Pyx_GIVEREF(__pyx_tuple__9);
16928 
16929   /* "rasterio/_features.pyx":117
16930  *         layer = OGR_DS_CreateLayer(fs, "polygons", NULL, 3, NULL)
16931  *         if layer == NULL:
16932  *             raise ValueError("NULL layer")             # <<<<<<<<<<<<<<
16933  *
16934  *         fielddefn = OGR_Fld_Create("image_value", fieldtp)
16935  */
16936   __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_u_NULL_layer); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 117, __pyx_L1_error)
16937   __Pyx_GOTREF(__pyx_tuple__10);
16938   __Pyx_GIVEREF(__pyx_tuple__10);
16939 
16940   /* "rasterio/_features.pyx":121
16941  *         fielddefn = OGR_Fld_Create("image_value", fieldtp)
16942  *         if fielddefn == NULL:
16943  *             raise ValueError("NULL field definition")             # <<<<<<<<<<<<<<
16944  *         OGR_L_CreateField(layer, fielddefn, 1)
16945  *         OGR_Fld_Destroy(fielddefn)
16946  */
16947   __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_u_NULL_field_definition); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 121, __pyx_L1_error)
16948   __Pyx_GOTREF(__pyx_tuple__11);
16949   __Pyx_GIVEREF(__pyx_tuple__11);
16950 
16951   /* "rasterio/_features.pyx":186
16952  *     cdef GDALRasterBandH mask_band = NULL
16953  *
16954  *     valid_dtypes = ('int16', 'int32', 'uint8', 'uint16')             # <<<<<<<<<<<<<<
16955  *
16956  *     if _getnpdtype(image.dtype).name not in valid_dtypes:
16957  */
16958   __pyx_tuple__12 = PyTuple_Pack(4, __pyx_n_u_int16, __pyx_n_u_int32, __pyx_n_u_uint8, __pyx_n_u_uint16); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 186, __pyx_L1_error)
16959   __Pyx_GOTREF(__pyx_tuple__12);
16960   __Pyx_GIVEREF(__pyx_tuple__12);
16961 
16962   /* "rasterio/_features.pyx":195
16963  *
16964  *     if size <= 0:
16965  *         raise ValueError('size must be greater than 0')             # <<<<<<<<<<<<<<
16966  *     elif type(size) == float:
16967  *         raise ValueError('size must be an integer number of pixels')
16968  */
16969   __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_u_size_must_be_greater_than_0); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 195, __pyx_L1_error)
16970   __Pyx_GOTREF(__pyx_tuple__13);
16971   __Pyx_GIVEREF(__pyx_tuple__13);
16972 
16973   /* "rasterio/_features.pyx":197
16974  *         raise ValueError('size must be greater than 0')
16975  *     elif type(size) == float:
16976  *         raise ValueError('size must be an integer number of pixels')             # <<<<<<<<<<<<<<
16977  *     elif size > (image.shape[0] * image.shape[1]):
16978  *         raise ValueError('size must be smaller than size of image')
16979  */
16980   __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_u_size_must_be_an_integer_number_o); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 197, __pyx_L1_error)
16981   __Pyx_GOTREF(__pyx_tuple__14);
16982   __Pyx_GIVEREF(__pyx_tuple__14);
16983 
16984   /* "rasterio/_features.pyx":199
16985  *         raise ValueError('size must be an integer number of pixels')
16986  *     elif size > (image.shape[0] * image.shape[1]):
16987  *         raise ValueError('size must be smaller than size of image')             # <<<<<<<<<<<<<<
16988  *
16989  *     if connectivity not in (4, 8):
16990  */
16991   __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_u_size_must_be_smaller_than_size_o); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 199, __pyx_L1_error)
16992   __Pyx_GOTREF(__pyx_tuple__15);
16993   __Pyx_GIVEREF(__pyx_tuple__15);
16994 
16995   /* "rasterio/_features.pyx":202
16996  *
16997  *     if connectivity not in (4, 8):
16998  *         raise ValueError('connectivity must be 4 or 8')             # <<<<<<<<<<<<<<
16999  *
17000  *     if out.shape != image.shape:
17001  */
17002   __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_u_connectivity_must_be_4_or_8); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 202, __pyx_L1_error)
17003   __Pyx_GOTREF(__pyx_tuple__16);
17004   __Pyx_GIVEREF(__pyx_tuple__16);
17005 
17006   /* "rasterio/_features.pyx":205
17007  *
17008  *     if out.shape != image.shape:
17009  *         raise ValueError('out raster shape must be same as image shape')             # <<<<<<<<<<<<<<
17010  *
17011  *     if _getnpdtype(image.dtype).name != _getnpdtype(out.dtype).name:
17012  */
17013   __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_u_out_raster_shape_must_be_same_as); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 205, __pyx_L1_error)
17014   __Pyx_GOTREF(__pyx_tuple__17);
17015   __Pyx_GIVEREF(__pyx_tuple__17);
17016 
17017   /* "rasterio/_features.pyx":208
17018  *
17019  *     if _getnpdtype(image.dtype).name != _getnpdtype(out.dtype).name:
17020  *         raise ValueError('out raster must match dtype of image')             # <<<<<<<<<<<<<<
17021  *
17022  *     try:
17023  */
17024   __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_u_out_raster_must_match_dtype_of_i); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 208, __pyx_L1_error)
17025   __Pyx_GOTREF(__pyx_tuple__18);
17026   __Pyx_GIVEREF(__pyx_tuple__18);
17027 
17028   /* "rasterio/_features.pyx":229
17029  *             out_band = (<DatasetReaderBase?>udr).band(out.bidx)
17030  *         else:
17031  *             raise ValueError("Invalid out image")             # <<<<<<<<<<<<<<
17032  *
17033  *         if mask is not None:
17034  */
17035   __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_u_Invalid_out_image); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 229, __pyx_L1_error)
17036   __Pyx_GOTREF(__pyx_tuple__19);
17037   __Pyx_GIVEREF(__pyx_tuple__19);
17038 
17039   /* "rasterio/_features.pyx":353
17040  *
17041  *         # TODO: is a vsimem file more memory efficient?
17042  *         with InMemoryRaster(image=image, transform=transform) as mem:             # <<<<<<<<<<<<<<
17043  *             exc_wrap_int(
17044  *                 GDALRasterizeGeometries(
17045  */
17046   __pyx_tuple__20 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 353, __pyx_L1_error)
17047   __Pyx_GOTREF(__pyx_tuple__20);
17048   __Pyx_GIVEREF(__pyx_tuple__20);
17049 
17050   /* "rasterio/_features.pyx":445
17051  *
17052  *     # all valid inputs returned above, so whatever falls through is an error
17053  *     raise ValueError(             # <<<<<<<<<<<<<<
17054  *             "geometry must be a GeoJSON-like geometry, GeometryCollection, "
17055  *             "or FeatureCollection"
17056  */
17057   __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_u_geometry_must_be_a_GeoJSON_like); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 445, __pyx_L1_error)
17058   __Pyx_GOTREF(__pyx_tuple__22);
17059   __Pyx_GIVEREF(__pyx_tuple__22);
17060 
17061   /* "rasterio/_features.pyx":494
17062  *         cdef int i
17063  *         if geom == NULL:
17064  *             raise ValueError("Null geom")             # <<<<<<<<<<<<<<
17065  *         npoints = OGR_G_GetPointCount(geom)
17066  *         coords = []
17067  */
17068   __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_u_Null_geom); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 494, __pyx_L1_error)
17069   __Pyx_GOTREF(__pyx_tuple__23);
17070   __Pyx_GIVEREF(__pyx_tuple__23);
17071 
17072   /* "(tree fragment)":2
17073  * def __reduce_cython__(self):
17074  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
17075  * def __setstate_cython__(self, __pyx_state):
17076  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")
17077  */
17078   __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_self_geom_cannot_be_converted_to); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(1, 2, __pyx_L1_error)
17079   __Pyx_GOTREF(__pyx_tuple__24);
17080   __Pyx_GIVEREF(__pyx_tuple__24);
17081 
17082   /* "(tree fragment)":4
17083  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")
17084  * def __setstate_cython__(self, __pyx_state):
17085  *     raise TypeError("self.geom cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
17086  */
17087   __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_self_geom_cannot_be_converted_to); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(1, 4, __pyx_L1_error)
17088   __Pyx_GOTREF(__pyx_tuple__25);
17089   __Pyx_GIVEREF(__pyx_tuple__25);
17090 
17091   /* "rasterio/_features.pyx":577
17092  *             OGR_G_AddPoint_2D(geom, x, y)
17093  *         else:
17094  *             x, y, z = coordinate[:3]             # <<<<<<<<<<<<<<
17095  *             OGR_G_AddPoint(geom, x, y, z)
17096  *
17097  */
17098   __pyx_slice__26 = PySlice_New(Py_None, __pyx_int_3, Py_None); if (unlikely(!__pyx_slice__26)) __PYX_ERR(0, 577, __pyx_L1_error)
17099   __Pyx_GOTREF(__pyx_slice__26);
17100   __Pyx_GIVEREF(__pyx_slice__26);
17101 
17102   /* "rasterio/_features.pyx":663
17103  *             coordinates = geometry.get('coordinates')
17104  *             if not (coordinates and len(coordinates) > 0):
17105  *                 raise ValueError("Input is not a valid geometry object")             # <<<<<<<<<<<<<<
17106  *
17107  *             if typename == 'Point':
17108  */
17109   __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_u_Input_is_not_a_valid_geometry_ob); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 663, __pyx_L1_error)
17110   __Pyx_GOTREF(__pyx_tuple__27);
17111   __Pyx_GIVEREF(__pyx_tuple__27);
17112 
17113   /* "(tree fragment)":2
17114  * def __reduce_cython__(self):
17115  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
17116  * def __setstate_cython__(self, __pyx_state):
17117  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")
17118  */
17119   __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_self_layer_cannot_be_converted_t); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(1, 2, __pyx_L1_error)
17120   __Pyx_GOTREF(__pyx_tuple__28);
17121   __Pyx_GIVEREF(__pyx_tuple__28);
17122 
17123   /* "(tree fragment)":4
17124  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")
17125  * def __setstate_cython__(self, __pyx_state):
17126  *     raise TypeError("self.layer cannot be converted to a Python object for pickling")             # <<<<<<<<<<<<<<
17127  */
17128   __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_self_layer_cannot_be_converted_t); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(1, 4, __pyx_L1_error)
17129   __Pyx_GOTREF(__pyx_tuple__29);
17130   __Pyx_GIVEREF(__pyx_tuple__29);
17131 
17132   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":947
17133  *         __pyx_import_array()
17134  *     except Exception:
17135  *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
17136  *
17137  * cdef inline int import_umath() except -1:
17138  */
17139   __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(2, 947, __pyx_L1_error)
17140   __Pyx_GOTREF(__pyx_tuple__30);
17141   __Pyx_GIVEREF(__pyx_tuple__30);
17142 
17143   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":953
17144  *         _import_umath()
17145  *     except Exception:
17146  *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
17147  *
17148  * cdef inline int import_ufunc() except -1:
17149  */
17150   __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(2, 953, __pyx_L1_error)
17151   __Pyx_GOTREF(__pyx_tuple__31);
17152   __Pyx_GIVEREF(__pyx_tuple__31);
17153 
17154   /* "rasterio/_features.pyx":22
17155  *
17156  *
17157  * def _shapes(image, mask, connectivity, transform):             # <<<<<<<<<<<<<<
17158  *     """
17159  *     Return a generator of (polygon, value) for each each set of adjacent pixels
17160  */
17161   __pyx_tuple__32 = PyTuple_Pack(24, __pyx_n_s_image, __pyx_n_s_mask, __pyx_n_s_connectivity, __pyx_n_s_transform, __pyx_n_s_retval, __pyx_n_s_rows, __pyx_n_s_cols, __pyx_n_s_band, __pyx_n_s_maskband, __pyx_n_s_driver, __pyx_n_s_fs, __pyx_n_s_layer, __pyx_n_s_fielddefn, __pyx_n_s_options, __pyx_n_s_mem_ds, __pyx_n_s_mask_ds, __pyx_n_s_shape_iter, __pyx_n_s_fieldtp, __pyx_n_s_is_float, __pyx_n_s_valid_dtypes, __pyx_n_s_rdr, __pyx_n_s_mrdr, __pyx_n_s_s, __pyx_n_s_v); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 22, __pyx_L1_error)
17162   __Pyx_GOTREF(__pyx_tuple__32);
17163   __Pyx_GIVEREF(__pyx_tuple__32);
17164   __pyx_codeobj_ = (PyObject*)__Pyx_PyCode_New(4, 0, 24, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_rasterio__features_pyx, __pyx_n_s_shapes, 22, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj_)) __PYX_ERR(0, 22, __pyx_L1_error)
17165 
17166   /* "rasterio/_features.pyx":154
17167  *
17168  *
17169  * def _sieve(image, size, out, mask, connectivity):             # <<<<<<<<<<<<<<
17170  *     """
17171  *     Replaces small polygons in `image` with the value of their largest
17172  */
17173   __pyx_tuple__33 = PyTuple_Pack(21, __pyx_n_s_image, __pyx_n_s_size, __pyx_n_s_out, __pyx_n_s_mask, __pyx_n_s_connectivity, __pyx_n_s_retval, __pyx_n_s_rows, __pyx_n_s_cols, __pyx_n_s_in_mem_ds, __pyx_n_s_out_mem_ds, __pyx_n_s_mask_mem_ds, __pyx_n_s_in_band, __pyx_n_s_out_band, __pyx_n_s_mask_band, __pyx_n_s_valid_dtypes, __pyx_n_s_valid_types_str, __pyx_n_s_rdr, __pyx_n_s_udr, __pyx_n_s_mask_reader, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 154, __pyx_L1_error)
17174   __Pyx_GOTREF(__pyx_tuple__33);
17175   __Pyx_GIVEREF(__pyx_tuple__33);
17176   __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(5, 0, 21, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_rasterio__features_pyx, __pyx_n_s_sieve, 154, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 154, __pyx_L1_error)
17177 
17178   /* "rasterio/_features.pyx":264
17179  *
17180  *
17181  * def _rasterize(shapes, image, transform, all_touched, merge_alg):             # <<<<<<<<<<<<<<
17182  *     """
17183  *     Burns input geometries into `image`.
17184  */
17185   __pyx_tuple__35 = PyTuple_Pack(16, __pyx_n_s_shapes_2, __pyx_n_s_image, __pyx_n_s_transform, __pyx_n_s_all_touched, __pyx_n_s_merge_alg, __pyx_n_s_retval, __pyx_n_s_i, __pyx_n_s_num_geoms, __pyx_n_s_geoms, __pyx_n_s_options, __pyx_n_s_pixel_values, __pyx_n_s_mem, __pyx_n_s_merge_algorithm, __pyx_n_s_all_shapes, __pyx_n_s_geometry, __pyx_n_s_value); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 264, __pyx_L1_error)
17186   __Pyx_GOTREF(__pyx_tuple__35);
17187   __Pyx_GIVEREF(__pyx_tuple__35);
17188   __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(5, 0, 16, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_rasterio__features_pyx, __pyx_n_s_rasterize, 264, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 264, __pyx_L1_error)
17189 
17190   /* "rasterio/_features.pyx":371
17191  *
17192  *
17193  * def _explode(coords):             # <<<<<<<<<<<<<<
17194  *     """Explode a GeoJSON geometry's coordinates object and yield
17195  *     coordinate tuples. As long as the input is conforming, the type of
17196  */
17197   __pyx_tuple__37 = PyTuple_Pack(3, __pyx_n_s_coords, __pyx_n_s_e, __pyx_n_s_f); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 371, __pyx_L1_error)
17198   __Pyx_GOTREF(__pyx_tuple__37);
17199   __Pyx_GIVEREF(__pyx_tuple__37);
17200   __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_rasterio__features_pyx, __pyx_n_s_explode, 371, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 371, __pyx_L1_error)
17201 
17202   /* "rasterio/_features.pyx":384
17203  *
17204  *
17205  * def _bounds(geometry, north_up=True, transform=None):             # <<<<<<<<<<<<<<
17206  *     """Bounding box of a GeoJSON geometry, GeometryCollection, or FeatureCollection.
17207  *
17208  */
17209   __pyx_tuple__38 = PyTuple_Pack(15, __pyx_n_s_geometry, __pyx_n_s_north_up, __pyx_n_s_transform, __pyx_n_s_xmins, __pyx_n_s_ymins, __pyx_n_s_xmaxs, __pyx_n_s_ymaxs, __pyx_n_s_feature, __pyx_n_s_xmin, __pyx_n_s_ymin, __pyx_n_s_xmax, __pyx_n_s_ymax, __pyx_n_s_xyz, __pyx_n_s_xyz_px, __pyx_n_s_point); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 384, __pyx_L1_error)
17210   __Pyx_GOTREF(__pyx_tuple__38);
17211   __Pyx_GIVEREF(__pyx_tuple__38);
17212   __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(3, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_rasterio__features_pyx, __pyx_n_s_bounds, 384, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 384, __pyx_L1_error)
17213 
17214   /* "(tree fragment)":1
17215  * def __pyx_unpickle_OGRGeomBuilder(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
17216  *     cdef object __pyx_PickleError
17217  *     cdef object __pyx_result
17218  */
17219   __pyx_tuple__40 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(1, 1, __pyx_L1_error)
17220   __Pyx_GOTREF(__pyx_tuple__40);
17221   __Pyx_GIVEREF(__pyx_tuple__40);
17222   __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_OGRGeomBuilder, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(1, 1, __pyx_L1_error)
17223   __Pyx_RefNannyFinishContext();
17224   return 0;
17225   __pyx_L1_error:;
17226   __Pyx_RefNannyFinishContext();
17227   return -1;
17228 }
17229 
__Pyx_InitGlobals(void)17230 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
17231   if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
17232   __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
17233   __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
17234   __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
17235   __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
17236   __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
17237   __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) __PYX_ERR(0, 1, __pyx_L1_error)
17238   __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) __PYX_ERR(0, 1, __pyx_L1_error)
17239   __pyx_int_7 = PyInt_FromLong(7); if (unlikely(!__pyx_int_7)) __PYX_ERR(0, 1, __pyx_L1_error)
17240   __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) __PYX_ERR(0, 1, __pyx_L1_error)
17241   __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) __PYX_ERR(0, 1, __pyx_L1_error)
17242   __pyx_int_101 = PyInt_FromLong(101); if (unlikely(!__pyx_int_101)) __PYX_ERR(0, 1, __pyx_L1_error)
17243   __pyx_int_222419149 = PyInt_FromLong(222419149L); if (unlikely(!__pyx_int_222419149)) __PYX_ERR(0, 1, __pyx_L1_error)
17244   __pyx_int_2147483648 = PyInt_FromString((char *)"2147483648", 0, 0); if (unlikely(!__pyx_int_2147483648)) __PYX_ERR(0, 1, __pyx_L1_error)
17245   __pyx_int_2147483649 = PyInt_FromString((char *)"2147483649", 0, 0); if (unlikely(!__pyx_int_2147483649)) __PYX_ERR(0, 1, __pyx_L1_error)
17246   __pyx_int_2147483650 = PyInt_FromString((char *)"2147483650", 0, 0); if (unlikely(!__pyx_int_2147483650)) __PYX_ERR(0, 1, __pyx_L1_error)
17247   __pyx_int_2147483651 = PyInt_FromString((char *)"2147483651", 0, 0); if (unlikely(!__pyx_int_2147483651)) __PYX_ERR(0, 1, __pyx_L1_error)
17248   __pyx_int_2147483652 = PyInt_FromString((char *)"2147483652", 0, 0); if (unlikely(!__pyx_int_2147483652)) __PYX_ERR(0, 1, __pyx_L1_error)
17249   __pyx_int_2147483653 = PyInt_FromString((char *)"2147483653", 0, 0); if (unlikely(!__pyx_int_2147483653)) __PYX_ERR(0, 1, __pyx_L1_error)
17250   __pyx_int_2147483654 = PyInt_FromString((char *)"2147483654", 0, 0); if (unlikely(!__pyx_int_2147483654)) __PYX_ERR(0, 1, __pyx_L1_error)
17251   __pyx_int_2147483655 = PyInt_FromString((char *)"2147483655", 0, 0); if (unlikely(!__pyx_int_2147483655)) __PYX_ERR(0, 1, __pyx_L1_error)
17252   return 0;
17253   __pyx_L1_error:;
17254   return -1;
17255 }
17256 
17257 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
17258 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
17259 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
17260 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
17261 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
17262 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
17263 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
17264 
__Pyx_modinit_global_init_code(void)17265 static int __Pyx_modinit_global_init_code(void) {
17266   __Pyx_RefNannyDeclarations
17267   __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
17268   /*--- Global init code ---*/
17269   __Pyx_RefNannyFinishContext();
17270   return 0;
17271 }
17272 
__Pyx_modinit_variable_export_code(void)17273 static int __Pyx_modinit_variable_export_code(void) {
17274   __Pyx_RefNannyDeclarations
17275   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
17276   /*--- Variable export code ---*/
17277   __Pyx_RefNannyFinishContext();
17278   return 0;
17279 }
17280 
__Pyx_modinit_function_export_code(void)17281 static int __Pyx_modinit_function_export_code(void) {
17282   __Pyx_RefNannyDeclarations
17283   __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
17284   /*--- Function export code ---*/
17285   __Pyx_RefNannyFinishContext();
17286   return 0;
17287 }
17288 
__Pyx_modinit_type_init_code(void)17289 static int __Pyx_modinit_type_init_code(void) {
17290   __Pyx_RefNannyDeclarations
17291   int __pyx_lineno = 0;
17292   const char *__pyx_filename = NULL;
17293   int __pyx_clineno = 0;
17294   __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
17295   /*--- Type init code ---*/
17296   __pyx_vtabptr_8rasterio_9_features_GeomBuilder = &__pyx_vtable_8rasterio_9_features_GeomBuilder;
17297   __pyx_vtable_8rasterio_9_features_GeomBuilder._buildCoords = (PyObject *(*)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, OGRGeometryH))__pyx_f_8rasterio_9_features_11GeomBuilder__buildCoords;
17298   __pyx_vtable_8rasterio_9_features_GeomBuilder._buildPoint = (PyObject *(*)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_8rasterio_9_features_11GeomBuilder__buildPoint;
17299   __pyx_vtable_8rasterio_9_features_GeomBuilder._buildLineString = (PyObject *(*)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_8rasterio_9_features_11GeomBuilder__buildLineString;
17300   __pyx_vtable_8rasterio_9_features_GeomBuilder._buildLinearRing = (PyObject *(*)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_8rasterio_9_features_11GeomBuilder__buildLinearRing;
17301   __pyx_vtable_8rasterio_9_features_GeomBuilder._buildParts = (PyObject *(*)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, OGRGeometryH))__pyx_f_8rasterio_9_features_11GeomBuilder__buildParts;
17302   __pyx_vtable_8rasterio_9_features_GeomBuilder._buildPolygon = (PyObject *(*)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_8rasterio_9_features_11GeomBuilder__buildPolygon;
17303   __pyx_vtable_8rasterio_9_features_GeomBuilder._buildMultiPoint = (PyObject *(*)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiPoint;
17304   __pyx_vtable_8rasterio_9_features_GeomBuilder._buildMultiLineString = (PyObject *(*)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiLineString;
17305   __pyx_vtable_8rasterio_9_features_GeomBuilder._buildMultiPolygon = (PyObject *(*)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_8rasterio_9_features_11GeomBuilder__buildMultiPolygon;
17306   __pyx_vtable_8rasterio_9_features_GeomBuilder.build = (PyObject *(*)(struct __pyx_obj_8rasterio_9_features_GeomBuilder *, OGRGeometryH))__pyx_f_8rasterio_9_features_11GeomBuilder_build;
17307   if (PyType_Ready(&__pyx_type_8rasterio_9_features_GeomBuilder) < 0) __PYX_ERR(0, 487, __pyx_L1_error)
17308   #if PY_VERSION_HEX < 0x030800B1
17309   __pyx_type_8rasterio_9_features_GeomBuilder.tp_print = 0;
17310   #endif
17311   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_8rasterio_9_features_GeomBuilder.tp_dictoffset && __pyx_type_8rasterio_9_features_GeomBuilder.tp_getattro == PyObject_GenericGetAttr)) {
17312     __pyx_type_8rasterio_9_features_GeomBuilder.tp_getattro = __Pyx_PyObject_GenericGetAttr;
17313   }
17314   if (__Pyx_SetVtable(__pyx_type_8rasterio_9_features_GeomBuilder.tp_dict, __pyx_vtabptr_8rasterio_9_features_GeomBuilder) < 0) __PYX_ERR(0, 487, __pyx_L1_error)
17315   if (PyObject_SetAttr(__pyx_m, __pyx_n_s_GeomBuilder, (PyObject *)&__pyx_type_8rasterio_9_features_GeomBuilder) < 0) __PYX_ERR(0, 487, __pyx_L1_error)
17316   if (__Pyx_setup_reduce((PyObject*)&__pyx_type_8rasterio_9_features_GeomBuilder) < 0) __PYX_ERR(0, 487, __pyx_L1_error)
17317   __pyx_ptype_8rasterio_9_features_GeomBuilder = &__pyx_type_8rasterio_9_features_GeomBuilder;
17318   __pyx_vtabptr_8rasterio_9_features_OGRGeomBuilder = &__pyx_vtable_8rasterio_9_features_OGRGeomBuilder;
17319   __pyx_vtable_8rasterio_9_features_OGRGeomBuilder._createOgrGeometry = (OGRGeometryH (*)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, int))__pyx_f_8rasterio_9_features_14OGRGeomBuilder__createOgrGeometry;
17320   __pyx_vtable_8rasterio_9_features_OGRGeomBuilder._addPointToGeometry = (PyObject *(*)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, OGRGeometryH, PyObject *))__pyx_f_8rasterio_9_features_14OGRGeomBuilder__addPointToGeometry;
17321   __pyx_vtable_8rasterio_9_features_OGRGeomBuilder._buildPoint = (OGRGeometryH (*)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *))__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildPoint;
17322   __pyx_vtable_8rasterio_9_features_OGRGeomBuilder._buildLineString = (OGRGeometryH (*)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *))__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildLineString;
17323   __pyx_vtable_8rasterio_9_features_OGRGeomBuilder._buildLinearRing = (OGRGeometryH (*)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *))__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildLinearRing;
17324   __pyx_vtable_8rasterio_9_features_OGRGeomBuilder._buildPolygon = (OGRGeometryH (*)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *))__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildPolygon;
17325   __pyx_vtable_8rasterio_9_features_OGRGeomBuilder._buildMultiPoint = (OGRGeometryH (*)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *))__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildMultiPoint;
17326   __pyx_vtable_8rasterio_9_features_OGRGeomBuilder._buildMultiLineString = (OGRGeometryH (*)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *))__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildMultiLineString;
17327   __pyx_vtable_8rasterio_9_features_OGRGeomBuilder._buildMultiPolygon = (OGRGeometryH (*)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *))__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildMultiPolygon;
17328   __pyx_vtable_8rasterio_9_features_OGRGeomBuilder._buildGeomCollection = (OGRGeometryH (*)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *))__pyx_f_8rasterio_9_features_14OGRGeomBuilder__buildGeomCollection;
17329   __pyx_vtable_8rasterio_9_features_OGRGeomBuilder.build = (OGRGeometryH (*)(struct __pyx_obj_8rasterio_9_features_OGRGeomBuilder *, PyObject *))__pyx_f_8rasterio_9_features_14OGRGeomBuilder_build;
17330   if (PyType_Ready(&__pyx_type_8rasterio_9_features_OGRGeomBuilder) < 0) __PYX_ERR(0, 559, __pyx_L1_error)
17331   #if PY_VERSION_HEX < 0x030800B1
17332   __pyx_type_8rasterio_9_features_OGRGeomBuilder.tp_print = 0;
17333   #endif
17334   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_8rasterio_9_features_OGRGeomBuilder.tp_dictoffset && __pyx_type_8rasterio_9_features_OGRGeomBuilder.tp_getattro == PyObject_GenericGetAttr)) {
17335     __pyx_type_8rasterio_9_features_OGRGeomBuilder.tp_getattro = __Pyx_PyObject_GenericGetAttr;
17336   }
17337   if (__Pyx_SetVtable(__pyx_type_8rasterio_9_features_OGRGeomBuilder.tp_dict, __pyx_vtabptr_8rasterio_9_features_OGRGeomBuilder) < 0) __PYX_ERR(0, 559, __pyx_L1_error)
17338   if (PyObject_SetAttr(__pyx_m, __pyx_n_s_OGRGeomBuilder, (PyObject *)&__pyx_type_8rasterio_9_features_OGRGeomBuilder) < 0) __PYX_ERR(0, 559, __pyx_L1_error)
17339   if (__Pyx_setup_reduce((PyObject*)&__pyx_type_8rasterio_9_features_OGRGeomBuilder) < 0) __PYX_ERR(0, 559, __pyx_L1_error)
17340   __pyx_ptype_8rasterio_9_features_OGRGeomBuilder = &__pyx_type_8rasterio_9_features_OGRGeomBuilder;
17341   if (PyType_Ready(&__pyx_type_8rasterio_9_features_ShapeIterator) < 0) __PYX_ERR(0, 700, __pyx_L1_error)
17342   #if PY_VERSION_HEX < 0x030800B1
17343   __pyx_type_8rasterio_9_features_ShapeIterator.tp_print = 0;
17344   #endif
17345   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_8rasterio_9_features_ShapeIterator.tp_dictoffset && __pyx_type_8rasterio_9_features_ShapeIterator.tp_getattro == PyObject_GenericGetAttr)) {
17346     __pyx_type_8rasterio_9_features_ShapeIterator.tp_getattro = __Pyx_PyObject_GenericGetAttr;
17347   }
17348   if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ShapeIterator, (PyObject *)&__pyx_type_8rasterio_9_features_ShapeIterator) < 0) __PYX_ERR(0, 700, __pyx_L1_error)
17349   if (__Pyx_setup_reduce((PyObject*)&__pyx_type_8rasterio_9_features_ShapeIterator) < 0) __PYX_ERR(0, 700, __pyx_L1_error)
17350   __pyx_ptype_8rasterio_9_features_ShapeIterator = &__pyx_type_8rasterio_9_features_ShapeIterator;
17351   if (PyType_Ready(&__pyx_type_8rasterio_9_features___pyx_scope_struct___shapes) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
17352   #if PY_VERSION_HEX < 0x030800B1
17353   __pyx_type_8rasterio_9_features___pyx_scope_struct___shapes.tp_print = 0;
17354   #endif
17355   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_8rasterio_9_features___pyx_scope_struct___shapes.tp_dictoffset && __pyx_type_8rasterio_9_features___pyx_scope_struct___shapes.tp_getattro == PyObject_GenericGetAttr)) {
17356     __pyx_type_8rasterio_9_features___pyx_scope_struct___shapes.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
17357   }
17358   __pyx_ptype_8rasterio_9_features___pyx_scope_struct___shapes = &__pyx_type_8rasterio_9_features___pyx_scope_struct___shapes;
17359   if (PyType_Ready(&__pyx_type_8rasterio_9_features___pyx_scope_struct_1__sieve) < 0) __PYX_ERR(0, 154, __pyx_L1_error)
17360   #if PY_VERSION_HEX < 0x030800B1
17361   __pyx_type_8rasterio_9_features___pyx_scope_struct_1__sieve.tp_print = 0;
17362   #endif
17363   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_8rasterio_9_features___pyx_scope_struct_1__sieve.tp_dictoffset && __pyx_type_8rasterio_9_features___pyx_scope_struct_1__sieve.tp_getattro == PyObject_GenericGetAttr)) {
17364     __pyx_type_8rasterio_9_features___pyx_scope_struct_1__sieve.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
17365   }
17366   __pyx_ptype_8rasterio_9_features___pyx_scope_struct_1__sieve = &__pyx_type_8rasterio_9_features___pyx_scope_struct_1__sieve;
17367   if (PyType_Ready(&__pyx_type_8rasterio_9_features___pyx_scope_struct_2_genexpr) < 0) __PYX_ERR(0, 189, __pyx_L1_error)
17368   #if PY_VERSION_HEX < 0x030800B1
17369   __pyx_type_8rasterio_9_features___pyx_scope_struct_2_genexpr.tp_print = 0;
17370   #endif
17371   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_8rasterio_9_features___pyx_scope_struct_2_genexpr.tp_dictoffset && __pyx_type_8rasterio_9_features___pyx_scope_struct_2_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
17372     __pyx_type_8rasterio_9_features___pyx_scope_struct_2_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
17373   }
17374   __pyx_ptype_8rasterio_9_features___pyx_scope_struct_2_genexpr = &__pyx_type_8rasterio_9_features___pyx_scope_struct_2_genexpr;
17375   if (PyType_Ready(&__pyx_type_8rasterio_9_features___pyx_scope_struct_3__explode) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
17376   #if PY_VERSION_HEX < 0x030800B1
17377   __pyx_type_8rasterio_9_features___pyx_scope_struct_3__explode.tp_print = 0;
17378   #endif
17379   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_8rasterio_9_features___pyx_scope_struct_3__explode.tp_dictoffset && __pyx_type_8rasterio_9_features___pyx_scope_struct_3__explode.tp_getattro == PyObject_GenericGetAttr)) {
17380     __pyx_type_8rasterio_9_features___pyx_scope_struct_3__explode.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
17381   }
17382   __pyx_ptype_8rasterio_9_features___pyx_scope_struct_3__explode = &__pyx_type_8rasterio_9_features___pyx_scope_struct_3__explode;
17383   if (PyType_Ready(&__pyx_type_8rasterio_9_features___pyx_scope_struct_4_genexpr) < 0) __PYX_ERR(0, 473, __pyx_L1_error)
17384   #if PY_VERSION_HEX < 0x030800B1
17385   __pyx_type_8rasterio_9_features___pyx_scope_struct_4_genexpr.tp_print = 0;
17386   #endif
17387   if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_8rasterio_9_features___pyx_scope_struct_4_genexpr.tp_dictoffset && __pyx_type_8rasterio_9_features___pyx_scope_struct_4_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
17388     __pyx_type_8rasterio_9_features___pyx_scope_struct_4_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
17389   }
17390   __pyx_ptype_8rasterio_9_features___pyx_scope_struct_4_genexpr = &__pyx_type_8rasterio_9_features___pyx_scope_struct_4_genexpr;
17391   __Pyx_RefNannyFinishContext();
17392   return 0;
17393   __pyx_L1_error:;
17394   __Pyx_RefNannyFinishContext();
17395   return -1;
17396 }
17397 
__Pyx_modinit_type_import_code(void)17398 static int __Pyx_modinit_type_import_code(void) {
17399   __Pyx_RefNannyDeclarations
17400   PyObject *__pyx_t_1 = NULL;
17401   int __pyx_lineno = 0;
17402   const char *__pyx_filename = NULL;
17403   int __pyx_clineno = 0;
17404   __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
17405   /*--- Type import code ---*/
17406   __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error)
17407   __Pyx_GOTREF(__pyx_t_1);
17408   __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
17409   #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
17410   sizeof(PyTypeObject),
17411   #else
17412   sizeof(PyHeapTypeObject),
17413   #endif
17414   __Pyx_ImportType_CheckSize_Warn);
17415    if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error)
17416   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17417   __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 200, __pyx_L1_error)
17418   __Pyx_GOTREF(__pyx_t_1);
17419   __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore);
17420    if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(2, 200, __pyx_L1_error)
17421   __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore);
17422    if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(2, 223, __pyx_L1_error)
17423   __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore);
17424    if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(2, 227, __pyx_L1_error)
17425   __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore);
17426    if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(2, 239, __pyx_L1_error)
17427   __pyx_ptype_5numpy_generic = __Pyx_ImportType(__pyx_t_1, "numpy", "generic", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
17428    if (!__pyx_ptype_5numpy_generic) __PYX_ERR(2, 771, __pyx_L1_error)
17429   __pyx_ptype_5numpy_number = __Pyx_ImportType(__pyx_t_1, "numpy", "number", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
17430    if (!__pyx_ptype_5numpy_number) __PYX_ERR(2, 773, __pyx_L1_error)
17431   __pyx_ptype_5numpy_integer = __Pyx_ImportType(__pyx_t_1, "numpy", "integer", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
17432    if (!__pyx_ptype_5numpy_integer) __PYX_ERR(2, 775, __pyx_L1_error)
17433   __pyx_ptype_5numpy_signedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "signedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
17434    if (!__pyx_ptype_5numpy_signedinteger) __PYX_ERR(2, 777, __pyx_L1_error)
17435   __pyx_ptype_5numpy_unsignedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "unsignedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
17436    if (!__pyx_ptype_5numpy_unsignedinteger) __PYX_ERR(2, 779, __pyx_L1_error)
17437   __pyx_ptype_5numpy_inexact = __Pyx_ImportType(__pyx_t_1, "numpy", "inexact", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
17438    if (!__pyx_ptype_5numpy_inexact) __PYX_ERR(2, 781, __pyx_L1_error)
17439   __pyx_ptype_5numpy_floating = __Pyx_ImportType(__pyx_t_1, "numpy", "floating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
17440    if (!__pyx_ptype_5numpy_floating) __PYX_ERR(2, 783, __pyx_L1_error)
17441   __pyx_ptype_5numpy_complexfloating = __Pyx_ImportType(__pyx_t_1, "numpy", "complexfloating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
17442    if (!__pyx_ptype_5numpy_complexfloating) __PYX_ERR(2, 785, __pyx_L1_error)
17443   __pyx_ptype_5numpy_flexible = __Pyx_ImportType(__pyx_t_1, "numpy", "flexible", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
17444    if (!__pyx_ptype_5numpy_flexible) __PYX_ERR(2, 787, __pyx_L1_error)
17445   __pyx_ptype_5numpy_character = __Pyx_ImportType(__pyx_t_1, "numpy", "character", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
17446    if (!__pyx_ptype_5numpy_character) __PYX_ERR(2, 789, __pyx_L1_error)
17447   __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore);
17448    if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(2, 827, __pyx_L1_error)
17449   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17450   __pyx_t_1 = PyImport_ImportModule("rasterio._base"); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 6, __pyx_L1_error)
17451   __Pyx_GOTREF(__pyx_t_1);
17452   __pyx_ptype_8rasterio_5_base_DatasetBase = __Pyx_ImportType(__pyx_t_1, "rasterio._base", "DatasetBase", sizeof(struct __pyx_obj_8rasterio_5_base_DatasetBase), __Pyx_ImportType_CheckSize_Warn);
17453    if (!__pyx_ptype_8rasterio_5_base_DatasetBase) __PYX_ERR(4, 6, __pyx_L1_error)
17454   __pyx_vtabptr_8rasterio_5_base_DatasetBase = (struct __pyx_vtabstruct_8rasterio_5_base_DatasetBase*)__Pyx_GetVtable(__pyx_ptype_8rasterio_5_base_DatasetBase->tp_dict); if (unlikely(!__pyx_vtabptr_8rasterio_5_base_DatasetBase)) __PYX_ERR(4, 6, __pyx_L1_error)
17455   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17456   __pyx_t_1 = PyImport_ImportModule("rasterio._io"); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 10, __pyx_L1_error)
17457   __Pyx_GOTREF(__pyx_t_1);
17458   __pyx_ptype_8rasterio_3_io_DatasetReaderBase = __Pyx_ImportType(__pyx_t_1, "rasterio._io", "DatasetReaderBase", sizeof(struct __pyx_obj_8rasterio_3_io_DatasetReaderBase), __Pyx_ImportType_CheckSize_Warn);
17459    if (!__pyx_ptype_8rasterio_3_io_DatasetReaderBase) __PYX_ERR(5, 10, __pyx_L1_error)
17460   __pyx_vtabptr_8rasterio_3_io_DatasetReaderBase = (struct __pyx_vtabstruct_8rasterio_3_io_DatasetReaderBase*)__Pyx_GetVtable(__pyx_ptype_8rasterio_3_io_DatasetReaderBase->tp_dict); if (unlikely(!__pyx_vtabptr_8rasterio_3_io_DatasetReaderBase)) __PYX_ERR(5, 10, __pyx_L1_error)
17461   __pyx_ptype_8rasterio_3_io_DatasetWriterBase = __Pyx_ImportType(__pyx_t_1, "rasterio._io", "DatasetWriterBase", sizeof(struct __pyx_obj_8rasterio_3_io_DatasetWriterBase), __Pyx_ImportType_CheckSize_Warn);
17462    if (!__pyx_ptype_8rasterio_3_io_DatasetWriterBase) __PYX_ERR(5, 14, __pyx_L1_error)
17463   __pyx_vtabptr_8rasterio_3_io_DatasetWriterBase = (struct __pyx_vtabstruct_8rasterio_3_io_DatasetWriterBase*)__Pyx_GetVtable(__pyx_ptype_8rasterio_3_io_DatasetWriterBase->tp_dict); if (unlikely(!__pyx_vtabptr_8rasterio_3_io_DatasetWriterBase)) __PYX_ERR(5, 14, __pyx_L1_error)
17464   __pyx_ptype_8rasterio_3_io_BufferedDatasetWriterBase = __Pyx_ImportType(__pyx_t_1, "rasterio._io", "BufferedDatasetWriterBase", sizeof(struct __pyx_obj_8rasterio_3_io_BufferedDatasetWriterBase), __Pyx_ImportType_CheckSize_Warn);
17465    if (!__pyx_ptype_8rasterio_3_io_BufferedDatasetWriterBase) __PYX_ERR(5, 22, __pyx_L1_error)
17466   __pyx_vtabptr_8rasterio_3_io_BufferedDatasetWriterBase = (struct __pyx_vtabstruct_8rasterio_3_io_BufferedDatasetWriterBase*)__Pyx_GetVtable(__pyx_ptype_8rasterio_3_io_BufferedDatasetWriterBase->tp_dict); if (unlikely(!__pyx_vtabptr_8rasterio_3_io_BufferedDatasetWriterBase)) __PYX_ERR(5, 22, __pyx_L1_error)
17467   __pyx_ptype_8rasterio_3_io_InMemoryRaster = __Pyx_ImportType(__pyx_t_1, "rasterio._io", "InMemoryRaster", sizeof(struct __pyx_obj_8rasterio_3_io_InMemoryRaster), __Pyx_ImportType_CheckSize_Warn);
17468    if (!__pyx_ptype_8rasterio_3_io_InMemoryRaster) __PYX_ERR(5, 26, __pyx_L1_error)
17469   __pyx_vtabptr_8rasterio_3_io_InMemoryRaster = (struct __pyx_vtabstruct_8rasterio_3_io_InMemoryRaster*)__Pyx_GetVtable(__pyx_ptype_8rasterio_3_io_InMemoryRaster->tp_dict); if (unlikely(!__pyx_vtabptr_8rasterio_3_io_InMemoryRaster)) __PYX_ERR(5, 26, __pyx_L1_error)
17470   __pyx_ptype_8rasterio_3_io_MemoryFileBase = __Pyx_ImportType(__pyx_t_1, "rasterio._io", "MemoryFileBase", sizeof(struct __pyx_obj_8rasterio_3_io_MemoryFileBase), __Pyx_ImportType_CheckSize_Warn);
17471    if (!__pyx_ptype_8rasterio_3_io_MemoryFileBase) __PYX_ERR(5, 38, __pyx_L1_error)
17472   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17473   __Pyx_RefNannyFinishContext();
17474   return 0;
17475   __pyx_L1_error:;
17476   __Pyx_XDECREF(__pyx_t_1);
17477   __Pyx_RefNannyFinishContext();
17478   return -1;
17479 }
17480 
__Pyx_modinit_variable_import_code(void)17481 static int __Pyx_modinit_variable_import_code(void) {
17482   __Pyx_RefNannyDeclarations
17483   __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
17484   /*--- Variable import code ---*/
17485   __Pyx_RefNannyFinishContext();
17486   return 0;
17487 }
17488 
__Pyx_modinit_function_import_code(void)17489 static int __Pyx_modinit_function_import_code(void) {
17490   __Pyx_RefNannyDeclarations
17491   PyObject *__pyx_t_1 = NULL;
17492   int __pyx_lineno = 0;
17493   const char *__pyx_filename = NULL;
17494   int __pyx_clineno = 0;
17495   __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
17496   /*--- Function import code ---*/
17497   __pyx_t_1 = PyImport_ImportModule("rasterio._err"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
17498   __Pyx_GOTREF(__pyx_t_1);
17499   if (__Pyx_ImportFunction(__pyx_t_1, "exc_wrap_int", (void (**)(void))&__pyx_f_8rasterio_4_err_exc_wrap_int, "int (int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17500   if (__Pyx_ImportFunction(__pyx_t_1, "exc_wrap_pointer", (void (**)(void))&__pyx_f_8rasterio_4_err_exc_wrap_pointer, "void *(void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17501   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17502   __pyx_t_1 = PyImport_ImportModule("rasterio._io"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
17503   __Pyx_GOTREF(__pyx_t_1);
17504   if (__Pyx_ImportFunction(__pyx_t_1, "io_auto", (void (**)(void))&__pyx_f_8rasterio_3_io_io_auto, "int (PyObject *, GDALRasterBandH, int, struct __pyx_opt_args_8rasterio_3_io_io_auto *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17505   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17506   __Pyx_RefNannyFinishContext();
17507   return 0;
17508   __pyx_L1_error:;
17509   __Pyx_XDECREF(__pyx_t_1);
17510   __Pyx_RefNannyFinishContext();
17511   return -1;
17512 }
17513 
17514 
17515 #ifndef CYTHON_NO_PYINIT_EXPORT
17516 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
17517 #elif PY_MAJOR_VERSION < 3
17518 #ifdef __cplusplus
17519 #define __Pyx_PyMODINIT_FUNC extern "C" void
17520 #else
17521 #define __Pyx_PyMODINIT_FUNC void
17522 #endif
17523 #else
17524 #ifdef __cplusplus
17525 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
17526 #else
17527 #define __Pyx_PyMODINIT_FUNC PyObject *
17528 #endif
17529 #endif
17530 
17531 
17532 #if PY_MAJOR_VERSION < 3
17533 __Pyx_PyMODINIT_FUNC init_features(void) CYTHON_SMALL_CODE; /*proto*/
init_features(void)17534 __Pyx_PyMODINIT_FUNC init_features(void)
17535 #else
17536 __Pyx_PyMODINIT_FUNC PyInit__features(void) CYTHON_SMALL_CODE; /*proto*/
17537 __Pyx_PyMODINIT_FUNC PyInit__features(void)
17538 #if CYTHON_PEP489_MULTI_PHASE_INIT
17539 {
17540   return PyModuleDef_Init(&__pyx_moduledef);
17541 }
17542 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
17543     #if PY_VERSION_HEX >= 0x030700A1
17544     static PY_INT64_T main_interpreter_id = -1;
17545     PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
17546     if (main_interpreter_id == -1) {
17547         main_interpreter_id = current_id;
17548         return (unlikely(current_id == -1)) ? -1 : 0;
17549     } else if (unlikely(main_interpreter_id != current_id))
17550     #else
17551     static PyInterpreterState *main_interpreter = NULL;
17552     PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
17553     if (!main_interpreter) {
17554         main_interpreter = current_interpreter;
17555     } else if (unlikely(main_interpreter != current_interpreter))
17556     #endif
17557     {
17558         PyErr_SetString(
17559             PyExc_ImportError,
17560             "Interpreter change detected - this module can only be loaded into one interpreter per process.");
17561         return -1;
17562     }
17563     return 0;
17564 }
17565 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
17566     PyObject *value = PyObject_GetAttrString(spec, from_name);
17567     int result = 0;
17568     if (likely(value)) {
17569         if (allow_none || value != Py_None) {
17570             result = PyDict_SetItemString(moddict, to_name, value);
17571         }
17572         Py_DECREF(value);
17573     } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
17574         PyErr_Clear();
17575     } else {
17576         result = -1;
17577     }
17578     return result;
17579 }
17580 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
17581     PyObject *module = NULL, *moddict, *modname;
17582     if (__Pyx_check_single_interpreter())
17583         return NULL;
17584     if (__pyx_m)
17585         return __Pyx_NewRef(__pyx_m);
17586     modname = PyObject_GetAttrString(spec, "name");
17587     if (unlikely(!modname)) goto bad;
17588     module = PyModule_NewObject(modname);
17589     Py_DECREF(modname);
17590     if (unlikely(!module)) goto bad;
17591     moddict = PyModule_GetDict(module);
17592     if (unlikely(!moddict)) goto bad;
17593     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
17594     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
17595     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
17596     if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
17597     return module;
17598 bad:
17599     Py_XDECREF(module);
17600     return NULL;
17601 }
17602 
17603 
17604 static CYTHON_SMALL_CODE int __pyx_pymod_exec__features(PyObject *__pyx_pyinit_module)
17605 #endif
17606 #endif
17607 {
17608   PyObject *__pyx_t_1 = NULL;
17609   PyObject *__pyx_t_2 = NULL;
17610   PyObject *__pyx_t_3 = NULL;
17611   int __pyx_lineno = 0;
17612   const char *__pyx_filename = NULL;
17613   int __pyx_clineno = 0;
17614   __Pyx_RefNannyDeclarations
17615   #if CYTHON_PEP489_MULTI_PHASE_INIT
17616   if (__pyx_m) {
17617     if (__pyx_m == __pyx_pyinit_module) return 0;
17618     PyErr_SetString(PyExc_RuntimeError, "Module '_features' has already been imported. Re-initialisation is not supported.");
17619     return -1;
17620   }
17621   #elif PY_MAJOR_VERSION >= 3
17622   if (__pyx_m) return __Pyx_NewRef(__pyx_m);
17623   #endif
17624   #if CYTHON_REFNANNY
17625 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
17626 if (!__Pyx_RefNanny) {
17627   PyErr_Clear();
17628   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
17629   if (!__Pyx_RefNanny)
17630       Py_FatalError("failed to import 'refnanny' module");
17631 }
17632 #endif
17633   __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__features(void)", 0);
17634   if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17635   #ifdef __Pxy_PyFrame_Initialize_Offsets
17636   __Pxy_PyFrame_Initialize_Offsets();
17637   #endif
17638   __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
17639   __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
17640   __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
17641   #ifdef __Pyx_CyFunction_USED
17642   if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17643   #endif
17644   #ifdef __Pyx_FusedFunction_USED
17645   if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17646   #endif
17647   #ifdef __Pyx_Coroutine_USED
17648   if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17649   #endif
17650   #ifdef __Pyx_Generator_USED
17651   if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17652   #endif
17653   #ifdef __Pyx_AsyncGen_USED
17654   if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17655   #endif
17656   #ifdef __Pyx_StopAsyncIteration_USED
17657   if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17658   #endif
17659   /*--- Library function declarations ---*/
17660   /*--- Threads initialization code ---*/
17661   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
17662   #ifdef WITH_THREAD /* Python build with threading support? */
17663   PyEval_InitThreads();
17664   #endif
17665   #endif
17666   /*--- Module creation code ---*/
17667   #if CYTHON_PEP489_MULTI_PHASE_INIT
17668   __pyx_m = __pyx_pyinit_module;
17669   Py_INCREF(__pyx_m);
17670   #else
17671   #if PY_MAJOR_VERSION < 3
17672   __pyx_m = Py_InitModule4("_features", __pyx_methods, __pyx_k_Feature_extraction, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
17673   #else
17674   __pyx_m = PyModule_Create(&__pyx_moduledef);
17675   #endif
17676   if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
17677   #endif
17678   __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
17679   Py_INCREF(__pyx_d);
17680   __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
17681   Py_INCREF(__pyx_b);
17682   __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
17683   Py_INCREF(__pyx_cython_runtime);
17684   if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
17685   /*--- Initialize various global constants etc. ---*/
17686   if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17687   #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
17688   if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17689   #endif
17690   if (__pyx_module_is_main_rasterio___features) {
17691     if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17692   }
17693   #if PY_MAJOR_VERSION >= 3
17694   {
17695     PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
17696     if (!PyDict_GetItemString(modules, "rasterio._features")) {
17697       if (unlikely(PyDict_SetItemString(modules, "rasterio._features", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
17698     }
17699   }
17700   #endif
17701   /*--- Builtin init code ---*/
17702   if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17703   /*--- Constants init code ---*/
17704   if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17705   /*--- Global type/function init code ---*/
17706   (void)__Pyx_modinit_global_init_code();
17707   (void)__Pyx_modinit_variable_export_code();
17708   (void)__Pyx_modinit_function_export_code();
17709   if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
17710   if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
17711   (void)__Pyx_modinit_variable_import_code();
17712   if (unlikely(__Pyx_modinit_function_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
17713   /*--- Execution code ---*/
17714   #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
17715   if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17716   #endif
17717 
17718   /* "rasterio/_features.pyx":7
17719  * include "gdal.pxi"
17720  *
17721  * import logging             # <<<<<<<<<<<<<<
17722  *
17723  * import numpy as np
17724  */
17725   __pyx_t_1 = __Pyx_Import(__pyx_n_s_logging, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
17726   __Pyx_GOTREF(__pyx_t_1);
17727   if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
17728   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17729 
17730   /* "rasterio/_features.pyx":9
17731  * import logging
17732  *
17733  * import numpy as np             # <<<<<<<<<<<<<<
17734  *
17735  * from rasterio import dtypes
17736  */
17737   __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
17738   __Pyx_GOTREF(__pyx_t_1);
17739   if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
17740   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17741 
17742   /* "rasterio/_features.pyx":11
17743  * import numpy as np
17744  *
17745  * from rasterio import dtypes             # <<<<<<<<<<<<<<
17746  * from rasterio.dtypes import _getnpdtype
17747  * from rasterio.enums import MergeAlg
17748  */
17749   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
17750   __Pyx_GOTREF(__pyx_t_1);
17751   __Pyx_INCREF(__pyx_n_s_dtypes);
17752   __Pyx_GIVEREF(__pyx_n_s_dtypes);
17753   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_dtypes);
17754   __pyx_t_2 = __Pyx_Import(__pyx_n_s_rasterio, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
17755   __Pyx_GOTREF(__pyx_t_2);
17756   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17757   __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_dtypes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
17758   __Pyx_GOTREF(__pyx_t_1);
17759   if (PyDict_SetItem(__pyx_d, __pyx_n_s_dtypes, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
17760   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17761   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17762 
17763   /* "rasterio/_features.pyx":12
17764  *
17765  * from rasterio import dtypes
17766  * from rasterio.dtypes import _getnpdtype             # <<<<<<<<<<<<<<
17767  * from rasterio.enums import MergeAlg
17768  *
17769  */
17770   __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
17771   __Pyx_GOTREF(__pyx_t_2);
17772   __Pyx_INCREF(__pyx_n_s_getnpdtype);
17773   __Pyx_GIVEREF(__pyx_n_s_getnpdtype);
17774   PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_getnpdtype);
17775   __pyx_t_1 = __Pyx_Import(__pyx_n_s_rasterio_dtypes, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
17776   __Pyx_GOTREF(__pyx_t_1);
17777   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17778   __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_getnpdtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
17779   __Pyx_GOTREF(__pyx_t_2);
17780   if (PyDict_SetItem(__pyx_d, __pyx_n_s_getnpdtype, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
17781   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17782   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17783 
17784   /* "rasterio/_features.pyx":13
17785  * from rasterio import dtypes
17786  * from rasterio.dtypes import _getnpdtype
17787  * from rasterio.enums import MergeAlg             # <<<<<<<<<<<<<<
17788  *
17789  * from rasterio._err cimport exc_wrap_int, exc_wrap_pointer
17790  */
17791   __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
17792   __Pyx_GOTREF(__pyx_t_1);
17793   __Pyx_INCREF(__pyx_n_s_MergeAlg);
17794   __Pyx_GIVEREF(__pyx_n_s_MergeAlg);
17795   PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_MergeAlg);
17796   __pyx_t_2 = __Pyx_Import(__pyx_n_s_rasterio_enums, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
17797   __Pyx_GOTREF(__pyx_t_2);
17798   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17799   __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_MergeAlg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
17800   __Pyx_GOTREF(__pyx_t_1);
17801   if (PyDict_SetItem(__pyx_d, __pyx_n_s_MergeAlg, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
17802   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17803   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17804 
17805   /* "rasterio/_features.pyx":19
17806  *
17807  *
17808  * log = logging.getLogger(__name__)             # <<<<<<<<<<<<<<
17809  *
17810  *
17811  */
17812   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
17813   __Pyx_GOTREF(__pyx_t_2);
17814   __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
17815   __Pyx_GOTREF(__pyx_t_1);
17816   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17817   __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
17818   __Pyx_GOTREF(__pyx_t_2);
17819   __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error)
17820   __Pyx_GOTREF(__pyx_t_3);
17821   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17822   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17823   if (PyDict_SetItem(__pyx_d, __pyx_n_s_log, __pyx_t_3) < 0) __PYX_ERR(0, 19, __pyx_L1_error)
17824   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17825 
17826   /* "rasterio/_features.pyx":22
17827  *
17828  *
17829  * def _shapes(image, mask, connectivity, transform):             # <<<<<<<<<<<<<<
17830  *     """
17831  *     Return a generator of (polygon, value) for each each set of adjacent pixels
17832  */
17833   __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_8rasterio_9_features_1_shapes, NULL, __pyx_n_s_rasterio__features); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error)
17834   __Pyx_GOTREF(__pyx_t_3);
17835   if (PyDict_SetItem(__pyx_d, __pyx_n_s_shapes, __pyx_t_3) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
17836   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17837 
17838   /* "rasterio/_features.pyx":154
17839  *
17840  *
17841  * def _sieve(image, size, out, mask, connectivity):             # <<<<<<<<<<<<<<
17842  *     """
17843  *     Replaces small polygons in `image` with the value of their largest
17844  */
17845   __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_8rasterio_9_features_4_sieve, NULL, __pyx_n_s_rasterio__features); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 154, __pyx_L1_error)
17846   __Pyx_GOTREF(__pyx_t_3);
17847   if (PyDict_SetItem(__pyx_d, __pyx_n_s_sieve, __pyx_t_3) < 0) __PYX_ERR(0, 154, __pyx_L1_error)
17848   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17849 
17850   /* "rasterio/_features.pyx":264
17851  *
17852  *
17853  * def _rasterize(shapes, image, transform, all_touched, merge_alg):             # <<<<<<<<<<<<<<
17854  *     """
17855  *     Burns input geometries into `image`.
17856  */
17857   __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_8rasterio_9_features_6_rasterize, NULL, __pyx_n_s_rasterio__features); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 264, __pyx_L1_error)
17858   __Pyx_GOTREF(__pyx_t_3);
17859   if (PyDict_SetItem(__pyx_d, __pyx_n_s_rasterize, __pyx_t_3) < 0) __PYX_ERR(0, 264, __pyx_L1_error)
17860   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17861 
17862   /* "rasterio/_features.pyx":371
17863  *
17864  *
17865  * def _explode(coords):             # <<<<<<<<<<<<<<
17866  *     """Explode a GeoJSON geometry's coordinates object and yield
17867  *     coordinate tuples. As long as the input is conforming, the type of
17868  */
17869   __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_8rasterio_9_features_8_explode, NULL, __pyx_n_s_rasterio__features); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error)
17870   __Pyx_GOTREF(__pyx_t_3);
17871   if (PyDict_SetItem(__pyx_d, __pyx_n_s_explode, __pyx_t_3) < 0) __PYX_ERR(0, 371, __pyx_L1_error)
17872   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17873 
17874   /* "rasterio/_features.pyx":384
17875  *
17876  *
17877  * def _bounds(geometry, north_up=True, transform=None):             # <<<<<<<<<<<<<<
17878  *     """Bounding box of a GeoJSON geometry, GeometryCollection, or FeatureCollection.
17879  *
17880  */
17881   __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_8rasterio_9_features_11_bounds, NULL, __pyx_n_s_rasterio__features); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 384, __pyx_L1_error)
17882   __Pyx_GOTREF(__pyx_t_3);
17883   if (PyDict_SetItem(__pyx_d, __pyx_n_s_bounds, __pyx_t_3) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
17884   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17885 
17886   /* "rasterio/_features.pyx":452
17887  * # Mapping of OGR integer geometry types to GeoJSON type names.
17888  * GEOMETRY_TYPES = {
17889  *     0: 'Unknown',             # <<<<<<<<<<<<<<
17890  *     1: 'Point',
17891  *     2: 'LineString',
17892  */
17893   __pyx_t_3 = __Pyx_PyDict_NewPresized(17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L1_error)
17894   __Pyx_GOTREF(__pyx_t_3);
17895   if (PyDict_SetItem(__pyx_t_3, __pyx_int_0, __pyx_n_u_Unknown) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17896   if (PyDict_SetItem(__pyx_t_3, __pyx_int_1, __pyx_n_u_Point) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17897   if (PyDict_SetItem(__pyx_t_3, __pyx_int_2, __pyx_n_u_LineString) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17898   if (PyDict_SetItem(__pyx_t_3, __pyx_int_3, __pyx_n_u_Polygon) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17899   if (PyDict_SetItem(__pyx_t_3, __pyx_int_4, __pyx_n_u_MultiPoint) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17900   if (PyDict_SetItem(__pyx_t_3, __pyx_int_5, __pyx_n_u_MultiLineString) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17901   if (PyDict_SetItem(__pyx_t_3, __pyx_int_6, __pyx_n_u_MultiPolygon) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17902   if (PyDict_SetItem(__pyx_t_3, __pyx_int_7, __pyx_n_u_GeometryCollection) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17903   if (PyDict_SetItem(__pyx_t_3, __pyx_int_100, __pyx_n_u_None) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17904   if (PyDict_SetItem(__pyx_t_3, __pyx_int_101, __pyx_n_u_LinearRing) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17905   if (PyDict_SetItem(__pyx_t_3, __pyx_int_2147483649, __pyx_kp_u_3D_Point) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17906   if (PyDict_SetItem(__pyx_t_3, __pyx_int_2147483650, __pyx_kp_u_3D_LineString) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17907   if (PyDict_SetItem(__pyx_t_3, __pyx_int_2147483651, __pyx_kp_u_3D_Polygon) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17908   if (PyDict_SetItem(__pyx_t_3, __pyx_int_2147483652, __pyx_kp_u_3D_MultiPoint) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17909   if (PyDict_SetItem(__pyx_t_3, __pyx_int_2147483653, __pyx_kp_u_3D_MultiLineString) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17910   if (PyDict_SetItem(__pyx_t_3, __pyx_int_2147483654, __pyx_kp_u_3D_MultiPolygon) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17911   if (PyDict_SetItem(__pyx_t_3, __pyx_int_2147483655, __pyx_kp_u_3D_GeometryCollection) < 0) __PYX_ERR(0, 452, __pyx_L1_error)
17912   if (PyDict_SetItem(__pyx_d, __pyx_n_s_GEOMETRY_TYPES, __pyx_t_3) < 0) __PYX_ERR(0, 451, __pyx_L1_error)
17913   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17914 
17915   /* "rasterio/_features.pyx":473
17916  * # Mapping of GeoJSON type names to OGR integer geometry types
17917  * GEOJSON2OGR_GEOMETRY_TYPES = dict(
17918  *     (v, k) for k, v in GEOMETRY_TYPES.iteritems()             # <<<<<<<<<<<<<<
17919  * )
17920  *
17921  */
17922   __pyx_t_3 = __pyx_pf_8rasterio_9_features_12genexpr(NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 473, __pyx_L1_error)
17923   __Pyx_GOTREF(__pyx_t_3);
17924 
17925   /* "rasterio/_features.pyx":472
17926  *
17927  * # Mapping of GeoJSON type names to OGR integer geometry types
17928  * GEOJSON2OGR_GEOMETRY_TYPES = dict(             # <<<<<<<<<<<<<<
17929  *     (v, k) for k, v in GEOMETRY_TYPES.iteritems()
17930  * )
17931  */
17932   __pyx_t_2 = __Pyx_Generator_Next(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 472, __pyx_L1_error)
17933   __Pyx_GOTREF(__pyx_t_2);
17934   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17935   if (PyDict_SetItem(__pyx_d, __pyx_n_s_GEOJSON2OGR_GEOMETRY_TYPES, __pyx_t_2) < 0) __PYX_ERR(0, 472, __pyx_L1_error)
17936   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17937 
17938   /* "(tree fragment)":1
17939  * def __pyx_unpickle_OGRGeomBuilder(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
17940  *     cdef object __pyx_PickleError
17941  *     cdef object __pyx_result
17942  */
17943   __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8rasterio_9_features_16__pyx_unpickle_OGRGeomBuilder, NULL, __pyx_n_s_rasterio__features); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error)
17944   __Pyx_GOTREF(__pyx_t_2);
17945   if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_OGRGeomBuilder, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
17946   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17947 
17948   /* "rasterio/_features.pyx":1
17949  * # cython: language_level=3             # <<<<<<<<<<<<<<
17950  *
17951  * """Feature extraction"""
17952  */
17953   __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
17954   __Pyx_GOTREF(__pyx_t_2);
17955   if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
17956   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
17957 
17958   /* "../../.virtualenvs/dev-rasterio/lib/python3.7/site-packages/numpy/__init__.pxd":1016
17959  *
17960  *
17961  * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:             # <<<<<<<<<<<<<<
17962  *     """
17963  *     returns the unit part of the dtype for a numpy datetime64 object.
17964  */
17965 
17966   /*--- Wrapped vars code ---*/
17967 
17968   goto __pyx_L0;
17969   __pyx_L1_error:;
17970   __Pyx_XDECREF(__pyx_t_1);
17971   __Pyx_XDECREF(__pyx_t_2);
17972   __Pyx_XDECREF(__pyx_t_3);
17973   if (__pyx_m) {
17974     if (__pyx_d) {
17975       __Pyx_AddTraceback("init rasterio._features", __pyx_clineno, __pyx_lineno, __pyx_filename);
17976     }
17977     Py_CLEAR(__pyx_m);
17978   } else if (!PyErr_Occurred()) {
17979     PyErr_SetString(PyExc_ImportError, "init rasterio._features");
17980   }
17981   __pyx_L0:;
17982   __Pyx_RefNannyFinishContext();
17983   #if CYTHON_PEP489_MULTI_PHASE_INIT
17984   return (__pyx_m != NULL) ? 0 : -1;
17985   #elif PY_MAJOR_VERSION >= 3
17986   return __pyx_m;
17987   #else
17988   return;
17989   #endif
17990 }
17991 
17992 /* --- Runtime support code --- */
17993 /* Refnanny */
17994 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)17995 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
17996     PyObject *m = NULL, *p = NULL;
17997     void *r = NULL;
17998     m = PyImport_ImportModule(modname);
17999     if (!m) goto end;
18000     p = PyObject_GetAttrString(m, "RefNannyAPI");
18001     if (!p) goto end;
18002     r = PyLong_AsVoidPtr(p);
18003 end:
18004     Py_XDECREF(p);
18005     Py_XDECREF(m);
18006     return (__Pyx_RefNannyAPIStruct *)r;
18007 }
18008 #endif
18009 
18010 /* PyObjectGetAttrStr */
18011 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)18012 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
18013     PyTypeObject* tp = Py_TYPE(obj);
18014     if (likely(tp->tp_getattro))
18015         return tp->tp_getattro(obj, attr_name);
18016 #if PY_MAJOR_VERSION < 3
18017     if (likely(tp->tp_getattr))
18018         return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
18019 #endif
18020     return PyObject_GetAttr(obj, attr_name);
18021 }
18022 #endif
18023 
18024 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)18025 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
18026     PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
18027     if (unlikely(!result)) {
18028         PyErr_Format(PyExc_NameError,
18029 #if PY_MAJOR_VERSION >= 3
18030             "name '%U' is not defined", name);
18031 #else
18032             "name '%.200s' is not defined", PyString_AS_STRING(name));
18033 #endif
18034     }
18035     return result;
18036 }
18037 
18038 /* IterFinish */
__Pyx_IterFinish(void)18039 static CYTHON_INLINE int __Pyx_IterFinish(void) {
18040 #if CYTHON_FAST_THREAD_STATE
18041     PyThreadState *tstate = __Pyx_PyThreadState_Current;
18042     PyObject* exc_type = tstate->curexc_type;
18043     if (unlikely(exc_type)) {
18044         if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
18045             PyObject *exc_value, *exc_tb;
18046             exc_value = tstate->curexc_value;
18047             exc_tb = tstate->curexc_traceback;
18048             tstate->curexc_type = 0;
18049             tstate->curexc_value = 0;
18050             tstate->curexc_traceback = 0;
18051             Py_DECREF(exc_type);
18052             Py_XDECREF(exc_value);
18053             Py_XDECREF(exc_tb);
18054             return 0;
18055         } else {
18056             return -1;
18057         }
18058     }
18059     return 0;
18060 #else
18061     if (unlikely(PyErr_Occurred())) {
18062         if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
18063             PyErr_Clear();
18064             return 0;
18065         } else {
18066             return -1;
18067         }
18068     }
18069     return 0;
18070 #endif
18071 }
18072 
18073 /* PyFunctionFastCall */
18074 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)18075 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
18076                                                PyObject *globals) {
18077     PyFrameObject *f;
18078     PyThreadState *tstate = __Pyx_PyThreadState_Current;
18079     PyObject **fastlocals;
18080     Py_ssize_t i;
18081     PyObject *result;
18082     assert(globals != NULL);
18083     /* XXX Perhaps we should create a specialized
18084        PyFrame_New() that doesn't take locals, but does
18085        take builtins without sanity checking them.
18086        */
18087     assert(tstate != NULL);
18088     f = PyFrame_New(tstate, co, globals, NULL);
18089     if (f == NULL) {
18090         return NULL;
18091     }
18092     fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
18093     for (i = 0; i < na; i++) {
18094         Py_INCREF(*args);
18095         fastlocals[i] = *args++;
18096     }
18097     result = PyEval_EvalFrameEx(f,0);
18098     ++tstate->recursion_depth;
18099     Py_DECREF(f);
18100     --tstate->recursion_depth;
18101     return result;
18102 }
18103 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)18104 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
18105     PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
18106     PyObject *globals = PyFunction_GET_GLOBALS(func);
18107     PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
18108     PyObject *closure;
18109 #if PY_MAJOR_VERSION >= 3
18110     PyObject *kwdefs;
18111 #endif
18112     PyObject *kwtuple, **k;
18113     PyObject **d;
18114     Py_ssize_t nd;
18115     Py_ssize_t nk;
18116     PyObject *result;
18117     assert(kwargs == NULL || PyDict_Check(kwargs));
18118     nk = kwargs ? PyDict_Size(kwargs) : 0;
18119     if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
18120         return NULL;
18121     }
18122     if (
18123 #if PY_MAJOR_VERSION >= 3
18124             co->co_kwonlyargcount == 0 &&
18125 #endif
18126             likely(kwargs == NULL || nk == 0) &&
18127             co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
18128         if (argdefs == NULL && co->co_argcount == nargs) {
18129             result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
18130             goto done;
18131         }
18132         else if (nargs == 0 && argdefs != NULL
18133                  && co->co_argcount == Py_SIZE(argdefs)) {
18134             /* function called with no arguments, but all parameters have
18135                a default value: use default values as arguments .*/
18136             args = &PyTuple_GET_ITEM(argdefs, 0);
18137             result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
18138             goto done;
18139         }
18140     }
18141     if (kwargs != NULL) {
18142         Py_ssize_t pos, i;
18143         kwtuple = PyTuple_New(2 * nk);
18144         if (kwtuple == NULL) {
18145             result = NULL;
18146             goto done;
18147         }
18148         k = &PyTuple_GET_ITEM(kwtuple, 0);
18149         pos = i = 0;
18150         while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
18151             Py_INCREF(k[i]);
18152             Py_INCREF(k[i+1]);
18153             i += 2;
18154         }
18155         nk = i / 2;
18156     }
18157     else {
18158         kwtuple = NULL;
18159         k = NULL;
18160     }
18161     closure = PyFunction_GET_CLOSURE(func);
18162 #if PY_MAJOR_VERSION >= 3
18163     kwdefs = PyFunction_GET_KW_DEFAULTS(func);
18164 #endif
18165     if (argdefs != NULL) {
18166         d = &PyTuple_GET_ITEM(argdefs, 0);
18167         nd = Py_SIZE(argdefs);
18168     }
18169     else {
18170         d = NULL;
18171         nd = 0;
18172     }
18173 #if PY_MAJOR_VERSION >= 3
18174     result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
18175                                args, (int)nargs,
18176                                k, (int)nk,
18177                                d, (int)nd, kwdefs, closure);
18178 #else
18179     result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
18180                                args, (int)nargs,
18181                                k, (int)nk,
18182                                d, (int)nd, closure);
18183 #endif
18184     Py_XDECREF(kwtuple);
18185 done:
18186     Py_LeaveRecursiveCall();
18187     return result;
18188 }
18189 #endif
18190 #endif
18191 
18192 /* PyObjectCall */
18193 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)18194 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
18195     PyObject *result;
18196     ternaryfunc call = func->ob_type->tp_call;
18197     if (unlikely(!call))
18198         return PyObject_Call(func, arg, kw);
18199     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
18200         return NULL;
18201     result = (*call)(func, arg, kw);
18202     Py_LeaveRecursiveCall();
18203     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
18204         PyErr_SetString(
18205             PyExc_SystemError,
18206             "NULL result without error in PyObject_Call");
18207     }
18208     return result;
18209 }
18210 #endif
18211 
18212 /* PyObjectCallMethO */
18213 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)18214 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
18215     PyObject *self, *result;
18216     PyCFunction cfunc;
18217     cfunc = PyCFunction_GET_FUNCTION(func);
18218     self = PyCFunction_GET_SELF(func);
18219     if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
18220         return NULL;
18221     result = cfunc(self, arg);
18222     Py_LeaveRecursiveCall();
18223     if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
18224         PyErr_SetString(
18225             PyExc_SystemError,
18226             "NULL result without error in PyObject_Call");
18227     }
18228     return result;
18229 }
18230 #endif
18231 
18232 /* PyObjectCallNoArg */
18233 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)18234 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
18235 #if CYTHON_FAST_PYCALL
18236     if (PyFunction_Check(func)) {
18237         return __Pyx_PyFunction_FastCall(func, NULL, 0);
18238     }
18239 #endif
18240 #ifdef __Pyx_CyFunction_USED
18241     if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
18242 #else
18243     if (likely(PyCFunction_Check(func)))
18244 #endif
18245     {
18246         if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
18247             return __Pyx_PyObject_CallMethO(func, NULL);
18248         }
18249     }
18250     return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
18251 }
18252 #endif
18253 
18254 /* PyCFunctionFastCall */
18255 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)18256 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
18257     PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
18258     PyCFunction meth = PyCFunction_GET_FUNCTION(func);
18259     PyObject *self = PyCFunction_GET_SELF(func);
18260     int flags = PyCFunction_GET_FLAGS(func);
18261     assert(PyCFunction_Check(func));
18262     assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
18263     assert(nargs >= 0);
18264     assert(nargs == 0 || args != NULL);
18265     /* _PyCFunction_FastCallDict() must not be called with an exception set,
18266        because it may clear it (directly or indirectly) and so the
18267        caller loses its exception */
18268     assert(!PyErr_Occurred());
18269     if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
18270         return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
18271     } else {
18272         return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
18273     }
18274 }
18275 #endif
18276 
18277 /* PyObjectCallOneArg */
18278 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)18279 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
18280     PyObject *result;
18281     PyObject *args = PyTuple_New(1);
18282     if (unlikely(!args)) return NULL;
18283     Py_INCREF(arg);
18284     PyTuple_SET_ITEM(args, 0, arg);
18285     result = __Pyx_PyObject_Call(func, args, NULL);
18286     Py_DECREF(args);
18287     return result;
18288 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)18289 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
18290 #if CYTHON_FAST_PYCALL
18291     if (PyFunction_Check(func)) {
18292         return __Pyx_PyFunction_FastCall(func, &arg, 1);
18293     }
18294 #endif
18295     if (likely(PyCFunction_Check(func))) {
18296         if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
18297             return __Pyx_PyObject_CallMethO(func, arg);
18298 #if CYTHON_FAST_PYCCALL
18299         } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
18300             return __Pyx_PyCFunction_FastCall(func, &arg, 1);
18301 #endif
18302         }
18303     }
18304     return __Pyx__PyObject_CallOneArg(func, arg);
18305 }
18306 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)18307 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
18308     PyObject *result;
18309     PyObject *args = PyTuple_Pack(1, arg);
18310     if (unlikely(!args)) return NULL;
18311     result = __Pyx_PyObject_Call(func, args, NULL);
18312     Py_DECREF(args);
18313     return result;
18314 }
18315 #endif
18316 
18317 /* PyObjectGetMethod */
__Pyx_PyObject_GetMethod(PyObject * obj,PyObject * name,PyObject ** method)18318 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
18319     PyObject *attr;
18320 #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
18321     PyTypeObject *tp = Py_TYPE(obj);
18322     PyObject *descr;
18323     descrgetfunc f = NULL;
18324     PyObject **dictptr, *dict;
18325     int meth_found = 0;
18326     assert (*method == NULL);
18327     if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
18328         attr = __Pyx_PyObject_GetAttrStr(obj, name);
18329         goto try_unpack;
18330     }
18331     if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
18332         return 0;
18333     }
18334     descr = _PyType_Lookup(tp, name);
18335     if (likely(descr != NULL)) {
18336         Py_INCREF(descr);
18337 #if PY_MAJOR_VERSION >= 3
18338         #ifdef __Pyx_CyFunction_USED
18339         if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
18340         #else
18341         if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
18342         #endif
18343 #else
18344         #ifdef __Pyx_CyFunction_USED
18345         if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
18346         #else
18347         if (likely(PyFunction_Check(descr)))
18348         #endif
18349 #endif
18350         {
18351             meth_found = 1;
18352         } else {
18353             f = Py_TYPE(descr)->tp_descr_get;
18354             if (f != NULL && PyDescr_IsData(descr)) {
18355                 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
18356                 Py_DECREF(descr);
18357                 goto try_unpack;
18358             }
18359         }
18360     }
18361     dictptr = _PyObject_GetDictPtr(obj);
18362     if (dictptr != NULL && (dict = *dictptr) != NULL) {
18363         Py_INCREF(dict);
18364         attr = __Pyx_PyDict_GetItemStr(dict, name);
18365         if (attr != NULL) {
18366             Py_INCREF(attr);
18367             Py_DECREF(dict);
18368             Py_XDECREF(descr);
18369             goto try_unpack;
18370         }
18371         Py_DECREF(dict);
18372     }
18373     if (meth_found) {
18374         *method = descr;
18375         return 1;
18376     }
18377     if (f != NULL) {
18378         attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
18379         Py_DECREF(descr);
18380         goto try_unpack;
18381     }
18382     if (descr != NULL) {
18383         *method = descr;
18384         return 0;
18385     }
18386     PyErr_Format(PyExc_AttributeError,
18387 #if PY_MAJOR_VERSION >= 3
18388                  "'%.50s' object has no attribute '%U'",
18389                  tp->tp_name, name);
18390 #else
18391                  "'%.50s' object has no attribute '%.400s'",
18392                  tp->tp_name, PyString_AS_STRING(name));
18393 #endif
18394     return 0;
18395 #else
18396     attr = __Pyx_PyObject_GetAttrStr(obj, name);
18397     goto try_unpack;
18398 #endif
18399 try_unpack:
18400 #if CYTHON_UNPACK_METHODS
18401     if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
18402         PyObject *function = PyMethod_GET_FUNCTION(attr);
18403         Py_INCREF(function);
18404         Py_DECREF(attr);
18405         *method = function;
18406         return 1;
18407     }
18408 #endif
18409     *method = attr;
18410     return 0;
18411 }
18412 
18413 /* PyObjectCallMethod0 */
__Pyx_PyObject_CallMethod0(PyObject * obj,PyObject * method_name)18414 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
18415     PyObject *method = NULL, *result = NULL;
18416     int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
18417     if (likely(is_method)) {
18418         result = __Pyx_PyObject_CallOneArg(method, obj);
18419         Py_DECREF(method);
18420         return result;
18421     }
18422     if (unlikely(!method)) goto bad;
18423     result = __Pyx_PyObject_CallNoArg(method);
18424     Py_DECREF(method);
18425 bad:
18426     return result;
18427 }
18428 
18429 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)18430 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
18431     PyErr_Format(PyExc_ValueError,
18432                  "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
18433                  index, (index == 1) ? "" : "s");
18434 }
18435 
18436 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)18437 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
18438     PyErr_Format(PyExc_ValueError,
18439                  "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
18440 }
18441 
18442 /* UnpackItemEndCheck */
__Pyx_IternextUnpackEndCheck(PyObject * retval,Py_ssize_t expected)18443 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
18444     if (unlikely(retval)) {
18445         Py_DECREF(retval);
18446         __Pyx_RaiseTooManyValuesError(expected);
18447         return -1;
18448     } else {
18449         return __Pyx_IterFinish();
18450     }
18451     return 0;
18452 }
18453 
18454 /* RaiseNoneIterError */
__Pyx_RaiseNoneNotIterableError(void)18455 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
18456     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
18457 }
18458 
18459 /* UnpackTupleError */
__Pyx_UnpackTupleError(PyObject * t,Py_ssize_t index)18460 static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
18461     if (t == Py_None) {
18462       __Pyx_RaiseNoneNotIterableError();
18463     } else if (PyTuple_GET_SIZE(t) < index) {
18464       __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
18465     } else {
18466       __Pyx_RaiseTooManyValuesError(index);
18467     }
18468 }
18469 
18470 /* UnpackTuple2 */
__Pyx_unpack_tuple2_exact(PyObject * tuple,PyObject ** pvalue1,PyObject ** pvalue2,int decref_tuple)18471 static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
18472         PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
18473     PyObject *value1 = NULL, *value2 = NULL;
18474 #if CYTHON_COMPILING_IN_PYPY
18475     value1 = PySequence_ITEM(tuple, 0);  if (unlikely(!value1)) goto bad;
18476     value2 = PySequence_ITEM(tuple, 1);  if (unlikely(!value2)) goto bad;
18477 #else
18478     value1 = PyTuple_GET_ITEM(tuple, 0);  Py_INCREF(value1);
18479     value2 = PyTuple_GET_ITEM(tuple, 1);  Py_INCREF(value2);
18480 #endif
18481     if (decref_tuple) {
18482         Py_DECREF(tuple);
18483     }
18484     *pvalue1 = value1;
18485     *pvalue2 = value2;
18486     return 0;
18487 #if CYTHON_COMPILING_IN_PYPY
18488 bad:
18489     Py_XDECREF(value1);
18490     Py_XDECREF(value2);
18491     if (decref_tuple) { Py_XDECREF(tuple); }
18492     return -1;
18493 #endif
18494 }
__Pyx_unpack_tuple2_generic(PyObject * tuple,PyObject ** pvalue1,PyObject ** pvalue2,int has_known_size,int decref_tuple)18495 static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
18496                                        int has_known_size, int decref_tuple) {
18497     Py_ssize_t index;
18498     PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
18499     iternextfunc iternext;
18500     iter = PyObject_GetIter(tuple);
18501     if (unlikely(!iter)) goto bad;
18502     if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
18503     iternext = Py_TYPE(iter)->tp_iternext;
18504     value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
18505     value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
18506     if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
18507     Py_DECREF(iter);
18508     *pvalue1 = value1;
18509     *pvalue2 = value2;
18510     return 0;
18511 unpacking_failed:
18512     if (!has_known_size && __Pyx_IterFinish() == 0)
18513         __Pyx_RaiseNeedMoreValuesError(index);
18514 bad:
18515     Py_XDECREF(iter);
18516     Py_XDECREF(value1);
18517     Py_XDECREF(value2);
18518     if (decref_tuple) { Py_XDECREF(tuple); }
18519     return -1;
18520 }
18521 
18522 /* dict_iter */
__Pyx_dict_iterator(PyObject * iterable,int is_dict,PyObject * method_name,Py_ssize_t * p_orig_length,int * p_source_is_dict)18523 static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
18524                                                    Py_ssize_t* p_orig_length, int* p_source_is_dict) {
18525     is_dict = is_dict || likely(PyDict_CheckExact(iterable));
18526     *p_source_is_dict = is_dict;
18527     if (is_dict) {
18528 #if !CYTHON_COMPILING_IN_PYPY
18529         *p_orig_length = PyDict_Size(iterable);
18530         Py_INCREF(iterable);
18531         return iterable;
18532 #elif PY_MAJOR_VERSION >= 3
18533         static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
18534         PyObject **pp = NULL;
18535         if (method_name) {
18536             const char *name = PyUnicode_AsUTF8(method_name);
18537             if (strcmp(name, "iteritems") == 0) pp = &py_items;
18538             else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
18539             else if (strcmp(name, "itervalues") == 0) pp = &py_values;
18540             if (pp) {
18541                 if (!*pp) {
18542                     *pp = PyUnicode_FromString(name + 4);
18543                     if (!*pp)
18544                         return NULL;
18545                 }
18546                 method_name = *pp;
18547             }
18548         }
18549 #endif
18550     }
18551     *p_orig_length = 0;
18552     if (method_name) {
18553         PyObject* iter;
18554         iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
18555         if (!iterable)
18556             return NULL;
18557 #if !CYTHON_COMPILING_IN_PYPY
18558         if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
18559             return iterable;
18560 #endif
18561         iter = PyObject_GetIter(iterable);
18562         Py_DECREF(iterable);
18563         return iter;
18564     }
18565     return PyObject_GetIter(iterable);
18566 }
__Pyx_dict_iter_next(PyObject * iter_obj,CYTHON_NCP_UNUSED Py_ssize_t orig_length,CYTHON_NCP_UNUSED Py_ssize_t * ppos,PyObject ** pkey,PyObject ** pvalue,PyObject ** pitem,int source_is_dict)18567 static CYTHON_INLINE int __Pyx_dict_iter_next(
18568         PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
18569         PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
18570     PyObject* next_item;
18571 #if !CYTHON_COMPILING_IN_PYPY
18572     if (source_is_dict) {
18573         PyObject *key, *value;
18574         if (unlikely(orig_length != PyDict_Size(iter_obj))) {
18575             PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
18576             return -1;
18577         }
18578         if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
18579             return 0;
18580         }
18581         if (pitem) {
18582             PyObject* tuple = PyTuple_New(2);
18583             if (unlikely(!tuple)) {
18584                 return -1;
18585             }
18586             Py_INCREF(key);
18587             Py_INCREF(value);
18588             PyTuple_SET_ITEM(tuple, 0, key);
18589             PyTuple_SET_ITEM(tuple, 1, value);
18590             *pitem = tuple;
18591         } else {
18592             if (pkey) {
18593                 Py_INCREF(key);
18594                 *pkey = key;
18595             }
18596             if (pvalue) {
18597                 Py_INCREF(value);
18598                 *pvalue = value;
18599             }
18600         }
18601         return 1;
18602     } else if (PyTuple_CheckExact(iter_obj)) {
18603         Py_ssize_t pos = *ppos;
18604         if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
18605         *ppos = pos + 1;
18606         next_item = PyTuple_GET_ITEM(iter_obj, pos);
18607         Py_INCREF(next_item);
18608     } else if (PyList_CheckExact(iter_obj)) {
18609         Py_ssize_t pos = *ppos;
18610         if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
18611         *ppos = pos + 1;
18612         next_item = PyList_GET_ITEM(iter_obj, pos);
18613         Py_INCREF(next_item);
18614     } else
18615 #endif
18616     {
18617         next_item = PyIter_Next(iter_obj);
18618         if (unlikely(!next_item)) {
18619             return __Pyx_IterFinish();
18620         }
18621     }
18622     if (pitem) {
18623         *pitem = next_item;
18624     } else if (pkey && pvalue) {
18625         if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
18626             return -1;
18627     } else if (pkey) {
18628         *pkey = next_item;
18629     } else {
18630         *pvalue = next_item;
18631     }
18632     return 1;
18633 }
18634 
18635 /* PyDictVersioning */
18636 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)18637 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
18638     PyObject *dict = Py_TYPE(obj)->tp_dict;
18639     return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
18640 }
__Pyx_get_object_dict_version(PyObject * obj)18641 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
18642     PyObject **dictptr = NULL;
18643     Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
18644     if (offset) {
18645 #if CYTHON_COMPILING_IN_CPYTHON
18646         dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
18647 #else
18648         dictptr = _PyObject_GetDictPtr(obj);
18649 #endif
18650     }
18651     return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
18652 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)18653 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
18654     PyObject *dict = Py_TYPE(obj)->tp_dict;
18655     if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
18656         return 0;
18657     return obj_dict_version == __Pyx_get_object_dict_version(obj);
18658 }
18659 #endif
18660 
18661 /* GetModuleGlobalName */
18662 #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)18663 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
18664 #else
18665 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
18666 #endif
18667 {
18668     PyObject *result;
18669 #if !CYTHON_AVOID_BORROWED_REFS
18670 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
18671     result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
18672     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
18673     if (likely(result)) {
18674         return __Pyx_NewRef(result);
18675     } else if (unlikely(PyErr_Occurred())) {
18676         return NULL;
18677     }
18678 #else
18679     result = PyDict_GetItem(__pyx_d, name);
18680     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
18681     if (likely(result)) {
18682         return __Pyx_NewRef(result);
18683     }
18684 #endif
18685 #else
18686     result = PyObject_GetItem(__pyx_d, name);
18687     __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
18688     if (likely(result)) {
18689         return __Pyx_NewRef(result);
18690     }
18691     PyErr_Clear();
18692 #endif
18693     return __Pyx_GetBuiltinName(name);
18694 }
18695 
18696 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)18697 static void __Pyx_RaiseArgtupleInvalid(
18698     const char* func_name,
18699     int exact,
18700     Py_ssize_t num_min,
18701     Py_ssize_t num_max,
18702     Py_ssize_t num_found)
18703 {
18704     Py_ssize_t num_expected;
18705     const char *more_or_less;
18706     if (num_found < num_min) {
18707         num_expected = num_min;
18708         more_or_less = "at least";
18709     } else {
18710         num_expected = num_max;
18711         more_or_less = "at most";
18712     }
18713     if (exact) {
18714         more_or_less = "exactly";
18715     }
18716     PyErr_Format(PyExc_TypeError,
18717                  "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
18718                  func_name, more_or_less, num_expected,
18719                  (num_expected == 1) ? "" : "s", num_found);
18720 }
18721 
18722 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)18723 static void __Pyx_RaiseDoubleKeywordsError(
18724     const char* func_name,
18725     PyObject* kw_name)
18726 {
18727     PyErr_Format(PyExc_TypeError,
18728         #if PY_MAJOR_VERSION >= 3
18729         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
18730         #else
18731         "%s() got multiple values for keyword argument '%s'", func_name,
18732         PyString_AsString(kw_name));
18733         #endif
18734 }
18735 
18736 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)18737 static int __Pyx_ParseOptionalKeywords(
18738     PyObject *kwds,
18739     PyObject **argnames[],
18740     PyObject *kwds2,
18741     PyObject *values[],
18742     Py_ssize_t num_pos_args,
18743     const char* function_name)
18744 {
18745     PyObject *key = 0, *value = 0;
18746     Py_ssize_t pos = 0;
18747     PyObject*** name;
18748     PyObject*** first_kw_arg = argnames + num_pos_args;
18749     while (PyDict_Next(kwds, &pos, &key, &value)) {
18750         name = first_kw_arg;
18751         while (*name && (**name != key)) name++;
18752         if (*name) {
18753             values[name-argnames] = value;
18754             continue;
18755         }
18756         name = first_kw_arg;
18757         #if PY_MAJOR_VERSION < 3
18758         if (likely(PyString_Check(key))) {
18759             while (*name) {
18760                 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
18761                         && _PyString_Eq(**name, key)) {
18762                     values[name-argnames] = value;
18763                     break;
18764                 }
18765                 name++;
18766             }
18767             if (*name) continue;
18768             else {
18769                 PyObject*** argname = argnames;
18770                 while (argname != first_kw_arg) {
18771                     if ((**argname == key) || (
18772                             (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
18773                              && _PyString_Eq(**argname, key))) {
18774                         goto arg_passed_twice;
18775                     }
18776                     argname++;
18777                 }
18778             }
18779         } else
18780         #endif
18781         if (likely(PyUnicode_Check(key))) {
18782             while (*name) {
18783                 int cmp = (**name == key) ? 0 :
18784                 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
18785                     (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
18786                 #endif
18787                     PyUnicode_Compare(**name, key);
18788                 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
18789                 if (cmp == 0) {
18790                     values[name-argnames] = value;
18791                     break;
18792                 }
18793                 name++;
18794             }
18795             if (*name) continue;
18796             else {
18797                 PyObject*** argname = argnames;
18798                 while (argname != first_kw_arg) {
18799                     int cmp = (**argname == key) ? 0 :
18800                     #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
18801                         (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
18802                     #endif
18803                         PyUnicode_Compare(**argname, key);
18804                     if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
18805                     if (cmp == 0) goto arg_passed_twice;
18806                     argname++;
18807                 }
18808             }
18809         } else
18810             goto invalid_keyword_type;
18811         if (kwds2) {
18812             if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
18813         } else {
18814             goto invalid_keyword;
18815         }
18816     }
18817     return 0;
18818 arg_passed_twice:
18819     __Pyx_RaiseDoubleKeywordsError(function_name, key);
18820     goto bad;
18821 invalid_keyword_type:
18822     PyErr_Format(PyExc_TypeError,
18823         "%.200s() keywords must be strings", function_name);
18824     goto bad;
18825 invalid_keyword:
18826     PyErr_Format(PyExc_TypeError,
18827     #if PY_MAJOR_VERSION < 3
18828         "%.200s() got an unexpected keyword argument '%.200s'",
18829         function_name, PyString_AsString(key));
18830     #else
18831         "%s() got an unexpected keyword argument '%U'",
18832         function_name, key);
18833     #endif
18834 bad:
18835     return -1;
18836 }
18837 
18838 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)18839 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
18840     PyObject *args, *result = NULL;
18841     #if CYTHON_FAST_PYCALL
18842     if (PyFunction_Check(function)) {
18843         PyObject *args[2] = {arg1, arg2};
18844         return __Pyx_PyFunction_FastCall(function, args, 2);
18845     }
18846     #endif
18847     #if CYTHON_FAST_PYCCALL
18848     if (__Pyx_PyFastCFunction_Check(function)) {
18849         PyObject *args[2] = {arg1, arg2};
18850         return __Pyx_PyCFunction_FastCall(function, args, 2);
18851     }
18852     #endif
18853     args = PyTuple_New(2);
18854     if (unlikely(!args)) goto done;
18855     Py_INCREF(arg1);
18856     PyTuple_SET_ITEM(args, 0, arg1);
18857     Py_INCREF(arg2);
18858     PyTuple_SET_ITEM(args, 1, arg2);
18859     Py_INCREF(function);
18860     result = __Pyx_PyObject_Call(function, args, NULL);
18861     Py_DECREF(args);
18862     Py_DECREF(function);
18863 done:
18864     return result;
18865 }
18866 
18867 /* PyErrFetchRestore */
18868 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)18869 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
18870     PyObject *tmp_type, *tmp_value, *tmp_tb;
18871     tmp_type = tstate->curexc_type;
18872     tmp_value = tstate->curexc_value;
18873     tmp_tb = tstate->curexc_traceback;
18874     tstate->curexc_type = type;
18875     tstate->curexc_value = value;
18876     tstate->curexc_traceback = tb;
18877     Py_XDECREF(tmp_type);
18878     Py_XDECREF(tmp_value);
18879     Py_XDECREF(tmp_tb);
18880 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)18881 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
18882     *type = tstate->curexc_type;
18883     *value = tstate->curexc_value;
18884     *tb = tstate->curexc_traceback;
18885     tstate->curexc_type = 0;
18886     tstate->curexc_value = 0;
18887     tstate->curexc_traceback = 0;
18888 }
18889 #endif
18890 
18891 /* RaiseException */
18892 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)18893 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
18894                         CYTHON_UNUSED PyObject *cause) {
18895     __Pyx_PyThreadState_declare
18896     Py_XINCREF(type);
18897     if (!value || value == Py_None)
18898         value = NULL;
18899     else
18900         Py_INCREF(value);
18901     if (!tb || tb == Py_None)
18902         tb = NULL;
18903     else {
18904         Py_INCREF(tb);
18905         if (!PyTraceBack_Check(tb)) {
18906             PyErr_SetString(PyExc_TypeError,
18907                 "raise: arg 3 must be a traceback or None");
18908             goto raise_error;
18909         }
18910     }
18911     if (PyType_Check(type)) {
18912 #if CYTHON_COMPILING_IN_PYPY
18913         if (!value) {
18914             Py_INCREF(Py_None);
18915             value = Py_None;
18916         }
18917 #endif
18918         PyErr_NormalizeException(&type, &value, &tb);
18919     } else {
18920         if (value) {
18921             PyErr_SetString(PyExc_TypeError,
18922                 "instance exception may not have a separate value");
18923             goto raise_error;
18924         }
18925         value = type;
18926         type = (PyObject*) Py_TYPE(type);
18927         Py_INCREF(type);
18928         if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
18929             PyErr_SetString(PyExc_TypeError,
18930                 "raise: exception class must be a subclass of BaseException");
18931             goto raise_error;
18932         }
18933     }
18934     __Pyx_PyThreadState_assign
18935     __Pyx_ErrRestore(type, value, tb);
18936     return;
18937 raise_error:
18938     Py_XDECREF(value);
18939     Py_XDECREF(type);
18940     Py_XDECREF(tb);
18941     return;
18942 }
18943 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)18944 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
18945     PyObject* owned_instance = NULL;
18946     if (tb == Py_None) {
18947         tb = 0;
18948     } else if (tb && !PyTraceBack_Check(tb)) {
18949         PyErr_SetString(PyExc_TypeError,
18950             "raise: arg 3 must be a traceback or None");
18951         goto bad;
18952     }
18953     if (value == Py_None)
18954         value = 0;
18955     if (PyExceptionInstance_Check(type)) {
18956         if (value) {
18957             PyErr_SetString(PyExc_TypeError,
18958                 "instance exception may not have a separate value");
18959             goto bad;
18960         }
18961         value = type;
18962         type = (PyObject*) Py_TYPE(value);
18963     } else if (PyExceptionClass_Check(type)) {
18964         PyObject *instance_class = NULL;
18965         if (value && PyExceptionInstance_Check(value)) {
18966             instance_class = (PyObject*) Py_TYPE(value);
18967             if (instance_class != type) {
18968                 int is_subclass = PyObject_IsSubclass(instance_class, type);
18969                 if (!is_subclass) {
18970                     instance_class = NULL;
18971                 } else if (unlikely(is_subclass == -1)) {
18972                     goto bad;
18973                 } else {
18974                     type = instance_class;
18975                 }
18976             }
18977         }
18978         if (!instance_class) {
18979             PyObject *args;
18980             if (!value)
18981                 args = PyTuple_New(0);
18982             else if (PyTuple_Check(value)) {
18983                 Py_INCREF(value);
18984                 args = value;
18985             } else
18986                 args = PyTuple_Pack(1, value);
18987             if (!args)
18988                 goto bad;
18989             owned_instance = PyObject_Call(type, args, NULL);
18990             Py_DECREF(args);
18991             if (!owned_instance)
18992                 goto bad;
18993             value = owned_instance;
18994             if (!PyExceptionInstance_Check(value)) {
18995                 PyErr_Format(PyExc_TypeError,
18996                              "calling %R should have returned an instance of "
18997                              "BaseException, not %R",
18998                              type, Py_TYPE(value));
18999                 goto bad;
19000             }
19001         }
19002     } else {
19003         PyErr_SetString(PyExc_TypeError,
19004             "raise: exception class must be a subclass of BaseException");
19005         goto bad;
19006     }
19007     if (cause) {
19008         PyObject *fixed_cause;
19009         if (cause == Py_None) {
19010             fixed_cause = NULL;
19011         } else if (PyExceptionClass_Check(cause)) {
19012             fixed_cause = PyObject_CallObject(cause, NULL);
19013             if (fixed_cause == NULL)
19014                 goto bad;
19015         } else if (PyExceptionInstance_Check(cause)) {
19016             fixed_cause = cause;
19017             Py_INCREF(fixed_cause);
19018         } else {
19019             PyErr_SetString(PyExc_TypeError,
19020                             "exception causes must derive from "
19021                             "BaseException");
19022             goto bad;
19023         }
19024         PyException_SetCause(value, fixed_cause);
19025     }
19026     PyErr_SetObject(type, value);
19027     if (tb) {
19028 #if CYTHON_COMPILING_IN_PYPY
19029         PyObject *tmp_type, *tmp_value, *tmp_tb;
19030         PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
19031         Py_INCREF(tb);
19032         PyErr_Restore(tmp_type, tmp_value, tb);
19033         Py_XDECREF(tmp_tb);
19034 #else
19035         PyThreadState *tstate = __Pyx_PyThreadState_Current;
19036         PyObject* tmp_tb = tstate->curexc_traceback;
19037         if (tb != tmp_tb) {
19038             Py_INCREF(tb);
19039             tstate->curexc_traceback = tb;
19040             Py_XDECREF(tmp_tb);
19041         }
19042 #endif
19043     }
19044 bad:
19045     Py_XDECREF(owned_instance);
19046     return;
19047 }
19048 #endif
19049 
19050 /* PyIntCompare */
__Pyx_PyInt_NeObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,CYTHON_UNUSED long inplace)19051 static CYTHON_INLINE PyObject* __Pyx_PyInt_NeObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
19052     if (op1 == op2) {
19053         Py_RETURN_FALSE;
19054     }
19055     #if PY_MAJOR_VERSION < 3
19056     if (likely(PyInt_CheckExact(op1))) {
19057         const long b = intval;
19058         long a = PyInt_AS_LONG(op1);
19059         if (a != b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
19060     }
19061     #endif
19062     #if CYTHON_USE_PYLONG_INTERNALS
19063     if (likely(PyLong_CheckExact(op1))) {
19064         int unequal;
19065         unsigned long uintval;
19066         Py_ssize_t size = Py_SIZE(op1);
19067         const digit* digits = ((PyLongObject*)op1)->ob_digit;
19068         if (intval == 0) {
19069             if (size != 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
19070         } else if (intval < 0) {
19071             if (size >= 0)
19072                 Py_RETURN_TRUE;
19073             intval = -intval;
19074             size = -size;
19075         } else {
19076             if (size <= 0)
19077                 Py_RETURN_TRUE;
19078         }
19079         uintval = (unsigned long) intval;
19080 #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
19081         if (uintval >> (PyLong_SHIFT * 4)) {
19082             unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
19083                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
19084         } else
19085 #endif
19086 #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
19087         if (uintval >> (PyLong_SHIFT * 3)) {
19088             unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
19089                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
19090         } else
19091 #endif
19092 #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
19093         if (uintval >> (PyLong_SHIFT * 2)) {
19094             unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
19095                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
19096         } else
19097 #endif
19098 #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
19099         if (uintval >> (PyLong_SHIFT * 1)) {
19100             unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
19101                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
19102         } else
19103 #endif
19104             unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
19105         if (unequal != 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
19106     }
19107     #endif
19108     if (PyFloat_CheckExact(op1)) {
19109         const long b = intval;
19110         double a = PyFloat_AS_DOUBLE(op1);
19111         if ((double)a != (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
19112     }
19113     return (
19114         PyObject_RichCompare(op1, op2, Py_NE));
19115 }
19116 
19117 /* ExtTypeTest */
__Pyx_TypeTest(PyObject * obj,PyTypeObject * type)19118 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
19119     if (unlikely(!type)) {
19120         PyErr_SetString(PyExc_SystemError, "Missing type object");
19121         return 0;
19122     }
19123     if (likely(__Pyx_TypeCheck(obj, type)))
19124         return 1;
19125     PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
19126                  Py_TYPE(obj)->tp_name, type->tp_name);
19127     return 0;
19128 }
19129 
19130 /* BytesEquals */
__Pyx_PyBytes_Equals(PyObject * s1,PyObject * s2,int equals)19131 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
19132 #if CYTHON_COMPILING_IN_PYPY
19133     return PyObject_RichCompareBool(s1, s2, equals);
19134 #else
19135     if (s1 == s2) {
19136         return (equals == Py_EQ);
19137     } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
19138         const char *ps1, *ps2;
19139         Py_ssize_t length = PyBytes_GET_SIZE(s1);
19140         if (length != PyBytes_GET_SIZE(s2))
19141             return (equals == Py_NE);
19142         ps1 = PyBytes_AS_STRING(s1);
19143         ps2 = PyBytes_AS_STRING(s2);
19144         if (ps1[0] != ps2[0]) {
19145             return (equals == Py_NE);
19146         } else if (length == 1) {
19147             return (equals == Py_EQ);
19148         } else {
19149             int result;
19150 #if CYTHON_USE_UNICODE_INTERNALS
19151             Py_hash_t hash1, hash2;
19152             hash1 = ((PyBytesObject*)s1)->ob_shash;
19153             hash2 = ((PyBytesObject*)s2)->ob_shash;
19154             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
19155                 return (equals == Py_NE);
19156             }
19157 #endif
19158             result = memcmp(ps1, ps2, (size_t)length);
19159             return (equals == Py_EQ) ? (result == 0) : (result != 0);
19160         }
19161     } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
19162         return (equals == Py_NE);
19163     } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
19164         return (equals == Py_NE);
19165     } else {
19166         int result;
19167         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
19168         if (!py_result)
19169             return -1;
19170         result = __Pyx_PyObject_IsTrue(py_result);
19171         Py_DECREF(py_result);
19172         return result;
19173     }
19174 #endif
19175 }
19176 
19177 /* UnicodeEquals */
__Pyx_PyUnicode_Equals(PyObject * s1,PyObject * s2,int equals)19178 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
19179 #if CYTHON_COMPILING_IN_PYPY
19180     return PyObject_RichCompareBool(s1, s2, equals);
19181 #else
19182 #if PY_MAJOR_VERSION < 3
19183     PyObject* owned_ref = NULL;
19184 #endif
19185     int s1_is_unicode, s2_is_unicode;
19186     if (s1 == s2) {
19187         goto return_eq;
19188     }
19189     s1_is_unicode = PyUnicode_CheckExact(s1);
19190     s2_is_unicode = PyUnicode_CheckExact(s2);
19191 #if PY_MAJOR_VERSION < 3
19192     if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
19193         owned_ref = PyUnicode_FromObject(s2);
19194         if (unlikely(!owned_ref))
19195             return -1;
19196         s2 = owned_ref;
19197         s2_is_unicode = 1;
19198     } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
19199         owned_ref = PyUnicode_FromObject(s1);
19200         if (unlikely(!owned_ref))
19201             return -1;
19202         s1 = owned_ref;
19203         s1_is_unicode = 1;
19204     } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
19205         return __Pyx_PyBytes_Equals(s1, s2, equals);
19206     }
19207 #endif
19208     if (s1_is_unicode & s2_is_unicode) {
19209         Py_ssize_t length;
19210         int kind;
19211         void *data1, *data2;
19212         if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
19213             return -1;
19214         length = __Pyx_PyUnicode_GET_LENGTH(s1);
19215         if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
19216             goto return_ne;
19217         }
19218 #if CYTHON_USE_UNICODE_INTERNALS
19219         {
19220             Py_hash_t hash1, hash2;
19221         #if CYTHON_PEP393_ENABLED
19222             hash1 = ((PyASCIIObject*)s1)->hash;
19223             hash2 = ((PyASCIIObject*)s2)->hash;
19224         #else
19225             hash1 = ((PyUnicodeObject*)s1)->hash;
19226             hash2 = ((PyUnicodeObject*)s2)->hash;
19227         #endif
19228             if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
19229                 goto return_ne;
19230             }
19231         }
19232 #endif
19233         kind = __Pyx_PyUnicode_KIND(s1);
19234         if (kind != __Pyx_PyUnicode_KIND(s2)) {
19235             goto return_ne;
19236         }
19237         data1 = __Pyx_PyUnicode_DATA(s1);
19238         data2 = __Pyx_PyUnicode_DATA(s2);
19239         if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
19240             goto return_ne;
19241         } else if (length == 1) {
19242             goto return_eq;
19243         } else {
19244             int result = memcmp(data1, data2, (size_t)(length * kind));
19245             #if PY_MAJOR_VERSION < 3
19246             Py_XDECREF(owned_ref);
19247             #endif
19248             return (equals == Py_EQ) ? (result == 0) : (result != 0);
19249         }
19250     } else if ((s1 == Py_None) & s2_is_unicode) {
19251         goto return_ne;
19252     } else if ((s2 == Py_None) & s1_is_unicode) {
19253         goto return_ne;
19254     } else {
19255         int result;
19256         PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
19257         #if PY_MAJOR_VERSION < 3
19258         Py_XDECREF(owned_ref);
19259         #endif
19260         if (!py_result)
19261             return -1;
19262         result = __Pyx_PyObject_IsTrue(py_result);
19263         Py_DECREF(py_result);
19264         return result;
19265     }
19266 return_eq:
19267     #if PY_MAJOR_VERSION < 3
19268     Py_XDECREF(owned_ref);
19269     #endif
19270     return (equals == Py_EQ);
19271 return_ne:
19272     #if PY_MAJOR_VERSION < 3
19273     Py_XDECREF(owned_ref);
19274     #endif
19275     return (equals == Py_NE);
19276 #endif
19277 }
19278 
19279 /* PyIntCompare */
__Pyx_PyInt_EqObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,CYTHON_UNUSED long inplace)19280 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
19281     if (op1 == op2) {
19282         Py_RETURN_TRUE;
19283     }
19284     #if PY_MAJOR_VERSION < 3
19285     if (likely(PyInt_CheckExact(op1))) {
19286         const long b = intval;
19287         long a = PyInt_AS_LONG(op1);
19288         if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
19289     }
19290     #endif
19291     #if CYTHON_USE_PYLONG_INTERNALS
19292     if (likely(PyLong_CheckExact(op1))) {
19293         int unequal;
19294         unsigned long uintval;
19295         Py_ssize_t size = Py_SIZE(op1);
19296         const digit* digits = ((PyLongObject*)op1)->ob_digit;
19297         if (intval == 0) {
19298             if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
19299         } else if (intval < 0) {
19300             if (size >= 0)
19301                 Py_RETURN_FALSE;
19302             intval = -intval;
19303             size = -size;
19304         } else {
19305             if (size <= 0)
19306                 Py_RETURN_FALSE;
19307         }
19308         uintval = (unsigned long) intval;
19309 #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
19310         if (uintval >> (PyLong_SHIFT * 4)) {
19311             unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
19312                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
19313         } else
19314 #endif
19315 #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
19316         if (uintval >> (PyLong_SHIFT * 3)) {
19317             unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
19318                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
19319         } else
19320 #endif
19321 #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
19322         if (uintval >> (PyLong_SHIFT * 2)) {
19323             unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
19324                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
19325         } else
19326 #endif
19327 #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
19328         if (uintval >> (PyLong_SHIFT * 1)) {
19329             unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
19330                  | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
19331         } else
19332 #endif
19333             unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
19334         if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
19335     }
19336     #endif
19337     if (PyFloat_CheckExact(op1)) {
19338         const long b = intval;
19339         double a = PyFloat_AS_DOUBLE(op1);
19340         if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
19341     }
19342     return (
19343         PyObject_RichCompare(op1, op2, Py_EQ));
19344 }
19345 
19346 /* GetException */
19347 #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)19348 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
19349 #else
19350 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
19351 #endif
19352 {
19353     PyObject *local_type, *local_value, *local_tb;
19354 #if CYTHON_FAST_THREAD_STATE
19355     PyObject *tmp_type, *tmp_value, *tmp_tb;
19356     local_type = tstate->curexc_type;
19357     local_value = tstate->curexc_value;
19358     local_tb = tstate->curexc_traceback;
19359     tstate->curexc_type = 0;
19360     tstate->curexc_value = 0;
19361     tstate->curexc_traceback = 0;
19362 #else
19363     PyErr_Fetch(&local_type, &local_value, &local_tb);
19364 #endif
19365     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
19366 #if CYTHON_FAST_THREAD_STATE
19367     if (unlikely(tstate->curexc_type))
19368 #else
19369     if (unlikely(PyErr_Occurred()))
19370 #endif
19371         goto bad;
19372     #if PY_MAJOR_VERSION >= 3
19373     if (local_tb) {
19374         if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
19375             goto bad;
19376     }
19377     #endif
19378     Py_XINCREF(local_tb);
19379     Py_XINCREF(local_type);
19380     Py_XINCREF(local_value);
19381     *type = local_type;
19382     *value = local_value;
19383     *tb = local_tb;
19384 #if CYTHON_FAST_THREAD_STATE
19385     #if CYTHON_USE_EXC_INFO_STACK
19386     {
19387         _PyErr_StackItem *exc_info = tstate->exc_info;
19388         tmp_type = exc_info->exc_type;
19389         tmp_value = exc_info->exc_value;
19390         tmp_tb = exc_info->exc_traceback;
19391         exc_info->exc_type = local_type;
19392         exc_info->exc_value = local_value;
19393         exc_info->exc_traceback = local_tb;
19394     }
19395     #else
19396     tmp_type = tstate->exc_type;
19397     tmp_value = tstate->exc_value;
19398     tmp_tb = tstate->exc_traceback;
19399     tstate->exc_type = local_type;
19400     tstate->exc_value = local_value;
19401     tstate->exc_traceback = local_tb;
19402     #endif
19403     Py_XDECREF(tmp_type);
19404     Py_XDECREF(tmp_value);
19405     Py_XDECREF(tmp_tb);
19406 #else
19407     PyErr_SetExcInfo(local_type, local_value, local_tb);
19408 #endif
19409     return 0;
19410 bad:
19411     *type = 0;
19412     *value = 0;
19413     *tb = 0;
19414     Py_XDECREF(local_type);
19415     Py_XDECREF(local_value);
19416     Py_XDECREF(local_tb);
19417     return -1;
19418 }
19419 
19420 /* SwapException */
19421 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSwap(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)19422 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
19423     PyObject *tmp_type, *tmp_value, *tmp_tb;
19424     #if CYTHON_USE_EXC_INFO_STACK
19425     _PyErr_StackItem *exc_info = tstate->exc_info;
19426     tmp_type = exc_info->exc_type;
19427     tmp_value = exc_info->exc_value;
19428     tmp_tb = exc_info->exc_traceback;
19429     exc_info->exc_type = *type;
19430     exc_info->exc_value = *value;
19431     exc_info->exc_traceback = *tb;
19432     #else
19433     tmp_type = tstate->exc_type;
19434     tmp_value = tstate->exc_value;
19435     tmp_tb = tstate->exc_traceback;
19436     tstate->exc_type = *type;
19437     tstate->exc_value = *value;
19438     tstate->exc_traceback = *tb;
19439     #endif
19440     *type = tmp_type;
19441     *value = tmp_value;
19442     *tb = tmp_tb;
19443 }
19444 #else
__Pyx_ExceptionSwap(PyObject ** type,PyObject ** value,PyObject ** tb)19445 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
19446     PyObject *tmp_type, *tmp_value, *tmp_tb;
19447     PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
19448     PyErr_SetExcInfo(*type, *value, *tb);
19449     *type = tmp_type;
19450     *value = tmp_value;
19451     *tb = tmp_tb;
19452 }
19453 #endif
19454 
19455 /* GetTopmostException */
19456 #if CYTHON_USE_EXC_INFO_STACK
19457 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)19458 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
19459 {
19460     _PyErr_StackItem *exc_info = tstate->exc_info;
19461     while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
19462            exc_info->previous_item != NULL)
19463     {
19464         exc_info = exc_info->previous_item;
19465     }
19466     return exc_info;
19467 }
19468 #endif
19469 
19470 /* SaveResetException */
19471 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)19472 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
19473     #if CYTHON_USE_EXC_INFO_STACK
19474     _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
19475     *type = exc_info->exc_type;
19476     *value = exc_info->exc_value;
19477     *tb = exc_info->exc_traceback;
19478     #else
19479     *type = tstate->exc_type;
19480     *value = tstate->exc_value;
19481     *tb = tstate->exc_traceback;
19482     #endif
19483     Py_XINCREF(*type);
19484     Py_XINCREF(*value);
19485     Py_XINCREF(*tb);
19486 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)19487 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
19488     PyObject *tmp_type, *tmp_value, *tmp_tb;
19489     #if CYTHON_USE_EXC_INFO_STACK
19490     _PyErr_StackItem *exc_info = tstate->exc_info;
19491     tmp_type = exc_info->exc_type;
19492     tmp_value = exc_info->exc_value;
19493     tmp_tb = exc_info->exc_traceback;
19494     exc_info->exc_type = type;
19495     exc_info->exc_value = value;
19496     exc_info->exc_traceback = tb;
19497     #else
19498     tmp_type = tstate->exc_type;
19499     tmp_value = tstate->exc_value;
19500     tmp_tb = tstate->exc_traceback;
19501     tstate->exc_type = type;
19502     tstate->exc_value = value;
19503     tstate->exc_traceback = tb;
19504     #endif
19505     Py_XDECREF(tmp_type);
19506     Py_XDECREF(tmp_value);
19507     Py_XDECREF(tmp_tb);
19508 }
19509 #endif
19510 
19511 /* None */
__Pyx_RaiseClosureNameError(const char * varname)19512 static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
19513     PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
19514 }
19515 
19516 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)19517 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
19518     PyObject *r;
19519     if (!j) return NULL;
19520     r = PyObject_GetItem(o, j);
19521     Py_DECREF(j);
19522     return r;
19523 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)19524 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
19525                                                               CYTHON_NCP_UNUSED int wraparound,
19526                                                               CYTHON_NCP_UNUSED int boundscheck) {
19527 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
19528     Py_ssize_t wrapped_i = i;
19529     if (wraparound & unlikely(i < 0)) {
19530         wrapped_i += PyList_GET_SIZE(o);
19531     }
19532     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
19533         PyObject *r = PyList_GET_ITEM(o, wrapped_i);
19534         Py_INCREF(r);
19535         return r;
19536     }
19537     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
19538 #else
19539     return PySequence_GetItem(o, i);
19540 #endif
19541 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)19542 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
19543                                                               CYTHON_NCP_UNUSED int wraparound,
19544                                                               CYTHON_NCP_UNUSED int boundscheck) {
19545 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
19546     Py_ssize_t wrapped_i = i;
19547     if (wraparound & unlikely(i < 0)) {
19548         wrapped_i += PyTuple_GET_SIZE(o);
19549     }
19550     if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
19551         PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
19552         Py_INCREF(r);
19553         return r;
19554     }
19555     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
19556 #else
19557     return PySequence_GetItem(o, i);
19558 #endif
19559 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)19560 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
19561                                                      CYTHON_NCP_UNUSED int wraparound,
19562                                                      CYTHON_NCP_UNUSED int boundscheck) {
19563 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
19564     if (is_list || PyList_CheckExact(o)) {
19565         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
19566         if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
19567             PyObject *r = PyList_GET_ITEM(o, n);
19568             Py_INCREF(r);
19569             return r;
19570         }
19571     }
19572     else if (PyTuple_CheckExact(o)) {
19573         Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
19574         if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
19575             PyObject *r = PyTuple_GET_ITEM(o, n);
19576             Py_INCREF(r);
19577             return r;
19578         }
19579     } else {
19580         PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
19581         if (likely(m && m->sq_item)) {
19582             if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
19583                 Py_ssize_t l = m->sq_length(o);
19584                 if (likely(l >= 0)) {
19585                     i += l;
19586                 } else {
19587                     if (!PyErr_ExceptionMatches(PyExc_OverflowError))
19588                         return NULL;
19589                     PyErr_Clear();
19590                 }
19591             }
19592             return m->sq_item(o, i);
19593         }
19594     }
19595 #else
19596     if (is_list || PySequence_Check(o)) {
19597         return PySequence_GetItem(o, i);
19598     }
19599 #endif
19600     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
19601 }
19602 
19603 /* DictGetItem */
19604 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
__Pyx_PyDict_GetItem(PyObject * d,PyObject * key)19605 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
19606     PyObject *value;
19607     value = PyDict_GetItemWithError(d, key);
19608     if (unlikely(!value)) {
19609         if (!PyErr_Occurred()) {
19610             if (unlikely(PyTuple_Check(key))) {
19611                 PyObject* args = PyTuple_Pack(1, key);
19612                 if (likely(args)) {
19613                     PyErr_SetObject(PyExc_KeyError, args);
19614                     Py_DECREF(args);
19615                 }
19616             } else {
19617                 PyErr_SetObject(PyExc_KeyError, key);
19618             }
19619         }
19620         return NULL;
19621     }
19622     Py_INCREF(value);
19623     return value;
19624 }
19625 #endif
19626 
19627 /* ObjectGetItem */
19628 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetIndex(PyObject * obj,PyObject * index)19629 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
19630     PyObject *runerr;
19631     Py_ssize_t key_value;
19632     PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
19633     if (unlikely(!(m && m->sq_item))) {
19634         PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
19635         return NULL;
19636     }
19637     key_value = __Pyx_PyIndex_AsSsize_t(index);
19638     if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
19639         return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
19640     }
19641     if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
19642         PyErr_Clear();
19643         PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
19644     }
19645     return NULL;
19646 }
__Pyx_PyObject_GetItem(PyObject * obj,PyObject * key)19647 static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
19648     PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
19649     if (likely(m && m->mp_subscript)) {
19650         return m->mp_subscript(obj, key);
19651     }
19652     return __Pyx_PyObject_GetIndex(obj, key);
19653 }
19654 #endif
19655 
19656 /* GetAttr */
__Pyx_GetAttr(PyObject * o,PyObject * n)19657 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
19658 #if CYTHON_USE_TYPE_SLOTS
19659 #if PY_MAJOR_VERSION >= 3
19660     if (likely(PyUnicode_Check(n)))
19661 #else
19662     if (likely(PyString_Check(n)))
19663 #endif
19664         return __Pyx_PyObject_GetAttrStr(o, n);
19665 #endif
19666     return PyObject_GetAttr(o, n);
19667 }
19668 
19669 /* SliceObject */
__Pyx_PyObject_GetSlice(PyObject * obj,Py_ssize_t cstart,Py_ssize_t cstop,PyObject ** _py_start,PyObject ** _py_stop,PyObject ** _py_slice,int has_cstart,int has_cstop,CYTHON_UNUSED int wraparound)19670 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
19671         Py_ssize_t cstart, Py_ssize_t cstop,
19672         PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
19673         int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
19674 #if CYTHON_USE_TYPE_SLOTS
19675     PyMappingMethods* mp;
19676 #if PY_MAJOR_VERSION < 3
19677     PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
19678     if (likely(ms && ms->sq_slice)) {
19679         if (!has_cstart) {
19680             if (_py_start && (*_py_start != Py_None)) {
19681                 cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
19682                 if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
19683             } else
19684                 cstart = 0;
19685         }
19686         if (!has_cstop) {
19687             if (_py_stop && (*_py_stop != Py_None)) {
19688                 cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
19689                 if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
19690             } else
19691                 cstop = PY_SSIZE_T_MAX;
19692         }
19693         if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
19694             Py_ssize_t l = ms->sq_length(obj);
19695             if (likely(l >= 0)) {
19696                 if (cstop < 0) {
19697                     cstop += l;
19698                     if (cstop < 0) cstop = 0;
19699                 }
19700                 if (cstart < 0) {
19701                     cstart += l;
19702                     if (cstart < 0) cstart = 0;
19703                 }
19704             } else {
19705                 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
19706                     goto bad;
19707                 PyErr_Clear();
19708             }
19709         }
19710         return ms->sq_slice(obj, cstart, cstop);
19711     }
19712 #endif
19713     mp = Py_TYPE(obj)->tp_as_mapping;
19714     if (likely(mp && mp->mp_subscript))
19715 #endif
19716     {
19717         PyObject* result;
19718         PyObject *py_slice, *py_start, *py_stop;
19719         if (_py_slice) {
19720             py_slice = *_py_slice;
19721         } else {
19722             PyObject* owned_start = NULL;
19723             PyObject* owned_stop = NULL;
19724             if (_py_start) {
19725                 py_start = *_py_start;
19726             } else {
19727                 if (has_cstart) {
19728                     owned_start = py_start = PyInt_FromSsize_t(cstart);
19729                     if (unlikely(!py_start)) goto bad;
19730                 } else
19731                     py_start = Py_None;
19732             }
19733             if (_py_stop) {
19734                 py_stop = *_py_stop;
19735             } else {
19736                 if (has_cstop) {
19737                     owned_stop = py_stop = PyInt_FromSsize_t(cstop);
19738                     if (unlikely(!py_stop)) {
19739                         Py_XDECREF(owned_start);
19740                         goto bad;
19741                     }
19742                 } else
19743                     py_stop = Py_None;
19744             }
19745             py_slice = PySlice_New(py_start, py_stop, Py_None);
19746             Py_XDECREF(owned_start);
19747             Py_XDECREF(owned_stop);
19748             if (unlikely(!py_slice)) goto bad;
19749         }
19750 #if CYTHON_USE_TYPE_SLOTS
19751         result = mp->mp_subscript(obj, py_slice);
19752 #else
19753         result = PyObject_GetItem(obj, py_slice);
19754 #endif
19755         if (!_py_slice) {
19756             Py_DECREF(py_slice);
19757         }
19758         return result;
19759     }
19760     PyErr_Format(PyExc_TypeError,
19761         "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
19762 bad:
19763     return NULL;
19764 }
19765 
19766 /* PyErrExceptionMatches */
19767 #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)19768 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
19769     Py_ssize_t i, n;
19770     n = PyTuple_GET_SIZE(tuple);
19771 #if PY_MAJOR_VERSION >= 3
19772     for (i=0; i<n; i++) {
19773         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
19774     }
19775 #endif
19776     for (i=0; i<n; i++) {
19777         if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
19778     }
19779     return 0;
19780 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)19781 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
19782     PyObject *exc_type = tstate->curexc_type;
19783     if (exc_type == err) return 1;
19784     if (unlikely(!exc_type)) return 0;
19785     if (unlikely(PyTuple_Check(err)))
19786         return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
19787     return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
19788 }
19789 #endif
19790 
19791 /* GetAttr3 */
__Pyx_GetAttr3Default(PyObject * d)19792 static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
19793     __Pyx_PyThreadState_declare
19794     __Pyx_PyThreadState_assign
19795     if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
19796         return NULL;
19797     __Pyx_PyErr_Clear();
19798     Py_INCREF(d);
19799     return d;
19800 }
__Pyx_GetAttr3(PyObject * o,PyObject * n,PyObject * d)19801 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
19802     PyObject *r = __Pyx_GetAttr(o, n);
19803     return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
19804 }
19805 
19806 /* pyfrozenset_new */
__Pyx_PyFrozenSet_New(PyObject * it)19807 static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) {
19808     if (it) {
19809         PyObject* result;
19810 #if CYTHON_COMPILING_IN_PYPY
19811         PyObject* args;
19812         args = PyTuple_Pack(1, it);
19813         if (unlikely(!args))
19814             return NULL;
19815         result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL);
19816         Py_DECREF(args);
19817         return result;
19818 #else
19819         if (PyFrozenSet_CheckExact(it)) {
19820             Py_INCREF(it);
19821             return it;
19822         }
19823         result = PyFrozenSet_New(it);
19824         if (unlikely(!result))
19825             return NULL;
19826         if (likely(PySet_GET_SIZE(result)))
19827             return result;
19828         Py_DECREF(result);
19829 #endif
19830     }
19831 #if CYTHON_USE_TYPE_SLOTS
19832     return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
19833 #else
19834     return PyObject_Call((PyObject*)&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
19835 #endif
19836 }
19837 
19838 /* PySetContains */
__Pyx_PySet_ContainsUnhashable(PyObject * set,PyObject * key)19839 static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) {
19840     int result = -1;
19841     if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) {
19842         PyObject *tmpkey;
19843         PyErr_Clear();
19844         tmpkey = __Pyx_PyFrozenSet_New(key);
19845         if (tmpkey != NULL) {
19846             result = PySet_Contains(set, tmpkey);
19847             Py_DECREF(tmpkey);
19848         }
19849     }
19850     return result;
19851 }
__Pyx_PySet_ContainsTF(PyObject * key,PyObject * set,int eq)19852 static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) {
19853     int result = PySet_Contains(set, key);
19854     if (unlikely(result < 0)) {
19855         result = __Pyx_PySet_ContainsUnhashable(set, key);
19856     }
19857     return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
19858 }
19859 
19860 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)19861 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
19862     PyObject *empty_list = 0;
19863     PyObject *module = 0;
19864     PyObject *global_dict = 0;
19865     PyObject *empty_dict = 0;
19866     PyObject *list;
19867     #if PY_MAJOR_VERSION < 3
19868     PyObject *py_import;
19869     py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
19870     if (!py_import)
19871         goto bad;
19872     #endif
19873     if (from_list)
19874         list = from_list;
19875     else {
19876         empty_list = PyList_New(0);
19877         if (!empty_list)
19878             goto bad;
19879         list = empty_list;
19880     }
19881     global_dict = PyModule_GetDict(__pyx_m);
19882     if (!global_dict)
19883         goto bad;
19884     empty_dict = PyDict_New();
19885     if (!empty_dict)
19886         goto bad;
19887     {
19888         #if PY_MAJOR_VERSION >= 3
19889         if (level == -1) {
19890             if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
19891                 module = PyImport_ImportModuleLevelObject(
19892                     name, global_dict, empty_dict, list, 1);
19893                 if (!module) {
19894                     if (!PyErr_ExceptionMatches(PyExc_ImportError))
19895                         goto bad;
19896                     PyErr_Clear();
19897                 }
19898             }
19899             level = 0;
19900         }
19901         #endif
19902         if (!module) {
19903             #if PY_MAJOR_VERSION < 3
19904             PyObject *py_level = PyInt_FromLong(level);
19905             if (!py_level)
19906                 goto bad;
19907             module = PyObject_CallFunctionObjArgs(py_import,
19908                 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
19909             Py_DECREF(py_level);
19910             #else
19911             module = PyImport_ImportModuleLevelObject(
19912                 name, global_dict, empty_dict, list, level);
19913             #endif
19914         }
19915     }
19916 bad:
19917     #if PY_MAJOR_VERSION < 3
19918     Py_XDECREF(py_import);
19919     #endif
19920     Py_XDECREF(empty_list);
19921     Py_XDECREF(empty_dict);
19922     return module;
19923 }
19924 
19925 /* ImportFrom */
__Pyx_ImportFrom(PyObject * module,PyObject * name)19926 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
19927     PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
19928     if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
19929         PyErr_Format(PyExc_ImportError,
19930         #if PY_MAJOR_VERSION < 3
19931             "cannot import name %.230s", PyString_AS_STRING(name));
19932         #else
19933             "cannot import name %S", name);
19934         #endif
19935     }
19936     return value;
19937 }
19938 
19939 /* HasAttr */
__Pyx_HasAttr(PyObject * o,PyObject * n)19940 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
19941     PyObject *r;
19942     if (unlikely(!__Pyx_PyBaseString_Check(n))) {
19943         PyErr_SetString(PyExc_TypeError,
19944                         "hasattr(): attribute name must be string");
19945         return -1;
19946     }
19947     r = __Pyx_GetAttr(o, n);
19948     if (unlikely(!r)) {
19949         PyErr_Clear();
19950         return 0;
19951     } else {
19952         Py_DECREF(r);
19953         return 1;
19954     }
19955 }
19956 
19957 /* PyObject_GenericGetAttrNoDict */
19958 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_RaiseGenericGetAttributeError(PyTypeObject * tp,PyObject * attr_name)19959 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
19960     PyErr_Format(PyExc_AttributeError,
19961 #if PY_MAJOR_VERSION >= 3
19962                  "'%.50s' object has no attribute '%U'",
19963                  tp->tp_name, attr_name);
19964 #else
19965                  "'%.50s' object has no attribute '%.400s'",
19966                  tp->tp_name, PyString_AS_STRING(attr_name));
19967 #endif
19968     return NULL;
19969 }
__Pyx_PyObject_GenericGetAttrNoDict(PyObject * obj,PyObject * attr_name)19970 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
19971     PyObject *descr;
19972     PyTypeObject *tp = Py_TYPE(obj);
19973     if (unlikely(!PyString_Check(attr_name))) {
19974         return PyObject_GenericGetAttr(obj, attr_name);
19975     }
19976     assert(!tp->tp_dictoffset);
19977     descr = _PyType_Lookup(tp, attr_name);
19978     if (unlikely(!descr)) {
19979         return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
19980     }
19981     Py_INCREF(descr);
19982     #if PY_MAJOR_VERSION < 3
19983     if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
19984     #endif
19985     {
19986         descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
19987         if (unlikely(f)) {
19988             PyObject *res = f(descr, obj, (PyObject *)tp);
19989             Py_DECREF(descr);
19990             return res;
19991         }
19992     }
19993     return descr;
19994 }
19995 #endif
19996 
19997 /* PyObject_GenericGetAttr */
19998 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
__Pyx_PyObject_GenericGetAttr(PyObject * obj,PyObject * attr_name)19999 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
20000     if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
20001         return PyObject_GenericGetAttr(obj, attr_name);
20002     }
20003     return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
20004 }
20005 #endif
20006 
20007 /* SetVTable */
__Pyx_SetVtable(PyObject * dict,void * vtable)20008 static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
20009 #if PY_VERSION_HEX >= 0x02070000
20010     PyObject *ob = PyCapsule_New(vtable, 0, 0);
20011 #else
20012     PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
20013 #endif
20014     if (!ob)
20015         goto bad;
20016     if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
20017         goto bad;
20018     Py_DECREF(ob);
20019     return 0;
20020 bad:
20021     Py_XDECREF(ob);
20022     return -1;
20023 }
20024 
20025 /* PyObjectGetAttrStrNoError */
__Pyx_PyObject_GetAttrStr_ClearAttributeError(void)20026 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
20027     __Pyx_PyThreadState_declare
20028     __Pyx_PyThreadState_assign
20029     if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
20030         __Pyx_PyErr_Clear();
20031 }
__Pyx_PyObject_GetAttrStrNoError(PyObject * obj,PyObject * attr_name)20032 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
20033     PyObject *result;
20034 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
20035     PyTypeObject* tp = Py_TYPE(obj);
20036     if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
20037         return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
20038     }
20039 #endif
20040     result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
20041     if (unlikely(!result)) {
20042         __Pyx_PyObject_GetAttrStr_ClearAttributeError();
20043     }
20044     return result;
20045 }
20046 
20047 /* SetupReduce */
__Pyx_setup_reduce_is_named(PyObject * meth,PyObject * name)20048 static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
20049   int ret;
20050   PyObject *name_attr;
20051   name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
20052   if (likely(name_attr)) {
20053       ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
20054   } else {
20055       ret = -1;
20056   }
20057   if (unlikely(ret < 0)) {
20058       PyErr_Clear();
20059       ret = 0;
20060   }
20061   Py_XDECREF(name_attr);
20062   return ret;
20063 }
__Pyx_setup_reduce(PyObject * type_obj)20064 static int __Pyx_setup_reduce(PyObject* type_obj) {
20065     int ret = 0;
20066     PyObject *object_reduce = NULL;
20067     PyObject *object_reduce_ex = NULL;
20068     PyObject *reduce = NULL;
20069     PyObject *reduce_ex = NULL;
20070     PyObject *reduce_cython = NULL;
20071     PyObject *setstate = NULL;
20072     PyObject *setstate_cython = NULL;
20073 #if CYTHON_USE_PYTYPE_LOOKUP
20074     if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
20075 #else
20076     if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
20077 #endif
20078 #if CYTHON_USE_PYTYPE_LOOKUP
20079     object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
20080 #else
20081     object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
20082 #endif
20083     reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
20084     if (reduce_ex == object_reduce_ex) {
20085 #if CYTHON_USE_PYTYPE_LOOKUP
20086         object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
20087 #else
20088         object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
20089 #endif
20090         reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
20091         if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
20092             reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
20093             if (likely(reduce_cython)) {
20094                 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
20095                 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
20096             } else if (reduce == object_reduce || PyErr_Occurred()) {
20097                 goto __PYX_BAD;
20098             }
20099             setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
20100             if (!setstate) PyErr_Clear();
20101             if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
20102                 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
20103                 if (likely(setstate_cython)) {
20104                     ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
20105                     ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
20106                 } else if (!setstate || PyErr_Occurred()) {
20107                     goto __PYX_BAD;
20108                 }
20109             }
20110             PyType_Modified((PyTypeObject*)type_obj);
20111         }
20112     }
20113     goto __PYX_GOOD;
20114 __PYX_BAD:
20115     if (!PyErr_Occurred())
20116         PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
20117     ret = -1;
20118 __PYX_GOOD:
20119 #if !CYTHON_USE_PYTYPE_LOOKUP
20120     Py_XDECREF(object_reduce);
20121     Py_XDECREF(object_reduce_ex);
20122 #endif
20123     Py_XDECREF(reduce);
20124     Py_XDECREF(reduce_ex);
20125     Py_XDECREF(reduce_cython);
20126     Py_XDECREF(setstate);
20127     Py_XDECREF(setstate_cython);
20128     return ret;
20129 }
20130 
20131 /* TypeImport */
20132 #ifndef __PYX_HAVE_RT_ImportType
20133 #define __PYX_HAVE_RT_ImportType
__Pyx_ImportType(PyObject * module,const char * module_name,const char * class_name,size_t size,enum __Pyx_ImportType_CheckSize check_size)20134 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
20135     size_t size, enum __Pyx_ImportType_CheckSize check_size)
20136 {
20137     PyObject *result = 0;
20138     char warning[200];
20139     Py_ssize_t basicsize;
20140 #ifdef Py_LIMITED_API
20141     PyObject *py_basicsize;
20142 #endif
20143     result = PyObject_GetAttrString(module, class_name);
20144     if (!result)
20145         goto bad;
20146     if (!PyType_Check(result)) {
20147         PyErr_Format(PyExc_TypeError,
20148             "%.200s.%.200s is not a type object",
20149             module_name, class_name);
20150         goto bad;
20151     }
20152 #ifndef Py_LIMITED_API
20153     basicsize = ((PyTypeObject *)result)->tp_basicsize;
20154 #else
20155     py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
20156     if (!py_basicsize)
20157         goto bad;
20158     basicsize = PyLong_AsSsize_t(py_basicsize);
20159     Py_DECREF(py_basicsize);
20160     py_basicsize = 0;
20161     if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
20162         goto bad;
20163 #endif
20164     if ((size_t)basicsize < size) {
20165         PyErr_Format(PyExc_ValueError,
20166             "%.200s.%.200s size changed, may indicate binary incompatibility. "
20167             "Expected %zd from C header, got %zd from PyObject",
20168             module_name, class_name, size, basicsize);
20169         goto bad;
20170     }
20171     if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
20172         PyErr_Format(PyExc_ValueError,
20173             "%.200s.%.200s size changed, may indicate binary incompatibility. "
20174             "Expected %zd from C header, got %zd from PyObject",
20175             module_name, class_name, size, basicsize);
20176         goto bad;
20177     }
20178     else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
20179         PyOS_snprintf(warning, sizeof(warning),
20180             "%s.%s size changed, may indicate binary incompatibility. "
20181             "Expected %zd from C header, got %zd from PyObject",
20182             module_name, class_name, size, basicsize);
20183         if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
20184     }
20185     return (PyTypeObject *)result;
20186 bad:
20187     Py_XDECREF(result);
20188     return NULL;
20189 }
20190 #endif
20191 
20192 /* GetVTable */
__Pyx_GetVtable(PyObject * dict)20193 static void* __Pyx_GetVtable(PyObject *dict) {
20194     void* ptr;
20195     PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
20196     if (!ob)
20197         goto bad;
20198 #if PY_VERSION_HEX >= 0x02070000
20199     ptr = PyCapsule_GetPointer(ob, 0);
20200 #else
20201     ptr = PyCObject_AsVoidPtr(ob);
20202 #endif
20203     if (!ptr && !PyErr_Occurred())
20204         PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
20205     Py_DECREF(ob);
20206     return ptr;
20207 bad:
20208     Py_XDECREF(ob);
20209     return NULL;
20210 }
20211 
20212 /* CLineInTraceback */
20213 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)20214 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
20215     PyObject *use_cline;
20216     PyObject *ptype, *pvalue, *ptraceback;
20217 #if CYTHON_COMPILING_IN_CPYTHON
20218     PyObject **cython_runtime_dict;
20219 #endif
20220     if (unlikely(!__pyx_cython_runtime)) {
20221         return c_line;
20222     }
20223     __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
20224 #if CYTHON_COMPILING_IN_CPYTHON
20225     cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
20226     if (likely(cython_runtime_dict)) {
20227         __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
20228             use_cline, *cython_runtime_dict,
20229             __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
20230     } else
20231 #endif
20232     {
20233       PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
20234       if (use_cline_obj) {
20235         use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
20236         Py_DECREF(use_cline_obj);
20237       } else {
20238         PyErr_Clear();
20239         use_cline = NULL;
20240       }
20241     }
20242     if (!use_cline) {
20243         c_line = 0;
20244         PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
20245     }
20246     else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
20247         c_line = 0;
20248     }
20249     __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
20250     return c_line;
20251 }
20252 #endif
20253 
20254 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)20255 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
20256     int start = 0, mid = 0, end = count - 1;
20257     if (end >= 0 && code_line > entries[end].code_line) {
20258         return count;
20259     }
20260     while (start < end) {
20261         mid = start + (end - start) / 2;
20262         if (code_line < entries[mid].code_line) {
20263             end = mid;
20264         } else if (code_line > entries[mid].code_line) {
20265              start = mid + 1;
20266         } else {
20267             return mid;
20268         }
20269     }
20270     if (code_line <= entries[mid].code_line) {
20271         return mid;
20272     } else {
20273         return mid + 1;
20274     }
20275 }
__pyx_find_code_object(int code_line)20276 static PyCodeObject *__pyx_find_code_object(int code_line) {
20277     PyCodeObject* code_object;
20278     int pos;
20279     if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
20280         return NULL;
20281     }
20282     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
20283     if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
20284         return NULL;
20285     }
20286     code_object = __pyx_code_cache.entries[pos].code_object;
20287     Py_INCREF(code_object);
20288     return code_object;
20289 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)20290 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
20291     int pos, i;
20292     __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
20293     if (unlikely(!code_line)) {
20294         return;
20295     }
20296     if (unlikely(!entries)) {
20297         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
20298         if (likely(entries)) {
20299             __pyx_code_cache.entries = entries;
20300             __pyx_code_cache.max_count = 64;
20301             __pyx_code_cache.count = 1;
20302             entries[0].code_line = code_line;
20303             entries[0].code_object = code_object;
20304             Py_INCREF(code_object);
20305         }
20306         return;
20307     }
20308     pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
20309     if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
20310         PyCodeObject* tmp = entries[pos].code_object;
20311         entries[pos].code_object = code_object;
20312         Py_DECREF(tmp);
20313         return;
20314     }
20315     if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
20316         int new_max = __pyx_code_cache.max_count + 64;
20317         entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
20318             __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
20319         if (unlikely(!entries)) {
20320             return;
20321         }
20322         __pyx_code_cache.entries = entries;
20323         __pyx_code_cache.max_count = new_max;
20324     }
20325     for (i=__pyx_code_cache.count; i>pos; i--) {
20326         entries[i] = entries[i-1];
20327     }
20328     entries[pos].code_line = code_line;
20329     entries[pos].code_object = code_object;
20330     __pyx_code_cache.count++;
20331     Py_INCREF(code_object);
20332 }
20333 
20334 /* AddTraceback */
20335 #include "compile.h"
20336 #include "frameobject.h"
20337 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)20338 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
20339             const char *funcname, int c_line,
20340             int py_line, const char *filename) {
20341     PyCodeObject *py_code = 0;
20342     PyObject *py_srcfile = 0;
20343     PyObject *py_funcname = 0;
20344     #if PY_MAJOR_VERSION < 3
20345     py_srcfile = PyString_FromString(filename);
20346     #else
20347     py_srcfile = PyUnicode_FromString(filename);
20348     #endif
20349     if (!py_srcfile) goto bad;
20350     if (c_line) {
20351         #if PY_MAJOR_VERSION < 3
20352         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
20353         #else
20354         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
20355         #endif
20356     }
20357     else {
20358         #if PY_MAJOR_VERSION < 3
20359         py_funcname = PyString_FromString(funcname);
20360         #else
20361         py_funcname = PyUnicode_FromString(funcname);
20362         #endif
20363     }
20364     if (!py_funcname) goto bad;
20365     py_code = __Pyx_PyCode_New(
20366         0,
20367         0,
20368         0,
20369         0,
20370         0,
20371         __pyx_empty_bytes, /*PyObject *code,*/
20372         __pyx_empty_tuple, /*PyObject *consts,*/
20373         __pyx_empty_tuple, /*PyObject *names,*/
20374         __pyx_empty_tuple, /*PyObject *varnames,*/
20375         __pyx_empty_tuple, /*PyObject *freevars,*/
20376         __pyx_empty_tuple, /*PyObject *cellvars,*/
20377         py_srcfile,   /*PyObject *filename,*/
20378         py_funcname,  /*PyObject *name,*/
20379         py_line,
20380         __pyx_empty_bytes  /*PyObject *lnotab*/
20381     );
20382     Py_DECREF(py_srcfile);
20383     Py_DECREF(py_funcname);
20384     return py_code;
20385 bad:
20386     Py_XDECREF(py_srcfile);
20387     Py_XDECREF(py_funcname);
20388     return NULL;
20389 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)20390 static void __Pyx_AddTraceback(const char *funcname, int c_line,
20391                                int py_line, const char *filename) {
20392     PyCodeObject *py_code = 0;
20393     PyFrameObject *py_frame = 0;
20394     PyThreadState *tstate = __Pyx_PyThreadState_Current;
20395     if (c_line) {
20396         c_line = __Pyx_CLineForTraceback(tstate, c_line);
20397     }
20398     py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
20399     if (!py_code) {
20400         py_code = __Pyx_CreateCodeObjectForTraceback(
20401             funcname, c_line, py_line, filename);
20402         if (!py_code) goto bad;
20403         __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
20404     }
20405     py_frame = PyFrame_New(
20406         tstate,            /*PyThreadState *tstate,*/
20407         py_code,           /*PyCodeObject *code,*/
20408         __pyx_d,    /*PyObject *globals,*/
20409         0                  /*PyObject *locals*/
20410     );
20411     if (!py_frame) goto bad;
20412     __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
20413     PyTraceBack_Here(py_frame);
20414 bad:
20415     Py_XDECREF(py_code);
20416     Py_XDECREF(py_frame);
20417 }
20418 
20419 /* CIntFromPyVerify */
20420 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
20421     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
20422 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
20423     __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
20424 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
20425     {\
20426         func_type value = func_value;\
20427         if (sizeof(target_type) < sizeof(func_type)) {\
20428             if (unlikely(value != (func_type) (target_type) value)) {\
20429                 func_type zero = 0;\
20430                 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
20431                     return (target_type) -1;\
20432                 if (is_unsigned && unlikely(value < zero))\
20433                     goto raise_neg_overflow;\
20434                 else\
20435                     goto raise_overflow;\
20436             }\
20437         }\
20438         return (target_type) value;\
20439     }
20440 
20441 /* CIntToPy */
__Pyx_PyInt_From_long(long value)20442 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
20443     const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
20444     const int is_unsigned = neg_one > const_zero;
20445     if (is_unsigned) {
20446         if (sizeof(long) < sizeof(long)) {
20447             return PyInt_FromLong((long) value);
20448         } else if (sizeof(long) <= sizeof(unsigned long)) {
20449             return PyLong_FromUnsignedLong((unsigned long) value);
20450 #ifdef HAVE_LONG_LONG
20451         } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
20452             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
20453 #endif
20454         }
20455     } else {
20456         if (sizeof(long) <= sizeof(long)) {
20457             return PyInt_FromLong((long) value);
20458 #ifdef HAVE_LONG_LONG
20459         } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
20460             return PyLong_FromLongLong((PY_LONG_LONG) value);
20461 #endif
20462         }
20463     }
20464     {
20465         int one = 1; int little = (int)*(unsigned char *)&one;
20466         unsigned char *bytes = (unsigned char *)&value;
20467         return _PyLong_FromByteArray(bytes, sizeof(long),
20468                                      little, !is_unsigned);
20469     }
20470 }
20471 
20472 /* CIntToPy */
__Pyx_PyInt_From_int(int value)20473 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
20474     const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
20475     const int is_unsigned = neg_one > const_zero;
20476     if (is_unsigned) {
20477         if (sizeof(int) < sizeof(long)) {
20478             return PyInt_FromLong((long) value);
20479         } else if (sizeof(int) <= sizeof(unsigned long)) {
20480             return PyLong_FromUnsignedLong((unsigned long) value);
20481 #ifdef HAVE_LONG_LONG
20482         } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
20483             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
20484 #endif
20485         }
20486     } else {
20487         if (sizeof(int) <= sizeof(long)) {
20488             return PyInt_FromLong((long) value);
20489 #ifdef HAVE_LONG_LONG
20490         } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
20491             return PyLong_FromLongLong((PY_LONG_LONG) value);
20492 #endif
20493         }
20494     }
20495     {
20496         int one = 1; int little = (int)*(unsigned char *)&one;
20497         unsigned char *bytes = (unsigned char *)&value;
20498         return _PyLong_FromByteArray(bytes, sizeof(int),
20499                                      little, !is_unsigned);
20500     }
20501 }
20502 
20503 /* CIntToPy */
__Pyx_PyInt_From_unsigned_int(unsigned int value)20504 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
20505     const unsigned int neg_one = (unsigned int) ((unsigned int) 0 - (unsigned int) 1), const_zero = (unsigned int) 0;
20506     const int is_unsigned = neg_one > const_zero;
20507     if (is_unsigned) {
20508         if (sizeof(unsigned int) < sizeof(long)) {
20509             return PyInt_FromLong((long) value);
20510         } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
20511             return PyLong_FromUnsignedLong((unsigned long) value);
20512 #ifdef HAVE_LONG_LONG
20513         } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
20514             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
20515 #endif
20516         }
20517     } else {
20518         if (sizeof(unsigned int) <= sizeof(long)) {
20519             return PyInt_FromLong((long) value);
20520 #ifdef HAVE_LONG_LONG
20521         } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
20522             return PyLong_FromLongLong((PY_LONG_LONG) value);
20523 #endif
20524         }
20525     }
20526     {
20527         int one = 1; int little = (int)*(unsigned char *)&one;
20528         unsigned char *bytes = (unsigned char *)&value;
20529         return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
20530                                      little, !is_unsigned);
20531     }
20532 }
20533 
20534 /* Declarations */
20535 #if CYTHON_CCOMPLEX
20536   #ifdef __cplusplus
__pyx_t_float_complex_from_parts(float x,float y)20537     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
20538       return ::std::complex< float >(x, y);
20539     }
20540   #else
__pyx_t_float_complex_from_parts(float x,float y)20541     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
20542       return x + y*(__pyx_t_float_complex)_Complex_I;
20543     }
20544   #endif
20545 #else
__pyx_t_float_complex_from_parts(float x,float y)20546     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
20547       __pyx_t_float_complex z;
20548       z.real = x;
20549       z.imag = y;
20550       return z;
20551     }
20552 #endif
20553 
20554 /* Arithmetic */
20555 #if CYTHON_CCOMPLEX
20556 #else
__Pyx_c_eq_float(__pyx_t_float_complex a,__pyx_t_float_complex b)20557     static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
20558        return (a.real == b.real) && (a.imag == b.imag);
20559     }
__Pyx_c_sum_float(__pyx_t_float_complex a,__pyx_t_float_complex b)20560     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
20561         __pyx_t_float_complex z;
20562         z.real = a.real + b.real;
20563         z.imag = a.imag + b.imag;
20564         return z;
20565     }
__Pyx_c_diff_float(__pyx_t_float_complex a,__pyx_t_float_complex b)20566     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
20567         __pyx_t_float_complex z;
20568         z.real = a.real - b.real;
20569         z.imag = a.imag - b.imag;
20570         return z;
20571     }
__Pyx_c_prod_float(__pyx_t_float_complex a,__pyx_t_float_complex b)20572     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
20573         __pyx_t_float_complex z;
20574         z.real = a.real * b.real - a.imag * b.imag;
20575         z.imag = a.real * b.imag + a.imag * b.real;
20576         return z;
20577     }
20578     #if 1
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)20579     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
20580         if (b.imag == 0) {
20581             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
20582         } else if (fabsf(b.real) >= fabsf(b.imag)) {
20583             if (b.real == 0 && b.imag == 0) {
20584                 return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
20585             } else {
20586                 float r = b.imag / b.real;
20587                 float s = (float)(1.0) / (b.real + b.imag * r);
20588                 return __pyx_t_float_complex_from_parts(
20589                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
20590             }
20591         } else {
20592             float r = b.real / b.imag;
20593             float s = (float)(1.0) / (b.imag + b.real * r);
20594             return __pyx_t_float_complex_from_parts(
20595                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
20596         }
20597     }
20598     #else
__Pyx_c_quot_float(__pyx_t_float_complex a,__pyx_t_float_complex b)20599     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
20600         if (b.imag == 0) {
20601             return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
20602         } else {
20603             float denom = b.real * b.real + b.imag * b.imag;
20604             return __pyx_t_float_complex_from_parts(
20605                 (a.real * b.real + a.imag * b.imag) / denom,
20606                 (a.imag * b.real - a.real * b.imag) / denom);
20607         }
20608     }
20609     #endif
__Pyx_c_neg_float(__pyx_t_float_complex a)20610     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
20611         __pyx_t_float_complex z;
20612         z.real = -a.real;
20613         z.imag = -a.imag;
20614         return z;
20615     }
__Pyx_c_is_zero_float(__pyx_t_float_complex a)20616     static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
20617        return (a.real == 0) && (a.imag == 0);
20618     }
__Pyx_c_conj_float(__pyx_t_float_complex a)20619     static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
20620         __pyx_t_float_complex z;
20621         z.real =  a.real;
20622         z.imag = -a.imag;
20623         return z;
20624     }
20625     #if 1
__Pyx_c_abs_float(__pyx_t_float_complex z)20626         static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
20627           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
20628             return sqrtf(z.real*z.real + z.imag*z.imag);
20629           #else
20630             return hypotf(z.real, z.imag);
20631           #endif
20632         }
__Pyx_c_pow_float(__pyx_t_float_complex a,__pyx_t_float_complex b)20633         static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
20634             __pyx_t_float_complex z;
20635             float r, lnr, theta, z_r, z_theta;
20636             if (b.imag == 0 && b.real == (int)b.real) {
20637                 if (b.real < 0) {
20638                     float denom = a.real * a.real + a.imag * a.imag;
20639                     a.real = a.real / denom;
20640                     a.imag = -a.imag / denom;
20641                     b.real = -b.real;
20642                 }
20643                 switch ((int)b.real) {
20644                     case 0:
20645                         z.real = 1;
20646                         z.imag = 0;
20647                         return z;
20648                     case 1:
20649                         return a;
20650                     case 2:
20651                         return __Pyx_c_prod_float(a, a);
20652                     case 3:
20653                         z = __Pyx_c_prod_float(a, a);
20654                         return __Pyx_c_prod_float(z, a);
20655                     case 4:
20656                         z = __Pyx_c_prod_float(a, a);
20657                         return __Pyx_c_prod_float(z, z);
20658                 }
20659             }
20660             if (a.imag == 0) {
20661                 if (a.real == 0) {
20662                     return a;
20663                 } else if (b.imag == 0) {
20664                     z.real = powf(a.real, b.real);
20665                     z.imag = 0;
20666                     return z;
20667                 } else if (a.real > 0) {
20668                     r = a.real;
20669                     theta = 0;
20670                 } else {
20671                     r = -a.real;
20672                     theta = atan2f(0.0, -1.0);
20673                 }
20674             } else {
20675                 r = __Pyx_c_abs_float(a);
20676                 theta = atan2f(a.imag, a.real);
20677             }
20678             lnr = logf(r);
20679             z_r = expf(lnr * b.real - theta * b.imag);
20680             z_theta = theta * b.real + lnr * b.imag;
20681             z.real = z_r * cosf(z_theta);
20682             z.imag = z_r * sinf(z_theta);
20683             return z;
20684         }
20685     #endif
20686 #endif
20687 
20688 /* Declarations */
20689 #if CYTHON_CCOMPLEX
20690   #ifdef __cplusplus
__pyx_t_double_complex_from_parts(double x,double y)20691     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
20692       return ::std::complex< double >(x, y);
20693     }
20694   #else
__pyx_t_double_complex_from_parts(double x,double y)20695     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
20696       return x + y*(__pyx_t_double_complex)_Complex_I;
20697     }
20698   #endif
20699 #else
__pyx_t_double_complex_from_parts(double x,double y)20700     static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
20701       __pyx_t_double_complex z;
20702       z.real = x;
20703       z.imag = y;
20704       return z;
20705     }
20706 #endif
20707 
20708 /* Arithmetic */
20709 #if CYTHON_CCOMPLEX
20710 #else
__Pyx_c_eq_double(__pyx_t_double_complex a,__pyx_t_double_complex b)20711     static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
20712        return (a.real == b.real) && (a.imag == b.imag);
20713     }
__Pyx_c_sum_double(__pyx_t_double_complex a,__pyx_t_double_complex b)20714     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
20715         __pyx_t_double_complex z;
20716         z.real = a.real + b.real;
20717         z.imag = a.imag + b.imag;
20718         return z;
20719     }
__Pyx_c_diff_double(__pyx_t_double_complex a,__pyx_t_double_complex b)20720     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
20721         __pyx_t_double_complex z;
20722         z.real = a.real - b.real;
20723         z.imag = a.imag - b.imag;
20724         return z;
20725     }
__Pyx_c_prod_double(__pyx_t_double_complex a,__pyx_t_double_complex b)20726     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
20727         __pyx_t_double_complex z;
20728         z.real = a.real * b.real - a.imag * b.imag;
20729         z.imag = a.real * b.imag + a.imag * b.real;
20730         return z;
20731     }
20732     #if 1
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)20733     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
20734         if (b.imag == 0) {
20735             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
20736         } else if (fabs(b.real) >= fabs(b.imag)) {
20737             if (b.real == 0 && b.imag == 0) {
20738                 return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
20739             } else {
20740                 double r = b.imag / b.real;
20741                 double s = (double)(1.0) / (b.real + b.imag * r);
20742                 return __pyx_t_double_complex_from_parts(
20743                     (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
20744             }
20745         } else {
20746             double r = b.real / b.imag;
20747             double s = (double)(1.0) / (b.imag + b.real * r);
20748             return __pyx_t_double_complex_from_parts(
20749                 (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
20750         }
20751     }
20752     #else
__Pyx_c_quot_double(__pyx_t_double_complex a,__pyx_t_double_complex b)20753     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
20754         if (b.imag == 0) {
20755             return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
20756         } else {
20757             double denom = b.real * b.real + b.imag * b.imag;
20758             return __pyx_t_double_complex_from_parts(
20759                 (a.real * b.real + a.imag * b.imag) / denom,
20760                 (a.imag * b.real - a.real * b.imag) / denom);
20761         }
20762     }
20763     #endif
__Pyx_c_neg_double(__pyx_t_double_complex a)20764     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
20765         __pyx_t_double_complex z;
20766         z.real = -a.real;
20767         z.imag = -a.imag;
20768         return z;
20769     }
__Pyx_c_is_zero_double(__pyx_t_double_complex a)20770     static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
20771        return (a.real == 0) && (a.imag == 0);
20772     }
__Pyx_c_conj_double(__pyx_t_double_complex a)20773     static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
20774         __pyx_t_double_complex z;
20775         z.real =  a.real;
20776         z.imag = -a.imag;
20777         return z;
20778     }
20779     #if 1
__Pyx_c_abs_double(__pyx_t_double_complex z)20780         static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
20781           #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
20782             return sqrt(z.real*z.real + z.imag*z.imag);
20783           #else
20784             return hypot(z.real, z.imag);
20785           #endif
20786         }
__Pyx_c_pow_double(__pyx_t_double_complex a,__pyx_t_double_complex b)20787         static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
20788             __pyx_t_double_complex z;
20789             double r, lnr, theta, z_r, z_theta;
20790             if (b.imag == 0 && b.real == (int)b.real) {
20791                 if (b.real < 0) {
20792                     double denom = a.real * a.real + a.imag * a.imag;
20793                     a.real = a.real / denom;
20794                     a.imag = -a.imag / denom;
20795                     b.real = -b.real;
20796                 }
20797                 switch ((int)b.real) {
20798                     case 0:
20799                         z.real = 1;
20800                         z.imag = 0;
20801                         return z;
20802                     case 1:
20803                         return a;
20804                     case 2:
20805                         return __Pyx_c_prod_double(a, a);
20806                     case 3:
20807                         z = __Pyx_c_prod_double(a, a);
20808                         return __Pyx_c_prod_double(z, a);
20809                     case 4:
20810                         z = __Pyx_c_prod_double(a, a);
20811                         return __Pyx_c_prod_double(z, z);
20812                 }
20813             }
20814             if (a.imag == 0) {
20815                 if (a.real == 0) {
20816                     return a;
20817                 } else if (b.imag == 0) {
20818                     z.real = pow(a.real, b.real);
20819                     z.imag = 0;
20820                     return z;
20821                 } else if (a.real > 0) {
20822                     r = a.real;
20823                     theta = 0;
20824                 } else {
20825                     r = -a.real;
20826                     theta = atan2(0.0, -1.0);
20827                 }
20828             } else {
20829                 r = __Pyx_c_abs_double(a);
20830                 theta = atan2(a.imag, a.real);
20831             }
20832             lnr = log(r);
20833             z_r = exp(lnr * b.real - theta * b.imag);
20834             z_theta = theta * b.real + lnr * b.imag;
20835             z.real = z_r * cos(z_theta);
20836             z.imag = z_r * sin(z_theta);
20837             return z;
20838         }
20839     #endif
20840 #endif
20841 
20842 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)20843 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
20844     const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
20845     const int is_unsigned = neg_one > const_zero;
20846 #if PY_MAJOR_VERSION < 3
20847     if (likely(PyInt_Check(x))) {
20848         if (sizeof(long) < sizeof(long)) {
20849             __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
20850         } else {
20851             long val = PyInt_AS_LONG(x);
20852             if (is_unsigned && unlikely(val < 0)) {
20853                 goto raise_neg_overflow;
20854             }
20855             return (long) val;
20856         }
20857     } else
20858 #endif
20859     if (likely(PyLong_Check(x))) {
20860         if (is_unsigned) {
20861 #if CYTHON_USE_PYLONG_INTERNALS
20862             const digit* digits = ((PyLongObject*)x)->ob_digit;
20863             switch (Py_SIZE(x)) {
20864                 case  0: return (long) 0;
20865                 case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
20866                 case 2:
20867                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
20868                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
20869                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20870                         } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
20871                             return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
20872                         }
20873                     }
20874                     break;
20875                 case 3:
20876                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
20877                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
20878                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20879                         } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
20880                             return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
20881                         }
20882                     }
20883                     break;
20884                 case 4:
20885                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
20886                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
20887                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20888                         } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
20889                             return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
20890                         }
20891                     }
20892                     break;
20893             }
20894 #endif
20895 #if CYTHON_COMPILING_IN_CPYTHON
20896             if (unlikely(Py_SIZE(x) < 0)) {
20897                 goto raise_neg_overflow;
20898             }
20899 #else
20900             {
20901                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
20902                 if (unlikely(result < 0))
20903                     return (long) -1;
20904                 if (unlikely(result == 1))
20905                     goto raise_neg_overflow;
20906             }
20907 #endif
20908             if (sizeof(long) <= sizeof(unsigned long)) {
20909                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
20910 #ifdef HAVE_LONG_LONG
20911             } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
20912                 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
20913 #endif
20914             }
20915         } else {
20916 #if CYTHON_USE_PYLONG_INTERNALS
20917             const digit* digits = ((PyLongObject*)x)->ob_digit;
20918             switch (Py_SIZE(x)) {
20919                 case  0: return (long) 0;
20920                 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
20921                 case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
20922                 case -2:
20923                     if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
20924                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
20925                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20926                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
20927                             return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20928                         }
20929                     }
20930                     break;
20931                 case 2:
20932                     if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
20933                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
20934                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20935                         } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
20936                             return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20937                         }
20938                     }
20939                     break;
20940                 case -3:
20941                     if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
20942                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
20943                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20944                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
20945                             return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20946                         }
20947                     }
20948                     break;
20949                 case 3:
20950                     if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
20951                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
20952                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20953                         } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
20954                             return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20955                         }
20956                     }
20957                     break;
20958                 case -4:
20959                     if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
20960                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
20961                             __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20962                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
20963                             return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20964                         }
20965                     }
20966                     break;
20967                 case 4:
20968                     if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
20969                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
20970                             __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
20971                         } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
20972                             return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
20973                         }
20974                     }
20975                     break;
20976             }
20977 #endif
20978             if (sizeof(long) <= sizeof(long)) {
20979                 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
20980 #ifdef HAVE_LONG_LONG
20981             } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
20982                 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
20983 #endif
20984             }
20985         }
20986         {
20987 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
20988             PyErr_SetString(PyExc_RuntimeError,
20989                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
20990 #else
20991             long val;
20992             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
20993  #if PY_MAJOR_VERSION < 3
20994             if (likely(v) && !PyLong_Check(v)) {
20995                 PyObject *tmp = v;
20996                 v = PyNumber_Long(tmp);
20997                 Py_DECREF(tmp);
20998             }
20999  #endif
21000             if (likely(v)) {
21001                 int one = 1; int is_little = (int)*(unsigned char *)&one;
21002                 unsigned char *bytes = (unsigned char *)&val;
21003                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
21004                                               bytes, sizeof(val),
21005                                               is_little, !is_unsigned);
21006                 Py_DECREF(v);
21007                 if (likely(!ret))
21008                     return val;
21009             }
21010 #endif
21011             return (long) -1;
21012         }
21013     } else {
21014         long val;
21015         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
21016         if (!tmp) return (long) -1;
21017         val = __Pyx_PyInt_As_long(tmp);
21018         Py_DECREF(tmp);
21019         return val;
21020     }
21021 raise_overflow:
21022     PyErr_SetString(PyExc_OverflowError,
21023         "value too large to convert to long");
21024     return (long) -1;
21025 raise_neg_overflow:
21026     PyErr_SetString(PyExc_OverflowError,
21027         "can't convert negative value to long");
21028     return (long) -1;
21029 }
21030 
21031 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)21032 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
21033     const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
21034     const int is_unsigned = neg_one > const_zero;
21035 #if PY_MAJOR_VERSION < 3
21036     if (likely(PyInt_Check(x))) {
21037         if (sizeof(int) < sizeof(long)) {
21038             __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
21039         } else {
21040             long val = PyInt_AS_LONG(x);
21041             if (is_unsigned && unlikely(val < 0)) {
21042                 goto raise_neg_overflow;
21043             }
21044             return (int) val;
21045         }
21046     } else
21047 #endif
21048     if (likely(PyLong_Check(x))) {
21049         if (is_unsigned) {
21050 #if CYTHON_USE_PYLONG_INTERNALS
21051             const digit* digits = ((PyLongObject*)x)->ob_digit;
21052             switch (Py_SIZE(x)) {
21053                 case  0: return (int) 0;
21054                 case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
21055                 case 2:
21056                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
21057                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
21058                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21059                         } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
21060                             return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
21061                         }
21062                     }
21063                     break;
21064                 case 3:
21065                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
21066                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
21067                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21068                         } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
21069                             return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
21070                         }
21071                     }
21072                     break;
21073                 case 4:
21074                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
21075                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
21076                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21077                         } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
21078                             return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
21079                         }
21080                     }
21081                     break;
21082             }
21083 #endif
21084 #if CYTHON_COMPILING_IN_CPYTHON
21085             if (unlikely(Py_SIZE(x) < 0)) {
21086                 goto raise_neg_overflow;
21087             }
21088 #else
21089             {
21090                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
21091                 if (unlikely(result < 0))
21092                     return (int) -1;
21093                 if (unlikely(result == 1))
21094                     goto raise_neg_overflow;
21095             }
21096 #endif
21097             if (sizeof(int) <= sizeof(unsigned long)) {
21098                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
21099 #ifdef HAVE_LONG_LONG
21100             } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
21101                 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
21102 #endif
21103             }
21104         } else {
21105 #if CYTHON_USE_PYLONG_INTERNALS
21106             const digit* digits = ((PyLongObject*)x)->ob_digit;
21107             switch (Py_SIZE(x)) {
21108                 case  0: return (int) 0;
21109                 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
21110                 case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
21111                 case -2:
21112                     if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
21113                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
21114                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21115                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
21116                             return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
21117                         }
21118                     }
21119                     break;
21120                 case 2:
21121                     if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
21122                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
21123                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21124                         } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
21125                             return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
21126                         }
21127                     }
21128                     break;
21129                 case -3:
21130                     if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
21131                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
21132                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21133                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
21134                             return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
21135                         }
21136                     }
21137                     break;
21138                 case 3:
21139                     if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
21140                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
21141                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21142                         } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
21143                             return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
21144                         }
21145                     }
21146                     break;
21147                 case -4:
21148                     if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
21149                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
21150                             __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21151                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
21152                             return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
21153                         }
21154                     }
21155                     break;
21156                 case 4:
21157                     if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
21158                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
21159                             __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21160                         } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
21161                             return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
21162                         }
21163                     }
21164                     break;
21165             }
21166 #endif
21167             if (sizeof(int) <= sizeof(long)) {
21168                 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
21169 #ifdef HAVE_LONG_LONG
21170             } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
21171                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
21172 #endif
21173             }
21174         }
21175         {
21176 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
21177             PyErr_SetString(PyExc_RuntimeError,
21178                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
21179 #else
21180             int val;
21181             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
21182  #if PY_MAJOR_VERSION < 3
21183             if (likely(v) && !PyLong_Check(v)) {
21184                 PyObject *tmp = v;
21185                 v = PyNumber_Long(tmp);
21186                 Py_DECREF(tmp);
21187             }
21188  #endif
21189             if (likely(v)) {
21190                 int one = 1; int is_little = (int)*(unsigned char *)&one;
21191                 unsigned char *bytes = (unsigned char *)&val;
21192                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
21193                                               bytes, sizeof(val),
21194                                               is_little, !is_unsigned);
21195                 Py_DECREF(v);
21196                 if (likely(!ret))
21197                     return val;
21198             }
21199 #endif
21200             return (int) -1;
21201         }
21202     } else {
21203         int val;
21204         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
21205         if (!tmp) return (int) -1;
21206         val = __Pyx_PyInt_As_int(tmp);
21207         Py_DECREF(tmp);
21208         return val;
21209     }
21210 raise_overflow:
21211     PyErr_SetString(PyExc_OverflowError,
21212         "value too large to convert to int");
21213     return (int) -1;
21214 raise_neg_overflow:
21215     PyErr_SetString(PyExc_OverflowError,
21216         "can't convert negative value to int");
21217     return (int) -1;
21218 }
21219 
21220 /* CIntFromPy */
__Pyx_PyInt_As_size_t(PyObject * x)21221 static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
21222     const size_t neg_one = (size_t) ((size_t) 0 - (size_t) 1), const_zero = (size_t) 0;
21223     const int is_unsigned = neg_one > const_zero;
21224 #if PY_MAJOR_VERSION < 3
21225     if (likely(PyInt_Check(x))) {
21226         if (sizeof(size_t) < sizeof(long)) {
21227             __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
21228         } else {
21229             long val = PyInt_AS_LONG(x);
21230             if (is_unsigned && unlikely(val < 0)) {
21231                 goto raise_neg_overflow;
21232             }
21233             return (size_t) val;
21234         }
21235     } else
21236 #endif
21237     if (likely(PyLong_Check(x))) {
21238         if (is_unsigned) {
21239 #if CYTHON_USE_PYLONG_INTERNALS
21240             const digit* digits = ((PyLongObject*)x)->ob_digit;
21241             switch (Py_SIZE(x)) {
21242                 case  0: return (size_t) 0;
21243                 case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
21244                 case 2:
21245                     if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
21246                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
21247                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21248                         } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
21249                             return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
21250                         }
21251                     }
21252                     break;
21253                 case 3:
21254                     if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
21255                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
21256                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21257                         } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
21258                             return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
21259                         }
21260                     }
21261                     break;
21262                 case 4:
21263                     if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
21264                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
21265                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21266                         } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
21267                             return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
21268                         }
21269                     }
21270                     break;
21271             }
21272 #endif
21273 #if CYTHON_COMPILING_IN_CPYTHON
21274             if (unlikely(Py_SIZE(x) < 0)) {
21275                 goto raise_neg_overflow;
21276             }
21277 #else
21278             {
21279                 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
21280                 if (unlikely(result < 0))
21281                     return (size_t) -1;
21282                 if (unlikely(result == 1))
21283                     goto raise_neg_overflow;
21284             }
21285 #endif
21286             if (sizeof(size_t) <= sizeof(unsigned long)) {
21287                 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
21288 #ifdef HAVE_LONG_LONG
21289             } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
21290                 __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
21291 #endif
21292             }
21293         } else {
21294 #if CYTHON_USE_PYLONG_INTERNALS
21295             const digit* digits = ((PyLongObject*)x)->ob_digit;
21296             switch (Py_SIZE(x)) {
21297                 case  0: return (size_t) 0;
21298                 case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
21299                 case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
21300                 case -2:
21301                     if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
21302                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
21303                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21304                         } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
21305                             return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
21306                         }
21307                     }
21308                     break;
21309                 case 2:
21310                     if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
21311                         if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
21312                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21313                         } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
21314                             return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
21315                         }
21316                     }
21317                     break;
21318                 case -3:
21319                     if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
21320                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
21321                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21322                         } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
21323                             return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
21324                         }
21325                     }
21326                     break;
21327                 case 3:
21328                     if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
21329                         if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
21330                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21331                         } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
21332                             return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
21333                         }
21334                     }
21335                     break;
21336                 case -4:
21337                     if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
21338                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
21339                             __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21340                         } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
21341                             return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
21342                         }
21343                     }
21344                     break;
21345                 case 4:
21346                     if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
21347                         if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
21348                             __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
21349                         } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
21350                             return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
21351                         }
21352                     }
21353                     break;
21354             }
21355 #endif
21356             if (sizeof(size_t) <= sizeof(long)) {
21357                 __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
21358 #ifdef HAVE_LONG_LONG
21359             } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
21360                 __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
21361 #endif
21362             }
21363         }
21364         {
21365 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
21366             PyErr_SetString(PyExc_RuntimeError,
21367                             "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
21368 #else
21369             size_t val;
21370             PyObject *v = __Pyx_PyNumber_IntOrLong(x);
21371  #if PY_MAJOR_VERSION < 3
21372             if (likely(v) && !PyLong_Check(v)) {
21373                 PyObject *tmp = v;
21374                 v = PyNumber_Long(tmp);
21375                 Py_DECREF(tmp);
21376             }
21377  #endif
21378             if (likely(v)) {
21379                 int one = 1; int is_little = (int)*(unsigned char *)&one;
21380                 unsigned char *bytes = (unsigned char *)&val;
21381                 int ret = _PyLong_AsByteArray((PyLongObject *)v,
21382                                               bytes, sizeof(val),
21383                                               is_little, !is_unsigned);
21384                 Py_DECREF(v);
21385                 if (likely(!ret))
21386                     return val;
21387             }
21388 #endif
21389             return (size_t) -1;
21390         }
21391     } else {
21392         size_t val;
21393         PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
21394         if (!tmp) return (size_t) -1;
21395         val = __Pyx_PyInt_As_size_t(tmp);
21396         Py_DECREF(tmp);
21397         return val;
21398     }
21399 raise_overflow:
21400     PyErr_SetString(PyExc_OverflowError,
21401         "value too large to convert to size_t");
21402     return (size_t) -1;
21403 raise_neg_overflow:
21404     PyErr_SetString(PyExc_OverflowError,
21405         "can't convert negative value to size_t");
21406     return (size_t) -1;
21407 }
21408 
21409 /* FastTypeChecks */
21410 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)21411 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
21412     while (a) {
21413         a = a->tp_base;
21414         if (a == b)
21415             return 1;
21416     }
21417     return b == &PyBaseObject_Type;
21418 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)21419 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
21420     PyObject *mro;
21421     if (a == b) return 1;
21422     mro = a->tp_mro;
21423     if (likely(mro)) {
21424         Py_ssize_t i, n;
21425         n = PyTuple_GET_SIZE(mro);
21426         for (i = 0; i < n; i++) {
21427             if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
21428                 return 1;
21429         }
21430         return 0;
21431     }
21432     return __Pyx_InBases(a, b);
21433 }
21434 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)21435 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
21436     PyObject *exception, *value, *tb;
21437     int res;
21438     __Pyx_PyThreadState_declare
21439     __Pyx_PyThreadState_assign
21440     __Pyx_ErrFetch(&exception, &value, &tb);
21441     res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
21442     if (unlikely(res == -1)) {
21443         PyErr_WriteUnraisable(err);
21444         res = 0;
21445     }
21446     if (!res) {
21447         res = PyObject_IsSubclass(err, exc_type2);
21448         if (unlikely(res == -1)) {
21449             PyErr_WriteUnraisable(err);
21450             res = 0;
21451         }
21452     }
21453     __Pyx_ErrRestore(exception, value, tb);
21454     return res;
21455 }
21456 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)21457 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
21458     int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
21459     if (!res) {
21460         res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
21461     }
21462     return res;
21463 }
21464 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)21465 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
21466     Py_ssize_t i, n;
21467     assert(PyExceptionClass_Check(exc_type));
21468     n = PyTuple_GET_SIZE(tuple);
21469 #if PY_MAJOR_VERSION >= 3
21470     for (i=0; i<n; i++) {
21471         if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
21472     }
21473 #endif
21474     for (i=0; i<n; i++) {
21475         PyObject *t = PyTuple_GET_ITEM(tuple, i);
21476         #if PY_MAJOR_VERSION < 3
21477         if (likely(exc_type == t)) return 1;
21478         #endif
21479         if (likely(PyExceptionClass_Check(t))) {
21480             if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
21481         } else {
21482         }
21483     }
21484     return 0;
21485 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)21486 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
21487     if (likely(err == exc_type)) return 1;
21488     if (likely(PyExceptionClass_Check(err))) {
21489         if (likely(PyExceptionClass_Check(exc_type))) {
21490             return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
21491         } else if (likely(PyTuple_Check(exc_type))) {
21492             return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
21493         } else {
21494         }
21495     }
21496     return PyErr_GivenExceptionMatches(err, exc_type);
21497 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)21498 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
21499     assert(PyExceptionClass_Check(exc_type1));
21500     assert(PyExceptionClass_Check(exc_type2));
21501     if (likely(err == exc_type1 || err == exc_type2)) return 1;
21502     if (likely(PyExceptionClass_Check(err))) {
21503         return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
21504     }
21505     return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
21506 }
21507 #endif
21508 
21509 /* FetchCommonType */
__Pyx_FetchCommonType(PyTypeObject * type)21510 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
21511     PyObject* fake_module;
21512     PyTypeObject* cached_type = NULL;
21513     fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
21514     if (!fake_module) return NULL;
21515     Py_INCREF(fake_module);
21516     cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
21517     if (cached_type) {
21518         if (!PyType_Check((PyObject*)cached_type)) {
21519             PyErr_Format(PyExc_TypeError,
21520                 "Shared Cython type %.200s is not a type object",
21521                 type->tp_name);
21522             goto bad;
21523         }
21524         if (cached_type->tp_basicsize != type->tp_basicsize) {
21525             PyErr_Format(PyExc_TypeError,
21526                 "Shared Cython type %.200s has the wrong size, try recompiling",
21527                 type->tp_name);
21528             goto bad;
21529         }
21530     } else {
21531         if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
21532         PyErr_Clear();
21533         if (PyType_Ready(type) < 0) goto bad;
21534         if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
21535             goto bad;
21536         Py_INCREF(type);
21537         cached_type = type;
21538     }
21539 done:
21540     Py_DECREF(fake_module);
21541     return cached_type;
21542 bad:
21543     Py_XDECREF(cached_type);
21544     cached_type = NULL;
21545     goto done;
21546 }
21547 
21548 /* PyObjectCallMethod1 */
__Pyx__PyObject_CallMethod1(PyObject * method,PyObject * arg)21549 static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
21550     PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
21551     Py_DECREF(method);
21552     return result;
21553 }
__Pyx_PyObject_CallMethod1(PyObject * obj,PyObject * method_name,PyObject * arg)21554 static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
21555     PyObject *method = NULL, *result;
21556     int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
21557     if (likely(is_method)) {
21558         result = __Pyx_PyObject_Call2Args(method, obj, arg);
21559         Py_DECREF(method);
21560         return result;
21561     }
21562     if (unlikely(!method)) return NULL;
21563     return __Pyx__PyObject_CallMethod1(method, arg);
21564 }
21565 
21566 /* CoroutineBase */
21567 #include <structmember.h>
21568 #include <frameobject.h>
21569 #define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
__Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState * __pyx_tstate,PyObject ** pvalue)21570 static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
21571     PyObject *et, *ev, *tb;
21572     PyObject *value = NULL;
21573     __Pyx_ErrFetch(&et, &ev, &tb);
21574     if (!et) {
21575         Py_XDECREF(tb);
21576         Py_XDECREF(ev);
21577         Py_INCREF(Py_None);
21578         *pvalue = Py_None;
21579         return 0;
21580     }
21581     if (likely(et == PyExc_StopIteration)) {
21582         if (!ev) {
21583             Py_INCREF(Py_None);
21584             value = Py_None;
21585         }
21586 #if PY_VERSION_HEX >= 0x030300A0
21587         else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
21588             value = ((PyStopIterationObject *)ev)->value;
21589             Py_INCREF(value);
21590             Py_DECREF(ev);
21591         }
21592 #endif
21593         else if (unlikely(PyTuple_Check(ev))) {
21594             if (PyTuple_GET_SIZE(ev) >= 1) {
21595 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
21596                 value = PyTuple_GET_ITEM(ev, 0);
21597                 Py_INCREF(value);
21598 #else
21599                 value = PySequence_ITEM(ev, 0);
21600 #endif
21601             } else {
21602                 Py_INCREF(Py_None);
21603                 value = Py_None;
21604             }
21605             Py_DECREF(ev);
21606         }
21607         else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
21608             value = ev;
21609         }
21610         if (likely(value)) {
21611             Py_XDECREF(tb);
21612             Py_DECREF(et);
21613             *pvalue = value;
21614             return 0;
21615         }
21616     } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
21617         __Pyx_ErrRestore(et, ev, tb);
21618         return -1;
21619     }
21620     PyErr_NormalizeException(&et, &ev, &tb);
21621     if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
21622         __Pyx_ErrRestore(et, ev, tb);
21623         return -1;
21624     }
21625     Py_XDECREF(tb);
21626     Py_DECREF(et);
21627 #if PY_VERSION_HEX >= 0x030300A0
21628     value = ((PyStopIterationObject *)ev)->value;
21629     Py_INCREF(value);
21630     Py_DECREF(ev);
21631 #else
21632     {
21633         PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
21634         Py_DECREF(ev);
21635         if (likely(args)) {
21636             value = PySequence_GetItem(args, 0);
21637             Py_DECREF(args);
21638         }
21639         if (unlikely(!value)) {
21640             __Pyx_ErrRestore(NULL, NULL, NULL);
21641             Py_INCREF(Py_None);
21642             value = Py_None;
21643         }
21644     }
21645 #endif
21646     *pvalue = value;
21647     return 0;
21648 }
21649 static CYTHON_INLINE
__Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct * exc_state)21650 void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
21651     PyObject *t, *v, *tb;
21652     t = exc_state->exc_type;
21653     v = exc_state->exc_value;
21654     tb = exc_state->exc_traceback;
21655     exc_state->exc_type = NULL;
21656     exc_state->exc_value = NULL;
21657     exc_state->exc_traceback = NULL;
21658     Py_XDECREF(t);
21659     Py_XDECREF(v);
21660     Py_XDECREF(tb);
21661 }
21662 #define __Pyx_Coroutine_AlreadyRunningError(gen)  (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
__Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject * gen)21663 static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
21664     const char *msg;
21665     if ((0)) {
21666     #ifdef __Pyx_Coroutine_USED
21667     } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
21668         msg = "coroutine already executing";
21669     #endif
21670     #ifdef __Pyx_AsyncGen_USED
21671     } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
21672         msg = "async generator already executing";
21673     #endif
21674     } else {
21675         msg = "generator already executing";
21676     }
21677     PyErr_SetString(PyExc_ValueError, msg);
21678 }
21679 #define __Pyx_Coroutine_NotStartedError(gen)  (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
__Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject * gen)21680 static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
21681     const char *msg;
21682     if ((0)) {
21683     #ifdef __Pyx_Coroutine_USED
21684     } else if (__Pyx_Coroutine_Check(gen)) {
21685         msg = "can't send non-None value to a just-started coroutine";
21686     #endif
21687     #ifdef __Pyx_AsyncGen_USED
21688     } else if (__Pyx_AsyncGen_CheckExact(gen)) {
21689         msg = "can't send non-None value to a just-started async generator";
21690     #endif
21691     } else {
21692         msg = "can't send non-None value to a just-started generator";
21693     }
21694     PyErr_SetString(PyExc_TypeError, msg);
21695 }
21696 #define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing)  (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
__Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject * gen,PyObject * value,CYTHON_UNUSED int closing)21697 static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
21698     #ifdef __Pyx_Coroutine_USED
21699     if (!closing && __Pyx_Coroutine_Check(gen)) {
21700         PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
21701     } else
21702     #endif
21703     if (value) {
21704         #ifdef __Pyx_AsyncGen_USED
21705         if (__Pyx_AsyncGen_CheckExact(gen))
21706             PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
21707         else
21708         #endif
21709         PyErr_SetNone(PyExc_StopIteration);
21710     }
21711 }
21712 static
__Pyx_Coroutine_SendEx(__pyx_CoroutineObject * self,PyObject * value,int closing)21713 PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
21714     __Pyx_PyThreadState_declare
21715     PyThreadState *tstate;
21716     __Pyx_ExcInfoStruct *exc_state;
21717     PyObject *retval;
21718     assert(!self->is_running);
21719     if (unlikely(self->resume_label == 0)) {
21720         if (unlikely(value && value != Py_None)) {
21721             return __Pyx_Coroutine_NotStartedError((PyObject*)self);
21722         }
21723     }
21724     if (unlikely(self->resume_label == -1)) {
21725         return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
21726     }
21727 #if CYTHON_FAST_THREAD_STATE
21728     __Pyx_PyThreadState_assign
21729     tstate = __pyx_tstate;
21730 #else
21731     tstate = __Pyx_PyThreadState_Current;
21732 #endif
21733     exc_state = &self->gi_exc_state;
21734     if (exc_state->exc_type) {
21735         #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
21736         #else
21737         if (exc_state->exc_traceback) {
21738             PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback;
21739             PyFrameObject *f = tb->tb_frame;
21740             Py_XINCREF(tstate->frame);
21741             assert(f->f_back == NULL);
21742             f->f_back = tstate->frame;
21743         }
21744         #endif
21745     }
21746 #if CYTHON_USE_EXC_INFO_STACK
21747     exc_state->previous_item = tstate->exc_info;
21748     tstate->exc_info = exc_state;
21749 #else
21750     if (exc_state->exc_type) {
21751         __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
21752     } else {
21753         __Pyx_Coroutine_ExceptionClear(exc_state);
21754         __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
21755     }
21756 #endif
21757     self->is_running = 1;
21758     retval = self->body((PyObject *) self, tstate, value);
21759     self->is_running = 0;
21760 #if CYTHON_USE_EXC_INFO_STACK
21761     exc_state = &self->gi_exc_state;
21762     tstate->exc_info = exc_state->previous_item;
21763     exc_state->previous_item = NULL;
21764     __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
21765 #endif
21766     return retval;
21767 }
__Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct * exc_state)21768 static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
21769     PyObject *exc_tb = exc_state->exc_traceback;
21770     if (likely(exc_tb)) {
21771 #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
21772 #else
21773         PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
21774         PyFrameObject *f = tb->tb_frame;
21775         Py_CLEAR(f->f_back);
21776 #endif
21777     }
21778 }
21779 static CYTHON_INLINE
__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject * gen,PyObject * retval)21780 PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
21781     if (unlikely(!retval)) {
21782         __Pyx_PyThreadState_declare
21783         __Pyx_PyThreadState_assign
21784         if (!__Pyx_PyErr_Occurred()) {
21785             PyObject *exc = PyExc_StopIteration;
21786             #ifdef __Pyx_AsyncGen_USED
21787             if (__Pyx_AsyncGen_CheckExact(gen))
21788                 exc = __Pyx_PyExc_StopAsyncIteration;
21789             #endif
21790             __Pyx_PyErr_SetNone(exc);
21791         }
21792     }
21793     return retval;
21794 }
21795 static CYTHON_INLINE
__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject * gen)21796 PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
21797     PyObject *ret;
21798     PyObject *val = NULL;
21799     __Pyx_Coroutine_Undelegate(gen);
21800     __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
21801     ret = __Pyx_Coroutine_SendEx(gen, val, 0);
21802     Py_XDECREF(val);
21803     return ret;
21804 }
__Pyx_Coroutine_Send(PyObject * self,PyObject * value)21805 static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
21806     PyObject *retval;
21807     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
21808     PyObject *yf = gen->yieldfrom;
21809     if (unlikely(gen->is_running))
21810         return __Pyx_Coroutine_AlreadyRunningError(gen);
21811     if (yf) {
21812         PyObject *ret;
21813         gen->is_running = 1;
21814         #ifdef __Pyx_Generator_USED
21815         if (__Pyx_Generator_CheckExact(yf)) {
21816             ret = __Pyx_Coroutine_Send(yf, value);
21817         } else
21818         #endif
21819         #ifdef __Pyx_Coroutine_USED
21820         if (__Pyx_Coroutine_Check(yf)) {
21821             ret = __Pyx_Coroutine_Send(yf, value);
21822         } else
21823         #endif
21824         #ifdef __Pyx_AsyncGen_USED
21825         if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
21826             ret = __Pyx_async_gen_asend_send(yf, value);
21827         } else
21828         #endif
21829         #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
21830         if (PyGen_CheckExact(yf)) {
21831             ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
21832         } else
21833         #endif
21834         #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
21835         if (PyCoro_CheckExact(yf)) {
21836             ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
21837         } else
21838         #endif
21839         {
21840             if (value == Py_None)
21841                 ret = Py_TYPE(yf)->tp_iternext(yf);
21842             else
21843                 ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
21844         }
21845         gen->is_running = 0;
21846         if (likely(ret)) {
21847             return ret;
21848         }
21849         retval = __Pyx_Coroutine_FinishDelegation(gen);
21850     } else {
21851         retval = __Pyx_Coroutine_SendEx(gen, value, 0);
21852     }
21853     return __Pyx_Coroutine_MethodReturn(self, retval);
21854 }
__Pyx_Coroutine_CloseIter(__pyx_CoroutineObject * gen,PyObject * yf)21855 static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
21856     PyObject *retval = NULL;
21857     int err = 0;
21858     #ifdef __Pyx_Generator_USED
21859     if (__Pyx_Generator_CheckExact(yf)) {
21860         retval = __Pyx_Coroutine_Close(yf);
21861         if (!retval)
21862             return -1;
21863     } else
21864     #endif
21865     #ifdef __Pyx_Coroutine_USED
21866     if (__Pyx_Coroutine_Check(yf)) {
21867         retval = __Pyx_Coroutine_Close(yf);
21868         if (!retval)
21869             return -1;
21870     } else
21871     if (__Pyx_CoroutineAwait_CheckExact(yf)) {
21872         retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL);
21873         if (!retval)
21874             return -1;
21875     } else
21876     #endif
21877     #ifdef __Pyx_AsyncGen_USED
21878     if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
21879         retval = __Pyx_async_gen_asend_close(yf, NULL);
21880     } else
21881     if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
21882         retval = __Pyx_async_gen_athrow_close(yf, NULL);
21883     } else
21884     #endif
21885     {
21886         PyObject *meth;
21887         gen->is_running = 1;
21888         meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
21889         if (unlikely(!meth)) {
21890             if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
21891                 PyErr_WriteUnraisable(yf);
21892             }
21893             PyErr_Clear();
21894         } else {
21895             retval = PyObject_CallFunction(meth, NULL);
21896             Py_DECREF(meth);
21897             if (!retval)
21898                 err = -1;
21899         }
21900         gen->is_running = 0;
21901     }
21902     Py_XDECREF(retval);
21903     return err;
21904 }
__Pyx_Generator_Next(PyObject * self)21905 static PyObject *__Pyx_Generator_Next(PyObject *self) {
21906     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
21907     PyObject *yf = gen->yieldfrom;
21908     if (unlikely(gen->is_running))
21909         return __Pyx_Coroutine_AlreadyRunningError(gen);
21910     if (yf) {
21911         PyObject *ret;
21912         gen->is_running = 1;
21913         #ifdef __Pyx_Generator_USED
21914         if (__Pyx_Generator_CheckExact(yf)) {
21915             ret = __Pyx_Generator_Next(yf);
21916         } else
21917         #endif
21918         #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
21919         if (PyGen_CheckExact(yf)) {
21920             ret = _PyGen_Send((PyGenObject*)yf, NULL);
21921         } else
21922         #endif
21923         #ifdef __Pyx_Coroutine_USED
21924         if (__Pyx_Coroutine_Check(yf)) {
21925             ret = __Pyx_Coroutine_Send(yf, Py_None);
21926         } else
21927         #endif
21928             ret = Py_TYPE(yf)->tp_iternext(yf);
21929         gen->is_running = 0;
21930         if (likely(ret)) {
21931             return ret;
21932         }
21933         return __Pyx_Coroutine_FinishDelegation(gen);
21934     }
21935     return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
21936 }
__Pyx_Coroutine_Close_Method(PyObject * self,CYTHON_UNUSED PyObject * arg)21937 static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNUSED PyObject *arg) {
21938     return __Pyx_Coroutine_Close(self);
21939 }
__Pyx_Coroutine_Close(PyObject * self)21940 static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
21941     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
21942     PyObject *retval, *raised_exception;
21943     PyObject *yf = gen->yieldfrom;
21944     int err = 0;
21945     if (unlikely(gen->is_running))
21946         return __Pyx_Coroutine_AlreadyRunningError(gen);
21947     if (yf) {
21948         Py_INCREF(yf);
21949         err = __Pyx_Coroutine_CloseIter(gen, yf);
21950         __Pyx_Coroutine_Undelegate(gen);
21951         Py_DECREF(yf);
21952     }
21953     if (err == 0)
21954         PyErr_SetNone(PyExc_GeneratorExit);
21955     retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
21956     if (unlikely(retval)) {
21957         const char *msg;
21958         Py_DECREF(retval);
21959         if ((0)) {
21960         #ifdef __Pyx_Coroutine_USED
21961         } else if (__Pyx_Coroutine_Check(self)) {
21962             msg = "coroutine ignored GeneratorExit";
21963         #endif
21964         #ifdef __Pyx_AsyncGen_USED
21965         } else if (__Pyx_AsyncGen_CheckExact(self)) {
21966 #if PY_VERSION_HEX < 0x03060000
21967             msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
21968 #else
21969             msg = "async generator ignored GeneratorExit";
21970 #endif
21971         #endif
21972         } else {
21973             msg = "generator ignored GeneratorExit";
21974         }
21975         PyErr_SetString(PyExc_RuntimeError, msg);
21976         return NULL;
21977     }
21978     raised_exception = PyErr_Occurred();
21979     if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
21980         if (raised_exception) PyErr_Clear();
21981         Py_INCREF(Py_None);
21982         return Py_None;
21983     }
21984     return NULL;
21985 }
__Pyx__Coroutine_Throw(PyObject * self,PyObject * typ,PyObject * val,PyObject * tb,PyObject * args,int close_on_genexit)21986 static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
21987                                         PyObject *args, int close_on_genexit) {
21988     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
21989     PyObject *yf = gen->yieldfrom;
21990     if (unlikely(gen->is_running))
21991         return __Pyx_Coroutine_AlreadyRunningError(gen);
21992     if (yf) {
21993         PyObject *ret;
21994         Py_INCREF(yf);
21995         if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
21996             int err = __Pyx_Coroutine_CloseIter(gen, yf);
21997             Py_DECREF(yf);
21998             __Pyx_Coroutine_Undelegate(gen);
21999             if (err < 0)
22000                 return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
22001             goto throw_here;
22002         }
22003         gen->is_running = 1;
22004         if (0
22005         #ifdef __Pyx_Generator_USED
22006             || __Pyx_Generator_CheckExact(yf)
22007         #endif
22008         #ifdef __Pyx_Coroutine_USED
22009             || __Pyx_Coroutine_Check(yf)
22010         #endif
22011             ) {
22012             ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
22013         #ifdef __Pyx_Coroutine_USED
22014         } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
22015             ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
22016         #endif
22017         } else {
22018             PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
22019             if (unlikely(!meth)) {
22020                 Py_DECREF(yf);
22021                 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
22022                     gen->is_running = 0;
22023                     return NULL;
22024                 }
22025                 PyErr_Clear();
22026                 __Pyx_Coroutine_Undelegate(gen);
22027                 gen->is_running = 0;
22028                 goto throw_here;
22029             }
22030             if (likely(args)) {
22031                 ret = PyObject_CallObject(meth, args);
22032             } else {
22033                 ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
22034             }
22035             Py_DECREF(meth);
22036         }
22037         gen->is_running = 0;
22038         Py_DECREF(yf);
22039         if (!ret) {
22040             ret = __Pyx_Coroutine_FinishDelegation(gen);
22041         }
22042         return __Pyx_Coroutine_MethodReturn(self, ret);
22043     }
22044 throw_here:
22045     __Pyx_Raise(typ, val, tb, NULL);
22046     return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
22047 }
__Pyx_Coroutine_Throw(PyObject * self,PyObject * args)22048 static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
22049     PyObject *typ;
22050     PyObject *val = NULL;
22051     PyObject *tb = NULL;
22052     if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
22053         return NULL;
22054     return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
22055 }
__Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct * exc_state,visitproc visit,void * arg)22056 static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
22057     Py_VISIT(exc_state->exc_type);
22058     Py_VISIT(exc_state->exc_value);
22059     Py_VISIT(exc_state->exc_traceback);
22060     return 0;
22061 }
__Pyx_Coroutine_traverse(__pyx_CoroutineObject * gen,visitproc visit,void * arg)22062 static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
22063     Py_VISIT(gen->closure);
22064     Py_VISIT(gen->classobj);
22065     Py_VISIT(gen->yieldfrom);
22066     return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
22067 }
__Pyx_Coroutine_clear(PyObject * self)22068 static int __Pyx_Coroutine_clear(PyObject *self) {
22069     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
22070     Py_CLEAR(gen->closure);
22071     Py_CLEAR(gen->classobj);
22072     Py_CLEAR(gen->yieldfrom);
22073     __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
22074 #ifdef __Pyx_AsyncGen_USED
22075     if (__Pyx_AsyncGen_CheckExact(self)) {
22076         Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
22077     }
22078 #endif
22079     Py_CLEAR(gen->gi_code);
22080     Py_CLEAR(gen->gi_name);
22081     Py_CLEAR(gen->gi_qualname);
22082     Py_CLEAR(gen->gi_modulename);
22083     return 0;
22084 }
__Pyx_Coroutine_dealloc(PyObject * self)22085 static void __Pyx_Coroutine_dealloc(PyObject *self) {
22086     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
22087     PyObject_GC_UnTrack(gen);
22088     if (gen->gi_weakreflist != NULL)
22089         PyObject_ClearWeakRefs(self);
22090     if (gen->resume_label >= 0) {
22091         PyObject_GC_Track(self);
22092 #if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
22093         if (PyObject_CallFinalizerFromDealloc(self))
22094 #else
22095         Py_TYPE(gen)->tp_del(self);
22096         if (self->ob_refcnt > 0)
22097 #endif
22098         {
22099             return;
22100         }
22101         PyObject_GC_UnTrack(self);
22102     }
22103 #ifdef __Pyx_AsyncGen_USED
22104     if (__Pyx_AsyncGen_CheckExact(self)) {
22105         /* We have to handle this case for asynchronous generators
22106            right here, because this code has to be between UNTRACK
22107            and GC_Del. */
22108         Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
22109     }
22110 #endif
22111     __Pyx_Coroutine_clear(self);
22112     PyObject_GC_Del(gen);
22113 }
__Pyx_Coroutine_del(PyObject * self)22114 static void __Pyx_Coroutine_del(PyObject *self) {
22115     PyObject *error_type, *error_value, *error_traceback;
22116     __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
22117     __Pyx_PyThreadState_declare
22118     if (gen->resume_label < 0) {
22119         return;
22120     }
22121 #if !CYTHON_USE_TP_FINALIZE
22122     assert(self->ob_refcnt == 0);
22123     self->ob_refcnt = 1;
22124 #endif
22125     __Pyx_PyThreadState_assign
22126     __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
22127 #ifdef __Pyx_AsyncGen_USED
22128     if (__Pyx_AsyncGen_CheckExact(self)) {
22129         __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
22130         PyObject *finalizer = agen->ag_finalizer;
22131         if (finalizer && !agen->ag_closed) {
22132             PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
22133             if (unlikely(!res)) {
22134                 PyErr_WriteUnraisable(self);
22135             } else {
22136                 Py_DECREF(res);
22137             }
22138             __Pyx_ErrRestore(error_type, error_value, error_traceback);
22139             return;
22140         }
22141     }
22142 #endif
22143     if (unlikely(gen->resume_label == 0 && !error_value)) {
22144 #ifdef __Pyx_Coroutine_USED
22145 #ifdef __Pyx_Generator_USED
22146     if (!__Pyx_Generator_CheckExact(self))
22147 #endif
22148         {
22149         PyObject_GC_UnTrack(self);
22150 #if PY_MAJOR_VERSION >= 3  || defined(PyErr_WarnFormat)
22151         if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
22152             PyErr_WriteUnraisable(self);
22153 #else
22154         {PyObject *msg;
22155         char *cmsg;
22156         #if CYTHON_COMPILING_IN_PYPY
22157         msg = NULL;
22158         cmsg = (char*) "coroutine was never awaited";
22159         #else
22160         char *cname;
22161         PyObject *qualname;
22162         qualname = gen->gi_qualname;
22163         cname = PyString_AS_STRING(qualname);
22164         msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
22165         if (unlikely(!msg)) {
22166             PyErr_Clear();
22167             cmsg = (char*) "coroutine was never awaited";
22168         } else {
22169             cmsg = PyString_AS_STRING(msg);
22170         }
22171         #endif
22172         if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
22173             PyErr_WriteUnraisable(self);
22174         Py_XDECREF(msg);}
22175 #endif
22176         PyObject_GC_Track(self);
22177         }
22178 #endif
22179     } else {
22180         PyObject *res = __Pyx_Coroutine_Close(self);
22181         if (unlikely(!res)) {
22182             if (PyErr_Occurred())
22183                 PyErr_WriteUnraisable(self);
22184         } else {
22185             Py_DECREF(res);
22186         }
22187     }
22188     __Pyx_ErrRestore(error_type, error_value, error_traceback);
22189 #if !CYTHON_USE_TP_FINALIZE
22190     assert(self->ob_refcnt > 0);
22191     if (--self->ob_refcnt == 0) {
22192         return;
22193     }
22194     {
22195         Py_ssize_t refcnt = self->ob_refcnt;
22196         _Py_NewReference(self);
22197         self->ob_refcnt = refcnt;
22198     }
22199 #if CYTHON_COMPILING_IN_CPYTHON
22200     assert(PyType_IS_GC(self->ob_type) &&
22201            _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
22202     _Py_DEC_REFTOTAL;
22203 #endif
22204 #ifdef COUNT_ALLOCS
22205     --Py_TYPE(self)->tp_frees;
22206     --Py_TYPE(self)->tp_allocs;
22207 #endif
22208 #endif
22209 }
22210 static PyObject *
__Pyx_Coroutine_get_name(__pyx_CoroutineObject * self,CYTHON_UNUSED void * context)22211 __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
22212 {
22213     PyObject *name = self->gi_name;
22214     if (unlikely(!name)) name = Py_None;
22215     Py_INCREF(name);
22216     return name;
22217 }
22218 static int
__Pyx_Coroutine_set_name(__pyx_CoroutineObject * self,PyObject * value,CYTHON_UNUSED void * context)22219 __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
22220 {
22221     PyObject *tmp;
22222 #if PY_MAJOR_VERSION >= 3
22223     if (unlikely(value == NULL || !PyUnicode_Check(value)))
22224 #else
22225     if (unlikely(value == NULL || !PyString_Check(value)))
22226 #endif
22227     {
22228         PyErr_SetString(PyExc_TypeError,
22229                         "__name__ must be set to a string object");
22230         return -1;
22231     }
22232     tmp = self->gi_name;
22233     Py_INCREF(value);
22234     self->gi_name = value;
22235     Py_XDECREF(tmp);
22236     return 0;
22237 }
22238 static PyObject *
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject * self,CYTHON_UNUSED void * context)22239 __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
22240 {
22241     PyObject *name = self->gi_qualname;
22242     if (unlikely(!name)) name = Py_None;
22243     Py_INCREF(name);
22244     return name;
22245 }
22246 static int
__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject * self,PyObject * value,CYTHON_UNUSED void * context)22247 __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
22248 {
22249     PyObject *tmp;
22250 #if PY_MAJOR_VERSION >= 3
22251     if (unlikely(value == NULL || !PyUnicode_Check(value)))
22252 #else
22253     if (unlikely(value == NULL || !PyString_Check(value)))
22254 #endif
22255     {
22256         PyErr_SetString(PyExc_TypeError,
22257                         "__qualname__ must be set to a string object");
22258         return -1;
22259     }
22260     tmp = self->gi_qualname;
22261     Py_INCREF(value);
22262     self->gi_qualname = value;
22263     Py_XDECREF(tmp);
22264     return 0;
22265 }
__Pyx__Coroutine_New(PyTypeObject * type,__pyx_coroutine_body_t body,PyObject * code,PyObject * closure,PyObject * name,PyObject * qualname,PyObject * module_name)22266 static __pyx_CoroutineObject *__Pyx__Coroutine_New(
22267             PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
22268             PyObject *name, PyObject *qualname, PyObject *module_name) {
22269     __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
22270     if (unlikely(!gen))
22271         return NULL;
22272     return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
22273 }
__Pyx__Coroutine_NewInit(__pyx_CoroutineObject * gen,__pyx_coroutine_body_t body,PyObject * code,PyObject * closure,PyObject * name,PyObject * qualname,PyObject * module_name)22274 static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
22275             __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
22276             PyObject *name, PyObject *qualname, PyObject *module_name) {
22277     gen->body = body;
22278     gen->closure = closure;
22279     Py_XINCREF(closure);
22280     gen->is_running = 0;
22281     gen->resume_label = 0;
22282     gen->classobj = NULL;
22283     gen->yieldfrom = NULL;
22284     gen->gi_exc_state.exc_type = NULL;
22285     gen->gi_exc_state.exc_value = NULL;
22286     gen->gi_exc_state.exc_traceback = NULL;
22287 #if CYTHON_USE_EXC_INFO_STACK
22288     gen->gi_exc_state.previous_item = NULL;
22289 #endif
22290     gen->gi_weakreflist = NULL;
22291     Py_XINCREF(qualname);
22292     gen->gi_qualname = qualname;
22293     Py_XINCREF(name);
22294     gen->gi_name = name;
22295     Py_XINCREF(module_name);
22296     gen->gi_modulename = module_name;
22297     Py_XINCREF(code);
22298     gen->gi_code = code;
22299     PyObject_GC_Track(gen);
22300     return gen;
22301 }
22302 
22303 /* PatchModuleWithCoroutine */
__Pyx_Coroutine_patch_module(PyObject * module,const char * py_code)22304 static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
22305 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
22306     int result;
22307     PyObject *globals, *result_obj;
22308     globals = PyDict_New();  if (unlikely(!globals)) goto ignore;
22309     result = PyDict_SetItemString(globals, "_cython_coroutine_type",
22310     #ifdef __Pyx_Coroutine_USED
22311         (PyObject*)__pyx_CoroutineType);
22312     #else
22313         Py_None);
22314     #endif
22315     if (unlikely(result < 0)) goto ignore;
22316     result = PyDict_SetItemString(globals, "_cython_generator_type",
22317     #ifdef __Pyx_Generator_USED
22318         (PyObject*)__pyx_GeneratorType);
22319     #else
22320         Py_None);
22321     #endif
22322     if (unlikely(result < 0)) goto ignore;
22323     if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
22324     if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
22325     result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
22326     if (unlikely(!result_obj)) goto ignore;
22327     Py_DECREF(result_obj);
22328     Py_DECREF(globals);
22329     return module;
22330 ignore:
22331     Py_XDECREF(globals);
22332     PyErr_WriteUnraisable(module);
22333     if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
22334         Py_DECREF(module);
22335         module = NULL;
22336     }
22337 #else
22338     py_code++;
22339 #endif
22340     return module;
22341 }
22342 
22343 /* PatchGeneratorABC */
22344 #ifndef CYTHON_REGISTER_ABCS
22345 #define CYTHON_REGISTER_ABCS 1
22346 #endif
22347 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
22348 static PyObject* __Pyx_patch_abc_module(PyObject *module);
__Pyx_patch_abc_module(PyObject * module)22349 static PyObject* __Pyx_patch_abc_module(PyObject *module) {
22350     module = __Pyx_Coroutine_patch_module(
22351         module, ""
22352 "if _cython_generator_type is not None:\n"
22353 "    try: Generator = _module.Generator\n"
22354 "    except AttributeError: pass\n"
22355 "    else: Generator.register(_cython_generator_type)\n"
22356 "if _cython_coroutine_type is not None:\n"
22357 "    try: Coroutine = _module.Coroutine\n"
22358 "    except AttributeError: pass\n"
22359 "    else: Coroutine.register(_cython_coroutine_type)\n"
22360     );
22361     return module;
22362 }
22363 #endif
__Pyx_patch_abc(void)22364 static int __Pyx_patch_abc(void) {
22365 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
22366     static int abc_patched = 0;
22367     if (CYTHON_REGISTER_ABCS && !abc_patched) {
22368         PyObject *module;
22369         module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
22370         if (!module) {
22371             PyErr_WriteUnraisable(NULL);
22372             if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
22373                     ((PY_MAJOR_VERSION >= 3) ?
22374                         "Cython module failed to register with collections.abc module" :
22375                         "Cython module failed to register with collections module"), 1) < 0)) {
22376                 return -1;
22377             }
22378         } else {
22379             module = __Pyx_patch_abc_module(module);
22380             abc_patched = 1;
22381             if (unlikely(!module))
22382                 return -1;
22383             Py_DECREF(module);
22384         }
22385         module = PyImport_ImportModule("backports_abc");
22386         if (module) {
22387             module = __Pyx_patch_abc_module(module);
22388             Py_XDECREF(module);
22389         }
22390         if (!module) {
22391             PyErr_Clear();
22392         }
22393     }
22394 #else
22395     if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
22396 #endif
22397     return 0;
22398 }
22399 
22400 /* Generator */
22401 static PyMethodDef __pyx_Generator_methods[] = {
22402     {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
22403      (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
22404     {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
22405      (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
22406     {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
22407      (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
22408     {0, 0, 0, 0}
22409 };
22410 static PyMemberDef __pyx_Generator_memberlist[] = {
22411     {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
22412     {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
22413      (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
22414     {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
22415     {0, 0, 0, 0, 0}
22416 };
22417 static PyGetSetDef __pyx_Generator_getsets[] = {
22418     {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
22419      (char*) PyDoc_STR("name of the generator"), 0},
22420     {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
22421      (char*) PyDoc_STR("qualified name of the generator"), 0},
22422     {0, 0, 0, 0, 0}
22423 };
22424 static PyTypeObject __pyx_GeneratorType_type = {
22425     PyVarObject_HEAD_INIT(0, 0)
22426     "generator",
22427     sizeof(__pyx_CoroutineObject),
22428     0,
22429     (destructor) __Pyx_Coroutine_dealloc,
22430     0,
22431     0,
22432     0,
22433     0,
22434     0,
22435     0,
22436     0,
22437     0,
22438     0,
22439     0,
22440     0,
22441     0,
22442     0,
22443     0,
22444     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
22445     0,
22446     (traverseproc) __Pyx_Coroutine_traverse,
22447     0,
22448     0,
22449     offsetof(__pyx_CoroutineObject, gi_weakreflist),
22450     0,
22451     (iternextfunc) __Pyx_Generator_Next,
22452     __pyx_Generator_methods,
22453     __pyx_Generator_memberlist,
22454     __pyx_Generator_getsets,
22455     0,
22456     0,
22457     0,
22458     0,
22459     0,
22460     0,
22461     0,
22462     0,
22463     0,
22464     0,
22465     0,
22466     0,
22467     0,
22468     0,
22469     0,
22470 #if CYTHON_USE_TP_FINALIZE
22471     0,
22472 #else
22473     __Pyx_Coroutine_del,
22474 #endif
22475     0,
22476 #if CYTHON_USE_TP_FINALIZE
22477     __Pyx_Coroutine_del,
22478 #elif PY_VERSION_HEX >= 0x030400a1
22479     0,
22480 #endif
22481 #if PY_VERSION_HEX >= 0x030800b1
22482     0,
22483 #endif
22484 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
22485     0,
22486 #endif
22487 };
__pyx_Generator_init(void)22488 static int __pyx_Generator_init(void) {
22489     __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
22490     __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
22491     __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
22492     if (unlikely(!__pyx_GeneratorType)) {
22493         return -1;
22494     }
22495     return 0;
22496 }
22497 
22498 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)22499 static int __Pyx_check_binary_version(void) {
22500     char ctversion[4], rtversion[4];
22501     PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
22502     PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
22503     if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
22504         char message[200];
22505         PyOS_snprintf(message, sizeof(message),
22506                       "compiletime version %s of module '%.100s' "
22507                       "does not match runtime version %s",
22508                       ctversion, __Pyx_MODULE_NAME, rtversion);
22509         return PyErr_WarnEx(NULL, message, 1);
22510     }
22511     return 0;
22512 }
22513 
22514 /* FunctionImport */
22515 #ifndef __PYX_HAVE_RT_ImportFunction
22516 #define __PYX_HAVE_RT_ImportFunction
__Pyx_ImportFunction(PyObject * module,const char * funcname,void (** f)(void),const char * sig)22517 static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
22518     PyObject *d = 0;
22519     PyObject *cobj = 0;
22520     union {
22521         void (*fp)(void);
22522         void *p;
22523     } tmp;
22524     d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
22525     if (!d)
22526         goto bad;
22527     cobj = PyDict_GetItemString(d, funcname);
22528     if (!cobj) {
22529         PyErr_Format(PyExc_ImportError,
22530             "%.200s does not export expected C function %.200s",
22531                 PyModule_GetName(module), funcname);
22532         goto bad;
22533     }
22534 #if PY_VERSION_HEX >= 0x02070000
22535     if (!PyCapsule_IsValid(cobj, sig)) {
22536         PyErr_Format(PyExc_TypeError,
22537             "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
22538              PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
22539         goto bad;
22540     }
22541     tmp.p = PyCapsule_GetPointer(cobj, sig);
22542 #else
22543     {const char *desc, *s1, *s2;
22544     desc = (const char *)PyCObject_GetDesc(cobj);
22545     if (!desc)
22546         goto bad;
22547     s1 = desc; s2 = sig;
22548     while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
22549     if (*s1 != *s2) {
22550         PyErr_Format(PyExc_TypeError,
22551             "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
22552              PyModule_GetName(module), funcname, sig, desc);
22553         goto bad;
22554     }
22555     tmp.p = PyCObject_AsVoidPtr(cobj);}
22556 #endif
22557     *f = tmp.fp;
22558     if (!(*f))
22559         goto bad;
22560     Py_DECREF(d);
22561     return 0;
22562 bad:
22563     Py_XDECREF(d);
22564     return -1;
22565 }
22566 #endif
22567 
22568 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)22569 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
22570     while (t->p) {
22571         #if PY_MAJOR_VERSION < 3
22572         if (t->is_unicode) {
22573             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
22574         } else if (t->intern) {
22575             *t->p = PyString_InternFromString(t->s);
22576         } else {
22577             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
22578         }
22579         #else
22580         if (t->is_unicode | t->is_str) {
22581             if (t->intern) {
22582                 *t->p = PyUnicode_InternFromString(t->s);
22583             } else if (t->encoding) {
22584                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
22585             } else {
22586                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
22587             }
22588         } else {
22589             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
22590         }
22591         #endif
22592         if (!*t->p)
22593             return -1;
22594         if (PyObject_Hash(*t->p) == -1)
22595             return -1;
22596         ++t;
22597     }
22598     return 0;
22599 }
22600 
__Pyx_PyUnicode_FromString(const char * c_str)22601 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
22602     return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
22603 }
__Pyx_PyObject_AsString(PyObject * o)22604 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
22605     Py_ssize_t ignore;
22606     return __Pyx_PyObject_AsStringAndSize(o, &ignore);
22607 }
22608 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
22609 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)22610 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
22611     char* defenc_c;
22612     PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
22613     if (!defenc) return NULL;
22614     defenc_c = PyBytes_AS_STRING(defenc);
22615 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
22616     {
22617         char* end = defenc_c + PyBytes_GET_SIZE(defenc);
22618         char* c;
22619         for (c = defenc_c; c < end; c++) {
22620             if ((unsigned char) (*c) >= 128) {
22621                 PyUnicode_AsASCIIString(o);
22622                 return NULL;
22623             }
22624         }
22625     }
22626 #endif
22627     *length = PyBytes_GET_SIZE(defenc);
22628     return defenc_c;
22629 }
22630 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)22631 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
22632     if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
22633 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
22634     if (likely(PyUnicode_IS_ASCII(o))) {
22635         *length = PyUnicode_GET_LENGTH(o);
22636         return PyUnicode_AsUTF8(o);
22637     } else {
22638         PyUnicode_AsASCIIString(o);
22639         return NULL;
22640     }
22641 #else
22642     return PyUnicode_AsUTF8AndSize(o, length);
22643 #endif
22644 }
22645 #endif
22646 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)22647 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
22648 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
22649     if (
22650 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
22651             __Pyx_sys_getdefaultencoding_not_ascii &&
22652 #endif
22653             PyUnicode_Check(o)) {
22654         return __Pyx_PyUnicode_AsStringAndSize(o, length);
22655     } else
22656 #endif
22657 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
22658     if (PyByteArray_Check(o)) {
22659         *length = PyByteArray_GET_SIZE(o);
22660         return PyByteArray_AS_STRING(o);
22661     } else
22662 #endif
22663     {
22664         char* result;
22665         int r = PyBytes_AsStringAndSize(o, &result, length);
22666         if (unlikely(r < 0)) {
22667             return NULL;
22668         } else {
22669             return result;
22670         }
22671     }
22672 }
__Pyx_PyObject_IsTrue(PyObject * x)22673 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
22674    int is_true = x == Py_True;
22675    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
22676    else return PyObject_IsTrue(x);
22677 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)22678 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
22679     int retval;
22680     if (unlikely(!x)) return -1;
22681     retval = __Pyx_PyObject_IsTrue(x);
22682     Py_DECREF(x);
22683     return retval;
22684 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)22685 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
22686 #if PY_MAJOR_VERSION >= 3
22687     if (PyLong_Check(result)) {
22688         if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
22689                 "__int__ returned non-int (type %.200s).  "
22690                 "The ability to return an instance of a strict subclass of int "
22691                 "is deprecated, and may be removed in a future version of Python.",
22692                 Py_TYPE(result)->tp_name)) {
22693             Py_DECREF(result);
22694             return NULL;
22695         }
22696         return result;
22697     }
22698 #endif
22699     PyErr_Format(PyExc_TypeError,
22700                  "__%.4s__ returned non-%.4s (type %.200s)",
22701                  type_name, type_name, Py_TYPE(result)->tp_name);
22702     Py_DECREF(result);
22703     return NULL;
22704 }
__Pyx_PyNumber_IntOrLong(PyObject * x)22705 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
22706 #if CYTHON_USE_TYPE_SLOTS
22707   PyNumberMethods *m;
22708 #endif
22709   const char *name = NULL;
22710   PyObject *res = NULL;
22711 #if PY_MAJOR_VERSION < 3
22712   if (likely(PyInt_Check(x) || PyLong_Check(x)))
22713 #else
22714   if (likely(PyLong_Check(x)))
22715 #endif
22716     return __Pyx_NewRef(x);
22717 #if CYTHON_USE_TYPE_SLOTS
22718   m = Py_TYPE(x)->tp_as_number;
22719   #if PY_MAJOR_VERSION < 3
22720   if (m && m->nb_int) {
22721     name = "int";
22722     res = m->nb_int(x);
22723   }
22724   else if (m && m->nb_long) {
22725     name = "long";
22726     res = m->nb_long(x);
22727   }
22728   #else
22729   if (likely(m && m->nb_int)) {
22730     name = "int";
22731     res = m->nb_int(x);
22732   }
22733   #endif
22734 #else
22735   if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
22736     res = PyNumber_Int(x);
22737   }
22738 #endif
22739   if (likely(res)) {
22740 #if PY_MAJOR_VERSION < 3
22741     if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
22742 #else
22743     if (unlikely(!PyLong_CheckExact(res))) {
22744 #endif
22745         return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
22746     }
22747   }
22748   else if (!PyErr_Occurred()) {
22749     PyErr_SetString(PyExc_TypeError,
22750                     "an integer is required");
22751   }
22752   return res;
22753 }
22754 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
22755   Py_ssize_t ival;
22756   PyObject *x;
22757 #if PY_MAJOR_VERSION < 3
22758   if (likely(PyInt_CheckExact(b))) {
22759     if (sizeof(Py_ssize_t) >= sizeof(long))
22760         return PyInt_AS_LONG(b);
22761     else
22762         return PyInt_AsSsize_t(b);
22763   }
22764 #endif
22765   if (likely(PyLong_CheckExact(b))) {
22766     #if CYTHON_USE_PYLONG_INTERNALS
22767     const digit* digits = ((PyLongObject*)b)->ob_digit;
22768     const Py_ssize_t size = Py_SIZE(b);
22769     if (likely(__Pyx_sst_abs(size) <= 1)) {
22770         ival = likely(size) ? digits[0] : 0;
22771         if (size == -1) ival = -ival;
22772         return ival;
22773     } else {
22774       switch (size) {
22775          case 2:
22776            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
22777              return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
22778            }
22779            break;
22780          case -2:
22781            if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
22782              return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
22783            }
22784            break;
22785          case 3:
22786            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
22787              return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
22788            }
22789            break;
22790          case -3:
22791            if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
22792              return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
22793            }
22794            break;
22795          case 4:
22796            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
22797              return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
22798            }
22799            break;
22800          case -4:
22801            if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
22802              return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
22803            }
22804            break;
22805       }
22806     }
22807     #endif
22808     return PyLong_AsSsize_t(b);
22809   }
22810   x = PyNumber_Index(b);
22811   if (!x) return -1;
22812   ival = PyInt_AsSsize_t(x);
22813   Py_DECREF(x);
22814   return ival;
22815 }
22816 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
22817   return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
22818 }
22819 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
22820     return PyInt_FromSize_t(ival);
22821 }
22822 
22823 
22824 #endif /* Py_PYTHON_H */
22825