/* Generated by Cython 0.15 on Sat Jan  7 12:59:35 2012 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#else

#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif

#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif

#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif

#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif

#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
#endif

#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_AsInt(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#endif

#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)

  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;

  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)

#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#endif

#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif

#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif

#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)

#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif

#if PY_VERSION_HEX < 0x03020000
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__fiona__ogrext
#define __PYX_HAVE_API__fiona__ogrext
#include "cpl_conv.h"
#include "ogr_srs_api.h"
#include "ogr_api.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


/* inline attribute */
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

/* unused attribute */
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || defined(__INTEL_COMPILER)
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif

typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/


/* Type Conversion Predeclarations */

#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))

#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))


#ifdef __GNUC__
  /* Test for GCC > 2.95 */
  #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
    #define likely(x)   __builtin_expect(!!(x), 1)
    #define unlikely(x) __builtin_expect(!!(x), 0)
  #else /* __GNUC__ > 2 ... */
    #define likely(x)   (x)
    #define unlikely(x) (x)
  #endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "ogrext.pyx",
};

/* "ograpi.pxd":8
 *     void    CPLFree (void *ptr)
 * 
 * ctypedef int OGRErr             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "ogr_srs_api.h":
 */
typedef int __pyx_t_5fiona_6ograpi_OGRErr;

/*--- Type declarations ---*/
struct __pyx_obj_5fiona_6ogrext_OGRFeatureBuilder;
struct __pyx_obj_5fiona_6ogrext_Session;
struct __pyx_obj_5fiona_6ogrext_WritingSession;
struct __pyx_obj_5fiona_6ogrext_Iterator;
struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder;
struct __pyx_obj_5fiona_6ogrext_FeatureBuilder;
struct __pyx_obj_5fiona_6ogrext_GeomBuilder;

/* "fiona/ogrext.pyx":391
 * 
 * 
 * cdef class OGRFeatureBuilder:             # <<<<<<<<<<<<<<
 * 
 *     """Builds an OGR Feature from a Fiona feature mapping.
 */
struct __pyx_obj_5fiona_6ogrext_OGRFeatureBuilder {
  PyObject_HEAD
  struct __pyx_vtabstruct_5fiona_6ogrext_OGRFeatureBuilder *__pyx_vtab;
};


/* "fiona/ogrext.pyx":447
 * # Collection-related extension classes and functions
 * 
 * cdef class Session:             # <<<<<<<<<<<<<<
 * 
 *     cdef void *cogr_ds
 */
struct __pyx_obj_5fiona_6ogrext_Session {
  PyObject_HEAD
  void *cogr_ds;
  void *cogr_layer;
};


/* "fiona/ogrext.pyx":541
 * 
 * 
 * cdef class WritingSession(Session):             # <<<<<<<<<<<<<<
 * 
 *     def start(self, collection):
 */
struct __pyx_obj_5fiona_6ogrext_WritingSession {
  struct __pyx_obj_5fiona_6ogrext_Session __pyx_base;
};


/* "fiona/ogrext.pyx":636
 * 
 * 
 * cdef class Iterator:             # <<<<<<<<<<<<<<
 * 
 *     """Provides iterated access to feature data.
 */
struct __pyx_obj_5fiona_6ogrext_Iterator {
  PyObject_HEAD
  PyObject *collection;
};


/* "fiona/ogrext.pyx":187
 * 
 * 
 * cdef class OGRGeomBuilder:             # <<<<<<<<<<<<<<
 *     """Builds OGR geometries from Fiona geometries.
 *     """
 */
struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder {
  PyObject_HEAD
  struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *__pyx_vtab;
  PyObject *coordinates;
  PyObject *typename;
  PyObject *ndims;
};


/* "fiona/ogrext.pyx":347
 * # Feature extension classes and functions follow.
 * 
 * cdef class FeatureBuilder:             # <<<<<<<<<<<<<<
 *     """Build Fiona features from OGR feature pointers.
 * 
 */
struct __pyx_obj_5fiona_6ogrext_FeatureBuilder {
  PyObject_HEAD
  struct __pyx_vtabstruct_5fiona_6ogrext_FeatureBuilder *__pyx_vtab;
};


/* "fiona/ogrext.pyx":109
 * 
 * 
 * cdef class GeomBuilder:             # <<<<<<<<<<<<<<
 *     """Builds Fiona (GeoJSON) geometries from an OGR geometry handle.
 *     """
 */
struct __pyx_obj_5fiona_6ogrext_GeomBuilder {
  PyObject_HEAD
  struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *__pyx_vtab;
  void *geom;
  PyObject *code;
  PyObject *typename;
  PyObject *ndims;
};



struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder {
  PyObject *(*_buildCoords)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, void *);
  PyObject *(*_buildPoint)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch);
  PyObject *(*_buildLineString)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch);
  PyObject *(*_buildLinearRing)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch);
  PyObject *(*_buildParts)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, void *);
  PyObject *(*_buildPolygon)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch);
  PyObject *(*_buildMultiPoint)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch);
  PyObject *(*_buildMultiLineString)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch);
  PyObject *(*_buildMultiPolygon)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch);
  PyObject *(*_buildGeometryCollection)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch);
  PyObject *(*build)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, void *);
  PyObject *(*build_wkb)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *__pyx_vtabptr_5fiona_6ogrext_GeomBuilder;


/* "fiona/ogrext.pyx":187
 * 
 * 
 * cdef class OGRGeomBuilder:             # <<<<<<<<<<<<<<
 *     """Builds OGR geometries from Fiona geometries.
 *     """
 */

struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder {
  void *(*_buildPoint)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *);
  void *(*_buildLineString)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *);
  void *(*_buildLinearRing)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *);
  void *(*_buildPolygon)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *);
  void *(*_buildMultiPoint)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *);
  void *(*_buildMultiLineString)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *);
  void *(*_buildMultiPolygon)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *);
  void *(*_buildGeometryCollection)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *);
  void *(*build)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *, PyObject *);
};
static struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *__pyx_vtabptr_5fiona_6ogrext_OGRGeomBuilder;


/* "fiona/ogrext.pyx":391
 * 
 * 
 * cdef class OGRFeatureBuilder:             # <<<<<<<<<<<<<<
 * 
 *     """Builds an OGR Feature from a Fiona feature mapping.
 */

struct __pyx_vtabstruct_5fiona_6ogrext_OGRFeatureBuilder {
  void *(*build)(struct __pyx_obj_5fiona_6ogrext_OGRFeatureBuilder *, PyObject *, PyObject *);
};
static struct __pyx_vtabstruct_5fiona_6ogrext_OGRFeatureBuilder *__pyx_vtabptr_5fiona_6ogrext_OGRFeatureBuilder;


/* "fiona/ogrext.pyx":347
 * # Feature extension classes and functions follow.
 * 
 * cdef class FeatureBuilder:             # <<<<<<<<<<<<<<
 *     """Build Fiona features from OGR feature pointers.
 * 
 */

struct __pyx_vtabstruct_5fiona_6ogrext_FeatureBuilder {
  PyObject *(*build)(struct __pyx_obj_5fiona_6ogrext_FeatureBuilder *, void *);
};
static struct __pyx_vtabstruct_5fiona_6ogrext_FeatureBuilder *__pyx_vtabptr_5fiona_6ogrext_FeatureBuilder;

#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif

#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  #define __Pyx_RefNannySetupContext(name)           __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif /* CYTHON_REFNANNY */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/


static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}


#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}


#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
    PyObject *r;
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
        r = PySequence_GetItem(o, i);
    }
    else {
        r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
    }
    return r;
}

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name, PyObject* kw_name); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
    const char* function_name, int kw_allowed); /*proto*/

static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */

#define __Pyx_PyObject_AsDouble(obj) \
    ((likely(PyFloat_CheckExact(obj))) ? \
     PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))

static CYTHON_INLINE int __Pyx_NegateNonNeg(int b) { 
    return unlikely(b < 0) ? b : !b; 
}
static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
    return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/

static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
                                   PyObject *modname); /*proto*/

#define __pyx_binding_PyCFunctionType_USED 1

typedef struct {
    PyCFunctionObject func;
} __pyx_binding_PyCFunctionType_object;

static PyTypeObject __pyx_binding_PyCFunctionType_type;
static PyTypeObject *__pyx_binding_PyCFunctionType = NULL;

static PyObject *__pyx_binding_PyCFunctionType_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module); /* proto */
#define __pyx_binding_PyCFunctionType_New(ml, self) __pyx_binding_PyCFunctionType_NewEx(ml, self, NULL)

static int __pyx_binding_PyCFunctionType_init(void); /* proto */

static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); /*proto*/

#include <string.h>

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/

#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static int __Pyx_check_binary_version(void);

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno,
                               int __pyx_lineno, const char *__pyx_filename); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/

/* Module declarations from 'fiona' */

/* Module declarations from 'fiona.ograpi' */

/* Module declarations from 'fiona.ogrext' */
static PyTypeObject *__pyx_ptype_5fiona_6ogrext_GeomBuilder = 0;
static PyTypeObject *__pyx_ptype_5fiona_6ogrext_OGRGeomBuilder = 0;
static PyTypeObject *__pyx_ptype_5fiona_6ogrext_FeatureBuilder = 0;
static PyTypeObject *__pyx_ptype_5fiona_6ogrext_OGRFeatureBuilder = 0;
static PyTypeObject *__pyx_ptype_5fiona_6ogrext_Session = 0;
static PyTypeObject *__pyx_ptype_5fiona_6ogrext_WritingSession = 0;
static PyTypeObject *__pyx_ptype_5fiona_6ogrext_Iterator = 0;
static void *__pyx_f_5fiona_6ogrext__createOgrGeomFromWKB(PyObject *); /*proto*/
static PyObject *__pyx_f_5fiona_6ogrext__deleteOgrGeom(void *); /*proto*/
static PyObject *__pyx_f_5fiona_6ogrext_geometry(void *); /*proto*/
static PyObject *__pyx_f_5fiona_6ogrext__deleteOgrFeature(void *); /*proto*/
#define __Pyx_MODULE_NAME "fiona.ogrext"
int __pyx_module_is_main_fiona__ogrext = 0;

/* Implementation of 'fiona.ogrext' */
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_bytearray;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_OSError;
static PyObject *__pyx_builtin_AssertionError;
static PyObject *__pyx_builtin_StopIteration;
static char __pyx_k_1[] = "_buildMultiLineString";
static char __pyx_k_2[] = "_buildGeometryCollection";
static char __pyx_k_3[] = "Adding point %s";
static char __pyx_k_4[] = "Adding values %f, %f";
static char __pyx_k_5[] = "Closing ring";
static char __pyx_k_7[] = "Adding ring %s";
static char __pyx_k_8[] = "Built ring";
static char __pyx_k_10[] = "Added ring %s";
static char __pyx_k_11[] = "Added point %s";
static char __pyx_k_12[] = "Adding line %s";
static char __pyx_k_13[] = "Built line";
static char __pyx_k_15[] = "Added line %s";
static char __pyx_k_16[] = "Adding polygon %s";
static char __pyx_k_17[] = "Built polygon";
static char __pyx_k_19[] = "Added polygon %s";
static char __pyx_k_20[] = "Adding part %s";
static char __pyx_k_21[] = "Built part";
static char __pyx_k_23[] = "Added part %s";
static char __pyx_k_26[] = "Unsupported geometry type %s";
static char __pyx_k_27[] = "Geometry: %s";
static char __pyx_k_28[] = "Invalid field type %s";
static char __pyx_k_29[] = "utf-8";
static char __pyx_k_30[] = "Set field %s: %s";
static char __pyx_k_31[] = "Got coordinate system";
static char __pyx_k_33[] = "Params: %s";
static char __pyx_k_34[] = "=";
static char __pyx_k_36[] = "Unexpected proj parameter %s";
static char __pyx_k_37[] = "+";
static char __pyx_k_39[] = "Projection not found (cogr_crs was NULL)";
static char __pyx_k_41[] = "Failed to open %s";
static char __pyx_k_42[] = "Failed to get layer %s";
static char __pyx_k_43[] = "No such file or directory %s";
static char __pyx_k_44[] = "Deleted pre-existing data at %s";
static char __pyx_k_45[] = "+%s";
static char __pyx_k_46[] = "+%s=%s";
static char __pyx_k_47[] = " ";
static char __pyx_k_48[] = "Created layer";
static char __pyx_k_50[] = "Creating field: %s %s";
static char __pyx_k_51[] = "Created fields";
static char __pyx_k_53[] = "Writing started";
static char __pyx_k_55[] = "Creating feature in layer: %s";
static char __pyx_k_56[] = "Feature data not match collection schema";
static char __pyx_k_58[] = "Failed to add feature: %s";
static char __pyx_k_59[] = "I/O operation on closed collection";
static char __pyx_k_62[] = "OGRERR_NOT_ENOUGH_DATA";
static char __pyx_k_63[] = "OGRERR_NOT_ENOUGH_MEMORY";
static char __pyx_k_64[] = "OGRERR_UNSUPPORTED_GEOMETRY_TYPE";
static char __pyx_k_65[] = "OGRERR_UNSUPPORTED_OPERATION";
static char __pyx_k_66[] = "OGRERR_UNSUPPORTED_SRS";
static char __pyx_k_67[] = "OGRERR_INVALID_HANDLE";
static char __pyx_k_68[] = "fiona.ogrext";
static char __pyx_k_69[] = "getNumDimsLineString";
static char __pyx_k_70[] = "getNumDimsLinearRing";
static char __pyx_k_71[] = "getNumDimsMultiPoint";
static char __pyx_k_72[] = "getNumDimsMultiLineString";
static char __pyx_k_73[] = "getNumDimsMultiPolygon";
static char __pyx_k_74[] = "getNumDimsGeometryCollection";
static char __pyx_k_75[] = "Determines the number of dimensions of a Fiona geometry.\n    ";
static char __pyx_k__a[] = "a";
static char __pyx_k__w[] = "w";
static char __pyx_k__id[] = "id";
static char __pyx_k__os[] = "os";
static char __pyx_k__crs[] = "crs";
static char __pyx_k__get[] = "get";
static char __pyx_k__int[] = "int";
static char __pyx_k__log[] = "log";
static char __pyx_k__str[] = "str";
static char __pyx_k__sys[] = "sys";
static char __pyx_k__bbox[] = "bbox";
static char __pyx_k__join[] = "join";
static char __pyx_k__mode[] = "mode";
static char __pyx_k__name[] = "name";
static char __pyx_k__path[] = "path";
static char __pyx_k__self[] = "self";
static char __pyx_k__stop[] = "stop";
static char __pyx_k__type[] = "type";
static char __pyx_k__Fiona[] = "Fiona";
static char __pyx_k__Point[] = "Point";
static char __pyx_k__debug[] = "debug";
static char __pyx_k__fiona[] = "fiona";
static char __pyx_k__float[] = "float";
static char __pyx_k__index[] = "index";
static char __pyx_k__items[] = "items";
static char __pyx_k__range[] = "range";
static char __pyx_k__split[] = "split";
static char __pyx_k__strip[] = "strip";
static char __pyx_k__types[] = "types";
static char __pyx_k___build[] = "_build";
static char __pyx_k__driver[] = "driver";
static char __pyx_k__exists[] = "exists";
static char __pyx_k__lstrip[] = "lstrip";
static char __pyx_k__object[] = "object";
static char __pyx_k__schema[] = "schema";
static char __pyx_k__IntType[] = "IntType";
static char __pyx_k__OSError[] = "OSError";
static char __pyx_k__Polygon[] = "Polygon";
static char __pyx_k__Unknown[] = "Unknown";
static char __pyx_k__feature[] = "feature";
static char __pyx_k__logging[] = "logging";
static char __pyx_k__no_defs[] = "no_defs";
static char __pyx_k__ogrinit[] = "ogrinit";
static char __pyx_k__session[] = "session";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__geometry[] = "geometry";
static char __pyx_k__FloatType[] = "FloatType";
static char __pyx_k__build_wkb[] = "build_wkb";
static char __pyx_k__bytearray[] = "bytearray";
static char __pyx_k__featureRT[] = "featureRT";
static char __pyx_k__geom_type[] = "geom_type";
static char __pyx_k__getLogger[] = "getLogger";
static char __pyx_k__LineString[] = "LineString";
static char __pyx_k__LinearRing[] = "LinearRing";
static char __pyx_k__MultiPoint[] = "MultiPoint";
static char __pyx_k__StringType[] = "StringType";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k__collection[] = "collection";
static char __pyx_k__geometries[] = "geometries";
static char __pyx_k__geometryRT[] = "geometryRT";
static char __pyx_k__getNumDims[] = "getNumDims";
static char __pyx_k__properties[] = "properties";
static char __pyx_k__FIELD_TYPES[] = "FIELD_TYPES";
static char __pyx_k__OGRERR_NONE[] = "OGRERR_NONE";
static char __pyx_k__UnicodeType[] = "UnicodeType";
static char __pyx_k___buildPoint[] = "_buildPoint";
static char __pyx_k__coordinates[] = "coordinates";
static char __pyx_k__MultiPolygon[] = "MultiPolygon";
static char __pyx_k__RuntimeError[] = "RuntimeError";
static char __pyx_k__StopIteration[] = "StopIteration";
static char __pyx_k___buildPolygon[] = "_buildPolygon";
static char __pyx_k__AssertionError[] = "AssertionError";
static char __pyx_k__GEOMETRY_TYPES[] = "GEOMETRY_TYPES";
static char __pyx_k__OGRERR_FAILURE[] = "OGRERR_FAILURE";
static char __pyx_k__FIELD_TYPES_MAP[] = "FIELD_TYPES_MAP";
static char __pyx_k__MultiLineString[] = "MultiLineString";
static char __pyx_k__getNumDimsPoint[] = "getNumDimsPoint";
static char __pyx_k___buildLineString[] = "_buildLineString";
static char __pyx_k___buildLinearRing[] = "_buildLinearRing";
static char __pyx_k___buildMultiPoint[] = "_buildMultiPoint";
static char __pyx_k__DimensionsHandler[] = "DimensionsHandler";
static char __pyx_k__getNumDimsPolygon[] = "getNumDimsPolygon";
static char __pyx_k__GeometryCollection[] = "GeometryCollection";
static char __pyx_k___buildMultiPolygon[] = "_buildMultiPolygon";
static char __pyx_k__OGRERR_CORRUPT_DATA[] = "OGRERR_CORRUPT_DATA";
static PyObject *__pyx_n_s_1;
static PyObject *__pyx_kp_s_10;
static PyObject *__pyx_kp_s_11;
static PyObject *__pyx_kp_s_12;
static PyObject *__pyx_kp_s_13;
static PyObject *__pyx_kp_s_15;
static PyObject *__pyx_kp_s_16;
static PyObject *__pyx_kp_s_17;
static PyObject *__pyx_kp_s_19;
static PyObject *__pyx_n_s_2;
static PyObject *__pyx_kp_s_20;
static PyObject *__pyx_kp_s_21;
static PyObject *__pyx_kp_s_23;
static PyObject *__pyx_kp_s_26;
static PyObject *__pyx_kp_s_27;
static PyObject *__pyx_kp_s_28;
static PyObject *__pyx_kp_s_29;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_30;
static PyObject *__pyx_kp_s_31;
static PyObject *__pyx_kp_s_33;
static PyObject *__pyx_kp_s_34;
static PyObject *__pyx_kp_s_36;
static PyObject *__pyx_kp_s_37;
static PyObject *__pyx_kp_s_39;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_41;
static PyObject *__pyx_kp_s_42;
static PyObject *__pyx_kp_s_43;
static PyObject *__pyx_kp_s_44;
static PyObject *__pyx_kp_s_45;
static PyObject *__pyx_kp_s_46;
static PyObject *__pyx_kp_s_47;
static PyObject *__pyx_kp_s_48;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_kp_s_50;
static PyObject *__pyx_kp_s_51;
static PyObject *__pyx_kp_s_53;
static PyObject *__pyx_kp_s_55;
static PyObject *__pyx_kp_s_56;
static PyObject *__pyx_kp_s_58;
static PyObject *__pyx_kp_s_59;
static PyObject *__pyx_n_s_62;
static PyObject *__pyx_n_s_63;
static PyObject *__pyx_n_s_64;
static PyObject *__pyx_n_s_65;
static PyObject *__pyx_n_s_66;
static PyObject *__pyx_n_s_67;
static PyObject *__pyx_n_s_68;
static PyObject *__pyx_n_s_69;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_n_s_70;
static PyObject *__pyx_n_s_71;
static PyObject *__pyx_n_s_72;
static PyObject *__pyx_n_s_73;
static PyObject *__pyx_n_s_74;
static PyObject *__pyx_kp_s_75;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_n_s__AssertionError;
static PyObject *__pyx_n_s__DimensionsHandler;
static PyObject *__pyx_n_s__FIELD_TYPES;
static PyObject *__pyx_n_s__FIELD_TYPES_MAP;
static PyObject *__pyx_n_s__Fiona;
static PyObject *__pyx_n_s__FloatType;
static PyObject *__pyx_n_s__GEOMETRY_TYPES;
static PyObject *__pyx_n_s__GeometryCollection;
static PyObject *__pyx_n_s__IntType;
static PyObject *__pyx_n_s__LineString;
static PyObject *__pyx_n_s__LinearRing;
static PyObject *__pyx_n_s__MultiLineString;
static PyObject *__pyx_n_s__MultiPoint;
static PyObject *__pyx_n_s__MultiPolygon;
static PyObject *__pyx_n_s__OGRERR_CORRUPT_DATA;
static PyObject *__pyx_n_s__OGRERR_FAILURE;
static PyObject *__pyx_n_s__OGRERR_NONE;
static PyObject *__pyx_n_s__OSError;
static PyObject *__pyx_n_s__Point;
static PyObject *__pyx_n_s__Polygon;
static PyObject *__pyx_n_s__RuntimeError;
static PyObject *__pyx_n_s__StopIteration;
static PyObject *__pyx_n_s__StringType;
static PyObject *__pyx_n_s__UnicodeType;
static PyObject *__pyx_n_s__Unknown;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___build;
static PyObject *__pyx_n_s___buildLineString;
static PyObject *__pyx_n_s___buildLinearRing;
static PyObject *__pyx_n_s___buildMultiPoint;
static PyObject *__pyx_n_s___buildMultiPolygon;
static PyObject *__pyx_n_s___buildPoint;
static PyObject *__pyx_n_s___buildPolygon;
static PyObject *__pyx_n_s__a;
static PyObject *__pyx_n_s__bbox;
static PyObject *__pyx_n_s__build_wkb;
static PyObject *__pyx_n_s__bytearray;
static PyObject *__pyx_n_s__collection;
static PyObject *__pyx_n_s__coordinates;
static PyObject *__pyx_n_s__crs;
static PyObject *__pyx_n_s__debug;
static PyObject *__pyx_n_s__driver;
static PyObject *__pyx_n_s__exists;
static PyObject *__pyx_n_s__feature;
static PyObject *__pyx_n_s__featureRT;
static PyObject *__pyx_n_s__fiona;
static PyObject *__pyx_n_s__float;
static PyObject *__pyx_n_s__geom_type;
static PyObject *__pyx_n_s__geometries;
static PyObject *__pyx_n_s__geometry;
static PyObject *__pyx_n_s__geometryRT;
static PyObject *__pyx_n_s__get;
static PyObject *__pyx_n_s__getLogger;
static PyObject *__pyx_n_s__getNumDims;
static PyObject *__pyx_n_s__getNumDimsPoint;
static PyObject *__pyx_n_s__getNumDimsPolygon;
static PyObject *__pyx_n_s__id;
static PyObject *__pyx_n_s__index;
static PyObject *__pyx_n_s__int;
static PyObject *__pyx_n_s__items;
static PyObject *__pyx_n_s__join;
static PyObject *__pyx_n_s__log;
static PyObject *__pyx_n_s__logging;
static PyObject *__pyx_n_s__lstrip;
static PyObject *__pyx_n_s__mode;
static PyObject *__pyx_n_s__name;
static PyObject *__pyx_n_s__no_defs;
static PyObject *__pyx_n_s__object;
static PyObject *__pyx_n_s__ogrinit;
static PyObject *__pyx_n_s__os;
static PyObject *__pyx_n_s__path;
static PyObject *__pyx_n_s__properties;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__schema;
static PyObject *__pyx_n_s__self;
static PyObject *__pyx_n_s__session;
static PyObject *__pyx_n_s__split;
static PyObject *__pyx_n_s__stop;
static PyObject *__pyx_n_s__str;
static PyObject *__pyx_n_s__strip;
static PyObject *__pyx_n_s__sys;
static PyObject *__pyx_n_s__type;
static PyObject *__pyx_n_s__types;
static PyObject *__pyx_n_s__w;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_int_5;
static PyObject *__pyx_int_6;
static PyObject *__pyx_int_7;
static PyObject *__pyx_int_8;
static PyObject *__pyx_k_tuple_6;
static PyObject *__pyx_k_tuple_9;
static PyObject *__pyx_k_tuple_14;
static PyObject *__pyx_k_tuple_18;
static PyObject *__pyx_k_tuple_22;
static PyObject *__pyx_k_tuple_24;
static PyObject *__pyx_k_tuple_25;
static PyObject *__pyx_k_tuple_32;
static PyObject *__pyx_k_tuple_35;
static PyObject *__pyx_k_tuple_38;
static PyObject *__pyx_k_tuple_40;
static PyObject *__pyx_k_tuple_49;
static PyObject *__pyx_k_tuple_52;
static PyObject *__pyx_k_tuple_54;
static PyObject *__pyx_k_tuple_57;
static PyObject *__pyx_k_tuple_60;
static PyObject *__pyx_k_tuple_61;

/* "fiona/ogrext.pyx":58
 * # Geometry related functions and classes follow.
 * 
 * cdef void * _createOgrGeomFromWKB(object wkb) except NULL:             # <<<<<<<<<<<<<<
 *     """Make an OGR geometry from a WKB string"""
 *     geom_type = bytearray(wkb)[1]
 */

static void *__pyx_f_5fiona_6ogrext__createOgrGeomFromWKB(PyObject *__pyx_v_wkb) {
  PyObject *__pyx_v_geom_type = NULL;
  unsigned char *__pyx_v_buffer;
  void *__pyx_v_cogr_geometry;
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  unsigned char *__pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_createOgrGeomFromWKB");

  /* "fiona/ogrext.pyx":60
 * cdef void * _createOgrGeomFromWKB(object wkb) except NULL:
 *     """Make an OGR geometry from a WKB string"""
 *     geom_type = bytearray(wkb)[1]             # <<<<<<<<<<<<<<
 *     cdef unsigned char *buffer = wkb
 *     cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(geom_type)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_wkb);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_wkb);
  __Pyx_GIVEREF(__pyx_v_wkb);
  __pyx_t_2 = PyObject_Call(__pyx_builtin_bytearray, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_geom_type = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":61
 *     """Make an OGR geometry from a WKB string"""
 *     geom_type = bytearray(wkb)[1]
 *     cdef unsigned char *buffer = wkb             # <<<<<<<<<<<<<<
 *     cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(geom_type)
 *     assert cogr_geometry is not NULL
 */
  __pyx_t_3 = __Pyx_PyBytes_AsUString(__pyx_v_wkb); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_buffer = __pyx_t_3;

  /* "fiona/ogrext.pyx":62
 *     geom_type = bytearray(wkb)[1]
 *     cdef unsigned char *buffer = wkb
 *     cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(geom_type)             # <<<<<<<<<<<<<<
 *     assert cogr_geometry is not NULL
 *     ograpi.OGR_G_ImportFromWkb(cogr_geometry, buffer, len(wkb))
 */
  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_geom_type); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cogr_geometry = OGR_G_CreateGeometry(__pyx_t_4);

  /* "fiona/ogrext.pyx":63
 *     cdef unsigned char *buffer = wkb
 *     cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(geom_type)
 *     assert cogr_geometry is not NULL             # <<<<<<<<<<<<<<
 *     ograpi.OGR_G_ImportFromWkb(cogr_geometry, buffer, len(wkb))
 *     return cogr_geometry
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_geometry != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":64
 *     cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(geom_type)
 *     assert cogr_geometry is not NULL
 *     ograpi.OGR_G_ImportFromWkb(cogr_geometry, buffer, len(wkb))             # <<<<<<<<<<<<<<
 *     return cogr_geometry
 * 
 */
  __pyx_t_5 = PyObject_Length(__pyx_v_wkb); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  OGR_G_ImportFromWkb(__pyx_v_cogr_geometry, __pyx_v_buffer, __pyx_t_5);

  /* "fiona/ogrext.pyx":65
 *     assert cogr_geometry is not NULL
 *     ograpi.OGR_G_ImportFromWkb(cogr_geometry, buffer, len(wkb))
 *     return cogr_geometry             # <<<<<<<<<<<<<<
 * 
 * cdef _deleteOgrGeom(void *cogr_geometry):
 */
  __pyx_r = __pyx_v_cogr_geometry;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext._createOgrGeomFromWKB", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_geom_type);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":67
 *     return cogr_geometry
 * 
 * cdef _deleteOgrGeom(void *cogr_geometry):             # <<<<<<<<<<<<<<
 *     """Delete an OGR geometry"""
 *     if cogr_geometry is not NULL:
 */

static PyObject *__pyx_f_5fiona_6ogrext__deleteOgrGeom(void *__pyx_v_cogr_geometry) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_deleteOgrGeom");

  /* "fiona/ogrext.pyx":69
 * cdef _deleteOgrGeom(void *cogr_geometry):
 *     """Delete an OGR geometry"""
 *     if cogr_geometry is not NULL:             # <<<<<<<<<<<<<<
 *         ograpi.OGR_G_DestroyGeometry(cogr_geometry)
 *     cogr_geometry = NULL
 */
  __pyx_t_1 = (__pyx_v_cogr_geometry != NULL);
  if (__pyx_t_1) {

    /* "fiona/ogrext.pyx":70
 *     """Delete an OGR geometry"""
 *     if cogr_geometry is not NULL:
 *         ograpi.OGR_G_DestroyGeometry(cogr_geometry)             # <<<<<<<<<<<<<<
 *     cogr_geometry = NULL
 * 
 */
    OGR_G_DestroyGeometry(__pyx_v_cogr_geometry);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "fiona/ogrext.pyx":71
 *     if cogr_geometry is not NULL:
 *         ograpi.OGR_G_DestroyGeometry(cogr_geometry)
 *     cogr_geometry = NULL             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_cogr_geometry = NULL;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":79
 *     coordinates = None
 * 
 *     def getNumDimsPoint(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates)
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_getNumDimsPoint(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5fiona_6ogrext_17DimensionsHandler_getNumDimsPoint = {__Pyx_NAMESTR("getNumDimsPoint"), (PyCFunction)__pyx_pf_5fiona_6ogrext_17DimensionsHandler_getNumDimsPoint, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_getNumDimsPoint(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getNumDimsPoint");
  __pyx_self = __pyx_self;

  /* "fiona/ogrext.pyx":80
 * 
 *     def getNumDimsPoint(self):
 *         return len(self.coordinates)             # <<<<<<<<<<<<<<
 * 
 *     def getNumDimsLineString(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("fiona.ogrext.DimensionsHandler.getNumDimsPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":82
 *         return len(self.coordinates)
 * 
 *     def getNumDimsLineString(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates[0])
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_1getNumDimsLineString(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5fiona_6ogrext_17DimensionsHandler_1getNumDimsLineString = {__Pyx_NAMESTR("getNumDimsLineString"), (PyCFunction)__pyx_pf_5fiona_6ogrext_17DimensionsHandler_1getNumDimsLineString, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_1getNumDimsLineString(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getNumDimsLineString");
  __pyx_self = __pyx_self;

  /* "fiona/ogrext.pyx":83
 * 
 *     def getNumDimsLineString(self):
 *         return len(self.coordinates[0])             # <<<<<<<<<<<<<<
 * 
 *     def getNumDimsLinearRing(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext.DimensionsHandler.getNumDimsLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":85
 *         return len(self.coordinates[0])
 * 
 *     def getNumDimsLinearRing(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates[0])
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_2getNumDimsLinearRing(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5fiona_6ogrext_17DimensionsHandler_2getNumDimsLinearRing = {__Pyx_NAMESTR("getNumDimsLinearRing"), (PyCFunction)__pyx_pf_5fiona_6ogrext_17DimensionsHandler_2getNumDimsLinearRing, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_2getNumDimsLinearRing(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getNumDimsLinearRing");
  __pyx_self = __pyx_self;

  /* "fiona/ogrext.pyx":86
 * 
 *     def getNumDimsLinearRing(self):
 *         return len(self.coordinates[0])             # <<<<<<<<<<<<<<
 * 
 *     def getNumDimsPolygon(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext.DimensionsHandler.getNumDimsLinearRing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":88
 *         return len(self.coordinates[0])
 * 
 *     def getNumDimsPolygon(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates[0][0])
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_3getNumDimsPolygon(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5fiona_6ogrext_17DimensionsHandler_3getNumDimsPolygon = {__Pyx_NAMESTR("getNumDimsPolygon"), (PyCFunction)__pyx_pf_5fiona_6ogrext_17DimensionsHandler_3getNumDimsPolygon, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_3getNumDimsPolygon(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getNumDimsPolygon");
  __pyx_self = __pyx_self;

  /* "fiona/ogrext.pyx":89
 * 
 *     def getNumDimsPolygon(self):
 *         return len(self.coordinates[0][0])             # <<<<<<<<<<<<<<
 * 
 *     def getNumDimsMultiPoint(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext.DimensionsHandler.getNumDimsPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":91
 *         return len(self.coordinates[0][0])
 * 
 *     def getNumDimsMultiPoint(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates[0])
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_4getNumDimsMultiPoint(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5fiona_6ogrext_17DimensionsHandler_4getNumDimsMultiPoint = {__Pyx_NAMESTR("getNumDimsMultiPoint"), (PyCFunction)__pyx_pf_5fiona_6ogrext_17DimensionsHandler_4getNumDimsMultiPoint, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_4getNumDimsMultiPoint(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getNumDimsMultiPoint");
  __pyx_self = __pyx_self;

  /* "fiona/ogrext.pyx":92
 * 
 *     def getNumDimsMultiPoint(self):
 *         return len(self.coordinates[0])             # <<<<<<<<<<<<<<
 * 
 *     def getNumDimsMultiLineString(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext.DimensionsHandler.getNumDimsMultiPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":94
 *         return len(self.coordinates[0])
 * 
 *     def getNumDimsMultiLineString(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates[0][0])
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_5getNumDimsMultiLineString(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5fiona_6ogrext_17DimensionsHandler_5getNumDimsMultiLineString = {__Pyx_NAMESTR("getNumDimsMultiLineString"), (PyCFunction)__pyx_pf_5fiona_6ogrext_17DimensionsHandler_5getNumDimsMultiLineString, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_5getNumDimsMultiLineString(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getNumDimsMultiLineString");
  __pyx_self = __pyx_self;

  /* "fiona/ogrext.pyx":95
 * 
 *     def getNumDimsMultiLineString(self):
 *         return len(self.coordinates[0][0])             # <<<<<<<<<<<<<<
 * 
 *     def getNumDimsMultiPolygon(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext.DimensionsHandler.getNumDimsMultiLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":97
 *         return len(self.coordinates[0][0])
 * 
 *     def getNumDimsMultiPolygon(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates[0][0][0])
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_6getNumDimsMultiPolygon(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5fiona_6ogrext_17DimensionsHandler_6getNumDimsMultiPolygon = {__Pyx_NAMESTR("getNumDimsMultiPolygon"), (PyCFunction)__pyx_pf_5fiona_6ogrext_17DimensionsHandler_6getNumDimsMultiPolygon, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_6getNumDimsMultiPolygon(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getNumDimsMultiPolygon");
  __pyx_self = __pyx_self;

  /* "fiona/ogrext.pyx":98
 * 
 *     def getNumDimsMultiPolygon(self):
 *         return len(self.coordinates[0][0][0])             # <<<<<<<<<<<<<<
 * 
 *     def getNumDimsGeometryCollection(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext.DimensionsHandler.getNumDimsMultiPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":100
 *         return len(self.coordinates[0][0][0])
 * 
 *     def getNumDimsGeometryCollection(self):             # <<<<<<<<<<<<<<
 *         first = self.coordinates[0]
 *         return self.getNumDims(first['type'], first['coordinates'])
 */

static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_7getNumDimsGeometryCollection(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
static PyMethodDef __pyx_mdef_5fiona_6ogrext_17DimensionsHandler_7getNumDimsGeometryCollection = {__Pyx_NAMESTR("getNumDimsGeometryCollection"), (PyCFunction)__pyx_pf_5fiona_6ogrext_17DimensionsHandler_7getNumDimsGeometryCollection, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_7getNumDimsGeometryCollection(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_first = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getNumDimsGeometryCollection");
  __pyx_self = __pyx_self;

  /* "fiona/ogrext.pyx":101
 * 
 *     def getNumDimsGeometryCollection(self):
 *         first = self.coordinates[0]             # <<<<<<<<<<<<<<
 *         return self.getNumDims(first['type'], first['coordinates'])
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_first = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":102
 *     def getNumDimsGeometryCollection(self):
 *         first = self.coordinates[0]
 *         return self.getNumDims(first['type'], first['coordinates'])             # <<<<<<<<<<<<<<
 * 
 *     def getNumDims(self, geom_type, coordinates):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__getNumDims); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_GetItem(__pyx_v_first, ((PyObject *)__pyx_n_s__type)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_GetItem(__pyx_v_first, ((PyObject *)__pyx_n_s__coordinates)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("fiona.ogrext.DimensionsHandler.getNumDimsGeometryCollection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_first);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":104
 *         return self.getNumDims(first['type'], first['coordinates'])
 * 
 *     def getNumDims(self, geom_type, coordinates):             # <<<<<<<<<<<<<<
 *         self.coordinates = coordinates
 *         return getattr(self, 'getNumDims' + geom_type)()
 */

static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_8getNumDims(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5fiona_6ogrext_17DimensionsHandler_8getNumDims = {__Pyx_NAMESTR("getNumDims"), (PyCFunction)__pyx_pf_5fiona_6ogrext_17DimensionsHandler_8getNumDims, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5fiona_6ogrext_17DimensionsHandler_8getNumDims(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_geom_type = 0;
  PyObject *__pyx_v_coordinates = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__geom_type,&__pyx_n_s__coordinates,0};
  __Pyx_RefNannySetupContext("getNumDims");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__geom_type);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("getNumDims", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__coordinates);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("getNumDims", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "getNumDims") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_self = values[0];
    __pyx_v_geom_type = values[1];
    __pyx_v_coordinates = values[2];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_geom_type = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_coordinates = PyTuple_GET_ITEM(__pyx_args, 2);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getNumDims", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("fiona.ogrext.DimensionsHandler.getNumDims", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "fiona/ogrext.pyx":105
 * 
 *     def getNumDims(self, geom_type, coordinates):
 *         self.coordinates = coordinates             # <<<<<<<<<<<<<<
 *         return getattr(self, 'getNumDims' + geom_type)()
 * 
 */
  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__coordinates, __pyx_v_coordinates) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "fiona/ogrext.pyx":106
 *     def getNumDims(self, geom_type, coordinates):
 *         self.coordinates = coordinates
 *         return getattr(self, 'getNumDims' + geom_type)()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_n_s__getNumDims), __pyx_v_geom_type); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext.DimensionsHandler.getNumDims", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":117
 *     cdef object ndims
 * 
 *     cdef _buildCoords(self, void *geom):             # <<<<<<<<<<<<<<
 *         # Build a coordinate sequence
 *         cdef int i
 */

static PyObject *__pyx_f_5fiona_6ogrext_11GeomBuilder__buildCoords(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *__pyx_v_self, void *__pyx_v_geom) {
  int __pyx_v_i;
  int __pyx_v_npoints;
  PyObject *__pyx_v_coords = NULL;
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildCoords");

  /* "fiona/ogrext.pyx":120
 *         # Build a coordinate sequence
 *         cdef int i
 *         assert geom is not NULL             # <<<<<<<<<<<<<<
 *         npoints = ograpi.OGR_G_GetPointCount(geom)
 *         coords = []
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_geom != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":121
 *         cdef int i
 *         assert geom is not NULL
 *         npoints = ograpi.OGR_G_GetPointCount(geom)             # <<<<<<<<<<<<<<
 *         coords = []
 *         for i in range(npoints):
 */
  __pyx_v_npoints = OGR_G_GetPointCount(__pyx_v_geom);

  /* "fiona/ogrext.pyx":122
 *         assert geom is not NULL
 *         npoints = ograpi.OGR_G_GetPointCount(geom)
 *         coords = []             # <<<<<<<<<<<<<<
 *         for i in range(npoints):
 *             values = [ograpi.OGR_G_GetX(geom, i), ograpi.OGR_G_GetY(geom, i)]
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_coords = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":123
 *         npoints = ograpi.OGR_G_GetPointCount(geom)
 *         coords = []
 *         for i in range(npoints):             # <<<<<<<<<<<<<<
 *             values = [ograpi.OGR_G_GetX(geom, i), ograpi.OGR_G_GetY(geom, i)]
 *             if self.ndims > 2:
 */
  __pyx_t_2 = __pyx_v_npoints;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "fiona/ogrext.pyx":124
 *         coords = []
 *         for i in range(npoints):
 *             values = [ograpi.OGR_G_GetX(geom, i), ograpi.OGR_G_GetY(geom, i)]             # <<<<<<<<<<<<<<
 *             if self.ndims > 2:
 *                 values.append(ograpi.OGR_G_GetZ(geom, i))
 */
    __pyx_t_1 = PyFloat_FromDouble(OGR_G_GetX(__pyx_v_geom, __pyx_v_i)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyFloat_FromDouble(OGR_G_GetY(__pyx_v_geom, __pyx_v_i)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_1 = 0;
    __pyx_t_4 = 0;
    __Pyx_XDECREF(((PyObject *)__pyx_v_values));
    __pyx_v_values = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "fiona/ogrext.pyx":125
 *         for i in range(npoints):
 *             values = [ograpi.OGR_G_GetX(geom, i), ograpi.OGR_G_GetY(geom, i)]
 *             if self.ndims > 2:             # <<<<<<<<<<<<<<
 *                 values.append(ograpi.OGR_G_GetZ(geom, i))
 *             coords.append(tuple(values))
 */
    __pyx_t_5 = PyObject_RichCompare(__pyx_v_self->ndims, __pyx_int_2, Py_GT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_6) {

      /* "fiona/ogrext.pyx":126
 *             values = [ograpi.OGR_G_GetX(geom, i), ograpi.OGR_G_GetY(geom, i)]
 *             if self.ndims > 2:
 *                 values.append(ograpi.OGR_G_GetZ(geom, i))             # <<<<<<<<<<<<<<
 *             coords.append(tuple(values))
 *         return coords
 */
      if (unlikely(((PyObject *)__pyx_v_values) == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
      }
      __pyx_t_5 = PyFloat_FromDouble(OGR_G_GetZ(__pyx_v_geom, __pyx_v_i)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = PyList_Append(__pyx_v_values, __pyx_t_5); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "fiona/ogrext.pyx":127
 *             if self.ndims > 2:
 *                 values.append(ograpi.OGR_G_GetZ(geom, i))
 *             coords.append(tuple(values))             # <<<<<<<<<<<<<<
 *         return coords
 * 
 */
    if (unlikely(((PyObject *)__pyx_v_coords) == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    if (unlikely(((PyObject *)__pyx_v_values) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_5 = ((PyObject *)PyList_AsTuple(__pyx_v_values)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __pyx_t_7 = PyList_Append(__pyx_v_coords, ((PyObject *)__pyx_t_5)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  }

  /* "fiona/ogrext.pyx":128
 *                 values.append(ograpi.OGR_G_GetZ(geom, i))
 *             coords.append(tuple(values))
 *         return coords             # <<<<<<<<<<<<<<
 * 
 *     cpdef _buildPoint(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_coords));
  __pyx_r = ((PyObject *)__pyx_v_coords);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildCoords", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_coords);
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":130
 *         return coords
 * 
 *     cpdef _buildPoint(self):             # <<<<<<<<<<<<<<
 *         return {'type': 'Point', 'coordinates': self._buildCoords(self.geom)[0]}
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder__buildPoint(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_5fiona_6ogrext_11GeomBuilder__buildPoint(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildPoint");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildPoint); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_5fiona_6ogrext_11GeomBuilder__buildPoint)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "fiona/ogrext.pyx":131
 * 
 *     cpdef _buildPoint(self):
 *         return {'type': 'Point', 'coordinates': self._buildCoords(self.geom)[0]}             # <<<<<<<<<<<<<<
 * 
 *     cpdef _buildLineString(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__type), ((PyObject *)__pyx_n_s__Point)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildCoords(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__coordinates), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":130
 *         return coords
 * 
 *     cpdef _buildPoint(self):             # <<<<<<<<<<<<<<
 *         return {'type': 'Point', 'coordinates': self._buildCoords(self.geom)[0]}
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder__buildPoint(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder__buildPoint(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildPoint");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self)->__pyx_vtab)->_buildPoint(((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":133
 *         return {'type': 'Point', 'coordinates': self._buildCoords(self.geom)[0]}
 * 
 *     cpdef _buildLineString(self):             # <<<<<<<<<<<<<<
 *         return {'type': 'LineString', 'coordinates': self._buildCoords(self.geom)}
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_1_buildLineString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_5fiona_6ogrext_11GeomBuilder__buildLineString(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildLineString");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLineString); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_5fiona_6ogrext_11GeomBuilder_1_buildLineString)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "fiona/ogrext.pyx":134
 * 
 *     cpdef _buildLineString(self):
 *         return {'type': 'LineString', 'coordinates': self._buildCoords(self.geom)}             # <<<<<<<<<<<<<<
 * 
 *     cpdef _buildLinearRing(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__type), ((PyObject *)__pyx_n_s__LineString)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildCoords(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__coordinates), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":133
 *         return {'type': 'Point', 'coordinates': self._buildCoords(self.geom)[0]}
 * 
 *     cpdef _buildLineString(self):             # <<<<<<<<<<<<<<
 *         return {'type': 'LineString', 'coordinates': self._buildCoords(self.geom)}
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_1_buildLineString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_1_buildLineString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildLineString");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self)->__pyx_vtab)->_buildLineString(((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":136
 *         return {'type': 'LineString', 'coordinates': self._buildCoords(self.geom)}
 * 
 *     cpdef _buildLinearRing(self):             # <<<<<<<<<<<<<<
 *         return {'type': 'LinearRing', 'coordinates': self._buildCoords(self.geom)}
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_2_buildLinearRing(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_5fiona_6ogrext_11GeomBuilder__buildLinearRing(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildLinearRing");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLinearRing); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_5fiona_6ogrext_11GeomBuilder_2_buildLinearRing)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "fiona/ogrext.pyx":137
 * 
 *     cpdef _buildLinearRing(self):
 *         return {'type': 'LinearRing', 'coordinates': self._buildCoords(self.geom)}             # <<<<<<<<<<<<<<
 * 
 *     cdef _buildParts(self, void *geom):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__type), ((PyObject *)__pyx_n_s__LinearRing)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildCoords(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__coordinates), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildLinearRing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":136
 *         return {'type': 'LineString', 'coordinates': self._buildCoords(self.geom)}
 * 
 *     cpdef _buildLinearRing(self):             # <<<<<<<<<<<<<<
 *         return {'type': 'LinearRing', 'coordinates': self._buildCoords(self.geom)}
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_2_buildLinearRing(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_2_buildLinearRing(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildLinearRing");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self)->__pyx_vtab)->_buildLinearRing(((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildLinearRing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":139
 *         return {'type': 'LinearRing', 'coordinates': self._buildCoords(self.geom)}
 * 
 *     cdef _buildParts(self, void *geom):             # <<<<<<<<<<<<<<
 *         cdef int j
 *         cdef void *part
 */

static PyObject *__pyx_f_5fiona_6ogrext_11GeomBuilder__buildParts(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *__pyx_v_self, void *__pyx_v_geom) {
  int __pyx_v_j;
  void *__pyx_v_part;
  PyObject *__pyx_v_parts = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildParts");

  /* "fiona/ogrext.pyx":142
 *         cdef int j
 *         cdef void *part
 *         assert geom is not NULL             # <<<<<<<<<<<<<<
 *         parts = []
 *         for j in range(ograpi.OGR_G_GetGeometryCount(geom)):
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_geom != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":143
 *         cdef void *part
 *         assert geom is not NULL
 *         parts = []             # <<<<<<<<<<<<<<
 *         for j in range(ograpi.OGR_G_GetGeometryCount(geom)):
 *             part = ograpi.OGR_G_GetGeometryRef(geom, j)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_parts = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":144
 *         assert geom is not NULL
 *         parts = []
 *         for j in range(ograpi.OGR_G_GetGeometryCount(geom)):             # <<<<<<<<<<<<<<
 *             part = ograpi.OGR_G_GetGeometryRef(geom, j)
 *             parts.append(GeomBuilder().build(part))
 */
  __pyx_t_2 = OGR_G_GetGeometryCount(__pyx_v_geom);
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_j = __pyx_t_3;

    /* "fiona/ogrext.pyx":145
 *         parts = []
 *         for j in range(ograpi.OGR_G_GetGeometryCount(geom)):
 *             part = ograpi.OGR_G_GetGeometryRef(geom, j)             # <<<<<<<<<<<<<<
 *             parts.append(GeomBuilder().build(part))
 *         return parts
 */
    __pyx_v_part = OGR_G_GetGeometryRef(__pyx_v_geom, __pyx_v_j);

    /* "fiona/ogrext.pyx":146
 *         for j in range(ograpi.OGR_G_GetGeometryCount(geom)):
 *             part = ograpi.OGR_G_GetGeometryRef(geom, j)
 *             parts.append(GeomBuilder().build(part))             # <<<<<<<<<<<<<<
 *         return parts
 * 
 */
    if (unlikely(((PyObject *)__pyx_v_parts) == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_GeomBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_t_1)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_t_1), __pyx_v_part); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = PyList_Append(__pyx_v_parts, __pyx_t_4); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "fiona/ogrext.pyx":147
 *             part = ograpi.OGR_G_GetGeometryRef(geom, j)
 *             parts.append(GeomBuilder().build(part))
 *         return parts             # <<<<<<<<<<<<<<
 * 
 *     cpdef _buildPolygon(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_parts));
  __pyx_r = ((PyObject *)__pyx_v_parts);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildParts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_parts);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":149
 *         return parts
 * 
 *     cpdef _buildPolygon(self):             # <<<<<<<<<<<<<<
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
 *         return {'type': 'Polygon', 'coordinates': coordinates}
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_3_buildPolygon(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_5fiona_6ogrext_11GeomBuilder__buildPolygon(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_coordinates = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildPolygon");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildPolygon); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_5fiona_6ogrext_11GeomBuilder_3_buildPolygon)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "fiona/ogrext.pyx":150
 * 
 *     cpdef _buildPolygon(self):
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]             # <<<<<<<<<<<<<<
 *         return {'type': 'Polygon', 'coordinates': coordinates}
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildParts(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
    } else if (PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_p);
    __pyx_v_p = __pyx_t_2;
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__coordinates)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(((PyObject *)__pyx_t_1));
  __pyx_v_coordinates = __pyx_t_1;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":151
 *     cpdef _buildPolygon(self):
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
 *         return {'type': 'Polygon', 'coordinates': coordinates}             # <<<<<<<<<<<<<<
 * 
 *     cpdef _buildMultiPoint(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__type), ((PyObject *)__pyx_n_s__Polygon)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__coordinates), ((PyObject *)__pyx_v_coordinates)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_coordinates);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":149
 *         return parts
 * 
 *     cpdef _buildPolygon(self):             # <<<<<<<<<<<<<<
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
 *         return {'type': 'Polygon', 'coordinates': coordinates}
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_3_buildPolygon(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_3_buildPolygon(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildPolygon");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self)->__pyx_vtab)->_buildPolygon(((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":153
 *         return {'type': 'Polygon', 'coordinates': coordinates}
 * 
 *     cpdef _buildMultiPoint(self):             # <<<<<<<<<<<<<<
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
 *         return {'type': 'MultiPoint', 'coordinates': coordinates}
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_4_buildMultiPoint(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_5fiona_6ogrext_11GeomBuilder__buildMultiPoint(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_coordinates = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildMultiPoint");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildMultiPoint); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_5fiona_6ogrext_11GeomBuilder_4_buildMultiPoint)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "fiona/ogrext.pyx":154
 * 
 *     cpdef _buildMultiPoint(self):
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]             # <<<<<<<<<<<<<<
 *         return {'type': 'MultiPoint', 'coordinates': coordinates}
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildParts(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
    } else if (PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_p);
    __pyx_v_p = __pyx_t_2;
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__coordinates)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(((PyObject *)__pyx_t_1));
  __pyx_v_coordinates = __pyx_t_1;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":155
 *     cpdef _buildMultiPoint(self):
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
 *         return {'type': 'MultiPoint', 'coordinates': coordinates}             # <<<<<<<<<<<<<<
 * 
 *     cpdef _buildMultiLineString(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__type), ((PyObject *)__pyx_n_s__MultiPoint)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__coordinates), ((PyObject *)__pyx_v_coordinates)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildMultiPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_coordinates);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":153
 *         return {'type': 'Polygon', 'coordinates': coordinates}
 * 
 *     cpdef _buildMultiPoint(self):             # <<<<<<<<<<<<<<
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
 *         return {'type': 'MultiPoint', 'coordinates': coordinates}
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_4_buildMultiPoint(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_4_buildMultiPoint(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildMultiPoint");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self)->__pyx_vtab)->_buildMultiPoint(((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildMultiPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":157
 *         return {'type': 'MultiPoint', 'coordinates': coordinates}
 * 
 *     cpdef _buildMultiLineString(self):             # <<<<<<<<<<<<<<
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
 *         return {'type': 'MultiLineString', 'coordinates': coordinates}
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_5_buildMultiLineString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_5fiona_6ogrext_11GeomBuilder__buildMultiLineString(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_coordinates = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildMultiLineString");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_5fiona_6ogrext_11GeomBuilder_5_buildMultiLineString)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "fiona/ogrext.pyx":158
 * 
 *     cpdef _buildMultiLineString(self):
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]             # <<<<<<<<<<<<<<
 *         return {'type': 'MultiLineString', 'coordinates': coordinates}
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildParts(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
    } else if (PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_p);
    __pyx_v_p = __pyx_t_2;
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__coordinates)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(((PyObject *)__pyx_t_1));
  __pyx_v_coordinates = __pyx_t_1;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":159
 *     cpdef _buildMultiLineString(self):
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
 *         return {'type': 'MultiLineString', 'coordinates': coordinates}             # <<<<<<<<<<<<<<
 * 
 *     cpdef _buildMultiPolygon(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__type), ((PyObject *)__pyx_n_s__MultiLineString)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__coordinates), ((PyObject *)__pyx_v_coordinates)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildMultiLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_coordinates);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":157
 *         return {'type': 'MultiPoint', 'coordinates': coordinates}
 * 
 *     cpdef _buildMultiLineString(self):             # <<<<<<<<<<<<<<
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
 *         return {'type': 'MultiLineString', 'coordinates': coordinates}
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_5_buildMultiLineString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_5_buildMultiLineString(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildMultiLineString");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self)->__pyx_vtab)->_buildMultiLineString(((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildMultiLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":161
 *         return {'type': 'MultiLineString', 'coordinates': coordinates}
 * 
 *     cpdef _buildMultiPolygon(self):             # <<<<<<<<<<<<<<
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
 *         return {'type': 'MultiPolygon', 'coordinates': coordinates}
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_6_buildMultiPolygon(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_5fiona_6ogrext_11GeomBuilder__buildMultiPolygon(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_coordinates = NULL;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildMultiPolygon");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildMultiPolygon); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_5fiona_6ogrext_11GeomBuilder_6_buildMultiPolygon)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "fiona/ogrext.pyx":162
 * 
 *     cpdef _buildMultiPolygon(self):
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]             # <<<<<<<<<<<<<<
 *         return {'type': 'MultiPolygon', 'coordinates': coordinates}
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildParts(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
    } else if (PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_p);
    __pyx_v_p = __pyx_t_2;
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_GetItem(__pyx_v_p, ((PyObject *)__pyx_n_s__coordinates)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_INCREF(((PyObject *)__pyx_t_1));
  __pyx_v_coordinates = __pyx_t_1;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":163
 *     cpdef _buildMultiPolygon(self):
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
 *         return {'type': 'MultiPolygon', 'coordinates': coordinates}             # <<<<<<<<<<<<<<
 * 
 *     cpdef _buildGeometryCollection(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__type), ((PyObject *)__pyx_n_s__MultiPolygon)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__coordinates), ((PyObject *)__pyx_v_coordinates)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildMultiPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_coordinates);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":161
 *         return {'type': 'MultiLineString', 'coordinates': coordinates}
 * 
 *     cpdef _buildMultiPolygon(self):             # <<<<<<<<<<<<<<
 *         coordinates = [p['coordinates'] for p in self._buildParts(self.geom)]
 *         return {'type': 'MultiPolygon', 'coordinates': coordinates}
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_6_buildMultiPolygon(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_6_buildMultiPolygon(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildMultiPolygon");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self)->__pyx_vtab)->_buildMultiPolygon(((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildMultiPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":165
 *         return {'type': 'MultiPolygon', 'coordinates': coordinates}
 * 
 *     cpdef _buildGeometryCollection(self):             # <<<<<<<<<<<<<<
 *         parts = self._buildParts(self.geom)
 *         return {'type': 'GeometryCollection', 'geometries': parts}
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_7_buildGeometryCollection(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_5fiona_6ogrext_11GeomBuilder__buildGeometryCollection(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_parts = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildGeometryCollection");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_5fiona_6ogrext_11GeomBuilder_7_buildGeometryCollection)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "fiona/ogrext.pyx":166
 * 
 *     cpdef _buildGeometryCollection(self):
 *         parts = self._buildParts(self.geom)             # <<<<<<<<<<<<<<
 *         return {'type': 'GeometryCollection', 'geometries': parts}
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildParts(__pyx_v_self, __pyx_v_self->geom); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_parts = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":167
 *     cpdef _buildGeometryCollection(self):
 *         parts = self._buildParts(self.geom)
 *         return {'type': 'GeometryCollection', 'geometries': parts}             # <<<<<<<<<<<<<<
 * 
 *     cdef build(self, void *geom):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__type), ((PyObject *)__pyx_n_s__GeometryCollection)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__geometries), __pyx_v_parts) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildGeometryCollection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_parts);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":165
 *         return {'type': 'MultiPolygon', 'coordinates': coordinates}
 * 
 *     cpdef _buildGeometryCollection(self):             # <<<<<<<<<<<<<<
 *         parts = self._buildParts(self.geom)
 *         return {'type': 'GeometryCollection', 'geometries': parts}
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_7_buildGeometryCollection(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_7_buildGeometryCollection(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildGeometryCollection");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self)->__pyx_vtab)->_buildGeometryCollection(((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder._buildGeometryCollection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":169
 *         return {'type': 'GeometryCollection', 'geometries': parts}
 * 
 *     cdef build(self, void *geom):             # <<<<<<<<<<<<<<
 *         # The only method anyone needs to call
 *         assert geom is not NULL
 */

static PyObject *__pyx_f_5fiona_6ogrext_11GeomBuilder_build(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *__pyx_v_self, void *__pyx_v_geom) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("build");

  /* "fiona/ogrext.pyx":171
 *     cdef build(self, void *geom):
 *         # The only method anyone needs to call
 *         assert geom is not NULL             # <<<<<<<<<<<<<<
 *         self.code = ograpi.OGR_G_GetGeometryType(geom)
 *         self.typename = GEOMETRY_TYPES[self.code]
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_geom != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":172
 *         # The only method anyone needs to call
 *         assert geom is not NULL
 *         self.code = ograpi.OGR_G_GetGeometryType(geom)             # <<<<<<<<<<<<<<
 *         self.typename = GEOMETRY_TYPES[self.code]
 *         self.ndims = ograpi.OGR_G_GetCoordinateDimension(geom)
 */
  __pyx_t_1 = PyInt_FromLong(OGR_G_GetGeometryType(__pyx_v_geom)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->code);
  __Pyx_DECREF(__pyx_v_self->code);
  __pyx_v_self->code = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":173
 *         assert geom is not NULL
 *         self.code = ograpi.OGR_G_GetGeometryType(geom)
 *         self.typename = GEOMETRY_TYPES[self.code]             # <<<<<<<<<<<<<<
 *         self.ndims = ograpi.OGR_G_GetCoordinateDimension(geom)
 *         self.geom = geom
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__GEOMETRY_TYPES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_self->code); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->typename);
  __Pyx_DECREF(__pyx_v_self->typename);
  __pyx_v_self->typename = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":174
 *         self.code = ograpi.OGR_G_GetGeometryType(geom)
 *         self.typename = GEOMETRY_TYPES[self.code]
 *         self.ndims = ograpi.OGR_G_GetCoordinateDimension(geom)             # <<<<<<<<<<<<<<
 *         self.geom = geom
 *         return getattr(self, '_build' + self.typename)()
 */
  __pyx_t_2 = PyInt_FromLong(OGR_G_GetCoordinateDimension(__pyx_v_geom)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->ndims);
  __Pyx_DECREF(__pyx_v_self->ndims);
  __pyx_v_self->ndims = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":175
 *         self.typename = GEOMETRY_TYPES[self.code]
 *         self.ndims = ograpi.OGR_G_GetCoordinateDimension(geom)
 *         self.geom = geom             # <<<<<<<<<<<<<<
 *         return getattr(self, '_build' + self.typename)()
 * 
 */
  __pyx_v_self->geom = __pyx_v_geom;

  /* "fiona/ogrext.pyx":176
 *         self.ndims = ograpi.OGR_G_GetCoordinateDimension(geom)
 *         self.geom = geom
 *         return getattr(self, '_build' + self.typename)()             # <<<<<<<<<<<<<<
 * 
 *     cpdef build_wkb(self, object wkb):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_n_s___build), __pyx_v_self->typename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder.build", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":178
 *         return getattr(self, '_build' + self.typename)()
 * 
 *     cpdef build_wkb(self, object wkb):             # <<<<<<<<<<<<<<
 *         # The only other method anyone needs to call
 *         cdef object data = wkb
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_8build_wkb(PyObject *__pyx_v_self, PyObject *__pyx_v_wkb); /*proto*/
static PyObject *__pyx_f_5fiona_6ogrext_11GeomBuilder_build_wkb(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *__pyx_v_self, PyObject *__pyx_v_wkb, int __pyx_skip_dispatch) {
  PyObject *__pyx_v_data = 0;
  void *__pyx_v_cogr_geometry;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  void *__pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("build_wkb");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__build_wkb); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_5fiona_6ogrext_11GeomBuilder_8build_wkb)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_v_wkb);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_wkb);
      __Pyx_GIVEREF(__pyx_v_wkb);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "fiona/ogrext.pyx":180
 *     cpdef build_wkb(self, object wkb):
 *         # The only other method anyone needs to call
 *         cdef object data = wkb             # <<<<<<<<<<<<<<
 *         cdef void *cogr_geometry = _createOgrGeomFromWKB(data)
 *         result = self.build(cogr_geometry)
 */
  __Pyx_INCREF(__pyx_v_wkb);
  __pyx_v_data = __pyx_v_wkb;

  /* "fiona/ogrext.pyx":181
 *         # The only other method anyone needs to call
 *         cdef object data = wkb
 *         cdef void *cogr_geometry = _createOgrGeomFromWKB(data)             # <<<<<<<<<<<<<<
 *         result = self.build(cogr_geometry)
 *         _deleteOgrGeom(cogr_geometry)
 */
  __pyx_t_4 = __pyx_f_5fiona_6ogrext__createOgrGeomFromWKB(__pyx_v_data); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cogr_geometry = __pyx_t_4;

  /* "fiona/ogrext.pyx":182
 *         cdef object data = wkb
 *         cdef void *cogr_geometry = _createOgrGeomFromWKB(data)
 *         result = self.build(cogr_geometry)             # <<<<<<<<<<<<<<
 *         _deleteOgrGeom(cogr_geometry)
 *         return result
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)__pyx_v_self->__pyx_vtab)->build(__pyx_v_self, __pyx_v_cogr_geometry); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":183
 *         cdef void *cogr_geometry = _createOgrGeomFromWKB(data)
 *         result = self.build(cogr_geometry)
 *         _deleteOgrGeom(cogr_geometry)             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
  __pyx_t_1 = __pyx_f_5fiona_6ogrext__deleteOgrGeom(__pyx_v_cogr_geometry); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":184
 *         result = self.build(cogr_geometry)
 *         _deleteOgrGeom(cogr_geometry)
 *         return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder.build_wkb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":178
 *         return getattr(self, '_build' + self.typename)()
 * 
 *     cpdef build_wkb(self, object wkb):             # <<<<<<<<<<<<<<
 *         # The only other method anyone needs to call
 *         cdef object data = wkb
 */

static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_8build_wkb(PyObject *__pyx_v_self, PyObject *__pyx_v_wkb); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_11GeomBuilder_8build_wkb(PyObject *__pyx_v_self, PyObject *__pyx_v_wkb) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("build_wkb");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self)->__pyx_vtab)->build_wkb(((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_v_self), __pyx_v_wkb, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("fiona.ogrext.GeomBuilder.build_wkb", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":194
 *     cdef object ndims
 * 
 *     cdef void * _buildPoint(self) except NULL:             # <<<<<<<<<<<<<<
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(1)
 *         assert cogr_geometry is not NULL
 */

static void *__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildPoint(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *__pyx_v_self) {
  void *__pyx_v_cogr_geometry;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_v_z = NULL;
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  double __pyx_t_7;
  double __pyx_t_8;
  double __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildPoint");

  /* "fiona/ogrext.pyx":195
 * 
 *     cdef void * _buildPoint(self) except NULL:
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(1)             # <<<<<<<<<<<<<<
 *         assert cogr_geometry is not NULL
 *         if self.ndims > 2:
 */
  __pyx_v_cogr_geometry = OGR_G_CreateGeometry(1);

  /* "fiona/ogrext.pyx":196
 *     cdef void * _buildPoint(self) except NULL:
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(1)
 *         assert cogr_geometry is not NULL             # <<<<<<<<<<<<<<
 *         if self.ndims > 2:
 *             x, y, z = self.coordinates
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_geometry != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":197
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(1)
 *         assert cogr_geometry is not NULL
 *         if self.ndims > 2:             # <<<<<<<<<<<<<<
 *             x, y, z = self.coordinates
 *             ograpi.OGR_G_AddPoint(cogr_geometry, x, y, z)
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_self->ndims, __pyx_int_2, Py_GT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "fiona/ogrext.pyx":198
 *         assert cogr_geometry is not NULL
 *         if self.ndims > 2:
 *             x, y, z = self.coordinates             # <<<<<<<<<<<<<<
 *             ograpi.OGR_G_AddPoint(cogr_geometry, x, y, z)
 *         else:
 */
    if ((likely(PyTuple_CheckExact(__pyx_v_self->coordinates))) || (PyList_CheckExact(__pyx_v_self->coordinates))) {
      PyObject* sequence = __pyx_v_self->coordinates;
      if (likely(PyTuple_CheckExact(sequence))) {
        if (unlikely(PyTuple_GET_SIZE(sequence) != 3)) {
          if (PyTuple_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
          else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        if (unlikely(PyList_GET_SIZE(sequence) != 3)) {
          if (PyList_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
          else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
    } else {
      Py_ssize_t index = -1;
      __pyx_t_5 = PyObject_GetIter(__pyx_v_self->coordinates); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 2; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L5_unpacking_done;
      __pyx_L4_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
      if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L5_unpacking_done:;
    }
    __pyx_v_x = __pyx_t_1;
    __pyx_t_1 = 0;
    __pyx_v_y = __pyx_t_3;
    __pyx_t_3 = 0;
    __pyx_v_z = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "fiona/ogrext.pyx":199
 *         if self.ndims > 2:
 *             x, y, z = self.coordinates
 *             ograpi.OGR_G_AddPoint(cogr_geometry, x, y, z)             # <<<<<<<<<<<<<<
 *         else:
 *             x, y = self.coordinates
 */
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_v_x); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_v_y); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_v_z); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    OGR_G_AddPoint(__pyx_v_cogr_geometry, __pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "fiona/ogrext.pyx":201
 *             ograpi.OGR_G_AddPoint(cogr_geometry, x, y, z)
 *         else:
 *             x, y = self.coordinates             # <<<<<<<<<<<<<<
 *             ograpi.OGR_G_AddPoint_2D(cogr_geometry, x, y)
 *         return cogr_geometry
 */
    if ((likely(PyTuple_CheckExact(__pyx_v_self->coordinates))) || (PyList_CheckExact(__pyx_v_self->coordinates))) {
      PyObject* sequence = __pyx_v_self->coordinates;
      if (likely(PyTuple_CheckExact(sequence))) {
        if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
          if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
          else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
          if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
          else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
    } else {
      Py_ssize_t index = -1;
      __pyx_t_1 = PyObject_GetIter(__pyx_v_self->coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext;
      index = 0; __pyx_t_4 = __pyx_t_6(__pyx_t_1); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_1), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
      if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L7_unpacking_done:;
    }
    __pyx_v_x = __pyx_t_4;
    __pyx_t_4 = 0;
    __pyx_v_y = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "fiona/ogrext.pyx":202
 *         else:
 *             x, y = self.coordinates
 *             ograpi.OGR_G_AddPoint_2D(cogr_geometry, x, y)             # <<<<<<<<<<<<<<
 *         return cogr_geometry
 * 
 */
    __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_v_x); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_v_y); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    OGR_G_AddPoint_2D(__pyx_v_cogr_geometry, __pyx_t_9, __pyx_t_8);
  }
  __pyx_L3:;

  /* "fiona/ogrext.pyx":203
 *             x, y = self.coordinates
 *             ograpi.OGR_G_AddPoint_2D(cogr_geometry, x, y)
 *         return cogr_geometry             # <<<<<<<<<<<<<<
 * 
 *     cdef void * _buildLineString(self) except NULL:
 */
  __pyx_r = __pyx_v_cogr_geometry;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("fiona.ogrext.OGRGeomBuilder._buildPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_z);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":205
 *         return cogr_geometry
 * 
 *     cdef void * _buildLineString(self) except NULL:             # <<<<<<<<<<<<<<
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(2)
 *         assert cogr_geometry is not NULL
 */

static void *__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildLineString(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *__pyx_v_self) {
  void *__pyx_v_cogr_geometry;
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_v_z = NULL;
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  double __pyx_t_11;
  double __pyx_t_12;
  double __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildLineString");

  /* "fiona/ogrext.pyx":206
 * 
 *     cdef void * _buildLineString(self) except NULL:
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(2)             # <<<<<<<<<<<<<<
 *         assert cogr_geometry is not NULL
 *         for values in self.coordinates:
 */
  __pyx_v_cogr_geometry = OGR_G_CreateGeometry(2);

  /* "fiona/ogrext.pyx":207
 *     cdef void * _buildLineString(self) except NULL:
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(2)
 *         assert cogr_geometry is not NULL             # <<<<<<<<<<<<<<
 *         for values in self.coordinates:
 *             log.debug("Adding point %s", values)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_geometry != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":208
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(2)
 *         assert cogr_geometry is not NULL
 *         for values in self.coordinates:             # <<<<<<<<<<<<<<
 *             log.debug("Adding point %s", values)
 *             if len(values) > 2:
 */
  if (PyList_CheckExact(__pyx_v_self->coordinates) || PyTuple_CheckExact(__pyx_v_self->coordinates)) {
    __pyx_t_1 = __pyx_v_self->coordinates; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else if (PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF(__pyx_v_values);
    __pyx_v_values = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "fiona/ogrext.pyx":209
 *         assert cogr_geometry is not NULL
 *         for values in self.coordinates:
 *             log.debug("Adding point %s", values)             # <<<<<<<<<<<<<<
 *             if len(values) > 2:
 *                 x, y, z = values
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
    __Pyx_INCREF(__pyx_v_values);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_values);
    __Pyx_GIVEREF(__pyx_v_values);
    __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "fiona/ogrext.pyx":210
 *         for values in self.coordinates:
 *             log.debug("Adding point %s", values)
 *             if len(values) > 2:             # <<<<<<<<<<<<<<
 *                 x, y, z = values
 *                 ograpi.OGR_G_AddPoint(cogr_geometry, x, y, z)
 */
    __pyx_t_7 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = (__pyx_t_7 > 2);
    if (__pyx_t_8) {

      /* "fiona/ogrext.pyx":211
 *             log.debug("Adding point %s", values)
 *             if len(values) > 2:
 *                 x, y, z = values             # <<<<<<<<<<<<<<
 *                 ograpi.OGR_G_AddPoint(cogr_geometry, x, y, z)
 *             else:
 */
      if ((likely(PyTuple_CheckExact(__pyx_v_values))) || (PyList_CheckExact(__pyx_v_values))) {
        PyObject* sequence = __pyx_v_values;
        if (likely(PyTuple_CheckExact(sequence))) {
          if (unlikely(PyTuple_GET_SIZE(sequence) != 3)) {
            if (PyTuple_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
            else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          if (unlikely(PyList_GET_SIZE(sequence) != 3)) {
            if (PyList_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
            else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
      } else {
        Py_ssize_t index = -1;
        __pyx_t_9 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 2; __pyx_t_5 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
        if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_x);
      __pyx_v_x = __pyx_t_6;
      __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_v_y);
      __pyx_v_y = __pyx_t_4;
      __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_v_z);
      __pyx_v_z = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "fiona/ogrext.pyx":212
 *             if len(values) > 2:
 *                 x, y, z = values
 *                 ograpi.OGR_G_AddPoint(cogr_geometry, x, y, z)             # <<<<<<<<<<<<<<
 *             else:
 *                 x, y = values
 */
      __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_v_x); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_y); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_v_z); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      OGR_G_AddPoint(__pyx_v_cogr_geometry, __pyx_t_11, __pyx_t_12, __pyx_t_13);
      goto __pyx_L5;
    }
    /*else*/ {

      /* "fiona/ogrext.pyx":214
 *                 ograpi.OGR_G_AddPoint(cogr_geometry, x, y, z)
 *             else:
 *                 x, y = values             # <<<<<<<<<<<<<<
 *                 ograpi.OGR_G_AddPoint_2D(cogr_geometry, x, y)
 *         return cogr_geometry
 */
      if ((likely(PyTuple_CheckExact(__pyx_v_values))) || (PyList_CheckExact(__pyx_v_values))) {
        PyObject* sequence = __pyx_v_values;
        if (likely(PyTuple_CheckExact(sequence))) {
          if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
            if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
            if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
      } else {
        Py_ssize_t index = -1;
        __pyx_t_6 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_10 = Py_TYPE(__pyx_t_6)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_10(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L9_unpacking_done;
        __pyx_L8_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
        if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L9_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_x);
      __pyx_v_x = __pyx_t_5;
      __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_v_y);
      __pyx_v_y = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "fiona/ogrext.pyx":215
 *             else:
 *                 x, y = values
 *                 ograpi.OGR_G_AddPoint_2D(cogr_geometry, x, y)             # <<<<<<<<<<<<<<
 *         return cogr_geometry
 * 
 */
      __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_v_x); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_y); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      OGR_G_AddPoint_2D(__pyx_v_cogr_geometry, __pyx_t_13, __pyx_t_12);
    }
    __pyx_L5:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":216
 *                 x, y = values
 *                 ograpi.OGR_G_AddPoint_2D(cogr_geometry, x, y)
 *         return cogr_geometry             # <<<<<<<<<<<<<<
 * 
 *     cdef void * _buildLinearRing(self) except NULL:
 */
  __pyx_r = __pyx_v_cogr_geometry;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("fiona.ogrext.OGRGeomBuilder._buildLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_z);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":218
 *         return cogr_geometry
 * 
 *     cdef void * _buildLinearRing(self) except NULL:             # <<<<<<<<<<<<<<
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(101)
 *         assert cogr_geometry is not NULL
 */

static void *__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildLinearRing(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *__pyx_v_self) {
  void *__pyx_v_cogr_geometry;
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_v_z = NULL;
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  double __pyx_t_11;
  double __pyx_t_12;
  double __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildLinearRing");

  /* "fiona/ogrext.pyx":219
 * 
 *     cdef void * _buildLinearRing(self) except NULL:
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(101)             # <<<<<<<<<<<<<<
 *         assert cogr_geometry is not NULL
 *         for values in self.coordinates:
 */
  __pyx_v_cogr_geometry = OGR_G_CreateGeometry(101);

  /* "fiona/ogrext.pyx":220
 *     cdef void * _buildLinearRing(self) except NULL:
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(101)
 *         assert cogr_geometry is not NULL             # <<<<<<<<<<<<<<
 *         for values in self.coordinates:
 *             log.debug("Adding point %s", values)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_geometry != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":221
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(101)
 *         assert cogr_geometry is not NULL
 *         for values in self.coordinates:             # <<<<<<<<<<<<<<
 *             log.debug("Adding point %s", values)
 *             if len(values) > 2:
 */
  if (PyList_CheckExact(__pyx_v_self->coordinates) || PyTuple_CheckExact(__pyx_v_self->coordinates)) {
    __pyx_t_1 = __pyx_v_self->coordinates; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else if (PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF(__pyx_v_values);
    __pyx_v_values = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "fiona/ogrext.pyx":222
 *         assert cogr_geometry is not NULL
 *         for values in self.coordinates:
 *             log.debug("Adding point %s", values)             # <<<<<<<<<<<<<<
 *             if len(values) > 2:
 *                 x, y, z = values
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
    __Pyx_INCREF(__pyx_v_values);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_values);
    __Pyx_GIVEREF(__pyx_v_values);
    __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "fiona/ogrext.pyx":223
 *         for values in self.coordinates:
 *             log.debug("Adding point %s", values)
 *             if len(values) > 2:             # <<<<<<<<<<<<<<
 *                 x, y, z = values
 *                 ograpi.OGR_G_AddPoint(cogr_geometry, x, y, z)
 */
    __pyx_t_7 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = (__pyx_t_7 > 2);
    if (__pyx_t_8) {

      /* "fiona/ogrext.pyx":224
 *             log.debug("Adding point %s", values)
 *             if len(values) > 2:
 *                 x, y, z = values             # <<<<<<<<<<<<<<
 *                 ograpi.OGR_G_AddPoint(cogr_geometry, x, y, z)
 *             else:
 */
      if ((likely(PyTuple_CheckExact(__pyx_v_values))) || (PyList_CheckExact(__pyx_v_values))) {
        PyObject* sequence = __pyx_v_values;
        if (likely(PyTuple_CheckExact(sequence))) {
          if (unlikely(PyTuple_GET_SIZE(sequence) != 3)) {
            if (PyTuple_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
            else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          if (unlikely(PyList_GET_SIZE(sequence) != 3)) {
            if (PyList_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
            else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
      } else {
        Py_ssize_t index = -1;
        __pyx_t_9 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 2; __pyx_t_5 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
        if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_x);
      __pyx_v_x = __pyx_t_6;
      __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_v_y);
      __pyx_v_y = __pyx_t_4;
      __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_v_z);
      __pyx_v_z = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "fiona/ogrext.pyx":225
 *             if len(values) > 2:
 *                 x, y, z = values
 *                 ograpi.OGR_G_AddPoint(cogr_geometry, x, y, z)             # <<<<<<<<<<<<<<
 *             else:
 *                 x, y = values
 */
      __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_v_x); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_y); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_v_z); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      OGR_G_AddPoint(__pyx_v_cogr_geometry, __pyx_t_11, __pyx_t_12, __pyx_t_13);
      goto __pyx_L5;
    }
    /*else*/ {

      /* "fiona/ogrext.pyx":227
 *                 ograpi.OGR_G_AddPoint(cogr_geometry, x, y, z)
 *             else:
 *                 x, y = values             # <<<<<<<<<<<<<<
 *                 log.debug("Adding values %f, %f", x, y)
 *                 ograpi.OGR_G_AddPoint_2D(cogr_geometry, x, y)
 */
      if ((likely(PyTuple_CheckExact(__pyx_v_values))) || (PyList_CheckExact(__pyx_v_values))) {
        PyObject* sequence = __pyx_v_values;
        if (likely(PyTuple_CheckExact(sequence))) {
          if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
            if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
            if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
      } else {
        Py_ssize_t index = -1;
        __pyx_t_6 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_10 = Py_TYPE(__pyx_t_6)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_10(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L9_unpacking_done;
        __pyx_L8_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
        if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L9_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_x);
      __pyx_v_x = __pyx_t_5;
      __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_v_y);
      __pyx_v_y = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "fiona/ogrext.pyx":228
 *             else:
 *                 x, y = values
 *                 log.debug("Adding values %f, %f", x, y)             # <<<<<<<<<<<<<<
 *                 ograpi.OGR_G_AddPoint_2D(cogr_geometry, x, y)
 *         log.debug("Closing ring")
 */
      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_4));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
      __Pyx_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "fiona/ogrext.pyx":229
 *                 x, y = values
 *                 log.debug("Adding values %f, %f", x, y)
 *                 ograpi.OGR_G_AddPoint_2D(cogr_geometry, x, y)             # <<<<<<<<<<<<<<
 *         log.debug("Closing ring")
 *         ograpi.OGR_G_CloseRings(cogr_geometry)
 */
      __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_v_x); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_y); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      OGR_G_AddPoint_2D(__pyx_v_cogr_geometry, __pyx_t_13, __pyx_t_12);
    }
    __pyx_L5:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":230
 *                 log.debug("Adding values %f, %f", x, y)
 *                 ograpi.OGR_G_AddPoint_2D(cogr_geometry, x, y)
 *         log.debug("Closing ring")             # <<<<<<<<<<<<<<
 *         ograpi.OGR_G_CloseRings(cogr_geometry)
 *         return cogr_geometry
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":231
 *                 ograpi.OGR_G_AddPoint_2D(cogr_geometry, x, y)
 *         log.debug("Closing ring")
 *         ograpi.OGR_G_CloseRings(cogr_geometry)             # <<<<<<<<<<<<<<
 *         return cogr_geometry
 * 
 */
  OGR_G_CloseRings(__pyx_v_cogr_geometry);

  /* "fiona/ogrext.pyx":232
 *         log.debug("Closing ring")
 *         ograpi.OGR_G_CloseRings(cogr_geometry)
 *         return cogr_geometry             # <<<<<<<<<<<<<<
 * 
 *     cdef void * _buildPolygon(self) except NULL:
 */
  __pyx_r = __pyx_v_cogr_geometry;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("fiona.ogrext.OGRGeomBuilder._buildLinearRing", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_z);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":234
 *         return cogr_geometry
 * 
 *     cdef void * _buildPolygon(self) except NULL:             # <<<<<<<<<<<<<<
 *         cdef void *cogr_ring
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(3)
 */

static void *__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildPolygon(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *__pyx_v_self) {
  void *__pyx_v_cogr_ring;
  void *__pyx_v_cogr_geometry;
  PyObject *__pyx_v_ring = NULL;
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  void *__pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildPolygon");

  /* "fiona/ogrext.pyx":236
 *     cdef void * _buildPolygon(self) except NULL:
 *         cdef void *cogr_ring
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(3)             # <<<<<<<<<<<<<<
 *         assert cogr_geometry is not NULL
 *         self.ndims = len(self.coordinates[0][0])
 */
  __pyx_v_cogr_geometry = OGR_G_CreateGeometry(3);

  /* "fiona/ogrext.pyx":237
 *         cdef void *cogr_ring
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(3)
 *         assert cogr_geometry is not NULL             # <<<<<<<<<<<<<<
 *         self.ndims = len(self.coordinates[0][0])
 *         for ring in self.coordinates:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_geometry != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":238
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(3)
 *         assert cogr_geometry is not NULL
 *         self.ndims = len(self.coordinates[0][0])             # <<<<<<<<<<<<<<
 *         for ring in self.coordinates:
 *             log.debug("Adding ring %s", ring)
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->coordinates, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->ndims);
  __Pyx_DECREF(__pyx_v_self->ndims);
  __pyx_v_self->ndims = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":239
 *         assert cogr_geometry is not NULL
 *         self.ndims = len(self.coordinates[0][0])
 *         for ring in self.coordinates:             # <<<<<<<<<<<<<<
 *             log.debug("Adding ring %s", ring)
 *             cogr_ring = OGRGeomBuilder().build(
 */
  if (PyList_CheckExact(__pyx_v_self->coordinates) || PyTuple_CheckExact(__pyx_v_self->coordinates)) {
    __pyx_t_2 = __pyx_v_self->coordinates; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_self->coordinates); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  for (;;) {
    if (PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else if (PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++;
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_ring);
    __pyx_v_ring = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "fiona/ogrext.pyx":240
 *         self.ndims = len(self.coordinates[0][0])
 *         for ring in self.coordinates:
 *             log.debug("Adding ring %s", ring)             # <<<<<<<<<<<<<<
 *             cogr_ring = OGRGeomBuilder().build(
 *                 {'type': 'LinearRing', 'coordinates': ring} )
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_7));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
    __Pyx_INCREF(__pyx_v_ring);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ring);
    __Pyx_GIVEREF(__pyx_v_ring);
    __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "fiona/ogrext.pyx":241
 *         for ring in self.coordinates:
 *             log.debug("Adding ring %s", ring)
 *             cogr_ring = OGRGeomBuilder().build(             # <<<<<<<<<<<<<<
 *                 {'type': 'LinearRing', 'coordinates': ring} )
 *             log.debug("Built ring")
 */
    __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_OGRGeomBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);

    /* "fiona/ogrext.pyx":242
 *             log.debug("Adding ring %s", ring)
 *             cogr_ring = OGRGeomBuilder().build(
 *                 {'type': 'LinearRing', 'coordinates': ring} )             # <<<<<<<<<<<<<<
 *             log.debug("Built ring")
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_ring)
 */
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__type), ((PyObject *)__pyx_n_s__LinearRing)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__coordinates), __pyx_v_ring) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)__pyx_t_6)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)__pyx_t_6), ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_v_cogr_ring = __pyx_t_7;

    /* "fiona/ogrext.pyx":243
 *             cogr_ring = OGRGeomBuilder().build(
 *                 {'type': 'LinearRing', 'coordinates': ring} )
 *             log.debug("Built ring")             # <<<<<<<<<<<<<<
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_ring)
 *             log.debug("Added ring %s", ring)
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "fiona/ogrext.pyx":244
 *                 {'type': 'LinearRing', 'coordinates': ring} )
 *             log.debug("Built ring")
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_ring)             # <<<<<<<<<<<<<<
 *             log.debug("Added ring %s", ring)
 *         return cogr_geometry
 */
    OGR_G_AddGeometryDirectly(__pyx_v_cogr_geometry, __pyx_v_cogr_ring);

    /* "fiona/ogrext.pyx":245
 *             log.debug("Built ring")
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_ring)
 *             log.debug("Added ring %s", ring)             # <<<<<<<<<<<<<<
 *         return cogr_geometry
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_10));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_10));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_10));
    __Pyx_INCREF(__pyx_v_ring);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ring);
    __Pyx_GIVEREF(__pyx_v_ring);
    __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":246
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_ring)
 *             log.debug("Added ring %s", ring)
 *         return cogr_geometry             # <<<<<<<<<<<<<<
 * 
 *     cdef void * _buildMultiPoint(self) except NULL:
 */
  __pyx_r = __pyx_v_cogr_geometry;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("fiona.ogrext.OGRGeomBuilder._buildPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ring);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":248
 *         return cogr_geometry
 * 
 *     cdef void * _buildMultiPoint(self) except NULL:             # <<<<<<<<<<<<<<
 *         cdef void *cogr_part
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(4)
 */

static void *__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildMultiPoint(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *__pyx_v_self) {
  void *__pyx_v_cogr_part;
  void *__pyx_v_cogr_geometry;
  PyObject *__pyx_v_values = NULL;
  PyObject *__pyx_v_x = NULL;
  PyObject *__pyx_v_y = NULL;
  PyObject *__pyx_v_z = NULL;
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  double __pyx_t_11;
  double __pyx_t_12;
  double __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildMultiPoint");

  /* "fiona/ogrext.pyx":250
 *     cdef void * _buildMultiPoint(self) except NULL:
 *         cdef void *cogr_part
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(4)             # <<<<<<<<<<<<<<
 *         assert cogr_geometry is not NULL
 *         for values in self.coordinates:
 */
  __pyx_v_cogr_geometry = OGR_G_CreateGeometry(4);

  /* "fiona/ogrext.pyx":251
 *         cdef void *cogr_part
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(4)
 *         assert cogr_geometry is not NULL             # <<<<<<<<<<<<<<
 *         for values in self.coordinates:
 *             log.debug("Adding point %s", values)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_geometry != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":252
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(4)
 *         assert cogr_geometry is not NULL
 *         for values in self.coordinates:             # <<<<<<<<<<<<<<
 *             log.debug("Adding point %s", values)
 *             cogr_part = ograpi.OGR_G_CreateGeometry(1)
 */
  if (PyList_CheckExact(__pyx_v_self->coordinates) || PyTuple_CheckExact(__pyx_v_self->coordinates)) {
    __pyx_t_1 = __pyx_v_self->coordinates; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else if (PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF(__pyx_v_values);
    __pyx_v_values = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "fiona/ogrext.pyx":253
 *         assert cogr_geometry is not NULL
 *         for values in self.coordinates:
 *             log.debug("Adding point %s", values)             # <<<<<<<<<<<<<<
 *             cogr_part = ograpi.OGR_G_CreateGeometry(1)
 *             if len(values) > 2:
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
    __Pyx_INCREF(__pyx_v_values);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_values);
    __Pyx_GIVEREF(__pyx_v_values);
    __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "fiona/ogrext.pyx":254
 *         for values in self.coordinates:
 *             log.debug("Adding point %s", values)
 *             cogr_part = ograpi.OGR_G_CreateGeometry(1)             # <<<<<<<<<<<<<<
 *             if len(values) > 2:
 *                 x, y, z = values
 */
    __pyx_v_cogr_part = OGR_G_CreateGeometry(1);

    /* "fiona/ogrext.pyx":255
 *             log.debug("Adding point %s", values)
 *             cogr_part = ograpi.OGR_G_CreateGeometry(1)
 *             if len(values) > 2:             # <<<<<<<<<<<<<<
 *                 x, y, z = values
 *                 ograpi.OGR_G_AddPoint(cogr_part, x, y, z)
 */
    __pyx_t_7 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = (__pyx_t_7 > 2);
    if (__pyx_t_8) {

      /* "fiona/ogrext.pyx":256
 *             cogr_part = ograpi.OGR_G_CreateGeometry(1)
 *             if len(values) > 2:
 *                 x, y, z = values             # <<<<<<<<<<<<<<
 *                 ograpi.OGR_G_AddPoint(cogr_part, x, y, z)
 *             else:
 */
      if ((likely(PyTuple_CheckExact(__pyx_v_values))) || (PyList_CheckExact(__pyx_v_values))) {
        PyObject* sequence = __pyx_v_values;
        if (likely(PyTuple_CheckExact(sequence))) {
          if (unlikely(PyTuple_GET_SIZE(sequence) != 3)) {
            if (PyTuple_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
            else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
        } else {
          if (unlikely(PyList_GET_SIZE(sequence) != 3)) {
            if (PyList_GET_SIZE(sequence) > 3) __Pyx_RaiseTooManyValuesError(3);
            else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
        }
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
      } else {
        Py_ssize_t index = -1;
        __pyx_t_9 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
        index = 0; __pyx_t_6 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_6);
        index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        index = 2; __pyx_t_5 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
        if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_x);
      __pyx_v_x = __pyx_t_6;
      __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_v_y);
      __pyx_v_y = __pyx_t_4;
      __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_v_z);
      __pyx_v_z = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "fiona/ogrext.pyx":257
 *             if len(values) > 2:
 *                 x, y, z = values
 *                 ograpi.OGR_G_AddPoint(cogr_part, x, y, z)             # <<<<<<<<<<<<<<
 *             else:
 *                 x, y = values
 */
      __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_v_x); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_y); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_v_z); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      OGR_G_AddPoint(__pyx_v_cogr_part, __pyx_t_11, __pyx_t_12, __pyx_t_13);
      goto __pyx_L5;
    }
    /*else*/ {

      /* "fiona/ogrext.pyx":259
 *                 ograpi.OGR_G_AddPoint(cogr_part, x, y, z)
 *             else:
 *                 x, y = values             # <<<<<<<<<<<<<<
 *                 ograpi.OGR_G_AddPoint_2D(cogr_part, x, y)
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 */
      if ((likely(PyTuple_CheckExact(__pyx_v_values))) || (PyList_CheckExact(__pyx_v_values))) {
        PyObject* sequence = __pyx_v_values;
        if (likely(PyTuple_CheckExact(sequence))) {
          if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
            if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
            if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
      } else {
        Py_ssize_t index = -1;
        __pyx_t_6 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_10 = Py_TYPE(__pyx_t_6)->tp_iternext;
        index = 0; __pyx_t_5 = __pyx_t_10(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_5);
        index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L8_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L9_unpacking_done;
        __pyx_L8_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
        if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L9_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_x);
      __pyx_v_x = __pyx_t_5;
      __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_v_y);
      __pyx_v_y = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "fiona/ogrext.pyx":260
 *             else:
 *                 x, y = values
 *                 ograpi.OGR_G_AddPoint_2D(cogr_part, x, y)             # <<<<<<<<<<<<<<
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added point %s", values)
 */
      __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_v_x); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_y); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      OGR_G_AddPoint_2D(__pyx_v_cogr_part, __pyx_t_13, __pyx_t_12);
    }
    __pyx_L5:;

    /* "fiona/ogrext.pyx":261
 *                 x, y = values
 *                 ograpi.OGR_G_AddPoint_2D(cogr_part, x, y)
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)             # <<<<<<<<<<<<<<
 *             log.debug("Added point %s", values)
 *         return cogr_geometry
 */
    OGR_G_AddGeometryDirectly(__pyx_v_cogr_geometry, __pyx_v_cogr_part);

    /* "fiona/ogrext.pyx":262
 *                 ograpi.OGR_G_AddPoint_2D(cogr_part, x, y)
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added point %s", values)             # <<<<<<<<<<<<<<
 *         return cogr_geometry
 * 
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_11));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_11));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_11));
    __Pyx_INCREF(__pyx_v_values);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_values);
    __Pyx_GIVEREF(__pyx_v_values);
    __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":263
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added point %s", values)
 *         return cogr_geometry             # <<<<<<<<<<<<<<
 * 
 *     cdef void * _buildMultiLineString(self) except NULL:
 */
  __pyx_r = __pyx_v_cogr_geometry;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("fiona.ogrext.OGRGeomBuilder._buildMultiPoint", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_values);
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_XDECREF(__pyx_v_y);
  __Pyx_XDECREF(__pyx_v_z);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":265
 *         return cogr_geometry
 * 
 *     cdef void * _buildMultiLineString(self) except NULL:             # <<<<<<<<<<<<<<
 *         cdef void *cogr_part
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(5)
 */

static void *__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildMultiLineString(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *__pyx_v_self) {
  void *__pyx_v_cogr_part;
  void *__pyx_v_cogr_geometry;
  PyObject *__pyx_v_line = NULL;
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  void *__pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildMultiLineString");

  /* "fiona/ogrext.pyx":267
 *     cdef void * _buildMultiLineString(self) except NULL:
 *         cdef void *cogr_part
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(5)             # <<<<<<<<<<<<<<
 *         assert cogr_geometry is not NULL
 *         for line in self.coordinates:
 */
  __pyx_v_cogr_geometry = OGR_G_CreateGeometry(5);

  /* "fiona/ogrext.pyx":268
 *         cdef void *cogr_part
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(5)
 *         assert cogr_geometry is not NULL             # <<<<<<<<<<<<<<
 *         for line in self.coordinates:
 *             log.debug("Adding line %s", line)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_geometry != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":269
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(5)
 *         assert cogr_geometry is not NULL
 *         for line in self.coordinates:             # <<<<<<<<<<<<<<
 *             log.debug("Adding line %s", line)
 *             cogr_part = OGRGeomBuilder().build(
 */
  if (PyList_CheckExact(__pyx_v_self->coordinates) || PyTuple_CheckExact(__pyx_v_self->coordinates)) {
    __pyx_t_1 = __pyx_v_self->coordinates; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else if (PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF(__pyx_v_line);
    __pyx_v_line = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "fiona/ogrext.pyx":270
 *         assert cogr_geometry is not NULL
 *         for line in self.coordinates:
 *             log.debug("Adding line %s", line)             # <<<<<<<<<<<<<<
 *             cogr_part = OGRGeomBuilder().build(
 *                 {'type': 'LineString', 'coordinates': line} )
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_12));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
    __Pyx_INCREF(__pyx_v_line);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_line);
    __Pyx_GIVEREF(__pyx_v_line);
    __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "fiona/ogrext.pyx":271
 *         for line in self.coordinates:
 *             log.debug("Adding line %s", line)
 *             cogr_part = OGRGeomBuilder().build(             # <<<<<<<<<<<<<<
 *                 {'type': 'LineString', 'coordinates': line} )
 *             log.debug("Built line")
 */
    __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_OGRGeomBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);

    /* "fiona/ogrext.pyx":272
 *             log.debug("Adding line %s", line)
 *             cogr_part = OGRGeomBuilder().build(
 *                 {'type': 'LineString', 'coordinates': line} )             # <<<<<<<<<<<<<<
 *             log.debug("Built line")
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 */
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__type), ((PyObject *)__pyx_n_s__LineString)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__coordinates), __pyx_v_line) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)__pyx_t_6)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)__pyx_t_6), ((PyObject *)__pyx_t_4)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_v_cogr_part = __pyx_t_7;

    /* "fiona/ogrext.pyx":273
 *             cogr_part = OGRGeomBuilder().build(
 *                 {'type': 'LineString', 'coordinates': line} )
 *             log.debug("Built line")             # <<<<<<<<<<<<<<
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added line %s", line)
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__debug); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "fiona/ogrext.pyx":274
 *                 {'type': 'LineString', 'coordinates': line} )
 *             log.debug("Built line")
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)             # <<<<<<<<<<<<<<
 *             log.debug("Added line %s", line)
 *         return cogr_geometry
 */
    OGR_G_AddGeometryDirectly(__pyx_v_cogr_geometry, __pyx_v_cogr_part);

    /* "fiona/ogrext.pyx":275
 *             log.debug("Built line")
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added line %s", line)             # <<<<<<<<<<<<<<
 *         return cogr_geometry
 * 
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__debug); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_15));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_15));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_15));
    __Pyx_INCREF(__pyx_v_line);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_line);
    __Pyx_GIVEREF(__pyx_v_line);
    __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":276
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added line %s", line)
 *         return cogr_geometry             # <<<<<<<<<<<<<<
 * 
 *     cdef void * _buildMultiPolygon(self) except NULL:
 */
  __pyx_r = __pyx_v_cogr_geometry;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("fiona.ogrext.OGRGeomBuilder._buildMultiLineString", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":278
 *         return cogr_geometry
 * 
 *     cdef void * _buildMultiPolygon(self) except NULL:             # <<<<<<<<<<<<<<
 *         cdef void *cogr_part
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(6)
 */

static void *__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildMultiPolygon(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *__pyx_v_self) {
  void *__pyx_v_cogr_part;
  void *__pyx_v_cogr_geometry;
  PyObject *__pyx_v_part = NULL;
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  void *__pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildMultiPolygon");

  /* "fiona/ogrext.pyx":280
 *     cdef void * _buildMultiPolygon(self) except NULL:
 *         cdef void *cogr_part
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(6)             # <<<<<<<<<<<<<<
 *         assert cogr_geometry is not NULL
 *         for part in self.coordinates:
 */
  __pyx_v_cogr_geometry = OGR_G_CreateGeometry(6);

  /* "fiona/ogrext.pyx":281
 *         cdef void *cogr_part
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(6)
 *         assert cogr_geometry is not NULL             # <<<<<<<<<<<<<<
 *         for part in self.coordinates:
 *             log.debug("Adding polygon %s", part)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_geometry != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":282
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(6)
 *         assert cogr_geometry is not NULL
 *         for part in self.coordinates:             # <<<<<<<<<<<<<<
 *             log.debug("Adding polygon %s", part)
 *             cogr_part = OGRGeomBuilder().build(
 */
  if (PyList_CheckExact(__pyx_v_self->coordinates) || PyTuple_CheckExact(__pyx_v_self->coordinates)) {
    __pyx_t_1 = __pyx_v_self->coordinates; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else if (PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF(__pyx_v_part);
    __pyx_v_part = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "fiona/ogrext.pyx":283
 *         assert cogr_geometry is not NULL
 *         for part in self.coordinates:
 *             log.debug("Adding polygon %s", part)             # <<<<<<<<<<<<<<
 *             cogr_part = OGRGeomBuilder().build(
 *                 {'type': 'Polygon', 'coordinates': part} )
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_16));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_16));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_16));
    __Pyx_INCREF(__pyx_v_part);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_part);
    __Pyx_GIVEREF(__pyx_v_part);
    __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "fiona/ogrext.pyx":284
 *         for part in self.coordinates:
 *             log.debug("Adding polygon %s", part)
 *             cogr_part = OGRGeomBuilder().build(             # <<<<<<<<<<<<<<
 *                 {'type': 'Polygon', 'coordinates': part} )
 *             log.debug("Built polygon")
 */
    __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_OGRGeomBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);

    /* "fiona/ogrext.pyx":285
 *             log.debug("Adding polygon %s", part)
 *             cogr_part = OGRGeomBuilder().build(
 *                 {'type': 'Polygon', 'coordinates': part} )             # <<<<<<<<<<<<<<
 *             log.debug("Built polygon")
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 */
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__type), ((PyObject *)__pyx_n_s__Polygon)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__coordinates), __pyx_v_part) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)__pyx_t_6)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)__pyx_t_6), ((PyObject *)__pyx_t_4)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_v_cogr_part = __pyx_t_7;

    /* "fiona/ogrext.pyx":286
 *             cogr_part = OGRGeomBuilder().build(
 *                 {'type': 'Polygon', 'coordinates': part} )
 *             log.debug("Built polygon")             # <<<<<<<<<<<<<<
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added polygon %s", part)
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__debug); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_k_tuple_18), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "fiona/ogrext.pyx":287
 *                 {'type': 'Polygon', 'coordinates': part} )
 *             log.debug("Built polygon")
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)             # <<<<<<<<<<<<<<
 *             log.debug("Added polygon %s", part)
 *         return cogr_geometry
 */
    OGR_G_AddGeometryDirectly(__pyx_v_cogr_geometry, __pyx_v_cogr_part);

    /* "fiona/ogrext.pyx":288
 *             log.debug("Built polygon")
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added polygon %s", part)             # <<<<<<<<<<<<<<
 *         return cogr_geometry
 * 
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__debug); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_19));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
    __Pyx_INCREF(__pyx_v_part);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_part);
    __Pyx_GIVEREF(__pyx_v_part);
    __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":289
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added polygon %s", part)
 *         return cogr_geometry             # <<<<<<<<<<<<<<
 * 
 *     cdef void * _buildGeometryCollection(self) except NULL:
 */
  __pyx_r = __pyx_v_cogr_geometry;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("fiona.ogrext.OGRGeomBuilder._buildMultiPolygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_part);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":291
 *         return cogr_geometry
 * 
 *     cdef void * _buildGeometryCollection(self) except NULL:             # <<<<<<<<<<<<<<
 *         cdef void *cogr_part
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(7)
 */

static void *__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildGeometryCollection(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *__pyx_v_self) {
  void *__pyx_v_cogr_part;
  void *__pyx_v_cogr_geometry;
  PyObject *__pyx_v_part = NULL;
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  void *__pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buildGeometryCollection");

  /* "fiona/ogrext.pyx":293
 *     cdef void * _buildGeometryCollection(self) except NULL:
 *         cdef void *cogr_part
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(7)             # <<<<<<<<<<<<<<
 *         assert cogr_geometry is not NULL
 *         for part in self.coordinates:
 */
  __pyx_v_cogr_geometry = OGR_G_CreateGeometry(7);

  /* "fiona/ogrext.pyx":294
 *         cdef void *cogr_part
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(7)
 *         assert cogr_geometry is not NULL             # <<<<<<<<<<<<<<
 *         for part in self.coordinates:
 *             log.debug("Adding part %s", part)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_geometry != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":295
 *         cdef void *cogr_geometry = ograpi.OGR_G_CreateGeometry(7)
 *         assert cogr_geometry is not NULL
 *         for part in self.coordinates:             # <<<<<<<<<<<<<<
 *             log.debug("Adding part %s", part)
 *             cogr_part = OGRGeomBuilder().build(part)
 */
  if (PyList_CheckExact(__pyx_v_self->coordinates) || PyTuple_CheckExact(__pyx_v_self->coordinates)) {
    __pyx_t_1 = __pyx_v_self->coordinates; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->coordinates); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else if (PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++;
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF(__pyx_v_part);
    __pyx_v_part = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "fiona/ogrext.pyx":296
 *         assert cogr_geometry is not NULL
 *         for part in self.coordinates:
 *             log.debug("Adding part %s", part)             # <<<<<<<<<<<<<<
 *             cogr_part = OGRGeomBuilder().build(part)
 *             log.debug("Built part")
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__debug); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_20));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
    __Pyx_INCREF(__pyx_v_part);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_part);
    __Pyx_GIVEREF(__pyx_v_part);
    __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "fiona/ogrext.pyx":297
 *         for part in self.coordinates:
 *             log.debug("Adding part %s", part)
 *             cogr_part = OGRGeomBuilder().build(part)             # <<<<<<<<<<<<<<
 *             log.debug("Built part")
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 */
    __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_OGRGeomBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)__pyx_t_6)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)__pyx_t_6), __pyx_v_part); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_cogr_part = __pyx_t_7;

    /* "fiona/ogrext.pyx":298
 *             log.debug("Adding part %s", part)
 *             cogr_part = OGRGeomBuilder().build(part)
 *             log.debug("Built part")             # <<<<<<<<<<<<<<
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added part %s", part)
 */
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__debug); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_22), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "fiona/ogrext.pyx":299
 *             cogr_part = OGRGeomBuilder().build(part)
 *             log.debug("Built part")
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)             # <<<<<<<<<<<<<<
 *             log.debug("Added part %s", part)
 *         return cogr_geometry
 */
    OGR_G_AddGeometryDirectly(__pyx_v_cogr_geometry, __pyx_v_cogr_part);

    /* "fiona/ogrext.pyx":300
 *             log.debug("Built part")
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added part %s", part)             # <<<<<<<<<<<<<<
 *         return cogr_geometry
 * 
 */
    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__debug); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_23));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
    __Pyx_INCREF(__pyx_v_part);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_part);
    __Pyx_GIVEREF(__pyx_v_part);
    __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":301
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added part %s", part)
 *         return cogr_geometry             # <<<<<<<<<<<<<<
 * 
 *     cdef void * build(self, object geometry) except NULL:
 */
  __pyx_r = __pyx_v_cogr_geometry;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("fiona.ogrext.OGRGeomBuilder._buildGeometryCollection", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_part);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":303
 *         return cogr_geometry
 * 
 *     cdef void * build(self, object geometry) except NULL:             # <<<<<<<<<<<<<<
 *         handler = DimensionsHandler()
 *         self.typename = geometry['type']
 */

static void *__pyx_f_5fiona_6ogrext_14OGRGeomBuilder_build(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *__pyx_v_self, PyObject *__pyx_v_geometry) {
  PyObject *__pyx_v_handler = NULL;
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  void *__pyx_t_5;
  void *__pyx_t_6;
  void *__pyx_t_7;
  void *__pyx_t_8;
  void *__pyx_t_9;
  void *__pyx_t_10;
  void *__pyx_t_11;
  void *__pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("build");

  /* "fiona/ogrext.pyx":304
 * 
 *     cdef void * build(self, object geometry) except NULL:
 *         handler = DimensionsHandler()             # <<<<<<<<<<<<<<
 *         self.typename = geometry['type']
 *         self.coordinates = geometry.get('coordinates')
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__DimensionsHandler); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_handler = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":305
 *     cdef void * build(self, object geometry) except NULL:
 *         handler = DimensionsHandler()
 *         self.typename = geometry['type']             # <<<<<<<<<<<<<<
 *         self.coordinates = geometry.get('coordinates')
 *         if self.coordinates:
 */
  __pyx_t_2 = PyObject_GetItem(__pyx_v_geometry, ((PyObject *)__pyx_n_s__type)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->typename);
  __Pyx_DECREF(__pyx_v_self->typename);
  __pyx_v_self->typename = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":306
 *         handler = DimensionsHandler()
 *         self.typename = geometry['type']
 *         self.coordinates = geometry.get('coordinates')             # <<<<<<<<<<<<<<
 *         if self.coordinates:
 *             self.ndims = handler.getNumDims(self.typename, self.coordinates)
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_geometry, __pyx_n_s__get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_24), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->coordinates);
  __Pyx_DECREF(__pyx_v_self->coordinates);
  __pyx_v_self->coordinates = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":307
 *         self.typename = geometry['type']
 *         self.coordinates = geometry.get('coordinates')
 *         if self.coordinates:             # <<<<<<<<<<<<<<
 *             self.ndims = handler.getNumDims(self.typename, self.coordinates)
 *         if self.typename == 'Point':
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_self->coordinates); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "fiona/ogrext.pyx":308
 *         self.coordinates = geometry.get('coordinates')
 *         if self.coordinates:
 *             self.ndims = handler.getNumDims(self.typename, self.coordinates)             # <<<<<<<<<<<<<<
 *         if self.typename == 'Point':
 *             return self._buildPoint()
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_handler, __pyx_n_s__getNumDims); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(__pyx_v_self->typename);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->typename);
    __Pyx_GIVEREF(__pyx_v_self->typename);
    __Pyx_INCREF(__pyx_v_self->coordinates);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->coordinates);
    __Pyx_GIVEREF(__pyx_v_self->coordinates);
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->ndims);
    __Pyx_DECREF(__pyx_v_self->ndims);
    __pyx_v_self->ndims = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "fiona/ogrext.pyx":309
 *         if self.coordinates:
 *             self.ndims = handler.getNumDims(self.typename, self.coordinates)
 *         if self.typename == 'Point':             # <<<<<<<<<<<<<<
 *             return self._buildPoint()
 *         elif self.typename == 'LineString':
 */
  __pyx_t_3 = __Pyx_PyString_Equals(__pyx_v_self->typename, ((PyObject *)__pyx_n_s__Point), Py_EQ); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "fiona/ogrext.pyx":310
 *             self.ndims = handler.getNumDims(self.typename, self.coordinates)
 *         if self.typename == 'Point':
 *             return self._buildPoint()             # <<<<<<<<<<<<<<
 *         elif self.typename == 'LineString':
 *             return self._buildLineString()
 */
    __pyx_t_5 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildPoint(__pyx_v_self); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_5;
    goto __pyx_L0;
    goto __pyx_L4;
  }

  /* "fiona/ogrext.pyx":311
 *         if self.typename == 'Point':
 *             return self._buildPoint()
 *         elif self.typename == 'LineString':             # <<<<<<<<<<<<<<
 *             return self._buildLineString()
 *         elif self.typename == 'LinearRing':
 */
  __pyx_t_3 = __Pyx_PyString_Equals(__pyx_v_self->typename, ((PyObject *)__pyx_n_s__LineString), Py_EQ); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "fiona/ogrext.pyx":312
 *             return self._buildPoint()
 *         elif self.typename == 'LineString':
 *             return self._buildLineString()             # <<<<<<<<<<<<<<
 *         elif self.typename == 'LinearRing':
 *             return self._buildLinearRing()
 */
    __pyx_t_6 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildLineString(__pyx_v_self); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_6;
    goto __pyx_L0;
    goto __pyx_L4;
  }

  /* "fiona/ogrext.pyx":313
 *         elif self.typename == 'LineString':
 *             return self._buildLineString()
 *         elif self.typename == 'LinearRing':             # <<<<<<<<<<<<<<
 *             return self._buildLinearRing()
 *         elif self.typename == 'Polygon':
 */
  __pyx_t_3 = __Pyx_PyString_Equals(__pyx_v_self->typename, ((PyObject *)__pyx_n_s__LinearRing), Py_EQ); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "fiona/ogrext.pyx":314
 *             return self._buildLineString()
 *         elif self.typename == 'LinearRing':
 *             return self._buildLinearRing()             # <<<<<<<<<<<<<<
 *         elif self.typename == 'Polygon':
 *             return self._buildPolygon()
 */
    __pyx_t_7 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildLinearRing(__pyx_v_self); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_7;
    goto __pyx_L0;
    goto __pyx_L4;
  }

  /* "fiona/ogrext.pyx":315
 *         elif self.typename == 'LinearRing':
 *             return self._buildLinearRing()
 *         elif self.typename == 'Polygon':             # <<<<<<<<<<<<<<
 *             return self._buildPolygon()
 *         elif self.typename == 'MultiPoint':
 */
  __pyx_t_3 = __Pyx_PyString_Equals(__pyx_v_self->typename, ((PyObject *)__pyx_n_s__Polygon), Py_EQ); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "fiona/ogrext.pyx":316
 *             return self._buildLinearRing()
 *         elif self.typename == 'Polygon':
 *             return self._buildPolygon()             # <<<<<<<<<<<<<<
 *         elif self.typename == 'MultiPoint':
 *             return self._buildMultiPoint()
 */
    __pyx_t_8 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildPolygon(__pyx_v_self); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_8;
    goto __pyx_L0;
    goto __pyx_L4;
  }

  /* "fiona/ogrext.pyx":317
 *         elif self.typename == 'Polygon':
 *             return self._buildPolygon()
 *         elif self.typename == 'MultiPoint':             # <<<<<<<<<<<<<<
 *             return self._buildMultiPoint()
 *         elif self.typename == 'MultiLineString':
 */
  __pyx_t_3 = __Pyx_PyString_Equals(__pyx_v_self->typename, ((PyObject *)__pyx_n_s__MultiPoint), Py_EQ); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "fiona/ogrext.pyx":318
 *             return self._buildPolygon()
 *         elif self.typename == 'MultiPoint':
 *             return self._buildMultiPoint()             # <<<<<<<<<<<<<<
 *         elif self.typename == 'MultiLineString':
 *             return self._buildMultiLineString()
 */
    __pyx_t_9 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildMultiPoint(__pyx_v_self); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_9;
    goto __pyx_L0;
    goto __pyx_L4;
  }

  /* "fiona/ogrext.pyx":319
 *         elif self.typename == 'MultiPoint':
 *             return self._buildMultiPoint()
 *         elif self.typename == 'MultiLineString':             # <<<<<<<<<<<<<<
 *             return self._buildMultiLineString()
 *         elif self.typename == 'MultiPolygon':
 */
  __pyx_t_3 = __Pyx_PyString_Equals(__pyx_v_self->typename, ((PyObject *)__pyx_n_s__MultiLineString), Py_EQ); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "fiona/ogrext.pyx":320
 *             return self._buildMultiPoint()
 *         elif self.typename == 'MultiLineString':
 *             return self._buildMultiLineString()             # <<<<<<<<<<<<<<
 *         elif self.typename == 'MultiPolygon':
 *             return self._buildMultiPolygon()
 */
    __pyx_t_10 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildMultiLineString(__pyx_v_self); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_10;
    goto __pyx_L0;
    goto __pyx_L4;
  }

  /* "fiona/ogrext.pyx":321
 *         elif self.typename == 'MultiLineString':
 *             return self._buildMultiLineString()
 *         elif self.typename == 'MultiPolygon':             # <<<<<<<<<<<<<<
 *             return self._buildMultiPolygon()
 *         elif self.typename == 'GeometryCollection':
 */
  __pyx_t_3 = __Pyx_PyString_Equals(__pyx_v_self->typename, ((PyObject *)__pyx_n_s__MultiPolygon), Py_EQ); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "fiona/ogrext.pyx":322
 *             return self._buildMultiLineString()
 *         elif self.typename == 'MultiPolygon':
 *             return self._buildMultiPolygon()             # <<<<<<<<<<<<<<
 *         elif self.typename == 'GeometryCollection':
 *             self.coordinates = geometry.get('geometries')
 */
    __pyx_t_11 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildMultiPolygon(__pyx_v_self); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_11;
    goto __pyx_L0;
    goto __pyx_L4;
  }

  /* "fiona/ogrext.pyx":323
 *         elif self.typename == 'MultiPolygon':
 *             return self._buildMultiPolygon()
 *         elif self.typename == 'GeometryCollection':             # <<<<<<<<<<<<<<
 *             self.coordinates = geometry.get('geometries')
 *             self.ndims = handler.getNumDims(self.typename, self.coordinates)
 */
  __pyx_t_3 = __Pyx_PyString_Equals(__pyx_v_self->typename, ((PyObject *)__pyx_n_s__GeometryCollection), Py_EQ); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "fiona/ogrext.pyx":324
 *             return self._buildMultiPolygon()
 *         elif self.typename == 'GeometryCollection':
 *             self.coordinates = geometry.get('geometries')             # <<<<<<<<<<<<<<
 *             self.ndims = handler.getNumDims(self.typename, self.coordinates)
 *             return self._buildGeometryCollection()
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_geometry, __pyx_n_s__get); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->coordinates);
    __Pyx_DECREF(__pyx_v_self->coordinates);
    __pyx_v_self->coordinates = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "fiona/ogrext.pyx":325
 *         elif self.typename == 'GeometryCollection':
 *             self.coordinates = geometry.get('geometries')
 *             self.ndims = handler.getNumDims(self.typename, self.coordinates)             # <<<<<<<<<<<<<<
 *             return self._buildGeometryCollection()
 *         else:
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_handler, __pyx_n_s__getNumDims); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(__pyx_v_self->typename);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self->typename);
    __Pyx_GIVEREF(__pyx_v_self->typename);
    __Pyx_INCREF(__pyx_v_self->coordinates);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->coordinates);
    __Pyx_GIVEREF(__pyx_v_self->coordinates);
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->ndims);
    __Pyx_DECREF(__pyx_v_self->ndims);
    __pyx_v_self->ndims = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "fiona/ogrext.pyx":326
 *             self.coordinates = geometry.get('geometries')
 *             self.ndims = handler.getNumDims(self.typename, self.coordinates)
 *             return self._buildGeometryCollection()             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("Unsupported geometry type %s" % self.typename)
 */
    __pyx_t_12 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)__pyx_v_self->__pyx_vtab)->_buildGeometryCollection(__pyx_v_self); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_r = __pyx_t_12;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "fiona/ogrext.pyx":328
 *             return self._buildGeometryCollection()
 *         else:
 *             raise ValueError("Unsupported geometry type %s" % self.typename)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_26), __pyx_v_self->typename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L4:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("fiona.ogrext.OGRGeomBuilder.build", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_handler);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":331
 * 
 * 
 * cdef geometry(void *geom):             # <<<<<<<<<<<<<<
 *     """Factory for Fiona geometries"""
 *     return GeomBuilder().build(geom)
 */

static PyObject *__pyx_f_5fiona_6ogrext_geometry(void *__pyx_v_geom) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("geometry");

  /* "fiona/ogrext.pyx":333
 * cdef geometry(void *geom):
 *     """Factory for Fiona geometries"""
 *     return GeomBuilder().build(geom)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_GeomBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_t_1)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_t_1), __pyx_v_geom); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext.geometry", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":336
 * 
 * 
 * def geometryRT(geometry):             # <<<<<<<<<<<<<<
 *     # For testing purposes only, leaks the JSON data
 *     cdef void *cogr_geometry = OGRGeomBuilder().build(geometry)
 */

static PyObject *__pyx_pf_5fiona_6ogrext_geometryRT(PyObject *__pyx_self, PyObject *__pyx_v_geometry); /*proto*/
static PyMethodDef __pyx_mdef_5fiona_6ogrext_geometryRT = {__Pyx_NAMESTR("geometryRT"), (PyCFunction)__pyx_pf_5fiona_6ogrext_geometryRT, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5fiona_6ogrext_geometryRT(PyObject *__pyx_self, PyObject *__pyx_v_geometry) {
  void *__pyx_v_cogr_geometry;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  void *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("geometryRT");
  __pyx_self = __pyx_self;

  /* "fiona/ogrext.pyx":338
 * def geometryRT(geometry):
 *     # For testing purposes only, leaks the JSON data
 *     cdef void *cogr_geometry = OGRGeomBuilder().build(geometry)             # <<<<<<<<<<<<<<
 *     log.debug("Geometry: %s" % ograpi.OGR_G_ExportToJson(cogr_geometry))
 *     result = GeomBuilder().build(cogr_geometry)
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_OGRGeomBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)__pyx_t_1)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)__pyx_t_1), __pyx_v_geometry); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_cogr_geometry = __pyx_t_2;

  /* "fiona/ogrext.pyx":339
 *     # For testing purposes only, leaks the JSON data
 *     cdef void *cogr_geometry = OGRGeomBuilder().build(geometry)
 *     log.debug("Geometry: %s" % ograpi.OGR_G_ExportToJson(cogr_geometry))             # <<<<<<<<<<<<<<
 *     result = GeomBuilder().build(cogr_geometry)
 *     _deleteOgrGeom(cogr_geometry)
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyBytes_FromUString(OGR_G_ExportToJson(__pyx_v_cogr_geometry)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_27), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "fiona/ogrext.pyx":340
 *     cdef void *cogr_geometry = OGRGeomBuilder().build(geometry)
 *     log.debug("Geometry: %s" % ograpi.OGR_G_ExportToJson(cogr_geometry))
 *     result = GeomBuilder().build(cogr_geometry)             # <<<<<<<<<<<<<<
 *     _deleteOgrGeom(cogr_geometry)
 *     return result
 */
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_GeomBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_t_4)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_t_4), __pyx_v_cogr_geometry); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":341
 *     log.debug("Geometry: %s" % ograpi.OGR_G_ExportToJson(cogr_geometry))
 *     result = GeomBuilder().build(cogr_geometry)
 *     _deleteOgrGeom(cogr_geometry)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  __pyx_t_1 = __pyx_f_5fiona_6ogrext__deleteOgrGeom(__pyx_v_cogr_geometry); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":342
 *     result = GeomBuilder().build(cogr_geometry)
 *     _deleteOgrGeom(cogr_geometry)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("fiona.ogrext.geometryRT", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":354
 *     """
 * 
 *     cdef build(self, void *feature):             # <<<<<<<<<<<<<<
 *         # The only method anyone ever needs to call
 *         assert feature is not NULL
 */

static PyObject *__pyx_f_5fiona_6ogrext_14FeatureBuilder_build(struct __pyx_obj_5fiona_6ogrext_FeatureBuilder *__pyx_v_self, void *__pyx_v_feature) {
  void *__pyx_v_fdefn;
  int __pyx_v_i;
  PyObject *__pyx_v_props = NULL;
  char *__pyx_v_key;
  PyObject *__pyx_v_fieldtypename = NULL;
  PyObject *__pyx_v_fieldtype = NULL;
  void *__pyx_v_cogr_geometry;
  PyObject *__pyx_v_geom = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("build");

  /* "fiona/ogrext.pyx":356
 *     cdef build(self, void *feature):
 *         # The only method anyone ever needs to call
 *         assert feature is not NULL             # <<<<<<<<<<<<<<
 *         cdef void *fdefn
 *         cdef int i
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_feature != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":359
 *         cdef void *fdefn
 *         cdef int i
 *         props = {}             # <<<<<<<<<<<<<<
 *         for i in range(ograpi.OGR_F_GetFieldCount(feature)):
 *             fdefn = ograpi.OGR_F_GetFieldDefnRef(feature, i)
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_props = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":360
 *         cdef int i
 *         props = {}
 *         for i in range(ograpi.OGR_F_GetFieldCount(feature)):             # <<<<<<<<<<<<<<
 *             fdefn = ograpi.OGR_F_GetFieldDefnRef(feature, i)
 *             assert fdefn is not NULL
 */
  __pyx_t_2 = OGR_F_GetFieldCount(__pyx_v_feature);
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "fiona/ogrext.pyx":361
 *         props = {}
 *         for i in range(ograpi.OGR_F_GetFieldCount(feature)):
 *             fdefn = ograpi.OGR_F_GetFieldDefnRef(feature, i)             # <<<<<<<<<<<<<<
 *             assert fdefn is not NULL
 *             key = ograpi.OGR_Fld_GetNameRef(fdefn)
 */
    __pyx_v_fdefn = OGR_F_GetFieldDefnRef(__pyx_v_feature, __pyx_v_i);

    /* "fiona/ogrext.pyx":362
 *         for i in range(ograpi.OGR_F_GetFieldCount(feature)):
 *             fdefn = ograpi.OGR_F_GetFieldDefnRef(feature, i)
 *             assert fdefn is not NULL             # <<<<<<<<<<<<<<
 *             key = ograpi.OGR_Fld_GetNameRef(fdefn)
 *             assert key is not NULL
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!(__pyx_v_fdefn != NULL))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "fiona/ogrext.pyx":363
 *             fdefn = ograpi.OGR_F_GetFieldDefnRef(feature, i)
 *             assert fdefn is not NULL
 *             key = ograpi.OGR_Fld_GetNameRef(fdefn)             # <<<<<<<<<<<<<<
 *             assert key is not NULL
 *             fieldtypename = FIELD_TYPES[ograpi.OGR_Fld_GetType(fdefn)]
 */
    __pyx_v_key = OGR_Fld_GetNameRef(__pyx_v_fdefn);

    /* "fiona/ogrext.pyx":364
 *             assert fdefn is not NULL
 *             key = ograpi.OGR_Fld_GetNameRef(fdefn)
 *             assert key is not NULL             # <<<<<<<<<<<<<<
 *             fieldtypename = FIELD_TYPES[ograpi.OGR_Fld_GetType(fdefn)]
 *             if not fieldtypename:
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!(__pyx_v_key != NULL))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "fiona/ogrext.pyx":365
 *             key = ograpi.OGR_Fld_GetNameRef(fdefn)
 *             assert key is not NULL
 *             fieldtypename = FIELD_TYPES[ograpi.OGR_Fld_GetType(fdefn)]             # <<<<<<<<<<<<<<
 *             if not fieldtypename:
 *                 raise ValueError(
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__FIELD_TYPES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = OGR_Fld_GetType(__pyx_v_fdefn);
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_1, __pyx_t_4, sizeof(int), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_fieldtypename);
    __pyx_v_fieldtypename = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "fiona/ogrext.pyx":366
 *             assert key is not NULL
 *             fieldtypename = FIELD_TYPES[ograpi.OGR_Fld_GetType(fdefn)]
 *             if not fieldtypename:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     "Invalid field type %s" % ograpi.OGR_Fld_GetType(fdefn))
 */
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_fieldtypename); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = (!__pyx_t_6);
    if (__pyx_t_7) {

      /* "fiona/ogrext.pyx":368
 *             if not fieldtypename:
 *                 raise ValueError(
 *                     "Invalid field type %s" % ograpi.OGR_Fld_GetType(fdefn))             # <<<<<<<<<<<<<<
 *             # TODO: other types
 *             fieldtype = FIELD_TYPES_MAP[fieldtypename]
 */
      __pyx_t_5 = PyInt_FromLong(OGR_Fld_GetType(__pyx_v_fdefn)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_28), __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_1));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "fiona/ogrext.pyx":370
 *                     "Invalid field type %s" % ograpi.OGR_Fld_GetType(fdefn))
 *             # TODO: other types
 *             fieldtype = FIELD_TYPES_MAP[fieldtypename]             # <<<<<<<<<<<<<<
 *             if fieldtype is IntType:
 *                 props[key] = ograpi.OGR_F_GetFieldAsInteger(feature, i)
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__FIELD_TYPES_MAP); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_GetItem(__pyx_t_1, __pyx_v_fieldtypename); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_fieldtype);
    __pyx_v_fieldtype = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "fiona/ogrext.pyx":371
 *             # TODO: other types
 *             fieldtype = FIELD_TYPES_MAP[fieldtypename]
 *             if fieldtype is IntType:             # <<<<<<<<<<<<<<
 *                 props[key] = ograpi.OGR_F_GetFieldAsInteger(feature, i)
 *             elif fieldtype is FloatType:
 */
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__IntType); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = (__pyx_v_fieldtype == __pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_7) {

      /* "fiona/ogrext.pyx":372
 *             fieldtype = FIELD_TYPES_MAP[fieldtypename]
 *             if fieldtype is IntType:
 *                 props[key] = ograpi.OGR_F_GetFieldAsInteger(feature, i)             # <<<<<<<<<<<<<<
 *             elif fieldtype is FloatType:
 *                 props[key] = ograpi.OGR_F_GetFieldAsDouble(feature, i)
 */
      __pyx_t_5 = PyInt_FromLong(OGR_F_GetFieldAsInteger(__pyx_v_feature, __pyx_v_i)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      if (PyDict_SetItem(((PyObject *)__pyx_v_props), ((PyObject *)__pyx_t_1), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L6;
    }

    /* "fiona/ogrext.pyx":373
 *             if fieldtype is IntType:
 *                 props[key] = ograpi.OGR_F_GetFieldAsInteger(feature, i)
 *             elif fieldtype is FloatType:             # <<<<<<<<<<<<<<
 *                 props[key] = ograpi.OGR_F_GetFieldAsDouble(feature, i)
 *             elif fieldtype is UnicodeType:
 */
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__FloatType); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = (__pyx_v_fieldtype == __pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_7) {

      /* "fiona/ogrext.pyx":374
 *                 props[key] = ograpi.OGR_F_GetFieldAsInteger(feature, i)
 *             elif fieldtype is FloatType:
 *                 props[key] = ograpi.OGR_F_GetFieldAsDouble(feature, i)             # <<<<<<<<<<<<<<
 *             elif fieldtype is UnicodeType:
 *                 props[key] = unicode(
 */
      __pyx_t_5 = PyFloat_FromDouble(OGR_F_GetFieldAsDouble(__pyx_v_feature, __pyx_v_i)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      if (PyDict_SetItem(((PyObject *)__pyx_v_props), ((PyObject *)__pyx_t_1), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L6;
    }

    /* "fiona/ogrext.pyx":375
 *             elif fieldtype is FloatType:
 *                 props[key] = ograpi.OGR_F_GetFieldAsDouble(feature, i)
 *             elif fieldtype is UnicodeType:             # <<<<<<<<<<<<<<
 *                 props[key] = unicode(
 *                     ograpi.OGR_F_GetFieldAsString(feature, i), 'utf-8' )
 */
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__UnicodeType); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = (__pyx_v_fieldtype == __pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_7) {

      /* "fiona/ogrext.pyx":377
 *             elif fieldtype is UnicodeType:
 *                 props[key] = unicode(
 *                     ograpi.OGR_F_GetFieldAsString(feature, i), 'utf-8' )             # <<<<<<<<<<<<<<
 *             else:
 *                 props[key] = None
 */
      __pyx_t_5 = PyBytes_FromString(OGR_F_GetFieldAsString(__pyx_v_feature, __pyx_v_i)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_5));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_29));
      PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_kp_s_29));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_29));
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

      /* "fiona/ogrext.pyx":376
 *                 props[key] = ograpi.OGR_F_GetFieldAsDouble(feature, i)
 *             elif fieldtype is UnicodeType:
 *                 props[key] = unicode(             # <<<<<<<<<<<<<<
 *                     ograpi.OGR_F_GetFieldAsString(feature, i), 'utf-8' )
 *             else:
 */
      __pyx_t_1 = PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      if (PyDict_SetItem(((PyObject *)__pyx_v_props), ((PyObject *)__pyx_t_1), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "fiona/ogrext.pyx":379
 *                     ograpi.OGR_F_GetFieldAsString(feature, i), 'utf-8' )
 *             else:
 *                 props[key] = None             # <<<<<<<<<<<<<<
 * 
 *         cdef void *cogr_geometry = ograpi.OGR_F_GetGeometryRef(feature)
 */
      __pyx_t_5 = PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      if (PyDict_SetItem(((PyObject *)__pyx_v_props), ((PyObject *)__pyx_t_5), Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    }
    __pyx_L6:;
  }

  /* "fiona/ogrext.pyx":381
 *                 props[key] = None
 * 
 *         cdef void *cogr_geometry = ograpi.OGR_F_GetGeometryRef(feature)             # <<<<<<<<<<<<<<
 *         assert cogr_geometry is not NULL
 *         geom = GeomBuilder().build(cogr_geometry)
 */
  __pyx_v_cogr_geometry = OGR_F_GetGeometryRef(__pyx_v_feature);

  /* "fiona/ogrext.pyx":382
 * 
 *         cdef void *cogr_geometry = ograpi.OGR_F_GetGeometryRef(feature)
 *         assert cogr_geometry is not NULL             # <<<<<<<<<<<<<<
 *         geom = GeomBuilder().build(cogr_geometry)
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_geometry != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":383
 *         cdef void *cogr_geometry = ograpi.OGR_F_GetGeometryRef(feature)
 *         assert cogr_geometry is not NULL
 *         geom = GeomBuilder().build(cogr_geometry)             # <<<<<<<<<<<<<<
 * 
 *         return {
 */
  __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_GeomBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_t_5)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)__pyx_t_5), __pyx_v_cogr_geometry); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_geom = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":385
 *         geom = GeomBuilder().build(cogr_geometry)
 * 
 *         return {             # <<<<<<<<<<<<<<
 *             'id': str(ograpi.OGR_F_GetFID(feature)),
 *             'geometry': geom,
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));

  /* "fiona/ogrext.pyx":386
 * 
 *         return {
 *             'id': str(ograpi.OGR_F_GetFID(feature)),             # <<<<<<<<<<<<<<
 *             'geometry': geom,
 *             'properties': props }
 */
  __pyx_t_5 = PyInt_FromLong(OGR_F_GetFID(__pyx_v_feature)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_8));
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__id), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "fiona/ogrext.pyx":387
 *         return {
 *             'id': str(ograpi.OGR_F_GetFID(feature)),
 *             'geometry': geom,             # <<<<<<<<<<<<<<
 *             'properties': props }
 * 
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__geometry), __pyx_v_geom) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "fiona/ogrext.pyx":388
 *             'id': str(ograpi.OGR_F_GetFID(feature)),
 *             'geometry': geom,
 *             'properties': props }             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__properties), ((PyObject *)__pyx_v_props)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("fiona.ogrext.FeatureBuilder.build", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_props);
  __Pyx_XDECREF(__pyx_v_fieldtypename);
  __Pyx_XDECREF(__pyx_v_fieldtype);
  __Pyx_XDECREF(__pyx_v_geom);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":399
 *     """
 * 
 *     cdef void * build(self, feature, collection) except NULL:             # <<<<<<<<<<<<<<
 *         cdef WritingSession session
 *         session = collection.session
 */

static void *__pyx_f_5fiona_6ogrext_17OGRFeatureBuilder_build(struct __pyx_obj_5fiona_6ogrext_OGRFeatureBuilder *__pyx_v_self, PyObject *__pyx_v_feature, PyObject *__pyx_v_collection) {
  struct __pyx_obj_5fiona_6ogrext_WritingSession *__pyx_v_session = 0;
  void *__pyx_v_cogr_layer;
  void *__pyx_v_cogr_featuredefn;
  void *__pyx_v_cogr_feature;
  void *__pyx_v_cogr_geometry;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_value = NULL;
  int __pyx_v_i;
  PyObject *__pyx_v_ptype = NULL;
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  void *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  char *__pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  double __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  int __pyx_t_16;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("build");

  /* "fiona/ogrext.pyx":401
 *     cdef void * build(self, feature, collection) except NULL:
 *         cdef WritingSession session
 *         session = collection.session             # <<<<<<<<<<<<<<
 *         cdef void *cogr_layer = session.cogr_layer
 *         assert cogr_layer is not NULL
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__session); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5fiona_6ogrext_WritingSession))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_session = ((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":402
 *         cdef WritingSession session
 *         session = collection.session
 *         cdef void *cogr_layer = session.cogr_layer             # <<<<<<<<<<<<<<
 *         assert cogr_layer is not NULL
 *         cdef void *cogr_featuredefn = ograpi.OGR_L_GetLayerDefn(cogr_layer)
 */
  __pyx_v_cogr_layer = __pyx_v_session->__pyx_base.cogr_layer;

  /* "fiona/ogrext.pyx":403
 *         session = collection.session
 *         cdef void *cogr_layer = session.cogr_layer
 *         assert cogr_layer is not NULL             # <<<<<<<<<<<<<<
 *         cdef void *cogr_featuredefn = ograpi.OGR_L_GetLayerDefn(cogr_layer)
 *         assert cogr_featuredefn is not NULL
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_layer != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":404
 *         cdef void *cogr_layer = session.cogr_layer
 *         assert cogr_layer is not NULL
 *         cdef void *cogr_featuredefn = ograpi.OGR_L_GetLayerDefn(cogr_layer)             # <<<<<<<<<<<<<<
 *         assert cogr_featuredefn is not NULL
 *         cdef void *cogr_feature = ograpi.OGR_F_Create(cogr_featuredefn)
 */
  __pyx_v_cogr_featuredefn = OGR_L_GetLayerDefn(__pyx_v_cogr_layer);

  /* "fiona/ogrext.pyx":405
 *         assert cogr_layer is not NULL
 *         cdef void *cogr_featuredefn = ograpi.OGR_L_GetLayerDefn(cogr_layer)
 *         assert cogr_featuredefn is not NULL             # <<<<<<<<<<<<<<
 *         cdef void *cogr_feature = ograpi.OGR_F_Create(cogr_featuredefn)
 *         assert cogr_feature is not NULL
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_featuredefn != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":406
 *         cdef void *cogr_featuredefn = ograpi.OGR_L_GetLayerDefn(cogr_layer)
 *         assert cogr_featuredefn is not NULL
 *         cdef void *cogr_feature = ograpi.OGR_F_Create(cogr_featuredefn)             # <<<<<<<<<<<<<<
 *         assert cogr_feature is not NULL
 * 
 */
  __pyx_v_cogr_feature = OGR_F_Create(__pyx_v_cogr_featuredefn);

  /* "fiona/ogrext.pyx":407
 *         assert cogr_featuredefn is not NULL
 *         cdef void *cogr_feature = ograpi.OGR_F_Create(cogr_featuredefn)
 *         assert cogr_feature is not NULL             # <<<<<<<<<<<<<<
 * 
 *         cdef void *cogr_geometry = OGRGeomBuilder().build(feature['geometry'])
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_feature != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":409
 *         assert cogr_feature is not NULL
 * 
 *         cdef void *cogr_geometry = OGRGeomBuilder().build(feature['geometry'])             # <<<<<<<<<<<<<<
 *         ograpi.OGR_F_SetGeometryDirectly(cogr_feature, cogr_geometry)
 * 
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_OGRGeomBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetItem(__pyx_v_feature, ((PyObject *)__pyx_n_s__geometry)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder *)((struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)__pyx_t_1)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)__pyx_t_1), __pyx_t_2); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_cogr_geometry = __pyx_t_3;

  /* "fiona/ogrext.pyx":410
 * 
 *         cdef void *cogr_geometry = OGRGeomBuilder().build(feature['geometry'])
 *         ograpi.OGR_F_SetGeometryDirectly(cogr_feature, cogr_geometry)             # <<<<<<<<<<<<<<
 * 
 *         for key, value in feature['properties'].items():
 */
  OGR_F_SetGeometryDirectly(__pyx_v_cogr_feature, __pyx_v_cogr_geometry);

  /* "fiona/ogrext.pyx":412
 *         ograpi.OGR_F_SetGeometryDirectly(cogr_feature, cogr_geometry)
 * 
 *         for key, value in feature['properties'].items():             # <<<<<<<<<<<<<<
 *             i = ograpi.OGR_F_GetFieldIndex(cogr_feature, key)
 *             ptype = type(value) #FIELD_TYPES_MAP[key]
 */
  __pyx_t_2 = PyObject_GetItem(__pyx_v_feature, ((PyObject *)__pyx_n_s__properties)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
    } else if (PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++;
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      if (likely(PyTuple_CheckExact(sequence))) {
        if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
          if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
          else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
          if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
          else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
      if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_key);
    __pyx_v_key = __pyx_t_6;
    __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_v_value);
    __pyx_v_value = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "fiona/ogrext.pyx":413
 * 
 *         for key, value in feature['properties'].items():
 *             i = ograpi.OGR_F_GetFieldIndex(cogr_feature, key)             # <<<<<<<<<<<<<<
 *             ptype = type(value) #FIELD_TYPES_MAP[key]
 *             if ptype is IntType:
 */
    __pyx_t_10 = PyBytes_AsString(__pyx_v_key); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_i = OGR_F_GetFieldIndex(__pyx_v_cogr_feature, __pyx_t_10);

    /* "fiona/ogrext.pyx":414
 *         for key, value in feature['properties'].items():
 *             i = ograpi.OGR_F_GetFieldIndex(cogr_feature, key)
 *             ptype = type(value) #FIELD_TYPES_MAP[key]             # <<<<<<<<<<<<<<
 *             if ptype is IntType:
 *                 ograpi.OGR_F_SetFieldInteger(cogr_feature, i, value)
 */
    __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_value)));
    __Pyx_XDECREF(((PyObject *)__pyx_v_ptype));
    __pyx_v_ptype = ((PyObject*)((PyObject *)Py_TYPE(__pyx_v_value)));

    /* "fiona/ogrext.pyx":415
 *             i = ograpi.OGR_F_GetFieldIndex(cogr_feature, key)
 *             ptype = type(value) #FIELD_TYPES_MAP[key]
 *             if ptype is IntType:             # <<<<<<<<<<<<<<
 *                 ograpi.OGR_F_SetFieldInteger(cogr_feature, i, value)
 *             elif ptype is FloatType:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__IntType); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_11 = (__pyx_v_ptype == ((PyObject*)__pyx_t_2));
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_11) {

      /* "fiona/ogrext.pyx":416
 *             ptype = type(value) #FIELD_TYPES_MAP[key]
 *             if ptype is IntType:
 *                 ograpi.OGR_F_SetFieldInteger(cogr_feature, i, value)             # <<<<<<<<<<<<<<
 *             elif ptype is FloatType:
 *                 ograpi.OGR_F_SetFieldDouble(cogr_feature, i, value)
 */
      __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_v_value); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      OGR_F_SetFieldInteger(__pyx_v_cogr_feature, __pyx_v_i, __pyx_t_12);
      goto __pyx_L7;
    }

    /* "fiona/ogrext.pyx":417
 *             if ptype is IntType:
 *                 ograpi.OGR_F_SetFieldInteger(cogr_feature, i, value)
 *             elif ptype is FloatType:             # <<<<<<<<<<<<<<
 *                 ograpi.OGR_F_SetFieldDouble(cogr_feature, i, value)
 *             elif ptype in (UnicodeType, StringType):
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__FloatType); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_11 = (__pyx_v_ptype == ((PyObject*)__pyx_t_2));
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_11) {

      /* "fiona/ogrext.pyx":418
 *                 ograpi.OGR_F_SetFieldInteger(cogr_feature, i, value)
 *             elif ptype is FloatType:
 *                 ograpi.OGR_F_SetFieldDouble(cogr_feature, i, value)             # <<<<<<<<<<<<<<
 *             elif ptype in (UnicodeType, StringType):
 *                 ograpi.OGR_F_SetFieldString(cogr_feature, i, value)
 */
      __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      OGR_F_SetFieldDouble(__pyx_v_cogr_feature, __pyx_v_i, __pyx_t_13);
      goto __pyx_L7;
    }

    /* "fiona/ogrext.pyx":419
 *             elif ptype is FloatType:
 *                 ograpi.OGR_F_SetFieldDouble(cogr_feature, i, value)
 *             elif ptype in (UnicodeType, StringType):             # <<<<<<<<<<<<<<
 *                 ograpi.OGR_F_SetFieldString(cogr_feature, i, value)
 *             else:
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_ptype));
    __pyx_t_14 = __pyx_v_ptype;
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__UnicodeType); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyObject_RichCompare(((PyObject *)__pyx_t_14), __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (!((int)__pyx_t_11)) {
      __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__StringType); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_t_14), __pyx_t_7, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_15 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_16 = ((int)__pyx_t_15);
    } else {
      __pyx_t_16 = ((int)__pyx_t_11);
    }
    __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
    __pyx_t_11 = __pyx_t_16;
    if (__pyx_t_11) {

      /* "fiona/ogrext.pyx":420
 *                 ograpi.OGR_F_SetFieldDouble(cogr_feature, i, value)
 *             elif ptype in (UnicodeType, StringType):
 *                 ograpi.OGR_F_SetFieldString(cogr_feature, i, value)             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("Invalid field type %s" % ptype)
 */
      __pyx_t_10 = PyBytes_AsString(__pyx_v_value); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      OGR_F_SetFieldString(__pyx_v_cogr_feature, __pyx_v_i, __pyx_t_10);
      goto __pyx_L7;
    }
    /*else*/ {

      /* "fiona/ogrext.pyx":422
 *                 ograpi.OGR_F_SetFieldString(cogr_feature, i, value)
 *             else:
 *                 raise ValueError("Invalid field type %s" % ptype)             # <<<<<<<<<<<<<<
 *             log.debug("Set field %s: %s" % (key, value))
 *         return cogr_feature
 */
      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_28), ((PyObject *)__pyx_v_ptype)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_7));
      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_2));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L7:;

    /* "fiona/ogrext.pyx":423
 *             else:
 *                 raise ValueError("Invalid field type %s" % ptype)
 *             log.debug("Set field %s: %s" % (key, value))             # <<<<<<<<<<<<<<
 *         return cogr_feature
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__debug); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
    __Pyx_GIVEREF(__pyx_v_key);
    __Pyx_INCREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_30), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_6));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
    __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":424
 *                 raise ValueError("Invalid field type %s" % ptype)
 *             log.debug("Set field %s: %s" % (key, value))
 *         return cogr_feature             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_cogr_feature;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(((PyObject *)__pyx_t_14));
  __Pyx_AddTraceback("fiona.ogrext.OGRFeatureBuilder.build", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_session);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_ptype);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":427
 * 
 * 
 * cdef _deleteOgrFeature(void *cogr_feature):             # <<<<<<<<<<<<<<
 *     """Delete an OGR feature"""
 *     if cogr_feature is not NULL:
 */

static PyObject *__pyx_f_5fiona_6ogrext__deleteOgrFeature(void *__pyx_v_cogr_feature) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_deleteOgrFeature");

  /* "fiona/ogrext.pyx":429
 * cdef _deleteOgrFeature(void *cogr_feature):
 *     """Delete an OGR feature"""
 *     if cogr_feature is not NULL:             # <<<<<<<<<<<<<<
 *         ograpi.OGR_F_Destroy(cogr_feature)
 *     cogr_feature = NULL
 */
  __pyx_t_1 = (__pyx_v_cogr_feature != NULL);
  if (__pyx_t_1) {

    /* "fiona/ogrext.pyx":430
 *     """Delete an OGR feature"""
 *     if cogr_feature is not NULL:
 *         ograpi.OGR_F_Destroy(cogr_feature)             # <<<<<<<<<<<<<<
 *     cogr_feature = NULL
 * 
 */
    OGR_F_Destroy(__pyx_v_cogr_feature);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "fiona/ogrext.pyx":431
 *     if cogr_feature is not NULL:
 *         ograpi.OGR_F_Destroy(cogr_feature)
 *     cogr_feature = NULL             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_cogr_feature = NULL;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":434
 * 
 * 
 * def featureRT(feature, collection):             # <<<<<<<<<<<<<<
 *     # For testing purposes only, leaks the JSON data
 *     cdef void *cogr_feature = OGRFeatureBuilder().build(feature, collection)
 */

static PyObject *__pyx_pf_5fiona_6ogrext_1featureRT(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_5fiona_6ogrext_1featureRT = {__Pyx_NAMESTR("featureRT"), (PyCFunction)__pyx_pf_5fiona_6ogrext_1featureRT, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pf_5fiona_6ogrext_1featureRT(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_feature = 0;
  PyObject *__pyx_v_collection = 0;
  void *__pyx_v_cogr_feature;
  void *__pyx_v_cogr_geometry;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  void *__pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__feature,&__pyx_n_s__collection,0};
  __Pyx_RefNannySetupContext("featureRT");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__feature);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__collection);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("featureRT", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "featureRT") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_feature = values[0];
    __pyx_v_collection = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_feature = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_collection = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("featureRT", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("fiona.ogrext.featureRT", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "fiona/ogrext.pyx":436
 * def featureRT(feature, collection):
 *     # For testing purposes only, leaks the JSON data
 *     cdef void *cogr_feature = OGRFeatureBuilder().build(feature, collection)             # <<<<<<<<<<<<<<
 *     cdef void *cogr_geometry = ograpi.OGR_F_GetGeometryRef(cogr_feature)
 *     assert cogr_geometry is not NULL
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_OGRFeatureBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRFeatureBuilder *)((struct __pyx_obj_5fiona_6ogrext_OGRFeatureBuilder *)__pyx_t_1)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_OGRFeatureBuilder *)__pyx_t_1), __pyx_v_feature, __pyx_v_collection); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_cogr_feature = __pyx_t_2;

  /* "fiona/ogrext.pyx":437
 *     # For testing purposes only, leaks the JSON data
 *     cdef void *cogr_feature = OGRFeatureBuilder().build(feature, collection)
 *     cdef void *cogr_geometry = ograpi.OGR_F_GetGeometryRef(cogr_feature)             # <<<<<<<<<<<<<<
 *     assert cogr_geometry is not NULL
 *     log.debug("Geometry: %s" % ograpi.OGR_G_ExportToJson(cogr_geometry))
 */
  __pyx_v_cogr_geometry = OGR_F_GetGeometryRef(__pyx_v_cogr_feature);

  /* "fiona/ogrext.pyx":438
 *     cdef void *cogr_feature = OGRFeatureBuilder().build(feature, collection)
 *     cdef void *cogr_geometry = ograpi.OGR_F_GetGeometryRef(cogr_feature)
 *     assert cogr_geometry is not NULL             # <<<<<<<<<<<<<<
 *     log.debug("Geometry: %s" % ograpi.OGR_G_ExportToJson(cogr_geometry))
 *     result = FeatureBuilder().build(cogr_feature)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_geometry != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":439
 *     cdef void *cogr_geometry = ograpi.OGR_F_GetGeometryRef(cogr_feature)
 *     assert cogr_geometry is not NULL
 *     log.debug("Geometry: %s" % ograpi.OGR_G_ExportToJson(cogr_geometry))             # <<<<<<<<<<<<<<
 *     result = FeatureBuilder().build(cogr_feature)
 *     _deleteOgrFeature(cogr_feature)
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyBytes_FromUString(OGR_G_ExportToJson(__pyx_v_cogr_geometry)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_27), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "fiona/ogrext.pyx":440
 *     assert cogr_geometry is not NULL
 *     log.debug("Geometry: %s" % ograpi.OGR_G_ExportToJson(cogr_geometry))
 *     result = FeatureBuilder().build(cogr_feature)             # <<<<<<<<<<<<<<
 *     _deleteOgrFeature(cogr_feature)
 *     return result
 */
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_FeatureBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = ((struct __pyx_vtabstruct_5fiona_6ogrext_FeatureBuilder *)((struct __pyx_obj_5fiona_6ogrext_FeatureBuilder *)__pyx_t_4)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_FeatureBuilder *)__pyx_t_4), __pyx_v_cogr_feature); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":441
 *     log.debug("Geometry: %s" % ograpi.OGR_G_ExportToJson(cogr_geometry))
 *     result = FeatureBuilder().build(cogr_feature)
 *     _deleteOgrFeature(cogr_feature)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
  __pyx_t_1 = __pyx_f_5fiona_6ogrext__deleteOgrFeature(__pyx_v_cogr_feature); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":442
 *     result = FeatureBuilder().build(cogr_feature)
 *     _deleteOgrFeature(cogr_feature)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("fiona.ogrext.featureRT", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":452
 *     cdef void *cogr_layer
 * 
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.cogr_ds = NULL
 *         self.cogr_layer = NULL
 */

static int __pyx_pf_5fiona_6ogrext_7Session___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_5fiona_6ogrext_7Session___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;

  /* "fiona/ogrext.pyx":453
 * 
 *     def __cinit__(self):
 *         self.cogr_ds = NULL             # <<<<<<<<<<<<<<
 *         self.cogr_layer = NULL
 * 
 */
  ((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_ds = NULL;

  /* "fiona/ogrext.pyx":454
 *     def __cinit__(self):
 *         self.cogr_ds = NULL
 *         self.cogr_layer = NULL             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  ((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_layer = NULL;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":456
 *         self.cogr_layer = NULL
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         self.stop()
 * 
 */

static void __pyx_pf_5fiona_6ogrext_7Session_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_5fiona_6ogrext_7Session_1__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__dealloc__");

  /* "fiona/ogrext.pyx":457
 * 
 *     def __dealloc__(self):
 *         self.stop()             # <<<<<<<<<<<<<<
 * 
 *     def start(self, collection):
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("fiona.ogrext.Session.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "fiona/ogrext.pyx":459
 *         self.stop()
 * 
 *     def start(self, collection):             # <<<<<<<<<<<<<<
 *         self.cogr_ds = ograpi.OGROpen(collection.path, 0, NULL)
 *         assert self.cogr_ds is not NULL
 */

static PyObject *__pyx_pf_5fiona_6ogrext_7Session_2start(PyObject *__pyx_v_self, PyObject *__pyx_v_collection); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_7Session_2start(PyObject *__pyx_v_self, PyObject *__pyx_v_collection) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  char *__pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("start");

  /* "fiona/ogrext.pyx":460
 * 
 *     def start(self, collection):
 *         self.cogr_ds = ograpi.OGROpen(collection.path, 0, NULL)             # <<<<<<<<<<<<<<
 *         assert self.cogr_ds is not NULL
 *         self.cogr_layer = ograpi.OGR_DS_GetLayerByName(
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyBytes_AsString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  ((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_ds = OGROpen(__pyx_t_2, 0, NULL);

  /* "fiona/ogrext.pyx":461
 *     def start(self, collection):
 *         self.cogr_ds = ograpi.OGROpen(collection.path, 0, NULL)
 *         assert self.cogr_ds is not NULL             # <<<<<<<<<<<<<<
 *         self.cogr_layer = ograpi.OGR_DS_GetLayerByName(
 *             self.cogr_ds, collection.name)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_ds != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":463
 *         assert self.cogr_ds is not NULL
 *         self.cogr_layer = ograpi.OGR_DS_GetLayerByName(
 *             self.cogr_ds, collection.name)             # <<<<<<<<<<<<<<
 *         assert self.cogr_layer is not NULL
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__name); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyBytes_AsString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":462
 *         self.cogr_ds = ograpi.OGROpen(collection.path, 0, NULL)
 *         assert self.cogr_ds is not NULL
 *         self.cogr_layer = ograpi.OGR_DS_GetLayerByName(             # <<<<<<<<<<<<<<
 *             self.cogr_ds, collection.name)
 *         assert self.cogr_layer is not NULL
 */
  ((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_layer = OGR_DS_GetLayerByName(((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_ds, __pyx_t_2);

  /* "fiona/ogrext.pyx":464
 *         self.cogr_layer = ograpi.OGR_DS_GetLayerByName(
 *             self.cogr_ds, collection.name)
 *         assert self.cogr_layer is not NULL             # <<<<<<<<<<<<<<
 * 
 *     def stop(self):
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_layer != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("fiona.ogrext.Session.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":466
 *         assert self.cogr_layer is not NULL
 * 
 *     def stop(self):             # <<<<<<<<<<<<<<
 *         self.cogr_layer = NULL
 *         if self.cogr_ds is not NULL:
 */

static PyObject *__pyx_pf_5fiona_6ogrext_7Session_3stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_7Session_3stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("stop");

  /* "fiona/ogrext.pyx":467
 * 
 *     def stop(self):
 *         self.cogr_layer = NULL             # <<<<<<<<<<<<<<
 *         if self.cogr_ds is not NULL:
 *             ograpi.OGR_DS_Destroy(self.cogr_ds)
 */
  ((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_layer = NULL;

  /* "fiona/ogrext.pyx":468
 *     def stop(self):
 *         self.cogr_layer = NULL
 *         if self.cogr_ds is not NULL:             # <<<<<<<<<<<<<<
 *             ograpi.OGR_DS_Destroy(self.cogr_ds)
 *         self.cogr_ds = NULL
 */
  __pyx_t_1 = (((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_ds != NULL);
  if (__pyx_t_1) {

    /* "fiona/ogrext.pyx":469
 *         self.cogr_layer = NULL
 *         if self.cogr_ds is not NULL:
 *             ograpi.OGR_DS_Destroy(self.cogr_ds)             # <<<<<<<<<<<<<<
 *         self.cogr_ds = NULL
 * 
 */
    OGR_DS_Destroy(((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_ds);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "fiona/ogrext.pyx":470
 *         if self.cogr_ds is not NULL:
 *             ograpi.OGR_DS_Destroy(self.cogr_ds)
 *         self.cogr_ds = NULL             # <<<<<<<<<<<<<<
 * 
 *     def get_length(self):
 */
  ((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_ds = NULL;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":472
 *         self.cogr_ds = NULL
 * 
 *     def get_length(self):             # <<<<<<<<<<<<<<
 *         assert self.cogr_layer is not NULL
 *         return ograpi.OGR_L_GetFeatureCount(self.cogr_layer, 0)
 */

static PyObject *__pyx_pf_5fiona_6ogrext_7Session_4get_length(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_7Session_4get_length(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_length");

  /* "fiona/ogrext.pyx":473
 * 
 *     def get_length(self):
 *         assert self.cogr_layer is not NULL             # <<<<<<<<<<<<<<
 *         return ograpi.OGR_L_GetFeatureCount(self.cogr_layer, 0)
 * 
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_layer != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":474
 *     def get_length(self):
 *         assert self.cogr_layer is not NULL
 *         return ograpi.OGR_L_GetFeatureCount(self.cogr_layer, 0)             # <<<<<<<<<<<<<<
 * 
 *     def get_schema(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(OGR_L_GetFeatureCount(((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_layer, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("fiona.ogrext.Session.get_length", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":476
 *         return ograpi.OGR_L_GetFeatureCount(self.cogr_layer, 0)
 * 
 *     def get_schema(self):             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef int n
 */

static PyObject *__pyx_pf_5fiona_6ogrext_7Session_5get_schema(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_7Session_5get_schema(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  int __pyx_v_i;
  int __pyx_v_n;
  void *__pyx_v_cogr_featuredefn;
  void *__pyx_v_cogr_fielddefn;
  PyObject *__pyx_v_props = NULL;
  PyObject *__pyx_v_fieldtypename = NULL;
  char *__pyx_v_key;
  int __pyx_v_geom_type;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_schema");

  /* "fiona/ogrext.pyx":481
 *         cdef void *cogr_featuredefn
 *         cdef void *cogr_fielddefn
 *         props = []             # <<<<<<<<<<<<<<
 *         assert self.cogr_layer is not NULL
 *         cogr_featuredefn = ograpi.OGR_L_GetLayerDefn(self.cogr_layer)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_props = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":482
 *         cdef void *cogr_fielddefn
 *         props = []
 *         assert self.cogr_layer is not NULL             # <<<<<<<<<<<<<<
 *         cogr_featuredefn = ograpi.OGR_L_GetLayerDefn(self.cogr_layer)
 *         assert cogr_featuredefn is not NULL
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_layer != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":483
 *         props = []
 *         assert self.cogr_layer is not NULL
 *         cogr_featuredefn = ograpi.OGR_L_GetLayerDefn(self.cogr_layer)             # <<<<<<<<<<<<<<
 *         assert cogr_featuredefn is not NULL
 *         n = ograpi.OGR_FD_GetFieldCount(cogr_featuredefn)
 */
  __pyx_v_cogr_featuredefn = OGR_L_GetLayerDefn(((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_layer);

  /* "fiona/ogrext.pyx":484
 *         assert self.cogr_layer is not NULL
 *         cogr_featuredefn = ograpi.OGR_L_GetLayerDefn(self.cogr_layer)
 *         assert cogr_featuredefn is not NULL             # <<<<<<<<<<<<<<
 *         n = ograpi.OGR_FD_GetFieldCount(cogr_featuredefn)
 *         for i from 0 <= i < n:
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_featuredefn != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":485
 *         cogr_featuredefn = ograpi.OGR_L_GetLayerDefn(self.cogr_layer)
 *         assert cogr_featuredefn is not NULL
 *         n = ograpi.OGR_FD_GetFieldCount(cogr_featuredefn)             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < n:
 *             cogr_fielddefn = ograpi.OGR_FD_GetFieldDefn(cogr_featuredefn, i)
 */
  __pyx_v_n = OGR_FD_GetFieldCount(__pyx_v_cogr_featuredefn);

  /* "fiona/ogrext.pyx":486
 *         assert cogr_featuredefn is not NULL
 *         n = ograpi.OGR_FD_GetFieldCount(cogr_featuredefn)
 *         for i from 0 <= i < n:             # <<<<<<<<<<<<<<
 *             cogr_fielddefn = ograpi.OGR_FD_GetFieldDefn(cogr_featuredefn, i)
 *             assert cogr_fielddefn is not NULL
 */
  __pyx_t_2 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "fiona/ogrext.pyx":487
 *         n = ograpi.OGR_FD_GetFieldCount(cogr_featuredefn)
 *         for i from 0 <= i < n:
 *             cogr_fielddefn = ograpi.OGR_FD_GetFieldDefn(cogr_featuredefn, i)             # <<<<<<<<<<<<<<
 *             assert cogr_fielddefn is not NULL
 *             fieldtypename = FIELD_TYPES[ograpi.OGR_Fld_GetType(cogr_fielddefn)]
 */
    __pyx_v_cogr_fielddefn = OGR_FD_GetFieldDefn(__pyx_v_cogr_featuredefn, __pyx_v_i);

    /* "fiona/ogrext.pyx":488
 *         for i from 0 <= i < n:
 *             cogr_fielddefn = ograpi.OGR_FD_GetFieldDefn(cogr_featuredefn, i)
 *             assert cogr_fielddefn is not NULL             # <<<<<<<<<<<<<<
 *             fieldtypename = FIELD_TYPES[ograpi.OGR_Fld_GetType(cogr_fielddefn)]
 *             if not fieldtypename:
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!(__pyx_v_cogr_fielddefn != NULL))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "fiona/ogrext.pyx":489
 *             cogr_fielddefn = ograpi.OGR_FD_GetFieldDefn(cogr_featuredefn, i)
 *             assert cogr_fielddefn is not NULL
 *             fieldtypename = FIELD_TYPES[ograpi.OGR_Fld_GetType(cogr_fielddefn)]             # <<<<<<<<<<<<<<
 *             if not fieldtypename:
 *                 raise ValueError(
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__FIELD_TYPES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = OGR_Fld_GetType(__pyx_v_cogr_fielddefn);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_t_3, sizeof(int), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_fieldtypename);
    __pyx_v_fieldtypename = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "fiona/ogrext.pyx":490
 *             assert cogr_fielddefn is not NULL
 *             fieldtypename = FIELD_TYPES[ograpi.OGR_Fld_GetType(cogr_fielddefn)]
 *             if not fieldtypename:             # <<<<<<<<<<<<<<
 *                 raise ValueError(
 *                     "Invalid field type %s" % ograpi.OGR_Fld_GetType(
 */
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_fieldtypename); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = (!__pyx_t_5);
    if (__pyx_t_6) {

      /* "fiona/ogrext.pyx":493
 *                 raise ValueError(
 *                     "Invalid field type %s" % ograpi.OGR_Fld_GetType(
 *                                                 cogr_fielddefn))             # <<<<<<<<<<<<<<
 *             key = ograpi.OGR_Fld_GetNameRef(cogr_fielddefn)
 *             assert key is not NULL
 */
      __pyx_t_4 = PyInt_FromLong(OGR_Fld_GetType(__pyx_v_cogr_fielddefn)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_28), __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "fiona/ogrext.pyx":494
 *                     "Invalid field type %s" % ograpi.OGR_Fld_GetType(
 *                                                 cogr_fielddefn))
 *             key = ograpi.OGR_Fld_GetNameRef(cogr_fielddefn)             # <<<<<<<<<<<<<<
 *             assert key is not NULL
 *             props.append((key, fieldtypename))
 */
    __pyx_v_key = OGR_Fld_GetNameRef(__pyx_v_cogr_fielddefn);

    /* "fiona/ogrext.pyx":495
 *                                                 cogr_fielddefn))
 *             key = ograpi.OGR_Fld_GetNameRef(cogr_fielddefn)
 *             assert key is not NULL             # <<<<<<<<<<<<<<
 *             props.append((key, fieldtypename))
 *         geom_type = ograpi.OGR_FD_GetGeomType(cogr_featuredefn)
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!(__pyx_v_key != NULL))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "fiona/ogrext.pyx":496
 *             key = ograpi.OGR_Fld_GetNameRef(cogr_fielddefn)
 *             assert key is not NULL
 *             props.append((key, fieldtypename))             # <<<<<<<<<<<<<<
 *         geom_type = ograpi.OGR_FD_GetGeomType(cogr_featuredefn)
 *         return {'properties': dict(props), 'geometry': GEOMETRY_TYPES[geom_type]}
 */
    if (unlikely(((PyObject *)__pyx_v_props) == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_1 = PyBytes_FromString(__pyx_v_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __Pyx_INCREF(__pyx_v_fieldtypename);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_fieldtypename);
    __Pyx_GIVEREF(__pyx_v_fieldtypename);
    __pyx_t_1 = 0;
    __pyx_t_7 = PyList_Append(__pyx_v_props, ((PyObject *)__pyx_t_4)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  }

  /* "fiona/ogrext.pyx":497
 *             assert key is not NULL
 *             props.append((key, fieldtypename))
 *         geom_type = ograpi.OGR_FD_GetGeomType(cogr_featuredefn)             # <<<<<<<<<<<<<<
 *         return {'properties': dict(props), 'geometry': GEOMETRY_TYPES[geom_type]}
 * 
 */
  __pyx_v_geom_type = OGR_FD_GetGeomType(__pyx_v_cogr_featuredefn);

  /* "fiona/ogrext.pyx":498
 *             props.append((key, fieldtypename))
 *         geom_type = ograpi.OGR_FD_GetGeomType(cogr_featuredefn)
 *         return {'properties': dict(props), 'geometry': GEOMETRY_TYPES[geom_type]}             # <<<<<<<<<<<<<<
 * 
 *     def get_crs(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_v_props));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_props));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_props));
  __pyx_t_8 = PyObject_Call(((PyObject *)((PyObject*)(&PyDict_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__properties), __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__GEOMETRY_TYPES); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_8, __pyx_v_geom_type, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__geometry), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("fiona.ogrext.Session.get_schema", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_props);
  __Pyx_XDECREF(__pyx_v_fieldtypename);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":500
 *         return {'properties': dict(props), 'geometry': GEOMETRY_TYPES[geom_type]}
 * 
 *     def get_crs(self):             # <<<<<<<<<<<<<<
 *         cdef char *proj = NULL
 *         assert self.cogr_layer is not NULL
 */

static PyObject *__pyx_pf_5fiona_6ogrext_7Session_6get_crs(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_7Session_6get_crs(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  char *__pyx_v_proj;
  void *__pyx_v_cogr_crs;
  PyObject *__pyx_v_crs = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_param = NULL;
  PyObject *__pyx_v_kv = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  double __pyx_t_13;
  int __pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_crs");

  /* "fiona/ogrext.pyx":501
 * 
 *     def get_crs(self):
 *         cdef char *proj = NULL             # <<<<<<<<<<<<<<
 *         assert self.cogr_layer is not NULL
 *         cdef void *cogr_crs = ograpi.OGR_L_GetSpatialRef(self.cogr_layer)
 */
  __pyx_v_proj = NULL;

  /* "fiona/ogrext.pyx":502
 *     def get_crs(self):
 *         cdef char *proj = NULL
 *         assert self.cogr_layer is not NULL             # <<<<<<<<<<<<<<
 *         cdef void *cogr_crs = ograpi.OGR_L_GetSpatialRef(self.cogr_layer)
 *         log.debug("Got coordinate system")
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_layer != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":503
 *         cdef char *proj = NULL
 *         assert self.cogr_layer is not NULL
 *         cdef void *cogr_crs = ograpi.OGR_L_GetSpatialRef(self.cogr_layer)             # <<<<<<<<<<<<<<
 *         log.debug("Got coordinate system")
 *         crs = {}
 */
  __pyx_v_cogr_crs = OGR_L_GetSpatialRef(((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_layer);

  /* "fiona/ogrext.pyx":504
 *         assert self.cogr_layer is not NULL
 *         cdef void *cogr_crs = ograpi.OGR_L_GetSpatialRef(self.cogr_layer)
 *         log.debug("Got coordinate system")             # <<<<<<<<<<<<<<
 *         crs = {}
 *         if cogr_crs is not NULL:
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_32), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":505
 *         cdef void *cogr_crs = ograpi.OGR_L_GetSpatialRef(self.cogr_layer)
 *         log.debug("Got coordinate system")
 *         crs = {}             # <<<<<<<<<<<<<<
 *         if cogr_crs is not NULL:
 *             ograpi.OSRExportToProj4(cogr_crs, &proj)
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_crs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":506
 *         log.debug("Got coordinate system")
 *         crs = {}
 *         if cogr_crs is not NULL:             # <<<<<<<<<<<<<<
 *             ograpi.OSRExportToProj4(cogr_crs, &proj)
 *             assert proj is not NULL
 */
  __pyx_t_3 = (__pyx_v_cogr_crs != NULL);
  if (__pyx_t_3) {

    /* "fiona/ogrext.pyx":507
 *         crs = {}
 *         if cogr_crs is not NULL:
 *             ograpi.OSRExportToProj4(cogr_crs, &proj)             # <<<<<<<<<<<<<<
 *             assert proj is not NULL
 *             log.debug("Params: %s", proj)
 */
    OSRExportToProj4(__pyx_v_cogr_crs, (&__pyx_v_proj));

    /* "fiona/ogrext.pyx":508
 *         if cogr_crs is not NULL:
 *             ograpi.OSRExportToProj4(cogr_crs, &proj)
 *             assert proj is not NULL             # <<<<<<<<<<<<<<
 *             log.debug("Params: %s", proj)
 *             value = proj
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!(__pyx_v_proj != NULL))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "fiona/ogrext.pyx":509
 *             ograpi.OSRExportToProj4(cogr_crs, &proj)
 *             assert proj is not NULL
 *             log.debug("Params: %s", proj)             # <<<<<<<<<<<<<<
 *             value = proj
 *             value = value.strip()
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyBytes_FromString(__pyx_v_proj); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_33));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_33));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_33));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "fiona/ogrext.pyx":510
 *             assert proj is not NULL
 *             log.debug("Params: %s", proj)
 *             value = proj             # <<<<<<<<<<<<<<
 *             value = value.strip()
 *             for param in value.split():
 */
    __pyx_t_1 = PyBytes_FromString(__pyx_v_proj); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_v_value = ((PyObject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "fiona/ogrext.pyx":511
 *             log.debug("Params: %s", proj)
 *             value = proj
 *             value = value.strip()             # <<<<<<<<<<<<<<
 *             for param in value.split():
 *                 kv = param.split("=")
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_value, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "fiona/ogrext.pyx":512
 *             value = proj
 *             value = value.strip()
 *             for param in value.split():             # <<<<<<<<<<<<<<
 *                 kv = param.split("=")
 *                 if len(kv) == 2:
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_value, __pyx_n_s__split); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (PyList_CheckExact(__pyx_t_4)) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
      } else if (PyTuple_CheckExact(__pyx_t_4)) {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
      } else {
        __pyx_t_1 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_1)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF(__pyx_v_param);
      __pyx_v_param = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "fiona/ogrext.pyx":513
 *             value = value.strip()
 *             for param in value.split():
 *                 kv = param.split("=")             # <<<<<<<<<<<<<<
 *                 if len(kv) == 2:
 *                     k, v = kv
 */
      __pyx_t_1 = PyObject_GetAttr(__pyx_v_param, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_35), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_v_kv);
      __pyx_v_kv = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "fiona/ogrext.pyx":514
 *             for param in value.split():
 *                 kv = param.split("=")
 *                 if len(kv) == 2:             # <<<<<<<<<<<<<<
 *                     k, v = kv
 *                     try:
 */
      __pyx_t_7 = PyObject_Length(__pyx_v_kv); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = (__pyx_t_7 == 2);
      if (__pyx_t_3) {

        /* "fiona/ogrext.pyx":515
 *                 kv = param.split("=")
 *                 if len(kv) == 2:
 *                     k, v = kv             # <<<<<<<<<<<<<<
 *                     try:
 *                         v = float(v)
 */
        if ((likely(PyTuple_CheckExact(__pyx_v_kv))) || (PyList_CheckExact(__pyx_v_kv))) {
          PyObject* sequence = __pyx_v_kv;
          if (likely(PyTuple_CheckExact(sequence))) {
            if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
              if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
              else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
              if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
              else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_1);
        } else {
          Py_ssize_t index = -1;
          __pyx_t_8 = PyObject_GetIter(__pyx_v_kv); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
          index = 0; __pyx_t_2 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_2);
          index = 1; __pyx_t_1 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_1)) goto __pyx_L9_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_1);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          goto __pyx_L10_unpacking_done;
          __pyx_L9_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
          if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_L10_unpacking_done:;
        }
        __Pyx_XDECREF(__pyx_v_k);
        __pyx_v_k = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_v_v);
        __pyx_v_v = __pyx_t_1;
        __pyx_t_1 = 0;

        /* "fiona/ogrext.pyx":516
 *                 if len(kv) == 2:
 *                     k, v = kv
 *                     try:             # <<<<<<<<<<<<<<
 *                         v = float(v)
 *                         if v % 1 == 0:
 */
        {
          __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          /*try:*/ {

            /* "fiona/ogrext.pyx":517
 *                     k, v = kv
 *                     try:
 *                         v = float(v)             # <<<<<<<<<<<<<<
 *                         if v % 1 == 0:
 *                             v = int(v)
 */
            __pyx_t_13 = __Pyx_PyObject_AsDouble(__pyx_v_v); if (unlikely(__pyx_t_13 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            __pyx_t_1 = PyFloat_FromDouble(__pyx_t_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_v_v);
            __pyx_v_v = __pyx_t_1;
            __pyx_t_1 = 0;

            /* "fiona/ogrext.pyx":518
 *                     try:
 *                         v = float(v)
 *                         if v % 1 == 0:             # <<<<<<<<<<<<<<
 *                             v = int(v)
 *                     except ValueError:
 */
            __pyx_t_1 = PyNumber_Remainder(__pyx_v_v, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (__pyx_t_3) {

              /* "fiona/ogrext.pyx":519
 *                         v = float(v)
 *                         if v % 1 == 0:
 *                             v = int(v)             # <<<<<<<<<<<<<<
 *                     except ValueError:
 *                         # Leave v as a string
 */
              __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
              __Pyx_GOTREF(((PyObject *)__pyx_t_2));
              __Pyx_INCREF(__pyx_v_v);
              PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_v);
              __Pyx_GIVEREF(__pyx_v_v);
              __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_v_v);
              __pyx_v_v = __pyx_t_1;
              __pyx_t_1 = 0;
              goto __pyx_L19;
            }
            __pyx_L19:;
          }
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          goto __pyx_L18_try_end;
          __pyx_L11_error:;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "fiona/ogrext.pyx":520
 *                         if v % 1 == 0:
 *                             v = int(v)
 *                     except ValueError:             # <<<<<<<<<<<<<<
 *                         # Leave v as a string
 *                         pass
 */
          __pyx_t_14 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
          if (__pyx_t_14) {
            PyErr_Restore(0,0,0);
            goto __pyx_L12_exception_handled;
          }
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          goto __pyx_L1_error;
          __pyx_L12_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          __pyx_L18_try_end:;
        }
        goto __pyx_L8;
      }

      /* "fiona/ogrext.pyx":523
 *                         # Leave v as a string
 *                         pass
 *                 elif len(kv) == 1:             # <<<<<<<<<<<<<<
 *                     k, v = kv[0], True
 *                 else:
 */
      __pyx_t_7 = PyObject_Length(__pyx_v_kv); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_3 = (__pyx_t_7 == 1);
      if (__pyx_t_3) {

        /* "fiona/ogrext.pyx":524
 *                         pass
 *                 elif len(kv) == 1:
 *                     k, v = kv[0], True             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError("Unexpected proj parameter %s" % param)
 */
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_kv, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_XDECREF(__pyx_v_k);
        __pyx_v_k = __pyx_t_1;
        __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_v_v);
        __pyx_v_v = __pyx_t_2;
        __pyx_t_2 = 0;
        goto __pyx_L8;
      }
      /*else*/ {

        /* "fiona/ogrext.pyx":526
 *                     k, v = kv[0], True
 *                 else:
 *                     raise ValueError("Unexpected proj parameter %s" % param)             # <<<<<<<<<<<<<<
 *                 k = k.lstrip("+")
 *                 crs[k] = v
 */
        __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_36), __pyx_v_param); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
        PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
        __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L8:;

      /* "fiona/ogrext.pyx":527
 *                 else:
 *                     raise ValueError("Unexpected proj parameter %s" % param)
 *                 k = k.lstrip("+")             # <<<<<<<<<<<<<<
 *                 crs[k] = v
 *             ograpi.CPLFree(proj)
 */
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_k, __pyx_n_s__lstrip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_38), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_v_k);
      __pyx_v_k = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "fiona/ogrext.pyx":528
 *                     raise ValueError("Unexpected proj parameter %s" % param)
 *                 k = k.lstrip("+")
 *                 crs[k] = v             # <<<<<<<<<<<<<<
 *             ograpi.CPLFree(proj)
 *         else:
 */
      if (PyDict_SetItem(((PyObject *)__pyx_v_crs), __pyx_v_k, __pyx_v_v) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "fiona/ogrext.pyx":529
 *                 k = k.lstrip("+")
 *                 crs[k] = v
 *             ograpi.CPLFree(proj)             # <<<<<<<<<<<<<<
 *         else:
 *             log.debug("Projection not found (cogr_crs was NULL)")
 */
    CPLFree(__pyx_v_proj);
    goto __pyx_L5;
  }
  /*else*/ {

    /* "fiona/ogrext.pyx":531
 *             ograpi.CPLFree(proj)
 *         else:
 *             log.debug("Projection not found (cogr_crs was NULL)")             # <<<<<<<<<<<<<<
 *         return crs
 * 
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__debug); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_40), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L5:;

  /* "fiona/ogrext.pyx":532
 *         else:
 *             log.debug("Projection not found (cogr_crs was NULL)")
 *         return crs             # <<<<<<<<<<<<<<
 * 
 *     def isactive(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_crs));
  __pyx_r = ((PyObject *)__pyx_v_crs);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("fiona.ogrext.Session.get_crs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_crs);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_param);
  __Pyx_XDECREF(__pyx_v_kv);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":534
 *         return crs
 * 
 *     def isactive(self):             # <<<<<<<<<<<<<<
 *         if self.cogr_layer != NULL and self.cogr_ds != NULL:
 *             return 1
 */

static PyObject *__pyx_pf_5fiona_6ogrext_7Session_7isactive(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_7Session_7isactive(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("isactive");

  /* "fiona/ogrext.pyx":535
 * 
 *     def isactive(self):
 *         if self.cogr_layer != NULL and self.cogr_ds != NULL:             # <<<<<<<<<<<<<<
 *             return 1
 *         else:
 */
  __pyx_t_1 = (((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_layer != NULL);
  if (__pyx_t_1) {
    __pyx_t_2 = (((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_v_self)->cogr_ds != NULL);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "fiona/ogrext.pyx":536
 *     def isactive(self):
 *         if self.cogr_layer != NULL and self.cogr_ds != NULL:
 *             return 1             # <<<<<<<<<<<<<<
 *         else:
 *             return 0
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_int_1);
    __pyx_r = __pyx_int_1;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "fiona/ogrext.pyx":538
 *             return 1
 *         else:
 *             return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_int_0);
    __pyx_r = __pyx_int_0;
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":543
 * cdef class WritingSession(Session):
 * 
 *     def start(self, collection):             # <<<<<<<<<<<<<<
 *         cdef void *cogr_fielddefn
 *         cdef void *cogr_driver
 */

static PyObject *__pyx_pf_5fiona_6ogrext_14WritingSession_start(PyObject *__pyx_v_self, PyObject *__pyx_v_collection); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_14WritingSession_start(PyObject *__pyx_v_self, PyObject *__pyx_v_collection) {
  void *__pyx_v_cogr_fielddefn;
  void *__pyx_v_cogr_driver;
  void *__pyx_v_cogr_srs;
  PyObject *__pyx_v_path = NULL;
  PyObject *__pyx_v_params = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_v_proj = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  char *__pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("start");

  /* "fiona/ogrext.pyx":546
 *         cdef void *cogr_fielddefn
 *         cdef void *cogr_driver
 *         cdef void *cogr_srs = NULL             # <<<<<<<<<<<<<<
 *         path = collection.path
 * 
 */
  __pyx_v_cogr_srs = NULL;

  /* "fiona/ogrext.pyx":547
 *         cdef void *cogr_driver
 *         cdef void *cogr_srs = NULL
 *         path = collection.path             # <<<<<<<<<<<<<<
 * 
 *         if collection.mode == 'a':
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_path = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":549
 *         path = collection.path
 * 
 *         if collection.mode == 'a':             # <<<<<<<<<<<<<<
 *             if os.path.exists(path):
 *                 self.cogr_ds = ograpi.OGROpen(path, 1, NULL)
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__mode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyString_Equals(__pyx_t_1, ((PyObject *)__pyx_n_s__a), Py_EQ); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "fiona/ogrext.pyx":550
 * 
 *         if collection.mode == 'a':
 *             if os.path.exists(path):             # <<<<<<<<<<<<<<
 *                 self.cogr_ds = ograpi.OGROpen(path, 1, NULL)
 *                 if self.cogr_ds is NULL:
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_INCREF(__pyx_v_path);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_path);
    __Pyx_GIVEREF(__pyx_v_path);
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_2) {

      /* "fiona/ogrext.pyx":551
 *         if collection.mode == 'a':
 *             if os.path.exists(path):
 *                 self.cogr_ds = ograpi.OGROpen(path, 1, NULL)             # <<<<<<<<<<<<<<
 *                 if self.cogr_ds is NULL:
 *                     raise RuntimeError("Failed to open %s" % path)
 */
      __pyx_t_5 = PyBytes_AsString(__pyx_v_path); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      ((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_ds = OGROpen(__pyx_t_5, 1, NULL);

      /* "fiona/ogrext.pyx":552
 *             if os.path.exists(path):
 *                 self.cogr_ds = ograpi.OGROpen(path, 1, NULL)
 *                 if self.cogr_ds is NULL:             # <<<<<<<<<<<<<<
 *                     raise RuntimeError("Failed to open %s" % path)
 *                 cogr_driver = ograpi.OGR_DS_GetDriver(self.cogr_ds)
 */
      __pyx_t_2 = (((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_ds == NULL);
      if (__pyx_t_2) {

        /* "fiona/ogrext.pyx":553
 *                 self.cogr_ds = ograpi.OGROpen(path, 1, NULL)
 *                 if self.cogr_ds is NULL:
 *                     raise RuntimeError("Failed to open %s" % path)             # <<<<<<<<<<<<<<
 *                 cogr_driver = ograpi.OGR_DS_GetDriver(self.cogr_ds)
 *                 assert cogr_driver is not NULL
 */
        __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_41), __pyx_v_path); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_4));
        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
        PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
        __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L7;
      }
      __pyx_L7:;

      /* "fiona/ogrext.pyx":554
 *                 if self.cogr_ds is NULL:
 *                     raise RuntimeError("Failed to open %s" % path)
 *                 cogr_driver = ograpi.OGR_DS_GetDriver(self.cogr_ds)             # <<<<<<<<<<<<<<
 *                 assert cogr_driver is not NULL
 *                 self.cogr_layer = ograpi.OGR_DS_GetLayerByName(
 */
      __pyx_v_cogr_driver = OGR_DS_GetDriver(((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_ds);

      /* "fiona/ogrext.pyx":555
 *                     raise RuntimeError("Failed to open %s" % path)
 *                 cogr_driver = ograpi.OGR_DS_GetDriver(self.cogr_ds)
 *                 assert cogr_driver is not NULL             # <<<<<<<<<<<<<<
 *                 self.cogr_layer = ograpi.OGR_DS_GetLayerByName(
 *                                         self.cogr_ds, collection.name)
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!(__pyx_v_cogr_driver != NULL))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #endif

      /* "fiona/ogrext.pyx":557
 *                 assert cogr_driver is not NULL
 *                 self.cogr_layer = ograpi.OGR_DS_GetLayerByName(
 *                                         self.cogr_ds, collection.name)             # <<<<<<<<<<<<<<
 *                 if self.cogr_layer is NULL:
 *                     raise RuntimeError(
 */
      __pyx_t_4 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__name); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "fiona/ogrext.pyx":556
 *                 cogr_driver = ograpi.OGR_DS_GetDriver(self.cogr_ds)
 *                 assert cogr_driver is not NULL
 *                 self.cogr_layer = ograpi.OGR_DS_GetLayerByName(             # <<<<<<<<<<<<<<
 *                                         self.cogr_ds, collection.name)
 *                 if self.cogr_layer is NULL:
 */
      ((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_layer = OGR_DS_GetLayerByName(((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_ds, __pyx_t_5);

      /* "fiona/ogrext.pyx":558
 *                 self.cogr_layer = ograpi.OGR_DS_GetLayerByName(
 *                                         self.cogr_ds, collection.name)
 *                 if self.cogr_layer is NULL:             # <<<<<<<<<<<<<<
 *                     raise RuntimeError(
 *                         "Failed to get layer %s" % collection.name)
 */
      __pyx_t_2 = (((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_layer == NULL);
      if (__pyx_t_2) {

        /* "fiona/ogrext.pyx":560
 *                 if self.cogr_layer is NULL:
 *                     raise RuntimeError(
 *                         "Failed to get layer %s" % collection.name)             # <<<<<<<<<<<<<<
 *             else:
 *                 raise OSError("No such file or directory %s" % path)
 */
        __pyx_t_4 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__name); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_42), __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_4));
        PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
        __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L8;
      }
      __pyx_L8:;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "fiona/ogrext.pyx":562
 *                         "Failed to get layer %s" % collection.name)
 *             else:
 *                 raise OSError("No such file or directory %s" % path)             # <<<<<<<<<<<<<<
 * 
 *         elif collection.mode == 'w':
 */
      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_43), __pyx_v_path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L6:;
    goto __pyx_L5;
  }

  /* "fiona/ogrext.pyx":564
 *                 raise OSError("No such file or directory %s" % path)
 * 
 *         elif collection.mode == 'w':             # <<<<<<<<<<<<<<
 *             if os.path.exists(path):
 *                 self.cogr_ds = ograpi.OGROpen(path, 0, NULL)
 */
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__mode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__w), Py_EQ); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "fiona/ogrext.pyx":565
 * 
 *         elif collection.mode == 'w':
 *             if os.path.exists(path):             # <<<<<<<<<<<<<<
 *                 self.cogr_ds = ograpi.OGROpen(path, 0, NULL)
 *                 if self.cogr_ds is not NULL:
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__exists); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(__pyx_v_path);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_path);
    __Pyx_GIVEREF(__pyx_v_path);
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_2) {

      /* "fiona/ogrext.pyx":566
 *         elif collection.mode == 'w':
 *             if os.path.exists(path):
 *                 self.cogr_ds = ograpi.OGROpen(path, 0, NULL)             # <<<<<<<<<<<<<<
 *                 if self.cogr_ds is not NULL:
 *                     cogr_driver = ograpi.OGR_DS_GetDriver(self.cogr_ds)
 */
      __pyx_t_5 = PyBytes_AsString(__pyx_v_path); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      ((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_ds = OGROpen(__pyx_t_5, 0, NULL);

      /* "fiona/ogrext.pyx":567
 *             if os.path.exists(path):
 *                 self.cogr_ds = ograpi.OGROpen(path, 0, NULL)
 *                 if self.cogr_ds is not NULL:             # <<<<<<<<<<<<<<
 *                     cogr_driver = ograpi.OGR_DS_GetDriver(self.cogr_ds)
 *                     assert cogr_driver is not NULL
 */
      __pyx_t_2 = (((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_ds != NULL);
      if (__pyx_t_2) {

        /* "fiona/ogrext.pyx":568
 *                 self.cogr_ds = ograpi.OGROpen(path, 0, NULL)
 *                 if self.cogr_ds is not NULL:
 *                     cogr_driver = ograpi.OGR_DS_GetDriver(self.cogr_ds)             # <<<<<<<<<<<<<<
 *                     assert cogr_driver is not NULL
 *                     ograpi.OGR_DS_Destroy(self.cogr_ds)
 */
        __pyx_v_cogr_driver = OGR_DS_GetDriver(((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_ds);

        /* "fiona/ogrext.pyx":569
 *                 if self.cogr_ds is not NULL:
 *                     cogr_driver = ograpi.OGR_DS_GetDriver(self.cogr_ds)
 *                     assert cogr_driver is not NULL             # <<<<<<<<<<<<<<
 *                     ograpi.OGR_DS_Destroy(self.cogr_ds)
 *                     ograpi.OGR_Dr_DeleteDataSource(cogr_driver, path)
 */
        #ifndef CYTHON_WITHOUT_ASSERTIONS
        if (unlikely(!(__pyx_v_cogr_driver != NULL))) {
          PyErr_SetNone(PyExc_AssertionError);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #endif

        /* "fiona/ogrext.pyx":570
 *                     cogr_driver = ograpi.OGR_DS_GetDriver(self.cogr_ds)
 *                     assert cogr_driver is not NULL
 *                     ograpi.OGR_DS_Destroy(self.cogr_ds)             # <<<<<<<<<<<<<<
 *                     ograpi.OGR_Dr_DeleteDataSource(cogr_driver, path)
 *                     log.debug("Deleted pre-existing data at %s", path)
 */
        OGR_DS_Destroy(((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_ds);

        /* "fiona/ogrext.pyx":571
 *                     assert cogr_driver is not NULL
 *                     ograpi.OGR_DS_Destroy(self.cogr_ds)
 *                     ograpi.OGR_Dr_DeleteDataSource(cogr_driver, path)             # <<<<<<<<<<<<<<
 *                     log.debug("Deleted pre-existing data at %s", path)
 *             cogr_driver = ograpi.OGRGetDriverByName(collection.driver)
 */
        __pyx_t_5 = PyBytes_AsString(__pyx_v_path); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        OGR_Dr_DeleteDataSource(__pyx_v_cogr_driver, __pyx_t_5);

        /* "fiona/ogrext.pyx":572
 *                     ograpi.OGR_DS_Destroy(self.cogr_ds)
 *                     ograpi.OGR_Dr_DeleteDataSource(cogr_driver, path)
 *                     log.debug("Deleted pre-existing data at %s", path)             # <<<<<<<<<<<<<<
 *             cogr_driver = ograpi.OGRGetDriverByName(collection.driver)
 *             assert cogr_driver is not NULL
 */
        __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
        __Pyx_INCREF(((PyObject *)__pyx_kp_s_44));
        PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_44));
        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_44));
        __Pyx_INCREF(__pyx_v_path);
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_path);
        __Pyx_GIVEREF(__pyx_v_path);
        __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L10;
      }
      __pyx_L10:;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "fiona/ogrext.pyx":573
 *                     ograpi.OGR_Dr_DeleteDataSource(cogr_driver, path)
 *                     log.debug("Deleted pre-existing data at %s", path)
 *             cogr_driver = ograpi.OGRGetDriverByName(collection.driver)             # <<<<<<<<<<<<<<
 *             assert cogr_driver is not NULL
 *             self.cogr_ds = ograpi.OGR_Dr_CreateDataSource(
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__driver); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 573; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_cogr_driver = OGRGetDriverByName(__pyx_t_5);

    /* "fiona/ogrext.pyx":574
 *                     log.debug("Deleted pre-existing data at %s", path)
 *             cogr_driver = ograpi.OGRGetDriverByName(collection.driver)
 *             assert cogr_driver is not NULL             # <<<<<<<<<<<<<<
 *             self.cogr_ds = ograpi.OGR_Dr_CreateDataSource(
 *                 cogr_driver, path, NULL)
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!(__pyx_v_cogr_driver != NULL))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "fiona/ogrext.pyx":576
 *             assert cogr_driver is not NULL
 *             self.cogr_ds = ograpi.OGR_Dr_CreateDataSource(
 *                 cogr_driver, path, NULL)             # <<<<<<<<<<<<<<
 *             if self.cogr_ds is NULL:
 *                 raise RuntimeError("Failed to open %s" % path)
 */
    __pyx_t_5 = PyBytes_AsString(__pyx_v_path); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "fiona/ogrext.pyx":575
 *             cogr_driver = ograpi.OGRGetDriverByName(collection.driver)
 *             assert cogr_driver is not NULL
 *             self.cogr_ds = ograpi.OGR_Dr_CreateDataSource(             # <<<<<<<<<<<<<<
 *                 cogr_driver, path, NULL)
 *             if self.cogr_ds is NULL:
 */
    ((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_ds = OGR_Dr_CreateDataSource(__pyx_v_cogr_driver, __pyx_t_5, NULL);

    /* "fiona/ogrext.pyx":577
 *             self.cogr_ds = ograpi.OGR_Dr_CreateDataSource(
 *                 cogr_driver, path, NULL)
 *             if self.cogr_ds is NULL:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError("Failed to open %s" % path)
 * 
 */
    __pyx_t_2 = (((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_ds == NULL);
    if (__pyx_t_2) {

      /* "fiona/ogrext.pyx":578
 *                 cogr_driver, path, NULL)
 *             if self.cogr_ds is NULL:
 *                 raise RuntimeError("Failed to open %s" % path)             # <<<<<<<<<<<<<<
 * 
 *             # Set the spatial reference system from the given crs.
 */
      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_41), __pyx_v_path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "fiona/ogrext.pyx":581
 * 
 *             # Set the spatial reference system from the given crs.
 *             if collection.crs:             # <<<<<<<<<<<<<<
 *                 cogr_srs = ograpi.OSRNewSpatialReference(NULL)
 *                 assert cogr_srs is not NULL
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__crs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {

      /* "fiona/ogrext.pyx":582
 *             # Set the spatial reference system from the given crs.
 *             if collection.crs:
 *                 cogr_srs = ograpi.OSRNewSpatialReference(NULL)             # <<<<<<<<<<<<<<
 *                 assert cogr_srs is not NULL
 *                 params = []
 */
      __pyx_v_cogr_srs = OSRNewSpatialReference(NULL);

      /* "fiona/ogrext.pyx":583
 *             if collection.crs:
 *                 cogr_srs = ograpi.OSRNewSpatialReference(NULL)
 *                 assert cogr_srs is not NULL             # <<<<<<<<<<<<<<
 *                 params = []
 *                 for k, v in collection.crs.items():
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!(__pyx_v_cogr_srs != NULL))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #endif

      /* "fiona/ogrext.pyx":584
 *                 cogr_srs = ograpi.OSRNewSpatialReference(NULL)
 *                 assert cogr_srs is not NULL
 *                 params = []             # <<<<<<<<<<<<<<
 *                 for k, v in collection.crs.items():
 *                     if v is True or (k == 'no_defs' and v):
 */
      __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __pyx_v_params = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "fiona/ogrext.pyx":585
 *                 assert cogr_srs is not NULL
 *                 params = []
 *                 for k, v in collection.crs.items():             # <<<<<<<<<<<<<<
 *                     if v is True or (k == 'no_defs' and v):
 *                         params.append("+%s" % k)
 */
      __pyx_t_3 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__crs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
        __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
        __pyx_t_7 = NULL;
      } else {
        __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      for (;;) {
        if (PyList_CheckExact(__pyx_t_1)) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++;
        } else if (PyTuple_CheckExact(__pyx_t_1)) {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++;
        } else {
          __pyx_t_3 = __pyx_t_7(__pyx_t_1);
          if (unlikely(!__pyx_t_3)) {
            if (PyErr_Occurred()) {
              if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_3);
        }
        if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
          PyObject* sequence = __pyx_t_3;
          if (likely(PyTuple_CheckExact(sequence))) {
            if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
              if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
              else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
              if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
              else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_9 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
          index = 0; __pyx_t_4 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L15_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_4);
          index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L15_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_8);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          goto __pyx_L16_unpacking_done;
          __pyx_L15_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
          if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_L16_unpacking_done:;
        }
        __Pyx_XDECREF(__pyx_v_k);
        __pyx_v_k = __pyx_t_4;
        __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_v_v);
        __pyx_v_v = __pyx_t_8;
        __pyx_t_8 = 0;

        /* "fiona/ogrext.pyx":586
 *                 params = []
 *                 for k, v in collection.crs.items():
 *                     if v is True or (k == 'no_defs' and v):             # <<<<<<<<<<<<<<
 *                         params.append("+%s" % k)
 *                     else:
 */
        __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = (__pyx_v_v == __pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!__pyx_t_2) {
          __pyx_t_11 = __Pyx_PyString_Equals(__pyx_v_k, ((PyObject *)__pyx_n_s__no_defs), Py_EQ); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          if (__pyx_t_11) {
            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_v); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_13 = __pyx_t_12;
          } else {
            __pyx_t_13 = __pyx_t_11;
          }
          __pyx_t_11 = __pyx_t_13;
        } else {
          __pyx_t_11 = __pyx_t_2;
        }
        if (__pyx_t_11) {

          /* "fiona/ogrext.pyx":587
 *                 for k, v in collection.crs.items():
 *                     if v is True or (k == 'no_defs' and v):
 *                         params.append("+%s" % k)             # <<<<<<<<<<<<<<
 *                     else:
 *                         params.append("+%s=%s" % (k, v))
 */
          if (unlikely(((PyObject *)__pyx_v_params) == Py_None)) {
            PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
          }
          __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_45), __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_3));
          __pyx_t_14 = PyList_Append(__pyx_v_params, ((PyObject *)__pyx_t_3)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
          goto __pyx_L17;
        }
        /*else*/ {

          /* "fiona/ogrext.pyx":589
 *                         params.append("+%s" % k)
 *                     else:
 *                         params.append("+%s=%s" % (k, v))             # <<<<<<<<<<<<<<
 *                 proj = " ".join(params)
 *                 ograpi.OSRImportFromProj4(cogr_srs, <char *>proj)
 */
          if (unlikely(((PyObject *)__pyx_v_params) == Py_None)) {
            PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
          }
          __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_3));
          __Pyx_INCREF(__pyx_v_k);
          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_k);
          __Pyx_GIVEREF(__pyx_v_k);
          __Pyx_INCREF(__pyx_v_v);
          PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_v);
          __Pyx_GIVEREF(__pyx_v_v);
          __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_46), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_8));
          __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
          __pyx_t_14 = PyList_Append(__pyx_v_params, ((PyObject *)__pyx_t_8)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
        }
        __pyx_L17:;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "fiona/ogrext.pyx":590
 *                     else:
 *                         params.append("+%s=%s" % (k, v))
 *                 proj = " ".join(params)             # <<<<<<<<<<<<<<
 *                 ograpi.OSRImportFromProj4(cogr_srs, <char *>proj)
 * 
 */
      __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_47), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __Pyx_INCREF(((PyObject *)__pyx_v_params));
      PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_params));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_params));
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
      __pyx_v_proj = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "fiona/ogrext.pyx":591
 *                         params.append("+%s=%s" % (k, v))
 *                 proj = " ".join(params)
 *                 ograpi.OSRImportFromProj4(cogr_srs, <char *>proj)             # <<<<<<<<<<<<<<
 * 
 *             self.cogr_layer = ograpi.OGR_DS_CreateLayer(
 */
      __pyx_t_5 = PyBytes_AsString(__pyx_v_proj); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      OSRImportFromProj4(__pyx_v_cogr_srs, ((char *)__pyx_t_5));
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "fiona/ogrext.pyx":595
 *             self.cogr_layer = ograpi.OGR_DS_CreateLayer(
 *                 self.cogr_ds,
 *                 collection.name,             # <<<<<<<<<<<<<<
 *                 cogr_srs,
 *                 GEOMETRY_TYPES.index(collection.schema['geometry']),
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__name); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "fiona/ogrext.pyx":597
 *                 collection.name,
 *                 cogr_srs,
 *                 GEOMETRY_TYPES.index(collection.schema['geometry']),             # <<<<<<<<<<<<<<
 *                 NULL
 *                 )
 */
    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__GEOMETRY_TYPES); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__index); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__schema); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_GetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__geometry)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_15 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_15 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "fiona/ogrext.pyx":593
 *                 ograpi.OSRImportFromProj4(cogr_srs, <char *>proj)
 * 
 *             self.cogr_layer = ograpi.OGR_DS_CreateLayer(             # <<<<<<<<<<<<<<
 *                 self.cogr_ds,
 *                 collection.name,
 */
    ((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_layer = OGR_DS_CreateLayer(((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_ds, __pyx_t_5, __pyx_v_cogr_srs, __pyx_t_15, NULL);

    /* "fiona/ogrext.pyx":600
 *                 NULL
 *                 )
 *             assert self.cogr_layer is not NULL             # <<<<<<<<<<<<<<
 *             log.debug("Created layer")
 * 
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!(((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_layer != NULL))) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif

    /* "fiona/ogrext.pyx":601
 *                 )
 *             assert self.cogr_layer is not NULL
 *             log.debug("Created layer")             # <<<<<<<<<<<<<<
 * 
 *             # Next, make a layer definition from the given schema.
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_49), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "fiona/ogrext.pyx":604
 * 
 *             # Next, make a layer definition from the given schema.
 *             for key, value in collection.schema['properties'].items():             # <<<<<<<<<<<<<<
 *                 log.debug("Creating field: %s %s", key, value)
 *                 cogr_fielddefn = ograpi.OGR_Fld_Create(
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__schema); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_GetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__properties)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (PyList_CheckExact(__pyx_t_1)) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++;
      } else if (PyTuple_CheckExact(__pyx_t_1)) {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++;
      } else {
        __pyx_t_3 = __pyx_t_7(__pyx_t_1);
        if (unlikely(!__pyx_t_3)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        if (likely(PyTuple_CheckExact(sequence))) {
          if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) {
            if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          if (unlikely(PyList_GET_SIZE(sequence) != 2)) {
            if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2);
            else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence));
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_9 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
        index = 0; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L20_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L20_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_4);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L21_unpacking_done;
        __pyx_L20_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear();
        if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L21_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_key);
      __pyx_v_key = __pyx_t_8;
      __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_v_value);
      __pyx_v_value = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "fiona/ogrext.pyx":605
 *             # Next, make a layer definition from the given schema.
 *             for key, value in collection.schema['properties'].items():
 *                 log.debug("Creating field: %s %s", key, value)             # <<<<<<<<<<<<<<
 *                 cogr_fielddefn = ograpi.OGR_Fld_Create(
 *                     key,
 */
      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__debug); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_50));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_50));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_50));
      __Pyx_INCREF(__pyx_v_key);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_key);
      __Pyx_GIVEREF(__pyx_v_key);
      __Pyx_INCREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      __pyx_t_8 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "fiona/ogrext.pyx":607
 *                 log.debug("Creating field: %s %s", key, value)
 *                 cogr_fielddefn = ograpi.OGR_Fld_Create(
 *                     key,             # <<<<<<<<<<<<<<
 *                     FIELD_TYPES.index(value) )
 *                 assert cogr_fielddefn is not NULL
 */
      __pyx_t_5 = PyBytes_AsString(__pyx_v_key); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "fiona/ogrext.pyx":608
 *                 cogr_fielddefn = ograpi.OGR_Fld_Create(
 *                     key,
 *                     FIELD_TYPES.index(value) )             # <<<<<<<<<<<<<<
 *                 assert cogr_fielddefn is not NULL
 *                 ograpi.OGR_L_CreateField(self.cogr_layer, cogr_fielddefn, 1)
 */
      __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__FIELD_TYPES); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__index); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __Pyx_INCREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
      __pyx_t_15 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_15 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_cogr_fielddefn = OGR_Fld_Create(__pyx_t_5, __pyx_t_15);

      /* "fiona/ogrext.pyx":609
 *                     key,
 *                     FIELD_TYPES.index(value) )
 *                 assert cogr_fielddefn is not NULL             # <<<<<<<<<<<<<<
 *                 ograpi.OGR_L_CreateField(self.cogr_layer, cogr_fielddefn, 1)
 *                 ograpi.OGR_Fld_Destroy(cogr_fielddefn)
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!(__pyx_v_cogr_fielddefn != NULL))) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #endif

      /* "fiona/ogrext.pyx":610
 *                     FIELD_TYPES.index(value) )
 *                 assert cogr_fielddefn is not NULL
 *                 ograpi.OGR_L_CreateField(self.cogr_layer, cogr_fielddefn, 1)             # <<<<<<<<<<<<<<
 *                 ograpi.OGR_Fld_Destroy(cogr_fielddefn)
 *             log.debug("Created fields")
 */
      OGR_L_CreateField(((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_layer, __pyx_v_cogr_fielddefn, 1);

      /* "fiona/ogrext.pyx":611
 *                 assert cogr_fielddefn is not NULL
 *                 ograpi.OGR_L_CreateField(self.cogr_layer, cogr_fielddefn, 1)
 *                 ograpi.OGR_Fld_Destroy(cogr_fielddefn)             # <<<<<<<<<<<<<<
 *             log.debug("Created fields")
 * 
 */
      OGR_Fld_Destroy(__pyx_v_cogr_fielddefn);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "fiona/ogrext.pyx":612
 *                 ograpi.OGR_L_CreateField(self.cogr_layer, cogr_fielddefn, 1)
 *                 ograpi.OGR_Fld_Destroy(cogr_fielddefn)
 *             log.debug("Created fields")             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_52), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "fiona/ogrext.pyx":615
 * 
 * 
 *         log.debug("Writing started")             # <<<<<<<<<<<<<<
 * 
 *     def write(self, feature, collection):
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_54), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("fiona.ogrext.WritingSession.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_path);
  __Pyx_XDECREF(__pyx_v_params);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_proj);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":617
 *         log.debug("Writing started")
 * 
 *     def write(self, feature, collection):             # <<<<<<<<<<<<<<
 *         log.debug("Creating feature in layer: %s" % feature)
 *         try:
 */

static PyObject *__pyx_pf_5fiona_6ogrext_14WritingSession_1write(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_14WritingSession_1write(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_feature = 0;
  PyObject *__pyx_v_collection = 0;
  PyObject *__pyx_v_key = NULL;
  void *__pyx_v_cogr_layer;
  void *__pyx_v_cogr_feature;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  void *__pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__feature,&__pyx_n_s__collection,0};
  __Pyx_RefNannySetupContext("write");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__feature);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__collection);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("write", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "write") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_feature = values[0];
    __pyx_v_collection = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_feature = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_collection = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("fiona.ogrext.WritingSession.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "fiona/ogrext.pyx":618
 * 
 *     def write(self, feature, collection):
 *         log.debug("Creating feature in layer: %s" % feature)             # <<<<<<<<<<<<<<
 *         try:
 *             for key in feature['properties']:
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__log); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_55), __pyx_v_feature); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":619
 *     def write(self, feature, collection):
 *         log.debug("Creating feature in layer: %s" % feature)
 *         try:             # <<<<<<<<<<<<<<
 *             for key in feature['properties']:
 *                 assert key in collection.schema['properties']
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "fiona/ogrext.pyx":620
 *         log.debug("Creating feature in layer: %s" % feature)
 *         try:
 *             for key in feature['properties']:             # <<<<<<<<<<<<<<
 *                 assert key in collection.schema['properties']
 *             assert feature['geometry']['type'] == collection.schema['geometry']
 */
      __pyx_t_1 = PyObject_GetItem(__pyx_v_feature, ((PyObject *)__pyx_n_s__properties)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_1);
      if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
        __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
        __pyx_t_8 = NULL;
      } else {
        __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      for (;;) {
        if (PyList_CheckExact(__pyx_t_3)) {
          if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
          __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++;
        } else if (PyTuple_CheckExact(__pyx_t_3)) {
          if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++;
        } else {
          __pyx_t_1 = __pyx_t_8(__pyx_t_3);
          if (unlikely(!__pyx_t_1)) {
            if (PyErr_Occurred()) {
              if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_XDECREF(__pyx_v_key);
        __pyx_v_key = __pyx_t_1;
        __pyx_t_1 = 0;

        /* "fiona/ogrext.pyx":621
 *         try:
 *             for key in feature['properties']:
 *                 assert key in collection.schema['properties']             # <<<<<<<<<<<<<<
 *             assert feature['geometry']['type'] == collection.schema['geometry']
 *         except AssertionError:
 */
        #ifndef CYTHON_WITHOUT_ASSERTIONS
        __pyx_t_1 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__schema); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = PyObject_GetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__properties)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_9 = ((PySequence_Contains(__pyx_t_2, __pyx_v_key))); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_9)) {
          PyErr_SetNone(PyExc_AssertionError);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
        }
        #endif
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "fiona/ogrext.pyx":622
 *             for key in feature['properties']:
 *                 assert key in collection.schema['properties']
 *             assert feature['geometry']['type'] == collection.schema['geometry']             # <<<<<<<<<<<<<<
 *         except AssertionError:
 *             raise ValueError("Feature data not match collection schema")
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      __pyx_t_3 = PyObject_GetItem(__pyx_v_feature, ((PyObject *)__pyx_n_s__geometry)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyObject_GetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__type)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__schema); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyObject_GetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__geometry)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_9)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L6_error;}
      }
      #endif
    }
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L13_try_end;
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "fiona/ogrext.pyx":623
 *                 assert key in collection.schema['properties']
 *             assert feature['geometry']['type'] == collection.schema['geometry']
 *         except AssertionError:             # <<<<<<<<<<<<<<
 *             raise ValueError("Feature data not match collection schema")
 * 
 */
    __pyx_t_10 = PyErr_ExceptionMatches(__pyx_builtin_AssertionError);
    if (__pyx_t_10) {
      __Pyx_AddTraceback("fiona.ogrext.WritingSession.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_2);

      /* "fiona/ogrext.pyx":624
 *             assert feature['geometry']['type'] == collection.schema['geometry']
 *         except AssertionError:
 *             raise ValueError("Feature data not match collection schema")             # <<<<<<<<<<<<<<
 * 
 *         cdef void *cogr_layer = self.cogr_layer
 */
      __pyx_t_11 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_57), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_Raise(__pyx_t_11, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L8_except_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L7_exception_handled;
    }
    __pyx_L8_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    __pyx_L13_try_end:;
  }

  /* "fiona/ogrext.pyx":626
 *             raise ValueError("Feature data not match collection schema")
 * 
 *         cdef void *cogr_layer = self.cogr_layer             # <<<<<<<<<<<<<<
 *         assert cogr_layer is not NULL
 *         cdef void *cogr_feature = OGRFeatureBuilder().build(feature, collection)
 */
  __pyx_v_cogr_layer = ((struct __pyx_obj_5fiona_6ogrext_WritingSession *)__pyx_v_self)->__pyx_base.cogr_layer;

  /* "fiona/ogrext.pyx":627
 * 
 *         cdef void *cogr_layer = self.cogr_layer
 *         assert cogr_layer is not NULL             # <<<<<<<<<<<<<<
 *         cdef void *cogr_feature = OGRFeatureBuilder().build(feature, collection)
 *         result = ograpi.OGR_L_CreateFeature(cogr_layer, cogr_feature)
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_layer != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":628
 *         cdef void *cogr_layer = self.cogr_layer
 *         assert cogr_layer is not NULL
 *         cdef void *cogr_feature = OGRFeatureBuilder().build(feature, collection)             # <<<<<<<<<<<<<<
 *         result = ograpi.OGR_L_CreateFeature(cogr_layer, cogr_feature)
 *         if result != OGRERR_NONE:
 */
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_OGRFeatureBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_12 = ((struct __pyx_vtabstruct_5fiona_6ogrext_OGRFeatureBuilder *)((struct __pyx_obj_5fiona_6ogrext_OGRFeatureBuilder *)__pyx_t_2)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_OGRFeatureBuilder *)__pyx_t_2), __pyx_v_feature, __pyx_v_collection); if (unlikely(__pyx_t_12 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_cogr_feature = __pyx_t_12;

  /* "fiona/ogrext.pyx":629
 *         assert cogr_layer is not NULL
 *         cdef void *cogr_feature = OGRFeatureBuilder().build(feature, collection)
 *         result = ograpi.OGR_L_CreateFeature(cogr_layer, cogr_feature)             # <<<<<<<<<<<<<<
 *         if result != OGRERR_NONE:
 *             raise RuntimeError("Failed to add feature: %s" % result)
 */
  __pyx_t_2 = PyInt_FromLong(OGR_L_CreateFeature(__pyx_v_cogr_layer, __pyx_v_cogr_feature)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_result = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":630
 *         cdef void *cogr_feature = OGRFeatureBuilder().build(feature, collection)
 *         result = ograpi.OGR_L_CreateFeature(cogr_layer, cogr_feature)
 *         if result != OGRERR_NONE:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Failed to add feature: %s" % result)
 *         _deleteOgrFeature(cogr_feature)
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__OGRERR_NONE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_result, __pyx_t_2, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_9) {

    /* "fiona/ogrext.pyx":631
 *         result = ograpi.OGR_L_CreateFeature(cogr_layer, cogr_feature)
 *         if result != OGRERR_NONE:
 *             raise RuntimeError("Failed to add feature: %s" % result)             # <<<<<<<<<<<<<<
 *         _deleteOgrFeature(cogr_feature)
 *         return result
 */
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_58), __pyx_v_result); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L18;
  }
  __pyx_L18:;

  /* "fiona/ogrext.pyx":632
 *         if result != OGRERR_NONE:
 *             raise RuntimeError("Failed to add feature: %s" % result)
 *         _deleteOgrFeature(cogr_feature)             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
  __pyx_t_1 = __pyx_f_5fiona_6ogrext__deleteOgrFeature(__pyx_v_cogr_feature); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":633
 *             raise RuntimeError("Failed to add feature: %s" % result)
 *         _deleteOgrFeature(cogr_feature)
 *         return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("fiona.ogrext.WritingSession.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":644
 *     cdef collection
 * 
 *     def __init__(self, collection, bbox=None):             # <<<<<<<<<<<<<<
 *         if collection.session is None:
 *             raise ValueError("I/O operation on closed collection")
 */

static int __pyx_pf_5fiona_6ogrext_8Iterator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_5fiona_6ogrext_8Iterator___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_collection = 0;
  PyObject *__pyx_v_bbox = 0;
  struct __pyx_obj_5fiona_6ogrext_Session *__pyx_v_session = 0;
  void *__pyx_v_cogr_layer;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  double __pyx_t_3;
  double __pyx_t_4;
  double __pyx_t_5;
  double __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__collection,&__pyx_n_s__bbox,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__collection);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bbox);
        if (value) { values[1] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_collection = values[0];
    __pyx_v_bbox = values[1];
  } else {
    __pyx_v_bbox = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_bbox = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_collection = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("fiona.ogrext.Iterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "fiona/ogrext.pyx":645
 * 
 *     def __init__(self, collection, bbox=None):
 *         if collection.session is None:             # <<<<<<<<<<<<<<
 *             raise ValueError("I/O operation on closed collection")
 *         self.collection = collection
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_collection, __pyx_n_s__session); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__pyx_t_1 == Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "fiona/ogrext.pyx":646
 *     def __init__(self, collection, bbox=None):
 *         if collection.session is None:
 *             raise ValueError("I/O operation on closed collection")             # <<<<<<<<<<<<<<
 *         self.collection = collection
 *         cdef Session session
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_60), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "fiona/ogrext.pyx":647
 *         if collection.session is None:
 *             raise ValueError("I/O operation on closed collection")
 *         self.collection = collection             # <<<<<<<<<<<<<<
 *         cdef Session session
 *         session = self.collection.session
 */
  __Pyx_INCREF(__pyx_v_collection);
  __Pyx_GIVEREF(__pyx_v_collection);
  __Pyx_GOTREF(((struct __pyx_obj_5fiona_6ogrext_Iterator *)__pyx_v_self)->collection);
  __Pyx_DECREF(((struct __pyx_obj_5fiona_6ogrext_Iterator *)__pyx_v_self)->collection);
  ((struct __pyx_obj_5fiona_6ogrext_Iterator *)__pyx_v_self)->collection = __pyx_v_collection;

  /* "fiona/ogrext.pyx":649
 *         self.collection = collection
 *         cdef Session session
 *         session = self.collection.session             # <<<<<<<<<<<<<<
 *         cdef void *cogr_layer = session.cogr_layer
 *         assert cogr_layer is not NULL
 */
  __pyx_t_1 = PyObject_GetAttr(((struct __pyx_obj_5fiona_6ogrext_Iterator *)__pyx_v_self)->collection, __pyx_n_s__session); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5fiona_6ogrext_Session))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_session = ((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":650
 *         cdef Session session
 *         session = self.collection.session
 *         cdef void *cogr_layer = session.cogr_layer             # <<<<<<<<<<<<<<
 *         assert cogr_layer is not NULL
 *         if bbox:
 */
  __pyx_v_cogr_layer = __pyx_v_session->cogr_layer;

  /* "fiona/ogrext.pyx":651
 *         session = self.collection.session
 *         cdef void *cogr_layer = session.cogr_layer
 *         assert cogr_layer is not NULL             # <<<<<<<<<<<<<<
 *         if bbox:
 *             ograpi.OGR_L_SetSpatialFilterRect(
 */
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!(__pyx_v_cogr_layer != NULL))) {
    PyErr_SetNone(PyExc_AssertionError);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  #endif

  /* "fiona/ogrext.pyx":652
 *         cdef void *cogr_layer = session.cogr_layer
 *         assert cogr_layer is not NULL
 *         if bbox:             # <<<<<<<<<<<<<<
 *             ograpi.OGR_L_SetSpatialFilterRect(
 *                 cogr_layer, bbox[0], bbox[1], bbox[2], bbox[3])
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_bbox); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {

    /* "fiona/ogrext.pyx":654
 *         if bbox:
 *             ograpi.OGR_L_SetSpatialFilterRect(
 *                 cogr_layer, bbox[0], bbox[1], bbox[2], bbox[3])             # <<<<<<<<<<<<<<
 * 
 *     def __iter__(self):
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_bbox, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_bbox, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_bbox, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_bbox, 3, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    OGR_L_SetSpatialFilterRect(__pyx_v_cogr_layer, __pyx_t_3, __pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L7;
  }
  __pyx_L7:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("fiona.ogrext.Iterator.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_session);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":656
 *                 cogr_layer, bbox[0], bbox[1], bbox[2], bbox[3])
 * 
 *     def __iter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

static PyObject *__pyx_pf_5fiona_6ogrext_8Iterator_1__iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_8Iterator_1__iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__iter__");

  /* "fiona/ogrext.pyx":657
 * 
 *     def __iter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __next__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "fiona/ogrext.pyx":659
 *         return self
 * 
 *     def __next__(self):             # <<<<<<<<<<<<<<
 *         cdef long fid
 *         cdef void * cogr_feature
 */

static PyObject *__pyx_pf_5fiona_6ogrext_8Iterator_2__next__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_5fiona_6ogrext_8Iterator_2__next__(PyObject *__pyx_v_self) {
  void *__pyx_v_cogr_feature;
  struct __pyx_obj_5fiona_6ogrext_Session *__pyx_v_session = 0;
  PyObject *__pyx_v_feature = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__next__");

  /* "fiona/ogrext.pyx":663
 *         cdef void * cogr_feature
 *         cdef Session session
 *         session = self.collection.session             # <<<<<<<<<<<<<<
 *         cogr_feature = ograpi.OGR_L_GetNextFeature(session.cogr_layer)
 *         if cogr_feature == NULL:
 */
  __pyx_t_1 = PyObject_GetAttr(((struct __pyx_obj_5fiona_6ogrext_Iterator *)__pyx_v_self)->collection, __pyx_n_s__session); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5fiona_6ogrext_Session))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_session = ((struct __pyx_obj_5fiona_6ogrext_Session *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":664
 *         cdef Session session
 *         session = self.collection.session
 *         cogr_feature = ograpi.OGR_L_GetNextFeature(session.cogr_layer)             # <<<<<<<<<<<<<<
 *         if cogr_feature == NULL:
 *             raise StopIteration
 */
  __pyx_v_cogr_feature = OGR_L_GetNextFeature(__pyx_v_session->cogr_layer);

  /* "fiona/ogrext.pyx":665
 *         session = self.collection.session
 *         cogr_feature = ograpi.OGR_L_GetNextFeature(session.cogr_layer)
 *         if cogr_feature == NULL:             # <<<<<<<<<<<<<<
 *             raise StopIteration
 *         feature = FeatureBuilder().build(cogr_feature)
 */
  __pyx_t_2 = (__pyx_v_cogr_feature == NULL);
  if (__pyx_t_2) {

    /* "fiona/ogrext.pyx":666
 *         cogr_feature = ograpi.OGR_L_GetNextFeature(session.cogr_layer)
 *         if cogr_feature == NULL:
 *             raise StopIteration             # <<<<<<<<<<<<<<
 *         feature = FeatureBuilder().build(cogr_feature)
 *         _deleteOgrFeature(cogr_feature)
 */
    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "fiona/ogrext.pyx":667
 *         if cogr_feature == NULL:
 *             raise StopIteration
 *         feature = FeatureBuilder().build(cogr_feature)             # <<<<<<<<<<<<<<
 *         _deleteOgrFeature(cogr_feature)
 *         return feature
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5fiona_6ogrext_FeatureBuilder)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = ((struct __pyx_vtabstruct_5fiona_6ogrext_FeatureBuilder *)((struct __pyx_obj_5fiona_6ogrext_FeatureBuilder *)__pyx_t_1)->__pyx_vtab)->build(((struct __pyx_obj_5fiona_6ogrext_FeatureBuilder *)__pyx_t_1), __pyx_v_cogr_feature); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_feature = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "fiona/ogrext.pyx":668
 *             raise StopIteration
 *         feature = FeatureBuilder().build(cogr_feature)
 *         _deleteOgrFeature(cogr_feature)             # <<<<<<<<<<<<<<
 *         return feature
 * 
 */
  __pyx_t_3 = __pyx_f_5fiona_6ogrext__deleteOgrFeature(__pyx_v_cogr_feature); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "fiona/ogrext.pyx":669
 *         feature = FeatureBuilder().build(cogr_feature)
 *         _deleteOgrFeature(cogr_feature)
 *         return feature             # <<<<<<<<<<<<<<
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_feature);
  __pyx_r = __pyx_v_feature;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("fiona.ogrext.Iterator.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_session);
  __Pyx_XDECREF(__pyx_v_feature);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_5fiona_6ogrext_GeomBuilder __pyx_vtable_5fiona_6ogrext_GeomBuilder;

static PyObject *__pyx_tp_new_5fiona_6ogrext_GeomBuilder(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5fiona_6ogrext_GeomBuilder *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)o);
  p->__pyx_vtab = __pyx_vtabptr_5fiona_6ogrext_GeomBuilder;
  p->code = Py_None; Py_INCREF(Py_None);
  p->typename = Py_None; Py_INCREF(Py_None);
  p->ndims = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5fiona_6ogrext_GeomBuilder(PyObject *o) {
  struct __pyx_obj_5fiona_6ogrext_GeomBuilder *p = (struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)o;
  Py_XDECREF(p->code);
  Py_XDECREF(p->typename);
  Py_XDECREF(p->ndims);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5fiona_6ogrext_GeomBuilder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5fiona_6ogrext_GeomBuilder *p = (struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)o;
  if (p->code) {
    e = (*v)(p->code, a); if (e) return e;
  }
  if (p->typename) {
    e = (*v)(p->typename, a); if (e) return e;
  }
  if (p->ndims) {
    e = (*v)(p->ndims, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5fiona_6ogrext_GeomBuilder(PyObject *o) {
  struct __pyx_obj_5fiona_6ogrext_GeomBuilder *p = (struct __pyx_obj_5fiona_6ogrext_GeomBuilder *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->code);
  p->code = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->typename);
  p->typename = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->ndims);
  p->ndims = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5fiona_6ogrext_GeomBuilder[] = {
  {__Pyx_NAMESTR("_buildPoint"), (PyCFunction)__pyx_pf_5fiona_6ogrext_11GeomBuilder__buildPoint, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("_buildLineString"), (PyCFunction)__pyx_pf_5fiona_6ogrext_11GeomBuilder_1_buildLineString, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("_buildLinearRing"), (PyCFunction)__pyx_pf_5fiona_6ogrext_11GeomBuilder_2_buildLinearRing, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("_buildPolygon"), (PyCFunction)__pyx_pf_5fiona_6ogrext_11GeomBuilder_3_buildPolygon, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("_buildMultiPoint"), (PyCFunction)__pyx_pf_5fiona_6ogrext_11GeomBuilder_4_buildMultiPoint, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("_buildMultiLineString"), (PyCFunction)__pyx_pf_5fiona_6ogrext_11GeomBuilder_5_buildMultiLineString, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("_buildMultiPolygon"), (PyCFunction)__pyx_pf_5fiona_6ogrext_11GeomBuilder_6_buildMultiPolygon, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("_buildGeometryCollection"), (PyCFunction)__pyx_pf_5fiona_6ogrext_11GeomBuilder_7_buildGeometryCollection, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("build_wkb"), (PyCFunction)__pyx_pf_5fiona_6ogrext_11GeomBuilder_8build_wkb, METH_O, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_GeomBuilder = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_GeomBuilder = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_GeomBuilder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_GeomBuilder = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_5fiona_6ogrext_GeomBuilder = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("fiona.ogrext.GeomBuilder"), /*tp_name*/
  sizeof(struct __pyx_obj_5fiona_6ogrext_GeomBuilder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5fiona_6ogrext_GeomBuilder, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_GeomBuilder, /*tp_as_number*/
  &__pyx_tp_as_sequence_GeomBuilder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_GeomBuilder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_GeomBuilder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Builds Fiona (GeoJSON) geometries from an OGR geometry handle.\n    "), /*tp_doc*/
  __pyx_tp_traverse_5fiona_6ogrext_GeomBuilder, /*tp_traverse*/
  __pyx_tp_clear_5fiona_6ogrext_GeomBuilder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5fiona_6ogrext_GeomBuilder, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5fiona_6ogrext_GeomBuilder, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_5fiona_6ogrext_OGRGeomBuilder __pyx_vtable_5fiona_6ogrext_OGRGeomBuilder;

static PyObject *__pyx_tp_new_5fiona_6ogrext_OGRGeomBuilder(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)o);
  p->__pyx_vtab = __pyx_vtabptr_5fiona_6ogrext_OGRGeomBuilder;
  p->coordinates = Py_None; Py_INCREF(Py_None);
  p->typename = Py_None; Py_INCREF(Py_None);
  p->ndims = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5fiona_6ogrext_OGRGeomBuilder(PyObject *o) {
  struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *p = (struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)o;
  Py_XDECREF(p->coordinates);
  Py_XDECREF(p->typename);
  Py_XDECREF(p->ndims);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5fiona_6ogrext_OGRGeomBuilder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *p = (struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)o;
  if (p->coordinates) {
    e = (*v)(p->coordinates, a); if (e) return e;
  }
  if (p->typename) {
    e = (*v)(p->typename, a); if (e) return e;
  }
  if (p->ndims) {
    e = (*v)(p->ndims, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5fiona_6ogrext_OGRGeomBuilder(PyObject *o) {
  struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *p = (struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->coordinates);
  p->coordinates = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->typename);
  p->typename = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->ndims);
  p->ndims = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5fiona_6ogrext_OGRGeomBuilder[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_OGRGeomBuilder = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_OGRGeomBuilder = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_OGRGeomBuilder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_OGRGeomBuilder = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_5fiona_6ogrext_OGRGeomBuilder = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("fiona.ogrext.OGRGeomBuilder"), /*tp_name*/
  sizeof(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5fiona_6ogrext_OGRGeomBuilder, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_OGRGeomBuilder, /*tp_as_number*/
  &__pyx_tp_as_sequence_OGRGeomBuilder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_OGRGeomBuilder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_OGRGeomBuilder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Builds OGR geometries from Fiona geometries.\n    "), /*tp_doc*/
  __pyx_tp_traverse_5fiona_6ogrext_OGRGeomBuilder, /*tp_traverse*/
  __pyx_tp_clear_5fiona_6ogrext_OGRGeomBuilder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5fiona_6ogrext_OGRGeomBuilder, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5fiona_6ogrext_OGRGeomBuilder, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_5fiona_6ogrext_FeatureBuilder __pyx_vtable_5fiona_6ogrext_FeatureBuilder;

static PyObject *__pyx_tp_new_5fiona_6ogrext_FeatureBuilder(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5fiona_6ogrext_FeatureBuilder *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_5fiona_6ogrext_FeatureBuilder *)o);
  p->__pyx_vtab = __pyx_vtabptr_5fiona_6ogrext_FeatureBuilder;
  return o;
}

static void __pyx_tp_dealloc_5fiona_6ogrext_FeatureBuilder(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5fiona_6ogrext_FeatureBuilder[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_FeatureBuilder = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_FeatureBuilder = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_FeatureBuilder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_FeatureBuilder = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_5fiona_6ogrext_FeatureBuilder = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("fiona.ogrext.FeatureBuilder"), /*tp_name*/
  sizeof(struct __pyx_obj_5fiona_6ogrext_FeatureBuilder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5fiona_6ogrext_FeatureBuilder, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_FeatureBuilder, /*tp_as_number*/
  &__pyx_tp_as_sequence_FeatureBuilder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_FeatureBuilder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_FeatureBuilder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("Build Fiona features from OGR feature pointers.\n\n    No OGR objects are allocated by this function and the feature\n    argument is not destroyed.\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5fiona_6ogrext_FeatureBuilder, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5fiona_6ogrext_FeatureBuilder, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_5fiona_6ogrext_OGRFeatureBuilder __pyx_vtable_5fiona_6ogrext_OGRFeatureBuilder;

static PyObject *__pyx_tp_new_5fiona_6ogrext_OGRFeatureBuilder(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5fiona_6ogrext_OGRFeatureBuilder *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_5fiona_6ogrext_OGRFeatureBuilder *)o);
  p->__pyx_vtab = __pyx_vtabptr_5fiona_6ogrext_OGRFeatureBuilder;
  return o;
}

static void __pyx_tp_dealloc_5fiona_6ogrext_OGRFeatureBuilder(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5fiona_6ogrext_OGRFeatureBuilder[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_OGRFeatureBuilder = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_OGRFeatureBuilder = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_OGRFeatureBuilder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_OGRFeatureBuilder = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_5fiona_6ogrext_OGRFeatureBuilder = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("fiona.ogrext.OGRFeatureBuilder"), /*tp_name*/
  sizeof(struct __pyx_obj_5fiona_6ogrext_OGRFeatureBuilder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5fiona_6ogrext_OGRFeatureBuilder, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_OGRFeatureBuilder, /*tp_as_number*/
  &__pyx_tp_as_sequence_OGRFeatureBuilder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_OGRFeatureBuilder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_OGRFeatureBuilder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  __Pyx_DOCSTR("Builds an OGR Feature from a Fiona feature mapping.\n\n    Allocates one OGR Feature which should be destroyed by the caller.\n    Borrows a layer definition from the collection.\n    "), /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5fiona_6ogrext_OGRFeatureBuilder, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5fiona_6ogrext_OGRFeatureBuilder, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_5fiona_6ogrext_Session(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  if (__pyx_pf_5fiona_6ogrext_7Session___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5fiona_6ogrext_Session(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_5fiona_6ogrext_7Session_1__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_5fiona_6ogrext_Session[] = {
  {__Pyx_NAMESTR("start"), (PyCFunction)__pyx_pf_5fiona_6ogrext_7Session_2start, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("stop"), (PyCFunction)__pyx_pf_5fiona_6ogrext_7Session_3stop, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("get_length"), (PyCFunction)__pyx_pf_5fiona_6ogrext_7Session_4get_length, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("get_schema"), (PyCFunction)__pyx_pf_5fiona_6ogrext_7Session_5get_schema, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("get_crs"), (PyCFunction)__pyx_pf_5fiona_6ogrext_7Session_6get_crs, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("isactive"), (PyCFunction)__pyx_pf_5fiona_6ogrext_7Session_7isactive, METH_NOARGS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Session = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Session = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Session = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Session = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_5fiona_6ogrext_Session = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("fiona.ogrext.Session"), /*tp_name*/
  sizeof(struct __pyx_obj_5fiona_6ogrext_Session), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5fiona_6ogrext_Session, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Session, /*tp_as_number*/
  &__pyx_tp_as_sequence_Session, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Session, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Session, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5fiona_6ogrext_Session, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5fiona_6ogrext_Session, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_5fiona_6ogrext_WritingSession(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_tp_new_5fiona_6ogrext_Session(t, a, k);
  if (!o) return 0;
  return o;
}

static PyMethodDef __pyx_methods_5fiona_6ogrext_WritingSession[] = {
  {__Pyx_NAMESTR("start"), (PyCFunction)__pyx_pf_5fiona_6ogrext_14WritingSession_start, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pf_5fiona_6ogrext_14WritingSession_1write, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_WritingSession = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_WritingSession = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_WritingSession = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_WritingSession = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_5fiona_6ogrext_WritingSession = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("fiona.ogrext.WritingSession"), /*tp_name*/
  sizeof(struct __pyx_obj_5fiona_6ogrext_WritingSession), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5fiona_6ogrext_Session, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_WritingSession, /*tp_as_number*/
  &__pyx_tp_as_sequence_WritingSession, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_WritingSession, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_WritingSession, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5fiona_6ogrext_WritingSession, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5fiona_6ogrext_WritingSession, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_5fiona_6ogrext_Iterator(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_5fiona_6ogrext_Iterator *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_5fiona_6ogrext_Iterator *)o);
  p->collection = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_5fiona_6ogrext_Iterator(PyObject *o) {
  struct __pyx_obj_5fiona_6ogrext_Iterator *p = (struct __pyx_obj_5fiona_6ogrext_Iterator *)o;
  Py_XDECREF(p->collection);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_5fiona_6ogrext_Iterator(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5fiona_6ogrext_Iterator *p = (struct __pyx_obj_5fiona_6ogrext_Iterator *)o;
  if (p->collection) {
    e = (*v)(p->collection, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5fiona_6ogrext_Iterator(PyObject *o) {
  struct __pyx_obj_5fiona_6ogrext_Iterator *p = (struct __pyx_obj_5fiona_6ogrext_Iterator *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->collection);
  p->collection = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_5fiona_6ogrext_Iterator[] = {
  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_5fiona_6ogrext_8Iterator_2__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Iterator = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Iterator = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Iterator = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Iterator = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_5fiona_6ogrext_Iterator = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("fiona.ogrext.Iterator"), /*tp_name*/
  sizeof(struct __pyx_obj_5fiona_6ogrext_Iterator), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5fiona_6ogrext_Iterator, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Iterator, /*tp_as_number*/
  &__pyx_tp_as_sequence_Iterator, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Iterator, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Iterator, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Provides iterated access to feature data.\n    "), /*tp_doc*/
  __pyx_tp_traverse_5fiona_6ogrext_Iterator, /*tp_traverse*/
  __pyx_tp_clear_5fiona_6ogrext_Iterator, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_pf_5fiona_6ogrext_8Iterator_1__iter__, /*tp_iter*/
  __pyx_pf_5fiona_6ogrext_8Iterator_2__next__, /*tp_iternext*/
  __pyx_methods_5fiona_6ogrext_Iterator, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_5fiona_6ogrext_8Iterator___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5fiona_6ogrext_Iterator, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("ogrext"),
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 1},
  {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
  {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
  {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
  {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
  {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
  {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
  {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
  {&__pyx_n_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 1},
  {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
  {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
  {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0},
  {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0},
  {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
  {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
  {&__pyx_kp_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 0},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0},
  {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0},
  {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0},
  {&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0},
  {&__pyx_kp_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 0},
  {&__pyx_kp_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 0},
  {&__pyx_kp_s_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 0, 1, 0},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_kp_s_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 1, 0},
  {&__pyx_kp_s_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 0, 1, 0},
  {&__pyx_kp_s_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 1, 0},
  {&__pyx_kp_s_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 0},
  {&__pyx_kp_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 0},
  {&__pyx_kp_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 0},
  {&__pyx_kp_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 0},
  {&__pyx_kp_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 0},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_kp_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 0},
  {&__pyx_kp_s_51, __pyx_k_51, sizeof(__pyx_k_51), 0, 0, 1, 0},
  {&__pyx_kp_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 0},
  {&__pyx_kp_s_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 1, 0},
  {&__pyx_kp_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 0},
  {&__pyx_kp_s_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 0, 1, 0},
  {&__pyx_kp_s_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 0, 1, 0},
  {&__pyx_n_s_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 0, 1, 1},
  {&__pyx_n_s_63, __pyx_k_63, sizeof(__pyx_k_63), 0, 0, 1, 1},
  {&__pyx_n_s_64, __pyx_k_64, sizeof(__pyx_k_64), 0, 0, 1, 1},
  {&__pyx_n_s_65, __pyx_k_65, sizeof(__pyx_k_65), 0, 0, 1, 1},
  {&__pyx_n_s_66, __pyx_k_66, sizeof(__pyx_k_66), 0, 0, 1, 1},
  {&__pyx_n_s_67, __pyx_k_67, sizeof(__pyx_k_67), 0, 0, 1, 1},
  {&__pyx_n_s_68, __pyx_k_68, sizeof(__pyx_k_68), 0, 0, 1, 1},
  {&__pyx_n_s_69, __pyx_k_69, sizeof(__pyx_k_69), 0, 0, 1, 1},
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  {&__pyx_n_s_70, __pyx_k_70, sizeof(__pyx_k_70), 0, 0, 1, 1},
  {&__pyx_n_s_71, __pyx_k_71, sizeof(__pyx_k_71), 0, 0, 1, 1},
  {&__pyx_n_s_72, __pyx_k_72, sizeof(__pyx_k_72), 0, 0, 1, 1},
  {&__pyx_n_s_73, __pyx_k_73, sizeof(__pyx_k_73), 0, 0, 1, 1},
  {&__pyx_n_s_74, __pyx_k_74, sizeof(__pyx_k_74), 0, 0, 1, 1},
  {&__pyx_kp_s_75, __pyx_k_75, sizeof(__pyx_k_75), 0, 0, 1, 0},
  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
  {&__pyx_n_s__AssertionError, __pyx_k__AssertionError, sizeof(__pyx_k__AssertionError), 0, 0, 1, 1},
  {&__pyx_n_s__DimensionsHandler, __pyx_k__DimensionsHandler, sizeof(__pyx_k__DimensionsHandler), 0, 0, 1, 1},
  {&__pyx_n_s__FIELD_TYPES, __pyx_k__FIELD_TYPES, sizeof(__pyx_k__FIELD_TYPES), 0, 0, 1, 1},
  {&__pyx_n_s__FIELD_TYPES_MAP, __pyx_k__FIELD_TYPES_MAP, sizeof(__pyx_k__FIELD_TYPES_MAP), 0, 0, 1, 1},
  {&__pyx_n_s__Fiona, __pyx_k__Fiona, sizeof(__pyx_k__Fiona), 0, 0, 1, 1},
  {&__pyx_n_s__FloatType, __pyx_k__FloatType, sizeof(__pyx_k__FloatType), 0, 0, 1, 1},
  {&__pyx_n_s__GEOMETRY_TYPES, __pyx_k__GEOMETRY_TYPES, sizeof(__pyx_k__GEOMETRY_TYPES), 0, 0, 1, 1},
  {&__pyx_n_s__GeometryCollection, __pyx_k__GeometryCollection, sizeof(__pyx_k__GeometryCollection), 0, 0, 1, 1},
  {&__pyx_n_s__IntType, __pyx_k__IntType, sizeof(__pyx_k__IntType), 0, 0, 1, 1},
  {&__pyx_n_s__LineString, __pyx_k__LineString, sizeof(__pyx_k__LineString), 0, 0, 1, 1},
  {&__pyx_n_s__LinearRing, __pyx_k__LinearRing, sizeof(__pyx_k__LinearRing), 0, 0, 1, 1},
  {&__pyx_n_s__MultiLineString, __pyx_k__MultiLineString, sizeof(__pyx_k__MultiLineString), 0, 0, 1, 1},
  {&__pyx_n_s__MultiPoint, __pyx_k__MultiPoint, sizeof(__pyx_k__MultiPoint), 0, 0, 1, 1},
  {&__pyx_n_s__MultiPolygon, __pyx_k__MultiPolygon, sizeof(__pyx_k__MultiPolygon), 0, 0, 1, 1},
  {&__pyx_n_s__OGRERR_CORRUPT_DATA, __pyx_k__OGRERR_CORRUPT_DATA, sizeof(__pyx_k__OGRERR_CORRUPT_DATA), 0, 0, 1, 1},
  {&__pyx_n_s__OGRERR_FAILURE, __pyx_k__OGRERR_FAILURE, sizeof(__pyx_k__OGRERR_FAILURE), 0, 0, 1, 1},
  {&__pyx_n_s__OGRERR_NONE, __pyx_k__OGRERR_NONE, sizeof(__pyx_k__OGRERR_NONE), 0, 0, 1, 1},
  {&__pyx_n_s__OSError, __pyx_k__OSError, sizeof(__pyx_k__OSError), 0, 0, 1, 1},
  {&__pyx_n_s__Point, __pyx_k__Point, sizeof(__pyx_k__Point), 0, 0, 1, 1},
  {&__pyx_n_s__Polygon, __pyx_k__Polygon, sizeof(__pyx_k__Polygon), 0, 0, 1, 1},
  {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
  {&__pyx_n_s__StringType, __pyx_k__StringType, sizeof(__pyx_k__StringType), 0, 0, 1, 1},
  {&__pyx_n_s__UnicodeType, __pyx_k__UnicodeType, sizeof(__pyx_k__UnicodeType), 0, 0, 1, 1},
  {&__pyx_n_s__Unknown, __pyx_k__Unknown, sizeof(__pyx_k__Unknown), 0, 0, 1, 1},
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s___build, __pyx_k___build, sizeof(__pyx_k___build), 0, 0, 1, 1},
  {&__pyx_n_s___buildLineString, __pyx_k___buildLineString, sizeof(__pyx_k___buildLineString), 0, 0, 1, 1},
  {&__pyx_n_s___buildLinearRing, __pyx_k___buildLinearRing, sizeof(__pyx_k___buildLinearRing), 0, 0, 1, 1},
  {&__pyx_n_s___buildMultiPoint, __pyx_k___buildMultiPoint, sizeof(__pyx_k___buildMultiPoint), 0, 0, 1, 1},
  {&__pyx_n_s___buildMultiPolygon, __pyx_k___buildMultiPolygon, sizeof(__pyx_k___buildMultiPolygon), 0, 0, 1, 1},
  {&__pyx_n_s___buildPoint, __pyx_k___buildPoint, sizeof(__pyx_k___buildPoint), 0, 0, 1, 1},
  {&__pyx_n_s___buildPolygon, __pyx_k___buildPolygon, sizeof(__pyx_k___buildPolygon), 0, 0, 1, 1},
  {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1},
  {&__pyx_n_s__bbox, __pyx_k__bbox, sizeof(__pyx_k__bbox), 0, 0, 1, 1},
  {&__pyx_n_s__build_wkb, __pyx_k__build_wkb, sizeof(__pyx_k__build_wkb), 0, 0, 1, 1},
  {&__pyx_n_s__bytearray, __pyx_k__bytearray, sizeof(__pyx_k__bytearray), 0, 0, 1, 1},
  {&__pyx_n_s__collection, __pyx_k__collection, sizeof(__pyx_k__collection), 0, 0, 1, 1},
  {&__pyx_n_s__coordinates, __pyx_k__coordinates, sizeof(__pyx_k__coordinates), 0, 0, 1, 1},
  {&__pyx_n_s__crs, __pyx_k__crs, sizeof(__pyx_k__crs), 0, 0, 1, 1},
  {&__pyx_n_s__debug, __pyx_k__debug, sizeof(__pyx_k__debug), 0, 0, 1, 1},
  {&__pyx_n_s__driver, __pyx_k__driver, sizeof(__pyx_k__driver), 0, 0, 1, 1},
  {&__pyx_n_s__exists, __pyx_k__exists, sizeof(__pyx_k__exists), 0, 0, 1, 1},
  {&__pyx_n_s__feature, __pyx_k__feature, sizeof(__pyx_k__feature), 0, 0, 1, 1},
  {&__pyx_n_s__featureRT, __pyx_k__featureRT, sizeof(__pyx_k__featureRT), 0, 0, 1, 1},
  {&__pyx_n_s__fiona, __pyx_k__fiona, sizeof(__pyx_k__fiona), 0, 0, 1, 1},
  {&__pyx_n_s__float, __pyx_k__float, sizeof(__pyx_k__float), 0, 0, 1, 1},
  {&__pyx_n_s__geom_type, __pyx_k__geom_type, sizeof(__pyx_k__geom_type), 0, 0, 1, 1},
  {&__pyx_n_s__geometries, __pyx_k__geometries, sizeof(__pyx_k__geometries), 0, 0, 1, 1},
  {&__pyx_n_s__geometry, __pyx_k__geometry, sizeof(__pyx_k__geometry), 0, 0, 1, 1},
  {&__pyx_n_s__geometryRT, __pyx_k__geometryRT, sizeof(__pyx_k__geometryRT), 0, 0, 1, 1},
  {&__pyx_n_s__get, __pyx_k__get, sizeof(__pyx_k__get), 0, 0, 1, 1},
  {&__pyx_n_s__getLogger, __pyx_k__getLogger, sizeof(__pyx_k__getLogger), 0, 0, 1, 1},
  {&__pyx_n_s__getNumDims, __pyx_k__getNumDims, sizeof(__pyx_k__getNumDims), 0, 0, 1, 1},
  {&__pyx_n_s__getNumDimsPoint, __pyx_k__getNumDimsPoint, sizeof(__pyx_k__getNumDimsPoint), 0, 0, 1, 1},
  {&__pyx_n_s__getNumDimsPolygon, __pyx_k__getNumDimsPolygon, sizeof(__pyx_k__getNumDimsPolygon), 0, 0, 1, 1},
  {&__pyx_n_s__id, __pyx_k__id, sizeof(__pyx_k__id), 0, 0, 1, 1},
  {&__pyx_n_s__index, __pyx_k__index, sizeof(__pyx_k__index), 0, 0, 1, 1},
  {&__pyx_n_s__int, __pyx_k__int, sizeof(__pyx_k__int), 0, 0, 1, 1},
  {&__pyx_n_s__items, __pyx_k__items, sizeof(__pyx_k__items), 0, 0, 1, 1},
  {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
  {&__pyx_n_s__log, __pyx_k__log, sizeof(__pyx_k__log), 0, 0, 1, 1},
  {&__pyx_n_s__logging, __pyx_k__logging, sizeof(__pyx_k__logging), 0, 0, 1, 1},
  {&__pyx_n_s__lstrip, __pyx_k__lstrip, sizeof(__pyx_k__lstrip), 0, 0, 1, 1},
  {&__pyx_n_s__mode, __pyx_k__mode, sizeof(__pyx_k__mode), 0, 0, 1, 1},
  {&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1},
  {&__pyx_n_s__no_defs, __pyx_k__no_defs, sizeof(__pyx_k__no_defs), 0, 0, 1, 1},
  {&__pyx_n_s__object, __pyx_k__object, sizeof(__pyx_k__object), 0, 0, 1, 1},
  {&__pyx_n_s__ogrinit, __pyx_k__ogrinit, sizeof(__pyx_k__ogrinit), 0, 0, 1, 1},
  {&__pyx_n_s__os, __pyx_k__os, sizeof(__pyx_k__os), 0, 0, 1, 1},
  {&__pyx_n_s__path, __pyx_k__path, sizeof(__pyx_k__path), 0, 0, 1, 1},
  {&__pyx_n_s__properties, __pyx_k__properties, sizeof(__pyx_k__properties), 0, 0, 1, 1},
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
  {&__pyx_n_s__schema, __pyx_k__schema, sizeof(__pyx_k__schema), 0, 0, 1, 1},
  {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
  {&__pyx_n_s__session, __pyx_k__session, sizeof(__pyx_k__session), 0, 0, 1, 1},
  {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
  {&__pyx_n_s__stop, __pyx_k__stop, sizeof(__pyx_k__stop), 0, 0, 1, 1},
  {&__pyx_n_s__str, __pyx_k__str, sizeof(__pyx_k__str), 0, 0, 1, 1},
  {&__pyx_n_s__strip, __pyx_k__strip, sizeof(__pyx_k__strip), 0, 0, 1, 1},
  {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
  {&__pyx_n_s__type, __pyx_k__type, sizeof(__pyx_k__type), 0, 0, 1, 1},
  {&__pyx_n_s__types, __pyx_k__types, sizeof(__pyx_k__types), 0, 0, 1, 1},
  {&__pyx_n_s__w, __pyx_k__w, sizeof(__pyx_k__w), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_object = __Pyx_GetName(__pyx_b, __pyx_n_s__object); if (!__pyx_builtin_object) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_bytearray = __Pyx_GetName(__pyx_b, __pyx_n_s__bytearray); if (!__pyx_builtin_bytearray) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_OSError = __Pyx_GetName(__pyx_b, __pyx_n_s__OSError); if (!__pyx_builtin_OSError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_AssertionError = __Pyx_GetName(__pyx_b, __pyx_n_s__AssertionError); if (!__pyx_builtin_AssertionError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");

  /* "fiona/ogrext.pyx":230
 *                 log.debug("Adding values %f, %f", x, y)
 *                 ograpi.OGR_G_AddPoint_2D(cogr_geometry, x, y)
 *         log.debug("Closing ring")             # <<<<<<<<<<<<<<
 *         ograpi.OGR_G_CloseRings(cogr_geometry)
 *         return cogr_geometry
 */
  __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_6));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
  PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, ((PyObject *)__pyx_kp_s_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6));

  /* "fiona/ogrext.pyx":243
 *             cogr_ring = OGRGeomBuilder().build(
 *                 {'type': 'LinearRing', 'coordinates': ring} )
 *             log.debug("Built ring")             # <<<<<<<<<<<<<<
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_ring)
 *             log.debug("Added ring %s", ring)
 */
  __pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_9));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
  PyTuple_SET_ITEM(__pyx_k_tuple_9, 0, ((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_9));

  /* "fiona/ogrext.pyx":273
 *             cogr_part = OGRGeomBuilder().build(
 *                 {'type': 'LineString', 'coordinates': line} )
 *             log.debug("Built line")             # <<<<<<<<<<<<<<
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added line %s", line)
 */
  __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_14));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
  PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, ((PyObject *)__pyx_kp_s_13));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14));

  /* "fiona/ogrext.pyx":286
 *             cogr_part = OGRGeomBuilder().build(
 *                 {'type': 'Polygon', 'coordinates': part} )
 *             log.debug("Built polygon")             # <<<<<<<<<<<<<<
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added polygon %s", part)
 */
  __pyx_k_tuple_18 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_18));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  PyTuple_SET_ITEM(__pyx_k_tuple_18, 0, ((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_18));

  /* "fiona/ogrext.pyx":298
 *             log.debug("Adding part %s", part)
 *             cogr_part = OGRGeomBuilder().build(part)
 *             log.debug("Built part")             # <<<<<<<<<<<<<<
 *             ograpi.OGR_G_AddGeometryDirectly(cogr_geometry, cogr_part)
 *             log.debug("Added part %s", part)
 */
  __pyx_k_tuple_22 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_22));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_21));
  PyTuple_SET_ITEM(__pyx_k_tuple_22, 0, ((PyObject *)__pyx_kp_s_21));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_21));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_22));

  /* "fiona/ogrext.pyx":306
 *         handler = DimensionsHandler()
 *         self.typename = geometry['type']
 *         self.coordinates = geometry.get('coordinates')             # <<<<<<<<<<<<<<
 *         if self.coordinates:
 *             self.ndims = handler.getNumDims(self.typename, self.coordinates)
 */
  __pyx_k_tuple_24 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_24));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__coordinates));
  PyTuple_SET_ITEM(__pyx_k_tuple_24, 0, ((PyObject *)__pyx_n_s__coordinates));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__coordinates));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_24));

  /* "fiona/ogrext.pyx":324
 *             return self._buildMultiPolygon()
 *         elif self.typename == 'GeometryCollection':
 *             self.coordinates = geometry.get('geometries')             # <<<<<<<<<<<<<<
 *             self.ndims = handler.getNumDims(self.typename, self.coordinates)
 *             return self._buildGeometryCollection()
 */
  __pyx_k_tuple_25 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_25));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__geometries));
  PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((PyObject *)__pyx_n_s__geometries));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__geometries));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25));

  /* "fiona/ogrext.pyx":504
 *         assert self.cogr_layer is not NULL
 *         cdef void *cogr_crs = ograpi.OGR_L_GetSpatialRef(self.cogr_layer)
 *         log.debug("Got coordinate system")             # <<<<<<<<<<<<<<
 *         crs = {}
 *         if cogr_crs is not NULL:
 */
  __pyx_k_tuple_32 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_32));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_31));
  PyTuple_SET_ITEM(__pyx_k_tuple_32, 0, ((PyObject *)__pyx_kp_s_31));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_32));

  /* "fiona/ogrext.pyx":513
 *             value = value.strip()
 *             for param in value.split():
 *                 kv = param.split("=")             # <<<<<<<<<<<<<<
 *                 if len(kv) == 2:
 *                     k, v = kv
 */
  __pyx_k_tuple_35 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_35));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
  PyTuple_SET_ITEM(__pyx_k_tuple_35, 0, ((PyObject *)__pyx_kp_s_34));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_34));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_35));

  /* "fiona/ogrext.pyx":527
 *                 else:
 *                     raise ValueError("Unexpected proj parameter %s" % param)
 *                 k = k.lstrip("+")             # <<<<<<<<<<<<<<
 *                 crs[k] = v
 *             ograpi.CPLFree(proj)
 */
  __pyx_k_tuple_38 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_38));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_37));
  PyTuple_SET_ITEM(__pyx_k_tuple_38, 0, ((PyObject *)__pyx_kp_s_37));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_37));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_38));

  /* "fiona/ogrext.pyx":531
 *             ograpi.CPLFree(proj)
 *         else:
 *             log.debug("Projection not found (cogr_crs was NULL)")             # <<<<<<<<<<<<<<
 *         return crs
 * 
 */
  __pyx_k_tuple_40 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_40));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_39));
  PyTuple_SET_ITEM(__pyx_k_tuple_40, 0, ((PyObject *)__pyx_kp_s_39));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_39));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_40));

  /* "fiona/ogrext.pyx":601
 *                 )
 *             assert self.cogr_layer is not NULL
 *             log.debug("Created layer")             # <<<<<<<<<<<<<<
 * 
 *             # Next, make a layer definition from the given schema.
 */
  __pyx_k_tuple_49 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_49));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_48));
  PyTuple_SET_ITEM(__pyx_k_tuple_49, 0, ((PyObject *)__pyx_kp_s_48));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_48));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_49));

  /* "fiona/ogrext.pyx":612
 *                 ograpi.OGR_L_CreateField(self.cogr_layer, cogr_fielddefn, 1)
 *                 ograpi.OGR_Fld_Destroy(cogr_fielddefn)
 *             log.debug("Created fields")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_k_tuple_52 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_52));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_51));
  PyTuple_SET_ITEM(__pyx_k_tuple_52, 0, ((PyObject *)__pyx_kp_s_51));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_51));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_52));

  /* "fiona/ogrext.pyx":615
 * 
 * 
 *         log.debug("Writing started")             # <<<<<<<<<<<<<<
 * 
 *     def write(self, feature, collection):
 */
  __pyx_k_tuple_54 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_54));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_53));
  PyTuple_SET_ITEM(__pyx_k_tuple_54, 0, ((PyObject *)__pyx_kp_s_53));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_53));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_54));

  /* "fiona/ogrext.pyx":624
 *             assert feature['geometry']['type'] == collection.schema['geometry']
 *         except AssertionError:
 *             raise ValueError("Feature data not match collection schema")             # <<<<<<<<<<<<<<
 * 
 *         cdef void *cogr_layer = self.cogr_layer
 */
  __pyx_k_tuple_57 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_57));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_56));
  PyTuple_SET_ITEM(__pyx_k_tuple_57, 0, ((PyObject *)__pyx_kp_s_56));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_56));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_57));

  /* "fiona/ogrext.pyx":646
 *     def __init__(self, collection, bbox=None):
 *         if collection.session is None:
 *             raise ValueError("I/O operation on closed collection")             # <<<<<<<<<<<<<<
 *         self.collection = collection
 *         cdef Session session
 */
  __pyx_k_tuple_60 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_60));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
  PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_kp_s_59));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60));

  /* "fiona/ogrext.pyx":11
 * from fiona import ogrinit
 * 
 * log = logging.getLogger("Fiona")             # <<<<<<<<<<<<<<
 * 
 * # Mapping of OGR integer geometry types to GeoJSON type names.
 */
  __pyx_k_tuple_61 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_61));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Fiona));
  PyTuple_SET_ITEM(__pyx_k_tuple_61, 0, ((PyObject *)__pyx_n_s__Fiona));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Fiona));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61));
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_7 = PyInt_FromLong(7); if (unlikely(!__pyx_int_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initogrext(void); /*proto*/
PyMODINIT_FUNC initogrext(void)
#else
PyMODINIT_FUNC PyInit_ogrext(void); /*proto*/
PyMODINIT_FUNC PyInit_ogrext(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_ogrext(void)");
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __pyx_binding_PyCFunctionType_USED
  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("ogrext"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_fiona__ogrext) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_5fiona_6ogrext_GeomBuilder = &__pyx_vtable_5fiona_6ogrext_GeomBuilder;
  __pyx_vtable_5fiona_6ogrext_GeomBuilder._buildCoords = (PyObject *(*)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, void *))__pyx_f_5fiona_6ogrext_11GeomBuilder__buildCoords;
  __pyx_vtable_5fiona_6ogrext_GeomBuilder._buildPoint = (PyObject *(*)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_5fiona_6ogrext_11GeomBuilder__buildPoint;
  __pyx_vtable_5fiona_6ogrext_GeomBuilder._buildLineString = (PyObject *(*)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_5fiona_6ogrext_11GeomBuilder__buildLineString;
  __pyx_vtable_5fiona_6ogrext_GeomBuilder._buildLinearRing = (PyObject *(*)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_5fiona_6ogrext_11GeomBuilder__buildLinearRing;
  __pyx_vtable_5fiona_6ogrext_GeomBuilder._buildParts = (PyObject *(*)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, void *))__pyx_f_5fiona_6ogrext_11GeomBuilder__buildParts;
  __pyx_vtable_5fiona_6ogrext_GeomBuilder._buildPolygon = (PyObject *(*)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_5fiona_6ogrext_11GeomBuilder__buildPolygon;
  __pyx_vtable_5fiona_6ogrext_GeomBuilder._buildMultiPoint = (PyObject *(*)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_5fiona_6ogrext_11GeomBuilder__buildMultiPoint;
  __pyx_vtable_5fiona_6ogrext_GeomBuilder._buildMultiLineString = (PyObject *(*)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_5fiona_6ogrext_11GeomBuilder__buildMultiLineString;
  __pyx_vtable_5fiona_6ogrext_GeomBuilder._buildMultiPolygon = (PyObject *(*)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_5fiona_6ogrext_11GeomBuilder__buildMultiPolygon;
  __pyx_vtable_5fiona_6ogrext_GeomBuilder._buildGeometryCollection = (PyObject *(*)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, int __pyx_skip_dispatch))__pyx_f_5fiona_6ogrext_11GeomBuilder__buildGeometryCollection;
  __pyx_vtable_5fiona_6ogrext_GeomBuilder.build = (PyObject *(*)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, void *))__pyx_f_5fiona_6ogrext_11GeomBuilder_build;
  __pyx_vtable_5fiona_6ogrext_GeomBuilder.build_wkb = (PyObject *(*)(struct __pyx_obj_5fiona_6ogrext_GeomBuilder *, PyObject *, int __pyx_skip_dispatch))__pyx_f_5fiona_6ogrext_11GeomBuilder_build_wkb;
  if (PyType_Ready(&__pyx_type_5fiona_6ogrext_GeomBuilder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_5fiona_6ogrext_GeomBuilder.tp_dict, __pyx_vtabptr_5fiona_6ogrext_GeomBuilder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "GeomBuilder", (PyObject *)&__pyx_type_5fiona_6ogrext_GeomBuilder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5fiona_6ogrext_GeomBuilder = &__pyx_type_5fiona_6ogrext_GeomBuilder;
  __pyx_vtabptr_5fiona_6ogrext_OGRGeomBuilder = &__pyx_vtable_5fiona_6ogrext_OGRGeomBuilder;
  __pyx_vtable_5fiona_6ogrext_OGRGeomBuilder._buildPoint = (void *(*)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *))__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildPoint;
  __pyx_vtable_5fiona_6ogrext_OGRGeomBuilder._buildLineString = (void *(*)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *))__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildLineString;
  __pyx_vtable_5fiona_6ogrext_OGRGeomBuilder._buildLinearRing = (void *(*)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *))__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildLinearRing;
  __pyx_vtable_5fiona_6ogrext_OGRGeomBuilder._buildPolygon = (void *(*)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *))__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildPolygon;
  __pyx_vtable_5fiona_6ogrext_OGRGeomBuilder._buildMultiPoint = (void *(*)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *))__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildMultiPoint;
  __pyx_vtable_5fiona_6ogrext_OGRGeomBuilder._buildMultiLineString = (void *(*)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *))__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildMultiLineString;
  __pyx_vtable_5fiona_6ogrext_OGRGeomBuilder._buildMultiPolygon = (void *(*)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *))__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildMultiPolygon;
  __pyx_vtable_5fiona_6ogrext_OGRGeomBuilder._buildGeometryCollection = (void *(*)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *))__pyx_f_5fiona_6ogrext_14OGRGeomBuilder__buildGeometryCollection;
  __pyx_vtable_5fiona_6ogrext_OGRGeomBuilder.build = (void *(*)(struct __pyx_obj_5fiona_6ogrext_OGRGeomBuilder *, PyObject *))__pyx_f_5fiona_6ogrext_14OGRGeomBuilder_build;
  if (PyType_Ready(&__pyx_type_5fiona_6ogrext_OGRGeomBuilder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_5fiona_6ogrext_OGRGeomBuilder.tp_dict, __pyx_vtabptr_5fiona_6ogrext_OGRGeomBuilder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "OGRGeomBuilder", (PyObject *)&__pyx_type_5fiona_6ogrext_OGRGeomBuilder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5fiona_6ogrext_OGRGeomBuilder = &__pyx_type_5fiona_6ogrext_OGRGeomBuilder;
  __pyx_vtabptr_5fiona_6ogrext_FeatureBuilder = &__pyx_vtable_5fiona_6ogrext_FeatureBuilder;
  __pyx_vtable_5fiona_6ogrext_FeatureBuilder.build = (PyObject *(*)(struct __pyx_obj_5fiona_6ogrext_FeatureBuilder *, void *))__pyx_f_5fiona_6ogrext_14FeatureBuilder_build;
  if (PyType_Ready(&__pyx_type_5fiona_6ogrext_FeatureBuilder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_5fiona_6ogrext_FeatureBuilder.tp_dict, __pyx_vtabptr_5fiona_6ogrext_FeatureBuilder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "FeatureBuilder", (PyObject *)&__pyx_type_5fiona_6ogrext_FeatureBuilder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5fiona_6ogrext_FeatureBuilder = &__pyx_type_5fiona_6ogrext_FeatureBuilder;
  __pyx_vtabptr_5fiona_6ogrext_OGRFeatureBuilder = &__pyx_vtable_5fiona_6ogrext_OGRFeatureBuilder;
  __pyx_vtable_5fiona_6ogrext_OGRFeatureBuilder.build = (void *(*)(struct __pyx_obj_5fiona_6ogrext_OGRFeatureBuilder *, PyObject *, PyObject *))__pyx_f_5fiona_6ogrext_17OGRFeatureBuilder_build;
  if (PyType_Ready(&__pyx_type_5fiona_6ogrext_OGRFeatureBuilder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_5fiona_6ogrext_OGRFeatureBuilder.tp_dict, __pyx_vtabptr_5fiona_6ogrext_OGRFeatureBuilder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "OGRFeatureBuilder", (PyObject *)&__pyx_type_5fiona_6ogrext_OGRFeatureBuilder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5fiona_6ogrext_OGRFeatureBuilder = &__pyx_type_5fiona_6ogrext_OGRFeatureBuilder;
  if (PyType_Ready(&__pyx_type_5fiona_6ogrext_Session) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Session", (PyObject *)&__pyx_type_5fiona_6ogrext_Session) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5fiona_6ogrext_Session = &__pyx_type_5fiona_6ogrext_Session;
  __pyx_type_5fiona_6ogrext_WritingSession.tp_base = __pyx_ptype_5fiona_6ogrext_Session;
  if (PyType_Ready(&__pyx_type_5fiona_6ogrext_WritingSession) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "WritingSession", (PyObject *)&__pyx_type_5fiona_6ogrext_WritingSession) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5fiona_6ogrext_WritingSession = &__pyx_type_5fiona_6ogrext_WritingSession;
  if (PyType_Ready(&__pyx_type_5fiona_6ogrext_Iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Iterator", (PyObject *)&__pyx_type_5fiona_6ogrext_Iterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5fiona_6ogrext_Iterator = &__pyx_type_5fiona_6ogrext_Iterator;
  /*--- Type import code ---*/
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "fiona/ogrext.pyx":3
 * # These are extension functions and classes using the OGR C API.
 * 
 * import logging             # <<<<<<<<<<<<<<
 * import os
 * import sys
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__logging), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__logging, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":4
 * 
 * import logging
 * import os             # <<<<<<<<<<<<<<
 * import sys
 * from types import IntType, FloatType, StringType, UnicodeType
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__os), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":5
 * import logging
 * import os
 * import sys             # <<<<<<<<<<<<<<
 * from types import IntType, FloatType, StringType, UnicodeType
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":6
 * import os
 * import sys
 * from types import IntType, FloatType, StringType, UnicodeType             # <<<<<<<<<<<<<<
 * 
 * from fiona cimport ograpi
 */
  __pyx_t_1 = PyList_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__IntType));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__IntType));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IntType));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__FloatType));
  PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__FloatType));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__FloatType));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__StringType));
  PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__StringType));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__StringType));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__UnicodeType));
  PyList_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__UnicodeType));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__UnicodeType));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__types), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__IntType); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__IntType, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__FloatType); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__FloatType, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__StringType); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StringType, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__UnicodeType); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__UnicodeType, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":9
 * 
 * from fiona cimport ograpi
 * from fiona import ogrinit             # <<<<<<<<<<<<<<
 * 
 * log = logging.getLogger("Fiona")
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__ogrinit));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__ogrinit));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ogrinit));
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__fiona), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__ogrinit); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ogrinit, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":11
 * from fiona import ogrinit
 * 
 * log = logging.getLogger("Fiona")             # <<<<<<<<<<<<<<
 * 
 * # Mapping of OGR integer geometry types to GeoJSON type names.
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__logging); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__getLogger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_61), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__log, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":14
 * 
 * # Mapping of OGR integer geometry types to GeoJSON type names.
 * GEOMETRY_TYPES = [             # <<<<<<<<<<<<<<
 *     'Unknown', 'Point', 'LineString', 'Polygon', 'MultiPoint',
 *     'MultiLineString', 'MultiPolygon', 'GeometryCollection' ]
 */
  __pyx_t_1 = PyList_New(8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Unknown));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__Unknown));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Unknown));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Point));
  PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__Point));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Point));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__LineString));
  PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__LineString));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LineString));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Polygon));
  PyList_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__Polygon));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Polygon));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__MultiPoint));
  PyList_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__MultiPoint));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__MultiPoint));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__MultiLineString));
  PyList_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__MultiLineString));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__MultiLineString));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__MultiPolygon));
  PyList_SET_ITEM(__pyx_t_1, 6, ((PyObject *)__pyx_n_s__MultiPolygon));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__MultiPolygon));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__GeometryCollection));
  PyList_SET_ITEM(__pyx_t_1, 7, ((PyObject *)__pyx_n_s__GeometryCollection));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__GeometryCollection));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__GEOMETRY_TYPES, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":34
 *     None,           # OFTDate, Date
 *     None,           # OFTTime, Time
 *     None,           # OFTDateTime, Date and Time             # <<<<<<<<<<<<<<
 *     ]
 * 
 */
  __pyx_t_1 = PyList_New(12); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__int));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__int));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__int));
  __Pyx_INCREF(Py_None);
  PyList_SET_ITEM(__pyx_t_1, 1, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__float));
  PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__float));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__float));
  __Pyx_INCREF(Py_None);
  PyList_SET_ITEM(__pyx_t_1, 3, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__str));
  PyList_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__str));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__str));
  __Pyx_INCREF(Py_None);
  PyList_SET_ITEM(__pyx_t_1, 5, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_INCREF(Py_None);
  PyList_SET_ITEM(__pyx_t_1, 6, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_INCREF(Py_None);
  PyList_SET_ITEM(__pyx_t_1, 7, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_INCREF(Py_None);
  PyList_SET_ITEM(__pyx_t_1, 8, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_INCREF(Py_None);
  PyList_SET_ITEM(__pyx_t_1, 9, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_INCREF(Py_None);
  PyList_SET_ITEM(__pyx_t_1, 10, Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_INCREF(Py_None);
  PyList_SET_ITEM(__pyx_t_1, 11, Py_None);
  __Pyx_GIVEREF(Py_None);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__FIELD_TYPES, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":38
 * 
 * # Mapping of Fiona field type names to Python types.
 * FIELD_TYPES_MAP = {             # <<<<<<<<<<<<<<
 *     'int':      IntType,
 *     'float':    FloatType,
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));

  /* "fiona/ogrext.pyx":39
 * # Mapping of Fiona field type names to Python types.
 * FIELD_TYPES_MAP = {
 *     'int':      IntType,             # <<<<<<<<<<<<<<
 *     'float':    FloatType,
 *     'str':      UnicodeType,
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__IntType); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__int), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":40
 * FIELD_TYPES_MAP = {
 *     'int':      IntType,
 *     'float':    FloatType,             # <<<<<<<<<<<<<<
 *     'str':      UnicodeType,
 *     }
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__FloatType); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__float), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":41
 *     'int':      IntType,
 *     'float':    FloatType,
 *     'str':      UnicodeType,             # <<<<<<<<<<<<<<
 *     }
 * 
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__UnicodeType); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__str), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__FIELD_TYPES_MAP, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":46
 * # OGR integer error types.
 * 
 * OGRERR_NONE = 0             # <<<<<<<<<<<<<<
 * OGRERR_NOT_ENOUGH_DATA = 1    # not enough data to deserialize *[inserted by cython to avoid comment closer]/
 * OGRERR_NOT_ENOUGH_MEMORY = 2
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__OGRERR_NONE, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "fiona/ogrext.pyx":47
 * 
 * OGRERR_NONE = 0
 * OGRERR_NOT_ENOUGH_DATA = 1    # not enough data to deserialize *[inserted by cython to avoid comment closer]/             # <<<<<<<<<<<<<<
 * OGRERR_NOT_ENOUGH_MEMORY = 2
 * OGRERR_UNSUPPORTED_GEOMETRY_TYPE = 3
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_62, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "fiona/ogrext.pyx":48
 * OGRERR_NONE = 0
 * OGRERR_NOT_ENOUGH_DATA = 1    # not enough data to deserialize *[inserted by cython to avoid comment closer]/
 * OGRERR_NOT_ENOUGH_MEMORY = 2             # <<<<<<<<<<<<<<
 * OGRERR_UNSUPPORTED_GEOMETRY_TYPE = 3
 * OGRERR_UNSUPPORTED_OPERATION = 4
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_63, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "fiona/ogrext.pyx":49
 * OGRERR_NOT_ENOUGH_DATA = 1    # not enough data to deserialize *[inserted by cython to avoid comment closer]/
 * OGRERR_NOT_ENOUGH_MEMORY = 2
 * OGRERR_UNSUPPORTED_GEOMETRY_TYPE = 3             # <<<<<<<<<<<<<<
 * OGRERR_UNSUPPORTED_OPERATION = 4
 * OGRERR_CORRUPT_DATA = 5
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_64, __pyx_int_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "fiona/ogrext.pyx":50
 * OGRERR_NOT_ENOUGH_MEMORY = 2
 * OGRERR_UNSUPPORTED_GEOMETRY_TYPE = 3
 * OGRERR_UNSUPPORTED_OPERATION = 4             # <<<<<<<<<<<<<<
 * OGRERR_CORRUPT_DATA = 5
 * OGRERR_FAILURE = 6
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_65, __pyx_int_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "fiona/ogrext.pyx":51
 * OGRERR_UNSUPPORTED_GEOMETRY_TYPE = 3
 * OGRERR_UNSUPPORTED_OPERATION = 4
 * OGRERR_CORRUPT_DATA = 5             # <<<<<<<<<<<<<<
 * OGRERR_FAILURE = 6
 * OGRERR_UNSUPPORTED_SRS = 7
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__OGRERR_CORRUPT_DATA, __pyx_int_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "fiona/ogrext.pyx":52
 * OGRERR_UNSUPPORTED_OPERATION = 4
 * OGRERR_CORRUPT_DATA = 5
 * OGRERR_FAILURE = 6             # <<<<<<<<<<<<<<
 * OGRERR_UNSUPPORTED_SRS = 7
 * OGRERR_INVALID_HANDLE = 8
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__OGRERR_FAILURE, __pyx_int_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "fiona/ogrext.pyx":53
 * OGRERR_CORRUPT_DATA = 5
 * OGRERR_FAILURE = 6
 * OGRERR_UNSUPPORTED_SRS = 7             # <<<<<<<<<<<<<<
 * OGRERR_INVALID_HANDLE = 8
 * 
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_66, __pyx_int_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "fiona/ogrext.pyx":54
 * OGRERR_FAILURE = 6
 * OGRERR_UNSUPPORTED_SRS = 7
 * OGRERR_INVALID_HANDLE = 8             # <<<<<<<<<<<<<<
 * 
 * # Geometry related functions and classes follow.
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_67, __pyx_int_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "fiona/ogrext.pyx":74
 * 
 * 
 * class DimensionsHandler(object):             # <<<<<<<<<<<<<<
 *     """Determines the number of dimensions of a Fiona geometry.
 *     """
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));

  /* "fiona/ogrext.pyx":77
 *     """Determines the number of dimensions of a Fiona geometry.
 *     """
 *     coordinates = None             # <<<<<<<<<<<<<<
 * 
 *     def getNumDimsPoint(self):
 */
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__coordinates, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "fiona/ogrext.pyx":79
 *     coordinates = None
 * 
 *     def getNumDimsPoint(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates)
 * 
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_5fiona_6ogrext_17DimensionsHandler_getNumDimsPoint, NULL, __pyx_n_s_68); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__getNumDimsPoint, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":82
 *         return len(self.coordinates)
 * 
 *     def getNumDimsLineString(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates[0])
 * 
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_5fiona_6ogrext_17DimensionsHandler_1getNumDimsLineString, NULL, __pyx_n_s_68); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_69, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":85
 *         return len(self.coordinates[0])
 * 
 *     def getNumDimsLinearRing(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates[0])
 * 
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_5fiona_6ogrext_17DimensionsHandler_2getNumDimsLinearRing, NULL, __pyx_n_s_68); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_70, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":88
 *         return len(self.coordinates[0])
 * 
 *     def getNumDimsPolygon(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates[0][0])
 * 
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_5fiona_6ogrext_17DimensionsHandler_3getNumDimsPolygon, NULL, __pyx_n_s_68); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__getNumDimsPolygon, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":91
 *         return len(self.coordinates[0][0])
 * 
 *     def getNumDimsMultiPoint(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates[0])
 * 
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_5fiona_6ogrext_17DimensionsHandler_4getNumDimsMultiPoint, NULL, __pyx_n_s_68); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_71, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":94
 *         return len(self.coordinates[0])
 * 
 *     def getNumDimsMultiLineString(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates[0][0])
 * 
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_5fiona_6ogrext_17DimensionsHandler_5getNumDimsMultiLineString, NULL, __pyx_n_s_68); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_72, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":97
 *         return len(self.coordinates[0][0])
 * 
 *     def getNumDimsMultiPolygon(self):             # <<<<<<<<<<<<<<
 *         return len(self.coordinates[0][0][0])
 * 
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_5fiona_6ogrext_17DimensionsHandler_6getNumDimsMultiPolygon, NULL, __pyx_n_s_68); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_73, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":100
 *         return len(self.coordinates[0][0][0])
 * 
 *     def getNumDimsGeometryCollection(self):             # <<<<<<<<<<<<<<
 *         first = self.coordinates[0]
 *         return self.getNumDims(first['type'], first['coordinates'])
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_5fiona_6ogrext_17DimensionsHandler_7getNumDimsGeometryCollection, NULL, __pyx_n_s_68); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_74, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":104
 *         return self.getNumDims(first['type'], first['coordinates'])
 * 
 *     def getNumDims(self, geom_type, coordinates):             # <<<<<<<<<<<<<<
 *         self.coordinates = coordinates
 *         return getattr(self, 'getNumDims' + geom_type)()
 */
  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_5fiona_6ogrext_17DimensionsHandler_8getNumDims, NULL, __pyx_n_s_68); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__getNumDims, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "fiona/ogrext.pyx":74
 * 
 * 
 * class DimensionsHandler(object):             # <<<<<<<<<<<<<<
 *     """Determines the number of dimensions of a Fiona geometry.
 *     """
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_builtin_object);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_object);
  __Pyx_GIVEREF(__pyx_builtin_object);
  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_75)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__DimensionsHandler, __pyx_n_s_68); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DimensionsHandler, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":336
 * 
 * 
 * def geometryRT(geometry):             # <<<<<<<<<<<<<<
 *     # For testing purposes only, leaks the JSON data
 *     cdef void *cogr_geometry = OGRGeomBuilder().build(geometry)
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5fiona_6ogrext_geometryRT, NULL, __pyx_n_s_68); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__geometryRT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":434
 * 
 * 
 * def featureRT(feature, collection):             # <<<<<<<<<<<<<<
 *     # For testing purposes only, leaks the JSON data
 *     cdef void *cogr_feature = OGRFeatureBuilder().build(feature, collection)
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5fiona_6ogrext_1featureRT, NULL, __pyx_n_s_68); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__featureRT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "fiona/ogrext.pyx":1
 * # These are extension functions and classes using the OGR C API.             # <<<<<<<<<<<<<<
 * 
 * import logging
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  if (__pyx_m) {
    __Pyx_AddTraceback("init fiona.ogrext", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init fiona.ogrext");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */

#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif /* CYTHON_REFNANNY */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result) {
        if (dict != __pyx_b) {
            PyErr_Clear();
            result = PyObject_GetAttr(__pyx_b, name);
        }
        if (!result) {
            PyErr_SetObject(PyExc_NameError, name);
        }
    }
    return result;
}


static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;

    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;

    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
            #endif
                goto invalid_keyword_type;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        _PyString_Eq(**name, key)) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    /* unexpected keyword found */
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %"PY_FORMAT_SIZE_T"d value%s to unpack",
                 index, (index == 1) ? "" : "s");
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %"PY_FORMAT_SIZE_T"d)", expected);
}

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else if (PyErr_Occurred()) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();

    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;

    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}


#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    /* cause is unused */
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                type = 0;
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) Py_TYPE(type);
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }

    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

#else /* Python 3+ */

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;

    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (!PyExceptionClass_Check(type)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }

    if (cause) {
        PyObject *fixed_cause;
        if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        }
        else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        }
        else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        if (!value) {
            value = PyObject_CallObject(type, NULL);
        }
        PyException_SetCause(value, fixed_cause);
    }

    PyErr_SetObject(type, value);

    if (tb) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }

bad:
    return;
}
#endif

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #else
        if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key)))
        #endif
            goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

static double __Pyx__PyObject_AsDouble(PyObject* obj) {
    PyObject* float_value;
    if (Py_TYPE(obj)->tp_as_number && Py_TYPE(obj)->tp_as_number->nb_float) {
        return PyFloat_AsDouble(obj);
    } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
#if PY_MAJOR_VERSION >= 3
        float_value = PyFloat_FromString(obj);
#else
        float_value = PyFloat_FromString(obj, 0);
#endif
    } else {
        PyObject* args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        PyTuple_SET_ITEM(args, 0, obj);
        float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
        PyTuple_SET_ITEM(args, 0, 0);
        Py_DECREF(args);
    }
    if (likely(float_value)) {
        double value = PyFloat_AS_DOUBLE(float_value);
        Py_DECREF(float_value);
        return value;
    }
bad:
    return (double)-1;
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
    if (unlikely(tstate->curexc_type))
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
        goto bad;
    #endif
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
    Py_INCREF(local_type);
    Py_INCREF(local_value);
    Py_INCREF(local_tb);
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    /* Make sure tstate is in a consistent state when we XDECREF
       these objects (XDECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}


static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}

static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
    PyObject *py_import = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
    if (!py_import)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    #if PY_VERSION_HEX >= 0x02050000
    {
        PyObject *py_level = PyInt_FromLong(level);
        if (!py_level)
            goto bad;
        module = PyObject_CallFunctionObjArgs(py_import,
            name, global_dict, empty_dict, list, py_level, NULL);
        Py_DECREF(py_level);
    }
    #else
    if (level>0) {
        PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
        goto bad;
    }
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
    #endif
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(py_import);
    Py_XDECREF(empty_dict);
    return module;
}

static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
    PyObject *metaclass;
    /* Default metaclass */
#if PY_MAJOR_VERSION < 3
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = PyObject_GetAttrString(base, (char *)"__class__");
        if (!metaclass) {
            PyErr_Clear();
            metaclass = (PyObject*) Py_TYPE(base);
        }
    } else {
        metaclass = (PyObject *) &PyClass_Type;
    }
#else
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = (PyObject*) Py_TYPE(base);
    } else {
        metaclass = (PyObject *) &PyType_Type;
    }
#endif
    Py_INCREF(metaclass);
    return metaclass;
}

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
                                   PyObject *modname) {
    PyObject *result;
    PyObject *metaclass;

    if (PyDict_SetItemString(dict, "__module__", modname) < 0)
        return NULL;

    /* Python2 __metaclass__ */
    metaclass = PyDict_GetItemString(dict, "__metaclass__");
    if (metaclass) {
        Py_INCREF(metaclass);
    } else {
        metaclass = __Pyx_FindPy2Metaclass(bases);
    }
    result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL);
    Py_DECREF(metaclass);
    return result;
}


static PyObject *__pyx_binding_PyCFunctionType_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module) {
    __pyx_binding_PyCFunctionType_object *op = PyObject_GC_New(__pyx_binding_PyCFunctionType_object, __pyx_binding_PyCFunctionType);
    if (op == NULL)
        return NULL;
    op->func.m_ml = ml;
    Py_XINCREF(self);
    op->func.m_self = self;
    Py_XINCREF(module);
    op->func.m_module = module;
    PyObject_GC_Track(op);
    return (PyObject *)op;
}

static void __pyx_binding_PyCFunctionType_dealloc(__pyx_binding_PyCFunctionType_object *m) {
    PyObject_GC_UnTrack(m);
    Py_XDECREF(m->func.m_self);
    Py_XDECREF(m->func.m_module);
    PyObject_GC_Del(m);
}

static PyObject *__pyx_binding_PyCFunctionType_descr_get(PyObject *func, PyObject *obj, PyObject *type) {
    if (obj == Py_None)
            obj = NULL;
    return PyMethod_New(func, obj, type);
}

static int __pyx_binding_PyCFunctionType_init(void) {
    __pyx_binding_PyCFunctionType_type = PyCFunction_Type;
    __pyx_binding_PyCFunctionType_type.tp_name = __Pyx_NAMESTR("cython_binding_builtin_function_or_method");
    __pyx_binding_PyCFunctionType_type.tp_dealloc = (destructor)__pyx_binding_PyCFunctionType_dealloc;
    __pyx_binding_PyCFunctionType_type.tp_descr_get = __pyx_binding_PyCFunctionType_descr_get;
    if (PyType_Ready(&__pyx_binding_PyCFunctionType_type) < 0) {
        return -1;
    }
    __pyx_binding_PyCFunctionType = &__pyx_binding_PyCFunctionType_type;
    return 0;

}

static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = PyObject_GetAttr(o, n);
    if (!r) {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError))
            goto bad;
        PyErr_Clear();
        r = d;
        Py_INCREF(d);
    }
    return r;
bad:
    return NULL;
}

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
    if (s1 == s2) {   /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        if (PyBytes_GET_SIZE(s1) != PyBytes_GET_SIZE(s2)) {
            return (equals == Py_NE);
        } else if (PyBytes_GET_SIZE(s1) == 1) {
            if (equals == Py_EQ)
                return (PyBytes_AS_STRING(s1)[0] == PyBytes_AS_STRING(s2)[0]);
            else
                return (PyBytes_AS_STRING(s1)[0] != PyBytes_AS_STRING(s2)[0]);
        } else {
            int result = memcmp(PyBytes_AS_STRING(s1), PyBytes_AS_STRING(s2), (size_t)PyBytes_GET_SIZE(s1));
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
}

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
    if (s1 == s2) {   /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */
        return (equals == Py_EQ);
    } else if (PyUnicode_CheckExact(s1) & PyUnicode_CheckExact(s2)) {
        if (PyUnicode_GET_SIZE(s1) != PyUnicode_GET_SIZE(s2)) {
            return (equals == Py_NE);
        } else if (PyUnicode_GET_SIZE(s1) == 1) {
            if (equals == Py_EQ)
                return (PyUnicode_AS_UNICODE(s1)[0] == PyUnicode_AS_UNICODE(s2)[0]);
            else
                return (PyUnicode_AS_UNICODE(s1)[0] != PyUnicode_AS_UNICODE(s2)[0]);
        } else {
            int result = PyUnicode_Compare(s1, s2);
            if ((result == -1) && unlikely(PyErr_Occurred()))
                return -1;
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyUnicode_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyUnicode_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
}

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return (unsigned long)PyLong_AsUnsignedLong(x);
        } else {
            return (unsigned long)PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return (long)PyLong_AsUnsignedLong(x);
        } else {
            return (long)PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return (signed long)PyLong_AsUnsignedLong(x);
        } else {
            return (signed long)PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        #if PY_VERSION_HEX < 0x02050000
        return PyErr_Warn(NULL, message);
        #else
        return PyErr_WarnEx(NULL, message, 1);
        #endif
    }
    return 0;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno,
                               int __pyx_lineno, const char *__pyx_filename) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple,  /*PyObject *consts,*/
        __pyx_empty_tuple,  /*PyObject *names,*/
        __pyx_empty_tuple,  /*PyObject *varnames,*/
        __pyx_empty_tuple,  /*PyObject *freevars,*/
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}

static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_VERSION_HEX < 0x03000000
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_VERSION_HEX < 0x03000000
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
